Recalculate routing table after face destroy event
refs: #2635
Change-Id: I7abbb638515af4a55c4241c4242a496a8cf8ca88
diff --git a/tests/test-common.hpp b/tests/test-common.hpp
index 7bb4c20..5731292 100644
--- a/tests/test-common.hpp
+++ b/tests/test-common.hpp
@@ -29,6 +29,7 @@
#include <boost/test/unit_test.hpp>
#include <ndn-cxx/util/scheduler.hpp>
+#include <ndn-cxx/util/time-unit-test-clock.hpp>
namespace nlsr {
namespace test {
@@ -46,6 +47,41 @@
ndn::Scheduler g_scheduler;
};
+class UnitTestTimeFixture : public BaseFixture
+{
+protected:
+ UnitTestTimeFixture()
+ : steadyClock(make_shared<ndn::time::UnitTestSteadyClock>())
+ , systemClock(make_shared<ndn::time::UnitTestSystemClock>())
+ {
+ ndn::time::setCustomClocks(steadyClock, systemClock);
+ }
+
+ ~UnitTestTimeFixture()
+ {
+ ndn::time::setCustomClocks(nullptr, nullptr);
+ }
+
+ void
+ advanceClocks(const ndn::time::nanoseconds& tick, size_t nTicks = 1)
+ {
+ for (size_t i = 0; i < nTicks; ++i) {
+ steadyClock->advance(tick);
+ systemClock->advance(tick);
+
+ if (g_ioService.stopped()) {
+ g_ioService.reset();
+ }
+
+ g_ioService.poll();
+ }
+ }
+
+protected:
+ shared_ptr<ndn::time::UnitTestSteadyClock> steadyClock;
+ shared_ptr<ndn::time::UnitTestSystemClock> systemClock;
+};
+
} // namespace test
} // namespace nlsr