| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "device/bluetooth/test/bluetooth_test_bluez.h" | 5 #include "device/bluetooth/test/bluetooth_test_bluez.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <tuple> |
| 8 #include <utility> | 9 #include <utility> |
| 9 | 10 |
| 10 #include "base/bind.h" | 11 #include "base/bind.h" |
| 11 #include "base/callback.h" | 12 #include "base/callback.h" |
| 12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 13 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 14 #include "dbus/object_path.h" | 15 #include "dbus/object_path.h" |
| 15 #include "device/bluetooth/bluez/bluetooth_adapter_bluez.h" | 16 #include "device/bluetooth/bluez/bluetooth_adapter_bluez.h" |
| 16 #include "device/bluetooth/bluez/bluetooth_device_bluez.h" | 17 #include "device/bluetooth/bluez/bluetooth_device_bluez.h" |
| 17 #include "device/bluetooth/bluez/bluetooth_gatt_characteristic_bluez.h" | 18 #include "device/bluetooth/bluez/bluetooth_gatt_characteristic_bluez.h" |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 bluez::BluetoothLocalGattServiceBlueZ* service_bluez = | 272 bluez::BluetoothLocalGattServiceBlueZ* service_bluez = |
| 272 static_cast<bluez::BluetoothLocalGattServiceBlueZ*>( | 273 static_cast<bluez::BluetoothLocalGattServiceBlueZ*>( |
| 273 characteristic->GetService()); | 274 characteristic->GetService()); |
| 274 static_cast<TestBluetoothLocalGattServiceDelegate*>( | 275 static_cast<TestBluetoothLocalGattServiceDelegate*>( |
| 275 service_bluez->GetDelegate()) | 276 service_bluez->GetDelegate()) |
| 276 ->set_expected_characteristic(characteristic); | 277 ->set_expected_characteristic(characteristic); |
| 277 | 278 |
| 278 return characteristic_provider->NotificationsChange(start); | 279 return characteristic_provider->NotificationsChange(start); |
| 279 } | 280 } |
| 280 | 281 |
| 281 std::vector<uint8_t> BluetoothTestBlueZ::LastNotifactionValueForCharacteristic( | 282 BluetoothTestBase::NotificationType |
| 283 BluetoothTestBlueZ::LastNotifactionValueForCharacteristic( |
| 282 BluetoothLocalGattCharacteristic* characteristic) { | 284 BluetoothLocalGattCharacteristic* characteristic) { |
| 283 bluez::BluetoothLocalGattCharacteristicBlueZ* characteristic_bluez = | 285 bluez::BluetoothLocalGattCharacteristicBlueZ* characteristic_bluez = |
| 284 static_cast<bluez::BluetoothLocalGattCharacteristicBlueZ*>( | 286 static_cast<bluez::BluetoothLocalGattCharacteristicBlueZ*>( |
| 285 characteristic); | 287 characteristic); |
| 286 bluez::FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = | 288 bluez::FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = |
| 287 static_cast<bluez::FakeBluetoothGattManagerClient*>( | 289 static_cast<bluez::FakeBluetoothGattManagerClient*>( |
| 288 bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient()); | 290 bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient()); |
| 289 bluez::FakeBluetoothGattCharacteristicServiceProvider* | 291 bluez::FakeBluetoothGattCharacteristicServiceProvider* |
| 290 characteristic_provider = | 292 characteristic_provider = |
| 291 fake_bluetooth_gatt_manager_client->GetCharacteristicServiceProvider( | 293 fake_bluetooth_gatt_manager_client->GetCharacteristicServiceProvider( |
| 292 characteristic_bluez->object_path()); | 294 characteristic_bluez->object_path()); |
| 293 | 295 |
| 294 return characteristic_provider ? characteristic_provider->sent_value() | 296 if (!characteristic_provider) |
| 295 : std::vector<uint8_t>(); | 297 return NotificationType(); |
| 298 |
| 299 bluez::BluetoothAdapterBlueZ* adapter_bluez = |
| 300 static_cast<bluez::BluetoothAdapterBlueZ*>(adapter_.get()); |
| 301 const NotificationType& value = characteristic_provider->sent_value(); |
| 302 |
| 303 std::string device_id; |
| 304 bluez::BluetoothDeviceBlueZ* device = |
| 305 adapter_bluez->GetDeviceWithPath(dbus::ObjectPath(std::get<0>(value))); |
| 306 if (device) |
| 307 device_id = device->GetIdentifier(); |
| 308 |
| 309 return make_tuple(device_id, std::get<1>(value), std::get<2>(value)); |
| 296 } | 310 } |
| 297 | 311 |
| 298 std::vector<BluetoothLocalGattService*> | 312 std::vector<BluetoothLocalGattService*> |
| 299 BluetoothTestBlueZ::RegisteredGattServices() { | 313 BluetoothTestBlueZ::RegisteredGattServices() { |
| 300 std::vector<BluetoothLocalGattService*> services; | 314 std::vector<BluetoothLocalGattService*> services; |
| 301 bluez::BluetoothAdapterBlueZ* adapter_bluez = | 315 bluez::BluetoothAdapterBlueZ* adapter_bluez = |
| 302 static_cast<bluez::BluetoothAdapterBlueZ*>(adapter_.get()); | 316 static_cast<bluez::BluetoothAdapterBlueZ*>(adapter_.get()); |
| 303 | 317 |
| 304 for (const auto& iter : adapter_bluez->registered_gatt_services_) | 318 for (const auto& iter : adapter_bluez->registered_gatt_services_) |
| 305 services.push_back(iter.second); | 319 services.push_back(iter.second); |
| 306 return services; | 320 return services; |
| 307 } | 321 } |
| 308 | 322 |
| 309 } // namespace device | 323 } // namespace device |
| OLD | NEW |