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

Side by Side Diff: base/timer/hi_res_timer_manager_unittest.cc

Issue 179923006: Attempting to resolve a race condition with PowerMonitor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Win64 fixes Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « base/power_monitor/power_monitor_unittest.cc ('k') | base/timer/hi_res_timer_manager_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/timer/hi_res_timer_manager.h" 5 #include "base/timer/hi_res_timer_manager.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/power_monitor/power_monitor.h" 9 #include "base/power_monitor/power_monitor.h"
10 #include "base/power_monitor/power_monitor_device_source.h" 10 #include "base/power_monitor/power_monitor_device_source.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace base { 14 namespace base {
15 15
16 #if defined(OS_WIN) 16 #if defined(OS_WIN)
17 // http://crbug.com/114048 17 // http://crbug.com/114048
18 TEST(HiResTimerManagerTest, DISABLED_ToggleOnOff) { 18 TEST(HiResTimerManagerTest, DISABLED_ToggleOnOff) {
19 base::MessageLoop loop; 19 base::MessageLoop loop;
20 scoped_ptr<base::PowerMonitorSource> power_monitor_source( 20 scoped_ptr<base::PowerMonitorSource> power_monitor_source(
21 new base::PowerMonitorDeviceSource()); 21 new base::PowerMonitorDeviceSource());
22 scoped_ptr<base::PowerMonitor> power_monitor( 22 base::PowerMonitor::Initialize(power_monitor_source.Pass());
23 new base::PowerMonitor(power_monitor_source.Pass()));
24 HighResolutionTimerManager manager; 23 HighResolutionTimerManager manager;
25 24
26 // At this point, we don't know if the high resolution timers are on or off, 25 // At this point, we don't know if the high resolution timers are on or off,
27 // it depends on what system the tests are running on (for example, if this 26 // it depends on what system the tests are running on (for example, if this
28 // test is running on a laptop/battery, then the PowerMonitor would have 27 // test is running on a laptop/battery, then the PowerMonitor would have
29 // already set the PowerState to battery power; but if we're running on a 28 // already set the PowerState to battery power; but if we're running on a
30 // desktop, then the PowerState will be non-battery power). Simulate a power 29 // desktop, then the PowerState will be non-battery power). Simulate a power
31 // level change to get to a deterministic state. 30 // level change to get to a deterministic state.
32 manager.OnPowerStateChange(/* on_battery */ false); 31 manager.OnPowerStateChange(/* on_battery */ false);
33 32
(...skipping 14 matching lines...) Expand all
48 EXPECT_FALSE(base::Time::IsHighResolutionTimerInUse()); 47 EXPECT_FALSE(base::Time::IsHighResolutionTimerInUse());
49 48
50 // Simulate a off-battery power event. 49 // Simulate a off-battery power event.
51 manager.OnPowerStateChange(/* on_battery */ false); 50 manager.OnPowerStateChange(/* on_battery */ false);
52 EXPECT_TRUE(manager.hi_res_clock_available()); 51 EXPECT_TRUE(manager.hi_res_clock_available());
53 EXPECT_TRUE(base::Time::IsHighResolutionTimerInUse()); 52 EXPECT_TRUE(base::Time::IsHighResolutionTimerInUse());
54 53
55 // De-activate the high resolution timer. 54 // De-activate the high resolution timer.
56 base::Time::ActivateHighResolutionTimer(false); 55 base::Time::ActivateHighResolutionTimer(false);
57 } 56 }
57
58 base::PowerMonitor::ShutdownForTesting();
58 } 59 }
59 #endif // defined(OS_WIN) 60 #endif // defined(OS_WIN)
60 61
61 } // namespace base 62 } // namespace base
OLDNEW
« no previous file with comments | « base/power_monitor/power_monitor_unittest.cc ('k') | base/timer/hi_res_timer_manager_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698