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

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: rebase Created 4 years, 8 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 e370b700ee7c8c52217b9a12a5e7d3e0231dd4e1..c7ccd33fc92233d9eaf0b9a87b6a6b14e9281efc 100644
--- a/device/bluetooth/bluetooth_low_energy_win_fake.cc
+++ b/device/bluetooth/bluetooth_low_energy_win_fake.cc
@@ -261,7 +261,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;
@@ -269,8 +268,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();
@@ -481,6 +490,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