| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "components/timers/alarm_timer.h" | 12 #include "components/timers/alarm_timer.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 // Most of these tests have been lifted right out of timer_unittest.cc with only | 15 // Most of these tests have been lifted right out of timer_unittest.cc with only |
| 16 // cosmetic changes (like replacing calls to MessageLoop::current()->Run() with | 16 // cosmetic changes (like replacing calls to MessageLoop::current()->Run() with |
| 17 // a RunLoop). We want the AlarmTimer to be a drop-in replacement for the | 17 // a RunLoop). We want the AlarmTimer to be a drop-in replacement for the |
| 18 // regular Timer so it should pass the same tests as the Timer class. | 18 // regular Timer so it should pass the same tests as the Timer class. |
| 19 // | 19 // |
| 20 // The only new tests are the .*ConcurrentResetAndTimerFired tests, which test | 20 // The only new tests are the .*ConcurrentResetAndTimerFired tests, which test |
| 21 // that race conditions that can come up in the AlarmTimer::Delegate are | 21 // that race conditions that can come up in the AlarmTimer::Delegate are |
| 22 // properly handled. | 22 // properly handled. |
| 23 namespace timers { | 23 namespace timers { |
| 24 |
| 24 namespace { | 25 namespace { |
| 25 // The message loops on which each timer should be tested. | 26 // The message loops on which each timer should be tested. |
| 26 const base::MessageLoop::Type testing_message_loops[] = { | 27 const base::MessageLoop::Type testing_message_loops[] = { |
| 27 base::MessageLoop::TYPE_DEFAULT, | 28 base::MessageLoop::TYPE_DEFAULT, |
| 28 base::MessageLoop::TYPE_IO, | 29 base::MessageLoop::TYPE_IO, |
| 29 #if !defined(OS_IOS) // iOS does not allow direct running of the UI loop. | 30 #if !defined(OS_IOS) // iOS does not allow direct running of the UI loop. |
| 30 base::MessageLoop::TYPE_UI, | 31 base::MessageLoop::TYPE_UI, |
| 31 #endif | 32 #endif |
| 32 }; | 33 }; |
| 33 | 34 |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 TEST(AlarmTimerTest, RepeatingTimerConcurrentResetAndTimerFired) { | 488 TEST(AlarmTimerTest, RepeatingTimerConcurrentResetAndTimerFired) { |
| 488 for (int i = 0; i < kNumTestingMessageLoops; i++) { | 489 for (int i = 0; i < kNumTestingMessageLoops; i++) { |
| 489 RunTest_RepeatingTimerConcurrentResetAndTimerFired( | 490 RunTest_RepeatingTimerConcurrentResetAndTimerFired( |
| 490 testing_message_loops[i]); | 491 testing_message_loops[i]); |
| 491 } | 492 } |
| 492 } | 493 } |
| 493 | 494 |
| 494 } // namespace | 495 } // namespace |
| 495 | 496 |
| 496 } // namespace timers | 497 } // namespace timers |
| OLD | NEW |