mirror of
https://github.com/aria2/aria2.git
synced 2025-01-09 03:21:33 +00:00
7cf589e784
Made BtRegistry non-static object. Now DownloadEngine has a reference to its object. * src/AbstractBtMessage.cc * src/ActivePeerConnectionCommand.cc * src/ActivePeerConnectionCommand.h * src/BtContextAwareCommand.cc * src/BtContextAwareCommand.h * src/BtExtendedMessage.cc * src/BtExtendedMessage.h * src/BtInterestedMessage.cc * src/BtInterestedMessage.h * src/BtNotInterestedMessage.cc * src/BtNotInterestedMessage.h * src/BtRegistry.cc * src/BtRegistry.h * src/BtSeederStateChoke.cc * src/BtSetup.cc * src/DHTGetPeersCommand.cc * src/DHTGetPeersCommand.h * src/DHTPeerAnnounceEntry.cc * src/DHTPeerAnnounceEntry.h * src/DHTPeerAnnounceStorage.cc * src/DHTPeerAnnounceStorage.h * src/DHTPeerLookupTask.cc * src/DHTPeerLookupTask.h * src/DHTSetup.cc * src/DHTSetup.h * src/DHTTaskFactory.h * src/DHTTaskFactoryImpl.cc * src/DHTTaskFactoryImpl.h * src/DefaultBtAnnounce.cc * src/DefaultBtInteractive.cc * src/DefaultBtInteractive.h * src/DefaultBtMessageDispatcher.cc * src/DefaultBtMessageDispatcher.h * src/DefaultBtMessageFactory.cc * src/DefaultBtMessageFactory.h * src/DefaultBtMessageReceiver.cc * src/DefaultBtProgressInfoFile.cc * src/DefaultBtProgressInfoFile.h * src/DefaultBtRequestFactory.cc * src/DefaultBtRequestFactory.h * src/DefaultExtensionMessageFactory.cc * src/DefaultExtensionMessageFactory.h * src/DefaultPeerStorage.cc * src/DefaultPeerStorage.h * src/DownloadEngine.cc * src/DownloadEngine.h * src/InitiatorMSEHandshakeCommand.cc * src/InitiatorMSEHandshakeCommand.h * src/MSEHandshake.cc * src/MSEHandshake.h * src/Makefile.am * src/Makefile.in * src/PeerChokeCommand.cc * src/PeerChokeCommand.h * src/PeerInitiateConnectionCommand.cc * src/PeerInitiateConnectionCommand.h * src/PeerInteractionCommand.cc * src/PeerInteractionCommand.h * src/PeerObject.h * src/PeerReceiveHandshakeCommand.cc * src/PeerReceiveHandshakeCommand.h * src/ReceiverMSEHandshakeCommand.cc * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/RequestGroupMan.h * src/SeedCheckCommand.cc * src/SeedCheckCommand.h * src/ShareRatioSeedCriteria.h * src/SimpleBtMessage.cc * src/TrackerWatcherCommand.cc * src/TrackerWatcherCommand.h * src/UTPexExtensionMessage.cc * src/UTPexExtensionMessage.h * test/BtCancelMessageTest.cc * test/BtChokeMessageTest.cc * test/BtExtendedMessageTest.cc * test/BtInterestedMessageTest.cc * test/BtNotInterestedMessageTest.cc * test/BtPieceMessageTest.cc * test/BtPortMessageTest.cc * test/BtRegistryTest.cc * test/BtRejectMessageTest.cc * test/BtRequestMessageTest.cc * test/DHTPeerAnnounceEntryTest.cc * test/DHTPeerAnnounceStorageTest.cc * test/DefaultBtMessageDispatcherTest.cc * test/DefaultBtMessageFactoryTest.cc * test/DefaultBtProgressInfoFileTest.cc * test/DefaultBtRequestFactoryTest.cc * test/DefaultExtensionMessageFactoryTest.cc * test/MSEHandshakeTest.cc * test/MockDHTTaskFactory.h * test/ShareRatioSeedCriteriaTest.cc * test/UTPexExtensionMessageTest.cc
106 lines
2.9 KiB
C++
106 lines
2.9 KiB
C++
#include "BtRegistry.h"
|
|
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
#include "Exception.h"
|
|
#include "MockBtContext.h"
|
|
#include "MockPeerStorage.h"
|
|
#include "MockPieceStorage.h"
|
|
#include "MockBtAnnounce.h"
|
|
#include "MockBtProgressInfoFile.h"
|
|
#include "BtRuntime.h"
|
|
#include "FileEntry.h"
|
|
|
|
namespace aria2 {
|
|
|
|
class BtRegistryTest:public CppUnit::TestFixture {
|
|
|
|
CPPUNIT_TEST_SUITE(BtRegistryTest);
|
|
CPPUNIT_TEST(testGetBtContext);
|
|
CPPUNIT_TEST(testGetPeerStorage);
|
|
CPPUNIT_TEST(testGetPieceStorage);
|
|
CPPUNIT_TEST(testGetBtRuntime);
|
|
CPPUNIT_TEST(testGetBtAnnounce);
|
|
CPPUNIT_TEST(testGetBtProgressInfoFile);
|
|
CPPUNIT_TEST_SUITE_END();
|
|
private:
|
|
|
|
public:
|
|
void testGetBtContext();
|
|
void testGetPeerStorage();
|
|
void testGetPieceStorage();
|
|
void testGetBtRuntime();
|
|
void testGetBtAnnounce();
|
|
void testGetBtProgressInfoFile();
|
|
};
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION( BtRegistryTest );
|
|
|
|
void BtRegistryTest::testGetBtContext()
|
|
{
|
|
BtRegistry btRegistry;
|
|
CPPUNIT_ASSERT(btRegistry.getBtContext("test").isNull());
|
|
SharedHandle<BtContext> btContext(new MockBtContext());
|
|
btRegistry.registerBtContext("test", btContext);
|
|
CPPUNIT_ASSERT_EQUAL(btContext.get(),
|
|
btRegistry.getBtContext("test").get());
|
|
}
|
|
|
|
void BtRegistryTest::testGetPeerStorage() {
|
|
BtRegistry btRegistry;
|
|
CPPUNIT_ASSERT(!btRegistry.getPeerStorage("test").get());
|
|
|
|
SharedHandle<PeerStorage> peerStorage(new MockPeerStorage());
|
|
|
|
btRegistry.registerPeerStorage("test", peerStorage);
|
|
CPPUNIT_ASSERT_EQUAL(peerStorage.get(),
|
|
btRegistry.getPeerStorage("test").get());
|
|
}
|
|
|
|
void BtRegistryTest::testGetPieceStorage() {
|
|
BtRegistry btRegistry;
|
|
CPPUNIT_ASSERT(!btRegistry.getPieceStorage("test").get());
|
|
|
|
SharedHandle<PieceStorage> pieceStorage(new MockPieceStorage());
|
|
|
|
btRegistry.registerPieceStorage("test", pieceStorage);
|
|
CPPUNIT_ASSERT_EQUAL(pieceStorage.get(),
|
|
btRegistry.getPieceStorage("test").get());
|
|
}
|
|
|
|
void BtRegistryTest::testGetBtRuntime() {
|
|
BtRegistry btRegistry;
|
|
CPPUNIT_ASSERT(!btRegistry.getBtRuntime("test").get());
|
|
|
|
SharedHandle<BtRuntime> runtime;
|
|
|
|
btRegistry.registerBtRuntime("test", runtime);
|
|
CPPUNIT_ASSERT_EQUAL(runtime.get(),
|
|
btRegistry.getBtRuntime("test").get());
|
|
}
|
|
|
|
void BtRegistryTest::testGetBtAnnounce() {
|
|
BtRegistry btRegistry;
|
|
CPPUNIT_ASSERT(!btRegistry.getBtAnnounce("test").get());
|
|
|
|
SharedHandle<BtAnnounce> btAnnounce(new MockBtAnnounce());
|
|
|
|
btRegistry.registerBtAnnounce("test", btAnnounce);
|
|
CPPUNIT_ASSERT_EQUAL(btAnnounce.get(),
|
|
btRegistry.getBtAnnounce("test").get());
|
|
}
|
|
|
|
void BtRegistryTest::testGetBtProgressInfoFile() {
|
|
BtRegistry btRegistry;
|
|
CPPUNIT_ASSERT(!btRegistry.getBtProgressInfoFile("test").get());
|
|
|
|
SharedHandle<BtProgressInfoFile> btProgressInfoFile(new MockBtProgressInfoFile());
|
|
|
|
btRegistry.registerBtProgressInfoFile("test", btProgressInfoFile);
|
|
CPPUNIT_ASSERT_EQUAL(btProgressInfoFile.get(),
|
|
btRegistry.getBtProgressInfoFile("test").get());
|
|
}
|
|
|
|
} // namespace aria2
|