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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 BluetoothRemoteGattCharacteristic* characteristic) {} | 180 BluetoothRemoteGattCharacteristic* characteristic) {} |
181 | 181 |
182 // Simulates a Characteristic Set Notify error. | 182 // Simulates a Characteristic Set Notify error. |
183 // If |characteristic| is null, acts upon the characteristic & CCC | 183 // If |characteristic| is null, acts upon the characteristic & CCC |
184 // descriptor provided to RememberCharacteristicForSubsequentAction & | 184 // descriptor provided to RememberCharacteristicForSubsequentAction & |
185 // RememberCCCDescriptorForSubsequentAction. | 185 // RememberCCCDescriptorForSubsequentAction. |
186 virtual void SimulateGattNotifySessionStartError( | 186 virtual void SimulateGattNotifySessionStartError( |
187 BluetoothRemoteGattCharacteristic* characteristic, | 187 BluetoothRemoteGattCharacteristic* characteristic, |
188 BluetoothRemoteGattService::GattErrorCode error_code) {} | 188 BluetoothRemoteGattService::GattErrorCode error_code) {} |
189 | 189 |
190 // Simulates a Characteristic Stop Notify completed. | |
191 // If |characteristic| is null, acts upon the characteristic & CCC | |
192 // descriptor provided to RememberCharacteristicForSubsequentAction & | |
193 // RememberCCCDescriptorForSubsequentAction. | |
194 virtual void SimulateGattNotifySessionStopped( | |
195 BluetoothRemoteGattCharacteristic* characteristic) {} | |
196 | |
197 // Simulates a Characteristic Stop Notify error. | |
198 // If |characteristic| is null, acts upon the characteristic & CCC | |
199 // descriptor provided to RememberCharacteristicForSubsequentAction & | |
200 // RememberCCCDescriptorForSubsequentAction. | |
201 virtual void SimulateGattNotifySessionStopError( | |
202 BluetoothRemoteGattCharacteristic* characteristic, | |
203 BluetoothRemoteGattService::GattErrorCode error_code) {} | |
204 | |
205 // Simulates a Characteristic Set Notify operation failing synchronously once | 190 // Simulates a Characteristic Set Notify operation failing synchronously once |
206 // for an unknown reason. | 191 // for an unknown reason. |
207 virtual void SimulateGattCharacteristicSetNotifyWillFailSynchronouslyOnce( | 192 virtual void SimulateGattCharacteristicSetNotifyWillFailSynchronouslyOnce( |
208 BluetoothRemoteGattCharacteristic* characteristic) {} | 193 BluetoothRemoteGattCharacteristic* characteristic) {} |
209 | 194 |
210 // Simulates a Characteristic Changed operation with updated |value|. | 195 // Simulates a Characteristic Changed operation with updated |value|. |
211 virtual void SimulateGattCharacteristicChanged( | 196 virtual void SimulateGattCharacteristicChanged( |
212 BluetoothRemoteGattCharacteristic* characteristic, | 197 BluetoothRemoteGattCharacteristic* characteristic, |
213 const std::vector<uint8_t>& value) {} | 198 const std::vector<uint8_t>& value) {} |
214 | 199 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 virtual void DeleteDevice(BluetoothDevice* device); | 331 virtual void DeleteDevice(BluetoothDevice* device); |
347 | 332 |
348 // Callbacks that increment |callback_count_|, |error_callback_count_|: | 333 // Callbacks that increment |callback_count_|, |error_callback_count_|: |
349 void Callback(Call expected); | 334 void Callback(Call expected); |
350 void DiscoverySessionCallback(Call expected, | 335 void DiscoverySessionCallback(Call expected, |
351 std::unique_ptr<BluetoothDiscoverySession>); | 336 std::unique_ptr<BluetoothDiscoverySession>); |
352 void GattConnectionCallback(Call expected, | 337 void GattConnectionCallback(Call expected, |
353 std::unique_ptr<BluetoothGattConnection>); | 338 std::unique_ptr<BluetoothGattConnection>); |
354 void NotifyCallback(Call expected, | 339 void NotifyCallback(Call expected, |
355 std::unique_ptr<BluetoothGattNotifySession>); | 340 std::unique_ptr<BluetoothGattNotifySession>); |
356 void NotifyCheckForPrecedingCalls( | |
357 int num_of_preceding_calls, | |
358 std::unique_ptr<BluetoothGattNotifySession>); | |
359 void StopNotifyCallback(Call expected); | |
360 void StopNotifyCheckForPrecedingCalls(int num_of_preceding_calls); | |
361 void ReadValueCallback(Call expected, const std::vector<uint8_t>& value); | 341 void ReadValueCallback(Call expected, const std::vector<uint8_t>& value); |
362 void ErrorCallback(Call expected); | 342 void ErrorCallback(Call expected); |
363 void ConnectErrorCallback(Call expected, | 343 void ConnectErrorCallback(Call expected, |
364 enum BluetoothDevice::ConnectErrorCode); | 344 enum BluetoothDevice::ConnectErrorCode); |
365 void GattErrorCallback(Call expected, | 345 void GattErrorCallback(Call expected, |
366 BluetoothRemoteGattService::GattErrorCode); | 346 BluetoothRemoteGattService::GattErrorCode); |
367 void ReentrantStartNotifySessionSuccessCallback( | 347 void ReentrantStartNotifySessionSuccessCallback( |
368 Call expected, | 348 Call expected, |
369 BluetoothRemoteGattCharacteristic* characteristic, | 349 BluetoothRemoteGattCharacteristic* characteristic, |
370 std::unique_ptr<BluetoothGattNotifySession> notify_session); | 350 std::unique_ptr<BluetoothGattNotifySession> notify_session); |
371 void ReentrantStartNotifySessionErrorCallback( | 351 void ReentrantStartNotifySessionErrorCallback( |
372 Call expected, | 352 Call expected, |
373 BluetoothRemoteGattCharacteristic* characteristic, | 353 BluetoothRemoteGattCharacteristic* characteristic, |
374 bool error_in_reentrant, | 354 bool error_in_reentrant, |
375 BluetoothGattService::GattErrorCode error_code); | 355 BluetoothGattService::GattErrorCode error_code); |
376 | 356 |
377 // Accessors to get callbacks bound to this fixture: | 357 // Accessors to get callbacks bound to this fixture: |
378 base::Closure GetCallback(Call expected); | 358 base::Closure GetCallback(Call expected); |
379 BluetoothAdapter::DiscoverySessionCallback GetDiscoverySessionCallback( | 359 BluetoothAdapter::DiscoverySessionCallback GetDiscoverySessionCallback( |
380 Call expected); | 360 Call expected); |
381 BluetoothDevice::GattConnectionCallback GetGattConnectionCallback( | 361 BluetoothDevice::GattConnectionCallback GetGattConnectionCallback( |
382 Call expected); | 362 Call expected); |
383 BluetoothRemoteGattCharacteristic::NotifySessionCallback GetNotifyCallback( | 363 BluetoothRemoteGattCharacteristic::NotifySessionCallback GetNotifyCallback( |
384 Call expected); | 364 Call expected); |
385 BluetoothRemoteGattCharacteristic::NotifySessionCallback | |
386 GetNotifyCheckForPrecedingCalls(int num_of_preceding_calls); | |
387 base::Closure GetStopNotifyCallback(Call expected); | |
388 base::Closure GetStopNotifyCheckForPrecedingCalls(int num_of_preceding_calls); | |
389 BluetoothRemoteGattCharacteristic::ValueCallback GetReadValueCallback( | 365 BluetoothRemoteGattCharacteristic::ValueCallback GetReadValueCallback( |
390 Call expected); | 366 Call expected); |
391 BluetoothAdapter::ErrorCallback GetErrorCallback(Call expected); | 367 BluetoothAdapter::ErrorCallback GetErrorCallback(Call expected); |
392 BluetoothDevice::ConnectErrorCallback GetConnectErrorCallback(Call expected); | 368 BluetoothDevice::ConnectErrorCallback GetConnectErrorCallback(Call expected); |
393 base::Callback<void(BluetoothRemoteGattService::GattErrorCode)> | 369 base::Callback<void(BluetoothRemoteGattService::GattErrorCode)> |
394 GetGattErrorCallback(Call expected); | 370 GetGattErrorCallback(Call expected); |
395 BluetoothRemoteGattCharacteristic::NotifySessionCallback | 371 BluetoothRemoteGattCharacteristic::NotifySessionCallback |
396 GetReentrantStartNotifySessionSuccessCallback( | 372 GetReentrantStartNotifySessionSuccessCallback( |
397 Call expected, | 373 Call expected, |
398 BluetoothRemoteGattCharacteristic* characteristic); | 374 BluetoothRemoteGattCharacteristic* characteristic); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 int actual_error_callback_calls_ = 0; | 416 int actual_error_callback_calls_ = 0; |
441 bool unexpected_success_callback_ = false; | 417 bool unexpected_success_callback_ = false; |
442 bool unexpected_error_callback_ = false; | 418 bool unexpected_error_callback_ = false; |
443 | 419 |
444 base::WeakPtrFactory<BluetoothTestBase> weak_factory_; | 420 base::WeakPtrFactory<BluetoothTestBase> weak_factory_; |
445 }; | 421 }; |
446 | 422 |
447 } // namespace device | 423 } // namespace device |
448 | 424 |
449 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ | 425 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ |
OLD | NEW |