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

Side by Side Diff: extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_apitest.cc

Issue 593163002: Short-circuit failures in BLE js tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Testing new cls Created 6 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 | « chrome/test/data/extensions/api_test/bluetooth_low_energy/write_descriptor_value/runtest.js ('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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "chrome/browser/extensions/extension_apitest.h" 6 #include "chrome/browser/extensions/extension_apitest.h"
7 #include "device/bluetooth/test/mock_bluetooth_adapter.h" 7 #include "device/bluetooth/test/mock_bluetooth_adapter.h"
8 #include "device/bluetooth/test/mock_bluetooth_device.h" 8 #include "device/bluetooth/test/mock_bluetooth_device.h"
9 #include "device/bluetooth/test/mock_bluetooth_gatt_characteristic.h" 9 #include "device/bluetooth/test/mock_bluetooth_gatt_characteristic.h"
10 #include "device/bluetooth/test/mock_bluetooth_gatt_connection.h" 10 #include "device/bluetooth/test/mock_bluetooth_gatt_connection.h"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 .Times(3) 270 .Times(3)
271 .WillOnce(Return(static_cast<BluetoothDevice*>(NULL))) 271 .WillOnce(Return(static_cast<BluetoothDevice*>(NULL)))
272 .WillRepeatedly(Return(device0_.get())); 272 .WillRepeatedly(Return(device0_.get()));
273 273
274 EXPECT_CALL(*device0_, GetGattServices()) 274 EXPECT_CALL(*device0_, GetGattServices())
275 .Times(2) 275 .Times(2)
276 .WillOnce(Return(std::vector<BluetoothGattService*>())) 276 .WillOnce(Return(std::vector<BluetoothGattService*>()))
277 .WillOnce(Return(services)); 277 .WillOnce(Return(services));
278 278
279 // Load and wait for setup. 279 // Load and wait for setup.
280 ExtensionTestMessageListener listener("ready", true); 280 ExtensionTestMessageListener listener(true);
281 ASSERT_TRUE(LoadExtension( 281 ASSERT_TRUE(LoadExtension(
282 test_data_dir_.AppendASCII("bluetooth_low_energy/get_services"))); 282 test_data_dir_.AppendASCII("bluetooth_low_energy/get_services")));
283 EXPECT_TRUE(listener.WaitUntilSatisfied()); 283 EXPECT_TRUE(listener.WaitUntilSatisfied());
284 ASSERT_EQ("ready", listener.message()) << listener.message();
armansito 2014/09/23 20:05:56 Instead of doing this, you can give an ExtensionTe
284 285
285 listener.Reply("go"); 286 listener.Reply("go");
286 287
287 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 288 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
288 } 289 }
289 290
290 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetService) { 291 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetService) {
291 ResultCatcher catcher; 292 ResultCatcher catcher;
292 catcher.RestrictToBrowserContext(browser()->profile()); 293 catcher.RestrictToBrowserContext(browser()->profile());
293 294
294 event_router()->GattServiceAdded( 295 event_router()->GattServiceAdded(
295 mock_adapter_, device0_.get(), service0_.get()); 296 mock_adapter_, device0_.get(), service0_.get());
296 297
297 EXPECT_CALL(*mock_adapter_, GetDevice(_)) 298 EXPECT_CALL(*mock_adapter_, GetDevice(_))
298 .Times(3) 299 .Times(3)
299 .WillOnce(Return(static_cast<BluetoothDevice*>(NULL))) 300 .WillOnce(Return(static_cast<BluetoothDevice*>(NULL)))
300 .WillRepeatedly(Return(device0_.get())); 301 .WillRepeatedly(Return(device0_.get()));
301 302
302 EXPECT_CALL(*device0_, GetGattService(kTestServiceId0)) 303 EXPECT_CALL(*device0_, GetGattService(kTestServiceId0))
303 .Times(2) 304 .Times(2)
304 .WillOnce(Return(static_cast<BluetoothGattService*>(NULL))) 305 .WillOnce(Return(static_cast<BluetoothGattService*>(NULL)))
305 .WillOnce(Return(service0_.get())); 306 .WillOnce(Return(service0_.get()));
306 307
307 // Load and wait for setup. 308 // Load and wait for setup.
308 ExtensionTestMessageListener listener("ready", true); 309 ExtensionTestMessageListener listener(true);
309 ASSERT_TRUE(LoadExtension( 310 ASSERT_TRUE(LoadExtension(
310 test_data_dir_.AppendASCII("bluetooth_low_energy/get_service"))); 311 test_data_dir_.AppendASCII("bluetooth_low_energy/get_service")));
311 EXPECT_TRUE(listener.WaitUntilSatisfied()); 312 EXPECT_TRUE(listener.WaitUntilSatisfied());
313 ASSERT_EQ("ready", listener.message()) << listener.message();
312 314
313 listener.Reply("go"); 315 listener.Reply("go");
314 316
315 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 317 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
316 318
317 event_router()->GattServiceRemoved( 319 event_router()->GattServiceRemoved(
318 mock_adapter_, device0_.get(), service0_.get()); 320 mock_adapter_, device0_.get(), service0_.get());
319 } 321 }
320 322
321 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, ServiceEvents) { 323 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, ServiceEvents) {
322 ResultCatcher catcher; 324 ResultCatcher catcher;
323 catcher.RestrictToBrowserContext(browser()->profile()); 325 catcher.RestrictToBrowserContext(browser()->profile());
324 326
325 // Load the extension and let it set up. 327 // Load the extension and let it set up.
326 ExtensionTestMessageListener listener("ready", true); 328 ExtensionTestMessageListener listener(true);
327 ASSERT_TRUE(LoadExtension( 329 ASSERT_TRUE(LoadExtension(
328 test_data_dir_.AppendASCII("bluetooth_low_energy/service_events"))); 330 test_data_dir_.AppendASCII("bluetooth_low_energy/service_events")));
329 331
330 // These will create the identifier mappings. 332 // These will create the identifier mappings.
331 event_router()->GattServiceAdded( 333 event_router()->GattServiceAdded(
332 mock_adapter_, device0_.get(), service0_.get()); 334 mock_adapter_, device0_.get(), service0_.get());
333 event_router()->GattServiceAdded( 335 event_router()->GattServiceAdded(
334 mock_adapter_, device0_.get(), service1_.get()); 336 mock_adapter_, device0_.get(), service1_.get());
335 337
336 // These will send the onServiceAdded event to apps. 338 // These will send the onServiceAdded event to apps.
337 event_router()->GattDiscoveryCompleteForService(mock_adapter_, 339 event_router()->GattDiscoveryCompleteForService(mock_adapter_,
338 service0_.get()); 340 service0_.get());
339 event_router()->GattDiscoveryCompleteForService(mock_adapter_, 341 event_router()->GattDiscoveryCompleteForService(mock_adapter_,
340 service1_.get()); 342 service1_.get());
341 343
342 // This will send the onServiceChanged event to apps. 344 // This will send the onServiceChanged event to apps.
343 event_router()->GattServiceChanged(mock_adapter_, service1_.get()); 345 event_router()->GattServiceChanged(mock_adapter_, service1_.get());
344 346
345 // This will send the onServiceRemoved event to apps. 347 // This will send the onServiceRemoved event to apps.
346 event_router()->GattServiceRemoved( 348 event_router()->GattServiceRemoved(
347 mock_adapter_, device0_.get(), service0_.get()); 349 mock_adapter_, device0_.get(), service0_.get());
348 350
349 EXPECT_TRUE(listener.WaitUntilSatisfied()); 351 EXPECT_TRUE(listener.WaitUntilSatisfied());
352 ASSERT_EQ("ready", listener.message()) << listener.message();
350 listener.Reply("go"); 353 listener.Reply("go");
351 354
352 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 355 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
353 event_router()->GattServiceRemoved( 356 event_router()->GattServiceRemoved(
354 mock_adapter_, device0_.get(), service1_.get()); 357 mock_adapter_, device0_.get(), service1_.get());
355 } 358 }
356 359
357 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetRemovedService) { 360 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetRemovedService) {
358 ResultCatcher catcher; 361 ResultCatcher catcher;
359 catcher.RestrictToBrowserContext(browser()->profile()); 362 catcher.RestrictToBrowserContext(browser()->profile());
360 363
361 // Load the extension and let it set up. 364 // Load the extension and let it set up.
362 ASSERT_TRUE(LoadExtension( 365 ASSERT_TRUE(LoadExtension(
363 test_data_dir_.AppendASCII("bluetooth_low_energy/get_removed_service"))); 366 test_data_dir_.AppendASCII("bluetooth_low_energy/get_removed_service")));
364 367
365 // 1. getService success. 368 // 1. getService success.
366 EXPECT_CALL(*mock_adapter_, GetDevice(_)) 369 EXPECT_CALL(*mock_adapter_, GetDevice(_))
367 .Times(1) 370 .Times(1)
368 .WillOnce(Return(device0_.get())); 371 .WillOnce(Return(device0_.get()));
369 EXPECT_CALL(*device0_, GetGattService(kTestServiceId0)) 372 EXPECT_CALL(*device0_, GetGattService(kTestServiceId0))
370 .Times(1) 373 .Times(1)
371 .WillOnce(Return(service0_.get())); 374 .WillOnce(Return(service0_.get()));
372 375
373 event_router()->GattServiceAdded( 376 event_router()->GattServiceAdded(
374 mock_adapter_, device0_.get(), service0_.get()); 377 mock_adapter_, device0_.get(), service0_.get());
375 event_router()->GattDiscoveryCompleteForService(mock_adapter_, 378 event_router()->GattDiscoveryCompleteForService(mock_adapter_,
376 service0_.get()); 379 service0_.get());
377 380
378 ExtensionTestMessageListener get_service_success_listener("getServiceSuccess", 381 ExtensionTestMessageListener get_service_success_listener(true);
379 true);
380 EXPECT_TRUE(get_service_success_listener.WaitUntilSatisfied()); 382 EXPECT_TRUE(get_service_success_listener.WaitUntilSatisfied());
383 ASSERT_EQ("getServiceSuccess", get_service_success_listener.message())
384 << get_service_success_listener.message();
381 testing::Mock::VerifyAndClearExpectations(mock_adapter_); 385 testing::Mock::VerifyAndClearExpectations(mock_adapter_);
382 testing::Mock::VerifyAndClearExpectations(device0_.get()); 386 testing::Mock::VerifyAndClearExpectations(device0_.get());
383 387
384 // 2. getService fail. 388 // 2. getService fail.
385 EXPECT_CALL(*mock_adapter_, GetDevice(_)).Times(0); 389 EXPECT_CALL(*mock_adapter_, GetDevice(_)).Times(0);
386 EXPECT_CALL(*device0_, GetGattService(kTestServiceId0)).Times(0); 390 EXPECT_CALL(*device0_, GetGattService(kTestServiceId0)).Times(0);
387 391
388 event_router()->GattServiceRemoved( 392 event_router()->GattServiceRemoved(
389 mock_adapter_, device0_.get(), service0_.get()); 393 mock_adapter_, device0_.get(), service0_.get());
390 394
391 ExtensionTestMessageListener get_service_fail_listener("getServiceFail", 395 ExtensionTestMessageListener get_service_fail_listener(true);
392 true);
393 EXPECT_TRUE(get_service_fail_listener.WaitUntilSatisfied()); 396 EXPECT_TRUE(get_service_fail_listener.WaitUntilSatisfied());
397 ASSERT_EQ("getServiceFail", get_service_fail_listener.message())
398 << get_service_fail_listener.message();
394 testing::Mock::VerifyAndClearExpectations(mock_adapter_); 399 testing::Mock::VerifyAndClearExpectations(mock_adapter_);
395 testing::Mock::VerifyAndClearExpectations(device0_.get()); 400 testing::Mock::VerifyAndClearExpectations(device0_.get());
396 401
397 get_service_fail_listener.Reply("go"); 402 get_service_fail_listener.Reply("go");
398 403
399 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 404 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
400 } 405 }
401 406
402 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetIncludedServices) { 407 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetIncludedServices) {
403 ResultCatcher catcher; 408 ResultCatcher catcher;
404 catcher.RestrictToBrowserContext(browser()->profile()); 409 catcher.RestrictToBrowserContext(browser()->profile());
405 410
406 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( 411 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
407 "bluetooth_low_energy/get_included_services"))); 412 "bluetooth_low_energy/get_included_services")));
408 413
409 // Wait for initial call to end with failure as there is no mapping. 414 // Wait for initial call to end with failure as there is no mapping.
410 ExtensionTestMessageListener listener("ready", true); 415 ExtensionTestMessageListener listener(true);
411 EXPECT_TRUE(listener.WaitUntilSatisfied()); 416 EXPECT_TRUE(listener.WaitUntilSatisfied());
417 ASSERT_EQ("ready", listener.message()) << listener.message();
412 418
413 // Set up for the rest of the calls before replying. Included services can be 419 // Set up for the rest of the calls before replying. Included services can be
414 // returned even if there is no instance ID mapping for them yet, so no need 420 // returned even if there is no instance ID mapping for them yet, so no need
415 // to call GattServiceAdded for |service1_| here. 421 // to call GattServiceAdded for |service1_| here.
416 event_router()->GattServiceAdded( 422 event_router()->GattServiceAdded(
417 mock_adapter_, device0_.get(), service0_.get()); 423 mock_adapter_, device0_.get(), service0_.get());
418 424
419 std::vector<BluetoothGattService*> includes; 425 std::vector<BluetoothGattService*> includes;
420 includes.push_back(service1_.get()); 426 includes.push_back(service1_.get());
421 EXPECT_CALL(*mock_adapter_, GetDevice(kTestLeDeviceAddress0)) 427 EXPECT_CALL(*mock_adapter_, GetDevice(kTestLeDeviceAddress0))
422 .Times(2) 428 .Times(2)
423 .WillRepeatedly(Return(device0_.get())); 429 .WillRepeatedly(Return(device0_.get()));
424 EXPECT_CALL(*device0_, GetGattService(kTestServiceId0)) 430 EXPECT_CALL(*device0_, GetGattService(kTestServiceId0))
425 .Times(2) 431 .Times(2)
426 .WillRepeatedly(Return(service0_.get())); 432 .WillRepeatedly(Return(service0_.get()));
427 EXPECT_CALL(*service0_, GetIncludedServices()) 433 EXPECT_CALL(*service0_, GetIncludedServices())
428 .Times(2) 434 .Times(2)
429 .WillOnce(Return(std::vector<BluetoothGattService*>())) 435 .WillOnce(Return(std::vector<BluetoothGattService*>()))
430 .WillOnce(Return(includes)); 436 .WillOnce(Return(includes));
431 437
432 listener.Reply("go"); 438 listener.Reply("go");
433 listener.Reset(); 439 listener.Reset();
434 440
435 EXPECT_TRUE(listener.WaitUntilSatisfied()); 441 EXPECT_TRUE(listener.WaitUntilSatisfied());
442 ASSERT_EQ("ready", listener.message()) << listener.message();
436 443
437 listener.Reply("go"); 444 listener.Reply("go");
438 445
439 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 446 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
440 event_router()->GattServiceRemoved( 447 event_router()->GattServiceRemoved(
441 mock_adapter_, device0_.get(), service0_.get()); 448 mock_adapter_, device0_.get(), service0_.get());
442 } 449 }
443 450
444 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetCharacteristics) { 451 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetCharacteristics) {
445 ResultCatcher catcher; 452 ResultCatcher catcher;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 .Times(3) 499 .Times(3)
493 .WillOnce(Return(static_cast<BluetoothGattService*>(NULL))) 500 .WillOnce(Return(static_cast<BluetoothGattService*>(NULL)))
494 .WillRepeatedly(Return(service0_.get())); 501 .WillRepeatedly(Return(service0_.get()));
495 502
496 EXPECT_CALL(*service0_, GetCharacteristic(kTestCharacteristicId0)) 503 EXPECT_CALL(*service0_, GetCharacteristic(kTestCharacteristicId0))
497 .Times(2) 504 .Times(2)
498 .WillOnce(Return(static_cast<BluetoothGattCharacteristic*>(NULL))) 505 .WillOnce(Return(static_cast<BluetoothGattCharacteristic*>(NULL)))
499 .WillOnce(Return(chrc0_.get())); 506 .WillOnce(Return(chrc0_.get()));
500 507
501 // Load the extension and wait for first test. 508 // Load the extension and wait for first test.
502 ExtensionTestMessageListener listener("ready", true); 509 ExtensionTestMessageListener listener(true);
503 ASSERT_TRUE(LoadExtension( 510 ASSERT_TRUE(LoadExtension(
504 test_data_dir_.AppendASCII("bluetooth_low_energy/get_characteristic"))); 511 test_data_dir_.AppendASCII("bluetooth_low_energy/get_characteristic")));
505 EXPECT_TRUE(listener.WaitUntilSatisfied()); 512 EXPECT_TRUE(listener.WaitUntilSatisfied());
513 ASSERT_EQ("ready", listener.message()) << listener.message();
506 514
507 listener.Reply("go"); 515 listener.Reply("go");
508 516
509 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 517 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
510 518
511 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get()); 519 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get());
512 event_router()->GattServiceRemoved( 520 event_router()->GattServiceRemoved(
513 mock_adapter_, device0_.get(), service0_.get()); 521 mock_adapter_, device0_.get(), service0_.get());
514 } 522 }
515 523
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 BluetoothGattCharacteristic::kPropertyIndicate | 564 BluetoothGattCharacteristic::kPropertyIndicate |
557 BluetoothGattCharacteristic::kPropertyAuthenticatedSignedWrites | 565 BluetoothGattCharacteristic::kPropertyAuthenticatedSignedWrites |
558 BluetoothGattCharacteristic::kPropertyExtendedProperties | 566 BluetoothGattCharacteristic::kPropertyExtendedProperties |
559 BluetoothGattCharacteristic::kPropertyReliableWrite | 567 BluetoothGattCharacteristic::kPropertyReliableWrite |
560 BluetoothGattCharacteristic::kPropertyWritableAuxiliaries)); 568 BluetoothGattCharacteristic::kPropertyWritableAuxiliaries));
561 569
562 ExtensionTestMessageListener listener("ready", true); 570 ExtensionTestMessageListener listener("ready", true);
563 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( 571 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
564 "bluetooth_low_energy/characteristic_properties"))); 572 "bluetooth_low_energy/characteristic_properties")));
565 EXPECT_TRUE(listener.WaitUntilSatisfied()); 573 EXPECT_TRUE(listener.WaitUntilSatisfied());
574 ASSERT_EQ("ready", listener.message()) << listener.message();
566 575
567 listener.Reply("go"); 576 listener.Reply("go");
568 577
569 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 578 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
570 579
571 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get()); 580 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get());
572 event_router()->GattServiceRemoved( 581 event_router()->GattServiceRemoved(
573 mock_adapter_, device0_.get(), service0_.get()); 582 mock_adapter_, device0_.get(), service0_.get());
574 } 583 }
575 584
(...skipping 11 matching lines...) Expand all
587 .Times(1) 596 .Times(1)
588 .WillOnce(Return(chrc0_.get())); 597 .WillOnce(Return(chrc0_.get()));
589 598
590 event_router()->GattServiceAdded( 599 event_router()->GattServiceAdded(
591 mock_adapter_, device0_.get(), service0_.get()); 600 mock_adapter_, device0_.get(), service0_.get());
592 event_router()->GattCharacteristicAdded(mock_adapter_, chrc0_.get()); 601 event_router()->GattCharacteristicAdded(mock_adapter_, chrc0_.get());
593 602
594 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( 603 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
595 "bluetooth_low_energy/get_removed_characteristic"))); 604 "bluetooth_low_energy/get_removed_characteristic")));
596 605
597 ExtensionTestMessageListener listener("ready", true); 606 ExtensionTestMessageListener listener(true);
598 EXPECT_TRUE(listener.WaitUntilSatisfied()); 607 EXPECT_TRUE(listener.WaitUntilSatisfied());
608 ASSERT_EQ("ready", listener.message()) << listener.message();
599 testing::Mock::VerifyAndClearExpectations(mock_adapter_); 609 testing::Mock::VerifyAndClearExpectations(mock_adapter_);
600 testing::Mock::VerifyAndClearExpectations(device0_.get()); 610 testing::Mock::VerifyAndClearExpectations(device0_.get());
601 testing::Mock::VerifyAndClearExpectations(service0_.get()); 611 testing::Mock::VerifyAndClearExpectations(service0_.get());
602 612
603 EXPECT_CALL(*mock_adapter_, GetDevice(_)).Times(0); 613 EXPECT_CALL(*mock_adapter_, GetDevice(_)).Times(0);
604 EXPECT_CALL(*device0_, GetGattService(_)).Times(0); 614 EXPECT_CALL(*device0_, GetGattService(_)).Times(0);
605 EXPECT_CALL(*service0_, GetCharacteristic(_)).Times(0); 615 EXPECT_CALL(*service0_, GetCharacteristic(_)).Times(0);
606 616
607 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get()); 617 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get());
608 618
609 listener.Reply("go"); 619 listener.Reply("go");
610 listener.Reset(); 620 listener.Reset();
611 EXPECT_TRUE(listener.WaitUntilSatisfied()); 621 EXPECT_TRUE(listener.WaitUntilSatisfied());
622 ASSERT_EQ("ready", listener.message()) << listener.message();
612 623
613 listener.Reply("go"); 624 listener.Reply("go");
614 625
615 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 626 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
616 event_router()->GattServiceRemoved( 627 event_router()->GattServiceRemoved(
617 mock_adapter_, device0_.get(), service0_.get()); 628 mock_adapter_, device0_.get(), service0_.get());
618 } 629 }
619 630
620 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, CharacteristicValueChanged) { 631 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, CharacteristicValueChanged) {
621 ResultCatcher catcher; 632 ResultCatcher catcher;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 EXPECT_CALL(*service0_, GetCharacteristic(kTestCharacteristicId0)) 716 EXPECT_CALL(*service0_, GetCharacteristic(kTestCharacteristicId0))
706 .Times(3) 717 .Times(3)
707 .WillRepeatedly(Return(chrc0_.get())); 718 .WillRepeatedly(Return(chrc0_.get()));
708 719
709 std::vector<uint8> value; 720 std::vector<uint8> value;
710 EXPECT_CALL(*chrc0_, ReadRemoteCharacteristic(_, _)) 721 EXPECT_CALL(*chrc0_, ReadRemoteCharacteristic(_, _))
711 .Times(2) 722 .Times(2)
712 .WillOnce(InvokeCallbackArgument<1>()) 723 .WillOnce(InvokeCallbackArgument<1>())
713 .WillOnce(InvokeCallbackArgument<0>(value)); 724 .WillOnce(InvokeCallbackArgument<0>(value));
714 725
715 ExtensionTestMessageListener listener("ready", true); 726 ExtensionTestMessageListener listener(true);
716 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( 727 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
717 "bluetooth_low_energy/read_characteristic_value"))); 728 "bluetooth_low_energy/read_characteristic_value")));
718 EXPECT_TRUE(listener.WaitUntilSatisfied()); 729 listener.WaitUntilSatisfied();
730 ASSERT_EQ("ready", listener.message()) << listener.message();
719 731
720 listener.Reply("go"); 732 listener.Reply("go");
721 733
722 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 734 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
723 735
724 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get()); 736 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get());
725 event_router()->GattServiceRemoved( 737 event_router()->GattServiceRemoved(
726 mock_adapter_, device0_.get(), service0_.get()); 738 mock_adapter_, device0_.get(), service0_.get());
727 } 739 }
728 740
(...skipping 18 matching lines...) Expand all
747 .WillRepeatedly(Return(chrc0_.get())); 759 .WillRepeatedly(Return(chrc0_.get()));
748 760
749 std::vector<uint8> write_value; 761 std::vector<uint8> write_value;
750 EXPECT_CALL(*chrc0_, WriteRemoteCharacteristic(_, _, _)) 762 EXPECT_CALL(*chrc0_, WriteRemoteCharacteristic(_, _, _))
751 .Times(2) 763 .Times(2)
752 .WillOnce(InvokeCallbackArgument<2>()) 764 .WillOnce(InvokeCallbackArgument<2>())
753 .WillOnce(DoAll(SaveArg<0>(&write_value), InvokeCallbackArgument<1>())); 765 .WillOnce(DoAll(SaveArg<0>(&write_value), InvokeCallbackArgument<1>()));
754 766
755 EXPECT_CALL(*chrc0_, GetValue()).Times(1).WillOnce(ReturnRef(write_value)); 767 EXPECT_CALL(*chrc0_, GetValue()).Times(1).WillOnce(ReturnRef(write_value));
756 768
757 ExtensionTestMessageListener listener("ready", true); 769 ExtensionTestMessageListener listener(true);
758 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( 770 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
759 "bluetooth_low_energy/write_characteristic_value"))); 771 "bluetooth_low_energy/write_characteristic_value")));
760 EXPECT_TRUE(listener.WaitUntilSatisfied()); 772 EXPECT_TRUE(listener.WaitUntilSatisfied());
773 ASSERT_EQ("ready", listener.message()) << listener.message();
761 774
762 listener.Reply("go"); 775 listener.Reply("go");
763 776
764 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 777 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
765 778
766 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get()); 779 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get());
767 event_router()->GattServiceRemoved( 780 event_router()->GattServiceRemoved(
768 mock_adapter_, device0_.get(), service0_.get()); 781 mock_adapter_, device0_.get(), service0_.get());
769 } 782 }
770 783
(...skipping 17 matching lines...) Expand all
788 .WillRepeatedly(Return(service0_.get())); 801 .WillRepeatedly(Return(service0_.get()));
789 EXPECT_CALL(*service0_, GetCharacteristic(kTestCharacteristicId0)) 802 EXPECT_CALL(*service0_, GetCharacteristic(kTestCharacteristicId0))
790 .Times(3) 803 .Times(3)
791 .WillOnce(Return(static_cast<BluetoothGattCharacteristic*>(NULL))) 804 .WillOnce(Return(static_cast<BluetoothGattCharacteristic*>(NULL)))
792 .WillRepeatedly(Return(chrc0_.get())); 805 .WillRepeatedly(Return(chrc0_.get()));
793 EXPECT_CALL(*chrc0_, GetDescriptors()) 806 EXPECT_CALL(*chrc0_, GetDescriptors())
794 .Times(2) 807 .Times(2)
795 .WillOnce(Return(std::vector<BluetoothGattDescriptor*>())) 808 .WillOnce(Return(std::vector<BluetoothGattDescriptor*>()))
796 .WillOnce(Return(descriptors)); 809 .WillOnce(Return(descriptors));
797 810
798 ExtensionTestMessageListener listener("ready", true); 811 ExtensionTestMessageListener listener(true);
799 ASSERT_TRUE(LoadExtension( 812 ASSERT_TRUE(LoadExtension(
800 test_data_dir_.AppendASCII("bluetooth_low_energy/get_descriptors"))); 813 test_data_dir_.AppendASCII("bluetooth_low_energy/get_descriptors")));
801 EXPECT_TRUE(listener.WaitUntilSatisfied()); 814 EXPECT_TRUE(listener.WaitUntilSatisfied());
815 ASSERT_EQ("ready", listener.message()) << listener.message();
802 816
803 listener.Reply("go"); 817 listener.Reply("go");
804 818
805 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 819 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
806 820
807 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get()); 821 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get());
808 event_router()->GattServiceRemoved( 822 event_router()->GattServiceRemoved(
809 mock_adapter_, device0_.get(), service0_.get()); 823 mock_adapter_, device0_.get(), service0_.get());
810 } 824 }
811 825
(...skipping 20 matching lines...) Expand all
832 .Times(3) 846 .Times(3)
833 .WillOnce(Return(static_cast<BluetoothGattCharacteristic*>(NULL))) 847 .WillOnce(Return(static_cast<BluetoothGattCharacteristic*>(NULL)))
834 .WillRepeatedly(Return(chrc0_.get())); 848 .WillRepeatedly(Return(chrc0_.get()));
835 849
836 EXPECT_CALL(*chrc0_, GetDescriptor(kTestDescriptorId0)) 850 EXPECT_CALL(*chrc0_, GetDescriptor(kTestDescriptorId0))
837 .Times(2) 851 .Times(2)
838 .WillOnce(Return(static_cast<BluetoothGattDescriptor*>(NULL))) 852 .WillOnce(Return(static_cast<BluetoothGattDescriptor*>(NULL)))
839 .WillOnce(Return(desc0_.get())); 853 .WillOnce(Return(desc0_.get()));
840 854
841 // Load the extension and wait for first test. 855 // Load the extension and wait for first test.
842 ExtensionTestMessageListener listener("ready", true); 856 ExtensionTestMessageListener listener(true);
843 ASSERT_TRUE(LoadExtension( 857 ASSERT_TRUE(LoadExtension(
844 test_data_dir_.AppendASCII("bluetooth_low_energy/get_descriptor"))); 858 test_data_dir_.AppendASCII("bluetooth_low_energy/get_descriptor")));
845 EXPECT_TRUE(listener.WaitUntilSatisfied()); 859 EXPECT_TRUE(listener.WaitUntilSatisfied());
860 ASSERT_EQ("ready", listener.message()) << listener.message();
846 861
847 listener.Reply("go"); 862 listener.Reply("go");
848 863
849 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 864 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
850 865
851 event_router()->GattDescriptorRemoved(mock_adapter_, desc0_.get()); 866 event_router()->GattDescriptorRemoved(mock_adapter_, desc0_.get());
852 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get()); 867 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get());
853 event_router()->GattServiceRemoved( 868 event_router()->GattServiceRemoved(
854 mock_adapter_, device0_.get(), service0_.get()); 869 mock_adapter_, device0_.get(), service0_.get());
855 } 870 }
(...skipping 16 matching lines...) Expand all
872 .WillOnce(Return(desc0_.get())); 887 .WillOnce(Return(desc0_.get()));
873 888
874 event_router()->GattServiceAdded( 889 event_router()->GattServiceAdded(
875 mock_adapter_, device0_.get(), service0_.get()); 890 mock_adapter_, device0_.get(), service0_.get());
876 event_router()->GattCharacteristicAdded(mock_adapter_, chrc0_.get()); 891 event_router()->GattCharacteristicAdded(mock_adapter_, chrc0_.get());
877 event_router()->GattDescriptorAdded(mock_adapter_, desc0_.get()); 892 event_router()->GattDescriptorAdded(mock_adapter_, desc0_.get());
878 893
879 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( 894 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
880 "bluetooth_low_energy/get_removed_descriptor"))); 895 "bluetooth_low_energy/get_removed_descriptor")));
881 896
882 ExtensionTestMessageListener listener("ready", true); 897 ExtensionTestMessageListener listener(true);
883 EXPECT_TRUE(listener.WaitUntilSatisfied()); 898 EXPECT_TRUE(listener.WaitUntilSatisfied());
899 ASSERT_EQ("ready", listener.message()) << listener.message();
884 testing::Mock::VerifyAndClearExpectations(mock_adapter_); 900 testing::Mock::VerifyAndClearExpectations(mock_adapter_);
885 testing::Mock::VerifyAndClearExpectations(device0_.get()); 901 testing::Mock::VerifyAndClearExpectations(device0_.get());
886 testing::Mock::VerifyAndClearExpectations(service0_.get()); 902 testing::Mock::VerifyAndClearExpectations(service0_.get());
887 testing::Mock::VerifyAndClearExpectations(chrc0_.get()); 903 testing::Mock::VerifyAndClearExpectations(chrc0_.get());
888 904
889 EXPECT_CALL(*mock_adapter_, GetDevice(_)).Times(0); 905 EXPECT_CALL(*mock_adapter_, GetDevice(_)).Times(0);
890 EXPECT_CALL(*device0_, GetGattService(_)).Times(0); 906 EXPECT_CALL(*device0_, GetGattService(_)).Times(0);
891 EXPECT_CALL(*service0_, GetCharacteristic(_)).Times(0); 907 EXPECT_CALL(*service0_, GetCharacteristic(_)).Times(0);
892 EXPECT_CALL(*chrc0_, GetDescriptor(_)).Times(0); 908 EXPECT_CALL(*chrc0_, GetDescriptor(_)).Times(0);
893 909
894 event_router()->GattDescriptorRemoved(mock_adapter_, desc0_.get()); 910 event_router()->GattDescriptorRemoved(mock_adapter_, desc0_.get());
895 911
896 listener.Reply("go"); 912 listener.Reply("go");
897 listener.Reset(); 913 listener.Reset();
898 EXPECT_TRUE(listener.WaitUntilSatisfied()); 914 EXPECT_TRUE(listener.WaitUntilSatisfied());
915 ASSERT_EQ("ready", listener.message()) << listener.message();
899 916
900 listener.Reply("go"); 917 listener.Reply("go");
901 918
902 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 919 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
903 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get()); 920 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get());
904 event_router()->GattServiceRemoved( 921 event_router()->GattServiceRemoved(
905 mock_adapter_, device0_.get(), service0_.get()); 922 mock_adapter_, device0_.get(), service0_.get());
906 } 923 }
907 924
908 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, DescriptorValueChanged) { 925 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, DescriptorValueChanged) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 EXPECT_CALL(*chrc0_, GetDescriptor(kTestDescriptorId0)) 979 EXPECT_CALL(*chrc0_, GetDescriptor(kTestDescriptorId0))
963 .Times(3) 980 .Times(3)
964 .WillRepeatedly(Return(desc0_.get())); 981 .WillRepeatedly(Return(desc0_.get()));
965 982
966 std::vector<uint8> value; 983 std::vector<uint8> value;
967 EXPECT_CALL(*desc0_, ReadRemoteDescriptor(_, _)) 984 EXPECT_CALL(*desc0_, ReadRemoteDescriptor(_, _))
968 .Times(2) 985 .Times(2)
969 .WillOnce(InvokeCallbackArgument<1>()) 986 .WillOnce(InvokeCallbackArgument<1>())
970 .WillOnce(InvokeCallbackArgument<0>(value)); 987 .WillOnce(InvokeCallbackArgument<0>(value));
971 988
972 ExtensionTestMessageListener listener("ready", true); 989 ExtensionTestMessageListener listener(true);
973 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( 990 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
974 "bluetooth_low_energy/read_descriptor_value"))); 991 "bluetooth_low_energy/read_descriptor_value")));
975 EXPECT_TRUE(listener.WaitUntilSatisfied()); 992 EXPECT_TRUE(listener.WaitUntilSatisfied());
993 ASSERT_EQ("ready", listener.message()) << listener.message();
976 994
977 listener.Reply("go"); 995 listener.Reply("go");
978 996
979 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 997 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
980 998
981 event_router()->GattDescriptorRemoved(mock_adapter_, desc0_.get()); 999 event_router()->GattDescriptorRemoved(mock_adapter_, desc0_.get());
982 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get()); 1000 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get());
983 event_router()->GattServiceRemoved( 1001 event_router()->GattServiceRemoved(
984 mock_adapter_, device0_.get(), service0_.get()); 1002 mock_adapter_, device0_.get(), service0_.get());
985 } 1003 }
(...skipping 24 matching lines...) Expand all
1010 .WillRepeatedly(Return(desc0_.get())); 1028 .WillRepeatedly(Return(desc0_.get()));
1011 1029
1012 std::vector<uint8> write_value; 1030 std::vector<uint8> write_value;
1013 EXPECT_CALL(*desc0_, WriteRemoteDescriptor(_, _, _)) 1031 EXPECT_CALL(*desc0_, WriteRemoteDescriptor(_, _, _))
1014 .Times(2) 1032 .Times(2)
1015 .WillOnce(InvokeCallbackArgument<2>()) 1033 .WillOnce(InvokeCallbackArgument<2>())
1016 .WillOnce(DoAll(SaveArg<0>(&write_value), InvokeCallbackArgument<1>())); 1034 .WillOnce(DoAll(SaveArg<0>(&write_value), InvokeCallbackArgument<1>()));
1017 1035
1018 EXPECT_CALL(*desc0_, GetValue()).Times(1).WillOnce(ReturnRef(write_value)); 1036 EXPECT_CALL(*desc0_, GetValue()).Times(1).WillOnce(ReturnRef(write_value));
1019 1037
1020 ExtensionTestMessageListener listener("ready", true); 1038 ExtensionTestMessageListener listener(true);
1021 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( 1039 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
1022 "bluetooth_low_energy/write_descriptor_value"))); 1040 "bluetooth_low_energy/write_descriptor_value")));
1023 EXPECT_TRUE(listener.WaitUntilSatisfied()); 1041 EXPECT_TRUE(listener.WaitUntilSatisfied());
1042 ASSERT_EQ("ready", listener.message()) << listener.message();
1024 1043
1025 listener.Reply("go"); 1044 listener.Reply("go");
1026 1045
1027 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 1046 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
1028 1047
1029 event_router()->GattDescriptorRemoved(mock_adapter_, desc0_.get()); 1048 event_router()->GattDescriptorRemoved(mock_adapter_, desc0_.get());
1030 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get()); 1049 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get());
1031 event_router()->GattServiceRemoved( 1050 event_router()->GattServiceRemoved(
1032 mock_adapter_, device0_.get(), service0_.get()); 1051 mock_adapter_, device0_.get(), service0_.get());
1033 } 1052 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 event_router()->GattDescriptorRemoved(mock_adapter_, desc0_.get()); 1089 event_router()->GattDescriptorRemoved(mock_adapter_, desc0_.get());
1071 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get()); 1090 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get());
1072 event_router()->GattServiceRemoved( 1091 event_router()->GattServiceRemoved(
1073 mock_adapter_, device0_.get(), service0_.get()); 1092 mock_adapter_, device0_.get(), service0_.get());
1074 } 1093 }
1075 1094
1076 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, UuidPermissionEvents) { 1095 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, UuidPermissionEvents) {
1077 ResultCatcher catcher; 1096 ResultCatcher catcher;
1078 catcher.RestrictToBrowserContext(browser()->profile()); 1097 catcher.RestrictToBrowserContext(browser()->profile());
1079 1098
1080 ExtensionTestMessageListener listener("ready", true); 1099 ExtensionTestMessageListener listener(true);
1081 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( 1100 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
1082 "bluetooth_low_energy/uuid_permission_events"))); 1101 "bluetooth_low_energy/uuid_permission_events")));
1083 1102
1084 // Cause events to be sent to the extension. 1103 // Cause events to be sent to the extension.
1085 event_router()->GattServiceAdded( 1104 event_router()->GattServiceAdded(
1086 mock_adapter_, device0_.get(), service0_.get()); 1105 mock_adapter_, device0_.get(), service0_.get());
1087 event_router()->GattCharacteristicAdded(mock_adapter_, chrc0_.get()); 1106 event_router()->GattCharacteristicAdded(mock_adapter_, chrc0_.get());
1088 event_router()->GattDescriptorAdded(mock_adapter_, desc0_.get()); 1107 event_router()->GattDescriptorAdded(mock_adapter_, desc0_.get());
1089 1108
1090 std::vector<uint8> value; 1109 std::vector<uint8> value;
1091 event_router()->GattCharacteristicValueChanged( 1110 event_router()->GattCharacteristicValueChanged(
1092 mock_adapter_, chrc0_.get(), value); 1111 mock_adapter_, chrc0_.get(), value);
1093 event_router()->GattDescriptorValueChanged( 1112 event_router()->GattDescriptorValueChanged(
1094 mock_adapter_, desc0_.get(), value); 1113 mock_adapter_, desc0_.get(), value);
1095 event_router()->GattServiceChanged(mock_adapter_, service0_.get()); 1114 event_router()->GattServiceChanged(mock_adapter_, service0_.get());
1096 1115
1097 EXPECT_TRUE(listener.WaitUntilSatisfied()); 1116 EXPECT_TRUE(listener.WaitUntilSatisfied());
1098 listener.Reply("go"); 1117 listener.Reply("go");
1099 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 1118 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
1119 ASSERT_EQ("ready", listener.message()) << listener.message();
1100 1120
1101 event_router()->GattDescriptorRemoved(mock_adapter_, desc0_.get()); 1121 event_router()->GattDescriptorRemoved(mock_adapter_, desc0_.get());
1102 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get()); 1122 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get());
1103 event_router()->GattServiceRemoved( 1123 event_router()->GattServiceRemoved(
1104 mock_adapter_, device0_.get(), service0_.get()); 1124 mock_adapter_, device0_.get(), service0_.get());
1105 } 1125 }
1106 1126
1107 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GattConnection) { 1127 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GattConnection) {
1108 ResultCatcher catcher; 1128 ResultCatcher catcher;
1109 catcher.RestrictToBrowserContext(browser()->profile()); 1129 catcher.RestrictToBrowserContext(browser()->profile());
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 kTestLeDeviceAddress0); 1197 kTestLeDeviceAddress0);
1178 scoped_ptr<BluetoothGattConnection> conn_ptr(conn); 1198 scoped_ptr<BluetoothGattConnection> conn_ptr(conn);
1179 EXPECT_CALL(*conn, Disconnect(_)) 1199 EXPECT_CALL(*conn, Disconnect(_))
1180 .Times(1) 1200 .Times(1)
1181 .WillOnce(SaveArg<0>(&disconnect_callback)); 1201 .WillOnce(SaveArg<0>(&disconnect_callback));
1182 1202
1183 EXPECT_CALL(*device0_, CreateGattConnection(_, _)) 1203 EXPECT_CALL(*device0_, CreateGattConnection(_, _))
1184 .Times(1) 1204 .Times(1)
1185 .WillOnce(SaveArg<0>(&connect_callback)); 1205 .WillOnce(SaveArg<0>(&connect_callback));
1186 1206
1187 ExtensionTestMessageListener listener("ready", true); 1207 ExtensionTestMessageListener listener(true);
1188 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( 1208 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
1189 "bluetooth_low_energy/connect_in_progress"))); 1209 "bluetooth_low_energy/connect_in_progress")));
1190 1210
1191 listener.WaitUntilSatisfied(); 1211 EXPECT_TRUE(listener.WaitUntilSatisfied());
1212 ASSERT_EQ("ready", listener.message()) << listener.message();
1192 connect_callback.Run(conn_ptr.Pass()); 1213 connect_callback.Run(conn_ptr.Pass());
1193 1214
1194 listener.Reset(); 1215 listener.Reset();
1195 listener.WaitUntilSatisfied(); 1216 EXPECT_TRUE(listener.WaitUntilSatisfied());
1217 ASSERT_EQ("ready", listener.message()) << listener.message();
1196 disconnect_callback.Run(); 1218 disconnect_callback.Run();
1197 1219
1198 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 1220 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
1199 } 1221 }
1200 1222
1201 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, StartStopNotifications) { 1223 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, StartStopNotifications) {
1202 ResultCatcher catcher; 1224 ResultCatcher catcher;
1203 catcher.RestrictToBrowserContext(browser()->profile()); 1225 catcher.RestrictToBrowserContext(browser()->profile());
1204 1226
1205 event_router()->GattServiceAdded( 1227 event_router()->GattServiceAdded(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 .WillOnce(InvokeCallbackArgument<1>()) 1264 .WillOnce(InvokeCallbackArgument<1>())
1243 .WillOnce( 1265 .WillOnce(
1244 InvokeCallbackWithScopedPtrArg<0, BluetoothGattNotifySession>( 1266 InvokeCallbackWithScopedPtrArg<0, BluetoothGattNotifySession>(
1245 session0)); 1267 session0));
1246 EXPECT_CALL(*chrc1_, StartNotifySession(_, _)) 1268 EXPECT_CALL(*chrc1_, StartNotifySession(_, _))
1247 .Times(1) 1269 .Times(1)
1248 .WillOnce( 1270 .WillOnce(
1249 InvokeCallbackWithScopedPtrArg<0, BluetoothGattNotifySession>( 1271 InvokeCallbackWithScopedPtrArg<0, BluetoothGattNotifySession>(
1250 session1)); 1272 session1));
1251 1273
1252 ExtensionTestMessageListener listener("ready", true); 1274 ExtensionTestMessageListener listener(true);
1253 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( 1275 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
1254 "bluetooth_low_energy/start_stop_notifications"))); 1276 "bluetooth_low_energy/start_stop_notifications")));
1255 1277
1256 EXPECT_TRUE(listener.WaitUntilSatisfied()); 1278 EXPECT_TRUE(listener.WaitUntilSatisfied());
1279 ASSERT_EQ("ready", listener.message()) << listener.message();
1257 1280
1258 std::vector<uint8> value; 1281 std::vector<uint8> value;
1259 event_router()->GattCharacteristicValueChanged( 1282 event_router()->GattCharacteristicValueChanged(
1260 mock_adapter_, chrc0_.get(), value); 1283 mock_adapter_, chrc0_.get(), value);
1261 event_router()->GattCharacteristicValueChanged( 1284 event_router()->GattCharacteristicValueChanged(
1262 mock_adapter_, chrc1_.get(), value); 1285 mock_adapter_, chrc1_.get(), value);
1263 event_router()->GattCharacteristicValueChanged( 1286 event_router()->GattCharacteristicValueChanged(
1264 mock_adapter_, chrc2_.get(), value); 1287 mock_adapter_, chrc2_.get(), value);
1265 1288
1266 listener.Reply("go"); 1289 listener.Reply("go");
1267 1290
1268 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 1291 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
1269 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc2_.get()); 1292 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc2_.get());
1270 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc1_.get()); 1293 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc1_.get());
1271 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get()); 1294 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get());
1272 event_router()->GattServiceRemoved( 1295 event_router()->GattServiceRemoved(
1273 mock_adapter_, device0_.get(), service1_.get()); 1296 mock_adapter_, device0_.get(), service1_.get());
1274 event_router()->GattServiceRemoved( 1297 event_router()->GattServiceRemoved(
1275 mock_adapter_, device0_.get(), service0_.get()); 1298 mock_adapter_, device0_.get(), service0_.get());
1276 } 1299 }
1277 1300
1278 } // namespace 1301 } // namespace
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/bluetooth_low_energy/write_descriptor_value/runtest.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698