Chromium Code Reviews| Index: device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java |
| diff --git a/device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java b/device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java |
| index f9656e9182ac5f805b1da0f7009b861409a72e24..56c950edf773b663fcd3481b7299b1f29b9296ff 100644 |
| --- a/device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java |
| +++ b/device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java |
| @@ -306,6 +306,7 @@ class Fakes { |
| boolean mReadCharacteristicWillFailSynchronouslyOnce = false; |
| boolean mSetCharacteristicNotificationWillFailSynchronouslyOnce = false; |
| boolean mWriteCharacteristicWillFailSynchronouslyOnce = false; |
| + boolean mWriteDescriptorWillFailSynchronouslyOnce = false; |
| public FakeBluetoothGatt(FakeBluetoothDevice device) { |
| super(null, null); |
| @@ -361,6 +362,17 @@ class Fakes { |
| mDevice.mAdapter.mNativeBluetoothTestAndroid, characteristic.getValue()); |
| return true; |
| } |
| + |
| + @Override |
| + boolean writeDescriptor(Wrappers.BluetoothGattDescriptorWrapper descriptor) { |
| + if (mWriteDescriptorWillFailSynchronouslyOnce) { |
| + mWriteDescriptorWillFailSynchronouslyOnce = false; |
| + return false; |
| + } |
| + nativeOnFakeBluetoothGattWriteDescriptor( |
| + mDevice.mAdapter.mNativeBluetoothTestAndroid, descriptor.getValue()); |
| + return true; |
| + } |
| } |
| /** |
| @@ -533,7 +545,8 @@ class Fakes { |
| + uuidString + "' that has already been added to this characteristic."); |
| } |
| } |
| - fakeCharacteristic.mDescriptors.add(new FakeBluetoothGattDescriptor(uuid)); |
| + fakeCharacteristic.mDescriptors.add( |
| + new FakeBluetoothGattDescriptor(fakeCharacteristic, uuid)); |
| } |
| // ----------------------------------------------------------------------------------------- |
| @@ -575,11 +588,27 @@ class Fakes { |
| * Fakes android.bluetooth.BluetoothGattDescriptor. |
| */ |
| static class FakeBluetoothGattDescriptor extends Wrappers.BluetoothGattDescriptorWrapper { |
| + final FakeBluetoothGattCharacteristic mCharacteristic; |
| final UUID mUuid; |
| + byte[] mValue; |
| - public FakeBluetoothGattDescriptor(UUID uuid) { |
| + public FakeBluetoothGattDescriptor( |
| + FakeBluetoothGattCharacteristic characteristic, UUID uuid) { |
| super(null); |
| + mCharacteristic = characteristic; |
| mUuid = uuid; |
| + mValue = new byte[0]; |
| + } |
| + |
| + // Cause subsequent value write of a descriptor to fail synchronously. |
|
Jeffrey Yasskin
2016/01/13 01:52:34
I guess we don't need the 'read' version yet, beca
scheib
2016/01/13 02:01:26
Affirmative.
|
| + @CalledByNative("FakeBluetoothGattDescriptor") |
| + private static void setWriteDescriptorWillFailSynchronouslyOnce( |
| + ChromeBluetoothRemoteGattDescriptor chromeDescriptor) { |
| + FakeBluetoothGattDescriptor fakeDescriptor = |
| + (FakeBluetoothGattDescriptor) chromeDescriptor.mDescriptor; |
| + |
| + fakeDescriptor.mCharacteristic.mService.mDevice.mGatt |
| + .mWriteDescriptorWillFailSynchronouslyOnce = true; |
| } |
| // ----------------------------------------------------------------------------------------- |
| @@ -589,6 +618,17 @@ class Fakes { |
| public UUID getUuid() { |
| return mUuid; |
| } |
| + |
| + @Override |
| + public byte[] getValue() { |
| + return mValue; |
| + } |
| + |
| + @Override |
| + public boolean setValue(byte[] value) { |
| + mValue = value; |
| + return true; |
| + } |
| } |
| // --------------------------------------------------------------------------------------------- |
| @@ -616,4 +656,8 @@ class Fakes { |
| // Binds to BluetoothTestAndroid::OnFakeBluetoothGattWriteCharacteristic. |
| private static native void nativeOnFakeBluetoothGattWriteCharacteristic( |
| long nativeBluetoothTestAndroid, byte[] value); |
| + |
| + // Binds to BluetoothTestAndroid::OnFakeBluetoothGattWriteDescriptor. |
| + private static native void nativeOnFakeBluetoothGattWriteDescriptor( |
| + long nativeBluetoothTestAndroid, byte[] value); |
| } |