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

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

Issue 1538173003: Implementing GATT connection/disconnect on OS X. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing msarda comments. Created 4 years, 9 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
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 <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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 115 }
116 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) 116 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN)
117 117
118 // TODO(scheib): Test with a device with no name. http://crbug.com/506415 118 // TODO(scheib): Test with a device with no name. http://crbug.com/506415
119 // BluetoothDevice::GetAddressWithLocalizedDeviceTypeName() will run, which 119 // BluetoothDevice::GetAddressWithLocalizedDeviceTypeName() will run, which
120 // requires string resources to be loaded. For that, something like 120 // requires string resources to be loaded. For that, something like
121 // InitSharedInstance must be run. See unittest files that call that. It will 121 // InitSharedInstance must be run. See unittest files that call that. It will
122 // also require build configuration to generate string resources into a .pak 122 // also require build configuration to generate string resources into a .pak
123 // file. 123 // file.
124 124
125 #if defined(OS_ANDROID) 125 #if defined(OS_ANDROID) || defined(OS_MACOSX)
126 // Basic CreateGattConnection test. 126 // Basic CreateGattConnection test.
127 TEST_F(BluetoothTest, CreateGattConnection) { 127 TEST_F(BluetoothTest, CreateGattConnection) {
128 InitWithFakeAdapter(); 128 InitWithFakeAdapter();
129 StartLowEnergyDiscoverySession(); 129 StartLowEnergyDiscoverySession();
130 BluetoothDevice* device = DiscoverLowEnergyDevice(3); 130 BluetoothDevice* device = DiscoverLowEnergyDevice(3);
131 131
132 ResetEventCounts(); 132 ResetEventCounts();
133 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED), 133 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
134 GetConnectErrorCallback(Call::NOT_EXPECTED)); 134 GetConnectErrorCallback(Call::NOT_EXPECTED));
135 SimulateGattConnection(device); 135 SimulateGattConnection(device);
136 ASSERT_EQ(1u, gatt_connections_.size()); 136 ASSERT_EQ(1u, gatt_connections_.size());
137 EXPECT_TRUE(device->IsGattConnected()); 137 EXPECT_TRUE(device->IsGattConnected());
138 EXPECT_TRUE(gatt_connections_[0]->IsConnected()); 138 EXPECT_TRUE(gatt_connections_[0]->IsConnected());
139 } 139 }
140 #endif // defined(OS_ANDROID) 140 #endif // defined(OS_ANDROID) || defined(OS_MACOSX)
141 141
142 #if defined(OS_ANDROID) 142 #if defined(OS_ANDROID) || defined(OS_MACOSX)
143 // Creates BluetoothGattConnection instances and tests that the interface 143 // Creates BluetoothGattConnection instances and tests that the interface
144 // functions even when some Disconnect and the BluetoothDevice is destroyed. 144 // functions even when some Disconnect and the BluetoothDevice is destroyed.
145 TEST_F(BluetoothTest, BluetoothGattConnection) { 145 TEST_F(BluetoothTest, BluetoothGattConnection) {
146 InitWithFakeAdapter(); 146 InitWithFakeAdapter();
147 StartLowEnergyDiscoverySession(); 147 StartLowEnergyDiscoverySession();
148 BluetoothDevice* device = DiscoverLowEnergyDevice(3); 148 BluetoothDevice* device = DiscoverLowEnergyDevice(3);
149 std::string device_address = device->GetAddress(); 149 std::string device_address = device->GetAddress();
150 150
151 // CreateGattConnection 151 // CreateGattConnection
152 ResetEventCounts(); 152 ResetEventCounts();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 gatt_disconnection_attempts_ = 0; 191 gatt_disconnection_attempts_ = 0;
192 DeleteDevice(device); 192 DeleteDevice(device);
193 EXPECT_EQ(1, gatt_disconnection_attempts_); 193 EXPECT_EQ(1, gatt_disconnection_attempts_);
194 EXPECT_FALSE(gatt_connections_[0]->IsConnected()); 194 EXPECT_FALSE(gatt_connections_[0]->IsConnected());
195 EXPECT_FALSE(gatt_connections_[1]->IsConnected()); 195 EXPECT_FALSE(gatt_connections_[1]->IsConnected());
196 196
197 // Test GetDeviceAddress after device deleted. 197 // Test GetDeviceAddress after device deleted.
198 EXPECT_EQ(device_address, gatt_connections_[0]->GetDeviceAddress()); 198 EXPECT_EQ(device_address, gatt_connections_[0]->GetDeviceAddress());
199 EXPECT_EQ(device_address, gatt_connections_[1]->GetDeviceAddress()); 199 EXPECT_EQ(device_address, gatt_connections_[1]->GetDeviceAddress());
200 } 200 }
201 #endif // defined(OS_ANDROID) 201 #endif // defined(OS_ANDROID) || defined(OS_MACOSX)
202 202
203 #if defined(OS_ANDROID) 203 #if defined(OS_ANDROID) || defined(OS_MACOSX)
204 // Calls CreateGattConnection then simulates multiple connections from platform. 204 // Calls CreateGattConnection then simulates multiple connections from platform.
205 TEST_F(BluetoothTest, 205 TEST_F(BluetoothTest,
206 BluetoothGattConnection_ConnectWithMultipleOSConnections) { 206 BluetoothGattConnection_ConnectWithMultipleOSConnections) {
207 InitWithFakeAdapter(); 207 InitWithFakeAdapter();
208 StartLowEnergyDiscoverySession(); 208 StartLowEnergyDiscoverySession();
209 BluetoothDevice* device = DiscoverLowEnergyDevice(3); 209 BluetoothDevice* device = DiscoverLowEnergyDevice(3);
210 210
211 // CreateGattConnection, & multiple connections from platform only invoke 211 // CreateGattConnection, & multiple connections from platform only invoke
212 // callbacks once: 212 // callbacks once:
213 ResetEventCounts(); 213 ResetEventCounts();
214 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED), 214 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
215 GetConnectErrorCallback(Call::NOT_EXPECTED)); 215 GetConnectErrorCallback(Call::NOT_EXPECTED));
216 SimulateGattConnection(device); 216 SimulateGattConnection(device);
217 SimulateGattConnection(device); 217 SimulateGattConnection(device);
218 EXPECT_EQ(1, gatt_connection_attempts_); 218 EXPECT_EQ(1, gatt_connection_attempts_);
219 EXPECT_EQ(1, callback_count_); 219 EXPECT_EQ(1, callback_count_);
220 EXPECT_EQ(0, error_callback_count_); 220 EXPECT_EQ(0, error_callback_count_);
221 EXPECT_TRUE(gatt_connections_[0]->IsConnected()); 221 EXPECT_TRUE(gatt_connections_[0]->IsConnected());
222 222
223 // Become disconnected: 223 // Become disconnected:
224 SimulateGattDisconnection(device); 224 SimulateGattDisconnection(device);
225 EXPECT_FALSE(gatt_connections_[0]->IsConnected()); 225 EXPECT_FALSE(gatt_connections_[0]->IsConnected());
226 } 226 }
227 #endif // defined(OS_ANDROID) 227 #endif // defined(OS_ANDROID) || defined(OS_MACOSX)
228 228
229 #if defined(OS_ANDROID) 229 #if defined(OS_ANDROID) || defined(OS_MACOSX)
230 // Calls CreateGattConnection after already connected. 230 // Calls CreateGattConnection after already connected.
231 TEST_F(BluetoothTest, BluetoothGattConnection_AlreadyConnected) { 231 TEST_F(BluetoothTest, BluetoothGattConnection_AlreadyConnected) {
232 InitWithFakeAdapter(); 232 InitWithFakeAdapter();
233 StartLowEnergyDiscoverySession(); 233 StartLowEnergyDiscoverySession();
234 BluetoothDevice* device = DiscoverLowEnergyDevice(3); 234 BluetoothDevice* device = DiscoverLowEnergyDevice(3);
235 235
236 // Be already connected: 236 // Be already connected:
237 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED), 237 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
238 GetConnectErrorCallback(Call::NOT_EXPECTED)); 238 GetConnectErrorCallback(Call::NOT_EXPECTED));
239 SimulateGattConnection(device); 239 SimulateGattConnection(device);
240 EXPECT_TRUE(gatt_connections_[0]->IsConnected()); 240 EXPECT_TRUE(gatt_connections_[0]->IsConnected());
241 241
242 // Then CreateGattConnection: 242 // Then CreateGattConnection:
243 ResetEventCounts(); 243 ResetEventCounts();
244 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED), 244 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
245 GetConnectErrorCallback(Call::NOT_EXPECTED)); 245 GetConnectErrorCallback(Call::NOT_EXPECTED));
246 EXPECT_EQ(0, gatt_connection_attempts_); 246 EXPECT_EQ(0, gatt_connection_attempts_);
247 EXPECT_TRUE(gatt_connections_[1]->IsConnected()); 247 EXPECT_TRUE(gatt_connections_[1]->IsConnected());
248 } 248 }
249 #endif // defined(OS_ANDROID) 249 #endif // defined(OS_ANDROID) || defined(OS_MACOSX)
250 250
251 #if defined(OS_ANDROID) 251 #if defined(OS_ANDROID) || defined(OS_MACOSX)
252 // Creates BluetoothGattConnection after one exists that has disconnected. 252 // Creates BluetoothGattConnection after one exists that has disconnected.
253 TEST_F(BluetoothTest, 253 TEST_F(BluetoothTest,
254 BluetoothGattConnection_NewConnectionLeavesPreviousDisconnected) { 254 BluetoothGattConnection_NewConnectionLeavesPreviousDisconnected) {
255 InitWithFakeAdapter(); 255 InitWithFakeAdapter();
256 StartLowEnergyDiscoverySession(); 256 StartLowEnergyDiscoverySession();
257 BluetoothDevice* device = DiscoverLowEnergyDevice(3); 257 BluetoothDevice* device = DiscoverLowEnergyDevice(3);
258 258
259 // Create connection: 259 // Create connection:
260 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED), 260 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
261 GetConnectErrorCallback(Call::NOT_EXPECTED)); 261 GetConnectErrorCallback(Call::NOT_EXPECTED));
262 SimulateGattConnection(device); 262 SimulateGattConnection(device);
263 263
264 // Disconnect connection: 264 // Disconnect connection:
265 gatt_connections_[0]->Disconnect(); 265 gatt_connections_[0]->Disconnect();
266 SimulateGattDisconnection(device); 266 SimulateGattDisconnection(device);
267 267
268 // Create 2nd connection: 268 // Create 2nd connection:
269 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED), 269 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
270 GetConnectErrorCallback(Call::NOT_EXPECTED)); 270 GetConnectErrorCallback(Call::NOT_EXPECTED));
271 SimulateGattConnection(device); 271 SimulateGattConnection(device);
272 272
273 EXPECT_FALSE(gatt_connections_[0]->IsConnected()) 273 EXPECT_FALSE(gatt_connections_[0]->IsConnected())
274 << "The disconnected connection shouldn't become connected when another " 274 << "The disconnected connection shouldn't become connected when another "
275 "connection is created."; 275 "connection is created.";
276 EXPECT_TRUE(gatt_connections_[1]->IsConnected()); 276 EXPECT_TRUE(gatt_connections_[1]->IsConnected());
277 } 277 }
278 #endif // defined(OS_ANDROID) 278 #endif // defined(OS_ANDROID) || defined(OS_MACOSX)
279 279
280 #if defined(OS_ANDROID) 280 #if defined(OS_ANDROID) || defined(OS_MACOSX)
281 // Deletes BluetoothGattConnection causing disconnection. 281 // Deletes BluetoothGattConnection causing disconnection.
282 TEST_F(BluetoothTest, BluetoothGattConnection_DisconnectWhenObjectsDestroyed) { 282 TEST_F(BluetoothTest, BluetoothGattConnection_DisconnectWhenObjectsDestroyed) {
283 InitWithFakeAdapter(); 283 InitWithFakeAdapter();
284 StartLowEnergyDiscoverySession(); 284 StartLowEnergyDiscoverySession();
285 BluetoothDevice* device = DiscoverLowEnergyDevice(3); 285 BluetoothDevice* device = DiscoverLowEnergyDevice(3);
286 286
287 // Create multiple connections and simulate connection complete: 287 // Create multiple connections and simulate connection complete:
288 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED), 288 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
289 GetConnectErrorCallback(Call::NOT_EXPECTED)); 289 GetConnectErrorCallback(Call::NOT_EXPECTED));
290 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED), 290 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
291 GetConnectErrorCallback(Call::NOT_EXPECTED)); 291 GetConnectErrorCallback(Call::NOT_EXPECTED));
292 SimulateGattConnection(device); 292 SimulateGattConnection(device);
293 293
294 // Delete all CreateGattConnection objects, observe disconnection: 294 // Delete all CreateGattConnection objects, observe disconnection:
295 ResetEventCounts(); 295 ResetEventCounts();
296 gatt_connections_.clear(); 296 gatt_connections_.clear();
297 EXPECT_EQ(1, gatt_disconnection_attempts_); 297 EXPECT_EQ(1, gatt_disconnection_attempts_);
298 } 298 }
299 #endif // defined(OS_ANDROID) 299 #endif // defined(OS_ANDROID) || defined(OS_MACOSX)
300 300
301 #if defined(OS_ANDROID) 301 #if defined(OS_ANDROID) || defined(OS_MACOSX)
302 // Starts process of disconnecting and then calls BluetoothGattConnection. 302 // Starts process of disconnecting and then calls BluetoothGattConnection.
303 TEST_F(BluetoothTest, BluetoothGattConnection_DisconnectInProgress) { 303 TEST_F(BluetoothTest, BluetoothGattConnection_DisconnectInProgress) {
304 InitWithFakeAdapter(); 304 InitWithFakeAdapter();
305 StartLowEnergyDiscoverySession(); 305 StartLowEnergyDiscoverySession();
306 BluetoothDevice* device = DiscoverLowEnergyDevice(3); 306 BluetoothDevice* device = DiscoverLowEnergyDevice(3);
307 307
308 // Create multiple connections and simulate connection complete: 308 // Create multiple connections and simulate connection complete:
309 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED), 309 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
310 GetConnectErrorCallback(Call::NOT_EXPECTED)); 310 GetConnectErrorCallback(Call::NOT_EXPECTED));
311 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED), 311 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
(...skipping 14 matching lines...) Expand all
326 EXPECT_EQ(1, callback_count_); // Device is assumed still connected. 326 EXPECT_EQ(1, callback_count_); // Device is assumed still connected.
327 EXPECT_EQ(0, error_callback_count_); 327 EXPECT_EQ(0, error_callback_count_);
328 EXPECT_FALSE(gatt_connections_.front()->IsConnected()); 328 EXPECT_FALSE(gatt_connections_.front()->IsConnected());
329 EXPECT_TRUE(gatt_connections_.back()->IsConnected()); 329 EXPECT_TRUE(gatt_connections_.back()->IsConnected());
330 330
331 // Actually disconnect: 331 // Actually disconnect:
332 SimulateGattDisconnection(device); 332 SimulateGattDisconnection(device);
333 for (BluetoothGattConnection* connection : gatt_connections_) 333 for (BluetoothGattConnection* connection : gatt_connections_)
334 EXPECT_FALSE(connection->IsConnected()); 334 EXPECT_FALSE(connection->IsConnected());
335 } 335 }
336 #endif // defined(OS_ANDROID) 336 #endif // defined(OS_ANDROID) || defined(OS_MACOSX)
337 337
338 #if defined(OS_ANDROID) 338 #if defined(OS_ANDROID) || defined(OS_MACOSX)
339 // Calls CreateGattConnection but receives notice that the device disconnected 339 // Calls CreateGattConnection but receives notice that the device disconnected
340 // before it ever connects. 340 // before it ever connects.
341 TEST_F(BluetoothTest, BluetoothGattConnection_SimulateDisconnect) { 341 TEST_F(BluetoothTest, BluetoothGattConnection_SimulateDisconnect) {
342 InitWithFakeAdapter(); 342 InitWithFakeAdapter();
343 StartLowEnergyDiscoverySession(); 343 StartLowEnergyDiscoverySession();
344 BluetoothDevice* device = DiscoverLowEnergyDevice(3); 344 BluetoothDevice* device = DiscoverLowEnergyDevice(3);
345 345
346 ResetEventCounts(); 346 ResetEventCounts();
347 device->CreateGattConnection(GetGattConnectionCallback(Call::NOT_EXPECTED), 347 device->CreateGattConnection(GetGattConnectionCallback(Call::NOT_EXPECTED),
348 GetConnectErrorCallback(Call::EXPECTED)); 348 GetConnectErrorCallback(Call::EXPECTED));
349 EXPECT_EQ(1, gatt_connection_attempts_); 349 EXPECT_EQ(1, gatt_connection_attempts_);
350 SimulateGattDisconnection(device); 350 SimulateGattDisconnection(device);
351 EXPECT_EQ(BluetoothDevice::ERROR_FAILED, last_connect_error_code_); 351 EXPECT_EQ(BluetoothDevice::ERROR_FAILED, last_connect_error_code_);
352 for (BluetoothGattConnection* connection : gatt_connections_) 352 for (BluetoothGattConnection* connection : gatt_connections_)
353 EXPECT_FALSE(connection->IsConnected()); 353 EXPECT_FALSE(connection->IsConnected());
354 } 354 }
355 #endif // defined(OS_ANDROID) 355 #endif // defined(OS_ANDROID) || defined(OS_MACOSX)
356 356
357 #if defined(OS_ANDROID) 357 #if defined(OS_ANDROID) || defined(OS_MACOSX)
358 // Calls CreateGattConnection & DisconnectGatt, then simulates connection. 358 // Calls CreateGattConnection & DisconnectGatt, then simulates connection.
359 TEST_F(BluetoothTest, BluetoothGattConnection_DisconnectGatt_SimulateConnect) { 359 TEST_F(BluetoothTest, BluetoothGattConnection_DisconnectGatt_SimulateConnect) {
360 InitWithFakeAdapter(); 360 InitWithFakeAdapter();
361 StartLowEnergyDiscoverySession(); 361 StartLowEnergyDiscoverySession();
362 BluetoothDevice* device = DiscoverLowEnergyDevice(3); 362 BluetoothDevice* device = DiscoverLowEnergyDevice(3);
363 363
364 ResetEventCounts(); 364 ResetEventCounts();
365 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED), 365 device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
366 GetConnectErrorCallback(Call::NOT_EXPECTED)); 366 GetConnectErrorCallback(Call::NOT_EXPECTED));
367 device->DisconnectGatt(); 367 device->DisconnectGatt();
368 EXPECT_EQ(1, gatt_connection_attempts_); 368 EXPECT_EQ(1, gatt_connection_attempts_);
369 EXPECT_EQ(1, gatt_disconnection_attempts_); 369 EXPECT_EQ(1, gatt_disconnection_attempts_);
370 SimulateGattConnection(device); 370 SimulateGattConnection(device);
371 EXPECT_EQ(1, callback_count_); 371 EXPECT_EQ(1, callback_count_);
372 EXPECT_EQ(0, error_callback_count_); 372 EXPECT_EQ(0, error_callback_count_);
373 EXPECT_TRUE(gatt_connections_.back()->IsConnected()); 373 EXPECT_TRUE(gatt_connections_.back()->IsConnected());
374 ResetEventCounts(); 374 ResetEventCounts();
375 SimulateGattDisconnection(device); 375 SimulateGattDisconnection(device);
376 EXPECT_EQ(0, callback_count_); 376 EXPECT_EQ(0, callback_count_);
377 EXPECT_EQ(0, error_callback_count_); 377 EXPECT_EQ(0, error_callback_count_);
378 } 378 }
379 #endif // defined(OS_ANDROID) 379 #endif // defined(OS_ANDROID) || defined(OS_MACOSX)
380 380
381 #if defined(OS_ANDROID) 381 #if defined(OS_ANDROID) || defined(OS_MACOSX)
382 // Calls CreateGattConnection & DisconnectGatt, then simulates disconnection. 382 // Calls CreateGattConnection & DisconnectGatt, then simulates disconnection.
383 TEST_F(BluetoothTest, 383 TEST_F(BluetoothTest,
384 BluetoothGattConnection_DisconnectGatt_SimulateDisconnect) { 384 BluetoothGattConnection_DisconnectGatt_SimulateDisconnect) {
385 InitWithFakeAdapter(); 385 InitWithFakeAdapter();
386 StartLowEnergyDiscoverySession(); 386 StartLowEnergyDiscoverySession();
387 BluetoothDevice* device = DiscoverLowEnergyDevice(3); 387 BluetoothDevice* device = DiscoverLowEnergyDevice(3);
388 388
389 ResetEventCounts(); 389 ResetEventCounts();
390 device->CreateGattConnection(GetGattConnectionCallback(Call::NOT_EXPECTED), 390 device->CreateGattConnection(GetGattConnectionCallback(Call::NOT_EXPECTED),
391 GetConnectErrorCallback(Call::EXPECTED)); 391 GetConnectErrorCallback(Call::EXPECTED));
392 device->DisconnectGatt(); 392 device->DisconnectGatt();
393 EXPECT_EQ(1, gatt_connection_attempts_); 393 EXPECT_EQ(1, gatt_connection_attempts_);
394 EXPECT_EQ(1, gatt_disconnection_attempts_); 394 EXPECT_EQ(1, gatt_disconnection_attempts_);
395 SimulateGattDisconnection(device); 395 SimulateGattDisconnection(device);
396 EXPECT_EQ(BluetoothDevice::ERROR_FAILED, last_connect_error_code_); 396 EXPECT_EQ(BluetoothDevice::ERROR_FAILED, last_connect_error_code_);
397 for (BluetoothGattConnection* connection : gatt_connections_) 397 for (BluetoothGattConnection* connection : gatt_connections_)
398 EXPECT_FALSE(connection->IsConnected()); 398 EXPECT_FALSE(connection->IsConnected());
399 } 399 }
400 #endif // defined(OS_ANDROID) 400 #endif // defined(OS_ANDROID) || defined(OS_MACOSX)
401 401
402 #if defined(OS_ANDROID) 402 #if defined(OS_ANDROID)
403 // Calls CreateGattConnection & DisconnectGatt, then checks that gatt services 403 // Calls CreateGattConnection & DisconnectGatt, then checks that gatt services
404 // have been cleaned up. 404 // have been cleaned up.
405 TEST_F(BluetoothTest, BluetoothGattConnection_DisconnectGatt_Cleanup) { 405 TEST_F(BluetoothTest, BluetoothGattConnection_DisconnectGatt_Cleanup) {
406 InitWithFakeAdapter(); 406 InitWithFakeAdapter();
407 StartLowEnergyDiscoverySession(); 407 StartLowEnergyDiscoverySession();
408 BluetoothDevice* device = DiscoverLowEnergyDevice(3); 408 BluetoothDevice* device = DiscoverLowEnergyDevice(3);
409 EXPECT_FALSE(device->IsConnected()); 409 EXPECT_FALSE(device->IsConnected());
410 410
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 ResetEventCounts(); 541 ResetEventCounts();
542 SimulateGattConnection(device); 542 SimulateGattConnection(device);
543 EXPECT_EQ(1, gatt_discovery_attempts_); 543 EXPECT_EQ(1, gatt_discovery_attempts_);
544 544
545 SimulateGattServicesDiscoveryError(device); 545 SimulateGattServicesDiscoveryError(device);
546 EXPECT_EQ(0u, device->GetGattServices().size()); 546 EXPECT_EQ(0u, device->GetGattServices().size());
547 } 547 }
548 #endif // defined(OS_ANDROID) 548 #endif // defined(OS_ANDROID)
549 549
550 } // namespace device 550 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698