Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / extensions / browser / api / bluetooth_low_energy / bluetooth_low_energy_apitest.cc
index e9997e9..d300dfa 100644 (file)
@@ -61,24 +61,24 @@ const char kTestServiceUuid1[] = "5678";
 const char kTestCharacteristicId0[] = "char_id0";
 const char kTestCharacteristicUuid0[] = "1211";
 const BluetoothGattCharacteristic::Properties kTestCharacteristicProperties0 =
-    BluetoothGattCharacteristic::kPropertyBroadcast |
-    BluetoothGattCharacteristic::kPropertyRead |
-    BluetoothGattCharacteristic::kPropertyWriteWithoutResponse |
-    BluetoothGattCharacteristic::kPropertyIndicate;
+    BluetoothGattCharacteristic::PROPERTY_BROADCAST |
+    BluetoothGattCharacteristic::PROPERTY_READ |
+    BluetoothGattCharacteristic::PROPERTY_WRITE_WITHOUT_RESPONSE |
+    BluetoothGattCharacteristic::PROPERTY_INDICATE;
 const uint8 kTestCharacteristicDefaultValue0[] = {0x01, 0x02, 0x03, 0x04, 0x05};
 
 const char kTestCharacteristicId1[] = "char_id1";
 const char kTestCharacteristicUuid1[] = "1212";
 const BluetoothGattCharacteristic::Properties kTestCharacteristicProperties1 =
-    BluetoothGattCharacteristic::kPropertyRead |
-    BluetoothGattCharacteristic::kPropertyWrite |
-    BluetoothGattCharacteristic::kPropertyNotify;
+    BluetoothGattCharacteristic::PROPERTY_READ |
+    BluetoothGattCharacteristic::PROPERTY_WRITE |
+    BluetoothGattCharacteristic::PROPERTY_NOTIFY;
 const uint8 kTestCharacteristicDefaultValue1[] = {0x06, 0x07, 0x08};
 
 const char kTestCharacteristicId2[] = "char_id2";
 const char kTestCharacteristicUuid2[] = "1213";
 const BluetoothGattCharacteristic::Properties kTestCharacteristicProperties2 =
-    BluetoothGattCharacteristic::kPropertyNone;
+    BluetoothGattCharacteristic::PROPERTY_NONE;
 
 // Test descriptor constants.
 const char kTestDescriptorId0[] = "desc_id0";
@@ -93,15 +93,15 @@ class BluetoothLowEnergyApiTest : public ExtensionApiTest {
  public:
   BluetoothLowEnergyApiTest() {}
 
-  virtual ~BluetoothLowEnergyApiTest() {}
+  ~BluetoothLowEnergyApiTest() override {}
 
-  virtual void SetUpOnMainThread() OVERRIDE {
+  void SetUpOnMainThread() override {
     ExtensionApiTest::SetUpOnMainThread();
     empty_extension_ = extensions::test_util::CreateEmptyExtension();
     SetUpMocks();
   }
 
-  virtual void TearDownOnMainThread() OVERRIDE {
+  void TearDownOnMainThread() override {
     EXPECT_CALL(*mock_adapter_, RemoveObserver(_));
   }
 
@@ -153,7 +153,7 @@ class BluetoothLowEnergyApiTest : public ExtensionApiTest {
         BluetoothUUID(kTestCharacteristicUuid0),
         false /* is_local */,
         kTestCharacteristicProperties0,
-        BluetoothGattCharacteristic::kPermissionNone));
+        BluetoothGattCharacteristic::PERMISSION_NONE));
     default_value.assign(kTestCharacteristicDefaultValue0,
                          (kTestCharacteristicDefaultValue0 +
                           sizeof(kTestCharacteristicDefaultValue0)));
@@ -165,7 +165,7 @@ class BluetoothLowEnergyApiTest : public ExtensionApiTest {
         BluetoothUUID(kTestCharacteristicUuid1),
         false /* is_local */,
         kTestCharacteristicProperties1,
-        BluetoothGattCharacteristic::kPermissionNone));
+        BluetoothGattCharacteristic::PERMISSION_NONE));
     default_value.assign(kTestCharacteristicDefaultValue1,
                          (kTestCharacteristicDefaultValue1 +
                           sizeof(kTestCharacteristicDefaultValue1)));
@@ -177,14 +177,14 @@ class BluetoothLowEnergyApiTest : public ExtensionApiTest {
         BluetoothUUID(kTestCharacteristicUuid2),
         false /* is_local */,
         kTestCharacteristicProperties2,
-        BluetoothGattCharacteristic::kPermissionNone));
+        BluetoothGattCharacteristic::PERMISSION_NONE));
 
     desc0_.reset(new testing::NiceMock<MockBluetoothGattDescriptor>(
         chrc0_.get(),
         kTestDescriptorId0,
         BluetoothUUID(kTestDescriptorUuid0),
         false /* is_local */,
-        BluetoothGattCharacteristic::kPermissionNone));
+        BluetoothGattCharacteristic::PERMISSION_NONE));
     default_value.assign(
         kTestDescriptorDefaultValue0,
         (kTestDescriptorDefaultValue0 + sizeof(kTestDescriptorDefaultValue0)));
@@ -195,7 +195,7 @@ class BluetoothLowEnergyApiTest : public ExtensionApiTest {
         kTestDescriptorId1,
         BluetoothUUID(kTestDescriptorUuid1),
         false /* is_local */,
-        BluetoothGattCharacteristic::kPermissionNone));
+        BluetoothGattCharacteristic::PERMISSION_NONE));
     default_value.assign(
         kTestDescriptorDefaultValue1,
         (kTestDescriptorDefaultValue1 + sizeof(kTestDescriptorDefaultValue1)));
@@ -278,6 +278,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetServices) {
 
   // Load and wait for setup.
   ExtensionTestMessageListener listener("ready", true);
+  listener.set_failure_message("fail");
   ASSERT_TRUE(LoadExtension(
       test_data_dir_.AppendASCII("bluetooth_low_energy/get_services")));
   EXPECT_TRUE(listener.WaitUntilSatisfied());
@@ -306,6 +307,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetService) {
 
   // Load and wait for setup.
   ExtensionTestMessageListener listener("ready", true);
+  listener.set_failure_message("fail");
   ASSERT_TRUE(LoadExtension(
       test_data_dir_.AppendASCII("bluetooth_low_energy/get_service")));
   EXPECT_TRUE(listener.WaitUntilSatisfied());
@@ -323,7 +325,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, ServiceEvents) {
   catcher.RestrictToBrowserContext(browser()->profile());
 
   // Load the extension and let it set up.
-  ExtensionTestMessageListener listener("ready", true);
+  ExtensionTestMessageListener listener(true);
   ASSERT_TRUE(LoadExtension(
       test_data_dir_.AppendASCII("bluetooth_low_energy/service_events")));
 
@@ -347,6 +349,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, ServiceEvents) {
       mock_adapter_, device0_.get(), service0_.get());
 
   EXPECT_TRUE(listener.WaitUntilSatisfied());
+  ASSERT_EQ("ready", listener.message()) << listener.message();
   listener.Reply("go");
 
   EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
@@ -375,9 +378,10 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetRemovedService) {
   event_router()->GattDiscoveryCompleteForService(mock_adapter_,
                                                   service0_.get());
 
-  ExtensionTestMessageListener get_service_success_listener("getServiceSuccess",
-                                                            true);
+  ExtensionTestMessageListener get_service_success_listener(true);
   EXPECT_TRUE(get_service_success_listener.WaitUntilSatisfied());
+  ASSERT_EQ("getServiceSuccess", get_service_success_listener.message())
+      << get_service_success_listener.message();
   testing::Mock::VerifyAndClearExpectations(mock_adapter_);
   testing::Mock::VerifyAndClearExpectations(device0_.get());
 
@@ -388,9 +392,10 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetRemovedService) {
   event_router()->GattServiceRemoved(
       mock_adapter_, device0_.get(), service0_.get());
 
-  ExtensionTestMessageListener get_service_fail_listener("getServiceFail",
-                                                         true);
+  ExtensionTestMessageListener get_service_fail_listener(true);
   EXPECT_TRUE(get_service_fail_listener.WaitUntilSatisfied());
+  ASSERT_EQ("getServiceFail", get_service_fail_listener.message())
+      << get_service_fail_listener.message();
   testing::Mock::VerifyAndClearExpectations(mock_adapter_);
   testing::Mock::VerifyAndClearExpectations(device0_.get());
 
@@ -408,6 +413,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetIncludedServices) {
 
   // Wait for initial call to end with failure as there is no mapping.
   ExtensionTestMessageListener listener("ready", true);
+  listener.set_failure_message("fail");
   EXPECT_TRUE(listener.WaitUntilSatisfied());
 
   // Set up for the rest of the calls before replying. Included services can be
@@ -500,6 +506,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetCharacteristic) {
 
   // Load the extension and wait for first test.
   ExtensionTestMessageListener listener("ready", true);
+  listener.set_failure_message("fail");
   ASSERT_TRUE(LoadExtension(
       test_data_dir_.AppendASCII("bluetooth_low_energy/get_characteristic")));
   EXPECT_TRUE(listener.WaitUntilSatisfied());
@@ -532,34 +539,35 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, CharacteristicProperties) {
       .WillRepeatedly(Return(chrc0_.get()));
   EXPECT_CALL(*chrc0_, GetProperties())
       .Times(12)
-      .WillOnce(Return(BluetoothGattCharacteristic::kPropertyNone))
-      .WillOnce(Return(BluetoothGattCharacteristic::kPropertyBroadcast))
-      .WillOnce(Return(BluetoothGattCharacteristic::kPropertyRead))
+      .WillOnce(Return(BluetoothGattCharacteristic::PROPERTY_NONE))
+      .WillOnce(Return(BluetoothGattCharacteristic::PROPERTY_BROADCAST))
+      .WillOnce(Return(BluetoothGattCharacteristic::PROPERTY_READ))
       .WillOnce(
-           Return(BluetoothGattCharacteristic::kPropertyWriteWithoutResponse))
-      .WillOnce(Return(BluetoothGattCharacteristic::kPropertyWrite))
-      .WillOnce(Return(BluetoothGattCharacteristic::kPropertyNotify))
-      .WillOnce(Return(BluetoothGattCharacteristic::kPropertyIndicate))
+           Return(BluetoothGattCharacteristic::PROPERTY_WRITE_WITHOUT_RESPONSE))
+      .WillOnce(Return(BluetoothGattCharacteristic::PROPERTY_WRITE))
+      .WillOnce(Return(BluetoothGattCharacteristic::PROPERTY_NOTIFY))
+      .WillOnce(Return(BluetoothGattCharacteristic::PROPERTY_INDICATE))
       .WillOnce(Return(
-          BluetoothGattCharacteristic::kPropertyAuthenticatedSignedWrites))
+          BluetoothGattCharacteristic::PROPERTY_AUTHENTICATED_SIGNED_WRITES))
       .WillOnce(
-           Return(BluetoothGattCharacteristic::kPropertyExtendedProperties))
-      .WillOnce(Return(BluetoothGattCharacteristic::kPropertyReliableWrite))
+           Return(BluetoothGattCharacteristic::PROPERTY_EXTENDED_PROPERTIES))
+      .WillOnce(Return(BluetoothGattCharacteristic::PROPERTY_RELIABLE_WRITE))
       .WillOnce(
-           Return(BluetoothGattCharacteristic::kPropertyWritableAuxiliaries))
+           Return(BluetoothGattCharacteristic::PROPERTY_WRITABLE_AUXILIARIES))
       .WillOnce(Return(
-          BluetoothGattCharacteristic::kPropertyBroadcast |
-          BluetoothGattCharacteristic::kPropertyRead |
-          BluetoothGattCharacteristic::kPropertyWriteWithoutResponse |
-          BluetoothGattCharacteristic::kPropertyWrite |
-          BluetoothGattCharacteristic::kPropertyNotify |
-          BluetoothGattCharacteristic::kPropertyIndicate |
-          BluetoothGattCharacteristic::kPropertyAuthenticatedSignedWrites |
-          BluetoothGattCharacteristic::kPropertyExtendedProperties |
-          BluetoothGattCharacteristic::kPropertyReliableWrite |
-          BluetoothGattCharacteristic::kPropertyWritableAuxiliaries));
+          BluetoothGattCharacteristic::PROPERTY_BROADCAST |
+          BluetoothGattCharacteristic::PROPERTY_READ |
+          BluetoothGattCharacteristic::PROPERTY_WRITE_WITHOUT_RESPONSE |
+          BluetoothGattCharacteristic::PROPERTY_WRITE |
+          BluetoothGattCharacteristic::PROPERTY_NOTIFY |
+          BluetoothGattCharacteristic::PROPERTY_INDICATE |
+          BluetoothGattCharacteristic::PROPERTY_AUTHENTICATED_SIGNED_WRITES |
+          BluetoothGattCharacteristic::PROPERTY_EXTENDED_PROPERTIES |
+          BluetoothGattCharacteristic::PROPERTY_RELIABLE_WRITE |
+          BluetoothGattCharacteristic::PROPERTY_WRITABLE_AUXILIARIES));
 
   ExtensionTestMessageListener listener("ready", true);
+  listener.set_failure_message("fail");
   ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
       "bluetooth_low_energy/characteristic_properties")));
   EXPECT_TRUE(listener.WaitUntilSatisfied());
@@ -594,8 +602,9 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetRemovedCharacteristic) {
   ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
       "bluetooth_low_energy/get_removed_characteristic")));
 
-  ExtensionTestMessageListener listener("ready", true);
+  ExtensionTestMessageListener listener(true);
   EXPECT_TRUE(listener.WaitUntilSatisfied());
+  ASSERT_EQ("ready", listener.message()) << listener.message();
   testing::Mock::VerifyAndClearExpectations(mock_adapter_);
   testing::Mock::VerifyAndClearExpectations(device0_.get());
   testing::Mock::VerifyAndClearExpectations(service0_.get());
@@ -609,6 +618,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetRemovedCharacteristic) {
   listener.Reply("go");
   listener.Reset();
   EXPECT_TRUE(listener.WaitUntilSatisfied());
+  ASSERT_EQ("ready", listener.message()) << listener.message();
 
   listener.Reply("go");
 
@@ -709,13 +719,15 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, ReadCharacteristicValue) {
   std::vector<uint8> value;
   EXPECT_CALL(*chrc0_, ReadRemoteCharacteristic(_, _))
       .Times(2)
-      .WillOnce(InvokeCallbackArgument<1>())
+      .WillOnce(
+           InvokeCallbackArgument<1>(BluetoothGattService::GATT_ERROR_FAILED))
       .WillOnce(InvokeCallbackArgument<0>(value));
 
   ExtensionTestMessageListener listener("ready", true);
+  listener.set_failure_message("fail");
   ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
       "bluetooth_low_energy/read_characteristic_value")));
-  EXPECT_TRUE(listener.WaitUntilSatisfied());
+  listener.WaitUntilSatisfied();
 
   listener.Reply("go");
 
@@ -749,12 +761,14 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, WriteCharacteristicValue) {
   std::vector<uint8> write_value;
   EXPECT_CALL(*chrc0_, WriteRemoteCharacteristic(_, _, _))
       .Times(2)
-      .WillOnce(InvokeCallbackArgument<2>())
+      .WillOnce(
+           InvokeCallbackArgument<2>(BluetoothGattService::GATT_ERROR_FAILED))
       .WillOnce(DoAll(SaveArg<0>(&write_value), InvokeCallbackArgument<1>()));
 
   EXPECT_CALL(*chrc0_, GetValue()).Times(1).WillOnce(ReturnRef(write_value));
 
   ExtensionTestMessageListener listener("ready", true);
+  listener.set_failure_message("fail");
   ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
       "bluetooth_low_energy/write_characteristic_value")));
   EXPECT_TRUE(listener.WaitUntilSatisfied());
@@ -796,6 +810,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetDescriptors) {
       .WillOnce(Return(descriptors));
 
   ExtensionTestMessageListener listener("ready", true);
+  listener.set_failure_message("fail");
   ASSERT_TRUE(LoadExtension(
       test_data_dir_.AppendASCII("bluetooth_low_energy/get_descriptors")));
   EXPECT_TRUE(listener.WaitUntilSatisfied());
@@ -840,6 +855,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetDescriptor) {
 
   // Load the extension and wait for first test.
   ExtensionTestMessageListener listener("ready", true);
+  listener.set_failure_message("fail");
   ASSERT_TRUE(LoadExtension(
       test_data_dir_.AppendASCII("bluetooth_low_energy/get_descriptor")));
   EXPECT_TRUE(listener.WaitUntilSatisfied());
@@ -879,8 +895,9 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetRemovedDescriptor) {
   ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
       "bluetooth_low_energy/get_removed_descriptor")));
 
-  ExtensionTestMessageListener listener("ready", true);
+  ExtensionTestMessageListener listener(true);
   EXPECT_TRUE(listener.WaitUntilSatisfied());
+  ASSERT_EQ("ready", listener.message()) << listener.message();
   testing::Mock::VerifyAndClearExpectations(mock_adapter_);
   testing::Mock::VerifyAndClearExpectations(device0_.get());
   testing::Mock::VerifyAndClearExpectations(service0_.get());
@@ -896,6 +913,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetRemovedDescriptor) {
   listener.Reply("go");
   listener.Reset();
   EXPECT_TRUE(listener.WaitUntilSatisfied());
+  ASSERT_EQ("ready", listener.message()) << listener.message();
 
   listener.Reply("go");
 
@@ -948,28 +966,42 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, ReadDescriptorValue) {
   event_router()->GattDescriptorAdded(mock_adapter_, desc0_.get());
 
   EXPECT_CALL(*mock_adapter_, GetDevice(_))
-      .Times(3)
+      .Times(9)
       .WillRepeatedly(Return(device0_.get()));
 
   EXPECT_CALL(*device0_, GetGattService(kTestServiceId0))
-      .Times(3)
+      .Times(9)
       .WillRepeatedly(Return(service0_.get()));
 
   EXPECT_CALL(*service0_, GetCharacteristic(kTestCharacteristicId0))
-      .Times(3)
+      .Times(9)
       .WillRepeatedly(Return(chrc0_.get()));
 
   EXPECT_CALL(*chrc0_, GetDescriptor(kTestDescriptorId0))
-      .Times(3)
+      .Times(9)
       .WillRepeatedly(Return(desc0_.get()));
 
   std::vector<uint8> value;
   EXPECT_CALL(*desc0_, ReadRemoteDescriptor(_, _))
-      .Times(2)
-      .WillOnce(InvokeCallbackArgument<1>())
+      .Times(8)
+      .WillOnce(
+           InvokeCallbackArgument<1>(BluetoothGattService::GATT_ERROR_FAILED))
+      .WillOnce(InvokeCallbackArgument<1>(
+          BluetoothGattService::GATT_ERROR_INVALID_LENGTH))
+      .WillOnce(InvokeCallbackArgument<1>(
+          BluetoothGattService::GATT_ERROR_NOT_PERMITTED))
+      .WillOnce(InvokeCallbackArgument<1>(
+          BluetoothGattService::GATT_ERROR_NOT_AUTHORIZED))
+      .WillOnce(InvokeCallbackArgument<1>(
+          BluetoothGattService::GATT_ERROR_NOT_PAIRED))
+      .WillOnce(InvokeCallbackArgument<1>(
+          BluetoothGattService::GATT_ERROR_NOT_SUPPORTED))
+      .WillOnce(InvokeCallbackArgument<1>(
+          BluetoothGattService::GATT_ERROR_IN_PROGRESS))
       .WillOnce(InvokeCallbackArgument<0>(value));
 
   ExtensionTestMessageListener listener("ready", true);
+  listener.set_failure_message("fail");
   ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
       "bluetooth_low_energy/read_descriptor_value")));
   EXPECT_TRUE(listener.WaitUntilSatisfied());
@@ -1012,12 +1044,14 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, WriteDescriptorValue) {
   std::vector<uint8> write_value;
   EXPECT_CALL(*desc0_, WriteRemoteDescriptor(_, _, _))
       .Times(2)
-      .WillOnce(InvokeCallbackArgument<2>())
+      .WillOnce(
+           InvokeCallbackArgument<2>(BluetoothGattService::GATT_ERROR_FAILED))
       .WillOnce(DoAll(SaveArg<0>(&write_value), InvokeCallbackArgument<1>()));
 
   EXPECT_CALL(*desc0_, GetValue()).Times(1).WillOnce(ReturnRef(write_value));
 
   ExtensionTestMessageListener listener("ready", true);
+  listener.set_failure_message("fail");
   ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
       "bluetooth_low_energy/write_descriptor_value")));
   EXPECT_TRUE(listener.WaitUntilSatisfied());
@@ -1077,7 +1111,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, UuidPermissionEvents) {
   ResultCatcher catcher;
   catcher.RestrictToBrowserContext(browser()->profile());
 
-  ExtensionTestMessageListener listener("ready", true);
+  ExtensionTestMessageListener listener(true);
   ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
       "bluetooth_low_energy/uuid_permission_events")));
 
@@ -1097,6 +1131,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, UuidPermissionEvents) {
   EXPECT_TRUE(listener.WaitUntilSatisfied());
   listener.Reply("go");
   EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
+  ASSERT_EQ("ready", listener.message()) << listener.message();
 
   event_router()->GattDescriptorRemoved(mock_adapter_, desc0_.get());
   event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get());
@@ -1115,8 +1150,15 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GattConnection) {
   EXPECT_CALL(*mock_adapter_, GetDevice(kTestLeDeviceAddress1))
       .WillRepeatedly(Return(device1_.get()));
   EXPECT_CALL(*device0_, CreateGattConnection(_, _))
-      .Times(3)
+      .Times(9)
       .WillOnce(InvokeCallbackArgument<1>(BluetoothDevice::ERROR_FAILED))
+      .WillOnce(InvokeCallbackArgument<1>(BluetoothDevice::ERROR_INPROGRESS))
+      .WillOnce(InvokeCallbackArgument<1>(BluetoothDevice::ERROR_AUTH_FAILED))
+      .WillOnce(InvokeCallbackArgument<1>(BluetoothDevice::ERROR_AUTH_REJECTED))
+      .WillOnce(InvokeCallbackArgument<1>(BluetoothDevice::ERROR_AUTH_CANCELED))
+      .WillOnce(InvokeCallbackArgument<1>(BluetoothDevice::ERROR_AUTH_TIMEOUT))
+      .WillOnce(
+           InvokeCallbackArgument<1>(BluetoothDevice::ERROR_UNSUPPORTED_DEVICE))
       .WillOnce(InvokeCallbackWithScopedPtrArg<0, BluetoothGattConnection>(
           CreateGattConnection(kTestLeDeviceAddress0,
                                true /* expect_disconnect */)))
@@ -1184,15 +1226,17 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, ConnectInProgress) {
       .Times(1)
       .WillOnce(SaveArg<0>(&connect_callback));
 
-  ExtensionTestMessageListener listener("ready", true);
+  ExtensionTestMessageListener listener(true);
   ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
       "bluetooth_low_energy/connect_in_progress")));
 
-  listener.WaitUntilSatisfied();
+  EXPECT_TRUE(listener.WaitUntilSatisfied());
+  ASSERT_EQ("ready", listener.message()) << listener.message();
   connect_callback.Run(conn_ptr.Pass());
 
   listener.Reset();
-  listener.WaitUntilSatisfied();
+  EXPECT_TRUE(listener.WaitUntilSatisfied());
+  ASSERT_EQ("ready", listener.message()) << listener.message();
   disconnect_callback.Run();
 
   EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
@@ -1239,10 +1283,10 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, StartStopNotifications) {
 
   EXPECT_CALL(*chrc0_, StartNotifySession(_, _))
       .Times(2)
-      .WillOnce(InvokeCallbackArgument<1>())
       .WillOnce(
-          InvokeCallbackWithScopedPtrArg<0, BluetoothGattNotifySession>(
-              session0));
+           InvokeCallbackArgument<1>(BluetoothGattService::GATT_ERROR_FAILED))
+      .WillOnce(InvokeCallbackWithScopedPtrArg<0, BluetoothGattNotifySession>(
+          session0));
   EXPECT_CALL(*chrc1_, StartNotifySession(_, _))
       .Times(1)
       .WillOnce(
@@ -1250,6 +1294,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, StartStopNotifications) {
               session1));
 
   ExtensionTestMessageListener listener("ready", true);
+  listener.set_failure_message("fail");
   ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(
       "bluetooth_low_energy/start_stop_notifications")));