OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/bluetooth_device.h" | 5 #include "device/bluetooth/bluetooth_device.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 EXPECT_FALSE(device->IsGattServicesDiscoveryComplete()); | 458 EXPECT_FALSE(device->IsGattServicesDiscoveryComplete()); |
459 | 459 |
460 observer.Reset(); | 460 observer.Reset(); |
461 SimulateGattServicesChanged(device); | 461 SimulateGattServicesChanged(device); |
462 EXPECT_EQ(1, observer.device_changed_count()); | 462 EXPECT_EQ(1, observer.device_changed_count()); |
463 EXPECT_FALSE(device->IsGattServicesDiscoveryComplete()); | 463 EXPECT_FALSE(device->IsGattServicesDiscoveryComplete()); |
464 | 464 |
465 // Fist system call to | 465 // Fist system call to |
466 // -[id<CBPeripheralDelegate> peripheral:didDiscoverServices:] | 466 // -[id<CBPeripheralDelegate> peripheral:didDiscoverServices:] |
467 observer.Reset(); | 467 observer.Reset(); |
468 SimulateDidDiscoverServices(device, {kTestUUIDHeartRate}); | 468 AddServicesToDevice(device, {kTestUUIDHeartRate}); |
| 469 SimulateDidDiscoverServices(device); |
469 EXPECT_EQ(0, observer.device_changed_count()); | 470 EXPECT_EQ(0, observer.device_changed_count()); |
470 EXPECT_FALSE(device->IsGattServicesDiscoveryComplete()); | 471 EXPECT_FALSE(device->IsGattServicesDiscoveryComplete()); |
471 EXPECT_EQ(gatt_characteristic_discovery_attempts_, 0); | 472 EXPECT_EQ(gatt_characteristic_discovery_attempts_, 0); |
472 | 473 |
473 // Second system call to | 474 // Second system call to |
474 // -[id<CBPeripheralDelegate> peripheral:didDiscoverServices:] | 475 // -[id<CBPeripheralDelegate> peripheral:didDiscoverServices:] |
475 SimulateGattServicesDiscovered( | 476 SimulateGattServicesDiscovered( |
476 device, std::vector<std::string>({kTestUUIDImmediateAlert})); | 477 device, std::vector<std::string>({kTestUUIDImmediateAlert})); |
477 EXPECT_EQ(1, observer.device_changed_count()); | 478 EXPECT_EQ(1, observer.device_changed_count()); |
478 EXPECT_TRUE(device->IsGattServicesDiscoveryComplete()); | 479 EXPECT_TRUE(device->IsGattServicesDiscoveryComplete()); |
(...skipping 27 matching lines...) Expand all Loading... |
506 observer.Reset(); | 507 observer.Reset(); |
507 SimulateGattServicesDiscovered( | 508 SimulateGattServicesDiscovered( |
508 device, std::vector<std::string>({kTestUUIDHeartRate})); | 509 device, std::vector<std::string>({kTestUUIDHeartRate})); |
509 EXPECT_EQ(1, observer.device_changed_count()); | 510 EXPECT_EQ(1, observer.device_changed_count()); |
510 EXPECT_TRUE(device->IsGattServicesDiscoveryComplete()); | 511 EXPECT_TRUE(device->IsGattServicesDiscoveryComplete()); |
511 EXPECT_EQ(gatt_characteristic_discovery_attempts_, 1); | 512 EXPECT_EQ(gatt_characteristic_discovery_attempts_, 1); |
512 EXPECT_EQ(1u, device->GetGattServices().size()); | 513 EXPECT_EQ(1u, device->GetGattServices().size()); |
513 | 514 |
514 // Unexpected system call to | 515 // Unexpected system call to |
515 // -[id<CBPeripheralDelegate> peripheral:didDiscoverServices:] | 516 // -[id<CBPeripheralDelegate> peripheral:didDiscoverServices:] |
516 SimulateDidDiscoverServices(device, {kTestUUIDImmediateAlert}); | 517 AddServicesToDevice(device, {kTestUUIDImmediateAlert}); |
| 518 SimulateDidDiscoverServices(device); |
517 EXPECT_EQ(1, observer.device_changed_count()); | 519 EXPECT_EQ(1, observer.device_changed_count()); |
518 EXPECT_TRUE(device->IsGattServicesDiscoveryComplete()); | 520 EXPECT_TRUE(device->IsGattServicesDiscoveryComplete()); |
519 | 521 |
520 EXPECT_EQ(1u, device->GetGattServices().size()); | 522 EXPECT_EQ(1u, device->GetGattServices().size()); |
521 } | 523 } |
522 #endif // defined(OS_MACOSX) | 524 #endif // defined(OS_MACOSX) |
523 | 525 |
524 #if defined(OS_ANDROID) || defined(OS_MACOSX) | 526 #if defined(OS_ANDROID) || defined(OS_MACOSX) |
525 // Tests Advertisement Data is updated correctly when we start discovery | 527 // Tests Advertisement Data is updated correctly when we start discovery |
526 // during a connection. | 528 // during a connection. |
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1613 .empty()); | 1615 .empty()); |
1614 EXPECT_TRUE(device_ | 1616 EXPECT_TRUE(device_ |
1615 ->GetCharacteristicsByUUID( | 1617 ->GetCharacteristicsByUUID( |
1616 service_instance_id2, | 1618 service_instance_id2, |
1617 BluetoothUUID(characteristic_uuid_not_exist_in_setup)) | 1619 BluetoothUUID(characteristic_uuid_not_exist_in_setup)) |
1618 .empty()); | 1620 .empty()); |
1619 } | 1621 } |
1620 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) | 1622 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
1621 | 1623 |
1622 } // namespace device | 1624 } // namespace device |
OLD | NEW |