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

Unified Diff: device/bluetooth/bluetooth_low_energy_win_fake.cc

Issue 1804093003: Add BluetoothGattCharacteristicTest::StartNotifySession_Reentrant unit test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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: device/bluetooth/bluetooth_low_energy_win_fake.cc
diff --git a/device/bluetooth/bluetooth_low_energy_win_fake.cc b/device/bluetooth/bluetooth_low_energy_win_fake.cc
index 3f4c1ff3f008ffb2c46f6fa5106096a6c2dfe01f..ef5dcd63e7d50d437a1378ab19688d0c46ba22e8 100644
--- a/device/bluetooth/bluetooth_low_energy_win_fake.cc
+++ b/device/bluetooth/bluetooth_low_energy_win_fake.cc
@@ -256,7 +256,6 @@ HRESULT BluetoothLowEnergyWrapperFake::RegisterGattEvents(
observer->callback = callback;
observer->context = context;
*out_handle = (BLUETOOTH_GATT_EVENT_HANDLE)observer.get();
- gatt_characteristic_observers_[*out_handle] = std::move(observer);
PBLUETOOTH_GATT_VALUE_CHANGED_EVENT_REGISTRATION parameter =
(PBLUETOOTH_GATT_VALUE_CHANGED_EVENT_REGISTRATION)event_parameter;
@@ -264,8 +263,18 @@ HRESULT BluetoothLowEnergyWrapperFake::RegisterGattEvents(
GattCharacteristic* target_characteristic = GetSimulatedGattCharacteristic(
service_path, &parameter->Characteristics[i]);
CHECK(target_characteristic);
+
+ // Return error simulated by SimulateGattCharacteristicSetNotifyError.
+ if (target_characteristic->notify_errors.size()) {
+ HRESULT error = target_characteristic->notify_errors[0];
+ target_characteristic->notify_errors.erase(
+ target_characteristic->notify_errors.begin());
+ return error;
+ }
+
target_characteristic->observers.push_back(*out_handle);
}
+ gatt_characteristic_observers_[*out_handle] = std::move(observer);
if (observer_)
observer_->OnStartCharacteristicNotification();
@@ -440,6 +449,12 @@ void BluetoothLowEnergyWrapperFake::
}
}
+void BluetoothLowEnergyWrapperFake::SimulateGattCharacteristicSetNotifyError(
+ GattCharacteristic* characteristic,
+ HRESULT error) {
+ characteristic->notify_errors.push_back(error);
+}
+
void BluetoothLowEnergyWrapperFake::SimulateGattCharacteristicReadError(
GattCharacteristic* characteristic,
HRESULT error) {

Powered by Google App Engine
This is Rietveld 408576698