RequestGroupManTest.cc 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include "RequestGroupMan.h"
  2. #include "CUIDCounter.h"
  3. #include "prefs.h"
  4. #include "SingleFileDownloadContext.h"
  5. #include "RequestGroup.h"
  6. #include "Option.h"
  7. #include "DownloadResult.h"
  8. #include <cppunit/extensions/HelperMacros.h>
  9. using namespace std;
  10. class RequestGroupManTest : public CppUnit::TestFixture {
  11. CPPUNIT_TEST_SUITE(RequestGroupManTest);
  12. CPPUNIT_TEST(testIsSameFileBeingDownloaded);
  13. CPPUNIT_TEST(testGetInitialCommands);
  14. CPPUNIT_TEST_SUITE_END();
  15. private:
  16. public:
  17. void setUp()
  18. {
  19. CUIDCounterHandle counter = new CUIDCounter();
  20. CUIDCounterSingletonHolder::instance(counter);
  21. }
  22. void testIsSameFileBeingDownloaded();
  23. void testGetInitialCommands();
  24. };
  25. CPPUNIT_TEST_SUITE_REGISTRATION( RequestGroupManTest );
  26. void RequestGroupManTest::testIsSameFileBeingDownloaded()
  27. {
  28. Option option;
  29. Strings uris;
  30. uris.push_back("http://localhost/aria2.tar.bz2");
  31. RequestGroupHandle rg1 = new RequestGroup(&option, uris);
  32. RequestGroupHandle rg2 = new RequestGroup(&option, uris);
  33. SingleFileDownloadContextHandle dctx1 =
  34. new SingleFileDownloadContext(0, 0, "aria2.tar.bz2");
  35. SingleFileDownloadContextHandle dctx2 =
  36. new SingleFileDownloadContext(0, 0, "aria2.tar.bz2");
  37. rg1->setDownloadContext(dctx1);
  38. rg2->setDownloadContext(dctx2);
  39. RequestGroups rgs;
  40. rgs.push_back(rg1);
  41. rgs.push_back(rg2);
  42. RequestGroupMan gm(rgs, 1);
  43. CPPUNIT_ASSERT(gm.isSameFileBeingDownloaded(rg1.get()));
  44. dctx2->setFilename("aria2.tar.gz");
  45. CPPUNIT_ASSERT(!gm.isSameFileBeingDownloaded(rg1.get()));
  46. }
  47. void RequestGroupManTest::testGetInitialCommands()
  48. {
  49. // TODO implement later
  50. }