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 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
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 TEST(SystemMonitor, PowerRequirements) { | |
141 #if defined(OS_WIN) | |
142 MessageLoop loop; | |
143 SystemMonitor system_monitor; | |
144 ASSERT_EQ(0, system_monitor.GetPowerRequirementsCountForTest()); | |
145 | |
146 system_monitor.BeginPowerRequirement(SystemMonitor::TEST_REQUIRED, "foo"); | |
147 ASSERT_EQ(1, system_monitor.GetPowerRequirementsCountForTest()); | |
148 | |
149 system_monitor.BeginPowerRequirement(SystemMonitor::TEST_REQUIRED, "bar"); | |
150 ASSERT_EQ(2, system_monitor.GetPowerRequirementsCountForTest()); | |
151 | |
152 // A second identical request should not increase the request count. | |
153 system_monitor.BeginPowerRequirement(SystemMonitor::TEST_REQUIRED, "bar"); | |
154 ASSERT_EQ(2, system_monitor.GetPowerRequirementsCountForTest()); | |
155 | |
156 system_monitor.EndPowerRequirement(SystemMonitor::TEST_REQUIRED, "foo"); | |
157 ASSERT_EQ(1, system_monitor.GetPowerRequirementsCountForTest()); | |
158 | |
159 // The request count should not decrease until all identical requests end. | |
160 system_monitor.EndPowerRequirement(SystemMonitor::TEST_REQUIRED, "bar"); | |
161 ASSERT_EQ(1, system_monitor.GetPowerRequirementsCountForTest()); | |
162 | |
163 system_monitor.EndPowerRequirement(SystemMonitor::TEST_REQUIRED, "bar"); | |
164 ASSERT_EQ(0, system_monitor.GetPowerRequirementsCountForTest()); | |
165 #endif // defined(OS_WIN) | |
166 } | |
167 | |
168 } // namespace base | 140 } // namespace base |
OLD | NEW |