OLD | NEW |
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/file_path.h" | 5 #include "base/file_path.h" |
6 #include "base/test/mock_devices_changed_observer.h" | 6 #include "base/test/mock_devices_changed_observer.h" |
7 #include "base/system_monitor/system_monitor.h" | 7 #include "base/system_monitor/system_monitor.h" |
8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 namespace base { | 11 namespace base { |
12 | 12 |
13 class PowerTest : public SystemMonitor::PowerObserver { | 13 class PowerTest : public SystemMonitor::PowerObserver { |
14 public: | 14 public: |
15 PowerTest() | 15 PowerTest() |
16 : battery_(false), | 16 : battery_(false), |
17 power_state_changes_(0), | 17 power_state_changes_(0), |
18 suspends_(0), | 18 suspends_(0), |
19 resumes_(0) { | 19 resumes_(0) { |
20 } | 20 } |
21 | 21 |
22 // PowerObserver callbacks. | 22 // PowerObserver callbacks. |
23 void OnPowerStateChange(bool on_battery_power) { | 23 virtual void OnPowerStateChange(bool on_battery_power) OVERRIDE { |
24 power_state_changes_++; | 24 power_state_changes_++; |
25 } | 25 } |
26 | 26 |
27 void OnSuspend() { | 27 virtual void OnSuspend() OVERRIDE { |
28 suspends_++; | 28 suspends_++; |
29 } | 29 } |
30 | 30 |
31 void OnResume() { | 31 virtual void OnResume() OVERRIDE { |
32 resumes_++; | 32 resumes_++; |
33 } | 33 } |
34 | 34 |
35 // Test status counts. | 35 // Test status counts. |
36 bool battery() { return battery_; } | 36 bool battery() { return battery_; } |
37 int power_state_changes() { return power_state_changes_; } | 37 int power_state_changes() { return power_state_changes_; } |
38 int suspends() { return suspends_; } | 38 int suspends() { return suspends_; } |
39 int resumes() { return resumes_; } | 39 int resumes() { return resumes_; } |
40 | 40 |
41 private: | 41 private: |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 system_monitor.ProcessMediaDeviceAttached( | 131 system_monitor.ProcessMediaDeviceAttached( |
132 1, "media device", FilePath(FILE_PATH_LITERAL("path"))); | 132 1, "media device", FilePath(FILE_PATH_LITERAL("path"))); |
133 loop.RunAllPending(); | 133 loop.RunAllPending(); |
134 | 134 |
135 system_monitor.ProcessMediaDeviceDetached(1); | 135 system_monitor.ProcessMediaDeviceDetached(1); |
136 system_monitor.ProcessMediaDeviceDetached(2); | 136 system_monitor.ProcessMediaDeviceDetached(2); |
137 loop.RunAllPending(); | 137 loop.RunAllPending(); |
138 } | 138 } |
139 | 139 |
140 } // namespace base | 140 } // namespace base |
OLD | NEW |