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 "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // kTestUUIDGenericAttribute and address kTestDeviceAddress1. | 68 // kTestUUIDGenericAttribute and address kTestDeviceAddress1. |
69 // 2: kTestDeviceName with advertised UUIDs kTestUUIDImmediateAlert, | 69 // 2: kTestDeviceName with advertised UUIDs kTestUUIDImmediateAlert, |
70 // kTestUUIDLinkLoss and address kTestDeviceAddress1. | 70 // kTestUUIDLinkLoss and address kTestDeviceAddress1. |
71 // 3: kTestDeviceNameEmpty with no advertised UUIDs and address | 71 // 3: kTestDeviceNameEmpty with no advertised UUIDs and address |
72 // kTestDeviceAddress1. | 72 // kTestDeviceAddress1. |
73 // 4: kTestDeviceNameEmpty with no advertised UUIDs and address | 73 // 4: kTestDeviceNameEmpty with no advertised UUIDs and address |
74 // kTestDeviceAddress2. | 74 // kTestDeviceAddress2. |
75 virtual BluetoothDevice* DiscoverLowEnergyDevice(int device_ordinal); | 75 virtual BluetoothDevice* DiscoverLowEnergyDevice(int device_ordinal); |
76 | 76 |
77 // Simulates success of implementation details of CreateGattConnection. | 77 // Simulates success of implementation details of CreateGattConnection. |
78 virtual void CompleteGattConnection(BluetoothDevice* device) {} | 78 virtual void SimulateGattConnection(BluetoothDevice* device) {} |
79 | 79 |
80 // Simulates failure of CreateGattConnection with the given error code. | 80 // Simulates failure of CreateGattConnection with the given error code. |
81 virtual void FailGattConnection(BluetoothDevice* device, | 81 virtual void SimulateGattConnectionError(BluetoothDevice* device, |
82 BluetoothDevice::ConnectErrorCode) {} | 82 BluetoothDevice::ConnectErrorCode) {} |
83 | 83 |
84 // Simulates GattConnection disconnecting. | 84 // Simulates GattConnection disconnecting. |
85 virtual void CompleteGattDisconnection(BluetoothDevice* device) {} | 85 virtual void SimulateGattDisconnection(BluetoothDevice* device) {} |
86 | 86 |
87 // Remove the device from the adapter and delete it. | 87 // Remove the device from the adapter and delete it. |
88 virtual void DeleteDevice(BluetoothDevice* device); | 88 virtual void DeleteDevice(BluetoothDevice* device); |
89 | 89 |
90 // Callbacks that increment |callback_count_|, |error_callback_count_|: | 90 // Callbacks that increment |callback_count_|, |error_callback_count_|: |
91 void Callback(); | 91 void Callback(); |
92 void DiscoverySessionCallback(scoped_ptr<BluetoothDiscoverySession>); | 92 void DiscoverySessionCallback(scoped_ptr<BluetoothDiscoverySession>); |
93 void GattConnectionCallback(scoped_ptr<BluetoothGattConnection>); | 93 void GattConnectionCallback(scoped_ptr<BluetoothGattConnection>); |
94 void ErrorCallback(); | 94 void ErrorCallback(); |
95 void ConnectErrorCallback(enum BluetoothDevice::ConnectErrorCode); | 95 void ConnectErrorCallback(enum BluetoothDevice::ConnectErrorCode); |
(...skipping 12 matching lines...) Expand all Loading... |
108 // by base::RunLoop().RunUntilIdle() use in this fixuture. | 108 // by base::RunLoop().RunUntilIdle() use in this fixuture. |
109 base::MessageLoop message_loop_; | 109 base::MessageLoop message_loop_; |
110 | 110 |
111 scoped_refptr<BluetoothAdapter> adapter_; | 111 scoped_refptr<BluetoothAdapter> adapter_; |
112 ScopedVector<BluetoothDiscoverySession> discovery_sessions_; | 112 ScopedVector<BluetoothDiscoverySession> discovery_sessions_; |
113 ScopedVector<BluetoothGattConnection> gatt_connections_; | 113 ScopedVector<BluetoothGattConnection> gatt_connections_; |
114 enum BluetoothDevice::ConnectErrorCode last_connect_error_code_ = | 114 enum BluetoothDevice::ConnectErrorCode last_connect_error_code_ = |
115 BluetoothDevice::ERROR_UNKNOWN; | 115 BluetoothDevice::ERROR_UNKNOWN; |
116 int callback_count_ = 0; | 116 int callback_count_ = 0; |
117 int error_callback_count_ = 0; | 117 int error_callback_count_ = 0; |
118 int gatt_connection_attempt_count_ = 0; | 118 int gatt_connection_attempts_ = 0; |
119 int gatt_disconnection_attempt_count_ = 0; | 119 int gatt_disconnection_attempts_ = 0; |
120 base::WeakPtrFactory<BluetoothTestBase> weak_factory_; | 120 base::WeakPtrFactory<BluetoothTestBase> weak_factory_; |
121 }; | 121 }; |
122 | 122 |
123 } // namespace device | 123 } // namespace device |
124 | 124 |
125 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ | 125 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ |
OLD | NEW |