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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
392 // the device holds and notify of device changed. | 392 // the device holds and notify of device changed. |
393 gatt_connections_[0]->Disconnect(); | 393 gatt_connections_[0]->Disconnect(); |
394 SimulateGattDisconnection(device); | 394 SimulateGattDisconnection(device); |
395 ASSERT_FALSE(device->IsGattConnected()); | 395 ASSERT_FALSE(device->IsGattConnected()); |
396 | 396 |
397 EXPECT_EQ(1, observer.device_changed_count()); | 397 EXPECT_EQ(1, observer.device_changed_count()); |
398 EXPECT_TRUE(device->GetUUIDs().empty()); | 398 EXPECT_TRUE(device->GetUUIDs().empty()); |
399 } | 399 } |
400 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) | 400 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
401 | 401 |
402 #if defined(OS_MACOSX) | |
403 TEST_F(BluetoothTest, DoubleDidModifyServicesEvent) { | |
ortuno
2017/01/23 06:12:38
This is a good test for the case in which we get t
jlebel
2017/01/23 18:49:38
Done.
| |
404 if (!PlatformSupportsLowEnergy()) { | |
405 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; | |
406 return; | |
407 } | |
408 | |
409 InitWithFakeAdapter(); | |
410 TestBluetoothAdapterObserver observer(adapter_); | |
411 | |
412 BluetoothDevice* device = SimulateLowEnergyDevice(1); | |
413 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED), | |
414 GetConnectErrorCallback(Call::NOT_EXPECTED)); | |
415 SimulateGattConnection(device); | |
416 | |
417 SimulateGattServicesDiscovered(device, {} /* services */); | |
418 EXPECT_EQ(2, observer.device_changed_count()); | |
419 EXPECT_TRUE(device->IsGattServicesDiscoveryComplete()); | |
420 | |
421 observer.Reset(); | |
422 SimulateGattServicesChanged(device); | |
423 SimulateGattServicesChanged(device); | |
424 EXPECT_EQ(2, observer.device_changed_count()); | |
425 EXPECT_FALSE(device->IsGattServicesDiscoveryComplete()); | |
426 | |
427 observer.Reset(); | |
428 SimulateGattServicesDiscovered(device, {} /* services */); | |
429 SimulateGattServicesDiscovered(device, {} /* services */); | |
ortuno
2017/01/23 06:12:38
Is there any way we can test that DiscoveryCharact
jlebel
2017/01/23 18:49:38
I guess the simplest way to do that would be to ad
ortuno
2017/01/23 20:44:02
SGTM
| |
430 EXPECT_EQ(1, observer.device_changed_count()); | |
431 EXPECT_TRUE(device->IsGattServicesDiscoveryComplete()); | |
432 } | |
433 #endif // defined(OS_MACOSX) | |
434 | |
402 #if defined(OS_ANDROID) || defined(OS_MACOSX) | 435 #if defined(OS_ANDROID) || defined(OS_MACOSX) |
403 // Tests Advertisement Data is updated correctly when we start discovery | 436 // Tests Advertisement Data is updated correctly when we start discovery |
404 // during a connection. | 437 // during a connection. |
405 TEST_F(BluetoothTest, AdvertisementData_DiscoveryDuringConnection) { | 438 TEST_F(BluetoothTest, AdvertisementData_DiscoveryDuringConnection) { |
406 if (!PlatformSupportsLowEnergy()) { | 439 if (!PlatformSupportsLowEnergy()) { |
407 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; | 440 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
408 return; | 441 return; |
409 } | 442 } |
410 | 443 |
411 InitWithFakeAdapter(); | 444 InitWithFakeAdapter(); |
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1334 | 1367 |
1335 BluetoothDevice* device2 = SimulateLowEnergyDevice(6); | 1368 BluetoothDevice* device2 = SimulateLowEnergyDevice(6); |
1336 EXPECT_EQ(BLUETOOTH_TRANSPORT_DUAL, device2->GetType()); | 1369 EXPECT_EQ(BLUETOOTH_TRANSPORT_DUAL, device2->GetType()); |
1337 | 1370 |
1338 BluetoothDevice* device3 = SimulateClassicDevice(); | 1371 BluetoothDevice* device3 = SimulateClassicDevice(); |
1339 EXPECT_EQ(BLUETOOTH_TRANSPORT_CLASSIC, device3->GetType()); | 1372 EXPECT_EQ(BLUETOOTH_TRANSPORT_CLASSIC, device3->GetType()); |
1340 } | 1373 } |
1341 #endif // defined(OS_CHROMEOS) || defined(OS_LINUX) | 1374 #endif // defined(OS_CHROMEOS) || defined(OS_LINUX) |
1342 | 1375 |
1343 } // namespace device | 1376 } // namespace device |
OLD | NEW |