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 3a35167d200d6a13e816edc70a57202348046e89..da6502a8de5ba2235dcc0b7638f26ac6f18436ee 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 |
| @@ -8,6 +8,7 @@ import android.annotation.TargetApi; |
| import android.bluetooth.BluetoothDevice; |
| import android.bluetooth.le.ScanFilter; |
| import android.bluetooth.le.ScanSettings; |
| +import android.content.Context; |
| import android.os.Build; |
| import android.os.ParcelUuid; |
| @@ -179,6 +180,7 @@ class Fakes { |
| static class FakeBluetoothDevice extends Wrappers.BluetoothDeviceWrapper { |
| private String mAddress; |
| private String mName; |
| + private Wrappers.BluetoothGattCallbackWrapper mGattCallback; |
| public FakeBluetoothDevice(String address, String name) { |
| super(null); |
| @@ -186,6 +188,31 @@ class Fakes { |
| mName = name; |
| } |
| + // Create a call to onConnectionStateChange on the |chrome_device| using parameters |
| + // |status| & |connected|. |
| + @CalledByNative("FakeBluetoothDevice") |
| + private static void connectionStateChange( |
| + ChromeBluetoothDevice chromeDevice, int status, boolean connected) { |
| + FakeBluetoothDevice fakeDevice = (FakeBluetoothDevice) chromeDevice.mDevice; |
| + fakeDevice.mGattCallback.onConnectionStateChange(status, connected |
| + ? android.bluetooth.BluetoothProfile.STATE_CONNECTED |
| + : android.bluetooth.BluetoothProfile.STATE_DISCONNECTED); |
| + } |
| + |
| + // ----------------------------------------------------------------------------------------- |
| + // Wrappers.BluetoothDeviceWrapper overrides: |
| + |
| + @Override |
| + public Wrappers.BluetoothGattWrapper connectGatt(Context context, boolean autoConnect, |
| + Wrappers.BluetoothGattCallbackWrapper callback) { |
| + if (mGattCallback != null && mGattCallback != callback) { |
| + throw new IllegalArgumentException( |
| + "Multiple callbacks provided to connectGatt unsupported."); |
|
Jeffrey Yasskin
2015/09/16 01:40:49
"BluetoothGattWrapper doesn't support calls to con
scheib
2015/09/16 21:55:17
Done.
|
| + } |
| + mGattCallback = callback; |
| + return new FakeBluetoothGatt(); |
| + } |
| + |
| @Override |
| public String getAddress() { |
| return mAddress; |
| @@ -206,4 +233,16 @@ class Fakes { |
| return mName; |
| } |
| } |
| + |
| + /** |
| + * Fakes android.bluetooth.BluetoothDevice. |
| + */ |
| + static class FakeBluetoothGatt extends Wrappers.BluetoothGattWrapper { |
| + public FakeBluetoothGatt() { |
| + super(null); |
| + } |
| + |
| + @Override |
| + public void disconnect() {} |
| + } |
| } |