2006-12-24 06:25:21 +00:00
|
|
|
#ifndef _D_MOCK_BT_MESSAGE_DISPATCHER_H_
|
|
|
|
#define _D_MOCK_BT_MESSAGE_DISPATCHER_H_
|
|
|
|
|
|
|
|
#include "BtMessageDispatcher.h"
|
2008-11-03 07:16:25 +00:00
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
#include <algorithm>
|
|
|
|
|
2008-11-03 07:16:25 +00:00
|
|
|
#include "BtMessage.h"
|
|
|
|
#include "Piece.h"
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
namespace aria2 {
|
2006-12-24 06:25:21 +00:00
|
|
|
|
|
|
|
class MockBtMessageDispatcher : public BtMessageDispatcher {
|
|
|
|
public:
|
|
|
|
BtMessages messageQueue;
|
|
|
|
|
|
|
|
virtual ~MockBtMessageDispatcher() {}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
virtual void addMessageToQueue(const SharedHandle<BtMessage>& btMessage) {
|
2006-12-24 06:25:21 +00:00
|
|
|
messageQueue.push_back(btMessage);
|
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
virtual void addMessageToQueue(const std::deque<SharedHandle<BtMessage> >& btMessages) {
|
|
|
|
std::copy(btMessages.begin(), btMessages.end(), back_inserter(messageQueue));
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void sendMessages() {}
|
|
|
|
|
2008-03-09 12:24:01 +00:00
|
|
|
virtual void doCancelSendingPieceAction(size_t index, uint32_t begin, size_t length) {}
|
2006-12-24 06:25:21 +00:00
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
virtual void doCancelSendingPieceAction(const SharedHandle<Piece>& piece) {}
|
2006-12-24 06:25:21 +00:00
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
virtual void doAbortOutstandingRequestAction(const SharedHandle<Piece>& piece) {}
|
2006-12-24 06:25:21 +00:00
|
|
|
|
|
|
|
virtual void doChokedAction() {}
|
|
|
|
|
|
|
|
virtual void doChokingAction() {}
|
|
|
|
|
|
|
|
virtual void checkRequestSlotAndDoNecessaryThing() {}
|
|
|
|
|
|
|
|
virtual bool isSendingInProgress() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-03-09 12:24:01 +00:00
|
|
|
virtual size_t countMessageInQueue() {
|
2006-12-24 06:25:21 +00:00
|
|
|
return messageQueue.size();
|
|
|
|
}
|
|
|
|
|
2008-03-09 12:24:01 +00:00
|
|
|
virtual size_t countOutstandingRequest() {
|
2006-12-24 06:25:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-03-09 12:24:01 +00:00
|
|
|
virtual bool isOutstandingRequest(size_t index, size_t blockIndex) {
|
2006-12-24 06:25:21 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-03-09 12:24:01 +00:00
|
|
|
virtual RequestSlot getOutstandingRequest(size_t index, uint32_t begin, size_t length) {
|
2006-12-24 06:25:21 +00:00
|
|
|
return RequestSlot::nullSlot;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void removeOutstandingRequest(const RequestSlot& slot) {}
|
|
|
|
|
|
|
|
virtual void addOutstandingRequest(const RequestSlot& slot) {}
|
2008-04-13 01:25:36 +00:00
|
|
|
|
|
|
|
virtual size_t countOutstandingUpload()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2006-12-24 06:25:21 +00:00
|
|
|
};
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
} // namespace aria2
|
2006-12-24 06:25:21 +00:00
|
|
|
|
|
|
|
#endif // _D_MOCK_BT_MESSAGE_DISPATCHER_H_
|