| OLD | NEW |
| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
| (...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GattConnection) { | 1137 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GattConnection) { |
| 1138 ResultCatcher catcher; | 1138 ResultCatcher catcher; |
| 1139 catcher.RestrictToBrowserContext(browser()->profile()); | 1139 catcher.RestrictToBrowserContext(browser()->profile()); |
| 1140 | 1140 |
| 1141 EXPECT_CALL(*mock_adapter_, GetDevice(_)) | 1141 EXPECT_CALL(*mock_adapter_, GetDevice(_)) |
| 1142 .WillRepeatedly(Return(static_cast<BluetoothDevice*>(NULL))); | 1142 .WillRepeatedly(Return(static_cast<BluetoothDevice*>(NULL))); |
| 1143 EXPECT_CALL(*mock_adapter_, GetDevice(kTestLeDeviceAddress0)) | 1143 EXPECT_CALL(*mock_adapter_, GetDevice(kTestLeDeviceAddress0)) |
| 1144 .WillRepeatedly(Return(device0_.get())); | 1144 .WillRepeatedly(Return(device0_.get())); |
| 1145 EXPECT_CALL(*mock_adapter_, GetDevice(kTestLeDeviceAddress1)) | 1145 EXPECT_CALL(*mock_adapter_, GetDevice(kTestLeDeviceAddress1)) |
| 1146 .WillRepeatedly(Return(device1_.get())); | 1146 .WillRepeatedly(Return(device1_.get())); |
| 1147 static_assert(BluetoothDevice::NUM_CONNECT_ERROR_CODES == 15, | 1147 static_assert( |
| 1148 BluetoothDevice::NUM_CONNECT_ERROR_CODES == 8, |
| 1148 "Update required if the number of BluetoothDevice enums changes."); | 1149 "Update required if the number of BluetoothDevice enums changes."); |
| 1149 EXPECT_CALL(*device0_, CreateGattConnection(_, _)) | 1150 EXPECT_CALL(*device0_, CreateGattConnection(_, _)) |
| 1150 .Times(16) | 1151 .Times(9) |
| 1151 .WillOnce(InvokeCallbackArgument<1>(BluetoothDevice::ERROR_FAILED)) | 1152 .WillOnce(InvokeCallbackArgument<1>(BluetoothDevice::ERROR_FAILED)) |
| 1152 .WillOnce(InvokeCallbackArgument<1>(BluetoothDevice::ERROR_INPROGRESS)) | 1153 .WillOnce(InvokeCallbackArgument<1>(BluetoothDevice::ERROR_INPROGRESS)) |
| 1153 .WillOnce(InvokeCallbackArgument<1>(BluetoothDevice::ERROR_AUTH_FAILED)) | 1154 .WillOnce(InvokeCallbackArgument<1>(BluetoothDevice::ERROR_AUTH_FAILED)) |
| 1154 .WillOnce(InvokeCallbackArgument<1>(BluetoothDevice::ERROR_AUTH_REJECTED)) | 1155 .WillOnce(InvokeCallbackArgument<1>(BluetoothDevice::ERROR_AUTH_REJECTED)) |
| 1155 .WillOnce(InvokeCallbackArgument<1>(BluetoothDevice::ERROR_AUTH_CANCELED)) | 1156 .WillOnce(InvokeCallbackArgument<1>(BluetoothDevice::ERROR_AUTH_CANCELED)) |
| 1156 .WillOnce(InvokeCallbackArgument<1>(BluetoothDevice::ERROR_AUTH_TIMEOUT)) | 1157 .WillOnce(InvokeCallbackArgument<1>(BluetoothDevice::ERROR_AUTH_TIMEOUT)) |
| 1157 .WillOnce( | 1158 .WillOnce( |
| 1158 InvokeCallbackArgument<1>(BluetoothDevice::ERROR_UNSUPPORTED_DEVICE)) | 1159 InvokeCallbackArgument<1>(BluetoothDevice::ERROR_UNSUPPORTED_DEVICE)) |
| 1159 .WillOnce(InvokeCallbackArgument<1>( | |
| 1160 BluetoothDevice::ERROR_ATTRIBUTE_LENGTH_INVALID)) | |
| 1161 .WillOnce(InvokeCallbackArgument<1>( | |
| 1162 BluetoothDevice::ERROR_CONNECTION_CONGESTED)) | |
| 1163 .WillOnce(InvokeCallbackArgument<1>( | |
| 1164 BluetoothDevice::ERROR_INSUFFICIENT_ENCRYPTION)) | |
| 1165 .WillOnce( | |
| 1166 InvokeCallbackArgument<1>(BluetoothDevice::ERROR_OFFSET_INVALID)) | |
| 1167 .WillOnce(InvokeCallbackArgument<1>( | |
| 1168 BluetoothDevice::ERROR_READ_NOT_PERMITTED)) | |
| 1169 .WillOnce(InvokeCallbackArgument<1>( | |
| 1170 BluetoothDevice::ERROR_REQUEST_NOT_SUPPORTED)) | |
| 1171 .WillOnce(InvokeCallbackArgument<1>( | |
| 1172 BluetoothDevice::ERROR_WRITE_NOT_PERMITTED)) | |
| 1173 .WillOnce(InvokeCallbackWithScopedPtrArg<0, BluetoothGattConnection>( | 1160 .WillOnce(InvokeCallbackWithScopedPtrArg<0, BluetoothGattConnection>( |
| 1174 CreateGattConnection(mock_adapter_, kTestLeDeviceAddress0, | 1161 CreateGattConnection(mock_adapter_, kTestLeDeviceAddress0, |
| 1175 true /* expect_disconnect */))) | 1162 true /* expect_disconnect */))) |
| 1176 .WillOnce(InvokeCallbackWithScopedPtrArg<0, BluetoothGattConnection>( | 1163 .WillOnce(InvokeCallbackWithScopedPtrArg<0, BluetoothGattConnection>( |
| 1177 CreateGattConnection(mock_adapter_, kTestLeDeviceAddress0, | 1164 CreateGattConnection(mock_adapter_, kTestLeDeviceAddress0, |
| 1178 false /* expect_disconnect */))); | 1165 false /* expect_disconnect */))); |
| 1179 EXPECT_CALL(*device1_, CreateGattConnection(_, _)) | 1166 EXPECT_CALL(*device1_, CreateGattConnection(_, _)) |
| 1180 .Times(1) | 1167 .Times(1) |
| 1181 .WillOnce(InvokeCallbackWithScopedPtrArg<0, BluetoothGattConnection>( | 1168 .WillOnce(InvokeCallbackWithScopedPtrArg<0, BluetoothGattConnection>( |
| 1182 CreateGattConnection(mock_adapter_, kTestLeDeviceAddress1, | 1169 CreateGattConnection(mock_adapter_, kTestLeDeviceAddress1, |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1358 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 1345 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
| 1359 | 1346 |
| 1360 listener.Reply("go"); | 1347 listener.Reply("go"); |
| 1361 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 1348 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 1362 | 1349 |
| 1363 event_router()->GattServiceRemoved(mock_adapter_, device0_.get(), | 1350 event_router()->GattServiceRemoved(mock_adapter_, device0_.get(), |
| 1364 service0_.get()); | 1351 service0_.get()); |
| 1365 } | 1352 } |
| 1366 | 1353 |
| 1367 } // namespace | 1354 } // namespace |
| OLD | NEW |