summaryrefslogtreecommitdiffstats
path: root/base/timer_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'base/timer_unittest.cc')
-rw-r--r--base/timer_unittest.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/base/timer_unittest.cc b/base/timer_unittest.cc
index b48c774..4349245f 100644
--- a/base/timer_unittest.cc
+++ b/base/timer_unittest.cc
@@ -243,6 +243,31 @@ void RunTest_DelayTimer_Reset(MessageLoop::Type message_loop_type) {
ASSERT_TRUE(target.signaled());
}
+class DelayTimerFatalTarget {
+ public:
+ void Signal() {
+ ASSERT_TRUE(false);
+ }
+};
+
+
+void RunTest_DelayTimer_Deleted(MessageLoop::Type message_loop_type) {
+ MessageLoop loop(message_loop_type);
+
+ DelayTimerFatalTarget target;
+
+ {
+ base::DelayTimer<DelayTimerFatalTarget> timer(
+ TimeDelta::FromMilliseconds(50), &target,
+ &DelayTimerFatalTarget::Signal);
+ timer.Reset();
+ }
+
+ // When the timer is deleted, the DelayTimerFatalTarget should never be
+ // called.
+ PlatformThread::Sleep(100);
+}
+
} // namespace
//-----------------------------------------------------------------------------
@@ -299,6 +324,12 @@ TEST(TimerTest, DelayTimer_Reset) {
RunTest_DelayTimer_Reset(MessageLoop::TYPE_IO);
}
+TEST(TimerTest, DelayTimer_Deleted) {
+ RunTest_DelayTimer_Deleted(MessageLoop::TYPE_DEFAULT);
+ RunTest_DelayTimer_Deleted(MessageLoop::TYPE_UI);
+ RunTest_DelayTimer_Deleted(MessageLoop::TYPE_IO);
+}
+
TEST(TimerTest, MessageLoopShutdown) {
// This test is designed to verify that shutdown of the
// message loop does not cause crashes if there were pending