aria2/test/MockExtensionMessage.h

52 lines
1.1 KiB
C++

#ifndef _D_MOCK_EXTENSION_MESSAGE_H_
#define _D_MOCK_EXTENSION_MESSAGE_H_
#include "ExtensionMessage.h"
class MockExtensionMessage:public ExtensionMessage {
public:
string _extensionName;
uint8_t _extensionMessageID;
string _data;
bool _doReceivedActionCalled;
public:
MockExtensionMessage(const string& extensionName,
uint8_t extensionMessageID,
const char* data,
size_t length):_extensionName(extensionName),
_extensionMessageID(extensionMessageID),
_data(&data[0], &data[length]),
_doReceivedActionCalled(false) {}
virtual ~MockExtensionMessage() {}
virtual string getBencodedData()
{
return _data;
}
virtual uint8_t getExtensionMessageID()
{
return _extensionMessageID;
}
virtual const string& getExtensionName() const
{
return _extensionName;
}
virtual string toString() const
{
return _extensionName;
}
virtual void doReceivedAction()
{
_doReceivedActionCalled = true;
}
};
typedef SharedHandle<MockExtensionMessage> MockExtensionMessageHandle;
#endif // _D_MOCK_EXTENSION_MESSAGE_H_