| Index: device/bluetooth/bluetooth_remote_gatt_service_unittest.cc
|
| diff --git a/device/bluetooth/bluetooth_remote_gatt_service_unittest.cc b/device/bluetooth/bluetooth_remote_gatt_service_unittest.cc
|
| index c5118645f99ade3e2ed65c1bc579aa36082184fd..2c86e620e5b5d8e2d909151782a7751d2a9a3b87 100644
|
| --- a/device/bluetooth/bluetooth_remote_gatt_service_unittest.cc
|
| +++ b/device/bluetooth/bluetooth_remote_gatt_service_unittest.cc
|
| @@ -43,12 +43,12 @@ TEST_F(BluetoothRemoteGattServiceTest, GetIdentifier) {
|
| base::RunLoop().RunUntilIdle();
|
|
|
| // 2 duplicate UUIDs creating 2 service instances on each device.
|
| - std::vector<std::string> services;
|
| - std::string uuid = "00000000-0000-1000-8000-00805f9b34fb";
|
| - services.push_back(uuid);
|
| - services.push_back(uuid);
|
| - SimulateGattServicesDiscovered(device1, services);
|
| - SimulateGattServicesDiscovered(device2, services);
|
| + SimulateGattServicesDiscovered(
|
| + device1, std::vector<std::string>(
|
| + {kTestUUIDGenericAccess, kTestUUIDGenericAccess}));
|
| + SimulateGattServicesDiscovered(
|
| + device2, std::vector<std::string>(
|
| + {kTestUUIDGenericAccess, kTestUUIDGenericAccess}));
|
| base::RunLoop().RunUntilIdle();
|
| BluetoothRemoteGattService* service1 = device1->GetGattServices()[0];
|
| BluetoothRemoteGattService* service2 = device1->GetGattServices()[1];
|
| @@ -82,7 +82,7 @@ TEST_F(BluetoothRemoteGattServiceTest, GetUUID) {
|
| base::RunLoop().RunUntilIdle();
|
|
|
| // Create multiple instances with the same UUID.
|
| - BluetoothUUID uuid("00000000-0000-1000-8000-00805f9b34fb");
|
| + BluetoothUUID uuid(kTestUUIDGenericAccess);
|
| std::vector<std::string> services;
|
| services.push_back(uuid.canonical_value());
|
| services.push_back(uuid.canonical_value());
|
| @@ -110,9 +110,8 @@ TEST_F(BluetoothRemoteGattServiceTest, GetCharacteristics_FindNone) {
|
| base::RunLoop().RunUntilIdle();
|
|
|
| // Simulate a service, with no Characteristics:
|
| - std::vector<std::string> services;
|
| - services.push_back("00000000-0000-1000-8000-00805f9b34fb");
|
| - SimulateGattServicesDiscovered(device, services);
|
| + SimulateGattServicesDiscovered(
|
| + device, std::vector<std::string>({kTestUUIDGenericAccess}));
|
| base::RunLoop().RunUntilIdle();
|
| BluetoothRemoteGattService* service = device->GetGattServices()[0];
|
|
|
| @@ -136,19 +135,18 @@ TEST_F(BluetoothRemoteGattServiceTest,
|
| base::RunLoop().RunUntilIdle();
|
|
|
| // Simulate a service, with several Characteristics:
|
| - std::vector<std::string> services;
|
| - services.push_back("00000000-0000-1000-8000-00805f9b34fb");
|
| - SimulateGattServicesDiscovered(device, services);
|
| + SimulateGattServicesDiscovered(
|
| + device, std::vector<std::string>({kTestUUIDGenericAccess}));
|
| base::RunLoop().RunUntilIdle();
|
| BluetoothRemoteGattService* service = device->GetGattServices()[0];
|
| - std::string characteristic_uuid1 = "11111111-0000-1000-8000-00805f9b34fb";
|
| - std::string characteristic_uuid2 = "22222222-0000-1000-8000-00805f9b34fb";
|
| - std::string characteristic_uuid3 = characteristic_uuid2; // Duplicate UUID.
|
| - std::string characteristic_uuid4 = "33333333-0000-1000-8000-00805f9b34fb";
|
| - SimulateGattCharacteristic(service, characteristic_uuid1, /* properties */ 0);
|
| - SimulateGattCharacteristic(service, characteristic_uuid2, /* properties */ 0);
|
| - SimulateGattCharacteristic(service, characteristic_uuid3, /* properties */ 0);
|
| - SimulateGattCharacteristic(service, characteristic_uuid4, /* properties */ 0);
|
| + SimulateGattCharacteristic(service, kTestUUIDDeviceName, /* properties */ 0);
|
| + SimulateGattCharacteristic(service, kTestUUIDAppearance,
|
| + /* properties */ 0);
|
| + // Duplicate UUID.
|
| + SimulateGattCharacteristic(service, kTestUUIDAppearance,
|
| + /* properties */ 0);
|
| + SimulateGattCharacteristic(service, kTestUUIDReconnectionAddress,
|
| + /* properties */ 0);
|
|
|
| // Verify that GetCharacteristic can retrieve characteristics again by ID,
|
| // and that the same Characteristics come back.
|
| @@ -188,38 +186,36 @@ TEST_F(BluetoothRemoteGattServiceTest, GetCharacteristicsByUUID) {
|
| base::RunLoop().RunUntilIdle();
|
|
|
| // Simulate two primary GATT services.
|
| - std::vector<std::string> services;
|
| - services.push_back("00000000-0000-1000-8000-00805f9b34fb");
|
| - services.push_back("01010101-0101-1000-8000-00805f9b34fb");
|
| - SimulateGattServicesDiscovered(device, services);
|
| + SimulateGattServicesDiscovered(
|
| + device,
|
| + std::vector<std::string>({kTestUUIDGenericAccess, kTestUUIDHeartRate}));
|
| base::RunLoop().RunUntilIdle();
|
| BluetoothRemoteGattService* service1 = device->GetGattServices()[0];
|
| BluetoothRemoteGattService* service2 = device->GetGattServices()[1];
|
| - std::string characteristic_uuid1 = "11111111-0000-1000-8000-00805f9b34fb";
|
| - std::string characteristic_uuid2 = "22222222-0000-1000-8000-00805f9b34fb";
|
| - SimulateGattCharacteristic(service1, characteristic_uuid1,
|
| + SimulateGattCharacteristic(service1, kTestUUIDDeviceName,
|
| /* properties */ 0);
|
| // 2 duplicate UUIDs creating 2 instances.
|
| - SimulateGattCharacteristic(service2, characteristic_uuid2,
|
| + SimulateGattCharacteristic(service2, kTestUUIDHeartRateMeasurement,
|
| /* properties */ 0);
|
| - SimulateGattCharacteristic(service2, characteristic_uuid2,
|
| + SimulateGattCharacteristic(service2, kTestUUIDHeartRateMeasurement,
|
| /* properties */ 0);
|
|
|
| {
|
| std::vector<BluetoothRemoteGattCharacteristic*> characteristics =
|
| - service1->GetCharacteristicsByUUID(BluetoothUUID(characteristic_uuid1));
|
| + service1->GetCharacteristicsByUUID(BluetoothUUID(kTestUUIDDeviceName));
|
| EXPECT_EQ(1u, characteristics.size());
|
| - EXPECT_EQ(characteristic_uuid1,
|
| + EXPECT_EQ(kTestUUIDDeviceName,
|
| characteristics[0]->GetUUID().canonical_value());
|
| }
|
|
|
| {
|
| std::vector<BluetoothRemoteGattCharacteristic*> characteristics =
|
| - service2->GetCharacteristicsByUUID(BluetoothUUID(characteristic_uuid2));
|
| + service2->GetCharacteristicsByUUID(
|
| + BluetoothUUID(kTestUUIDHeartRateMeasurement));
|
| EXPECT_EQ(2u, characteristics.size());
|
| - EXPECT_EQ(characteristic_uuid2,
|
| + EXPECT_EQ(kTestUUIDHeartRateMeasurement,
|
| characteristics[0]->GetUUID().canonical_value());
|
| - EXPECT_EQ(characteristic_uuid2,
|
| + EXPECT_EQ(kTestUUIDHeartRateMeasurement,
|
| characteristics[1]->GetUUID().canonical_value());
|
| EXPECT_NE(characteristics[0]->GetIdentifier(),
|
| characteristics[1]->GetIdentifier());
|
| @@ -253,19 +249,18 @@ TEST_F(BluetoothRemoteGattServiceTest, GattCharacteristics_ObserversCalls) {
|
| TestBluetoothAdapterObserver observer(adapter_);
|
|
|
| // Simulate a service, with several Characteristics:
|
| - std::vector<std::string> services;
|
| - services.push_back("00000000-0000-1000-8000-00805f9b34fb");
|
| - SimulateGattServicesDiscovered(device, services);
|
| + SimulateGattServicesDiscovered(
|
| + device, std::vector<std::string>({kTestUUIDGenericAccess}));
|
| base::RunLoop().RunUntilIdle();
|
| BluetoothRemoteGattService* service = device->GetGattServices()[0];
|
| - std::string characteristic_uuid1 = "11111111-0000-1000-8000-00805f9b34fb";
|
| - std::string characteristic_uuid2 = "22222222-0000-1000-8000-00805f9b34fb";
|
| - std::string characteristic_uuid3 = characteristic_uuid2; // Duplicate UUID.
|
| - std::string characteristic_uuid4 = "33333333-0000-1000-8000-00805f9b34fb";
|
| - SimulateGattCharacteristic(service, characteristic_uuid1, /* properties */ 0);
|
| - SimulateGattCharacteristic(service, characteristic_uuid2, /* properties */ 0);
|
| - SimulateGattCharacteristic(service, characteristic_uuid3, /* properties */ 0);
|
| - SimulateGattCharacteristic(service, characteristic_uuid4, /* properties */ 0);
|
| + SimulateGattCharacteristic(service, kTestUUIDDeviceName, /* properties */ 0);
|
| + SimulateGattCharacteristic(service, kTestUUIDAppearance,
|
| + /* properties */ 0);
|
| + // Duplicate UUID.
|
| + SimulateGattCharacteristic(service, kTestUUIDAppearance,
|
| + /* properties */ 0);
|
| + SimulateGattCharacteristic(service, kTestUUIDReconnectionAddress,
|
| + /* properties */ 0);
|
| #if !defined(OS_WIN)
|
| // TODO(620895) GattCharacteristicAdded has to be implemented for Windows.
|
| EXPECT_EQ(4, observer.gatt_characteristic_added_count());
|
| @@ -326,10 +321,9 @@ TEST_F(BluetoothRemoteGattServiceTest, SimulateGattServiceRemove) {
|
| TestBluetoothAdapterObserver observer(adapter_);
|
|
|
| // Simulate two primary GATT services.
|
| - std::vector<std::string> services;
|
| - services.push_back("00000000-0000-1000-8000-00805f9b34fb");
|
| - services.push_back("01010101-0101-1000-8000-00805f9b34fb");
|
| - SimulateGattServicesDiscovered(device, services);
|
| + SimulateGattServicesDiscovered(
|
| + device,
|
| + std::vector<std::string>({kTestUUIDGenericAccess, kTestUUIDHeartRate}));
|
| EXPECT_EQ(2u, device->GetGattServices().size());
|
|
|
| // Simulate remove of a primary service.
|
|
|