mirror of
https://github.com/aria2/aria2.git
synced 2026-04-02 18:59:20 +00:00
* src/FileAllocationCommand.cc: Derived from RealtimeCommand. * src/CheckIntegrityCommand.cc: Derived from RealtimeCommand. * src/MetalinkEntry.h (checksum): Changed to ChecksumHandle * src/MetalinkRequestInfo.cc (checksum): Changed to ChecksumHandle * src/File.cc (mkdirs): OPEN_MODE -> DIR_OPEN_MODE * src/common.h (DIR_OPEN_MODE): New definition * src/RequestGroup.cc (prepareForNextAction): Added an argument. * src/message.h (MSG_GOOD_CHECKSUM): New definition (MSG_BAD_CHECKSUM): New definition * src/HttpResponseCommand.cc (handleDefaultEncoding): Continue download sequence in new non-segmented download. * src/FileAllocationEntry.h (_nextDownloadCommand): New variable. * src/DownloadCommand.cc (prepareForNextSegment): Create ChecksumCommand if checksum is available. * src/RealtimeCommand.h, src/RealtimeCommand.cc: New class. * src/IteratableChecksumValidator.h, src/IteratableChecksumValidator.cc: New class. * src/ChecksumCommand.h, src/ChecksumCommand.cc: New class.
95 lines
2.8 KiB
C++
95 lines
2.8 KiB
C++
#include "TrackerWatcherCommand.h"
|
|
#include "TorrentConsoleDownloadEngine.h"
|
|
#include "MetaFileUtil.h"
|
|
#include "Exception.h"
|
|
#include "prefs.h"
|
|
#include "HttpInitiateConnectionCommand.h"
|
|
#include "ByteArrayDiskWriter.h"
|
|
#include "DefaultBtContext.h"
|
|
#include "DefaultBtAnnounce.h"
|
|
#include "DefaultPieceStorage.h"
|
|
#include "DefaultPeerStorage.h"
|
|
#include "BtRegistry.h"
|
|
#include "RequestFactory.h"
|
|
#include "CUIDCounter.h"
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
using namespace std;
|
|
|
|
class TrackerWatcherCommandTest:public CppUnit::TestFixture {
|
|
|
|
CPPUNIT_TEST_SUITE(TrackerWatcherCommandTest);
|
|
CPPUNIT_TEST(testCreateCommand);
|
|
CPPUNIT_TEST_SUITE_END();
|
|
private:
|
|
Option* op;
|
|
public:
|
|
TrackerWatcherCommandTest():op(new Option())
|
|
{
|
|
op->put(PREF_TRACKER_MAX_TRIES, "10");
|
|
RequestFactoryHandle requestFactory = new RequestFactory();
|
|
requestFactory->setOption(op);
|
|
RequestFactorySingletonHolder::instance(requestFactory);
|
|
}
|
|
|
|
void setUp()
|
|
{
|
|
CUIDCounterHandle counter = new CUIDCounter();
|
|
CUIDCounterSingletonHolder::instance(counter);
|
|
}
|
|
|
|
void testCreateCommand();
|
|
};
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION( TrackerWatcherCommandTest );
|
|
|
|
void TrackerWatcherCommandTest::testCreateCommand() {
|
|
try {
|
|
|
|
BtContextHandle btContext(new DefaultBtContext());
|
|
btContext->load("test.torrent");
|
|
|
|
BtRuntimeHandle btRuntime;
|
|
BtRegistry::registerBtRuntime(btContext->getInfoHashAsString(), btRuntime);
|
|
|
|
PieceStorageHandle pieceStorage(new DefaultPieceStorage(btContext, op));
|
|
BtRegistry::registerPieceStorage(btContext->getInfoHashAsString(),
|
|
pieceStorage);
|
|
|
|
PeerStorageHandle peerStorage(new DefaultPeerStorage(btContext, op));
|
|
BtRegistry::registerPeerStorage(btContext->getInfoHashAsString(),
|
|
peerStorage);
|
|
|
|
BtAnnounceHandle btAnnounce(new DefaultBtAnnounce(btContext, op));
|
|
BtRegistry::registerBtAnnounce(btContext->getInfoHashAsString(), btAnnounce);
|
|
TorrentConsoleDownloadEngine* te = new TorrentConsoleDownloadEngine();
|
|
te->option = op;
|
|
te->_requestGroupMan = new RequestGroupMan();
|
|
|
|
TrackerWatcherCommand command(1, te, btContext);
|
|
|
|
CPPUNIT_ASSERT(dynamic_cast<HttpInitiateConnectionCommand*>(command.createCommand()));
|
|
//cerr << btAnnounce->getAnnounceUrl() << endl;
|
|
|
|
btAnnounce->announceSuccess();
|
|
btAnnounce->resetAnnounce();
|
|
te->_requestGroupMan = new RequestGroupMan();
|
|
|
|
btRuntime->setHalt(true);
|
|
|
|
CPPUNIT_ASSERT(dynamic_cast<HttpInitiateConnectionCommand*>(command.createCommand()));
|
|
//cerr << btAnnounce->getAnnounceUrl() << endl;
|
|
|
|
btAnnounce->announceSuccess();
|
|
btAnnounce->resetAnnounce();
|
|
te->_requestGroupMan = new RequestGroupMan();
|
|
|
|
CPPUNIT_ASSERT(btAnnounce->noMoreAnnounce());
|
|
|
|
} catch(Exception* e) {
|
|
cerr << e->getMsg() << endl;
|
|
delete e;
|
|
}
|
|
}
|