aria2/test/RequestGroupManTest.cc
Tatsuhiro Tsujikawa d64c8e75f6 2008-08-05 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Implemented download speed based URI selection algorithm.
	Introduced new option --uri-selector.
	If --uri-selector=feedback is given, aria2 uses download speed 
observed
	in the previous downloads and chooses fastest server in the URI 
list.
	Currently at most 10 URIs are considered to introduce 
randomeness for
	finding better servers. The speed is average download speed in 
the
	downloads.
	On the other hand, if --uri-selector=inorder is given, which is 
default,
	URI is tried in order in URI list.
	The usage text for the new option has not been written yet.
	* src/AbstractCommand.cc
	* src/DownloadCommand.cc
	* src/DownloadEngine.cc
	* src/DownloadEngineFactory.cc
	* src/InOrderURISelector.cc
	* src/InOrderURISelector.h
	* src/OptionHandlerFactory.cc
	* src/PeerStat.h
	* src/RequestGroup.cc
	* src/RequestGroup.h
	* src/RequestGroupMan.cc
	* src/RequestGroupMan.h
	* src/SegmentMan.cc
	* src/SegmentMan.h
	* src/ServerStat.cc
	* src/ServerStat.h
	* src/ServerStatMan.cc
	* src/ServerStatMan.h
	* src/ServerStatURISelector.cc
	* src/ServerStatURISelector.h
	* src/URISelector.h
	* src/option_processing.cc
	* src/prefs.cc
	* src/prefs.h
	* test/InOrderURISelectorTest.cc
	* test/RequestGroupManTest.cc
	* test/ServerStatManTest.cc
	* test/ServerStatURISelectorTest.cc
2008-08-04 17:06:47 +00:00

73 lines
1.7 KiB
C++

#include "RequestGroupMan.h"
#include "CUIDCounter.h"
#include "prefs.h"
#include "SingleFileDownloadContext.h"
#include "RequestGroup.h"
#include "Option.h"
#include "DownloadResult.h"
#include "FileEntry.h"
#include "ServerStatMan.h"
#include <cppunit/extensions/HelperMacros.h>
namespace aria2 {
class RequestGroupManTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(RequestGroupManTest);
CPPUNIT_TEST(testIsSameFileBeingDownloaded);
CPPUNIT_TEST(testGetInitialCommands);
CPPUNIT_TEST_SUITE_END();
private:
public:
void setUp()
{
SharedHandle<CUIDCounter> counter(new CUIDCounter());
SingletonHolder<SharedHandle<CUIDCounter> >::instance(counter);
}
void testIsSameFileBeingDownloaded();
void testGetInitialCommands();
};
CPPUNIT_TEST_SUITE_REGISTRATION( RequestGroupManTest );
void RequestGroupManTest::testIsSameFileBeingDownloaded()
{
Option option;
std::deque<std::string> uris;
uris.push_back("http://localhost/aria2.tar.bz2");
SharedHandle<RequestGroup> rg1(new RequestGroup(&option, uris));
SharedHandle<RequestGroup> rg2(new RequestGroup(&option, uris));
SharedHandle<SingleFileDownloadContext> dctx1
(new SingleFileDownloadContext(0, 0, "aria2.tar.bz2"));
SharedHandle<SingleFileDownloadContext> dctx2
(new SingleFileDownloadContext(0, 0, "aria2.tar.bz2"));
rg1->setDownloadContext(dctx1);
rg2->setDownloadContext(dctx2);
RequestGroups rgs;
rgs.push_back(rg1);
rgs.push_back(rg2);
RequestGroupMan gm(rgs, 1, &option);
CPPUNIT_ASSERT(gm.isSameFileBeingDownloaded(rg1.get()));
dctx2->setFilename("aria2.tar.gz");
CPPUNIT_ASSERT(!gm.isSameFileBeingDownloaded(rg1.get()));
}
void RequestGroupManTest::testGetInitialCommands()
{
// TODO implement later
}
} // namespace aria2