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; |
| 11 |
10 namespace { | 12 namespace { |
11 | 13 |
12 class OneShotTimerTester { | 14 class OneShotTimerTester { |
13 public: | 15 public: |
14 OneShotTimerTester(bool* did_run) : did_run_(did_run) { | 16 OneShotTimerTester(bool* did_run) : did_run_(did_run) { |
15 } | 17 } |
16 void Start() { | 18 void Start() { |
17 timer_.Start(TimeDelta::FromMilliseconds(10), this, | 19 timer_.Start(TimeDelta::FromMilliseconds(10), this, |
18 &OneShotTimerTester::Run); | 20 &OneShotTimerTester::Run); |
19 } | 21 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 RunTest_RepeatingTimer(MessageLoop::TYPE_DEFAULT); | 138 RunTest_RepeatingTimer(MessageLoop::TYPE_DEFAULT); |
137 RunTest_RepeatingTimer(MessageLoop::TYPE_UI); | 139 RunTest_RepeatingTimer(MessageLoop::TYPE_UI); |
138 RunTest_RepeatingTimer(MessageLoop::TYPE_IO); | 140 RunTest_RepeatingTimer(MessageLoop::TYPE_IO); |
139 } | 141 } |
140 | 142 |
141 TEST(TimerTest, RepeatingTimer_Cancel) { | 143 TEST(TimerTest, RepeatingTimer_Cancel) { |
142 RunTest_RepeatingTimer_Cancel(MessageLoop::TYPE_DEFAULT); | 144 RunTest_RepeatingTimer_Cancel(MessageLoop::TYPE_DEFAULT); |
143 RunTest_RepeatingTimer_Cancel(MessageLoop::TYPE_UI); | 145 RunTest_RepeatingTimer_Cancel(MessageLoop::TYPE_UI); |
144 RunTest_RepeatingTimer_Cancel(MessageLoop::TYPE_IO); | 146 RunTest_RepeatingTimer_Cancel(MessageLoop::TYPE_IO); |
145 } | 147 } |
OLD | NEW |