From 0348fa65c3d808f854f745fb9f8f185a5b74b922 Mon Sep 17 00:00:00 2001 From: tommyt Date: Mon, 14 Mar 2016 15:12:28 -0700 Subject: bluetooth: android: Confirm the notify session after the descriptor has been written. This change also implements WriteRemoteDescriptor and ReadRemoteDescriptor. Because of this, I've also added quite a few descriptor unit tests. These tests are pretty much the same as the read/write tests for characteristics. BUG=584369 Review URL: https://codereview.chromium.org/1712593002 Cr-Commit-Position: refs/heads/master@{#381088} --- device/bluetooth/test/bluetooth_test.h | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'device/bluetooth/test/bluetooth_test.h') diff --git a/device/bluetooth/test/bluetooth_test.h b/device/bluetooth/test/bluetooth_test.h index 5570ca1..c840935 100644 --- a/device/bluetooth/test/bluetooth_test.h +++ b/device/bluetooth/test/bluetooth_test.h @@ -189,6 +189,41 @@ class BluetoothTestBase : public testing::Test { BluetoothGattCharacteristic* characteristic, const std::string& uuid) {} + // Remembers |descriptor|'s platform specific object to be used in a + // subsequent call to methods such as SimulateGattDescriptorRead that + // accept a nullptr value to select this remembered descriptor. This + // enables tests where the platform attempts to reference descriptor + // objects after the Chrome objects have been deleted, e.g. with DeleteDevice. + virtual void RememberDescriptorForSubsequentAction( + BluetoothGattDescriptor* descriptor) {} + + // Simulates a Descriptor Read operation succeeding, returning |value|. + // If |descriptor| is null, acts upon the descriptor provided to + // RememberDescriptorForSubsequentAction. + virtual void SimulateGattDescriptorRead(BluetoothGattDescriptor* descriptor, + const std::vector& value) {} + + // Simulates a Descriptor Read operation failing with a GattErrorCode. + virtual void SimulateGattDescriptorReadError( + BluetoothGattDescriptor* descriptor, + BluetoothGattService::GattErrorCode) {} + + // Simulates a Descriptor Read operation failing synchronously once for an + // unknown reason. + virtual void SimulateGattDescriptorReadWillFailSynchronouslyOnce( + BluetoothGattDescriptor* descriptor) {} + + // Simulates a Descriptor Write operation succeeding, returning |value|. + // If |descriptor| is null, acts upon the descriptor provided to + // RememberDescriptorForSubsequentAction. + virtual void SimulateGattDescriptorWrite( + BluetoothGattDescriptor* descriptor) {} + + // Simulates a Descriptor Write operation failing with a GattErrorCode. + virtual void SimulateGattDescriptorWriteError( + BluetoothGattDescriptor* descriptor, + BluetoothGattService::GattErrorCode) {} + // Simulates a Descriptor Write operation failing synchronously once for // an unknown reason. virtual void SimulateGattDescriptorWriteWillFailSynchronouslyOnce( @@ -250,6 +285,7 @@ class BluetoothTestBase : public testing::Test { int gatt_notify_characteristic_attempts_ = 0; int gatt_read_characteristic_attempts_ = 0; int gatt_write_characteristic_attempts_ = 0; + int gatt_read_descriptor_attempts_ = 0; int gatt_write_descriptor_attempts_ = 0; // The following values are used to make sure the correct callbacks -- cgit v1.1