OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/power_usage_monitor_impl.h" | 5 #include "content/browser/power_usage_monitor_impl.h" |
6 | 6 |
7 #include "content/public/browser/notification_types.h" | 7 #include "content/public/browser/notification_types.h" |
8 #include "content/public/test/test_browser_thread_bundle.h" | 8 #include "content/public/test/test_browser_thread_bundle.h" |
9 #include "device/battery/battery_monitor.mojom.h" | 9 #include "device/battery/battery_monitor.mojom.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 base::Time Now() override { return now_; } | 53 base::Time Now() override { return now_; } |
54 | 54 |
55 private: | 55 private: |
56 int num_pending_histogram_reports_; | 56 int num_pending_histogram_reports_; |
57 int discharge_percent_per_hour_; | 57 int discharge_percent_per_hour_; |
58 base::Time now_; | 58 base::Time now_; |
59 }; | 59 }; |
60 | 60 |
61 class PowerUsageMonitorTest : public testing::Test { | 61 class PowerUsageMonitorTest : public testing::Test { |
62 protected: | 62 protected: |
63 virtual void SetUp() { | 63 void SetUp() override { |
64 monitor_.reset(new PowerUsageMonitor); | 64 monitor_.reset(new PowerUsageMonitor); |
65 // PowerUsageMonitor assumes ownership. | 65 // PowerUsageMonitor assumes ownership. |
66 scoped_ptr<SystemInterfaceForTest> test_interface( | 66 scoped_ptr<SystemInterfaceForTest> test_interface( |
67 new SystemInterfaceForTest()); | 67 new SystemInterfaceForTest()); |
68 system_interface_ = test_interface.get(); | 68 system_interface_ = test_interface.get(); |
69 monitor_->SetSystemInterfaceForTest(test_interface.Pass()); | 69 monitor_->SetSystemInterfaceForTest(test_interface.Pass()); |
70 | 70 |
71 // Without live renderers, the monitor won't do anything. | 71 // Without live renderers, the monitor won't do anything. |
72 monitor_->OnRenderProcessNotification(NOTIFICATION_RENDERER_PROCESS_CREATED, | 72 monitor_->OnRenderProcessNotification(NOTIFICATION_RENDERER_PROCESS_CREATED, |
73 kDummyRenderProcessHostID); | 73 kDummyRenderProcessHostID); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 ASSERT_EQ(0, system_interface_->num_pending_histogram_reports()); | 158 ASSERT_EQ(0, system_interface_->num_pending_histogram_reports()); |
159 | 159 |
160 // Wall power connected. | 160 // Wall power connected. |
161 system_interface_->AdvanceClockMinutes(31); | 161 system_interface_->AdvanceClockMinutes(31); |
162 UpdateBatteryStatus(true, 0); | 162 UpdateBatteryStatus(true, 0); |
163 ASSERT_EQ(0, system_interface_->num_pending_histogram_reports()); | 163 ASSERT_EQ(0, system_interface_->num_pending_histogram_reports()); |
164 ASSERT_EQ(0, system_interface_->discharge_percent_per_hour()); | 164 ASSERT_EQ(0, system_interface_->discharge_percent_per_hour()); |
165 } | 165 } |
166 | 166 |
167 } // namespace content | 167 } // namespace content |
OLD | NEW |