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 "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 TEST_F(BluetoothTest, SimulateGattServicesDiscovered) { | 429 TEST_F(BluetoothTest, SimulateGattServicesDiscovered) { |
430 InitWithFakeAdapter(); | 430 InitWithFakeAdapter(); |
431 StartDiscoverySession(); | 431 StartDiscoverySession(); |
432 BluetoothDevice* device = DiscoverLowEnergyDevice(3); | 432 BluetoothDevice* device = DiscoverLowEnergyDevice(3); |
433 device->CreateGattConnection(GetGattConnectionCallback(), | 433 device->CreateGattConnection(GetGattConnectionCallback(), |
434 GetConnectErrorCallback()); | 434 GetConnectErrorCallback()); |
435 ResetEventCounts(); | 435 ResetEventCounts(); |
436 SimulateGattConnection(device); | 436 SimulateGattConnection(device); |
437 EXPECT_EQ(1, gatt_discovery_attempts_); | 437 EXPECT_EQ(1, gatt_discovery_attempts_); |
438 | 438 |
439 // TODO(scheib): Add more control over how many services are created and | 439 std::vector<std::string> services; |
440 // their properties. http://crbug.com/541400 | 440 services.push_back("00000000-0000-1000-8000-00805f9b34fb"); |
441 SimulateGattServicesDiscovered(device); | 441 // 2 duplicate UUIDs creating 2 instances. |
442 EXPECT_EQ(2u, device->GetGattServices().size()); | 442 services.push_back("00000001-0000-1000-8000-00805f9b34fb"); |
| 443 services.push_back("00000001-0000-1000-8000-00805f9b34fb"); |
| 444 SimulateGattServicesDiscovered(device, services); |
| 445 EXPECT_EQ(3u, device->GetGattServices().size()); |
443 } | 446 } |
444 #endif // defined(OS_ANDROID) | 447 #endif // defined(OS_ANDROID) |
445 | 448 |
446 #if defined(OS_ANDROID) | 449 #if defined(OS_ANDROID) |
447 TEST_F(BluetoothTest, SimulateGattServicesDiscoveryError) { | 450 TEST_F(BluetoothTest, SimulateGattServicesDiscoveryError) { |
448 InitWithFakeAdapter(); | 451 InitWithFakeAdapter(); |
449 StartDiscoverySession(); | 452 StartDiscoverySession(); |
450 BluetoothDevice* device = DiscoverLowEnergyDevice(3); | 453 BluetoothDevice* device = DiscoverLowEnergyDevice(3); |
451 device->CreateGattConnection(GetGattConnectionCallback(), | 454 device->CreateGattConnection(GetGattConnectionCallback(), |
452 GetConnectErrorCallback()); | 455 GetConnectErrorCallback()); |
453 ResetEventCounts(); | 456 ResetEventCounts(); |
454 SimulateGattConnection(device); | 457 SimulateGattConnection(device); |
455 EXPECT_EQ(1, gatt_discovery_attempts_); | 458 EXPECT_EQ(1, gatt_discovery_attempts_); |
456 | 459 |
457 SimulateGattServicesDiscoveryError(device); | 460 SimulateGattServicesDiscoveryError(device); |
458 EXPECT_EQ(0u, device->GetGattServices().size()); | 461 EXPECT_EQ(0u, device->GetGattServices().size()); |
459 } | 462 } |
460 #endif // defined(OS_ANDROID) | 463 #endif // defined(OS_ANDROID) |
461 | 464 |
462 } // namespace device | 465 } // namespace device |
OLD | NEW |