Chromium Code Reviews| Index: content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc |
| diff --git a/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc b/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc |
| index 9dd447ef1fcd710ffbf8d06c2ded1b310e7f529d..356b60fb319e0030cc9982ee0e4bdc1722c20955 100644 |
| --- a/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc |
| +++ b/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc |
| @@ -759,21 +759,28 @@ LayoutTestBluetoothAdapterProvider::GetDisconnectingHealthThermometer( |
| callback.Run(value); |
| })); |
| + ON_CALL(*user_description, WriteRemoteDescriptor(_, _, _)) |
|
ortuno
2017/01/28 00:22:51
Please update the docs in the header to reflect th
dougt
2017/01/31 00:31:25
Done.
|
| + .WillByDefault(RunCallback<1 /* success_callback */>()); |
| + |
| auto client_config = base::MakeUnique<NiceMockBluetoothGattDescriptor>( |
| measurement_interval.get(), "gatt.client_characteristic_configuration", |
| BluetoothUUID(kClientConfigUUID), false /* is_local */, |
| device::BluetoothRemoteGattCharacteristic::PROPERTY_READ | |
| device::BluetoothRemoteGattCharacteristic::PROPERTY_WRITE); |
| + ON_CALL(*client_config, WriteRemoteDescriptor(_, _, _)) |
|
ortuno
2017/01/28 00:22:51
nit for consistency:
// Crash if WriteRemoteDe
dougt
2017/01/31 00:31:25
Done.
|
| + .WillByDefault( |
| + Invoke([](const std::vector<uint8_t>&, const base::Closure&, |
| + const BluetoothRemoteGattDescriptor::ErrorCallback&) { |
| + NOTREACHED(); |
| + })); |
| + |
| auto no_read_descriptor = base::MakeUnique<NiceMockBluetoothGattDescriptor>( |
| measurement_interval.get(), kBlocklistedReadDescriptorUUID, |
| BluetoothUUID(kBlocklistedReadDescriptorUUID), false, |
| device::BluetoothRemoteGattCharacteristic::PROPERTY_READ | |
| device::BluetoothRemoteGattCharacteristic::PROPERTY_WRITE); |
| - std::vector<uint8_t> value(1); |
| - value[0] = false; |
| - |
| // Crash if ReadRemoteDescriptor called. Not using GoogleMock's Expect |
| // because this is used in layout tests that may not report a mock |
| // expectation |
| @@ -1132,6 +1139,28 @@ scoped_refptr<NiceMockBluetoothAdapter> LayoutTestBluetoothAdapterProvider:: |
| } |
| })); |
| + ON_CALL(*user_descriptor, WriteRemoteDescriptor(_, _, _)) |
| + .WillByDefault(Invoke([adapter_ptr, device_ptr, user_descriptor_ptr, |
| + disconnect, succeeds]( |
| + const std::vector<uint8_t>& value, const base::Closure& callback, |
| + const BluetoothRemoteGattDescriptor::ErrorCallback& error_callback) { |
| + base::Closure pending; |
| + if (succeeds) { |
| + pending = callback; |
| + } else { |
| + pending = base::Bind(error_callback, |
| + BluetoothRemoteGattService::GATT_ERROR_FAILED); |
| + } |
| + device_ptr->PushPendingCallback(pending); |
| + if (disconnect) { |
| + device_ptr->SetConnected(false); |
| + base::ThreadTaskRunnerHandle::Get()->PostTask( |
| + FROM_HERE, |
| + base::Bind(&NotifyDeviceChanged, base::RetainedRef(adapter_ptr), |
| + device_ptr)); |
| + } |
| + })); |
| + |
| measurement_interval->AddMockDescriptor(std::move(user_descriptor)); |
| health_thermometer->AddMockCharacteristic(std::move(measurement_interval)); |
| @@ -1731,6 +1760,9 @@ LayoutTestBluetoothAdapterProvider::GetErrorCharacteristic( |
| ON_CALL(*error_descriptor, ReadRemoteDescriptor(_, _)) |
| .WillByDefault(RunCallback<1 /* error_callback */>(error_code)); |
| + ON_CALL(*error_descriptor, WriteRemoteDescriptor(_, _, _)) |
| + .WillByDefault(RunCallback<2 /* error_callback */>(error_code)); |
| + |
| characteristic->AddMockDescriptor(std::move(error_descriptor)); |
| return characteristic; |