| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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() |
| 11 : battery_(false), | 11 : battery_(false), |
| 12 power_state_changes_(0), | 12 power_state_changes_(0), |
| 13 suspends_(0), | 13 suspends_(0), |
| 14 resumes_(0) {}; | 14 resumes_(0) {}; |
| 15 | 15 |
| 16 // PowerObserver callbacks. | 16 // PowerObserver callbacks. |
| 17 void OnPowerStateChange(bool on_battery_power) { | 17 void OnPowerStateChange(bool on_battery_power) { |
| 18 power_state_changes_++; | 18 power_state_changes_++; |
| 19 } | 19 } |
| 20 | 20 |
| 21 void OnSuspend() { | 21 void OnSuspend() { |
| 22 suspends_++; | 22 suspends_++; |
| 23 } | 23 } |
| 24 | 24 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 // Pretend we were awakened. | 77 // Pretend we were awakened. |
| 78 system_monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT); | 78 system_monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT); |
| 79 loop.RunAllPending(); | 79 loop.RunAllPending(); |
| 80 EXPECT_EQ(test[0].resumes(), 1); | 80 EXPECT_EQ(test[0].resumes(), 1); |
| 81 | 81 |
| 82 // Send a duplicate resume notification. This should be suppressed. | 82 // Send a duplicate resume notification. This should be suppressed. |
| 83 system_monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT); | 83 system_monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT); |
| 84 loop.RunAllPending(); | 84 loop.RunAllPending(); |
| 85 EXPECT_EQ(test[0].resumes(), 1); | 85 EXPECT_EQ(test[0].resumes(), 1); |
| 86 } | 86 } |
| OLD | NEW |