OLD | NEW |
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/bluetooth_gatt_characteristic.h" |
| 6 |
5 #include "device/bluetooth/bluetooth_gatt_service.h" | 7 #include "device/bluetooth/bluetooth_gatt_service.h" |
6 | |
7 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_android.h" | |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 #if defined(OS_ANDROID) | 10 #if defined(OS_ANDROID) |
11 #include "device/bluetooth/test/bluetooth_test_android.h" | 11 #include "device/bluetooth/test/bluetooth_test_android.h" |
12 #elif defined(OS_MACOSX) | 12 #elif defined(OS_MACOSX) |
13 #include "device/bluetooth/test/bluetooth_test_mac.h" | 13 #include "device/bluetooth/test/bluetooth_test_mac.h" |
14 #endif | 14 #endif |
15 | 15 |
16 namespace device { | 16 namespace device { |
17 | 17 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 EXPECT_NE(char3->GetIdentifier(), char5->GetIdentifier()); | 75 EXPECT_NE(char3->GetIdentifier(), char5->GetIdentifier()); |
76 EXPECT_NE(char3->GetIdentifier(), char6->GetIdentifier()); | 76 EXPECT_NE(char3->GetIdentifier(), char6->GetIdentifier()); |
77 | 77 |
78 EXPECT_NE(char4->GetIdentifier(), char5->GetIdentifier()); | 78 EXPECT_NE(char4->GetIdentifier(), char5->GetIdentifier()); |
79 EXPECT_NE(char4->GetIdentifier(), char6->GetIdentifier()); | 79 EXPECT_NE(char4->GetIdentifier(), char6->GetIdentifier()); |
80 | 80 |
81 EXPECT_NE(char5->GetIdentifier(), char6->GetIdentifier()); | 81 EXPECT_NE(char5->GetIdentifier(), char6->GetIdentifier()); |
82 } | 82 } |
83 #endif // defined(OS_ANDROID) | 83 #endif // defined(OS_ANDROID) |
84 | 84 |
| 85 #if defined(OS_ANDROID) |
| 86 TEST_F(BluetoothGattCharacteristicTest, GetUUID) { |
| 87 InitWithFakeAdapter(); |
| 88 StartLowEnergyDiscoverySession(); |
| 89 BluetoothDevice* device = DiscoverLowEnergyDevice(3); |
| 90 device->CreateGattConnection(GetGattConnectionCallback(), |
| 91 GetConnectErrorCallback()); |
| 92 SimulateGattConnection(device); |
| 93 std::vector<std::string> services; |
| 94 services.push_back("00000000-0000-1000-8000-00805f9b34fb"); |
| 95 SimulateGattServicesDiscovered(device, services); |
| 96 BluetoothGattService* service = device->GetGattServices()[0]; |
| 97 |
| 98 // Create 3 characteristics. Two of them are duplicates. |
| 99 std::string uuid_str1("11111111-0000-1000-8000-00805f9b34fb"); |
| 100 std::string uuid_str2("22222222-0000-1000-8000-00805f9b34fb"); |
| 101 BluetoothUUID uuid1(uuid_str1); |
| 102 BluetoothUUID uuid2(uuid_str2); |
| 103 SimulateGattCharacteristic(service, uuid_str1); |
| 104 SimulateGattCharacteristic(service, uuid_str2); |
| 105 SimulateGattCharacteristic(service, uuid_str2); |
| 106 BluetoothGattCharacteristic* char1 = service->GetCharacteristics()[0]; |
| 107 BluetoothGattCharacteristic* char2 = service->GetCharacteristics()[1]; |
| 108 BluetoothGattCharacteristic* char3 = service->GetCharacteristics()[2]; |
| 109 |
| 110 // Swap as needed to have char1 point to the the characteristic with uuid1. |
| 111 if (char2->GetUUID() == uuid1) { |
| 112 std::swap(char1, char2); |
| 113 } else if (char3->GetUUID() == uuid1) { |
| 114 std::swap(char1, char3); |
| 115 } |
| 116 |
| 117 EXPECT_EQ(uuid1, char1->GetUUID()); |
| 118 EXPECT_EQ(uuid2, char2->GetUUID()); |
| 119 EXPECT_EQ(uuid2, char3->GetUUID()); |
| 120 } |
| 121 #endif // defined(OS_ANDROID) |
| 122 |
85 } // namespace device | 123 } // namespace device |
OLD | NEW |