#include "suite.hpp" #include #include #include /** @brief Makes sure that timer is not expired */ TEST_F(TimerTestCallBack, timerNotExpiredAfter2SecondsNoOptionalCallBack) { using namespace std::chrono; auto time = duration_cast(seconds(2)); EXPECT_GE(timer->start(time), 0); // Now turn off the timer post a 1 second sleep sleep(1); EXPECT_GE(timer->stop(), 0); // Wait 2 seconds and see that timer is not expired int count = 0; while (count < 2) { // Returns -0- on timeout auto sleepTime = duration_cast(seconds(1)); if (!sd_event_run(events, sleepTime.count())) { count++; } } EXPECT_EQ(false, timer->isExpired()); EXPECT_EQ(false, callBackDone); // 2 because of one more count that happens prior to exiting EXPECT_EQ(2, count); }