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_adapter.h" | 5 #include "device/bluetooth/bluetooth_adapter.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 return; | 627 return; |
628 } | 628 } |
629 InitWithFakeAdapter(); | 629 InitWithFakeAdapter(); |
630 TestBluetoothAdapterObserver observer(adapter_); | 630 TestBluetoothAdapterObserver observer(adapter_); |
631 | 631 |
632 // Start discovery and find a device. | 632 // Start discovery and find a device. |
633 StartLowEnergyDiscoverySession(); | 633 StartLowEnergyDiscoverySession(); |
634 BluetoothDevice* device = SimulateLowEnergyDevice(1); | 634 BluetoothDevice* device = SimulateLowEnergyDevice(1); |
635 | 635 |
636 // Check the initial UUIDs: | 636 // Check the initial UUIDs: |
637 EXPECT_TRUE( | 637 EXPECT_TRUE(base::ContainsValue(device->GetUUIDs(), |
638 ContainsValue(device->GetUUIDs(), BluetoothUUID(kTestUUIDGenericAccess))); | 638 BluetoothUUID(kTestUUIDGenericAccess))); |
639 EXPECT_FALSE(ContainsValue(device->GetUUIDs(), | 639 EXPECT_FALSE(base::ContainsValue(device->GetUUIDs(), |
640 BluetoothUUID(kTestUUIDImmediateAlert))); | 640 BluetoothUUID(kTestUUIDImmediateAlert))); |
641 | 641 |
642 // Discover same device again with updated UUIDs: | 642 // Discover same device again with updated UUIDs: |
643 observer.Reset(); | 643 observer.Reset(); |
644 SimulateLowEnergyDevice(2); | 644 SimulateLowEnergyDevice(2); |
645 EXPECT_EQ(0, observer.device_added_count()); | 645 EXPECT_EQ(0, observer.device_added_count()); |
646 EXPECT_EQ(1, observer.device_changed_count()); | 646 EXPECT_EQ(1, observer.device_changed_count()); |
647 EXPECT_EQ(1u, adapter_->GetDevices().size()); | 647 EXPECT_EQ(1u, adapter_->GetDevices().size()); |
648 EXPECT_EQ(device, observer.last_device()); | 648 EXPECT_EQ(device, observer.last_device()); |
649 | 649 |
650 // Expect only new UUIDs: | 650 // Expect only new UUIDs: |
651 EXPECT_FALSE( | 651 EXPECT_FALSE(base::ContainsValue(device->GetUUIDs(), |
652 ContainsValue(device->GetUUIDs(), BluetoothUUID(kTestUUIDGenericAccess))); | 652 BluetoothUUID(kTestUUIDGenericAccess))); |
653 EXPECT_TRUE(ContainsValue(device->GetUUIDs(), | 653 EXPECT_TRUE(base::ContainsValue(device->GetUUIDs(), |
654 BluetoothUUID(kTestUUIDImmediateAlert))); | 654 BluetoothUUID(kTestUUIDImmediateAlert))); |
655 | 655 |
656 // Discover same device again with empty UUIDs: | 656 // Discover same device again with empty UUIDs: |
657 observer.Reset(); | 657 observer.Reset(); |
658 SimulateLowEnergyDevice(3); | 658 SimulateLowEnergyDevice(3); |
659 EXPECT_EQ(0, observer.device_added_count()); | 659 EXPECT_EQ(0, observer.device_added_count()); |
660 EXPECT_EQ(1, observer.device_changed_count()); | 660 EXPECT_EQ(1, observer.device_changed_count()); |
661 EXPECT_EQ(1u, adapter_->GetDevices().size()); | 661 EXPECT_EQ(1u, adapter_->GetDevices().size()); |
662 | 662 |
663 // Expect no UUIDs: | 663 // Expect no UUIDs: |
664 EXPECT_EQ(0u, device->GetUUIDs().size()); | 664 EXPECT_EQ(0u, device->GetUUIDs().size()); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 GetConnectErrorCallback(Call::NOT_EXPECTED)); | 861 GetConnectErrorCallback(Call::NOT_EXPECTED)); |
862 SimulateGattConnection(device); | 862 SimulateGattConnection(device); |
863 EXPECT_EQ(1u, adapter_->GetDevices().size()); | 863 EXPECT_EQ(1u, adapter_->GetDevices().size()); |
864 RemoveTimedOutDevices(); | 864 RemoveTimedOutDevices(); |
865 EXPECT_EQ(0, observer.device_removed_count()); | 865 EXPECT_EQ(0, observer.device_removed_count()); |
866 EXPECT_EQ(1u, adapter_->GetDevices().size()); | 866 EXPECT_EQ(1u, adapter_->GetDevices().size()); |
867 } | 867 } |
868 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) | 868 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
869 | 869 |
870 } // namespace device | 870 } // namespace device |
OLD | NEW |