| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "device/bluetooth/test/bluetooth_test.h" | 5 #include "device/bluetooth/test/bluetooth_test.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "device/bluetooth/bluetooth_adapter.h" | 13 #include "device/bluetooth/bluetooth_adapter.h" |
| 14 #include "device/bluetooth/bluetooth_types.h" |
| 14 | 15 |
| 15 namespace device { | 16 namespace device { |
| 16 | 17 |
| 17 const std::string BluetoothTestBase::kTestAdapterName = "FakeBluetoothAdapter"; | 18 const std::string BluetoothTestBase::kTestAdapterName = "FakeBluetoothAdapter"; |
| 18 const std::string BluetoothTestBase::kTestAdapterAddress = "A1:B2:C3:D4:E5:F6"; | 19 const std::string BluetoothTestBase::kTestAdapterAddress = "A1:B2:C3:D4:E5:F6"; |
| 19 | 20 |
| 20 const std::string BluetoothTestBase::kTestDeviceName = "FakeBluetoothDevice"; | 21 const std::string BluetoothTestBase::kTestDeviceName = "FakeBluetoothDevice"; |
| 21 const std::string BluetoothTestBase::kTestDeviceNameEmpty = ""; | 22 const std::string BluetoothTestBase::kTestDeviceNameEmpty = ""; |
| 22 | 23 |
| 23 const std::string BluetoothTestBase::kTestDeviceAddress1 = "01:00:00:90:1E:BE"; | 24 const std::string BluetoothTestBase::kTestDeviceAddress1 = "01:00:00:90:1E:BE"; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 45 | 46 |
| 46 BluetoothTestBase::NotificationType::~NotificationType() {} | 47 BluetoothTestBase::NotificationType::~NotificationType() {} |
| 47 | 48 |
| 48 BluetoothTestBase::BluetoothTestBase() : weak_factory_(this) {} | 49 BluetoothTestBase::BluetoothTestBase() : weak_factory_(this) {} |
| 49 | 50 |
| 50 BluetoothTestBase::~BluetoothTestBase() { | 51 BluetoothTestBase::~BluetoothTestBase() { |
| 51 } | 52 } |
| 52 | 53 |
| 53 void BluetoothTestBase::StartLowEnergyDiscoverySession() { | 54 void BluetoothTestBase::StartLowEnergyDiscoverySession() { |
| 54 adapter_->StartDiscoverySessionWithFilter( | 55 adapter_->StartDiscoverySessionWithFilter( |
| 55 base::WrapUnique(new BluetoothDiscoveryFilter( | 56 base::WrapUnique( |
| 56 BluetoothDiscoveryFilter::Transport::TRANSPORT_LE)), | 57 new BluetoothDiscoveryFilter(BluetoothTransport::TRANSPORT_LE)), |
| 57 GetDiscoverySessionCallback(Call::EXPECTED), | 58 GetDiscoverySessionCallback(Call::EXPECTED), |
| 58 GetErrorCallback(Call::NOT_EXPECTED)); | 59 GetErrorCallback(Call::NOT_EXPECTED)); |
| 59 base::RunLoop().RunUntilIdle(); | 60 base::RunLoop().RunUntilIdle(); |
| 60 } | 61 } |
| 61 | 62 |
| 62 void BluetoothTestBase::StartLowEnergyDiscoverySessionExpectedToFail() { | 63 void BluetoothTestBase::StartLowEnergyDiscoverySessionExpectedToFail() { |
| 63 adapter_->StartDiscoverySessionWithFilter( | 64 adapter_->StartDiscoverySessionWithFilter( |
| 64 base::WrapUnique(new BluetoothDiscoveryFilter( | 65 base::WrapUnique( |
| 65 BluetoothDiscoveryFilter::Transport::TRANSPORT_LE)), | 66 new BluetoothDiscoveryFilter(BluetoothTransport::TRANSPORT_LE)), |
| 66 GetDiscoverySessionCallback(Call::NOT_EXPECTED), | 67 GetDiscoverySessionCallback(Call::NOT_EXPECTED), |
| 67 GetErrorCallback(Call::EXPECTED)); | 68 GetErrorCallback(Call::EXPECTED)); |
| 68 base::RunLoop().RunUntilIdle(); | 69 base::RunLoop().RunUntilIdle(); |
| 69 } | 70 } |
| 70 | 71 |
| 71 void BluetoothTestBase::TearDown() { | 72 void BluetoothTestBase::TearDown() { |
| 72 EXPECT_EQ(expected_success_callback_calls_, actual_success_callback_calls_); | 73 EXPECT_EQ(expected_success_callback_calls_, actual_success_callback_calls_); |
| 73 EXPECT_EQ(expected_error_callback_calls_, actual_error_callback_calls_); | 74 EXPECT_EQ(expected_error_callback_calls_, actual_error_callback_calls_); |
| 74 EXPECT_FALSE(unexpected_success_callback_); | 75 EXPECT_FALSE(unexpected_success_callback_); |
| 75 EXPECT_FALSE(unexpected_error_callback_); | 76 EXPECT_FALSE(unexpected_error_callback_); |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 gatt_disconnection_attempts_ = 0; | 334 gatt_disconnection_attempts_ = 0; |
| 334 gatt_discovery_attempts_ = 0; | 335 gatt_discovery_attempts_ = 0; |
| 335 gatt_notify_characteristic_attempts_ = 0; | 336 gatt_notify_characteristic_attempts_ = 0; |
| 336 gatt_read_characteristic_attempts_ = 0; | 337 gatt_read_characteristic_attempts_ = 0; |
| 337 gatt_write_characteristic_attempts_ = 0; | 338 gatt_write_characteristic_attempts_ = 0; |
| 338 gatt_read_descriptor_attempts_ = 0; | 339 gatt_read_descriptor_attempts_ = 0; |
| 339 gatt_write_descriptor_attempts_ = 0; | 340 gatt_write_descriptor_attempts_ = 0; |
| 340 } | 341 } |
| 341 | 342 |
| 342 } // namespace device | 343 } // namespace device |
| OLD | NEW |