blob: e64a16256ed4118ec6badc17a35e69201f727f5a [file] [log] [blame]
Junxiao Shicbba04c2014-01-26 14:21:22 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (C) 2014 Named Data Networking Project
4 * See COPYING for copyright and distribution information.
5 */
6
7#ifndef NFD_TEST_FACE_DUMMY_FACE_HPP
8#define NFD_TEST_FACE_DUMMY_FACE_HPP
9
10#include "face/face.hpp"
Alexander Afanasyevbd220a02014-02-20 00:29:56 -080011#include "face/local-face.hpp"
Junxiao Shicbba04c2014-01-26 14:21:22 -070012
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080013namespace nfd {
Junxiao Shid9ee45c2014-02-27 15:38:11 -070014namespace tests {
Junxiao Shicbba04c2014-01-26 14:21:22 -070015
16/** \class DummyFace
Junxiao Shi9b27bd22014-02-26 20:29:58 -070017 * \brief a Face for unit testing
Junxiao Shicbba04c2014-01-26 14:21:22 -070018 */
Alexander Afanasyevbd220a02014-02-20 00:29:56 -080019template<class FaceBase>
20class DummyFaceImpl : public FaceBase
Junxiao Shicbba04c2014-01-26 14:21:22 -070021{
22public:
Alexander Afanasyeva39b90b2014-03-05 15:31:00 +000023 DummyFaceImpl()
24 : FaceBase(FaceUri("dummy://"))
25 {
26 }
27
Junxiao Shicbba04c2014-01-26 14:21:22 -070028 virtual void
Junxiao Shi8c8d2182014-01-30 22:33:00 -070029 sendInterest(const Interest& interest)
Junxiao Shicbba04c2014-01-26 14:21:22 -070030 {
Junxiao Shi9b27bd22014-02-26 20:29:58 -070031 m_sentInterests.push_back(interest);
32 this->afterSend();
Junxiao Shicbba04c2014-01-26 14:21:22 -070033 }
Junxiao Shi9b27bd22014-02-26 20:29:58 -070034
Junxiao Shicbba04c2014-01-26 14:21:22 -070035 virtual void
Junxiao Shi8c8d2182014-01-30 22:33:00 -070036 sendData(const Data& data)
Junxiao Shicbba04c2014-01-26 14:21:22 -070037 {
Junxiao Shi9b27bd22014-02-26 20:29:58 -070038 m_sentDatas.push_back(data);
39 this->afterSend();
Junxiao Shicbba04c2014-01-26 14:21:22 -070040 }
Alexander Afanasyeva0a10fb2014-02-13 19:56:15 -080041
42 virtual void
43 close()
44 {
45 }
Alexander Afanasyev93ce75e2014-02-18 19:45:34 -080046
Junxiao Shi9b27bd22014-02-26 20:29:58 -070047 void
48 receiveInterest(const Interest& interest)
49 {
50 this->onReceiveInterest(interest);
51 }
52
53 void
54 receiveData(const Data& data)
55 {
56 this->onReceiveData(data);
57 }
58
Junxiao Shid9ee45c2014-02-27 15:38:11 -070059 EventEmitter<> afterSend;
Junxiao Shi9b27bd22014-02-26 20:29:58 -070060
61public:
62 std::vector<Interest> m_sentInterests;
63 std::vector<Data> m_sentDatas;
Junxiao Shicbba04c2014-01-26 14:21:22 -070064};
65
Alexander Afanasyevbd220a02014-02-20 00:29:56 -080066typedef DummyFaceImpl<Face> DummyFace;
67typedef DummyFaceImpl<LocalFace> DummyLocalFace;
68
Junxiao Shid9ee45c2014-02-27 15:38:11 -070069} // namespace tests
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080070} // namespace nfd
Junxiao Shicbba04c2014-01-26 14:21:22 -070071
72#endif // TEST_FACE_DUMMY_FACE_HPP