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

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

Issue 1973703002: Implement //device/bt changes for notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@notifications_dbus
Patch Set: Created 4 years, 7 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_bluez.cc
diff --git a/device/bluetooth/test/bluetooth_test_bluez.cc b/device/bluetooth/test/bluetooth_test_bluez.cc
index 7ee6ec6f65f2c85b63f481f00544825134a07995..66fe343d40ea89c0d14732c534f3ccf8b643acc1 100644
--- a/device/bluetooth/test/bluetooth_test_bluez.cc
+++ b/device/bluetooth/test/bluetooth_test_bluez.cc
@@ -239,6 +239,58 @@ void BluetoothTestBlueZ::SimulateLocalGattDescriptorValueWriteRequest(
run_loop.Run();
}
+bool BluetoothTestBlueZ::SimulateLocalGattCharacteristicNotificationsRequest(
+ BluetoothLocalGattService* service,
+ BluetoothLocalGattCharacteristic* characteristic,
+ bool start) {
+ bluez::BluetoothLocalGattCharacteristicBlueZ* characteristic_bluez =
+ static_cast<bluez::BluetoothLocalGattCharacteristicBlueZ*>(
+ characteristic);
+ bluez::FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client =
+ static_cast<bluez::FakeBluetoothGattManagerClient*>(
+ bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient());
+ bluez::FakeBluetoothGattCharacteristicServiceProvider*
+ characteristic_provider =
+ fake_bluetooth_gatt_manager_client->GetCharacteristicServiceProvider(
+ characteristic_bluez->object_path());
+
+ bluez::BluetoothLocalGattServiceBlueZ* service_bluez =
+ static_cast<bluez::BluetoothLocalGattServiceBlueZ*>(service);
+ static_cast<TestBluetoothLocalGattServiceDelegate*>(
+ service_bluez->GetDelegate())
+ ->set_expected_characteristic(characteristic);
+
+ return characteristic_provider->NotificationsChange(start);
+}
+
+bool BluetoothTestBlueZ::SimulateLocalGattCharacteristicSendValueUpdate(
+ BluetoothLocalGattService* service,
+ BluetoothLocalGattCharacteristic* characteristic,
+ const std::vector<uint8_t>& new_value) {
+ bluez::BluetoothLocalGattCharacteristicBlueZ* characteristic_bluez =
+ static_cast<bluez::BluetoothLocalGattCharacteristicBlueZ*>(
+ characteristic);
+ bluez::FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client =
+ static_cast<bluez::FakeBluetoothGattManagerClient*>(
+ bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient());
+ bluez::FakeBluetoothGattCharacteristicServiceProvider*
+ characteristic_provider =
+ fake_bluetooth_gatt_manager_client->GetCharacteristicServiceProvider(
+ characteristic_bluez->object_path());
+
+ bluez::BluetoothLocalGattServiceBlueZ* service_bluez =
+ static_cast<bluez::BluetoothLocalGattServiceBlueZ*>(service);
+ static_cast<TestBluetoothLocalGattServiceDelegate*>(
+ service_bluez->GetDelegate())
+ ->set_expected_characteristic(characteristic);
+
+ if (characteristic->NotifyValueChanged(new_value, false) !=
+ BluetoothLocalGattCharacteristic::NOTIFICATION_SUCCESS)
+ return false;
+
+ return characteristic_provider->sent_value() == new_value;
+}
+
std::vector<BluetoothLocalGattService*>
BluetoothTestBlueZ::RegisteredGattServices() {
std::vector<BluetoothLocalGattService*> services;

Powered by Google App Engine
This is Rietveld 408576698