| OLD | NEW |
| 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 "content/shell/browser/layout_test/layout_test_bluetooth_adapter_provid
er.h" | 5 #include "content/shell/browser/layout_test/layout_test_bluetooth_adapter_provid
er.h" |
| 6 | 6 |
| 7 #include "device/bluetooth/bluetooth_adapter.h" | 7 #include "device/bluetooth/bluetooth_adapter.h" |
| 8 #include "device/bluetooth/bluetooth_device.h" | 8 #include "device/bluetooth/bluetooth_device.h" |
| 9 #include "device/bluetooth/bluetooth_discovery_session.h" | 9 #include "device/bluetooth/bluetooth_discovery_session.h" |
| 10 #include "device/bluetooth/bluetooth_uuid.h" | 10 #include "device/bluetooth/bluetooth_uuid.h" |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 GetGattService(empty_device.get(), kGenericAccessServiceUUID)); | 265 GetGattService(empty_device.get(), kGenericAccessServiceUUID)); |
| 266 scoped_ptr<NiceMock<MockBluetoothGattCharacteristic>> | 266 scoped_ptr<NiceMock<MockBluetoothGattCharacteristic>> |
| 267 device_name_characteristic(GetGattCharacteristic( | 267 device_name_characteristic(GetGattCharacteristic( |
| 268 generic_access.get(), "2A00" /* Device Name */)); | 268 generic_access.get(), "2A00" /* Device Name */)); |
| 269 | 269 |
| 270 std::vector<uint8_t> device_name_value(device_name.begin(), | 270 std::vector<uint8_t> device_name_value(device_name.begin(), |
| 271 device_name.end()); | 271 device_name.end()); |
| 272 ON_CALL(*device_name_characteristic, ReadRemoteCharacteristic(_, _)) | 272 ON_CALL(*device_name_characteristic, ReadRemoteCharacteristic(_, _)) |
| 273 .WillByDefault(RunCallback<0>(device_name_value)); | 273 .WillByDefault(RunCallback<0>(device_name_value)); |
| 274 | 274 |
| 275 ON_CALL(*device_name_characteristic, WriteRemoteCharacteristic(_, _, _)) |
| 276 .WillByDefault(RunCallback<2 /* error callback */>( |
| 277 BluetoothGattService::GATT_ERROR_NOT_PERMITTED)); |
| 278 |
| 275 generic_access->AddMockCharacteristic(device_name_characteristic.Pass()); | 279 generic_access->AddMockCharacteristic(device_name_characteristic.Pass()); |
| 276 | 280 |
| 277 scoped_ptr<NiceMock<MockBluetoothGattCharacteristic>> reconnection_address( | 281 scoped_ptr<NiceMock<MockBluetoothGattCharacteristic>> reconnection_address( |
| 278 GetGattCharacteristic(generic_access.get(), | 282 GetGattCharacteristic(generic_access.get(), |
| 279 "2A03" /* Reconnection Address */)); | 283 "2A03" /* Reconnection Address */)); |
| 280 | 284 |
| 281 ON_CALL(*reconnection_address, ReadRemoteCharacteristic(_, _)) | 285 ON_CALL(*reconnection_address, ReadRemoteCharacteristic(_, _)) |
| 282 .WillByDefault( | 286 .WillByDefault( |
| 283 RunCallback<1>(BluetoothGattService::GATT_ERROR_NOT_PERMITTED)); | 287 RunCallback<1>(BluetoothGattService::GATT_ERROR_NOT_PERMITTED)); |
| 284 | 288 |
| 289 ON_CALL(*reconnection_address, WriteRemoteCharacteristic(_, _, _)) |
| 290 .WillByDefault(RunCallback<1 /* success callback */>()); |
| 291 |
| 285 generic_access->AddMockCharacteristic(reconnection_address.Pass()); | 292 generic_access->AddMockCharacteristic(reconnection_address.Pass()); |
| 286 | 293 |
| 287 empty_device->AddMockService(generic_access.Pass()); | 294 empty_device->AddMockService(generic_access.Pass()); |
| 288 | 295 |
| 289 // Using Invoke allows the device returned from this method to be futher | 296 // Using Invoke allows the device returned from this method to be futher |
| 290 // modified and have more services added to it. The call to ::GetGattServices | 297 // modified and have more services added to it. The call to ::GetGattServices |
| 291 // will invoke ::GetMockServices, returning all services added up to that | 298 // will invoke ::GetMockServices, returning all services added up to that |
| 292 // time. | 299 // time. |
| 293 ON_CALL(*empty_device, GetGattServices()) | 300 ON_CALL(*empty_device, GetGattServices()) |
| 294 .WillByDefault( | 301 .WillByDefault( |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 scoped_ptr<NiceMock<MockBluetoothGattCharacteristic>> | 366 scoped_ptr<NiceMock<MockBluetoothGattCharacteristic>> |
| 360 LayoutTestBluetoothAdapterProvider::GetGattCharacteristic( | 367 LayoutTestBluetoothAdapterProvider::GetGattCharacteristic( |
| 361 MockBluetoothGattService* service, | 368 MockBluetoothGattService* service, |
| 362 const std::string& uuid) { | 369 const std::string& uuid) { |
| 363 return make_scoped_ptr(new NiceMock<MockBluetoothGattCharacteristic>( | 370 return make_scoped_ptr(new NiceMock<MockBluetoothGattCharacteristic>( |
| 364 service, uuid /* identifier */, BluetoothUUID(uuid), false /* is_local */, | 371 service, uuid /* identifier */, BluetoothUUID(uuid), false /* is_local */, |
| 365 NULL /* properties */, NULL /* permissions */)); | 372 NULL /* properties */, NULL /* permissions */)); |
| 366 } | 373 } |
| 367 | 374 |
| 368 } // namespace content | 375 } // namespace content |
| OLD | NEW |