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

Side by Side 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 unified diff | Download patch
OLDNEW
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 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 ->set_expected_descriptor(descriptor); 232 ->set_expected_descriptor(descriptor);
233 233
234 base::RunLoop run_loop; 234 base::RunLoop run_loop;
235 descriptor_provider->SetValue( 235 descriptor_provider->SetValue(
236 value_to_write, 236 value_to_write,
237 base::Bind(&ClosureCallback, run_loop.QuitClosure(), success_callback), 237 base::Bind(&ClosureCallback, run_loop.QuitClosure(), success_callback),
238 base::Bind(&ClosureCallback, run_loop.QuitClosure(), error_callback)); 238 base::Bind(&ClosureCallback, run_loop.QuitClosure(), error_callback));
239 run_loop.Run(); 239 run_loop.Run();
240 } 240 }
241 241
242 bool BluetoothTestBlueZ::SimulateLocalGattCharacteristicNotificationsRequest(
243 BluetoothLocalGattService* service,
244 BluetoothLocalGattCharacteristic* characteristic,
245 bool start) {
246 bluez::BluetoothLocalGattCharacteristicBlueZ* characteristic_bluez =
247 static_cast<bluez::BluetoothLocalGattCharacteristicBlueZ*>(
248 characteristic);
249 bluez::FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client =
250 static_cast<bluez::FakeBluetoothGattManagerClient*>(
251 bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient());
252 bluez::FakeBluetoothGattCharacteristicServiceProvider*
253 characteristic_provider =
254 fake_bluetooth_gatt_manager_client->GetCharacteristicServiceProvider(
255 characteristic_bluez->object_path());
256
257 bluez::BluetoothLocalGattServiceBlueZ* service_bluez =
258 static_cast<bluez::BluetoothLocalGattServiceBlueZ*>(service);
259 static_cast<TestBluetoothLocalGattServiceDelegate*>(
260 service_bluez->GetDelegate())
261 ->set_expected_characteristic(characteristic);
262
263 return characteristic_provider->NotificationsChange(start);
264 }
265
266 std::vector<uint8_t> BluetoothTestBlueZ::LastNotifactionValueForCharacteristic(
267 BluetoothLocalGattCharacteristic* characteristic) {
268 bluez::BluetoothLocalGattCharacteristicBlueZ* characteristic_bluez =
269 static_cast<bluez::BluetoothLocalGattCharacteristicBlueZ*>(
270 characteristic);
271 bluez::FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client =
272 static_cast<bluez::FakeBluetoothGattManagerClient*>(
273 bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient());
274 bluez::FakeBluetoothGattCharacteristicServiceProvider*
275 characteristic_provider =
276 fake_bluetooth_gatt_manager_client->GetCharacteristicServiceProvider(
277 characteristic_bluez->object_path());
278
279 return characteristic_provider ? characteristic_provider->sent_value()
280 : std::vector<uint8_t>();
281 }
282
242 std::vector<BluetoothLocalGattService*> 283 std::vector<BluetoothLocalGattService*>
243 BluetoothTestBlueZ::RegisteredGattServices() { 284 BluetoothTestBlueZ::RegisteredGattServices() {
244 std::vector<BluetoothLocalGattService*> services; 285 std::vector<BluetoothLocalGattService*> services;
245 bluez::BluetoothAdapterBlueZ* adapter_bluez = 286 bluez::BluetoothAdapterBlueZ* adapter_bluez =
246 static_cast<bluez::BluetoothAdapterBlueZ*>(adapter_.get()); 287 static_cast<bluez::BluetoothAdapterBlueZ*>(adapter_.get());
247 288
248 for (const auto& iter : adapter_bluez->registered_gatt_services_) 289 for (const auto& iter : adapter_bluez->registered_gatt_services_)
249 services.push_back(iter.second); 290 services.push_back(iter.second);
250 return services; 291 return services;
251 } 292 }
252 293
253 } // namespace device 294 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/test/bluetooth_test_bluez.h ('k') | device/bluetooth/test/test_bluetooth_local_gatt_service_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698