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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
418 SimulateGattConnectionError(device, BluetoothDevice::ERROR_AUTH_FAILED); | 418 SimulateGattConnectionError(device, BluetoothDevice::ERROR_AUTH_FAILED); |
419 SimulateGattConnectionError(device, BluetoothDevice::ERROR_FAILED); | 419 SimulateGattConnectionError(device, BluetoothDevice::ERROR_FAILED); |
420 EXPECT_EQ(0, callback_count_); | 420 EXPECT_EQ(0, callback_count_); |
421 EXPECT_EQ(1, error_callback_count_); | 421 EXPECT_EQ(1, error_callback_count_); |
422 EXPECT_EQ(BluetoothDevice::ERROR_AUTH_FAILED, last_connect_error_code_); | 422 EXPECT_EQ(BluetoothDevice::ERROR_AUTH_FAILED, last_connect_error_code_); |
423 for (BluetoothGattConnection* connection : gatt_connections_) | 423 for (BluetoothGattConnection* connection : gatt_connections_) |
424 EXPECT_FALSE(connection->IsConnected()); | 424 EXPECT_FALSE(connection->IsConnected()); |
425 } | 425 } |
426 #endif // defined(OS_ANDROID) | 426 #endif // defined(OS_ANDROID) |
427 | 427 |
428 #if defined(OS_ANDROID) | |
429 TEST_F(BluetoothTest, SimulateGattServicesDiscovered) { | |
430 InitWithFakeAdapter(); | |
431 StartDiscoverySession(); | |
432 BluetoothDevice* device = DiscoverLowEnergyDevice(3); | |
433 device->CreateGattConnection(GetGattConnectionCallback(), | |
434 GetConnectErrorCallback()); | |
435 ResetEventCounts(); | |
ortuno
2015/10/08 22:53:27
Any reason why you have this here instead of in a
scheib
2015/10/08 23:52:19
Placing it immediately before and the EXPECT after
| |
436 SimulateGattConnection(device); | |
437 EXPECT_EQ(1, gatt_discovery_attempts_); | |
438 | |
439 // TODO(scheib): Add more control over how many services are created and | |
440 // their properties. | |
ortuno
2015/10/08 22:53:27
Link to issue?
scheib
2015/10/08 23:52:20
Done.
| |
441 SimulateGattServicesDiscovered(device); | |
442 EXPECT_EQ(2u, device->GetGattServices().size()); | |
443 } | |
444 #endif // defined(OS_ANDROID) | |
445 | |
446 #if defined(OS_ANDROID) | |
447 TEST_F(BluetoothTest, SimulateGattServicesDiscoveryError) { | |
448 InitWithFakeAdapter(); | |
449 StartDiscoverySession(); | |
450 BluetoothDevice* device = DiscoverLowEnergyDevice(3); | |
451 device->CreateGattConnection(GetGattConnectionCallback(), | |
452 GetConnectErrorCallback()); | |
453 ResetEventCounts(); | |
454 SimulateGattConnection(device); | |
455 EXPECT_EQ(1, gatt_discovery_attempts_); | |
456 | |
457 SimulateGattServicesDiscoveryError(device); | |
458 EXPECT_EQ(0u, device->GetGattServices().size()); | |
459 } | |
460 #endif // defined(OS_ANDROID) | |
461 | |
428 } // namespace device | 462 } // namespace device |
OLD | NEW |