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

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

Issue 1284073002: bluetooth: Add adapter to BluetoothDevice (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bt-drop-callback-
Patch Set: Updated patchset dependency Created 5 years, 4 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 : adapter_(new NiceMock<device::MockBluetoothAdapter>), 132 : adapter_(new NiceMock<device::MockBluetoothAdapter>),
133 remote_device_(kDeviceName, 133 remote_device_(kDeviceName,
134 kPublicKey, 134 kPublicKey,
135 kBluetoothAddress, 135 kBluetoothAddress,
136 kPersistentSymmetricKey), 136 kPersistentSymmetricKey),
137 service_uuid_(device::BluetoothUUID(kServiceUUID)), 137 service_uuid_(device::BluetoothUUID(kServiceUUID)),
138 to_peripheral_char_uuid_(device::BluetoothUUID(kToPeripheralCharUUID)), 138 to_peripheral_char_uuid_(device::BluetoothUUID(kToPeripheralCharUUID)),
139 from_peripheral_char_uuid_( 139 from_peripheral_char_uuid_(
140 device::BluetoothUUID(kFromPeripheralCharUUID)), 140 device::BluetoothUUID(kFromPeripheralCharUUID)),
141 gatt_connection_(new NiceMock<device::MockBluetoothGattConnection>( 141 gatt_connection_(new NiceMock<device::MockBluetoothGattConnection>(
142 adapter_,
142 kBluetoothAddress)), 143 kBluetoothAddress)),
143 gatt_connection_alias_(gatt_connection_.get()), 144 gatt_connection_alias_(gatt_connection_.get()),
144 notify_session_alias_(NULL), 145 notify_session_alias_(NULL),
145 bluetooth_throttler_(new NiceMock<MockBluetoothThrottler>), 146 bluetooth_throttler_(new NiceMock<MockBluetoothThrottler>),
146 task_runner_(new base::TestSimpleTaskRunner) {} 147 task_runner_(new base::TestSimpleTaskRunner) {}
147 148
148 void SetUp() override { 149 void SetUp() override {
149 device_ = make_scoped_ptr(new NiceMock<device::MockBluetoothDevice>( 150 device_ = make_scoped_ptr(new NiceMock<device::MockBluetoothDevice>(
150 adapter_.get(), 0, kDeviceName, kBluetoothAddress, false, false)); 151 adapter_.get(), 0, kDeviceName, kBluetoothAddress, false, false));
151 152
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 218
218 // Preparing |connection| to run |create_gatt_connection_success_callback_|. 219 // Preparing |connection| to run |create_gatt_connection_success_callback_|.
219 EXPECT_FALSE(create_gatt_connection_error_callback_.is_null()); 220 EXPECT_FALSE(create_gatt_connection_error_callback_.is_null());
220 ASSERT_FALSE(create_gatt_connection_success_callback_.is_null()); 221 ASSERT_FALSE(create_gatt_connection_success_callback_.is_null());
221 EXPECT_CALL(*connection, CreateCharacteristicsFinder(_, _)) 222 EXPECT_CALL(*connection, CreateCharacteristicsFinder(_, _))
222 .WillOnce(DoAll( 223 .WillOnce(DoAll(
223 SaveArg<0>(&characteristics_finder_success_callback_), 224 SaveArg<0>(&characteristics_finder_success_callback_),
224 SaveArg<1>(&characteristics_finder_error_callback_), 225 SaveArg<1>(&characteristics_finder_error_callback_),
225 Return(new NiceMock<MockBluetoothLowEnergyCharacteristicsFinder>))); 226 Return(new NiceMock<MockBluetoothLowEnergyCharacteristicsFinder>)));
226 227
227 create_gatt_connection_success_callback_.Run(make_scoped_ptr( 228 create_gatt_connection_success_callback_.Run(
228 new NiceMock<device::MockBluetoothGattConnection>(kBluetoothAddress))); 229 make_scoped_ptr(new NiceMock<device::MockBluetoothGattConnection>(
230 adapter_, kBluetoothAddress)));
229 231
230 EXPECT_EQ(connection->sub_status(), 232 EXPECT_EQ(connection->sub_status(),
231 BluetoothLowEnergyConnection::SubStatus::WAITING_CHARACTERISTICS); 233 BluetoothLowEnergyConnection::SubStatus::WAITING_CHARACTERISTICS);
232 EXPECT_EQ(connection->status(), Connection::IN_PROGRESS); 234 EXPECT_EQ(connection->status(), Connection::IN_PROGRESS);
233 } 235 }
234 236
235 // Transitions |connection| from WAITING_CHARACTERISTICS to 237 // Transitions |connection| from WAITING_CHARACTERISTICS to
236 // WAITING_NOTIFY_SESSION state. 238 // WAITING_NOTIFY_SESSION state.
237 void CharacteristicsFound(MockBluetoothLowEnergyConnection* connection) { 239 void CharacteristicsFound(MockBluetoothLowEnergyConnection* connection) {
238 EXPECT_CALL(*from_peripheral_char_, StartNotifySession(_, _)) 240 EXPECT_CALL(*from_peripheral_char_, StartNotifySession(_, _))
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 EXPECT_FALSE(create_gatt_connection_error_callback_.is_null()); 703 EXPECT_FALSE(create_gatt_connection_error_callback_.is_null());
702 ASSERT_FALSE(create_gatt_connection_success_callback_.is_null()); 704 ASSERT_FALSE(create_gatt_connection_success_callback_.is_null());
703 705
704 // Preparing |connection| to run |create_gatt_connection_success_callback_|. 706 // Preparing |connection| to run |create_gatt_connection_success_callback_|.
705 EXPECT_CALL(*connection, CreateCharacteristicsFinder(_, _)) 707 EXPECT_CALL(*connection, CreateCharacteristicsFinder(_, _))
706 .WillOnce(DoAll( 708 .WillOnce(DoAll(
707 SaveArg<0>(&characteristics_finder_success_callback_), 709 SaveArg<0>(&characteristics_finder_success_callback_),
708 SaveArg<1>(&characteristics_finder_error_callback_), 710 SaveArg<1>(&characteristics_finder_error_callback_),
709 Return(new NiceMock<MockBluetoothLowEnergyCharacteristicsFinder>))); 711 Return(new NiceMock<MockBluetoothLowEnergyCharacteristicsFinder>)));
710 712
711 create_gatt_connection_success_callback_.Run(make_scoped_ptr( 713 create_gatt_connection_success_callback_.Run(
712 new NiceMock<device::MockBluetoothGattConnection>(kBluetoothAddress))); 714 make_scoped_ptr(new NiceMock<device::MockBluetoothGattConnection>(
715 adapter_, kBluetoothAddress)));
713 716
714 CharacteristicsFound(connection.get()); 717 CharacteristicsFound(connection.get());
715 NotifySessionStarted(connection.get()); 718 NotifySessionStarted(connection.get());
716 ResponseSignalReceived(connection.get()); 719 ResponseSignalReceived(connection.get());
717 } 720 }
718 721
719 } // namespace proximity_auth 722 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698