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 <utility> | 5 #include <utility> |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/thread_task_runner_handle.h" | 8 #include "base/thread_task_runner_handle.h" |
9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
10 #include "content/public/test/content_browser_test.h" | 10 #include "content/public/test/content_browser_test.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 class BatteryMonitorImplTest : public ContentBrowserTest { | 69 class BatteryMonitorImplTest : public ContentBrowserTest { |
70 public: | 70 public: |
71 BatteryMonitorImplTest() : battery_manager_(NULL), battery_service_(NULL) {} | 71 BatteryMonitorImplTest() : battery_manager_(NULL), battery_service_(NULL) {} |
72 | 72 |
73 void SetUpOnMainThread() override { | 73 void SetUpOnMainThread() override { |
74 battery_service_ = device::BatteryStatusService::GetInstance(); | 74 battery_service_ = device::BatteryStatusService::GetInstance(); |
75 | 75 |
76 // We keep a raw pointer to the FakeBatteryManager, which we expect to | 76 // We keep a raw pointer to the FakeBatteryManager, which we expect to |
77 // remain valid for the lifetime of the BatteryStatusService. | 77 // remain valid for the lifetime of the BatteryStatusService. |
78 scoped_ptr<FakeBatteryManager> battery_manager(new FakeBatteryManager( | 78 std::unique_ptr<FakeBatteryManager> battery_manager(new FakeBatteryManager( |
79 battery_service_->GetUpdateCallbackForTesting())); | 79 battery_service_->GetUpdateCallbackForTesting())); |
80 battery_manager_ = battery_manager.get(); | 80 battery_manager_ = battery_manager.get(); |
81 | 81 |
82 battery_service_->SetBatteryManagerForTesting(std::move(battery_manager)); | 82 battery_service_->SetBatteryManagerForTesting(std::move(battery_manager)); |
83 } | 83 } |
84 | 84 |
85 void TearDown() override { | 85 void TearDown() override { |
86 battery_service_->SetBatteryManagerForTesting( | 86 battery_service_->SetBatteryManagerForTesting( |
87 scoped_ptr<device::BatteryStatusManager>()); | 87 std::unique_ptr<device::BatteryStatusManager>()); |
88 battery_manager_ = NULL; | 88 battery_manager_ = NULL; |
89 } | 89 } |
90 | 90 |
91 FakeBatteryManager* battery_manager() { return battery_manager_; } | 91 FakeBatteryManager* battery_manager() { return battery_manager_; } |
92 | 92 |
93 private: | 93 private: |
94 FakeBatteryManager* battery_manager_; | 94 FakeBatteryManager* battery_manager_; |
95 device::BatteryStatusService* battery_service_; | 95 device::BatteryStatusService* battery_service_; |
96 | 96 |
97 DISALLOW_COPY_AND_ASSIGN(BatteryMonitorImplTest); | 97 DISALLOW_COPY_AND_ASSIGN(BatteryMonitorImplTest); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 battery_manager()->set_battery_status(status); | 149 battery_manager()->set_battery_status(status); |
150 battery_manager()->InvokeUpdateCallback(); | 150 battery_manager()->InvokeUpdateCallback(); |
151 same_tab_observer2.Wait(); | 151 same_tab_observer2.Wait(); |
152 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref()); | 152 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref()); |
153 EXPECT_TRUE(battery_manager()->started()); | 153 EXPECT_TRUE(battery_manager()->started()); |
154 } | 154 } |
155 | 155 |
156 } // namespace | 156 } // namespace |
157 | 157 |
158 } // namespace content | 158 } // namespace content |
OLD | NEW |