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 "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 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
959 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, ReadDescriptorValue) { | 959 IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, ReadDescriptorValue) { |
960 ResultCatcher catcher; | 960 ResultCatcher catcher; |
961 catcher.RestrictToBrowserContext(browser()->profile()); | 961 catcher.RestrictToBrowserContext(browser()->profile()); |
962 | 962 |
963 event_router()->GattServiceAdded( | 963 event_router()->GattServiceAdded( |
964 mock_adapter_, device0_.get(), service0_.get()); | 964 mock_adapter_, device0_.get(), service0_.get()); |
965 event_router()->GattCharacteristicAdded(mock_adapter_, chrc0_.get()); | 965 event_router()->GattCharacteristicAdded(mock_adapter_, chrc0_.get()); |
966 event_router()->GattDescriptorAdded(mock_adapter_, desc0_.get()); | 966 event_router()->GattDescriptorAdded(mock_adapter_, desc0_.get()); |
967 | 967 |
968 EXPECT_CALL(*mock_adapter_, GetDevice(_)) | 968 EXPECT_CALL(*mock_adapter_, GetDevice(_)) |
969 .Times(3) | 969 .Times(9) |
970 .WillRepeatedly(Return(device0_.get())); | 970 .WillRepeatedly(Return(device0_.get())); |
971 | 971 |
972 EXPECT_CALL(*device0_, GetGattService(kTestServiceId0)) | 972 EXPECT_CALL(*device0_, GetGattService(kTestServiceId0)) |
973 .Times(3) | 973 .Times(9) |
974 .WillRepeatedly(Return(service0_.get())); | 974 .WillRepeatedly(Return(service0_.get())); |
975 | 975 |
976 EXPECT_CALL(*service0_, GetCharacteristic(kTestCharacteristicId0)) | 976 EXPECT_CALL(*service0_, GetCharacteristic(kTestCharacteristicId0)) |
977 .Times(3) | 977 .Times(9) |
978 .WillRepeatedly(Return(chrc0_.get())); | 978 .WillRepeatedly(Return(chrc0_.get())); |
979 | 979 |
980 EXPECT_CALL(*chrc0_, GetDescriptor(kTestDescriptorId0)) | 980 EXPECT_CALL(*chrc0_, GetDescriptor(kTestDescriptorId0)) |
981 .Times(3) | 981 .Times(9) |
982 .WillRepeatedly(Return(desc0_.get())); | 982 .WillRepeatedly(Return(desc0_.get())); |
983 | 983 |
984 std::vector<uint8> value; | 984 std::vector<uint8> value; |
985 EXPECT_CALL(*desc0_, ReadRemoteDescriptor(_, _)) | 985 EXPECT_CALL(*desc0_, ReadRemoteDescriptor(_, _)) |
986 .Times(2) | 986 .Times(8) |
987 .WillOnce(InvokeCallbackArgument<1>( | 987 .WillOnce(InvokeCallbackArgument<1>( |
988 BluetoothGattService::GattErrorCode::GATT_ERROR_FAILED)) | 988 BluetoothGattService::GattErrorCode::GATT_ERROR_FAILED)) |
989 .WillOnce(InvokeCallbackArgument<1>( | |
990 BluetoothGattService::GattErrorCode::GATT_ERROR_INVALID_LENGTH)) | |
armansito
2014/10/13 18:51:37
nit: I would ditch the "GattErrorCode::" in betwee
Marie Janssen
2014/10/13 21:22:49
Done.
| |
991 .WillOnce(InvokeCallbackArgument<1>( | |
992 BluetoothGattService::GattErrorCode::GATT_ERROR_NOT_PERMITTED)) | |
993 .WillOnce(InvokeCallbackArgument<1>( | |
994 BluetoothGattService::GattErrorCode::GATT_ERROR_NOT_AUTHORIZED)) | |
995 .WillOnce(InvokeCallbackArgument<1>( | |
996 BluetoothGattService::GattErrorCode::GATT_ERROR_NOT_PAIRED)) | |
997 .WillOnce(InvokeCallbackArgument<1>( | |
998 BluetoothGattService::GattErrorCode::GATT_ERROR_NOT_SUPPORTED)) | |
999 .WillOnce(InvokeCallbackArgument<1>( | |
1000 BluetoothGattService::GattErrorCode::GATT_ERROR_IN_PROGRESS)) | |
989 .WillOnce(InvokeCallbackArgument<0>(value)); | 1001 .WillOnce(InvokeCallbackArgument<0>(value)); |
990 | 1002 |
991 ExtensionTestMessageListener listener("ready", true); | 1003 ExtensionTestMessageListener listener("ready", true); |
992 listener.set_failure_message("fail"); | 1004 listener.set_failure_message("fail"); |
993 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( | 1005 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( |
994 "bluetooth_low_energy/read_descriptor_value"))); | 1006 "bluetooth_low_energy/read_descriptor_value"))); |
995 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 1007 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
996 | 1008 |
997 listener.Reply("go"); | 1009 listener.Reply("go"); |
998 | 1010 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1131 ResultCatcher catcher; | 1143 ResultCatcher catcher; |
1132 catcher.RestrictToBrowserContext(browser()->profile()); | 1144 catcher.RestrictToBrowserContext(browser()->profile()); |
1133 | 1145 |
1134 EXPECT_CALL(*mock_adapter_, GetDevice(_)) | 1146 EXPECT_CALL(*mock_adapter_, GetDevice(_)) |
1135 .WillRepeatedly(Return(static_cast<BluetoothDevice*>(NULL))); | 1147 .WillRepeatedly(Return(static_cast<BluetoothDevice*>(NULL))); |
1136 EXPECT_CALL(*mock_adapter_, GetDevice(kTestLeDeviceAddress0)) | 1148 EXPECT_CALL(*mock_adapter_, GetDevice(kTestLeDeviceAddress0)) |
1137 .WillRepeatedly(Return(device0_.get())); | 1149 .WillRepeatedly(Return(device0_.get())); |
1138 EXPECT_CALL(*mock_adapter_, GetDevice(kTestLeDeviceAddress1)) | 1150 EXPECT_CALL(*mock_adapter_, GetDevice(kTestLeDeviceAddress1)) |
1139 .WillRepeatedly(Return(device1_.get())); | 1151 .WillRepeatedly(Return(device1_.get())); |
1140 EXPECT_CALL(*device0_, CreateGattConnection(_, _)) | 1152 EXPECT_CALL(*device0_, CreateGattConnection(_, _)) |
1141 .Times(3) | 1153 .Times(9) |
1142 .WillOnce(InvokeCallbackArgument<1>(BluetoothDevice::ERROR_FAILED)) | 1154 .WillOnce(InvokeCallbackArgument<1>(BluetoothDevice::ERROR_FAILED)) |
1155 .WillOnce(InvokeCallbackArgument<1>(BluetoothDevice::ERROR_INPROGRESS)) | |
1156 .WillOnce(InvokeCallbackArgument<1>(BluetoothDevice::ERROR_AUTH_FAILED)) | |
1157 .WillOnce(InvokeCallbackArgument<1>(BluetoothDevice::ERROR_AUTH_REJECTED)) | |
1158 .WillOnce(InvokeCallbackArgument<1>(BluetoothDevice::ERROR_AUTH_CANCELED)) | |
1159 .WillOnce(InvokeCallbackArgument<1>(BluetoothDevice::ERROR_AUTH_TIMEOUT)) | |
1160 .WillOnce( | |
1161 InvokeCallbackArgument<1>(BluetoothDevice::ERROR_UNSUPPORTED_DEVICE)) | |
1143 .WillOnce(InvokeCallbackWithScopedPtrArg<0, BluetoothGattConnection>( | 1162 .WillOnce(InvokeCallbackWithScopedPtrArg<0, BluetoothGattConnection>( |
1144 CreateGattConnection(kTestLeDeviceAddress0, | 1163 CreateGattConnection(kTestLeDeviceAddress0, |
1145 true /* expect_disconnect */))) | 1164 true /* expect_disconnect */))) |
1146 .WillOnce(InvokeCallbackWithScopedPtrArg<0, BluetoothGattConnection>( | 1165 .WillOnce(InvokeCallbackWithScopedPtrArg<0, BluetoothGattConnection>( |
1147 CreateGattConnection(kTestLeDeviceAddress0, | 1166 CreateGattConnection(kTestLeDeviceAddress0, |
1148 false /* expect_disconnect */))); | 1167 false /* expect_disconnect */))); |
1149 EXPECT_CALL(*device1_, CreateGattConnection(_, _)) | 1168 EXPECT_CALL(*device1_, CreateGattConnection(_, _)) |
1150 .Times(1) | 1169 .Times(1) |
1151 .WillOnce(InvokeCallbackWithScopedPtrArg<0, BluetoothGattConnection>( | 1170 .WillOnce(InvokeCallbackWithScopedPtrArg<0, BluetoothGattConnection>( |
1152 CreateGattConnection(kTestLeDeviceAddress1, | 1171 CreateGattConnection(kTestLeDeviceAddress1, |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1295 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc2_.get()); | 1314 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc2_.get()); |
1296 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc1_.get()); | 1315 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc1_.get()); |
1297 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get()); | 1316 event_router()->GattCharacteristicRemoved(mock_adapter_, chrc0_.get()); |
1298 event_router()->GattServiceRemoved( | 1317 event_router()->GattServiceRemoved( |
1299 mock_adapter_, device0_.get(), service1_.get()); | 1318 mock_adapter_, device0_.get(), service1_.get()); |
1300 event_router()->GattServiceRemoved( | 1319 event_router()->GattServiceRemoved( |
1301 mock_adapter_, device0_.get(), service0_.get()); | 1320 mock_adapter_, device0_.get(), service0_.get()); |
1302 } | 1321 } |
1303 | 1322 |
1304 } // namespace | 1323 } // namespace |
OLD | NEW |