utility/timer: Implement callback setting
All of the other classes that take callbacks support having the callback
updated.
Tested:
Builds and passed through the unit test suite.
Change-Id: I0efcd074523fa6ec0cc84c7a930346dd9340f7ec
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/test/utility/timer.cpp b/test/utility/timer.cpp
index 6c04e87..f35a0c4 100644
--- a/test/utility/timer.cpp
+++ b/test/utility/timer.cpp
@@ -379,6 +379,13 @@
expectSetTime(new_time + interval);
EXPECT_EQ(0, handler(nullptr, 0, handler_userdata));
EXPECT_EQ(1, called);
+
+ // update the callback and make sure it still works
+ timer->set_callback(std::bind([]() {}));
+ expectNow(new_time);
+ expectSetTime(new_time + interval);
+ EXPECT_EQ(0, handler(nullptr, 0, handler_userdata));
+ EXPECT_EQ(1, called);
}
TEST_F(TimerTest, SetValuesExpiredTimer)