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

Unified Diff: content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc

Issue 2445633002: bluetooth: Require frame to be connected for writValue to succeed. (Closed)
Patch Set: Fix documentation Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
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 eba00675d4082d560d77735fedf4978735adf0dc..86401e1a471071a0c95da1e94b6d5faa7d2b40b9 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
@@ -670,7 +670,8 @@ LayoutTestBluetoothAdapterProvider::GetDisconnectingHealthThermometer() {
GetBaseGATTCharacteristic(
"Measurement Interval", health_thermometer.get(),
kMeasurementIntervalUUID,
- BluetoothRemoteGattCharacteristic::PROPERTY_READ));
+ BluetoothRemoteGattCharacteristic::PROPERTY_READ |
+ BluetoothRemoteGattCharacteristic::PROPERTY_WRITE));
NiceMockBluetoothGattCharacteristic* measurement_ptr =
measurement_interval.get();
@@ -684,7 +685,11 @@ LayoutTestBluetoothAdapterProvider::GetDisconnectingHealthThermometer() {
}
return interval;
}));
- // TODO(crbug.com/608538): Mock Write and StartNotifySession.
+
+ ON_CALL(*measurement_interval, WriteRemoteCharacteristic(_, _, _))
+ .WillByDefault(RunCallback<1 /* success callback */>());
+
+ // TODO(crbug.com/608538): Mock StartNotifySession.
health_thermometer->AddMockCharacteristic(std::move(measurement_interval));
device->AddMockService(std::move(health_thermometer));
@@ -902,7 +907,8 @@ scoped_refptr<NiceMockBluetoothAdapter> LayoutTestBluetoothAdapterProvider::
GetBaseGATTCharacteristic(
"Measurement Interval", health_thermometer.get(),
kMeasurementIntervalUUID,
- BluetoothRemoteGattCharacteristic::PROPERTY_READ));
+ BluetoothRemoteGattCharacteristic::PROPERTY_READ |
+ BluetoothRemoteGattCharacteristic::PROPERTY_WRITE));
NiceMockBluetoothGattCharacteristic* measurement_ptr =
measurement_interval.get();
@@ -931,6 +937,27 @@ scoped_refptr<NiceMockBluetoothAdapter> LayoutTestBluetoothAdapterProvider::
}
}));
+ ON_CALL(*measurement_interval, WriteRemoteCharacteristic(_, _, _))
+ .WillByDefault(Invoke([adapter_ptr, device_ptr, disconnect, succeeds](
+ const std::vector<uint8_t>& value, const base::Closure& callback,
+ const BluetoothRemoteGattCharacteristic::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));
+ }
+ }));
health_thermometer->AddMockCharacteristic(std::move(measurement_interval));
device->AddMockService(std::move(health_thermometer));
adapter->AddMockDevice(std::move(device));

Powered by Google App Engine
This is Rietveld 408576698