Chromium Code Reviews| 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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 EXPECT_EQ(1, gatt_connection_attempts_); | 388 EXPECT_EQ(1, gatt_connection_attempts_); |
| 389 EXPECT_EQ(1, gatt_disconnection_attempts_); | 389 EXPECT_EQ(1, gatt_disconnection_attempts_); |
| 390 SimulateGattDisconnection(device); | 390 SimulateGattDisconnection(device); |
| 391 EXPECT_EQ(BluetoothDevice::ERROR_FAILED, last_connect_error_code_); | 391 EXPECT_EQ(BluetoothDevice::ERROR_FAILED, last_connect_error_code_); |
| 392 for (BluetoothGattConnection* connection : gatt_connections_) | 392 for (BluetoothGattConnection* connection : gatt_connections_) |
| 393 EXPECT_FALSE(connection->IsConnected()); | 393 EXPECT_FALSE(connection->IsConnected()); |
| 394 } | 394 } |
| 395 #endif // defined(OS_ANDROID) | 395 #endif // defined(OS_ANDROID) |
| 396 | 396 |
| 397 #if defined(OS_ANDROID) | 397 #if defined(OS_ANDROID) |
| 398 // Calls CreateGattConnection & DisconnectGatt, then checks that gatt services | |
|
ortuno
2016/01/11 21:48:40
You also need to add tests for bluez based systems
tommyt
2016/01/12 08:42:35
While it wouldn't be too hard to add equivalent un
ortuno
2016/01/12 22:28:49
btw I'm not talking about clearing the services li
tommyt
2016/01/13 09:42:30
Hmm. The intention of my change was to fix somethi
ortuno
2016/01/13 18:22:01
My bad that was an incorrect example. The issue th
| |
| 399 // have been cleaned up. | |
| 400 TEST_F(BluetoothTest, BluetoothGattConnection_DisconnectGatt_Cleanup) { | |
|
scheib
2016/01/11 18:40:09
Thanks, would you add
+ Connecting again after a d
tommyt
2016/01/12 08:42:35
Done.
| |
| 401 InitWithFakeAdapter(); | |
| 402 StartLowEnergyDiscoverySession(); | |
| 403 BluetoothDevice* device = DiscoverLowEnergyDevice(3); | |
| 404 | |
| 405 ResetEventCounts(); | |
| 406 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED), | |
| 407 GetConnectErrorCallback(Call::NOT_EXPECTED)); | |
| 408 SimulateGattConnection(device); | |
| 409 | |
| 410 std::vector<std::string> services; | |
| 411 services.push_back("00000000-0000-1000-8000-00805f9b34fb"); | |
| 412 // 2 duplicate UUIDs creating 2 instances. | |
| 413 services.push_back("00000001-0000-1000-8000-00805f9b34fb"); | |
| 414 services.push_back("00000001-0000-1000-8000-00805f9b34fb"); | |
| 415 SimulateGattServicesDiscovered(device, services); | |
| 416 EXPECT_EQ(3u, device->GetGattServices().size()); | |
| 417 | |
| 418 device->DisconnectGatt(); | |
| 419 SimulateGattDisconnection(device); | |
| 420 EXPECT_EQ(0u, device->GetGattServices().size()); | |
|
ortuno
2016/01/11 21:48:40
Also make sure IsGattServicesDiscovered == false.
tommyt
2016/01/12 08:42:35
Done.
| |
| 421 } | |
| 422 #endif // defined(OS_ANDROID) | |
| 423 | |
| 424 #if defined(OS_ANDROID) | |
| 398 // Calls CreateGattConnection, but simulate errors connecting. Also, verifies | 425 // Calls CreateGattConnection, but simulate errors connecting. Also, verifies |
| 399 // multiple errors should only invoke callbacks once. | 426 // multiple errors should only invoke callbacks once. |
| 400 TEST_F(BluetoothTest, BluetoothGattConnection_ErrorAfterConnection) { | 427 TEST_F(BluetoothTest, BluetoothGattConnection_ErrorAfterConnection) { |
| 401 InitWithFakeAdapter(); | 428 InitWithFakeAdapter(); |
| 402 StartLowEnergyDiscoverySession(); | 429 StartLowEnergyDiscoverySession(); |
| 403 BluetoothDevice* device = DiscoverLowEnergyDevice(3); | 430 BluetoothDevice* device = DiscoverLowEnergyDevice(3); |
| 404 | 431 |
| 405 ResetEventCounts(); | 432 ResetEventCounts(); |
| 406 device->CreateGattConnection(GetGattConnectionCallback(Call::NOT_EXPECTED), | 433 device->CreateGattConnection(GetGattConnectionCallback(Call::NOT_EXPECTED), |
| 407 GetConnectErrorCallback(Call::EXPECTED)); | 434 GetConnectErrorCallback(Call::EXPECTED)); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 475 ResetEventCounts(); | 502 ResetEventCounts(); |
| 476 SimulateGattConnection(device); | 503 SimulateGattConnection(device); |
| 477 EXPECT_EQ(1, gatt_discovery_attempts_); | 504 EXPECT_EQ(1, gatt_discovery_attempts_); |
| 478 | 505 |
| 479 SimulateGattServicesDiscoveryError(device); | 506 SimulateGattServicesDiscoveryError(device); |
| 480 EXPECT_EQ(0u, device->GetGattServices().size()); | 507 EXPECT_EQ(0u, device->GetGattServices().size()); |
| 481 } | 508 } |
| 482 #endif // defined(OS_ANDROID) | 509 #endif // defined(OS_ANDROID) |
| 483 | 510 |
| 484 } // namespace device | 511 } // namespace device |
| OLD | NEW |