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 #ifndef DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ | 5 #ifndef DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ |
6 #define DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ | 6 #define DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 virtual void InitWithoutDefaultAdapter() {} | 84 virtual void InitWithoutDefaultAdapter() {} |
85 | 85 |
86 // Initializes the BluetoothAdapter |adapter_| with a fake adapter that can be | 86 // Initializes the BluetoothAdapter |adapter_| with a fake adapter that can be |
87 // controlled by this test fixture. | 87 // controlled by this test fixture. |
88 virtual void InitWithFakeAdapter() {} | 88 virtual void InitWithFakeAdapter() {} |
89 | 89 |
90 // Configures the fake adapter to lack the necessary permissions to scan for | 90 // Configures the fake adapter to lack the necessary permissions to scan for |
91 // devices. Returns false if the current platform always has permission. | 91 // devices. Returns false if the current platform always has permission. |
92 virtual bool DenyPermission(); | 92 virtual bool DenyPermission(); |
93 | 93 |
| 94 // Configure the device to be bonded. |
| 95 virtual void SetBonded(BluetoothDevice* device) {} |
| 96 |
94 // Create a fake Low Energy device and discover it. | 97 // Create a fake Low Energy device and discover it. |
95 // |device_ordinal| selects between multiple fake device data sets to produce: | 98 // |device_ordinal| selects between multiple fake device data sets to produce: |
96 // 1: kTestDeviceName with advertised UUIDs kTestUUIDGenericAccess, | 99 // 1: kTestDeviceName with advertised UUIDs kTestUUIDGenericAccess, |
97 // kTestUUIDGenericAttribute and address kTestDeviceAddress1. | 100 // kTestUUIDGenericAttribute and address kTestDeviceAddress1. |
98 // 2: kTestDeviceName with advertised UUIDs kTestUUIDImmediateAlert, | 101 // 2: kTestDeviceName with advertised UUIDs kTestUUIDImmediateAlert, |
99 // kTestUUIDLinkLoss and address kTestDeviceAddress1. | 102 // kTestUUIDLinkLoss and address kTestDeviceAddress1. |
100 // 3: kTestDeviceNameEmpty with no advertised UUIDs and address | 103 // 3: kTestDeviceNameEmpty with no advertised UUIDs and address |
101 // kTestDeviceAddress1. | 104 // kTestDeviceAddress1. |
102 // 4: kTestDeviceNameEmpty with no advertised UUIDs and address | 105 // 4: kTestDeviceNameEmpty with no advertised UUIDs and address |
103 // kTestDeviceAddress2. | 106 // kTestDeviceAddress2. |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 BluetoothRemoteGattCharacteristic* characteristic); | 360 BluetoothRemoteGattCharacteristic* characteristic); |
358 base::Callback<void(BluetoothGattService::GattErrorCode)> | 361 base::Callback<void(BluetoothGattService::GattErrorCode)> |
359 GetReentrantStartNotifySessionErrorCallback( | 362 GetReentrantStartNotifySessionErrorCallback( |
360 Call expected, | 363 Call expected, |
361 BluetoothRemoteGattCharacteristic* characteristic, | 364 BluetoothRemoteGattCharacteristic* characteristic, |
362 bool error_in_reentrant); | 365 bool error_in_reentrant); |
363 | 366 |
364 // Reset all event count members to 0. | 367 // Reset all event count members to 0. |
365 void ResetEventCounts(); | 368 void ResetEventCounts(); |
366 | 369 |
| 370 void RemoveTimedOutDevices(); |
| 371 |
367 // A Message loop is required by some implementations that will PostTasks and | 372 // A Message loop is required by some implementations that will PostTasks and |
368 // by base::RunLoop().RunUntilIdle() use in this fixture. | 373 // by base::RunLoop().RunUntilIdle() use in this fixture. |
369 base::MessageLoop message_loop_; | 374 base::MessageLoop message_loop_; |
370 | 375 |
371 scoped_refptr<BluetoothAdapter> adapter_; | 376 scoped_refptr<BluetoothAdapter> adapter_; |
372 ScopedVector<BluetoothDiscoverySession> discovery_sessions_; | 377 ScopedVector<BluetoothDiscoverySession> discovery_sessions_; |
373 ScopedVector<BluetoothGattConnection> gatt_connections_; | 378 ScopedVector<BluetoothGattConnection> gatt_connections_; |
374 enum BluetoothDevice::ConnectErrorCode last_connect_error_code_ = | 379 enum BluetoothDevice::ConnectErrorCode last_connect_error_code_ = |
375 BluetoothDevice::ERROR_UNKNOWN; | 380 BluetoothDevice::ERROR_UNKNOWN; |
376 ScopedVector<BluetoothGattNotifySession> notify_sessions_; | 381 ScopedVector<BluetoothGattNotifySession> notify_sessions_; |
(...skipping 20 matching lines...) Expand all Loading... |
397 int actual_error_callback_calls_ = 0; | 402 int actual_error_callback_calls_ = 0; |
398 bool unexpected_success_callback_ = false; | 403 bool unexpected_success_callback_ = false; |
399 bool unexpected_error_callback_ = false; | 404 bool unexpected_error_callback_ = false; |
400 | 405 |
401 base::WeakPtrFactory<BluetoothTestBase> weak_factory_; | 406 base::WeakPtrFactory<BluetoothTestBase> weak_factory_; |
402 }; | 407 }; |
403 | 408 |
404 } // namespace device | 409 } // namespace device |
405 | 410 |
406 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ | 411 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ |
OLD | NEW |