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