mirror of
https://github.com/aria2/aria2.git
synced 2025-04-06 14:07:37 +03:00
Now RequestGroup has its own copy of Option object. This will help to give custom option for each RequestGroup. addTorrentFile command now takes options. * src/AbstractCommand.cc * src/AbstractCommand.h * src/AbstractProxyRequestCommand.cc * src/ActivePeerConnectionCommand.cc * src/ActivePeerConnectionCommand.h * src/AdaptiveURISelector.cc * src/BtCheckIntegrityEntry.cc * src/BtDependency.cc * src/BtDependency.h * src/BtFileAllocationEntry.cc * src/BtPostDownloadHandler.cc * src/CheckIntegrityEntry.cc * src/DownloadCommand.cc * src/FtpDownloadCommand.cc * src/FtpFinishDownloadCommand.cc * src/FtpInitiateConnectionCommand.cc * src/FtpNegotiationCommand.cc * src/HttpInitiateConnectionCommand.cc * src/HttpRequestCommand.cc * src/HttpResponseCommand.cc * src/HttpSkipResponseCommand.cc * src/InitiateConnectionCommand.cc * src/InitiateConnectionCommandFactory.cc * src/InitiatorMSEHandshakeCommand.cc * src/InitiatorMSEHandshakeCommand.h * src/Metalink2RequestGroup.cc * src/Metalink2RequestGroup.h * src/MetalinkPostDownloadHandler.cc * src/MultiUrlRequestInfo.cc * src/MultiUrlRequestInfo.h * src/PeerAbstractCommand.cc * src/PeerInteractionCommand.cc * src/PeerInteractionCommand.h * src/PeerReceiveHandshakeCommand.cc * src/PeerReceiveHandshakeCommand.h * src/RequestGroup.cc * src/RequestGroup.h * src/TrackerWatcherCommand.cc * src/TrackerWatcherCommand.h * src/XmlRpcMethod.cc * src/XmlRpcMethod.h * src/XmlRpcMethodImpl.cc * src/download_helper.cc * src/download_helper.h * src/main.cc * test/BtDependencyTest.cc * test/BtPostDownloadHandlerTest.cc * test/DefaultBtMessageDispatcherTest.cc * test/DownloadHandlerFactoryTest.cc * test/DownloadHelperTest.cc * test/Metalink2RequestGroupTest.cc * test/MetalinkPostDownloadHandlerTest.cc * test/RequestGroupManTest.cc * test/RequestGroupTest.cc
119 lines
3.4 KiB
C++
119 lines
3.4 KiB
C++
#include "DownloadHandlerFactory.h"
|
|
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
#include "RequestGroup.h"
|
|
#include "Option.h"
|
|
#include "SingleFileDownloadContext.h"
|
|
#include "MemoryBufferPreDownloadHandler.h"
|
|
#include "FileEntry.h"
|
|
|
|
namespace aria2 {
|
|
|
|
class DownloadHandlerFactoryTest:public CppUnit::TestFixture {
|
|
|
|
CPPUNIT_TEST_SUITE(DownloadHandlerFactoryTest);
|
|
#ifdef ENABLE_METALINK
|
|
CPPUNIT_TEST(testGetMetalinkPreDownloadHandler_extension);
|
|
CPPUNIT_TEST(testGetMetalinkPreDownloadHandler_contentType);
|
|
#endif // ENABLE_METALINK
|
|
|
|
#ifdef ENABLE_BITTORRENT
|
|
CPPUNIT_TEST(testGetBtPreDownloadHandler_extension);
|
|
CPPUNIT_TEST(testGetBtPreDownloadHandler_contentType);
|
|
#endif // ENABLE_BITTORRENT
|
|
|
|
CPPUNIT_TEST_SUITE_END();
|
|
private:
|
|
SharedHandle<Option> _option;
|
|
public:
|
|
void setUp()
|
|
{
|
|
_option.reset(new Option());
|
|
}
|
|
#ifdef ENABLE_METALINK
|
|
void testGetMetalinkPreDownloadHandler_extension();
|
|
void testGetMetalinkPreDownloadHandler_contentType();
|
|
#endif // ENABLE_METALINK
|
|
|
|
#ifdef ENABLE_BITTORRENT
|
|
void testGetBtPreDownloadHandler_extension();
|
|
void testGetBtPreDownloadHandler_contentType();
|
|
#endif // ENABLE_BITTORRENT
|
|
|
|
};
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION( DownloadHandlerFactoryTest );
|
|
|
|
#ifdef ENABLE_METALINK
|
|
|
|
void DownloadHandlerFactoryTest::testGetMetalinkPreDownloadHandler_extension()
|
|
{
|
|
SharedHandle<SingleFileDownloadContext> dctx
|
|
(new SingleFileDownloadContext(0, 0, "test.metalink"));
|
|
RequestGroup rg(_option, std::deque<std::string>());
|
|
rg.setDownloadContext(dctx);
|
|
|
|
SharedHandle<PreDownloadHandler> handler = DownloadHandlerFactory::getMetalinkPreDownloadHandler();
|
|
|
|
CPPUNIT_ASSERT(handler->canHandle(&rg));
|
|
|
|
dctx->setFilename("test.metalink2");
|
|
CPPUNIT_ASSERT(!handler->canHandle(&rg));
|
|
}
|
|
|
|
void DownloadHandlerFactoryTest::testGetMetalinkPreDownloadHandler_contentType()
|
|
{
|
|
SharedHandle<SingleFileDownloadContext> dctx
|
|
(new SingleFileDownloadContext(0, 0, "test"));
|
|
dctx->setContentType("application/metalink+xml");
|
|
RequestGroup rg(_option, std::deque<std::string>());
|
|
rg.setDownloadContext(dctx);
|
|
|
|
SharedHandle<PreDownloadHandler> handler = DownloadHandlerFactory::getMetalinkPreDownloadHandler();
|
|
|
|
CPPUNIT_ASSERT(handler->canHandle(&rg));
|
|
|
|
dctx->setContentType("application/octet-stream");
|
|
CPPUNIT_ASSERT(!handler->canHandle(&rg));
|
|
}
|
|
|
|
#endif // ENABLE_METALINK
|
|
|
|
#ifdef ENABLE_BITTORRENT
|
|
|
|
void DownloadHandlerFactoryTest::testGetBtPreDownloadHandler_extension()
|
|
{
|
|
SharedHandle<SingleFileDownloadContext> dctx
|
|
(new SingleFileDownloadContext(0, 0, "test.torrent"));
|
|
RequestGroup rg(_option, std::deque<std::string>());
|
|
rg.setDownloadContext(dctx);
|
|
|
|
SharedHandle<PreDownloadHandler> handler = DownloadHandlerFactory::getBtPreDownloadHandler();
|
|
|
|
CPPUNIT_ASSERT(handler->canHandle(&rg));
|
|
|
|
dctx->setFilename("test.torrent2");
|
|
CPPUNIT_ASSERT(!handler->canHandle(&rg));
|
|
}
|
|
|
|
void DownloadHandlerFactoryTest::testGetBtPreDownloadHandler_contentType()
|
|
{
|
|
SharedHandle<SingleFileDownloadContext> dctx
|
|
(new SingleFileDownloadContext(0, 0, "test"));
|
|
dctx->setContentType("application/x-bittorrent");
|
|
RequestGroup rg(_option, std::deque<std::string>());
|
|
rg.setDownloadContext(dctx);
|
|
|
|
SharedHandle<PreDownloadHandler> handler = DownloadHandlerFactory::getBtPreDownloadHandler();
|
|
|
|
CPPUNIT_ASSERT(handler->canHandle(&rg));
|
|
|
|
dctx->setContentType("application/octet-stream");
|
|
CPPUNIT_ASSERT(!handler->canHandle(&rg));
|
|
}
|
|
|
|
#endif // ENABLE_BITTORRENT
|
|
|
|
} // namespace aria2
|