OLD | NEW |
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/system_monitor.h" | 5 #include "base/system_monitor.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 | 7 |
8 class PowerTest : public base::SystemMonitor::PowerObserver { | 8 class PowerTest : public base::SystemMonitor::PowerObserver { |
9 public: | 9 public: |
10 PowerTest() | 10 PowerTest() |
(...skipping 13 matching lines...) Expand all Loading... |
24 int suspends() { return suspends_; } | 24 int suspends() { return suspends_; } |
25 int resumes() { return resumes_; } | 25 int resumes() { return resumes_; } |
26 | 26 |
27 private: | 27 private: |
28 bool battery_; // Do we currently think we're on battery power. | 28 bool battery_; // Do we currently think we're on battery power. |
29 int power_state_changes_; // Count of OnPowerStateChange notifications. | 29 int power_state_changes_; // Count of OnPowerStateChange notifications. |
30 int suspends_; // Count of OnSuspend notifications. | 30 int suspends_; // Count of OnSuspend notifications. |
31 int resumes_; // Count of OnResume notifications. | 31 int resumes_; // Count of OnResume notifications. |
32 }; | 32 }; |
33 | 33 |
34 TEST(SystemMonitor, PowerNotifications) { | 34 // Disabled as a temporary workaround for http://crbug.com/12187 |
| 35 TEST(SystemMonitor, DISABLED_PowerNotifications) { |
35 const int kObservers = 5; | 36 const int kObservers = 5; |
36 | 37 |
37 // Initialize a message loop for this to run on. | 38 // Initialize a message loop for this to run on. |
38 MessageLoop loop; | 39 MessageLoop loop; |
39 // Initialize time() since it registers as a SystemMonitor observer. | 40 // Initialize time() since it registers as a SystemMonitor observer. |
40 base::Time now = base::Time::Now(); | 41 base::Time now = base::Time::Now(); |
41 | 42 |
42 base::SystemMonitor* monitor = base::SystemMonitor::Get(); | 43 base::SystemMonitor* monitor = base::SystemMonitor::Get(); |
43 PowerTest test[kObservers]; | 44 PowerTest test[kObservers]; |
44 for (int index = 0; index < kObservers; ++index) | 45 for (int index = 0; index < kObservers; ++index) |
(...skipping 24 matching lines...) Expand all Loading... |
69 // Pretend we were awakened. | 70 // Pretend we were awakened. |
70 monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT); | 71 monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT); |
71 loop.RunAllPending(); | 72 loop.RunAllPending(); |
72 EXPECT_EQ(test[0].resumes(), 1); | 73 EXPECT_EQ(test[0].resumes(), 1); |
73 | 74 |
74 // Send a duplicate resume notification. This should be suppressed. | 75 // Send a duplicate resume notification. This should be suppressed. |
75 monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT); | 76 monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT); |
76 loop.RunAllPending(); | 77 loop.RunAllPending(); |
77 EXPECT_EQ(test[0].resumes(), 1); | 78 EXPECT_EQ(test[0].resumes(), 1); |
78 } | 79 } |
OLD | NEW |