| 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/idle_timer.h" | 5 #include "base/idle_timer.h" |
| 6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 using base::Time; | 9 using base::Time; |
| 10 using base::TimeDelta; | 10 using base::TimeDelta; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 test_task.Start(); | 166 test_task.Start(); |
| 167 MessageLoop::current()->Run(); | 167 MessageLoop::current()->Run(); |
| 168 | 168 |
| 169 // In a perfect world, the idle_counter should be 10. However, | 169 // In a perfect world, the idle_counter should be 10. However, |
| 170 // since timers aren't guaranteed to fire perfectly, this can | 170 // since timers aren't guaranteed to fire perfectly, this can |
| 171 // be less. Just expect more than 5 and no more than 10. | 171 // be less. Just expect more than 5 and no more than 10. |
| 172 EXPECT_GT(test_task.get_idle_counter(), 5); | 172 EXPECT_GT(test_task.get_idle_counter(), 5); |
| 173 EXPECT_LE(test_task.get_idle_counter(), 10); | 173 EXPECT_LE(test_task.get_idle_counter(), 10); |
| 174 } | 174 } |
| 175 | 175 |
| 176 TEST_F(IdleTimerTest, RepeatIdleReset) { | 176 // TODO(darin): http://code.google.com/p/chromium/issues/detail?id=3780 |
| 177 TEST_F(IdleTimerTest, DISABLED_RepeatIdleReset) { |
| 177 // Create an IdleTimer, which should fire repeatedly after 100ms. | 178 // Create an IdleTimer, which should fire repeatedly after 100ms. |
| 178 // Create a Quit timer which will fire after 1s. | 179 // Create a Quit timer which will fire after 1s. |
| 179 // Create a reset timer, which fires after 550ms | 180 // Create a reset timer, which fires after 550ms |
| 180 // Verify that we fired 9 times. | 181 // Verify that we fired 9 times. |
| 181 mock_timer_started = Time::Now(); | 182 mock_timer_started = Time::Now(); |
| 182 TestIdleTask test_task(true); | 183 TestIdleTask test_task(true); |
| 183 | 184 |
| 184 ResetIdleTask reset_task; | 185 ResetIdleTask reset_task; |
| 185 TestFinishedTask finish_task; | 186 TestFinishedTask finish_task; |
| 186 | 187 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 | 225 |
| 225 test_task.Start(); | 226 test_task.Start(); |
| 226 MessageLoop::current()->Run(); | 227 MessageLoop::current()->Run(); |
| 227 | 228 |
| 228 reset_timer.Stop(); | 229 reset_timer.Stop(); |
| 229 | 230 |
| 230 EXPECT_EQ(test_task.get_idle_counter(), 0); | 231 EXPECT_EQ(test_task.get_idle_counter(), 0); |
| 231 } | 232 } |
| 232 | 233 |
| 233 } // namespace | 234 } // namespace |
| OLD | NEW |