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

Side by Side Diff: extensions/browser/api/bluetooth/bluetooth_apitest.cc

Issue 1902873002: Convert //extensions/browser/api 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
OLDNEW
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 <string.h> 5 #include <string.h>
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/extensions/extension_apitest.h" 9 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "chrome/browser/extensions/extension_function_test_utils.h" 10 #include "chrome/browser/extensions/extension_function_test_utils.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 device3_.reset(new testing::NiceMock<MockBluetoothDevice>( 69 device3_.reset(new testing::NiceMock<MockBluetoothDevice>(
70 mock_adapter_, 0, "d3", "31:32:33:34:35:36", 70 mock_adapter_, 0, "d3", "31:32:33:34:35:36",
71 false /* paired */, false /* connected */)); 71 false /* paired */, false /* connected */));
72 } 72 }
73 73
74 void DiscoverySessionCallback( 74 void DiscoverySessionCallback(
75 const BluetoothAdapter::DiscoverySessionCallback& callback, 75 const BluetoothAdapter::DiscoverySessionCallback& callback,
76 const BluetoothAdapter::ErrorCallback& error_callback) { 76 const BluetoothAdapter::ErrorCallback& error_callback) {
77 if (mock_session_.get()) { 77 if (mock_session_.get()) {
78 callback.Run( 78 callback.Run(
79 scoped_ptr<BluetoothDiscoverySession>(mock_session_.release())); 79 std::unique_ptr<BluetoothDiscoverySession>(mock_session_.release()));
80 return; 80 return;
81 } 81 }
82 error_callback.Run(); 82 error_callback.Run();
83 } 83 }
84 84
85 template <class T> 85 template <class T>
86 T* setupFunction(T* function) { 86 T* setupFunction(T* function) {
87 function->set_extension(empty_extension_.get()); 87 function->set_extension(empty_extension_.get());
88 function->set_has_callback(true); 88 function->set_has_callback(true);
89 return function; 89 return function;
90 } 90 }
91 91
92 protected: 92 protected:
93 testing::StrictMock<MockBluetoothAdapter>* mock_adapter_; 93 testing::StrictMock<MockBluetoothAdapter>* mock_adapter_;
94 scoped_ptr<testing::NiceMock<MockBluetoothDiscoverySession> > mock_session_; 94 std::unique_ptr<testing::NiceMock<MockBluetoothDiscoverySession>>
95 scoped_ptr<testing::NiceMock<MockBluetoothDevice> > device1_; 95 mock_session_;
96 scoped_ptr<testing::NiceMock<MockBluetoothDevice> > device2_; 96 std::unique_ptr<testing::NiceMock<MockBluetoothDevice>> device1_;
97 scoped_ptr<testing::NiceMock<MockBluetoothDevice> > device3_; 97 std::unique_ptr<testing::NiceMock<MockBluetoothDevice>> device2_;
98 std::unique_ptr<testing::NiceMock<MockBluetoothDevice>> device3_;
98 99
99 extensions::BluetoothEventRouter* event_router() { 100 extensions::BluetoothEventRouter* event_router() {
100 return bluetooth_api()->event_router(); 101 return bluetooth_api()->event_router();
101 } 102 }
102 103
103 extensions::BluetoothAPI* bluetooth_api() { 104 extensions::BluetoothAPI* bluetooth_api() {
104 return extensions::BluetoothAPI::Get(browser()->profile()); 105 return extensions::BluetoothAPI::Get(browser()->profile());
105 } 106 }
106 107
107 private: 108 private:
(...skipping 15 matching lines...) Expand all
123 EXPECT_CALL(*mock_adapter_, IsPresent()) 124 EXPECT_CALL(*mock_adapter_, IsPresent())
124 .WillOnce(testing::Return(false)); 125 .WillOnce(testing::Return(false));
125 EXPECT_CALL(*mock_adapter_, IsPowered()) 126 EXPECT_CALL(*mock_adapter_, IsPowered())
126 .WillOnce(testing::Return(true)); 127 .WillOnce(testing::Return(true));
127 EXPECT_CALL(*mock_adapter_, IsDiscovering()) 128 EXPECT_CALL(*mock_adapter_, IsDiscovering())
128 .WillOnce(testing::Return(false)); 129 .WillOnce(testing::Return(false));
129 130
130 scoped_refptr<api::BluetoothGetAdapterStateFunction> get_adapter_state; 131 scoped_refptr<api::BluetoothGetAdapterStateFunction> get_adapter_state;
131 get_adapter_state = setupFunction(new api::BluetoothGetAdapterStateFunction); 132 get_adapter_state = setupFunction(new api::BluetoothGetAdapterStateFunction);
132 133
133 scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( 134 std::unique_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult(
134 get_adapter_state.get(), "[]", browser())); 135 get_adapter_state.get(), "[]", browser()));
135 ASSERT_TRUE(result.get() != NULL); 136 ASSERT_TRUE(result.get() != NULL);
136 api::bluetooth::AdapterState state; 137 api::bluetooth::AdapterState state;
137 ASSERT_TRUE(api::bluetooth::AdapterState::Populate(*result, &state)); 138 ASSERT_TRUE(api::bluetooth::AdapterState::Populate(*result, &state));
138 139
139 EXPECT_FALSE(state.available); 140 EXPECT_FALSE(state.available);
140 EXPECT_TRUE(state.powered); 141 EXPECT_TRUE(state.powered);
141 EXPECT_FALSE(state.discovering); 142 EXPECT_FALSE(state.discovering);
142 EXPECT_EQ(kName, state.name); 143 EXPECT_EQ(kName, state.name);
143 EXPECT_EQ(kAdapterAddress, state.address); 144 EXPECT_EQ(kAdapterAddress, state.address);
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 // Load and wait for setup 449 // Load and wait for setup
449 ExtensionTestMessageListener listener("ready", true); 450 ExtensionTestMessageListener listener("ready", true);
450 ASSERT_TRUE( 451 ASSERT_TRUE(
451 LoadExtension(test_data_dir_.AppendASCII("bluetooth/device_info"))); 452 LoadExtension(test_data_dir_.AppendASCII("bluetooth/device_info")));
452 EXPECT_TRUE(listener.WaitUntilSatisfied()); 453 EXPECT_TRUE(listener.WaitUntilSatisfied());
453 454
454 listener.Reply("go"); 455 listener.Reply("go");
455 456
456 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 457 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
457 } 458 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698