Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3060)

Unified Diff: base/timer_unittest.cc

Issue 27234: DelayTimer destruction test (Closed)
Patch Set: ... Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/timer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/timer_unittest.cc
diff --git a/base/timer_unittest.cc b/base/timer_unittest.cc
index b48c77428d4e01d62bb5f03166a4743812d6d092..4349245f729ca38e423b1edb75c593cfdbfbcf09 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
« no previous file with comments | « base/timer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698