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

Side by Side Diff: device/bluetooth/bluez/bluetooth_gatt_bluez_unittest.cc

Issue 1979633004: Invoke GattDiscoveryCompleteForService by observing ServicesResolved property (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_attr
Patch Set: Invoke GattDiscoveryCompleteForService for each GATT service once 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 EXPECT_TRUE(device->IsConnected()); 261 EXPECT_TRUE(device->IsConnected());
262 EXPECT_TRUE(gatt_conn_->IsConnected()); 262 EXPECT_TRUE(gatt_conn_->IsConnected());
263 263
264 fake_bluetooth_device_client_->RemoveDevice( 264 fake_bluetooth_device_client_->RemoveDevice(
265 dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), 265 dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath),
266 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); 266 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
267 ASSERT_TRUE(gatt_conn_.get()); 267 ASSERT_TRUE(gatt_conn_.get());
268 EXPECT_FALSE(gatt_conn_->IsConnected()); 268 EXPECT_FALSE(gatt_conn_->IsConnected());
269 } 269 }
270 270
271 TEST_F(BluetoothGattBlueZTest, GattServiceAddedAndRemoved) { 271 TEST_F(BluetoothGattBlueZTest, GattServiceAddedAndRemoved) {
scheib 2016/05/16 20:22:26 Lots of test code here. Please point out code, or
Miao 2016/05/17 18:08:27 Removed the added lines in other tests and created
272 // Create a fake LE device. We store the device pointer here because this is a 272 // Create a fake LE device. We store the device pointer here because this is a
273 // test. It's unsafe to do this in production as the device might get deleted. 273 // test. It's unsafe to do this in production as the device might get deleted.
274 fake_bluetooth_device_client_->CreateDevice( 274 fake_bluetooth_device_client_->CreateDevice(
275 dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), 275 dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath),
276 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); 276 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
277 BluetoothDevice* device = 277 BluetoothDevice* device =
278 adapter_->GetDevice(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress); 278 adapter_->GetDevice(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress);
279 bluez::FakeBluetoothDeviceClient::Properties* properties =
280 fake_bluetooth_device_client_->GetProperties(
281 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
279 ASSERT_TRUE(device); 282 ASSERT_TRUE(device);
280 283
281 TestBluetoothAdapterObserver observer(adapter_); 284 TestBluetoothAdapterObserver observer(adapter_);
282 285
283 EXPECT_EQ(0, observer.gatt_service_added_count()); 286 EXPECT_EQ(0, observer.gatt_service_added_count());
284 EXPECT_EQ(0, observer.gatt_service_removed_count()); 287 EXPECT_EQ(0, observer.gatt_service_removed_count());
288 EXPECT_EQ(0, observer.gatt_discovery_complete_count());
289 EXPECT_TRUE(device->GetGattServices().empty());
285 EXPECT_TRUE(observer.last_gatt_service_id().empty()); 290 EXPECT_TRUE(observer.last_gatt_service_id().empty());
286 EXPECT_FALSE(observer.last_gatt_service_uuid().IsValid()); 291 EXPECT_FALSE(observer.last_gatt_service_uuid().IsValid());
287 EXPECT_TRUE(device->GetGattServices().empty()); 292 EXPECT_TRUE(device->GetGattServices().empty());
288 293
289 // Expose the fake Heart Rate Service. 294 // Expose the fake Heart Rate Service.
290 fake_bluetooth_gatt_service_client_->ExposeHeartRateService( 295 fake_bluetooth_gatt_service_client_->ExposeHeartRateService(
291 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); 296 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
297 // Notify that all services have been discovered.
298 properties->services_resolved.ReplaceValue(true);
292 EXPECT_EQ(1, observer.gatt_service_added_count()); 299 EXPECT_EQ(1, observer.gatt_service_added_count());
293 EXPECT_EQ(0, observer.gatt_service_removed_count()); 300 EXPECT_EQ(0, observer.gatt_service_removed_count());
301 EXPECT_EQ(1, observer.gatt_discovery_complete_count());
294 EXPECT_FALSE(observer.last_gatt_service_id().empty()); 302 EXPECT_FALSE(observer.last_gatt_service_id().empty());
295 EXPECT_EQ(1U, device->GetGattServices().size()); 303 EXPECT_EQ(1U, device->GetGattServices().size());
296 EXPECT_EQ(BluetoothUUID( 304 EXPECT_EQ(BluetoothUUID(
297 bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID), 305 bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID),
298 observer.last_gatt_service_uuid()); 306 observer.last_gatt_service_uuid());
299 307
300 BluetoothRemoteGattService* service = 308 BluetoothRemoteGattService* service =
301 device->GetGattService(observer.last_gatt_service_id()); 309 device->GetGattService(observer.last_gatt_service_id());
302 EXPECT_TRUE(service->IsPrimary()); 310 EXPECT_TRUE(service->IsPrimary());
303 EXPECT_EQ(service, device->GetGattServices()[0]); 311 EXPECT_EQ(service, device->GetGattServices()[0]);
304 EXPECT_EQ(service, device->GetGattService(service->GetIdentifier())); 312 EXPECT_EQ(service, device->GetGattService(service->GetIdentifier()));
305 313
306 EXPECT_EQ(observer.last_gatt_service_uuid(), service->GetUUID()); 314 EXPECT_EQ(observer.last_gatt_service_uuid(), service->GetUUID());
307 315
308 // Hide the service. 316 // Hide the service.
309 observer.last_gatt_service_uuid() = BluetoothUUID(); 317 observer.last_gatt_service_uuid() = BluetoothUUID();
310 observer.last_gatt_service_id().clear(); 318 observer.last_gatt_service_id().clear();
311 fake_bluetooth_gatt_service_client_->HideHeartRateService(); 319 fake_bluetooth_gatt_service_client_->HideHeartRateService();
312 320
313 EXPECT_EQ(1, observer.gatt_service_added_count()); 321 EXPECT_EQ(1, observer.gatt_service_added_count());
314 EXPECT_EQ(1, observer.gatt_service_removed_count()); 322 EXPECT_EQ(1, observer.gatt_service_removed_count());
323 EXPECT_EQ(1, observer.gatt_discovery_complete_count());
315 EXPECT_FALSE(observer.last_gatt_service_id().empty()); 324 EXPECT_FALSE(observer.last_gatt_service_id().empty());
316 EXPECT_TRUE(device->GetGattServices().empty()); 325 EXPECT_TRUE(device->GetGattServices().empty());
317 EXPECT_EQ(BluetoothUUID( 326 EXPECT_EQ(BluetoothUUID(
318 bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID), 327 bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID),
319 observer.last_gatt_service_uuid()); 328 observer.last_gatt_service_uuid());
320 329
321 EXPECT_EQ(NULL, device->GetGattService(observer.last_gatt_service_id())); 330 EXPECT_EQ(NULL, device->GetGattService(observer.last_gatt_service_id()));
322 331
323 // Expose the service again. 332 // Expose the service again.
324 observer.last_gatt_service_uuid() = BluetoothUUID(); 333 observer.last_gatt_service_uuid() = BluetoothUUID();
325 observer.last_gatt_service_id().clear(); 334 observer.last_gatt_service_id().clear();
326 fake_bluetooth_gatt_service_client_->ExposeHeartRateService( 335 fake_bluetooth_gatt_service_client_->ExposeHeartRateService(
327 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); 336 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
337 // Notify that all services have been discovered.
338 properties->services_resolved.ReplaceValue(true);
339
328 EXPECT_EQ(2, observer.gatt_service_added_count()); 340 EXPECT_EQ(2, observer.gatt_service_added_count());
329 EXPECT_EQ(1, observer.gatt_service_removed_count()); 341 EXPECT_EQ(1, observer.gatt_service_removed_count());
342 EXPECT_EQ(2, observer.gatt_discovery_complete_count());
330 EXPECT_FALSE(observer.last_gatt_service_id().empty()); 343 EXPECT_FALSE(observer.last_gatt_service_id().empty());
331 EXPECT_EQ(1U, device->GetGattServices().size()); 344 EXPECT_EQ(1U, device->GetGattServices().size());
332 EXPECT_EQ(BluetoothUUID( 345 EXPECT_EQ(BluetoothUUID(
333 bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID), 346 bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID),
334 observer.last_gatt_service_uuid()); 347 observer.last_gatt_service_uuid());
335 348
336 // The object |service| points to should have been deallocated. |device| 349 // The object |service| points to should have been deallocated. |device|
337 // should contain a brand new instance. 350 // should contain a brand new instance.
338 service = device->GetGattService(observer.last_gatt_service_id()); 351 service = device->GetGattService(observer.last_gatt_service_id());
339 EXPECT_EQ(service, device->GetGattServices()[0]); 352 EXPECT_EQ(service, device->GetGattServices()[0]);
340 EXPECT_TRUE(service->IsPrimary()); 353 EXPECT_TRUE(service->IsPrimary());
341 354
342 EXPECT_EQ(observer.last_gatt_service_uuid(), service->GetUUID()); 355 EXPECT_EQ(observer.last_gatt_service_uuid(), service->GetUUID());
343 356
344 // Remove the device. The observer should be notified of the removed service. 357 // Remove the device. The observer should be notified of the removed service.
345 // |device| becomes invalid after this. 358 // |device| becomes invalid after this.
346 observer.last_gatt_service_uuid() = BluetoothUUID(); 359 observer.last_gatt_service_uuid() = BluetoothUUID();
347 observer.last_gatt_service_id().clear(); 360 observer.last_gatt_service_id().clear();
348 fake_bluetooth_device_client_->RemoveDevice( 361 fake_bluetooth_device_client_->RemoveDevice(
349 dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), 362 dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath),
350 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); 363 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
351 364
352 EXPECT_EQ(2, observer.gatt_service_added_count()); 365 EXPECT_EQ(2, observer.gatt_service_added_count());
353 EXPECT_EQ(2, observer.gatt_service_removed_count()); 366 EXPECT_EQ(2, observer.gatt_service_removed_count());
367 EXPECT_EQ(2, observer.gatt_discovery_complete_count());
354 EXPECT_FALSE(observer.last_gatt_service_id().empty()); 368 EXPECT_FALSE(observer.last_gatt_service_id().empty());
355 EXPECT_EQ(BluetoothUUID( 369 EXPECT_EQ(BluetoothUUID(
356 bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID), 370 bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID),
357 observer.last_gatt_service_uuid()); 371 observer.last_gatt_service_uuid());
358 EXPECT_EQ(NULL, adapter_->GetDevice( 372 EXPECT_EQ(NULL, adapter_->GetDevice(
359 bluez::FakeBluetoothDeviceClient::kLowEnergyAddress)); 373 bluez::FakeBluetoothDeviceClient::kLowEnergyAddress));
360 } 374 }
361 375
362 TEST_F(BluetoothGattBlueZTest, ServicesDiscovered) { 376 TEST_F(BluetoothGattBlueZTest, ServicesDiscovered) {
363 // Create a fake LE device. We store the device pointer here because this is a 377 // Create a fake LE device. We store the device pointer here because this is a
364 // test. It's unsafe to do this in production as the device might get deleted. 378 // test. It's unsafe to do this in production as the device might get deleted.
365 fake_bluetooth_device_client_->CreateDevice( 379 fake_bluetooth_device_client_->CreateDevice(
366 dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), 380 dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath),
367 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); 381 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
368 BluetoothDevice* device = 382 BluetoothDevice* device =
369 adapter_->GetDevice(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress); 383 adapter_->GetDevice(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress);
370 bluez::FakeBluetoothDeviceClient::Properties* properties = 384 bluez::FakeBluetoothDeviceClient::Properties* properties =
371 fake_bluetooth_device_client_->GetProperties( 385 fake_bluetooth_device_client_->GetProperties(
372 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); 386 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
373 387
374 ASSERT_TRUE(device); 388 ASSERT_TRUE(device);
375 389
390 device->CreateGattConnection(
391 base::Bind(&BluetoothGattBlueZTest::GattConnectionCallback,
392 base::Unretained(this)),
393 base::Bind(&BluetoothGattBlueZTest::ConnectErrorCallback,
394 base::Unretained(this)));
395
396 EXPECT_EQ(1, success_callback_count_);
397 EXPECT_EQ(0, error_callback_count_);
398 EXPECT_TRUE(device->IsConnected());
399 ASSERT_TRUE(gatt_conn_.get());
400 EXPECT_TRUE(gatt_conn_->IsConnected());
401 EXPECT_EQ(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress,
402 gatt_conn_->GetDeviceAddress());
403
376 TestBluetoothAdapterObserver observer(adapter_); 404 TestBluetoothAdapterObserver observer(adapter_);
377 405
406 EXPECT_EQ(0, observer.gatt_discovery_complete_count());
407 EXPECT_TRUE(device->GetGattServices().empty());
408
378 // Expose the fake Heart Rate Service. 409 // Expose the fake Heart Rate Service.
379 fake_bluetooth_gatt_service_client_->ExposeHeartRateService( 410 fake_bluetooth_gatt_service_client_->ExposeHeartRateService(
380 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); 411 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
381 // Notify that all services have been discovered. 412 // Notify that all services have been discovered.
382 properties->services_resolved.ReplaceValue(true); 413 properties->services_resolved.ReplaceValue(true);
383
384 EXPECT_TRUE(device->IsGattServicesDiscoveryComplete()); 414 EXPECT_TRUE(device->IsGattServicesDiscoveryComplete());
385 EXPECT_EQ(1u, device->GetGattServices().size()); 415 EXPECT_EQ(1u, device->GetGattServices().size());
386 EXPECT_EQ(device, observer.last_device()); 416 EXPECT_EQ(device, observer.last_device());
417 EXPECT_EQ(1, observer.gatt_discovery_complete_count());
387 EXPECT_EQ(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress, 418 EXPECT_EQ(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress,
388 observer.last_device_address()); 419 observer.last_device_address());
389 420
390 // Disconnect from the device: 421 // Disconnect from the device:
391 device->Disconnect(base::Bind(&BluetoothGattBlueZTest::SuccessCallback, 422 device->Disconnect(base::Bind(&BluetoothGattBlueZTest::SuccessCallback,
392 base::Unretained(this)), 423 base::Unretained(this)),
393 base::Bind(&BluetoothGattBlueZTest::ErrorCallback, 424 base::Bind(&BluetoothGattBlueZTest::ErrorCallback,
394 base::Unretained(this))); 425 base::Unretained(this)));
395 fake_bluetooth_gatt_service_client_->HideHeartRateService(); 426 fake_bluetooth_gatt_service_client_->HideHeartRateService();
396 properties->connected.ReplaceValue(false); 427 properties->connected.ReplaceValue(false);
397 properties->services_resolved.ReplaceValue(false); 428 properties->services_resolved.ReplaceValue(false);
398 429
399 EXPECT_FALSE(device->IsConnected()); 430 EXPECT_FALSE(device->IsConnected());
400 EXPECT_FALSE(device->IsGattServicesDiscoveryComplete()); 431 EXPECT_FALSE(device->IsGattServicesDiscoveryComplete());
432 EXPECT_EQ(1, observer.gatt_discovery_complete_count());
401 EXPECT_EQ(0u, device->GetGattServices().size()); 433 EXPECT_EQ(0u, device->GetGattServices().size());
402 434
403 // Verify that the device can be connected to again: 435 // Verify that the device can be connected to again:
404 device->CreateGattConnection( 436 device->CreateGattConnection(
405 base::Bind(&BluetoothGattBlueZTest::GattConnectionCallback, 437 base::Bind(&BluetoothGattBlueZTest::GattConnectionCallback,
406 base::Unretained(this)), 438 base::Unretained(this)),
407 base::Bind(&BluetoothGattBlueZTest::ConnectErrorCallback, 439 base::Bind(&BluetoothGattBlueZTest::ConnectErrorCallback,
408 base::Unretained(this))); 440 base::Unretained(this)));
409 properties->connected.ReplaceValue(true); 441 properties->connected.ReplaceValue(true);
410 EXPECT_TRUE(device->IsConnected()); 442 EXPECT_TRUE(device->IsConnected());
411 443
412 // Verify that service discovery can be done again: 444 // Verify that service discovery can be done again:
413 fake_bluetooth_gatt_service_client_->ExposeHeartRateService( 445 fake_bluetooth_gatt_service_client_->ExposeHeartRateService(
414 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); 446 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
447 // Notify that all services have been discovered.
415 properties->services_resolved.ReplaceValue(true); 448 properties->services_resolved.ReplaceValue(true);
416 EXPECT_TRUE(device->IsGattServicesDiscoveryComplete()); 449 EXPECT_TRUE(device->IsGattServicesDiscoveryComplete());
417 EXPECT_EQ(1u, device->GetGattServices().size()); 450 EXPECT_EQ(1u, device->GetGattServices().size());
451 EXPECT_EQ(2, observer.gatt_discovery_complete_count());
452 EXPECT_FALSE(device->GetGattServices().empty());
453 EXPECT_EQ(1u, device->GetGattServices().size());
418 } 454 }
419 455
420 TEST_F(BluetoothGattBlueZTest, GattCharacteristicAddedAndRemoved) { 456 TEST_F(BluetoothGattBlueZTest, GattCharacteristicAddedAndRemoved) {
421 fake_bluetooth_device_client_->CreateDevice( 457 fake_bluetooth_device_client_->CreateDevice(
422 dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), 458 dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath),
423 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); 459 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
424 BluetoothDevice* device = 460 BluetoothDevice* device =
425 adapter_->GetDevice(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress); 461 adapter_->GetDevice(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress);
462 bluez::FakeBluetoothDeviceClient::Properties* properties =
463 fake_bluetooth_device_client_->GetProperties(
464 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
465
426 ASSERT_TRUE(device); 466 ASSERT_TRUE(device);
427 467
428 TestBluetoothAdapterObserver observer(adapter_); 468 TestBluetoothAdapterObserver observer(adapter_);
429 469
430 // Expose the fake Heart Rate service. This will asynchronously expose 470 // Expose the fake Heart Rate service. This will asynchronously expose
431 // characteristics. 471 // characteristics.
432 fake_bluetooth_gatt_service_client_->ExposeHeartRateService( 472 fake_bluetooth_gatt_service_client_->ExposeHeartRateService(
433 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); 473 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
474 // Notify that all services have been discovered.
475 properties->services_resolved.ReplaceValue(true);
434 ASSERT_EQ(1, observer.gatt_service_added_count()); 476 ASSERT_EQ(1, observer.gatt_service_added_count());
435 477
436 BluetoothRemoteGattService* service = 478 BluetoothRemoteGattService* service =
437 device->GetGattService(observer.last_gatt_service_id()); 479 device->GetGattService(observer.last_gatt_service_id());
438 480
439 EXPECT_EQ(0, observer.gatt_service_changed_count()); 481 EXPECT_EQ(0, observer.gatt_service_changed_count());
440 EXPECT_EQ(0, observer.gatt_discovery_complete_count()); 482 EXPECT_EQ(1, observer.gatt_discovery_complete_count());
441 EXPECT_EQ(0, observer.gatt_characteristic_added_count()); 483 EXPECT_EQ(0, observer.gatt_characteristic_added_count());
442 EXPECT_EQ(0, observer.gatt_characteristic_removed_count()); 484 EXPECT_EQ(0, observer.gatt_characteristic_removed_count());
443 EXPECT_EQ(0, observer.gatt_characteristic_value_changed_count()); 485 EXPECT_EQ(0, observer.gatt_characteristic_value_changed_count());
444 EXPECT_TRUE(service->GetCharacteristics().empty()); 486 EXPECT_TRUE(service->GetCharacteristics().empty());
445 487
446 // Run the message loop so that the characteristics appear. 488 // Run the message loop so that the characteristics appear.
447 base::MessageLoop::current()->Run(); 489 base::MessageLoop::current()->Run();
448 490
449 // 3 characteristics should appear. Only 1 of the characteristics sends 491 // 3 characteristics should appear. Only 1 of the characteristics sends
450 // value changed signals. Service changed should be fired once for 492 // value changed signals. Service changed should be fired once for
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 // objects that were already exposed. 622 // objects that were already exposed.
581 adapter_ = NULL; 623 adapter_ = NULL;
582 ASSERT_FALSE(device::BluetoothAdapterFactory::HasSharedInstanceForTesting()); 624 ASSERT_FALSE(device::BluetoothAdapterFactory::HasSharedInstanceForTesting());
583 625
584 // Create the fake D-Bus objects. 626 // Create the fake D-Bus objects.
585 fake_bluetooth_device_client_->CreateDevice( 627 fake_bluetooth_device_client_->CreateDevice(
586 dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), 628 dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath),
587 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); 629 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
588 fake_bluetooth_gatt_service_client_->ExposeHeartRateService( 630 fake_bluetooth_gatt_service_client_->ExposeHeartRateService(
589 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); 631 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
632 bluez::FakeBluetoothDeviceClient::Properties* properties =
633 fake_bluetooth_device_client_->GetProperties(
634 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
635 // Notify that all services have been discovered.
636 properties->services_resolved.ReplaceValue(true);
590 while (!fake_bluetooth_gatt_characteristic_client_->IsHeartRateVisible()) 637 while (!fake_bluetooth_gatt_characteristic_client_->IsHeartRateVisible())
591 base::RunLoop().RunUntilIdle(); 638 base::RunLoop().RunUntilIdle();
592 ASSERT_TRUE(fake_bluetooth_gatt_service_client_->IsHeartRateVisible()); 639 ASSERT_TRUE(fake_bluetooth_gatt_service_client_->IsHeartRateVisible());
593 ASSERT_TRUE(fake_bluetooth_gatt_characteristic_client_->IsHeartRateVisible()); 640 ASSERT_TRUE(fake_bluetooth_gatt_characteristic_client_->IsHeartRateVisible());
594 641
595 // Create the adapter. This should create all the GATT objects. 642 // Create the adapter. This should create all the GATT objects.
596 GetAdapter(); 643 GetAdapter();
597 BluetoothDevice* device = 644 BluetoothDevice* device =
598 adapter_->GetDevice(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress); 645 adapter_->GetDevice(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress);
599 ASSERT_TRUE(device); 646 ASSERT_TRUE(device);
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 1336
1290 EXPECT_EQ(1, success_callback_count_); 1337 EXPECT_EQ(1, success_callback_count_);
1291 EXPECT_EQ(0, error_callback_count_); 1338 EXPECT_EQ(0, error_callback_count_);
1292 EXPECT_EQ(1, observer.gatt_characteristic_value_changed_count()); 1339 EXPECT_EQ(1, observer.gatt_characteristic_value_changed_count());
1293 EXPECT_TRUE(characteristic->IsNotifying()); 1340 EXPECT_TRUE(characteristic->IsNotifying());
1294 EXPECT_EQ(1U, update_sessions_.size()); 1341 EXPECT_EQ(1U, update_sessions_.size());
1295 EXPECT_TRUE(update_sessions_[0]->IsActive()); 1342 EXPECT_TRUE(update_sessions_[0]->IsActive());
1296 } 1343 }
1297 1344
1298 } // namespace bluez 1345 } // namespace bluez
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698