OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/task.h" | 7 #include "base/task.h" |
8 #include "base/timer.h" | 8 #include "base/timer.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 RunTest_OneShotTimer(MessageLoop::TYPE_IO); | 282 RunTest_OneShotTimer(MessageLoop::TYPE_IO); |
283 } | 283 } |
284 | 284 |
285 TEST(TimerTest, OneShotTimer_Cancel) { | 285 TEST(TimerTest, OneShotTimer_Cancel) { |
286 RunTest_OneShotTimer_Cancel(MessageLoop::TYPE_DEFAULT); | 286 RunTest_OneShotTimer_Cancel(MessageLoop::TYPE_DEFAULT); |
287 RunTest_OneShotTimer_Cancel(MessageLoop::TYPE_UI); | 287 RunTest_OneShotTimer_Cancel(MessageLoop::TYPE_UI); |
288 RunTest_OneShotTimer_Cancel(MessageLoop::TYPE_IO); | 288 RunTest_OneShotTimer_Cancel(MessageLoop::TYPE_IO); |
289 } | 289 } |
290 | 290 |
291 // If underline timer does not handle properly, we will crash or fail | 291 // If underline timer does not handle properly, we will crash or fail |
292 // in full page heap or purify environment. | 292 // in full page heap environment. |
293 TEST(TimerTest, OneShotSelfDeletingTimer) { | 293 TEST(TimerTest, OneShotSelfDeletingTimer) { |
294 RunTest_OneShotSelfDeletingTimer(MessageLoop::TYPE_DEFAULT); | 294 RunTest_OneShotSelfDeletingTimer(MessageLoop::TYPE_DEFAULT); |
295 RunTest_OneShotSelfDeletingTimer(MessageLoop::TYPE_UI); | 295 RunTest_OneShotSelfDeletingTimer(MessageLoop::TYPE_UI); |
296 RunTest_OneShotSelfDeletingTimer(MessageLoop::TYPE_IO); | 296 RunTest_OneShotSelfDeletingTimer(MessageLoop::TYPE_IO); |
297 } | 297 } |
298 | 298 |
299 TEST(TimerTest, RepeatingTimer) { | 299 TEST(TimerTest, RepeatingTimer) { |
300 RunTest_RepeatingTimer(MessageLoop::TYPE_DEFAULT); | 300 RunTest_RepeatingTimer(MessageLoop::TYPE_DEFAULT); |
301 RunTest_RepeatingTimer(MessageLoop::TYPE_UI); | 301 RunTest_RepeatingTimer(MessageLoop::TYPE_UI); |
302 RunTest_RepeatingTimer(MessageLoop::TYPE_IO); | 302 RunTest_RepeatingTimer(MessageLoop::TYPE_IO); |
(...skipping 27 matching lines...) Expand all Loading... |
330 TEST(TimerTest, DelayTimer_Deleted) { | 330 TEST(TimerTest, DelayTimer_Deleted) { |
331 RunTest_DelayTimer_Deleted(MessageLoop::TYPE_DEFAULT); | 331 RunTest_DelayTimer_Deleted(MessageLoop::TYPE_DEFAULT); |
332 RunTest_DelayTimer_Deleted(MessageLoop::TYPE_UI); | 332 RunTest_DelayTimer_Deleted(MessageLoop::TYPE_UI); |
333 RunTest_DelayTimer_Deleted(MessageLoop::TYPE_IO); | 333 RunTest_DelayTimer_Deleted(MessageLoop::TYPE_IO); |
334 } | 334 } |
335 | 335 |
336 TEST(TimerTest, MessageLoopShutdown) { | 336 TEST(TimerTest, MessageLoopShutdown) { |
337 // This test is designed to verify that shutdown of the | 337 // This test is designed to verify that shutdown of the |
338 // message loop does not cause crashes if there were pending | 338 // message loop does not cause crashes if there were pending |
339 // timers not yet fired. It may only trigger exceptions | 339 // timers not yet fired. It may only trigger exceptions |
340 // if debug heap checking (or purify) is enabled. | 340 // if debug heap checking is enabled. |
341 bool did_run = false; | 341 bool did_run = false; |
342 { | 342 { |
343 OneShotTimerTester a(&did_run); | 343 OneShotTimerTester a(&did_run); |
344 OneShotTimerTester b(&did_run); | 344 OneShotTimerTester b(&did_run); |
345 OneShotTimerTester c(&did_run); | 345 OneShotTimerTester c(&did_run); |
346 OneShotTimerTester d(&did_run); | 346 OneShotTimerTester d(&did_run); |
347 { | 347 { |
348 MessageLoop loop(MessageLoop::TYPE_DEFAULT); | 348 MessageLoop loop(MessageLoop::TYPE_DEFAULT); |
349 a.Start(); | 349 a.Start(); |
350 b.Start(); | 350 b.Start(); |
351 } // MessageLoop destructs by falling out of scope. | 351 } // MessageLoop destructs by falling out of scope. |
352 } // OneShotTimers destruct. SHOULD NOT CRASH, of course. | 352 } // OneShotTimers destruct. SHOULD NOT CRASH, of course. |
353 | 353 |
354 EXPECT_FALSE(did_run); | 354 EXPECT_FALSE(did_run); |
355 } | 355 } |
OLD | NEW |