tests: introduce ClockFixture

Identical to UnitTestTimeFixture, except that it does not derive
from BaseFixture, and thus does not depend on a global io_service.

Refs: #4528
Change-Id: Ia2e6c4835a1e461c73281e103109d5cc85be355e
diff --git a/tests/daemon/rib-io-fixture.cpp b/tests/daemon/rib-io-fixture.cpp
index 251d6e9..98563a9 100644
--- a/tests/daemon/rib-io-fixture.cpp
+++ b/tests/daemon/rib-io-fixture.cpp
@@ -23,7 +23,7 @@
  * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "rib-io-fixture.hpp"
+#include "tests/daemon/rib-io-fixture.hpp"
 #include "daemon/global.hpp"
 
 #include <boost/exception/diagnostic_information.hpp>
@@ -122,26 +122,9 @@
 }
 
 void
-RibIoTimeFixture::advanceClocks(time::nanoseconds tick, time::nanoseconds total)
+RibIoTimeFixture::pollAfterClockTick()
 {
-  BOOST_ASSERT(tick > time::nanoseconds::zero());
-  BOOST_ASSERT(total >= time::nanoseconds::zero());
-
-  time::nanoseconds remaining = total;
-  while (remaining > time::nanoseconds::zero()) {
-    if (remaining >= tick) {
-      steadyClock->advance(tick);
-      systemClock->advance(tick);
-      remaining -= tick;
-    }
-    else {
-      steadyClock->advance(remaining);
-      systemClock->advance(remaining);
-      remaining = time::nanoseconds::zero();
-    }
-
-    poll();
-  }
+  poll();
 }
 
 } // namespace tests
diff --git a/tests/daemon/rib-io-fixture.hpp b/tests/daemon/rib-io-fixture.hpp
index 99d4387..67b803c 100644
--- a/tests/daemon/rib-io-fixture.hpp
+++ b/tests/daemon/rib-io-fixture.hpp
@@ -35,7 +35,7 @@
 namespace nfd {
 namespace tests {
 
-/** \brief a base test fixture that provides both main and RIB io_service
+/** \brief A base test fixture that provides both main and RIB io_service.
  */
 class RibIoFixture : public virtual BaseFixture
 {
@@ -45,13 +45,13 @@
   ~RibIoFixture();
 
 protected:
-  /** \brief Poll main and RIB thread io_service to process all pending I/O events
+  /** \brief Poll main and RIB thread io_service to process all pending I/O events.
    *
    * This call will execute all pending I/O events, including events that are posted
    * inside the processing event, i.e., main and RIB thread io_service will be polled
    * repeatedly until all pending events are processed.
    *
-   *  \note Must be called from the main thread
+   * \warning Must be called from the main thread
    */
   void
   poll();
@@ -77,26 +77,13 @@
   std::condition_variable m_ribPollEndCv;
 };
 
-/** \brief RibIoFixture that also overrides steady clock and system clock
+/** \brief RibIoFixture that also overrides steady clock and system clock.
  */
 class RibIoTimeFixture : public RibIoFixture, public UnitTestTimeFixture
 {
-protected:
-  using UnitTestTimeFixture::advanceClocks;
-
-  /** \brief advance steady and system clocks in the main and RIB threads
-   *
-   *  Clocks are advanced in increments of \p tick for \p total time.
-   *  The last increment might be shorter than \p tick.
-   *  After each tick, the main and RIB thread io_service is polled to process pending I/O events.
-   *
-   *  Exceptions thrown during I/O events are propagated to the caller.
-   *  Clock advancing would stop in case of an exception.
-   *
-   *  \note Must be called from the main thread
-   */
+private:
   void
-  advanceClocks(time::nanoseconds tick, time::nanoseconds total) override;
+  pollAfterClockTick() override;
 };
 
 } // namespace tests