2009-11-23 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Fixed ut_metadata data handling. Implemented
	UTMetadataDataExtensionMessage::doReceivedAction().  Initialize
	PeerStorage in HandshakeExtensionMessage::doReceivedAction() when
	metadata_size is received.
	* src/DefaultExtensionMessageFactory.cc
	* src/DefaultExtensionMessageFactory.h
	* src/HandshakeExtensionMessage.cc
	* src/HandshakeExtensionMessage.h
	* src/UTMetadataDataExtensionMessage.cc
	* src/UTMetadataDataExtensionMessage.h
	* src/UTMetadataRequestExtensionMessage.cc
	* src/UTMetadataRequestFactory.cc
	* src/UTMetadataRequestFactory.h
	* src/UTMetadataRequestTracker.cc
	* src/UTMetadataRequestTracker.h
	* test/DefaultExtensionMessageFactoryTest.cc
	* test/HandshakeExtensionMessageTest.cc
	* test/MockBtMessage.h
	* test/UTMetadataDataExtensionMessageTest.cc
	* test/UTMetadataRequestExtensionMessageTest.cc
	* test/UTMetadataRequestFactoryTest.cc
	* test/UTMetadataRequestTrackerTest.cc
	* test/extension_message_test_helper.h
This commit is contained in:
Tatsuhiro Tsujikawa 2009-11-22 15:31:47 +00:00
parent b563621dd1
commit c1730aeea9
20 changed files with 813 additions and 64 deletions

View file

@ -13,6 +13,9 @@
#include "BtHandshakeMessage.h"
#include "UTMetadataRejectExtensionMessage.h"
#include "UTMetadataDataExtensionMessage.h"
#include "PieceStorage.h"
#include "BtRuntime.h"
#include "extension_message_test_helper.h"
namespace aria2 {
@ -27,30 +30,14 @@ class UTMetadataRequestExtensionMessageTest:public CppUnit::TestFixture {
CPPUNIT_TEST(testDoReceivedAction_data);
CPPUNIT_TEST_SUITE_END();
public:
class MockExtensionMessage:public MockBtMessage {
public:
SharedHandle<ExtensionMessage> _m;
MockExtensionMessage(const SharedHandle<ExtensionMessage>& m):_m(m) {}
};
class MockBtMessageFactory2:public MockBtMessageFactory {
public:
virtual SharedHandle<BtMessage>
createBtExtendedMessage(const SharedHandle<ExtensionMessage>& extmsg)
{
return SharedHandle<BtMessage>(new MockExtensionMessage(extmsg));
}
};
SharedHandle<DownloadContext> _dctx;
SharedHandle<MockBtMessageFactory2> _messageFactory;
SharedHandle<WrapExtBtMessageFactory> _messageFactory;
SharedHandle<MockBtMessageDispatcher> _dispatcher;
SharedHandle<Peer> _peer;
void setUp()
{
_messageFactory.reset(new MockBtMessageFactory2());
_messageFactory.reset(new WrapExtBtMessageFactory());
_dispatcher.reset(new MockBtMessageDispatcher());
_dctx.reset(new DownloadContext());
BDE attrs = BDE::dict();
@ -63,8 +50,8 @@ public:
template<typename T>
SharedHandle<T> getFirstDispatchedMessage()
{
SharedHandle<MockExtensionMessage> wrapmsg =
dynamic_pointer_cast<MockExtensionMessage>
SharedHandle<WrapExtBtMessage> wrapmsg =
dynamic_pointer_cast<WrapExtBtMessage>
(_dispatcher->messageQueue.front());
SharedHandle<T> msg = dynamic_pointer_cast<T>(wrapmsg->_m);