Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: content/browser/power_monitor_message_broadcaster_unittest.cc

Issue 1874893002: Convert //content/browser from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/plugin_service_impl.h ('k') | content/browser/power_save_blocker_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/macros.h" 5 #include "base/macros.h"
6 #include "base/test/power_monitor_test_base.h" 6 #include "base/test/power_monitor_test_base.h"
7 #include "content/browser/power_monitor_message_broadcaster.h" 7 #include "content/browser/power_monitor_message_broadcaster.h"
8 #include "content/common/power_monitor_messages.h" 8 #include "content/common/power_monitor_messages.h"
9 #include "ipc/ipc_sender.h" 9 #include "ipc/ipc_sender.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 int power_state_changes_; // Count of OnPowerStateChange notifications. 45 int power_state_changes_; // Count of OnPowerStateChange notifications.
46 int suspends_; // Count of OnSuspend notifications. 46 int suspends_; // Count of OnSuspend notifications.
47 int resumes_; // Count of OnResume notifications. 47 int resumes_; // Count of OnResume notifications.
48 }; 48 };
49 49
50 class PowerMonitorMessageBroadcasterTest : public testing::Test { 50 class PowerMonitorMessageBroadcasterTest : public testing::Test {
51 protected: 51 protected:
52 PowerMonitorMessageBroadcasterTest() { 52 PowerMonitorMessageBroadcasterTest() {
53 power_monitor_source_ = new base::PowerMonitorTestSource(); 53 power_monitor_source_ = new base::PowerMonitorTestSource();
54 power_monitor_.reset(new base::PowerMonitor( 54 power_monitor_.reset(new base::PowerMonitor(
55 scoped_ptr<base::PowerMonitorSource>(power_monitor_source_))); 55 std::unique_ptr<base::PowerMonitorSource>(power_monitor_source_)));
56 } 56 }
57 ~PowerMonitorMessageBroadcasterTest() override {} 57 ~PowerMonitorMessageBroadcasterTest() override {}
58 58
59 base::PowerMonitorTestSource* source() { return power_monitor_source_; } 59 base::PowerMonitorTestSource* source() { return power_monitor_source_; }
60 base::PowerMonitor* monitor() { return power_monitor_.get(); } 60 base::PowerMonitor* monitor() { return power_monitor_.get(); }
61 61
62 private: 62 private:
63 base::PowerMonitorTestSource* power_monitor_source_; 63 base::PowerMonitorTestSource* power_monitor_source_;
64 scoped_ptr<base::PowerMonitor> power_monitor_; 64 std::unique_ptr<base::PowerMonitor> power_monitor_;
65 65
66 DISALLOW_COPY_AND_ASSIGN(PowerMonitorMessageBroadcasterTest); 66 DISALLOW_COPY_AND_ASSIGN(PowerMonitorMessageBroadcasterTest);
67 }; 67 };
68 68
69 TEST_F(PowerMonitorMessageBroadcasterTest, PowerMessageBroadcast) { 69 TEST_F(PowerMonitorMessageBroadcasterTest, PowerMessageBroadcast) {
70 PowerMonitorMessageSender sender; 70 PowerMonitorMessageSender sender;
71 PowerMonitorMessageBroadcaster broadcaster(&sender); 71 PowerMonitorMessageBroadcaster broadcaster(&sender);
72 72
73 // Calling Init should invoke a power state change. 73 // Calling Init should invoke a power state change.
74 broadcaster.Init(); 74 broadcaster.Init();
(...skipping 30 matching lines...) Expand all
105 // Pretend the device has gone off battery power 105 // Pretend the device has gone off battery power
106 source()->GeneratePowerStateEvent(false); 106 source()->GeneratePowerStateEvent(false);
107 EXPECT_EQ(sender.power_state_changes(), 3); 107 EXPECT_EQ(sender.power_state_changes(), 3);
108 108
109 // Repeated indications the device is off battery power should be suppressed. 109 // Repeated indications the device is off battery power should be suppressed.
110 source()->GeneratePowerStateEvent(false); 110 source()->GeneratePowerStateEvent(false);
111 EXPECT_EQ(sender.power_state_changes(), 3); 111 EXPECT_EQ(sender.power_state_changes(), 3);
112 } 112 }
113 113
114 } // namespace base 114 } // namespace base
OLDNEW
« no previous file with comments | « content/browser/plugin_service_impl.h ('k') | content/browser/power_save_blocker_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698