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

Side by Side Diff: components/proximity_auth/ble/bluetooth_low_energy_connection_unittest.cc

Issue 1548203002: Convert Pass()→std::move() in //components/[n-z]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bad headers Created 4 years, 12 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/proximity_auth/ble/bluetooth_low_energy_connection.h" 5 #include "components/proximity_auth/ble/bluetooth_low_energy_connection.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
14 #include "base/run_loop.h" 15 #include "base/run_loop.h"
15 #include "base/test/test_simple_task_runner.h" 16 #include "base/test/test_simple_task_runner.h"
16 #include "components/proximity_auth/ble/bluetooth_low_energy_characteristics_fin der.h" 17 #include "components/proximity_auth/ble/bluetooth_low_energy_characteristics_fin der.h"
17 #include "components/proximity_auth/bluetooth_throttler.h" 18 #include "components/proximity_auth/bluetooth_throttler.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 new MockBluetoothLowEnergyConnection( 179 new MockBluetoothLowEnergyConnection(
179 remote_device_, adapter_, service_uuid_, bluetooth_throttler_.get(), 180 remote_device_, adapter_, service_uuid_, bluetooth_throttler_.get(),
180 kMaxNumberOfTries)); 181 kMaxNumberOfTries));
181 182
182 EXPECT_EQ(connection->sub_status(), 183 EXPECT_EQ(connection->sub_status(),
183 BluetoothLowEnergyConnection::SubStatus::DISCONNECTED); 184 BluetoothLowEnergyConnection::SubStatus::DISCONNECTED);
184 EXPECT_EQ(connection->status(), Connection::DISCONNECTED); 185 EXPECT_EQ(connection->status(), Connection::DISCONNECTED);
185 186
186 connection->SetTaskRunnerForTesting(task_runner_); 187 connection->SetTaskRunnerForTesting(task_runner_);
187 188
188 return connection.Pass(); 189 return connection;
189 } 190 }
190 191
191 // Transitions |connection| from DISCONNECTED to WAITING_CHARACTERISTICS 192 // Transitions |connection| from DISCONNECTED to WAITING_CHARACTERISTICS
192 // state, without an existing GATT connection. 193 // state, without an existing GATT connection.
193 void ConnectGatt(MockBluetoothLowEnergyConnection* connection) { 194 void ConnectGatt(MockBluetoothLowEnergyConnection* connection) {
194 // Preparing |connection| for a CreateGattConnection call. 195 // Preparing |connection| for a CreateGattConnection call.
195 EXPECT_CALL(*device_, CreateGattConnection(_, _)) 196 EXPECT_CALL(*device_, CreateGattConnection(_, _))
196 .WillOnce(DoAll(SaveArg<0>(&create_gatt_connection_success_callback_), 197 .WillOnce(DoAll(SaveArg<0>(&create_gatt_connection_success_callback_),
197 SaveArg<1>(&create_gatt_connection_error_callback_))); 198 SaveArg<1>(&create_gatt_connection_error_callback_)));
198 199
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 SaveArg<2>(&write_remote_characteristic_error_callback_))); 254 SaveArg<2>(&write_remote_characteristic_error_callback_)));
254 EXPECT_FALSE(notify_session_error_callback_.is_null()); 255 EXPECT_FALSE(notify_session_error_callback_.is_null());
255 ASSERT_FALSE(notify_session_success_callback_.is_null()); 256 ASSERT_FALSE(notify_session_success_callback_.is_null());
256 257
257 // Store an alias for the notify session passed |connection|. 258 // Store an alias for the notify session passed |connection|.
258 scoped_ptr<device::MockBluetoothGattNotifySession> notify_session( 259 scoped_ptr<device::MockBluetoothGattNotifySession> notify_session(
259 new NiceMock<device::MockBluetoothGattNotifySession>( 260 new NiceMock<device::MockBluetoothGattNotifySession>(
260 kToPeripheralCharID)); 261 kToPeripheralCharID));
261 notify_session_alias_ = notify_session.get(); 262 notify_session_alias_ = notify_session.get();
262 263
263 notify_session_success_callback_.Run(notify_session.Pass()); 264 notify_session_success_callback_.Run(std::move(notify_session));
264 task_runner_->RunUntilIdle(); 265 task_runner_->RunUntilIdle();
265 266
266 EXPECT_EQ(connection->sub_status(), 267 EXPECT_EQ(connection->sub_status(),
267 BluetoothLowEnergyConnection::SubStatus::WAITING_RESPONSE_SIGNAL); 268 BluetoothLowEnergyConnection::SubStatus::WAITING_RESPONSE_SIGNAL);
268 EXPECT_EQ(connection->status(), Connection::IN_PROGRESS); 269 EXPECT_EQ(connection->status(), Connection::IN_PROGRESS);
269 } 270 }
270 271
271 // Transitions |connection| from WAITING_RESPONSE_SIGNAL to CONNECTED state. 272 // Transitions |connection| from WAITING_RESPONSE_SIGNAL to CONNECTED state.
272 void ResponseSignalReceived(MockBluetoothLowEnergyConnection* connection) { 273 void ResponseSignalReceived(MockBluetoothLowEnergyConnection* connection) {
273 // Written value contains only the 274 // Written value contains only the
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 create_gatt_connection_success_callback_.Run( 676 create_gatt_connection_success_callback_.Run(
676 make_scoped_ptr(new NiceMock<device::MockBluetoothGattConnection>( 677 make_scoped_ptr(new NiceMock<device::MockBluetoothGattConnection>(
677 adapter_, kTestRemoteDeviceBluetoothAddress))); 678 adapter_, kTestRemoteDeviceBluetoothAddress)));
678 679
679 CharacteristicsFound(connection.get()); 680 CharacteristicsFound(connection.get());
680 NotifySessionStarted(connection.get()); 681 NotifySessionStarted(connection.get());
681 ResponseSignalReceived(connection.get()); 682 ResponseSignalReceived(connection.get());
682 } 683 }
683 684
684 } // namespace proximity_auth 685 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698