test/watchdog: Test interval update

Adds a test to ensure that setting the interval on the watchdog affects
subsequent resetTimeRemaining() calls.

Tested:
    Ran through a unit test run

Change-Id: Ibff14bbb40d5b93ffd5eaa5149f5cc9822e21d1e
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/test/watchdog_test.cpp b/test/watchdog_test.cpp
index 49890da..aa0ae0f 100644
--- a/test/watchdog_test.cpp
+++ b/test/watchdog_test.cpp
@@ -154,6 +154,33 @@
     EXPECT_EQ(expireTimeMs, wdog->interval());
 }
 
+/** @brief Make sure the Interval can be updated while the timer is running.
+ */
+TEST_F(WdogTest, verifyIntervalUpdateRunning)
+{
+    const auto oldInterval = milliseconds(wdog->interval());
+    const auto newInterval = 5s;
+
+    EXPECT_TRUE(wdog->enabled(true));
+    auto remaining = milliseconds(wdog->timeRemaining());
+    EXPECT_GE(oldInterval, remaining);
+    EXPECT_LE(oldInterval - defaultDrift, remaining);
+    EXPECT_EQ(newInterval,
+              milliseconds(wdog->interval(milliseconds(newInterval).count())));
+
+    // Expect only the interval to update
+    remaining = milliseconds(wdog->timeRemaining());
+    EXPECT_GE(oldInterval, remaining);
+    EXPECT_LE(oldInterval - defaultDrift, remaining);
+    EXPECT_EQ(newInterval, milliseconds(wdog->interval()));
+
+    // Expect reset to use the new interval
+    wdog->resetTimeRemaining(false);
+    remaining = milliseconds(wdog->timeRemaining());
+    EXPECT_GE(newInterval, remaining);
+    EXPECT_LE(newInterval - defaultDrift, remaining);
+}
+
 /** @brief Make sure that watchdog is started and enabled.
  *         Wait default interval seconds and make sure that wdog has died
  */