#include "DefaultExtensionMessageFactory.h" #include #include #include "Peer.h" #include "MockPeerStorage.h" #include "bittorrent_helper.h" #include "HandshakeExtensionMessage.h" #include "UTPexExtensionMessage.h" #include "Exception.h" #include "FileEntry.h" #include "ExtensionMessageRegistry.h" #include "DownloadContext.h" #include "MockBtMessageDispatcher.h" #include "MockBtMessageFactory.h" #include "DownloadContext.h" #include "BtHandshakeMessage.h" #include "UTMetadataRequestExtensionMessage.h" #include "UTMetadataDataExtensionMessage.h" #include "UTMetadataRejectExtensionMessage.h" #include "BtRuntime.h" #include "PieceStorage.h" #include "RequestGroup.h" #include "Option.h" namespace aria2 { class DefaultExtensionMessageFactoryTest:public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(DefaultExtensionMessageFactoryTest); CPPUNIT_TEST(testCreateMessage_unknown); CPPUNIT_TEST(testCreateMessage_Handshake); CPPUNIT_TEST(testCreateMessage_UTPex); CPPUNIT_TEST(testCreateMessage_UTMetadataRequest); CPPUNIT_TEST(testCreateMessage_UTMetadataData); CPPUNIT_TEST(testCreateMessage_UTMetadataReject); CPPUNIT_TEST_SUITE_END(); private: std::unique_ptr peerStorage_; std::shared_ptr peer_; std::unique_ptr factory_; std::unique_ptr registry_; std::unique_ptr dispatcher_; std::unique_ptr messageFactory_; std::shared_ptr dctx_; std::unique_ptr requestGroup_; public: void setUp() { peerStorage_ = make_unique(); peer_ = std::make_shared("192.168.0.1", 6969); peer_->allocateSessionResource(1024, 1024*1024); peer_->setExtension(ExtensionMessageRegistry::UT_PEX, 1); registry_ = make_unique(); dispatcher_ = make_unique(); messageFactory_ = make_unique(); dctx_ = std::make_shared(); auto option = std::make_shared