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

Unified Diff: device/bluetooth/test/bluetooth_test_win.cc

Issue 1749403002: Implement BluetoothRemoteGattCharacteristicWin::StartNotifySession and related unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: adjust comments Created 4 years, 10 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/test/bluetooth_test_win.cc
diff --git a/device/bluetooth/test/bluetooth_test_win.cc b/device/bluetooth/test/bluetooth_test_win.cc
index cd852aaf9951764250a065ac4485e86db5b10cdd..7dedf2fc9c1856540d571aeca1d32fa96a1a56f5 100644
--- a/device/bluetooth/test/bluetooth_test_win.cc
+++ b/device/bluetooth/test/bluetooth_test_win.cc
@@ -13,6 +13,7 @@
#include "device/bluetooth/bluetooth_adapter_win.h"
#include "device/bluetooth/bluetooth_low_energy_win.h"
#include "device/bluetooth/bluetooth_remote_gatt_characteristic_win.h"
+#include "device/bluetooth/bluetooth_remote_gatt_descriptor_win.h"
#include "device/bluetooth/bluetooth_remote_gatt_service_win.h"
namespace {
@@ -121,6 +122,10 @@ bool BluetoothTestWin::DenyPermission() {
return false;
}
+void BluetoothTestWin::RunUntilIdle() {
+ FinishPendingTasks();
+}
+
void BluetoothTestWin::StartLowEnergyDiscoverySession() {
__super ::StartLowEnergyDiscoverySession();
FinishPendingTasks();
@@ -347,6 +352,16 @@ void BluetoothTestWin::SimulateGattCharacteristicWriteError(
FinishPendingTasks();
}
+void BluetoothTestWin::
+ SimulateGattCharacteristicSetNotifyWillFailSynchronouslyOnce(
+ BluetoothGattCharacteristic* characteristic) {
+ win::GattCharacteristic* target_characteristic =
+ GetSimulatedCharacteristic(characteristic);
+ CHECK(target_characteristic);
+ fake_bt_le_wrapper_->SimulateGattCharacteristicSetNotifyError(
+ target_characteristic, E_BLUETOOTH_ATT_UNKNOWN_ERROR);
+}
+
void BluetoothTestWin::DeleteDevice(BluetoothDevice* device) {
CHECK(device);
fake_bt_le_wrapper_->RemoveSimulatedBLEDevice(device->GetAddress());
@@ -364,6 +379,54 @@ void BluetoothTestWin::SimulateGattDescriptor(
ForceRefreshDevice();
}
+void BluetoothTestWin::SimulateGattDescriptorWriteWillFailSynchronouslyOnce(
+ BluetoothGattDescriptor* descriptor) {
+ BluetoothRemoteGattDescriptorWin* win_descriptor =
+ (BluetoothRemoteGattDescriptorWin*)descriptor;
+ win::GattCharacteristic* target_characteristic =
+ GetSimulatedCharacteristic(win_descriptor->GetCharacteristic());
+ CHECK(target_characteristic);
+ win::GattDescriptor* target_descriptor =
+ fake_bt_le_wrapper_->GetSimulatedDescriptor(
+ target_characteristic,
+ std::to_string(win_descriptor->GetAttributeHandle()));
+ CHECK(target_descriptor);
+ fake_bt_le_wrapper_->SimulateGattDescriptorWriteError(
+ target_descriptor, E_BLUETOOTH_ATT_REQUEST_NOT_SUPPORTED);
+}
+
+void BluetoothTestWin::SimulateGattNotifySessionStarted(
+ BluetoothGattCharacteristic* characteristic) {
+ FinishPendingTasks();
+}
+
+void BluetoothTestWin::SimulateGattCharacteristicChanged(
+ BluetoothGattCharacteristic* characteristic,
+ const std::vector<uint8_t>& value) {
+ BluetoothGattCharacteristic* target_characteristic = characteristic;
+ if (target_characteristic == nullptr)
+ target_characteristic = remembered_characteristic_;
+ CHECK(target_characteristic);
+
+ win::GattCharacteristic* simulated_characteristic =
+ GetSimulatedCharacteristic(target_characteristic);
+ CHECK(simulated_characteristic);
+ fake_bt_le_wrapper_->SimulateGattCharacteristicValue(simulated_characteristic,
+ value);
+ std::string device_address =
+ characteristic->GetService()->GetDevice()->GetAddress();
+ win::BLEDevice* target_device =
+ fake_bt_le_wrapper_->GetSimulatedBLEDevice(device_address);
+ CHECK(target_device);
+ win::GattService* parent_service =
+ GetSimulatedService(target_device, characteristic->GetService());
+ CHECK(parent_service);
+ fake_bt_le_wrapper_->SimulateCharacteristicValueChangeNotification(
+ parent_service, simulated_characteristic);
+
+ FinishPendingTasks();
+}
+
void BluetoothTestWin::OnAttemptReadGattCharacteristic() {
gatt_read_characteristic_attempts_++;
}
@@ -372,13 +435,25 @@ void BluetoothTestWin::OnAttemptWriteGattCharacteristic() {
gatt_write_characteristic_attempts_++;
}
-void BluetoothTestWin::onWriteGattCharacteristicValue(
+void BluetoothTestWin::OnWriteGattCharacteristicValue(
const PBTH_LE_GATT_CHARACTERISTIC_VALUE value) {
last_write_value_.clear();
for (ULONG i = 0; i < value->DataSize; i++)
last_write_value_.push_back(value->Data[i]);
}
+void BluetoothTestWin::OnWriteGattDescriptorValue(
+ const PBTH_LE_GATT_DESCRIPTOR_VALUE value) {
+ gatt_write_descriptor_attempts_++;
+ last_write_value_.clear();
+ for (ULONG i = 0; i < value->DataSize; i++)
+ last_write_value_.push_back(value->Data[i]);
+}
+
+void BluetoothTestWin::OnStartCharacteristicNotification() {
+ gatt_notify_characteristic_attempts_++;
+}
+
win::GattService* BluetoothTestWin::GetSimulatedService(
win::BLEDevice* device,
BluetoothGattService* service) {

Powered by Google App Engine
This is Rietveld 408576698