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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 | 176 |
| 177 // Disconnect & Delete connection objects. Device stays connected. | 177 // Disconnect & Delete connection objects. Device stays connected. |
| 178 gatt_connections_[0]->Disconnect(); // Disconnect first. | 178 gatt_connections_[0]->Disconnect(); // Disconnect first. |
| 179 gatt_connections_.pop_back(); // Delete last. | 179 gatt_connections_.pop_back(); // Delete last. |
| 180 EXPECT_FALSE(gatt_connections_[0]->IsConnected()); | 180 EXPECT_FALSE(gatt_connections_[0]->IsConnected()); |
| 181 EXPECT_TRUE(gatt_connections_[1]->IsConnected()); | 181 EXPECT_TRUE(gatt_connections_[1]->IsConnected()); |
| 182 EXPECT_TRUE(device->IsGattConnected()); | 182 EXPECT_TRUE(device->IsGattConnected()); |
| 183 EXPECT_EQ(0, gatt_disconnection_attempts_); | 183 EXPECT_EQ(0, gatt_disconnection_attempts_); |
| 184 | 184 |
| 185 // Delete device, connection objects should all be disconnected. | 185 // Delete device, connection objects should all be disconnected. |
| 186 gatt_disconnection_attempts_ = 0; | |
| 187 DeleteDevice(device); | 186 DeleteDevice(device); |
| 188 EXPECT_EQ(1, gatt_disconnection_attempts_); | |
|
tommyt
2016/01/29 15:02:12
The destruction of the device no longer calls disc
ortuno
2016/01/29 16:23:53
@scheib: Should we add another member to Bluetooth
scheib
2016/01/29 21:50:58
Yes we should test this, and I think we can do it
tommyt
2016/02/01 14:37:13
I've resurrected this code and added some test cod
| |
| 189 EXPECT_FALSE(gatt_connections_[0]->IsConnected()); | 187 EXPECT_FALSE(gatt_connections_[0]->IsConnected()); |
| 190 EXPECT_FALSE(gatt_connections_[1]->IsConnected()); | 188 EXPECT_FALSE(gatt_connections_[1]->IsConnected()); |
| 191 | 189 |
| 192 // Test GetDeviceAddress after device deleted. | 190 // Test GetDeviceAddress after device deleted. |
| 193 EXPECT_EQ(device_address, gatt_connections_[0]->GetDeviceAddress()); | 191 EXPECT_EQ(device_address, gatt_connections_[0]->GetDeviceAddress()); |
| 194 EXPECT_EQ(device_address, gatt_connections_[1]->GetDeviceAddress()); | 192 EXPECT_EQ(device_address, gatt_connections_[1]->GetDeviceAddress()); |
| 195 } | 193 } |
| 196 #endif // defined(OS_ANDROID) | 194 #endif // defined(OS_ANDROID) |
| 197 | 195 |
| 198 #if defined(OS_ANDROID) | 196 #if defined(OS_ANDROID) |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 528 ResetEventCounts(); | 526 ResetEventCounts(); |
| 529 SimulateGattConnection(device); | 527 SimulateGattConnection(device); |
| 530 EXPECT_EQ(1, gatt_discovery_attempts_); | 528 EXPECT_EQ(1, gatt_discovery_attempts_); |
| 531 | 529 |
| 532 SimulateGattServicesDiscoveryError(device); | 530 SimulateGattServicesDiscoveryError(device); |
| 533 EXPECT_EQ(0u, device->GetGattServices().size()); | 531 EXPECT_EQ(0u, device->GetGattServices().size()); |
| 534 } | 532 } |
| 535 #endif // defined(OS_ANDROID) | 533 #endif // defined(OS_ANDROID) |
| 536 | 534 |
| 537 } // namespace device | 535 } // namespace device |
| OLD | NEW |