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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 // - Services: [ kTestUUIDGenericAccess ] | 49 // - Services: [ kTestUUIDGenericAccess ] |
50 // HEART_RATE_DEVICE: | 50 // HEART_RATE_DEVICE: |
51 // - Name: kTestDeviceName | 51 // - Name: kTestDeviceName |
52 // - Address: kTestPeripheralUUID2 | 52 // - Address: kTestPeripheralUUID2 |
53 // - Services: [ kTestUUIDGenericAccess, kTestUUIDHeartRate] | 53 // - Services: [ kTestUUIDGenericAccess, kTestUUIDHeartRate] |
54 enum class ConnectedDeviceType { | 54 enum class ConnectedDeviceType { |
55 GENERIC_DEVICE, | 55 GENERIC_DEVICE, |
56 HEART_RATE_DEVICE, | 56 HEART_RATE_DEVICE, |
57 }; | 57 }; |
58 | 58 |
| 59 enum class NotifyValueState { |
| 60 NONE, |
| 61 NOTIFY, |
| 62 INDICATE, |
| 63 }; |
| 64 |
59 static const std::string kTestAdapterName; | 65 static const std::string kTestAdapterName; |
60 static const std::string kTestAdapterAddress; | 66 static const std::string kTestAdapterAddress; |
61 | 67 |
62 static const std::string kTestDeviceName; | 68 static const std::string kTestDeviceName; |
63 static const std::string kTestDeviceNameEmpty; | 69 static const std::string kTestDeviceNameEmpty; |
64 | 70 |
65 static const std::string kTestDeviceAddress1; | 71 static const std::string kTestDeviceAddress1; |
66 static const std::string kTestDeviceAddress2; | 72 static const std::string kTestDeviceAddress2; |
67 static const std::string kTestDeviceAddress3; | 73 static const std::string kTestDeviceAddress3; |
68 | 74 |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 // Simulates a Descriptor Write operation failing with a GattErrorCode. | 400 // Simulates a Descriptor Write operation failing with a GattErrorCode. |
395 virtual void SimulateGattDescriptorWriteError( | 401 virtual void SimulateGattDescriptorWriteError( |
396 BluetoothRemoteGattDescriptor* descriptor, | 402 BluetoothRemoteGattDescriptor* descriptor, |
397 BluetoothRemoteGattService::GattErrorCode) {} | 403 BluetoothRemoteGattService::GattErrorCode) {} |
398 | 404 |
399 // Simulates a Descriptor Write operation failing synchronously once for | 405 // Simulates a Descriptor Write operation failing synchronously once for |
400 // an unknown reason. | 406 // an unknown reason. |
401 virtual void SimulateGattDescriptorWriteWillFailSynchronouslyOnce( | 407 virtual void SimulateGattDescriptorWriteWillFailSynchronouslyOnce( |
402 BluetoothRemoteGattDescriptor* descriptor) {} | 408 BluetoothRemoteGattDescriptor* descriptor) {} |
403 | 409 |
| 410 // Tests that functions to change the notify value have been called |attempts| |
| 411 // times. |
| 412 virtual void ExpectedChangeNotifyValueAttempts(int attempts); |
| 413 |
| 414 // Tests that the notify value is |expected_value_state|. The default |
| 415 // implementation checks that the correct value has been written to the CCC |
| 416 // Descriptor. |
| 417 virtual void ExpectedNotifyValue(NotifyValueState expected_value_state); |
| 418 |
404 // Returns a list of local GATT services registered with the adapter. | 419 // Returns a list of local GATT services registered with the adapter. |
405 virtual std::vector<BluetoothLocalGattService*> RegisteredGattServices(); | 420 virtual std::vector<BluetoothLocalGattService*> RegisteredGattServices(); |
406 | 421 |
407 // Removes the device from the adapter and deletes it. | 422 // Removes the device from the adapter and deletes it. |
408 virtual void DeleteDevice(BluetoothDevice* device); | 423 virtual void DeleteDevice(BluetoothDevice* device); |
409 | 424 |
410 // Callbacks that increment |callback_count_|, |error_callback_count_|: | 425 // Callbacks that increment |callback_count_|, |error_callback_count_|: |
411 void Callback(Call expected); | 426 void Callback(Call expected); |
412 void DiscoverySessionCallback(Call expected, | 427 void DiscoverySessionCallback(Call expected, |
413 std::unique_ptr<BluetoothDiscoverySession>); | 428 std::unique_ptr<BluetoothDiscoverySession>); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 GetReentrantStartNotifySessionSuccessCallback( | 473 GetReentrantStartNotifySessionSuccessCallback( |
459 Call expected, | 474 Call expected, |
460 BluetoothRemoteGattCharacteristic* characteristic); | 475 BluetoothRemoteGattCharacteristic* characteristic); |
461 base::Callback<void(BluetoothGattService::GattErrorCode)> | 476 base::Callback<void(BluetoothGattService::GattErrorCode)> |
462 GetReentrantStartNotifySessionErrorCallback( | 477 GetReentrantStartNotifySessionErrorCallback( |
463 Call expected, | 478 Call expected, |
464 BluetoothRemoteGattCharacteristic* characteristic, | 479 BluetoothRemoteGattCharacteristic* characteristic, |
465 bool error_in_reentrant); | 480 bool error_in_reentrant); |
466 | 481 |
467 // Reset all event count members to 0. | 482 // Reset all event count members to 0. |
468 void ResetEventCounts(); | 483 virtual void ResetEventCounts(); |
469 | 484 |
470 void RemoveTimedOutDevices(); | 485 void RemoveTimedOutDevices(); |
471 | 486 |
472 // A Message loop is required by some implementations that will PostTasks and | 487 // A Message loop is required by some implementations that will PostTasks and |
473 // by base::RunLoop().RunUntilIdle() use in this fixture. | 488 // by base::RunLoop().RunUntilIdle() use in this fixture. |
474 base::MessageLoop message_loop_; | 489 base::MessageLoop message_loop_; |
475 | 490 |
476 scoped_refptr<BluetoothAdapter> adapter_; | 491 scoped_refptr<BluetoothAdapter> adapter_; |
477 std::vector<std::unique_ptr<BluetoothDiscoverySession>> discovery_sessions_; | 492 std::vector<std::unique_ptr<BluetoothDiscoverySession>> discovery_sessions_; |
478 std::vector<std::unique_ptr<BluetoothGattConnection>> gatt_connections_; | 493 std::vector<std::unique_ptr<BluetoothGattConnection>> gatt_connections_; |
(...skipping 23 matching lines...) Expand all Loading... |
502 int actual_error_callback_calls_ = 0; | 517 int actual_error_callback_calls_ = 0; |
503 bool unexpected_success_callback_ = false; | 518 bool unexpected_success_callback_ = false; |
504 bool unexpected_error_callback_ = false; | 519 bool unexpected_error_callback_ = false; |
505 | 520 |
506 base::WeakPtrFactory<BluetoothTestBase> weak_factory_; | 521 base::WeakPtrFactory<BluetoothTestBase> weak_factory_; |
507 }; | 522 }; |
508 | 523 |
509 } // namespace device | 524 } // namespace device |
510 | 525 |
511 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ | 526 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ |
OLD | NEW |