OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/task.h" | 6 #include "base/task.h" |
7 #include "base/timer.h" | 7 #include "base/timer.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 using base::TimeDelta; | 10 using base::TimeDelta; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 RunTest_RepeatingTimer(MessageLoop::TYPE_DEFAULT); | 138 RunTest_RepeatingTimer(MessageLoop::TYPE_DEFAULT); |
139 RunTest_RepeatingTimer(MessageLoop::TYPE_UI); | 139 RunTest_RepeatingTimer(MessageLoop::TYPE_UI); |
140 RunTest_RepeatingTimer(MessageLoop::TYPE_IO); | 140 RunTest_RepeatingTimer(MessageLoop::TYPE_IO); |
141 } | 141 } |
142 | 142 |
143 TEST(TimerTest, RepeatingTimer_Cancel) { | 143 TEST(TimerTest, RepeatingTimer_Cancel) { |
144 RunTest_RepeatingTimer_Cancel(MessageLoop::TYPE_DEFAULT); | 144 RunTest_RepeatingTimer_Cancel(MessageLoop::TYPE_DEFAULT); |
145 RunTest_RepeatingTimer_Cancel(MessageLoop::TYPE_UI); | 145 RunTest_RepeatingTimer_Cancel(MessageLoop::TYPE_UI); |
146 RunTest_RepeatingTimer_Cancel(MessageLoop::TYPE_IO); | 146 RunTest_RepeatingTimer_Cancel(MessageLoop::TYPE_IO); |
147 } | 147 } |
| 148 |
| 149 TEST(TimerTest, MessageLoopShutdown) { |
| 150 // This test is designed to verify that shutdown of the |
| 151 // message loop does not cause crashes if there were pending |
| 152 // timers not yet fired. It may only trigger exceptions |
| 153 // if debug heap checking (or purify) is enabled. |
| 154 bool did_run = false; |
| 155 { |
| 156 OneShotTimerTester a(&did_run); |
| 157 OneShotTimerTester b(&did_run); |
| 158 OneShotTimerTester c(&did_run); |
| 159 OneShotTimerTester d(&did_run); |
| 160 { |
| 161 MessageLoop loop(MessageLoop::TYPE_DEFAULT); |
| 162 a.Start(); |
| 163 b.Start(); |
| 164 } // MessageLoop destructs by falling out of scope. |
| 165 } // OneShotTimers destruct. SHOULD NOT CRASH, of course. |
| 166 |
| 167 EXPECT_EQ(false, did_run); |
| 168 } |
OLD | NEW |