util: make DummyClientFace public API
refs #2164
Change-Id: I4a21b70faab1fc1f5cde8430ef602f2425150df9
diff --git a/tests/unit-tests/util/notification-stream.cpp b/tests/unit-tests/util/notification-stream.cpp
index 0378bd1..adba5c7 100644
--- a/tests/unit-tests/util/notification-stream.cpp
+++ b/tests/unit-tests/util/notification-stream.cpp
@@ -49,9 +49,10 @@
#include "simple-notification.hpp"
#include "boost-test.hpp"
-#include "../dummy-client-face.hpp"
+#include "util/dummy-client-face.hpp"
namespace ndn {
+namespace util {
namespace tests {
BOOST_AUTO_TEST_SUITE(UtilNotificationStream)
@@ -66,25 +67,26 @@
SimpleNotification event1("msg1");
notificationStream.postNotification(event1);
face->processEvents();
- BOOST_REQUIRE_EQUAL(face->m_sentDatas.size(), 1);
- BOOST_CHECK_EQUAL(face->m_sentDatas[0].getName(),
+ BOOST_REQUIRE_EQUAL(face->sentDatas.size(), 1);
+ BOOST_CHECK_EQUAL(face->sentDatas[0].getName(),
"/localhost/nfd/NotificationStreamTest/%FE%00");
SimpleNotification decoded1;
- BOOST_CHECK_NO_THROW(decoded1.wireDecode(face->m_sentDatas[0].getContent().blockFromValue()));
+ BOOST_CHECK_NO_THROW(decoded1.wireDecode(face->sentDatas[0].getContent().blockFromValue()));
BOOST_CHECK_EQUAL(decoded1.getMessage(), "msg1");
SimpleNotification event2("msg2");
notificationStream.postNotification(event2);
face->processEvents();
- BOOST_REQUIRE_EQUAL(face->m_sentDatas.size(), 2);
- BOOST_CHECK_EQUAL(face->m_sentDatas[1].getName(),
+ BOOST_REQUIRE_EQUAL(face->sentDatas.size(), 2);
+ BOOST_CHECK_EQUAL(face->sentDatas[1].getName(),
"/localhost/nfd/NotificationStreamTest/%FE%01");
SimpleNotification decoded2;
- BOOST_CHECK_NO_THROW(decoded2.wireDecode(face->m_sentDatas[1].getContent().blockFromValue()));
+ BOOST_CHECK_NO_THROW(decoded2.wireDecode(face->sentDatas[1].getContent().blockFromValue()));
BOOST_CHECK_EQUAL(decoded2.getMessage(), "msg2");
}
BOOST_AUTO_TEST_SUITE_END()
} // namespace tests
+} // namespace util
} // namespace ndn
diff --git a/tests/unit-tests/util/notification-subscriber.cpp b/tests/unit-tests/util/notification-subscriber.cpp
index 092a601..9d7ab65 100644
--- a/tests/unit-tests/util/notification-subscriber.cpp
+++ b/tests/unit-tests/util/notification-subscriber.cpp
@@ -50,9 +50,11 @@
#include "simple-notification.hpp"
#include "boost-test.hpp"
-#include "../dummy-client-face.hpp"
+#include <boost/asio.hpp>
+#include "util/dummy-client-face.hpp"
namespace ndn {
+namespace util {
namespace tests {
BOOST_AUTO_TEST_SUITE(UtilNotificationSubscriber)
@@ -74,18 +76,18 @@
void
deliverNotification(const std::string& msg)
{
- publisherFace->m_sentDatas.clear();
+ publisherFace->sentDatas.clear();
SimpleNotification notification(msg);
notificationStream.postNotification(notification);
publisherFace->processEvents(time::milliseconds(100));
- BOOST_REQUIRE_EQUAL(publisherFace->m_sentDatas.size(), 1);
+ BOOST_REQUIRE_EQUAL(publisherFace->sentDatas.size(), 1);
- lastDeliveredSeqNo = publisherFace->m_sentDatas[0].getName().at(-1).toSequenceNumber();
+ lastDeliveredSeqNo = publisherFace->sentDatas[0].getName().at(-1).toSequenceNumber();
lastNotification.setMessage("");
- subscriberFace->receive(publisherFace->m_sentDatas[0]);
+ subscriberFace->receive(publisherFace->sentDatas[0]);
}
void
@@ -117,10 +119,10 @@
bool
hasInitialRequest() const
{
- if (subscriberFace->m_sentInterests.empty())
+ if (subscriberFace->sentInterests.empty())
return 0;
- const Interest& interest = subscriberFace->m_sentInterests[0];
+ const Interest& interest = subscriberFace->sentInterests[0];
return interest.getName() == streamPrefix &&
interest.getChildSelector() == 1 &&
interest.getMustBeFresh() &&
@@ -133,10 +135,10 @@
uint64_t
getRequestSeqNo() const
{
- if (subscriberFace->m_sentInterests.size() != 1)
+ if (subscriberFace->sentInterests.size() != 1)
return 0;
- const Interest& interest = subscriberFace->m_sentInterests[0];
+ const Interest& interest = subscriberFace->sentInterests[0];
const Name& name = interest.getName();
if (streamPrefix.isPrefixOf(name) &&
name.size() == streamPrefix.size() + 1 &&
@@ -178,30 +180,30 @@
this->deliverNotification("n1");
subscriberFace->processEvents(time::milliseconds(100));
BOOST_CHECK(lastNotification.getMessage().empty());
- BOOST_CHECK_EQUAL(subscriberFace->m_sentInterests.size(), 0);
+ BOOST_CHECK_EQUAL(subscriberFace->sentInterests.size(), 0);
- subscriberFace->m_sentInterests.clear();
+ subscriberFace->sentInterests.clear();
subscriber.start();
subscriberFace->processEvents(time::milliseconds(-100));
BOOST_REQUIRE_EQUAL(subscriber.isRunning(), true);
BOOST_CHECK(this->hasInitialRequest());
// respond to initial request
- subscriberFace->m_sentInterests.clear();
+ subscriberFace->sentInterests.clear();
this->deliverNotification("n2");
subscriberFace->processEvents(time::milliseconds(-100));
BOOST_CHECK_EQUAL(lastNotification.getMessage(), "n2");
BOOST_CHECK_EQUAL(this->getRequestSeqNo(), lastDeliveredSeqNo + 1);
// respond to continuation request
- subscriberFace->m_sentInterests.clear();
+ subscriberFace->sentInterests.clear();
this->deliverNotification("n3");
subscriberFace->processEvents(time::milliseconds(-100));
BOOST_CHECK_EQUAL(lastNotification.getMessage(), "n3");
BOOST_CHECK_EQUAL(this->getRequestSeqNo(), lastDeliveredSeqNo + 1);
// timeout
- subscriberFace->m_sentInterests.clear();
+ subscriberFace->sentInterests.clear();
lastNotification.setMessage("");
subscriberFace->processEvents(2 * subscriber.getInterestLifetime());
BOOST_CHECK(lastNotification.getMessage().empty());
@@ -214,7 +216,7 @@
Data wrongData(wrongName);
publisherKeyChain.sign(wrongData);
subscriberFace->receive(wrongData);
- subscriberFace->m_sentInterests.clear();
+ subscriberFace->sentInterests.clear();
lastNotification.setMessage("");
subscriberFace->processEvents(time::milliseconds(-100));
BOOST_CHECK(lastNotification.getMessage().empty());
@@ -222,7 +224,7 @@
BOOST_CHECK(this->hasInitialRequest());
// decode error in payload
- subscriberFace->m_sentInterests.clear();
+ subscriberFace->sentInterests.clear();
lastNotification.setMessage("");
this->deliverNotification("\x07n4");
subscriberFace->processEvents(time::milliseconds(-100));
@@ -231,13 +233,14 @@
// stop if handlers are cleared
subscriber.onNotification += bind(&EndToEndFixture::clearNotificationHandlers, this);
- subscriberFace->m_sentInterests.clear();
+ subscriberFace->sentInterests.clear();
this->deliverNotification("n5");
subscriberFace->processEvents(time::milliseconds(-100));
- BOOST_CHECK_EQUAL(subscriberFace->m_sentInterests.size(), 0);
+ BOOST_CHECK_EQUAL(subscriberFace->sentInterests.size(), 0);
}
BOOST_AUTO_TEST_SUITE_END()
} // namespace tests
+} // namespace util
} // namespace ndn
diff --git a/tests/unit-tests/util/segment-fetcher.cpp b/tests/unit-tests/util/segment-fetcher.cpp
index f5d274d..3a9fc5f 100644
--- a/tests/unit-tests/util/segment-fetcher.cpp
+++ b/tests/unit-tests/util/segment-fetcher.cpp
@@ -22,7 +22,7 @@
#include "util/segment-fetcher.hpp"
#include "boost-test.hpp"
-#include "../dummy-client-face.hpp"
+#include "util/dummy-client-face.hpp"
#include "security/key-chain.hpp"
namespace ndn {
@@ -35,7 +35,7 @@
{
public:
Fixture()
- : face(::ndn::tests::makeDummyClientFace())
+ : face(makeDummyClientFace())
, nErrors(0)
, nDatas(0)
, dataSize(0)
@@ -73,7 +73,7 @@
public:
- shared_ptr<ndn::tests::DummyClientFace> face;
+ shared_ptr<DummyClientFace> face;
KeyChain keyChain;
uint32_t nErrors;
@@ -94,10 +94,10 @@
BOOST_CHECK_EQUAL(nErrors, 1);
BOOST_CHECK_EQUAL(lastError, static_cast<uint32_t>(SegmentFetcher::INTEREST_TIMEOUT));
BOOST_CHECK_EQUAL(nDatas, 0);
- BOOST_REQUIRE_EQUAL(face->m_sentInterests.size(), 1);
- BOOST_CHECK_EQUAL(face->m_sentDatas.size(), 0);
+ BOOST_REQUIRE_EQUAL(face->sentInterests.size(), 1);
+ BOOST_CHECK_EQUAL(face->sentDatas.size(), 0);
- const Interest& interest = face->m_sentInterests[0];
+ const Interest& interest = face->sentInterests[0];
BOOST_CHECK_EQUAL(interest.getName(), "/hello/world");
BOOST_CHECK_EQUAL(interest.getMustBeFresh(), true);
BOOST_CHECK_EQUAL(interest.getChildSelector(), 1);
@@ -122,10 +122,10 @@
BOOST_CHECK_EQUAL(dataSize, 14);
- BOOST_REQUIRE_EQUAL(face->m_sentInterests.size(), 1);
- BOOST_CHECK_EQUAL(face->m_sentDatas.size(), 0);
+ BOOST_REQUIRE_EQUAL(face->sentInterests.size(), 1);
+ BOOST_CHECK_EQUAL(face->sentDatas.size(), 0);
- const Interest& interest = face->m_sentInterests[0];
+ const Interest& interest = face->sentInterests[0];
BOOST_CHECK_EQUAL(interest.getName(), "/hello/world");
BOOST_CHECK_EQUAL(interest.getMustBeFresh(), true);
BOOST_CHECK_EQUAL(interest.getChildSelector(), 1);
@@ -204,25 +204,25 @@
BOOST_CHECK_EQUAL(dataSize, 42);
- BOOST_REQUIRE_EQUAL(face->m_sentInterests.size(), 3);
- BOOST_CHECK_EQUAL(face->m_sentDatas.size(), 0);
+ BOOST_REQUIRE_EQUAL(face->sentInterests.size(), 3);
+ BOOST_CHECK_EQUAL(face->sentDatas.size(), 0);
{
- const Interest& interest = face->m_sentInterests[0];
+ const Interest& interest = face->sentInterests[0];
BOOST_CHECK_EQUAL(interest.getName(), "/hello/world");
BOOST_CHECK_EQUAL(interest.getMustBeFresh(), true);
BOOST_CHECK_EQUAL(interest.getChildSelector(), 1);
}
{
- const Interest& interest = face->m_sentInterests[1];
+ const Interest& interest = face->sentInterests[1];
BOOST_CHECK_EQUAL(interest.getName(), "/hello/world/version0/%00%01");
BOOST_CHECK_EQUAL(interest.getMustBeFresh(), false);
BOOST_CHECK_EQUAL(interest.getChildSelector(), 0);
}
{
- const Interest& interest = face->m_sentInterests[2];
+ const Interest& interest = face->sentInterests[2];
BOOST_CHECK_EQUAL(interest.getName(), "/hello/world/version0/%00%02");
BOOST_CHECK_EQUAL(interest.getMustBeFresh(), false);
BOOST_CHECK_EQUAL(interest.getChildSelector(), 0);
@@ -257,32 +257,32 @@
BOOST_CHECK_EQUAL(dataSize, 42);
- BOOST_REQUIRE_EQUAL(face->m_sentInterests.size(), 4);
- BOOST_CHECK_EQUAL(face->m_sentDatas.size(), 0);
+ BOOST_REQUIRE_EQUAL(face->sentInterests.size(), 4);
+ BOOST_CHECK_EQUAL(face->sentDatas.size(), 0);
{
- const Interest& interest = face->m_sentInterests[0];
+ const Interest& interest = face->sentInterests[0];
BOOST_CHECK_EQUAL(interest.getName(), "/hello/world");
BOOST_CHECK_EQUAL(interest.getMustBeFresh(), true);
BOOST_CHECK_EQUAL(interest.getChildSelector(), 1);
}
{
- const Interest& interest = face->m_sentInterests[1];
+ const Interest& interest = face->sentInterests[1];
BOOST_CHECK_EQUAL(interest.getName(), "/hello/world/version0/%00%00");
BOOST_CHECK_EQUAL(interest.getMustBeFresh(), false);
BOOST_CHECK_EQUAL(interest.getChildSelector(), 0);
}
{
- const Interest& interest = face->m_sentInterests[2];
+ const Interest& interest = face->sentInterests[2];
BOOST_CHECK_EQUAL(interest.getName(), "/hello/world/version0/%00%01");
BOOST_CHECK_EQUAL(interest.getMustBeFresh(), false);
BOOST_CHECK_EQUAL(interest.getChildSelector(), 0);
}
{
- const Interest& interest = face->m_sentInterests[3];
+ const Interest& interest = face->sentInterests[3];
BOOST_CHECK_EQUAL(interest.getName(), "/hello/world/version0/%00%02");
BOOST_CHECK_EQUAL(interest.getMustBeFresh(), false);
BOOST_CHECK_EQUAL(interest.getChildSelector(), 0);
diff --git a/tests/unit-tests/util/simple-notification.hpp b/tests/unit-tests/util/simple-notification.hpp
index 2def4bb..e90e374 100644
--- a/tests/unit-tests/util/simple-notification.hpp
+++ b/tests/unit-tests/util/simple-notification.hpp
@@ -54,6 +54,7 @@
#include "security/key-chain.hpp"
namespace ndn {
+namespace util {
namespace tests {
class SimpleNotification
@@ -118,6 +119,7 @@
};
} // namespace tests
+} // namespace util
} // namespace ndn
#endif // NDN_UNIT_TESTS_UTIL_CORE_SIMPLE_NOTIFICATION_HPP