mirror of
https://github.com/aria2/aria2.git
synced 2025-02-13 02:21:05 +00:00
![Tatsuhiro Tsujikawa](/assets/img/avatar_default.png)
Rewritten SharedHandle. Now copy constructor taking raw pointer has keyword explicit and SharedHandle's default constructor initializes its internal obj to null, old implementation initializes it using obj's default constructor. To assign null, write SharedHandle<T> x(...); x.reset(); TODO: test/SharedHandleTest.cc needs more tests. * src/SharedHandle.h
72 lines
1.7 KiB
C++
72 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 <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);
|
|
|
|
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
|