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

Side by Side Diff: extensions/browser/api/bluetooth/bluetooth_private_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 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 <memory>
5 #include <utility> 6 #include <utility>
6 7
7 #include "base/command_line.h" 8 #include "base/command_line.h"
8 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "chrome/browser/extensions/extension_apitest.h" 11 #include "chrome/browser/extensions/extension_apitest.h"
12 #include "device/bluetooth/test/mock_bluetooth_adapter.h" 12 #include "device/bluetooth/test/mock_bluetooth_adapter.h"
13 #include "device/bluetooth/test/mock_bluetooth_device.h" 13 #include "device/bluetooth/test/mock_bluetooth_device.h"
14 #include "device/bluetooth/test/mock_bluetooth_discovery_session.h" 14 #include "device/bluetooth/test/mock_bluetooth_discovery_session.h"
15 #include "extensions/browser/api/bluetooth/bluetooth_api.h" 15 #include "extensions/browser/api/bluetooth/bluetooth_api.h"
16 #include "extensions/browser/api/bluetooth/bluetooth_event_router.h" 16 #include "extensions/browser/api/bluetooth/bluetooth_event_router.h"
17 #include "extensions/browser/event_router.h" 17 #include "extensions/browser/event_router.h"
18 #include "extensions/common/api/bluetooth_private.h" 18 #include "extensions/common/api/bluetooth_private.h"
19 #include "extensions/common/switches.h" 19 #include "extensions/common/switches.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } 99 }
100 100
101 void DispatchPairingEvent(bt_private::PairingEventType pairing_event_type) { 101 void DispatchPairingEvent(bt_private::PairingEventType pairing_event_type) {
102 bt_private::PairingEvent pairing_event; 102 bt_private::PairingEvent pairing_event;
103 pairing_event.pairing = pairing_event_type; 103 pairing_event.pairing = pairing_event_type;
104 pairing_event.device.name.reset(new std::string(kDeviceName)); 104 pairing_event.device.name.reset(new std::string(kDeviceName));
105 pairing_event.device.address = mock_device_->GetAddress(); 105 pairing_event.device.address = mock_device_->GetAddress();
106 pairing_event.device.vendor_id_source = bt::VENDOR_ID_SOURCE_USB; 106 pairing_event.device.vendor_id_source = bt::VENDOR_ID_SOURCE_USB;
107 pairing_event.device.type = bt::DEVICE_TYPE_PHONE; 107 pairing_event.device.type = bt::DEVICE_TYPE_PHONE;
108 108
109 scoped_ptr<base::ListValue> args = 109 std::unique_ptr<base::ListValue> args =
110 bt_private::OnPairing::Create(pairing_event); 110 bt_private::OnPairing::Create(pairing_event);
111 scoped_ptr<Event> event(new Event(events::BLUETOOTH_PRIVATE_ON_PAIRING, 111 std::unique_ptr<Event> event(new Event(events::BLUETOOTH_PRIVATE_ON_PAIRING,
112 bt_private::OnPairing::kEventName, 112 bt_private::OnPairing::kEventName,
113 std::move(args))); 113 std::move(args)));
114 EventRouter::Get(browser()->profile()) 114 EventRouter::Get(browser()->profile())
115 ->DispatchEventToExtension(kTestExtensionId, std::move(event)); 115 ->DispatchEventToExtension(kTestExtensionId, std::move(event));
116 } 116 }
117 117
118 void DispatchAuthorizePairingEvent() { 118 void DispatchAuthorizePairingEvent() {
119 DispatchPairingEvent(bt_private::PAIRING_EVENT_TYPE_REQUESTAUTHORIZATION); 119 DispatchPairingEvent(bt_private::PAIRING_EVENT_TYPE_REQUESTAUTHORIZATION);
120 } 120 }
121 121
122 void DispatchPincodePairingEvent() { 122 void DispatchPincodePairingEvent() {
123 DispatchPairingEvent(bt_private::PAIRING_EVENT_TYPE_REQUESTPINCODE); 123 DispatchPairingEvent(bt_private::PAIRING_EVENT_TYPE_REQUESTPINCODE);
124 } 124 }
125 125
126 void DispatchPasskeyPairingEvent() { 126 void DispatchPasskeyPairingEvent() {
127 DispatchPairingEvent(bt_private::PAIRING_EVENT_TYPE_REQUESTPASSKEY); 127 DispatchPairingEvent(bt_private::PAIRING_EVENT_TYPE_REQUESTPASSKEY);
128 } 128 }
129 129
130 void DispatchConfirmPasskeyPairingEvent() { 130 void DispatchConfirmPasskeyPairingEvent() {
131 DispatchPairingEvent(bt_private::PAIRING_EVENT_TYPE_CONFIRMPASSKEY); 131 DispatchPairingEvent(bt_private::PAIRING_EVENT_TYPE_CONFIRMPASSKEY);
132 } 132 }
133 133
134 void CallSetDiscoveryFilterCallback( 134 void CallSetDiscoveryFilterCallback(
135 device::BluetoothAdapter::DiscoverySessionCallback callback) { 135 device::BluetoothAdapter::DiscoverySessionCallback callback) {
136 auto session_ptr = scoped_ptr<NiceMock<MockBluetoothDiscoverySession>>( 136 auto session_ptr = std::unique_ptr<NiceMock<MockBluetoothDiscoverySession>>(
137 mock_discovery_session_); 137 mock_discovery_session_);
138 138
139 callback.Run(std::move(session_ptr)); 139 callback.Run(std::move(session_ptr));
140 } 140 }
141 141
142 protected: 142 protected:
143 std::string adapter_name_; 143 std::string adapter_name_;
144 bool adapter_powered_; 144 bool adapter_powered_;
145 bool adapter_discoverable_; 145 bool adapter_discoverable_;
146 146
147 scoped_refptr<NiceMock<MockBluetoothAdapter> > mock_adapter_; 147 scoped_refptr<NiceMock<MockBluetoothAdapter> > mock_adapter_;
148 scoped_ptr<NiceMock<MockBluetoothDevice> > mock_device_; 148 std::unique_ptr<NiceMock<MockBluetoothDevice>> mock_device_;
149 149
150 // This discovery session will be owned by EventRouter, we'll only keep 150 // This discovery session will be owned by EventRouter, we'll only keep
151 // pointer to it. 151 // pointer to it.
152 NiceMock<MockBluetoothDiscoverySession>* mock_discovery_session_; 152 NiceMock<MockBluetoothDiscoverySession>* mock_discovery_session_;
153 }; 153 };
154 154
155 ACTION_TEMPLATE(InvokeCallbackArgument, 155 ACTION_TEMPLATE(InvokeCallbackArgument,
156 HAS_1_TEMPLATE_PARAMS(int, k), 156 HAS_1_TEMPLATE_PARAMS(int, k),
157 AND_0_VALUE_PARAMS()) { 157 AND_0_VALUE_PARAMS()) {
158 ::std::tr1::get<k>(args).Run(); 158 ::std::tr1::get<k>(args).Run();
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 EXPECT_CALL(*mock_device_.get(), Pair(_, _, _)) 294 EXPECT_CALL(*mock_device_.get(), Pair(_, _, _))
295 .WillOnce(DoAll( 295 .WillOnce(DoAll(
296 WithoutArgs(Invoke( 296 WithoutArgs(Invoke(
297 this, 297 this,
298 &BluetoothPrivateApiTest::DispatchConfirmPasskeyPairingEvent)), 298 &BluetoothPrivateApiTest::DispatchConfirmPasskeyPairingEvent)),
299 InvokeCallbackArgument<1>())); 299 InvokeCallbackArgument<1>()));
300 ASSERT_TRUE(RunComponentExtensionTest("bluetooth_private/pair")) << message_; 300 ASSERT_TRUE(RunComponentExtensionTest("bluetooth_private/pair")) << message_;
301 } 301 }
302 302
303 } // namespace extensions 303 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698