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 "base/run_loop.h" | 5 #include "base/run_loop.h" |
6 #include "build/build_config.h" | 6 #include "build/build_config.h" |
7 #include "device/bluetooth/bluetooth_gatt_service.h" | 7 #include "device/bluetooth/bluetooth_gatt_service.h" |
8 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" | 8 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" |
9 #include "device/bluetooth/test/test_bluetooth_adapter_observer.h" | 9 #include "device/bluetooth/test/test_bluetooth_adapter_observer.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 EXPECT_EQ(char_uuid3, service->GetCharacteristic(char_id3)->GetUUID()); | 164 EXPECT_EQ(char_uuid3, service->GetCharacteristic(char_id3)->GetUUID()); |
165 EXPECT_EQ(char_uuid4, service->GetCharacteristic(char_id4)->GetUUID()); | 165 EXPECT_EQ(char_uuid4, service->GetCharacteristic(char_id4)->GetUUID()); |
166 | 166 |
167 // GetCharacteristics & GetCharacteristic return the same object for the same | 167 // GetCharacteristics & GetCharacteristic return the same object for the same |
168 // ID: | 168 // ID: |
169 EXPECT_EQ(service->GetCharacteristics()[0], | 169 EXPECT_EQ(service->GetCharacteristics()[0], |
170 service->GetCharacteristic(char_id1)); | 170 service->GetCharacteristic(char_id1)); |
171 EXPECT_EQ(service->GetCharacteristic(char_id1), | 171 EXPECT_EQ(service->GetCharacteristic(char_id1), |
172 service->GetCharacteristic(char_id1)); | 172 service->GetCharacteristic(char_id1)); |
173 } | 173 } |
| 174 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) |
174 | 175 |
| 176 #if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) |
175 TEST_F(BluetoothRemoteGattServiceTest, GetCharacteristicsByUUID) { | 177 TEST_F(BluetoothRemoteGattServiceTest, GetCharacteristicsByUUID) { |
176 if (!PlatformSupportsLowEnergy()) { | 178 if (!PlatformSupportsLowEnergy()) { |
177 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; | 179 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
178 return; | 180 return; |
179 } | 181 } |
180 InitWithFakeAdapter(); | 182 InitWithFakeAdapter(); |
181 StartLowEnergyDiscoverySession(); | 183 StartLowEnergyDiscoverySession(); |
182 BluetoothDevice* device = SimulateLowEnergyDevice(3); | 184 BluetoothDevice* device = SimulateLowEnergyDevice(3); |
183 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED), | 185 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED), |
184 GetConnectErrorCallback(Call::NOT_EXPECTED)); | 186 GetConnectErrorCallback(Call::NOT_EXPECTED)); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 std::string removed_service = service1->GetIdentifier(); | 334 std::string removed_service = service1->GetIdentifier(); |
333 SimulateGattServiceRemoved(device->GetGattService(removed_service)); | 335 SimulateGattServiceRemoved(device->GetGattService(removed_service)); |
334 EXPECT_EQ(1, observer.gatt_service_removed_count()); | 336 EXPECT_EQ(1, observer.gatt_service_removed_count()); |
335 EXPECT_EQ(1u, device->GetGattServices().size()); | 337 EXPECT_EQ(1u, device->GetGattServices().size()); |
336 EXPECT_FALSE(device->GetGattService(removed_service)); | 338 EXPECT_FALSE(device->GetGattService(removed_service)); |
337 EXPECT_EQ(device->GetGattServices()[0], service2); | 339 EXPECT_EQ(device->GetGattServices()[0], service2); |
338 } | 340 } |
339 #endif // defined(OS_WIN) || defined(OS_MACOSX) | 341 #endif // defined(OS_WIN) || defined(OS_MACOSX) |
340 | 342 |
341 } // namespace device | 343 } // namespace device |
OLD | NEW |