Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 1 | /* -*- 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 Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 11 | #include "face/local-face.hpp" |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 12 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 13 | namespace nfd { |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 14 | namespace tests { |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 15 | |
16 | /** \class DummyFace | ||||
Junxiao Shi | 9b27bd2 | 2014-02-26 20:29:58 -0700 | [diff] [blame] | 17 | * \brief a Face for unit testing |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 18 | */ |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 19 | template<class FaceBase> |
20 | class DummyFaceImpl : public FaceBase | ||||
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 21 | { |
22 | public: | ||||
Alexander Afanasyev | a39b90b | 2014-03-05 15:31:00 +0000 | [diff] [blame] | 23 | DummyFaceImpl() |
24 | : FaceBase(FaceUri("dummy://")) | ||||
25 | { | ||||
26 | } | ||||
27 | |||||
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 28 | virtual void |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 29 | sendInterest(const Interest& interest) |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 30 | { |
Junxiao Shi | 9b27bd2 | 2014-02-26 20:29:58 -0700 | [diff] [blame] | 31 | m_sentInterests.push_back(interest); |
32 | this->afterSend(); | ||||
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 33 | } |
Junxiao Shi | 9b27bd2 | 2014-02-26 20:29:58 -0700 | [diff] [blame] | 34 | |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 35 | virtual void |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 36 | sendData(const Data& data) |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 37 | { |
Junxiao Shi | 9b27bd2 | 2014-02-26 20:29:58 -0700 | [diff] [blame] | 38 | m_sentDatas.push_back(data); |
39 | this->afterSend(); | ||||
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 40 | } |
Alexander Afanasyev | a0a10fb | 2014-02-13 19:56:15 -0800 | [diff] [blame] | 41 | |
42 | virtual void | ||||
43 | close() | ||||
44 | { | ||||
45 | } | ||||
Alexander Afanasyev | 93ce75e | 2014-02-18 19:45:34 -0800 | [diff] [blame] | 46 | |
Junxiao Shi | 9b27bd2 | 2014-02-26 20:29:58 -0700 | [diff] [blame] | 47 | 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 Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 59 | EventEmitter<> afterSend; |
Junxiao Shi | 9b27bd2 | 2014-02-26 20:29:58 -0700 | [diff] [blame] | 60 | |
61 | public: | ||||
62 | std::vector<Interest> m_sentInterests; | ||||
63 | std::vector<Data> m_sentDatas; | ||||
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 64 | }; |
65 | |||||
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 66 | typedef DummyFaceImpl<Face> DummyFace; |
67 | typedef DummyFaceImpl<LocalFace> DummyLocalFace; | ||||
68 | |||||
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 69 | } // namespace tests |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 70 | } // namespace nfd |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 71 | |
72 | #endif // TEST_FACE_DUMMY_FACE_HPP |