Don't set Interval by setting TimeRemaining
This change allows one to set the TimeRemaining as a one-time shot,
and also allows more straightforward control.
-Changing the Interval doesn't reset the watchdog or update the
TimeRemaining.
-Changing the TimeRemaining doesn't set the Interval for future
cycles.
Change-Id: I03a3cdb9cc9e5c4bc034dc86d2b4324a5a4b7243
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/test/watchdog_test.cpp b/test/watchdog_test.cpp
index f9a992c..d3e09e6 100644
--- a/test/watchdog_test.cpp
+++ b/test/watchdog_test.cpp
@@ -84,9 +84,6 @@
auto newTime = duration_cast<milliseconds>(expireTime);
wdog.timeRemaining(newTime.count());
- // Expect an update in the Interval
- EXPECT_EQ(newTime.count(), wdog.interval());
-
// Waiting for expiration
int count = 0;
while(count < expireTime.count() && !wdog.timerExpired())
@@ -105,6 +102,18 @@
EXPECT_EQ(false, expired);
}
+/** @brief Make sure the Inteval can be updated directly.
+ */
+TEST_F(WdogTest, verifyIntervalUpdateReceived)
+{
+ auto expireTime = seconds(5s);
+ auto newTime = duration_cast<milliseconds>(expireTime);
+ wdog.interval(newTime.count());
+
+ // Expect an update in the Interval
+ EXPECT_EQ(newTime.count(), wdog.interval());
+}
+
/** @brief Make sure that watchdog is started and enabled.
* Wait default interval seconds and make sure that wdog has died
*/
diff --git a/watchdog.cpp b/watchdog.cpp
index 0c93d31..d0dc7f0 100644
--- a/watchdog.cpp
+++ b/watchdog.cpp
@@ -88,9 +88,6 @@
// Enable the timer.
timer.setEnabled<std::true_type>();
- // Update Interval in Base class.
- this->interval(value);
-
// Update Base class data.
return WatchdogInherits::timeRemaining(value);
}