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

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: rebase 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/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..7596bb3be6012db2c4bfa89fe52196571c22d6a2 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 {
@@ -113,7 +114,6 @@ void BluetoothTestWin::InitWithFakeAdapter() {
&BluetoothTestWin::AdapterInitCallback, base::Unretained(this)));
adapter_win_ = static_cast<BluetoothAdapterWin*>(adapter_.get());
adapter_win_->InitForTest(nullptr, bluetooth_task_runner_);
- adapter_win_->GetWinBluetoothTaskManager()->AddObserver(this);
FinishPendingTasks();
}
@@ -318,7 +318,7 @@ void BluetoothTestWin::SimulateGattCharacteristicReadError(
win::GattCharacteristic* target_characteristic =
GetSimulatedCharacteristic(characteristic);
CHECK(target_characteristic);
- HRESULT hr = ERROR_SEM_TIMEOUT;
+ HRESULT hr = HRESULT_FROM_WIN32(ERROR_SEM_TIMEOUT);
if (error_code == BluetoothGattService::GATT_ERROR_INVALID_LENGTH)
hr = E_BLUETOOTH_ATT_INVALID_ATTRIBUTE_VALUE_LENGTH;
fake_bt_le_wrapper_->SimulateGattCharacteristicReadError(
@@ -338,7 +338,7 @@ void BluetoothTestWin::SimulateGattCharacteristicWriteError(
win::GattCharacteristic* target_characteristic =
GetSimulatedCharacteristic(characteristic);
CHECK(target_characteristic);
- HRESULT hr = ERROR_SEM_TIMEOUT;
+ HRESULT hr = HRESULT_FROM_WIN32(ERROR_SEM_TIMEOUT);
if (error_code == BluetoothGattService::GATT_ERROR_INVALID_LENGTH)
hr = E_BLUETOOTH_ATT_INVALID_ATTRIBUTE_VALUE_LENGTH;
fake_bt_le_wrapper_->SimulateGattCharacteristicWriteError(
@@ -364,21 +364,46 @@ void BluetoothTestWin::SimulateGattDescriptor(
ForceRefreshDevice();
}
-void BluetoothTestWin::OnAttemptReadGattCharacteristic() {
- gatt_read_characteristic_attempts_++;
+void BluetoothTestWin::SimulateGattNotifySessionStarted(
+ BluetoothGattCharacteristic* characteristic) {
+ FinishPendingTasks();
}
-void BluetoothTestWin::OnAttemptWriteGattCharacteristic() {
- gatt_write_characteristic_attempts_++;
+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);
+ fake_bt_le_wrapper_->SimulateCharacteristicValueChangeNotification(
+ simulated_characteristic);
+
+ FinishPendingTasks();
+}
+
+void BluetoothTestWin::OnReadGattCharacteristicValue() {
+ gatt_read_characteristic_attempts_++;
}
-void BluetoothTestWin::onWriteGattCharacteristicValue(
+void BluetoothTestWin::OnWriteGattCharacteristicValue(
const PBTH_LE_GATT_CHARACTERISTIC_VALUE value) {
+ gatt_write_characteristic_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) {
« device/bluetooth/bluetooth_task_manager_win.cc ('K') | « device/bluetooth/test/bluetooth_test_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698