Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Side by Side Diff: base/hi_res_timer_manager_unittest.cc

Issue 10959020: SystemMonitor refactoring: move power state monitor into a separate class called PowerMonitor (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Update patch per vandebo's comments Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/hi_res_timer_manager.h" 5 #include "base/hi_res_timer_manager.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/system_monitor/system_monitor.h"
9 #include "base/time.h" 8 #include "base/time.h"
10 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
11 10
12 #if defined(OS_WIN) 11 #if defined(OS_WIN)
13 // http://crbug.com/114048 12 // http://crbug.com/114048
14 TEST(HiResTimerManagerTest, DISABLED_ToggleOnOff) { 13 TEST(HiResTimerManagerTest, DISABLED_ToggleOnOff) {
15 MessageLoop loop; 14 MessageLoop loop;
16 scoped_ptr<base::SystemMonitor> system_monitor(new base::SystemMonitor());
Hongbo Min 2012/10/11 07:57:53 No need to create PowerMonitor since the HighResol
Hongbo Min 2012/10/12 14:43:53 Done.
17 HighResolutionTimerManager manager; 15 HighResolutionTimerManager manager;
18 16
19 // At this point, we don't know if the high resolution timers are on or off, 17 // At this point, we don't know if the high resolution timers are on or off,
20 // it depends on what system the tests are running on (for example, if this 18 // it depends on what system the tests are running on (for example, if this
21 // test is running on a laptop/battery, then the SystemMonitor would have 19 // test is running on a laptop/battery, then the PowerMonitor would have
22 // already set the PowerState to battery power; but if we're running on a 20 // already set the PowerState to battery power; but if we're running on a
23 // desktop, then the PowerState will be non-battery power). Simulate a power 21 // desktop, then the PowerState will be non-battery power). Simulate a power
24 // level change to get to a deterministic state. 22 // level change to get to a deterministic state.
25 manager.OnPowerStateChange(/* on_battery */ false); 23 manager.OnPowerStateChange(/* on_battery */ false);
26 24
27 // Loop a few times to test power toggling. 25 // Loop a few times to test power toggling.
28 for (int loop = 2; loop >= 0; --loop) { 26 for (int loop = 2; loop >= 0; --loop) {
29 // The manager has the high resolution clock enabled now. 27 // The manager has the high resolution clock enabled now.
30 EXPECT_TRUE(manager.hi_res_clock_available()); 28 EXPECT_TRUE(manager.hi_res_clock_available());
31 // But the Time class has it off, because it hasn't been activated. 29 // But the Time class has it off, because it hasn't been activated.
(...skipping 11 matching lines...) Expand all
43 // Simulate a off-battery power event. 41 // Simulate a off-battery power event.
44 manager.OnPowerStateChange(/* on_battery */ false); 42 manager.OnPowerStateChange(/* on_battery */ false);
45 EXPECT_TRUE(manager.hi_res_clock_available()); 43 EXPECT_TRUE(manager.hi_res_clock_available());
46 EXPECT_TRUE(base::Time::IsHighResolutionTimerInUse()); 44 EXPECT_TRUE(base::Time::IsHighResolutionTimerInUse());
47 45
48 // De-activate the high resolution timer. 46 // De-activate the high resolution timer.
49 base::Time::ActivateHighResolutionTimer(false); 47 base::Time::ActivateHighResolutionTimer(false);
50 } 48 }
51 } 49 }
52 #endif // defined(OS_WIN) 50 #endif // defined(OS_WIN)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698