Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Side by Side Diff: device/bluetooth/bluetooth_device_unittest.cc

Issue 1369463004: bluetooth: android: Disconnect GATT upon BluetoothDeviceAndroid object destruction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/bluetooth/bluetooth_device_android.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 173
174 // Disconnect & Delete connection objects. Device stays connected. 174 // Disconnect & Delete connection objects. Device stays connected.
175 gatt_connections_[0]->Disconnect(); // Disconnect first. 175 gatt_connections_[0]->Disconnect(); // Disconnect first.
176 gatt_connections_.pop_back(); // Delete last. 176 gatt_connections_.pop_back(); // Delete last.
177 EXPECT_FALSE(gatt_connections_[0]->IsConnected()); 177 EXPECT_FALSE(gatt_connections_[0]->IsConnected());
178 EXPECT_TRUE(gatt_connections_[1]->IsConnected()); 178 EXPECT_TRUE(gatt_connections_[1]->IsConnected());
179 EXPECT_TRUE(device->IsGattConnected()); 179 EXPECT_TRUE(device->IsGattConnected());
180 EXPECT_EQ(0, gatt_disconnection_attempt_count_); 180 EXPECT_EQ(0, gatt_disconnection_attempt_count_);
181 181
182 // Delete device, connection objects should all be disconnected. 182 // Delete device, connection objects should all be disconnected.
183 gatt_disconnection_attempt_count_ = 0;
183 DeleteDevice(device); 184 DeleteDevice(device);
185 EXPECT_EQ(1, gatt_disconnection_attempt_count_);
184 EXPECT_FALSE(gatt_connections_[0]->IsConnected()); 186 EXPECT_FALSE(gatt_connections_[0]->IsConnected());
185 EXPECT_FALSE(gatt_connections_[1]->IsConnected()); 187 EXPECT_FALSE(gatt_connections_[1]->IsConnected());
186 188
187 // Test GetDeviceAddress after device deleted. 189 // Test GetDeviceAddress after device deleted.
188 EXPECT_EQ(device_address, gatt_connections_[0]->GetDeviceAddress()); 190 EXPECT_EQ(device_address, gatt_connections_[0]->GetDeviceAddress());
189 EXPECT_EQ(device_address, gatt_connections_[1]->GetDeviceAddress()); 191 EXPECT_EQ(device_address, gatt_connections_[1]->GetDeviceAddress());
190 } 192 }
191 #endif // defined(OS_ANDROID) 193 #endif // defined(OS_ANDROID)
192 194
193 #if defined(OS_ANDROID) 195 #if defined(OS_ANDROID)
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 FailGattConnection(device, BluetoothDevice::ERROR_FAILED); 419 FailGattConnection(device, BluetoothDevice::ERROR_FAILED);
418 EXPECT_EQ(0, callback_count_); 420 EXPECT_EQ(0, callback_count_);
419 EXPECT_EQ(1, error_callback_count_); 421 EXPECT_EQ(1, error_callback_count_);
420 EXPECT_EQ(BluetoothDevice::ERROR_AUTH_FAILED, last_connect_error_code_); 422 EXPECT_EQ(BluetoothDevice::ERROR_AUTH_FAILED, last_connect_error_code_);
421 for (BluetoothGattConnection* connection : gatt_connections_) 423 for (BluetoothGattConnection* connection : gatt_connections_)
422 EXPECT_FALSE(connection->IsConnected()); 424 EXPECT_FALSE(connection->IsConnected());
423 } 425 }
424 #endif // defined(OS_ANDROID) 426 #endif // defined(OS_ANDROID)
425 427
426 } // namespace device 428 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device_android.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698