| 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/api/bluetooth_low_energy/bluetooth_low_energ
y_api.h" | 10 #include "chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energ
y_api.h" |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 .WillOnce(Return(device0_.get())); | 363 .WillOnce(Return(device0_.get())); |
| 364 EXPECT_CALL(*device0_, GetGattService(kTestServiceId0)) | 364 EXPECT_CALL(*device0_, GetGattService(kTestServiceId0)) |
| 365 .Times(1) | 365 .Times(1) |
| 366 .WillOnce(Return(service0_.get())); | 366 .WillOnce(Return(service0_.get())); |
| 367 | 367 |
| 368 event_router()->GattServiceAdded( | 368 event_router()->GattServiceAdded( |
| 369 mock_adapter_, device0_.get(), service0_.get()); | 369 mock_adapter_, device0_.get(), service0_.get()); |
| 370 event_router()->GattDiscoveryCompleteForService(mock_adapter_, | 370 event_router()->GattDiscoveryCompleteForService(mock_adapter_, |
| 371 service0_.get()); | 371 service0_.get()); |
| 372 | 372 |
| 373 ExtensionTestMessageListener get_service_success_listener(true); | 373 ExtensionTestMessageListener get_service_success_listener(false); |
| 374 EXPECT_TRUE(get_service_success_listener.WaitUntilSatisfied()); | 374 EXPECT_TRUE(get_service_success_listener.WaitUntilSatisfied()); |
| 375 ASSERT_EQ("getServiceSuccess", get_service_success_listener.message()) | 375 ASSERT_EQ("getServiceSuccess", get_service_success_listener.message()) |
| 376 << get_service_success_listener.message(); | 376 << get_service_success_listener.message(); |
| 377 testing::Mock::VerifyAndClearExpectations(mock_adapter_); | 377 testing::Mock::VerifyAndClearExpectations(mock_adapter_); |
| 378 testing::Mock::VerifyAndClearExpectations(device0_.get()); | 378 testing::Mock::VerifyAndClearExpectations(device0_.get()); |
| 379 | 379 |
| 380 // 2. getService fail. | 380 // 2. getService fail. |
| 381 EXPECT_CALL(*mock_adapter_, GetDevice(_)).Times(0); | 381 EXPECT_CALL(*mock_adapter_, GetDevice(_)).Times(0); |
| 382 EXPECT_CALL(*device0_, GetGattService(kTestServiceId0)).Times(0); | 382 EXPECT_CALL(*device0_, GetGattService(kTestServiceId0)).Times(0); |
| 383 | 383 |
| (...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1227 testing::NiceMock<MockBluetoothGattConnection>* conn = | 1227 testing::NiceMock<MockBluetoothGattConnection>* conn = |
| 1228 new testing::NiceMock<MockBluetoothGattConnection>(mock_adapter_, | 1228 new testing::NiceMock<MockBluetoothGattConnection>(mock_adapter_, |
| 1229 kTestLeDeviceAddress0); | 1229 kTestLeDeviceAddress0); |
| 1230 std::unique_ptr<BluetoothGattConnection> conn_ptr(conn); | 1230 std::unique_ptr<BluetoothGattConnection> conn_ptr(conn); |
| 1231 EXPECT_CALL(*conn, Disconnect()).Times(1); | 1231 EXPECT_CALL(*conn, Disconnect()).Times(1); |
| 1232 | 1232 |
| 1233 EXPECT_CALL(*device0_, CreateGattConnection(_, _)) | 1233 EXPECT_CALL(*device0_, CreateGattConnection(_, _)) |
| 1234 .Times(1) | 1234 .Times(1) |
| 1235 .WillOnce(SaveArg<0>(&connect_callback)); | 1235 .WillOnce(SaveArg<0>(&connect_callback)); |
| 1236 | 1236 |
| 1237 ExtensionTestMessageListener listener(true); | 1237 ExtensionTestMessageListener listener(false); |
| 1238 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( | 1238 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( |
| 1239 "bluetooth_low_energy/connect_in_progress"))); | 1239 "bluetooth_low_energy/connect_in_progress"))); |
| 1240 | 1240 |
| 1241 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 1241 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
| 1242 ASSERT_EQ("After 2nd connect fails due to 1st connect being in progress.", | 1242 ASSERT_EQ("After 2nd connect fails due to 1st connect being in progress.", |
| 1243 listener.message()) | 1243 listener.message()) |
| 1244 << listener.message(); | 1244 << listener.message(); |
| 1245 listener.Reset(); | 1245 listener.Reset(); |
| 1246 | 1246 |
| 1247 connect_callback.Run(std::move(conn_ptr)); | 1247 connect_callback.Run(std::move(conn_ptr)); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1358 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 1358 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
| 1359 | 1359 |
| 1360 listener.Reply("go"); | 1360 listener.Reply("go"); |
| 1361 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 1361 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 1362 | 1362 |
| 1363 event_router()->GattServiceRemoved(mock_adapter_, device0_.get(), | 1363 event_router()->GattServiceRemoved(mock_adapter_, device0_.get(), |
| 1364 service0_.get()); | 1364 service0_.get()); |
| 1365 } | 1365 } |
| 1366 | 1366 |
| 1367 } // namespace | 1367 } // namespace |
| OLD | NEW |