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

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

Issue 1749403002: Implement BluetoothRemoteGattCharacteristicWin::StartNotifySession and related unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_gatt_characteristic.h" 5 #include "device/bluetooth/bluetooth_gatt_characteristic.h"
6 6
7 #include <stdint.h> 7 #include <stdint.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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 characteristic1_->StartNotifySession( 91 characteristic1_->StartNotifySession(
92 GetNotifyCallback(Call::NOT_EXPECTED), 92 GetNotifyCallback(Call::NOT_EXPECTED),
93 GetGattErrorCallback(Call::EXPECTED)); 93 GetGattErrorCallback(Call::EXPECTED));
94 return; 94 return;
95 } 95 }
96 96
97 characteristic1_->StartNotifySession( 97 characteristic1_->StartNotifySession(
98 GetNotifyCallback(Call::EXPECTED), 98 GetNotifyCallback(Call::EXPECTED),
99 GetGattErrorCallback(Call::NOT_EXPECTED)); 99 GetGattErrorCallback(Call::NOT_EXPECTED));
100 100
101 EXPECT_EQ(1, gatt_notify_characteristic_attempts_);
102 EXPECT_EQ(0, callback_count_); 101 EXPECT_EQ(0, callback_count_);
103 SimulateGattNotifySessionStarted(characteristic1_); 102 SimulateGattNotifySessionStarted(characteristic1_);
103 EXPECT_EQ(1, gatt_notify_characteristic_attempts_);
104 EXPECT_EQ(1, callback_count_); 104 EXPECT_EQ(1, callback_count_);
105 EXPECT_EQ(0, error_callback_count_); 105 EXPECT_EQ(0, error_callback_count_);
106 ASSERT_EQ(1u, notify_sessions_.size()); 106 ASSERT_EQ(1u, notify_sessions_.size());
107 ASSERT_TRUE(notify_sessions_[0]); 107 ASSERT_TRUE(notify_sessions_[0]);
108 EXPECT_EQ(characteristic1_->GetIdentifier(), 108 EXPECT_EQ(characteristic1_->GetIdentifier(),
109 notify_sessions_[0]->GetCharacteristicIdentifier()); 109 notify_sessions_[0]->GetCharacteristicIdentifier());
110 EXPECT_TRUE(notify_sessions_[0]->IsActive()); 110 EXPECT_TRUE(notify_sessions_[0]->IsActive());
111 111
112 #ifndef OS_WIN
112 // Verify the Client Characteristic Configuration descriptor was written to. 113 // Verify the Client Characteristic Configuration descriptor was written to.
114 // Windows: No need to write CCCD explicitly to start notification.
113 EXPECT_EQ(1, gatt_write_descriptor_attempts_); 115 EXPECT_EQ(1, gatt_write_descriptor_attempts_);
114 EXPECT_EQ(2u, last_write_value_.size()); 116 EXPECT_EQ(2u, last_write_value_.size());
115 uint8_t expected_byte0 = expected_config_descriptor_value & 0xFF; 117 uint8_t expected_byte0 = expected_config_descriptor_value & 0xFF;
116 uint8_t expected_byte1 = (expected_config_descriptor_value >> 8) & 0xFF; 118 uint8_t expected_byte1 = (expected_config_descriptor_value >> 8) & 0xFF;
117 EXPECT_EQ(expected_byte0, last_write_value_[0]); 119 EXPECT_EQ(expected_byte0, last_write_value_[0]);
118 EXPECT_EQ(expected_byte1, last_write_value_[1]); 120 EXPECT_EQ(expected_byte1, last_write_value_[1]);
121 #endif
119 } 122 }
120 123
121 BluetoothDevice* device_ = nullptr; 124 BluetoothDevice* device_ = nullptr;
122 BluetoothGattService* service_ = nullptr; 125 BluetoothGattService* service_ = nullptr;
123 BluetoothGattCharacteristic* characteristic1_ = nullptr; 126 BluetoothGattCharacteristic* characteristic1_ = nullptr;
124 BluetoothGattCharacteristic* characteristic2_ = nullptr; 127 BluetoothGattCharacteristic* characteristic2_ = nullptr;
125 }; 128 };
126 #endif 129 #endif
127 130
128 #if defined(OS_ANDROID) || defined(OS_WIN) 131 #if defined(OS_ANDROID) || defined(OS_WIN)
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 269
267 #if defined(OS_ANDROID) || defined(OS_WIN) 270 #if defined(OS_ANDROID) || defined(OS_WIN)
268 // Tests ReadRemoteCharacteristic and GetValue with empty value buffer. 271 // Tests ReadRemoteCharacteristic and GetValue with empty value buffer.
269 TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic_Empty) { 272 TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic_Empty) {
270 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate( 273 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
271 BluetoothGattCharacteristic::PROPERTY_READ)); 274 BluetoothGattCharacteristic::PROPERTY_READ));
272 275
273 characteristic1_->ReadRemoteCharacteristic( 276 characteristic1_->ReadRemoteCharacteristic(
274 GetReadValueCallback(Call::EXPECTED), 277 GetReadValueCallback(Call::EXPECTED),
275 GetGattErrorCallback(Call::NOT_EXPECTED)); 278 GetGattErrorCallback(Call::NOT_EXPECTED));
276 EXPECT_EQ(1, gatt_read_characteristic_attempts_);
277 std::vector<uint8_t> empty_vector; 279 std::vector<uint8_t> empty_vector;
278 SimulateGattCharacteristicRead(characteristic1_, empty_vector); 280 SimulateGattCharacteristicRead(characteristic1_, empty_vector);
279 281
280 // Duplicate read reported from OS shouldn't cause a problem: 282 // Duplicate read reported from OS shouldn't cause a problem:
281 SimulateGattCharacteristicRead(characteristic1_, empty_vector); 283 SimulateGattCharacteristicRead(characteristic1_, empty_vector);
282 284
285 EXPECT_EQ(1, gatt_read_characteristic_attempts_);
283 EXPECT_EQ(empty_vector, last_read_value_); 286 EXPECT_EQ(empty_vector, last_read_value_);
284 EXPECT_EQ(empty_vector, characteristic1_->GetValue()); 287 EXPECT_EQ(empty_vector, characteristic1_->GetValue());
285 } 288 }
286 #endif // defined(OS_ANDROID) || defined(OS_WIN) 289 #endif // defined(OS_ANDROID) || defined(OS_WIN)
287 290
288 #if defined(OS_ANDROID) || defined(OS_WIN) 291 #if defined(OS_ANDROID) || defined(OS_WIN)
289 // Tests WriteRemoteCharacteristic with empty value buffer. 292 // Tests WriteRemoteCharacteristic with empty value buffer.
290 TEST_F(BluetoothGattCharacteristicTest, WriteRemoteCharacteristic_Empty) { 293 TEST_F(BluetoothGattCharacteristicTest, WriteRemoteCharacteristic_Empty) {
291 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate( 294 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
292 BluetoothGattCharacteristic::PROPERTY_WRITE)); 295 BluetoothGattCharacteristic::PROPERTY_WRITE));
293 296
294 std::vector<uint8_t> empty_vector; 297 std::vector<uint8_t> empty_vector;
295 characteristic1_->WriteRemoteCharacteristic( 298 characteristic1_->WriteRemoteCharacteristic(
296 empty_vector, GetCallback(Call::EXPECTED), 299 empty_vector, GetCallback(Call::EXPECTED),
297 GetGattErrorCallback(Call::NOT_EXPECTED)); 300 GetGattErrorCallback(Call::NOT_EXPECTED));
298 EXPECT_EQ(1, gatt_write_characteristic_attempts_);
299 SimulateGattCharacteristicWrite(characteristic1_); 301 SimulateGattCharacteristicWrite(characteristic1_);
300 302
303 EXPECT_EQ(1, gatt_write_characteristic_attempts_);
301 EXPECT_EQ(empty_vector, last_write_value_); 304 EXPECT_EQ(empty_vector, last_write_value_);
302 } 305 }
303 #endif // defined(OS_ANDROID) || defined(OS_WIN) 306 #endif // defined(OS_ANDROID) || defined(OS_WIN)
304 307
305 #if defined(OS_ANDROID) || defined(OS_WIN) 308 #if defined(OS_ANDROID) || defined(OS_WIN)
306 // Tests ReadRemoteCharacteristic completing after Chrome objects are deleted. 309 // Tests ReadRemoteCharacteristic completing after Chrome objects are deleted.
307 TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic_AfterDeleted) { 310 TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic_AfterDeleted) {
308 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate( 311 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
309 BluetoothGattCharacteristic::PROPERTY_READ)); 312 BluetoothGattCharacteristic::PROPERTY_READ));
310 313
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 347
345 #if defined(OS_ANDROID) || defined(OS_WIN) 348 #if defined(OS_ANDROID) || defined(OS_WIN)
346 // Tests ReadRemoteCharacteristic and GetValue with non-empty value buffer. 349 // Tests ReadRemoteCharacteristic and GetValue with non-empty value buffer.
347 TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic) { 350 TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic) {
348 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate( 351 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
349 BluetoothGattCharacteristic::PROPERTY_READ)); 352 BluetoothGattCharacteristic::PROPERTY_READ));
350 353
351 characteristic1_->ReadRemoteCharacteristic( 354 characteristic1_->ReadRemoteCharacteristic(
352 GetReadValueCallback(Call::EXPECTED), 355 GetReadValueCallback(Call::EXPECTED),
353 GetGattErrorCallback(Call::NOT_EXPECTED)); 356 GetGattErrorCallback(Call::NOT_EXPECTED));
354 EXPECT_EQ(1, gatt_read_characteristic_attempts_);
355 357
356 uint8_t values[] = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff}; 358 uint8_t values[] = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff};
357 std::vector<uint8_t> test_vector(values, values + arraysize(values)); 359 std::vector<uint8_t> test_vector(values, values + arraysize(values));
358 SimulateGattCharacteristicRead(characteristic1_, test_vector); 360 SimulateGattCharacteristicRead(characteristic1_, test_vector);
359 361
360 // Duplicate read reported from OS shouldn't cause a problem: 362 // Duplicate read reported from OS shouldn't cause a problem:
361 std::vector<uint8_t> empty_vector; 363 std::vector<uint8_t> empty_vector;
362 SimulateGattCharacteristicRead(characteristic1_, empty_vector); 364 SimulateGattCharacteristicRead(characteristic1_, empty_vector);
363 365
366 EXPECT_EQ(1, gatt_read_characteristic_attempts_);
364 EXPECT_EQ(test_vector, last_read_value_); 367 EXPECT_EQ(test_vector, last_read_value_);
365 EXPECT_EQ(test_vector, characteristic1_->GetValue()); 368 EXPECT_EQ(test_vector, characteristic1_->GetValue());
366 } 369 }
367 #endif // defined(OS_ANDROID) || defined(OS_WIN) 370 #endif // defined(OS_ANDROID) || defined(OS_WIN)
368 371
369 #if defined(OS_ANDROID) || defined(OS_WIN) 372 #if defined(OS_ANDROID) || defined(OS_WIN)
370 // Tests WriteRemoteCharacteristic with non-empty value buffer. 373 // Tests WriteRemoteCharacteristic with non-empty value buffer.
371 TEST_F(BluetoothGattCharacteristicTest, WriteRemoteCharacteristic) { 374 TEST_F(BluetoothGattCharacteristicTest, WriteRemoteCharacteristic) {
372 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate( 375 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
373 BluetoothGattCharacteristic::PROPERTY_WRITE)); 376 BluetoothGattCharacteristic::PROPERTY_WRITE));
374 377
375 uint8_t values[] = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff}; 378 uint8_t values[] = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff};
376 std::vector<uint8_t> test_vector(values, values + arraysize(values)); 379 std::vector<uint8_t> test_vector(values, values + arraysize(values));
377 characteristic1_->WriteRemoteCharacteristic( 380 characteristic1_->WriteRemoteCharacteristic(
378 test_vector, GetCallback(Call::EXPECTED), 381 test_vector, GetCallback(Call::EXPECTED),
379 GetGattErrorCallback(Call::NOT_EXPECTED)); 382 GetGattErrorCallback(Call::NOT_EXPECTED));
380 EXPECT_EQ(1, gatt_write_characteristic_attempts_);
381 383
382 SimulateGattCharacteristicWrite(characteristic1_); 384 SimulateGattCharacteristicWrite(characteristic1_);
383 385
386 EXPECT_EQ(1, gatt_write_characteristic_attempts_);
384 EXPECT_EQ(test_vector, last_write_value_); 387 EXPECT_EQ(test_vector, last_write_value_);
385 } 388 }
386 #endif // defined(OS_ANDROID) || defined(OS_WIN) 389 #endif // defined(OS_ANDROID) || defined(OS_WIN)
387 390
388 #if defined(OS_ANDROID) || defined(OS_WIN) 391 #if defined(OS_ANDROID) || defined(OS_WIN)
389 // Tests ReadRemoteCharacteristic and GetValue multiple times. 392 // Tests ReadRemoteCharacteristic and GetValue multiple times.
390 TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic_Twice) { 393 TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic_Twice) {
391 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate( 394 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
392 BluetoothGattCharacteristic::PROPERTY_READ)); 395 BluetoothGattCharacteristic::PROPERTY_READ));
393 396
394 characteristic1_->ReadRemoteCharacteristic( 397 characteristic1_->ReadRemoteCharacteristic(
395 GetReadValueCallback(Call::EXPECTED), 398 GetReadValueCallback(Call::EXPECTED),
396 GetGattErrorCallback(Call::NOT_EXPECTED)); 399 GetGattErrorCallback(Call::NOT_EXPECTED));
397 EXPECT_EQ(1, gatt_read_characteristic_attempts_);
398 400
399 uint8_t values[] = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff}; 401 uint8_t values[] = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff};
400 std::vector<uint8_t> test_vector(values, values + arraysize(values)); 402 std::vector<uint8_t> test_vector(values, values + arraysize(values));
401 SimulateGattCharacteristicRead(characteristic1_, test_vector); 403 SimulateGattCharacteristicRead(characteristic1_, test_vector);
404 EXPECT_EQ(1, gatt_read_characteristic_attempts_);
402 EXPECT_EQ(1, callback_count_); 405 EXPECT_EQ(1, callback_count_);
403 EXPECT_EQ(0, error_callback_count_); 406 EXPECT_EQ(0, error_callback_count_);
404 EXPECT_EQ(test_vector, last_read_value_); 407 EXPECT_EQ(test_vector, last_read_value_);
405 EXPECT_EQ(test_vector, characteristic1_->GetValue()); 408 EXPECT_EQ(test_vector, characteristic1_->GetValue());
406 409
407 // Read again, with different value: 410 // Read again, with different value:
408 ResetEventCounts(); 411 ResetEventCounts();
409 characteristic1_->ReadRemoteCharacteristic( 412 characteristic1_->ReadRemoteCharacteristic(
410 GetReadValueCallback(Call::EXPECTED), 413 GetReadValueCallback(Call::EXPECTED),
411 GetGattErrorCallback(Call::NOT_EXPECTED)); 414 GetGattErrorCallback(Call::NOT_EXPECTED));
412 EXPECT_EQ(1, gatt_read_characteristic_attempts_);
413 std::vector<uint8_t> empty_vector; 415 std::vector<uint8_t> empty_vector;
414 SimulateGattCharacteristicRead(characteristic1_, empty_vector); 416 SimulateGattCharacteristicRead(characteristic1_, empty_vector);
417 EXPECT_EQ(1, gatt_read_characteristic_attempts_);
415 EXPECT_EQ(1, callback_count_); 418 EXPECT_EQ(1, callback_count_);
416 EXPECT_EQ(0, error_callback_count_); 419 EXPECT_EQ(0, error_callback_count_);
417 EXPECT_EQ(empty_vector, last_read_value_); 420 EXPECT_EQ(empty_vector, last_read_value_);
418 EXPECT_EQ(empty_vector, characteristic1_->GetValue()); 421 EXPECT_EQ(empty_vector, characteristic1_->GetValue());
419 } 422 }
420 #endif // defined(OS_ANDROID) || defined(OS_WIN) 423 #endif // defined(OS_ANDROID) || defined(OS_WIN)
421 424
422 #if defined(OS_ANDROID) || defined(OS_WIN) 425 #if defined(OS_ANDROID) || defined(OS_WIN)
423 // Tests WriteRemoteCharacteristic multiple times. 426 // Tests WriteRemoteCharacteristic multiple times.
424 TEST_F(BluetoothGattCharacteristicTest, WriteRemoteCharacteristic_Twice) { 427 TEST_F(BluetoothGattCharacteristicTest, WriteRemoteCharacteristic_Twice) {
425 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate( 428 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
426 BluetoothGattCharacteristic::PROPERTY_WRITE)); 429 BluetoothGattCharacteristic::PROPERTY_WRITE));
427 430
428 uint8_t values[] = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff}; 431 uint8_t values[] = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff};
429 std::vector<uint8_t> test_vector(values, values + arraysize(values)); 432 std::vector<uint8_t> test_vector(values, values + arraysize(values));
430 characteristic1_->WriteRemoteCharacteristic( 433 characteristic1_->WriteRemoteCharacteristic(
431 test_vector, GetCallback(Call::EXPECTED), 434 test_vector, GetCallback(Call::EXPECTED),
432 GetGattErrorCallback(Call::NOT_EXPECTED)); 435 GetGattErrorCallback(Call::NOT_EXPECTED));
433 EXPECT_EQ(1, gatt_write_characteristic_attempts_);
434 436
435 SimulateGattCharacteristicWrite(characteristic1_); 437 SimulateGattCharacteristicWrite(characteristic1_);
438 EXPECT_EQ(1, gatt_write_characteristic_attempts_);
436 EXPECT_EQ(1, callback_count_); 439 EXPECT_EQ(1, callback_count_);
437 EXPECT_EQ(0, error_callback_count_); 440 EXPECT_EQ(0, error_callback_count_);
438 EXPECT_EQ(test_vector, last_write_value_); 441 EXPECT_EQ(test_vector, last_write_value_);
439 442
440 // Write again, with different value: 443 // Write again, with different value:
441 ResetEventCounts(); 444 ResetEventCounts();
442 std::vector<uint8_t> empty_vector; 445 std::vector<uint8_t> empty_vector;
443 characteristic1_->WriteRemoteCharacteristic( 446 characteristic1_->WriteRemoteCharacteristic(
444 empty_vector, GetCallback(Call::EXPECTED), 447 empty_vector, GetCallback(Call::EXPECTED),
445 GetGattErrorCallback(Call::NOT_EXPECTED)); 448 GetGattErrorCallback(Call::NOT_EXPECTED));
449
450 SimulateGattCharacteristicWrite(characteristic1_);
446 EXPECT_EQ(1, gatt_write_characteristic_attempts_); 451 EXPECT_EQ(1, gatt_write_characteristic_attempts_);
447 SimulateGattCharacteristicWrite(characteristic1_);
448 EXPECT_EQ(1, callback_count_); 452 EXPECT_EQ(1, callback_count_);
449 EXPECT_EQ(0, error_callback_count_); 453 EXPECT_EQ(0, error_callback_count_);
450 EXPECT_EQ(empty_vector, last_write_value_); 454 EXPECT_EQ(empty_vector, last_write_value_);
451 } 455 }
452 #endif // defined(OS_ANDROID) || defined(OS_WIN) 456 #endif // defined(OS_ANDROID) || defined(OS_WIN)
453 457
454 #if defined(OS_ANDROID) || defined(OS_WIN) 458 #if defined(OS_ANDROID) || defined(OS_WIN)
455 // Tests ReadRemoteCharacteristic on two characteristics. 459 // Tests ReadRemoteCharacteristic on two characteristics.
456 TEST_F(BluetoothGattCharacteristicTest, 460 TEST_F(BluetoothGattCharacteristicTest,
457 ReadRemoteCharacteristic_MultipleCharacteristics) { 461 ReadRemoteCharacteristic_MultipleCharacteristics) {
458 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate( 462 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
459 BluetoothGattCharacteristic::PROPERTY_READ)); 463 BluetoothGattCharacteristic::PROPERTY_READ));
460 464
461 characteristic1_->ReadRemoteCharacteristic( 465 characteristic1_->ReadRemoteCharacteristic(
462 GetReadValueCallback(Call::EXPECTED), 466 GetReadValueCallback(Call::EXPECTED),
463 GetGattErrorCallback(Call::NOT_EXPECTED)); 467 GetGattErrorCallback(Call::NOT_EXPECTED));
464 characteristic2_->ReadRemoteCharacteristic( 468 characteristic2_->ReadRemoteCharacteristic(
465 GetReadValueCallback(Call::EXPECTED), 469 GetReadValueCallback(Call::EXPECTED),
466 GetGattErrorCallback(Call::NOT_EXPECTED)); 470 GetGattErrorCallback(Call::NOT_EXPECTED));
467 EXPECT_EQ(2, gatt_read_characteristic_attempts_);
468 EXPECT_EQ(0, callback_count_); 471 EXPECT_EQ(0, callback_count_);
469 EXPECT_EQ(0, error_callback_count_); 472 EXPECT_EQ(0, error_callback_count_);
470 473
471 std::vector<uint8_t> test_vector1; 474 std::vector<uint8_t> test_vector1;
472 test_vector1.push_back(111); 475 test_vector1.push_back(111);
473 SimulateGattCharacteristicRead(characteristic1_, test_vector1); 476 SimulateGattCharacteristicRead(characteristic1_, test_vector1);
474 EXPECT_EQ(test_vector1, last_read_value_); 477 EXPECT_EQ(test_vector1, last_read_value_);
475 478
476 std::vector<uint8_t> test_vector2; 479 std::vector<uint8_t> test_vector2;
477 test_vector2.push_back(222); 480 test_vector2.push_back(222);
478 SimulateGattCharacteristicRead(characteristic2_, test_vector2); 481 SimulateGattCharacteristicRead(characteristic2_, test_vector2);
479 EXPECT_EQ(test_vector2, last_read_value_); 482 EXPECT_EQ(test_vector2, last_read_value_);
480 483
484 EXPECT_EQ(2, gatt_read_characteristic_attempts_);
481 EXPECT_EQ(2, callback_count_); 485 EXPECT_EQ(2, callback_count_);
482 EXPECT_EQ(0, error_callback_count_); 486 EXPECT_EQ(0, error_callback_count_);
483 EXPECT_EQ(test_vector1, characteristic1_->GetValue()); 487 EXPECT_EQ(test_vector1, characteristic1_->GetValue());
484 EXPECT_EQ(test_vector2, characteristic2_->GetValue()); 488 EXPECT_EQ(test_vector2, characteristic2_->GetValue());
485 } 489 }
486 #endif // defined(OS_ANDROID) || defined(OS_WIN) 490 #endif // defined(OS_ANDROID) || defined(OS_WIN)
487 491
488 #if defined(OS_ANDROID) || defined(OS_WIN) 492 #if defined(OS_ANDROID) || defined(OS_WIN)
489 // Tests WriteRemoteCharacteristic on two characteristics. 493 // Tests WriteRemoteCharacteristic on two characteristics.
490 TEST_F(BluetoothGattCharacteristicTest, 494 TEST_F(BluetoothGattCharacteristicTest,
(...skipping 12 matching lines...) Expand all
503 507
504 std::vector<uint8_t> test_vector2; 508 std::vector<uint8_t> test_vector2;
505 test_vector2.push_back(222); 509 test_vector2.push_back(222);
506 characteristic2_->WriteRemoteCharacteristic( 510 characteristic2_->WriteRemoteCharacteristic(
507 test_vector2, GetCallback(Call::EXPECTED), 511 test_vector2, GetCallback(Call::EXPECTED),
508 GetGattErrorCallback(Call::NOT_EXPECTED)); 512 GetGattErrorCallback(Call::NOT_EXPECTED));
509 #ifdef OS_ANDROID 513 #ifdef OS_ANDROID
510 EXPECT_EQ(test_vector2, last_write_value_); 514 EXPECT_EQ(test_vector2, last_write_value_);
511 #endif 515 #endif
512 516
513 EXPECT_EQ(2, gatt_write_characteristic_attempts_);
514 EXPECT_EQ(0, callback_count_); 517 EXPECT_EQ(0, callback_count_);
515 EXPECT_EQ(0, error_callback_count_); 518 EXPECT_EQ(0, error_callback_count_);
516 519
517 SimulateGattCharacteristicWrite(characteristic1_); 520 SimulateGattCharacteristicWrite(characteristic1_);
518 #ifndef OS_ANDROID 521 #ifndef OS_ANDROID
519 EXPECT_EQ(test_vector1, last_write_value_); 522 EXPECT_EQ(test_vector1, last_write_value_);
520 #endif 523 #endif
521 524
522 SimulateGattCharacteristicWrite(characteristic2_); 525 SimulateGattCharacteristicWrite(characteristic2_);
523 #ifndef OS_ANDROID 526 #ifndef OS_ANDROID
524 EXPECT_EQ(test_vector2, last_write_value_); 527 EXPECT_EQ(test_vector2, last_write_value_);
525 #endif 528 #endif
526 529
530 EXPECT_EQ(2, gatt_write_characteristic_attempts_);
527 EXPECT_EQ(2, callback_count_); 531 EXPECT_EQ(2, callback_count_);
528 EXPECT_EQ(0, error_callback_count_); 532 EXPECT_EQ(0, error_callback_count_);
529 533
530 // TODO(crbug.com/591740): Remove if define for OS_ANDROID in this test. 534 // TODO(crbug.com/591740): Remove if define for OS_ANDROID in this test.
531 } 535 }
532 #endif // defined(OS_ANDROID) || defined(OS_WIN) 536 #endif // defined(OS_ANDROID) || defined(OS_WIN)
533 537
534 #if defined(OS_ANDROID) || defined(OS_WIN) 538 #if defined(OS_ANDROID) || defined(OS_WIN)
535 // Tests ReadRemoteCharacteristic asynchronous error. 539 // Tests ReadRemoteCharacteristic asynchronous error.
536 TEST_F(BluetoothGattCharacteristicTest, ReadError) { 540 TEST_F(BluetoothGattCharacteristicTest, ReadError) {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 last_gatt_error_code_); 740 last_gatt_error_code_);
737 741
738 // Initial read should still succeed: 742 // Initial read should still succeed:
739 ResetEventCounts(); 743 ResetEventCounts();
740 SimulateGattCharacteristicRead(characteristic1_, empty_vector); 744 SimulateGattCharacteristicRead(characteristic1_, empty_vector);
741 EXPECT_EQ(1, callback_count_); 745 EXPECT_EQ(1, callback_count_);
742 EXPECT_EQ(0, error_callback_count_); 746 EXPECT_EQ(0, error_callback_count_);
743 } 747 }
744 #endif // defined(OS_ANDROID) || defined(OS_WIN) 748 #endif // defined(OS_ANDROID) || defined(OS_WIN)
745 749
746 #if defined(OS_ANDROID) 750 #if defined(OS_ANDROID) || defined(OS_WIN)
747 // StartNotifySession fails if characteristic doesn't have Notify or Indicate 751 // StartNotifySession fails if characteristic doesn't have Notify or Indicate
748 // property. 752 // property.
749 TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_NoNotifyOrIndicate) { 753 TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_NoNotifyOrIndicate) {
750 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( 754 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
751 /* properties: NOTIFY */ 0x10, 755 /* properties: NOTIFY */ 0x10,
752 /* expected_config_descriptor_value: NOTIFY */ 1, 756 /* expected_config_descriptor_value: NOTIFY */ 1,
753 StartNotifySetupError::CHARACTERISTIC_PROPERTIES)); 757 StartNotifySetupError::CHARACTERISTIC_PROPERTIES));
754 758
755 EXPECT_EQ(0, gatt_notify_characteristic_attempts_); 759 EXPECT_EQ(0, gatt_notify_characteristic_attempts_);
756 760
757 // The expected error callback is asynchronous: 761 // The expected error callback is asynchronous:
758 EXPECT_EQ(0, error_callback_count_); 762 EXPECT_EQ(0, error_callback_count_);
759 base::RunLoop().RunUntilIdle(); 763 base::RunLoop().RunUntilIdle();
760 EXPECT_EQ(1, error_callback_count_); 764 EXPECT_EQ(1, error_callback_count_);
765 // TODO(crbug.com/584369) Android doesn't return the correct errors.
766 #ifndef OS_ANDROID
ortuno 2016/03/15 02:55:31 I think the style guide prefers #if defined(OS_AND
gogerald1 2016/03/15 18:28:22 Done. Do not see it explicitly, especially this lo
767 EXPECT_EQ(BluetoothGattService::GATT_ERROR_NOT_SUPPORTED,
768 last_gatt_error_code_);
769 #endif
ortuno 2016/03/15 02:55:31 #endif // defined(OS_ANDROID)
gogerald1 2016/03/15 18:28:22 Done.
761 } 770 }
762 #endif // defined(OS_ANDROID) 771 #endif // defined(OS_ANDROID) || defined(OS_WIN)
763 772
764 #if defined(OS_ANDROID) 773 #if defined(OS_ANDROID) || !defined(OS_WIN)
765 // StartNotifySession fails if the characteristic is missing the Client 774 // StartNotifySession fails if the characteristic is missing the Client
766 // Characteristic Configuration descriptor. 775 // Characteristic Configuration descriptor.
776 // Windows: TODO(crbug.com/594697):
777 // BluetoothRemoteGattCharacteristicWin::StartNotifySession doesn't check the
778 // existence of client characteristic configuration descriptor.
767 TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_NoConfigDescriptor) { 779 TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_NoConfigDescriptor) {
768 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( 780 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
769 /* properties: NOTIFY */ 0x10, 781 /* properties: NOTIFY */ 0x10,
770 /* expected_config_descriptor_value: NOTIFY */ 1, 782 /* expected_config_descriptor_value: NOTIFY */ 1,
771 StartNotifySetupError::CONFIG_DESCRIPTOR_MISSING)); 783 StartNotifySetupError::CONFIG_DESCRIPTOR_MISSING));
772 784
773 EXPECT_EQ(0, gatt_notify_characteristic_attempts_); 785 EXPECT_EQ(0, gatt_notify_characteristic_attempts_);
774 786
775 // The expected error callback is asynchronous: 787 // The expected error callback is asynchronous:
776 EXPECT_EQ(0, error_callback_count_); 788 EXPECT_EQ(0, error_callback_count_);
777 base::RunLoop().RunUntilIdle(); 789 base::RunLoop().RunUntilIdle();
778 EXPECT_EQ(1, error_callback_count_); 790 EXPECT_EQ(1, error_callback_count_);
779 } 791 }
780 #endif // defined(OS_ANDROID) 792 #endif // defined(OS_ANDROID) || !defined(OS_WIN)
781 793
782 #if defined(OS_ANDROID) 794 #if defined(OS_ANDROID) || !defined(OS_WIN)
783 // StartNotifySession fails synchronously when failing to set a characteristic 795 // StartNotifySession fails synchronously when failing to set a characteristic
784 // to enable notifications. 796 // to enable notifications.
785 // Android: This is mBluetoothGatt.setCharacteristicNotification failing. 797 // Android: This is mBluetoothGatt.setCharacteristicNotification failing.
798 // Windows: Characteristic notification is set to OS asynchronously.
786 TEST_F(BluetoothGattCharacteristicTest, 799 TEST_F(BluetoothGattCharacteristicTest,
787 StartNotifySession_FailToSetCharacteristicNotification) { 800 StartNotifySession_FailToSetCharacteristicNotification) {
788 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( 801 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
789 /* properties: NOTIFY */ 0x10, 802 /* properties: NOTIFY */ 0x10,
790 /* expected_config_descriptor_value: NOTIFY */ 1, 803 /* expected_config_descriptor_value: NOTIFY */ 1,
791 StartNotifySetupError::SET_NOTIFY)); 804 StartNotifySetupError::SET_NOTIFY));
792 805
793 // The expected error callback is asynchronous: 806 // The expected error callback is asynchronous:
794 EXPECT_EQ(0, error_callback_count_); 807 EXPECT_EQ(0, error_callback_count_);
795 base::RunLoop().RunUntilIdle(); 808 base::RunLoop().RunUntilIdle();
796 EXPECT_EQ(1, error_callback_count_); 809 EXPECT_EQ(1, error_callback_count_);
797 810
798 EXPECT_EQ(0, gatt_notify_characteristic_attempts_); 811 EXPECT_EQ(0, gatt_notify_characteristic_attempts_);
799 ASSERT_EQ(0u, notify_sessions_.size()); 812 ASSERT_EQ(0u, notify_sessions_.size());
800 } 813 }
801 #endif // defined(OS_ANDROID) 814 #endif // defined(OS_ANDROID) || !defined(OS_WIN)
802 815
803 #if defined(OS_ANDROID) 816 #if defined(OS_ANDROID) || !defined(OS_WIN)
804 // Tests StartNotifySession descriptor write synchronous failure. 817 // Tests StartNotifySession descriptor write synchronous failure.
818 // Windows: No need to write CCCD explicitly to start notification.
805 TEST_F(BluetoothGattCharacteristicTest, 819 TEST_F(BluetoothGattCharacteristicTest,
806 StartNotifySession_WriteDescriptorSynchronousError) { 820 StartNotifySession_WriteDescriptorSynchronousError) {
807 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( 821 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
808 /* properties: NOTIFY */ 0x10, 822 /* properties: NOTIFY */ 0x10,
809 /* expected_config_descriptor_value: NOTIFY */ 1, 823 /* expected_config_descriptor_value: NOTIFY */ 1,
810 StartNotifySetupError::WRITE_DESCRIPTOR)); 824 StartNotifySetupError::WRITE_DESCRIPTOR));
811 825
812 // The expected error callback is asynchronous: 826 // The expected error callback is asynchronous:
813 EXPECT_EQ(0, error_callback_count_); 827 EXPECT_EQ(0, error_callback_count_);
814 base::RunLoop().RunUntilIdle(); 828 base::RunLoop().RunUntilIdle();
815 EXPECT_EQ(1, error_callback_count_); 829 EXPECT_EQ(1, error_callback_count_);
816 830
817 EXPECT_EQ(1, gatt_notify_characteristic_attempts_); 831 EXPECT_EQ(1, gatt_notify_characteristic_attempts_);
818 ASSERT_EQ(0u, notify_sessions_.size()); 832 ASSERT_EQ(0u, notify_sessions_.size());
819 } 833 }
820 #endif // defined(OS_ANDROID) 834 #endif // defined(OS_ANDROID) || !defined(OS_WIN)
821 835
822 #if defined(OS_ANDROID) 836 #if defined(OS_ANDROID) || defined(OS_WIN)
823 // Tests StartNotifySession success on a characteristic enabling Notify. 837 // Tests StartNotifySession success on a characteristic enabling Notify.
824 TEST_F(BluetoothGattCharacteristicTest, StartNotifySession) { 838 TEST_F(BluetoothGattCharacteristicTest, StartNotifySession) {
825 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( 839 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
826 /* properties: NOTIFY */ 0x10, 840 /* properties: NOTIFY */ 0x10,
827 /* expected_config_descriptor_value: NOTIFY */ 1)); 841 /* expected_config_descriptor_value: NOTIFY */ 1));
828 } 842 }
829 #endif // defined(OS_ANDROID) 843 #endif // defined(OS_ANDROID) || defined(OS_WIN)
830 844
831 #if defined(OS_ANDROID) 845 #if defined(OS_ANDROID) || defined(OS_WIN)
832 // Tests StartNotifySession success on a characteristic enabling Indicate. 846 // Tests StartNotifySession success on a characteristic enabling Indicate.
833 TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_OnIndicate) { 847 TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_OnIndicate) {
834 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( 848 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
835 /* properties: INDICATE */ 0x20, 849 /* properties: INDICATE */ 0x20,
836 /* expected_config_descriptor_value: INDICATE */ 2)); 850 /* expected_config_descriptor_value: INDICATE */ 2));
837 } 851 }
838 #endif // defined(OS_ANDROID) 852 #endif // defined(OS_ANDROID) || defined(OS_WIN)
839 853
840 #if defined(OS_ANDROID) 854 #if defined(OS_ANDROID) || defined(OS_WIN)
841 // Tests StartNotifySession success on a characteristic enabling Notify & 855 // Tests StartNotifySession success on a characteristic enabling Notify &
842 // Indicate. 856 // Indicate.
843 TEST_F(BluetoothGattCharacteristicTest, 857 TEST_F(BluetoothGattCharacteristicTest,
844 StartNotifySession_OnNotifyAndIndicate) { 858 StartNotifySession_OnNotifyAndIndicate) {
845 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( 859 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
846 /* properties: NOTIFY and INDICATE bits set */ 0x30, 860 /* properties: NOTIFY and INDICATE bits set */ 0x30,
847 /* expected_config_descriptor_value: NOTIFY */ 1)); 861 /* expected_config_descriptor_value: NOTIFY */ 1));
848 } 862 }
849 #endif // defined(OS_ANDROID) 863 #endif // defined(OS_ANDROID) || defined(OS_WIN)
850 864
851 #if defined(OS_ANDROID) 865 #if defined(OS_ANDROID) || defined(OS_WIN)
852 // Tests multiple StartNotifySession success. 866 // Tests multiple StartNotifySession success.
853 TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_Multiple) { 867 TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_Multiple) {
854 ASSERT_NO_FATAL_FAILURE( 868 ASSERT_NO_FATAL_FAILURE(
855 FakeCharacteristicBoilerplate(/* properties: NOTIFY */ 0x10)); 869 FakeCharacteristicBoilerplate(/* properties: NOTIFY */ 0x10));
856 SimulateGattDescriptor( 870 SimulateGattDescriptor(
857 characteristic1_, 871 characteristic1_,
858 /* Client Characteristic Configuration descriptor's standard UUID: */ 872 /* Client Characteristic Configuration descriptor's standard UUID: */
859 "00002902-0000-1000-8000-00805F9B34FB"); 873 "00002902-0000-1000-8000-00805F9B34FB");
860 ASSERT_EQ(1u, characteristic1_->GetDescriptors().size()); 874 ASSERT_EQ(1u, characteristic1_->GetDescriptors().size());
861 875
862 characteristic1_->StartNotifySession( 876 characteristic1_->StartNotifySession(
863 GetNotifyCallback(Call::EXPECTED), 877 GetNotifyCallback(Call::EXPECTED),
864 GetGattErrorCallback(Call::NOT_EXPECTED)); 878 GetGattErrorCallback(Call::NOT_EXPECTED));
865 characteristic1_->StartNotifySession( 879 characteristic1_->StartNotifySession(
866 GetNotifyCallback(Call::EXPECTED), 880 GetNotifyCallback(Call::EXPECTED),
867 GetGattErrorCallback(Call::NOT_EXPECTED)); 881 GetGattErrorCallback(Call::NOT_EXPECTED));
868 EXPECT_EQ(1, gatt_notify_characteristic_attempts_);
869 EXPECT_EQ(0, callback_count_); 882 EXPECT_EQ(0, callback_count_);
870 SimulateGattNotifySessionStarted(characteristic1_); 883 SimulateGattNotifySessionStarted(characteristic1_);
884 EXPECT_EQ(1, gatt_notify_characteristic_attempts_);
871 EXPECT_EQ(2, callback_count_); 885 EXPECT_EQ(2, callback_count_);
872 EXPECT_EQ(0, error_callback_count_); 886 EXPECT_EQ(0, error_callback_count_);
873 ASSERT_EQ(2u, notify_sessions_.size()); 887 ASSERT_EQ(2u, notify_sessions_.size());
874 ASSERT_TRUE(notify_sessions_[0]); 888 ASSERT_TRUE(notify_sessions_[0]);
875 ASSERT_TRUE(notify_sessions_[1]); 889 ASSERT_TRUE(notify_sessions_[1]);
876 EXPECT_EQ(characteristic1_->GetIdentifier(), 890 EXPECT_EQ(characteristic1_->GetIdentifier(),
877 notify_sessions_[0]->GetCharacteristicIdentifier()); 891 notify_sessions_[0]->GetCharacteristicIdentifier());
878 EXPECT_EQ(characteristic1_->GetIdentifier(), 892 EXPECT_EQ(characteristic1_->GetIdentifier(),
879 notify_sessions_[1]->GetCharacteristicIdentifier()); 893 notify_sessions_[1]->GetCharacteristicIdentifier());
880 EXPECT_TRUE(notify_sessions_[0]->IsActive()); 894 EXPECT_TRUE(notify_sessions_[0]->IsActive());
881 EXPECT_TRUE(notify_sessions_[1]->IsActive()); 895 EXPECT_TRUE(notify_sessions_[1]->IsActive());
882 } 896 }
883 #endif // defined(OS_ANDROID) 897 #endif // defined(OS_ANDROID) || defined(OS_WIN)
884 898
885 #if defined(OS_ANDROID) 899 #if defined(OS_ANDROID) || defined(OS_WIN)
886 // Tests Characteristic Value changes during a Notify Session. 900 // Tests Characteristic Value changes during a Notify Session.
887 TEST_F(BluetoothGattCharacteristicTest, GattCharacteristicValueChanged) { 901 TEST_F(BluetoothGattCharacteristicTest, GattCharacteristicValueChanged) {
888 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( 902 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
889 /* properties: NOTIFY */ 0x10, 903 /* properties: NOTIFY */ 0x10,
890 /* expected_config_descriptor_value: NOTIFY */ 1)); 904 /* expected_config_descriptor_value: NOTIFY */ 1));
891 905
892 TestBluetoothAdapterObserver observer(adapter_); 906 TestBluetoothAdapterObserver observer(adapter_);
893 907
894 std::vector<uint8_t> test_vector1, test_vector2; 908 std::vector<uint8_t> test_vector1, test_vector2;
895 test_vector1.push_back(111); 909 test_vector1.push_back(111);
896 test_vector2.push_back(222); 910 test_vector2.push_back(222);
897 911
898 SimulateGattCharacteristicChanged(characteristic1_, test_vector1); 912 SimulateGattCharacteristicChanged(characteristic1_, test_vector1);
899 EXPECT_EQ(1, observer.gatt_characteristic_value_changed_count()); 913 EXPECT_EQ(1, observer.gatt_characteristic_value_changed_count());
900 EXPECT_EQ(test_vector1, characteristic1_->GetValue()); 914 EXPECT_EQ(test_vector1, characteristic1_->GetValue());
901 915
902 SimulateGattCharacteristicChanged(characteristic1_, test_vector2); 916 SimulateGattCharacteristicChanged(characteristic1_, test_vector2);
903 EXPECT_EQ(2, observer.gatt_characteristic_value_changed_count()); 917 EXPECT_EQ(2, observer.gatt_characteristic_value_changed_count());
904 EXPECT_EQ(test_vector2, characteristic1_->GetValue()); 918 EXPECT_EQ(test_vector2, characteristic1_->GetValue());
905 } 919 }
906 #endif // defined(OS_ANDROID) 920 #endif // defined(OS_ANDROID) || defined(OS_WIN)
907 921
908 #if defined(OS_ANDROID) 922 #if defined(OS_ANDROID) || !defined(OS_WIN)
909 // Tests Characteristic Value changing after a Notify Session and objects being 923 // Tests Characteristic Value changing after a Notify Session and objects being
910 // destroyed. 924 // destroyed.
925 // Windows: Characteristic changed notification is not available after deleting
926 // the device because OS detects device deleting before corresponding objects
927 // being destroyed.
ortuno 2016/03/15 02:55:31 What happens when you enable this test on windows?
gogerald1 2016/03/15 18:28:22 SimulateGattCharacteristicChanged has no target af
scheib 2016/03/19 04:57:54 ortuno mentioned in person wanting to understand t
gogerald1 2016/03/21 14:22:22 Done.
ortuno 2016/03/21 17:00:52 Have you tried this locally? I just tried it and i
gogerald1 2016/03/21 22:09:16 Of course, and it passed trybots
ortuno 2016/03/22 15:02:24 After looking into it a bit more I think we need t
gogerald1 2016/03/29 15:12:00 Done. Rebase to fixed test
911 TEST_F(BluetoothGattCharacteristicTest, 928 TEST_F(BluetoothGattCharacteristicTest,
912 GattCharacteristicValueChanged_AfterDeleted) { 929 GattCharacteristicValueChanged_AfterDeleted) {
913 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( 930 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
914 /* properties: NOTIFY */ 0x10, 931 /* properties: NOTIFY */ 0x10,
915 /* expected_config_descriptor_value: NOTIFY */ 1)); 932 /* expected_config_descriptor_value: NOTIFY */ 1));
916 933
917 RememberCharacteristicForSubsequentAction(characteristic1_); 934 RememberCharacteristicForSubsequentAction(characteristic1_);
918 DeleteDevice(device_); 935 DeleteDevice(device_);
919 936
920 std::vector<uint8_t> empty_vector; 937 std::vector<uint8_t> empty_vector;
921 SimulateGattCharacteristicChanged(/* use remembered characteristic */ nullptr, 938 SimulateGattCharacteristicChanged(/* use remembered characteristic */ nullptr,
922 empty_vector); 939 empty_vector);
923 EXPECT_TRUE("Did not crash!"); 940 EXPECT_TRUE("Did not crash!");
924 } 941 }
925 #endif // defined(OS_ANDROID) 942 #endif // defined(OS_ANDROID) || !defined(OS_WIN)
926 943
ortuno 2016/03/15 02:55:31 You still need to write a reentrancy test: // Tes
gogerald1 2016/03/15 18:28:22 Do it in the next CL
927 #if defined(OS_ANDROID) || defined(OS_WIN) 944 #if defined(OS_ANDROID) || defined(OS_WIN)
928 TEST_F(BluetoothGattCharacteristicTest, GetDescriptors_FindNone) { 945 TEST_F(BluetoothGattCharacteristicTest, GetDescriptors_FindNone) {
929 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate()); 946 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate());
930 947
931 EXPECT_EQ(0u, characteristic1_->GetDescriptors().size()); 948 EXPECT_EQ(0u, characteristic1_->GetDescriptors().size());
932 } 949 }
933 #endif // defined(OS_ANDROID) || defined(OS_WIN) 950 #endif // defined(OS_ANDROID) || defined(OS_WIN)
934 951
935 #if defined(OS_ANDROID) || defined(OS_WIN) 952 #if defined(OS_ANDROID) || defined(OS_WIN)
936 TEST_F(BluetoothGattCharacteristicTest, GetDescriptors_and_GetDescriptor) { 953 TEST_F(BluetoothGattCharacteristicTest, GetDescriptors_and_GetDescriptor) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 988
972 // Characteristic 1 has descriptor uuids 1 and 2 (we don't know the order). 989 // Characteristic 1 has descriptor uuids 1 and 2 (we don't know the order).
973 EXPECT_TRUE(c1_uuid1 == uuid1 || c1_uuid2 == uuid1); 990 EXPECT_TRUE(c1_uuid1 == uuid1 || c1_uuid2 == uuid1);
974 EXPECT_TRUE(c1_uuid1 == uuid2 || c1_uuid2 == uuid2); 991 EXPECT_TRUE(c1_uuid1 == uuid2 || c1_uuid2 == uuid2);
975 // ... but not uuid 3 992 // ... but not uuid 3
976 EXPECT_FALSE(c1_uuid1 == uuid3 || c1_uuid2 == uuid3); 993 EXPECT_FALSE(c1_uuid1 == uuid3 || c1_uuid2 == uuid3);
977 } 994 }
978 #endif // defined(OS_ANDROID) || defined(OS_WIN) 995 #endif // defined(OS_ANDROID) || defined(OS_WIN)
979 996
980 } // namespace device 997 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698