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 // Disabled as a temporary workaround for http://crbug.com/12187 | 34 TEST(SystemMonitor, PowerNotifications) { |
35 TEST(SystemMonitor, DISABLED_PowerNotifications) { | |
36 const int kObservers = 5; | 35 const int kObservers = 5; |
37 | 36 |
38 // Initialize a message loop for this to run on. | 37 // Initialize a message loop for this to run on. |
39 MessageLoop loop; | 38 MessageLoop loop; |
40 // Initialize time() since it registers as a SystemMonitor observer. | 39 // Initialize time() since it registers as a SystemMonitor observer. |
41 base::Time now = base::Time::Now(); | 40 base::Time now = base::Time::Now(); |
42 | 41 |
43 base::SystemMonitor* monitor = base::SystemMonitor::Get(); | 42 base::SystemMonitor* monitor = base::SystemMonitor::Get(); |
44 PowerTest test[kObservers]; | 43 PowerTest test[kObservers]; |
45 for (int index = 0; index < kObservers; ++index) | 44 for (int index = 0; index < kObservers; ++index) |
(...skipping 24 matching lines...) Expand all Loading... |
70 // Pretend we were awakened. | 69 // Pretend we were awakened. |
71 monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT); | 70 monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT); |
72 loop.RunAllPending(); | 71 loop.RunAllPending(); |
73 EXPECT_EQ(test[0].resumes(), 1); | 72 EXPECT_EQ(test[0].resumes(), 1); |
74 | 73 |
75 // Send a duplicate resume notification. This should be suppressed. | 74 // Send a duplicate resume notification. This should be suppressed. |
76 monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT); | 75 monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT); |
77 loop.RunAllPending(); | 76 loop.RunAllPending(); |
78 EXPECT_EQ(test[0].resumes(), 1); | 77 EXPECT_EQ(test[0].resumes(), 1); |
79 } | 78 } |
OLD | NEW |