face: connect to Transport during construction
This allows DummyClientFace to receive packets without sending.
refs #2318
Change-Id: I7451d2c4a873e4680cfb380c9029b1edcd4af7fb
diff --git a/tests/unit-tests/test-faces.cpp b/tests/unit-tests/test-face.cpp
similarity index 93%
rename from tests/unit-tests/test-faces.cpp
rename to tests/unit-tests/test-face.cpp
index 57effc9..33c3643 100644
--- a/tests/unit-tests/test-faces.cpp
+++ b/tests/unit-tests/test-face.cpp
@@ -34,11 +34,11 @@
using ndn::util::DummyClientFace;
using ndn::util::makeDummyClientFace;
-class FacesFixture : public UnitTestTimeFixture
+class FaceFixture : public UnitTestTimeFixture
{
public:
explicit
- FacesFixture(bool enableRegistrationReply = true)
+ FaceFixture(bool enableRegistrationReply = true)
: face(makeDummyClientFace(io, { true, enableRegistrationReply }))
{
}
@@ -47,16 +47,16 @@
shared_ptr<DummyClientFace> face;
};
-class FacesNoRegistrationReplyFixture : public FacesFixture
+class FacesNoRegistrationReplyFixture : public FaceFixture
{
public:
FacesNoRegistrationReplyFixture()
- : FacesFixture(false)
+ : FaceFixture(false)
{
}
};
-BOOST_FIXTURE_TEST_SUITE(TestFaces, FacesFixture)
+BOOST_FIXTURE_TEST_SUITE(TestFace, FaceFixture)
BOOST_AUTO_TEST_CASE(ExpressInterestData)
{
@@ -327,6 +327,22 @@
BOOST_CHECK_EQUAL(nInInterests, 2);
}
+BOOST_FIXTURE_TEST_CASE(SetInterestFilterNoReg, FacesNoRegistrationReplyFixture) // Bug 2318
+{
+ // This behavior is specific to DummyClientFace.
+ // Regular Face won't accept incoming packets until something is sent.
+
+ int hit = 0;
+ face->setInterestFilter(Name("/"), bind([&hit] { ++hit; }));
+ face->processEvents(time::milliseconds(-1));
+
+ auto interest = make_shared<Interest>("/A");
+ face->receive(*interest);
+ face->processEvents(time::milliseconds(-1));
+
+ BOOST_CHECK_EQUAL(hit, 1);
+}
+
BOOST_AUTO_TEST_CASE(ProcessEvents)
{
face->processEvents(time::milliseconds(-1)); // io_service::reset()/poll() inside