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..ced06b315d1640fe704090ea28a6c312faadf012 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,32 @@ 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, |
|
Jeffrey Yasskin
2015/09/16 23:42:49
I'd like to see this report back to C++ that it wa
scheib
2015/09/20 02:53:35
Done.
|
| + Wrappers.BluetoothGattCallbackWrapper callback) { |
| + if (mGattCallback != null && mGattCallback != callback) { |
| + throw new IllegalArgumentException( |
| + "BluetoothGattWrapper doesn't support calls to connectGatt() with " |
| + + "multiple distinct callbacks."); |
| + } |
| + mGattCallback = callback; |
| + return new FakeBluetoothGatt(); |
| + } |
| + |
| @Override |
| public String getAddress() { |
| return mAddress; |
| @@ -206,4 +234,16 @@ class Fakes { |
| return mName; |
| } |
| } |
| + |
| + /** |
| + * Fakes android.bluetooth.BluetoothDevice. |
| + */ |
| + static class FakeBluetoothGatt extends Wrappers.BluetoothGattWrapper { |
| + public FakeBluetoothGatt() { |
| + super(null); |
| + } |
| + |
| + @Override |
| + public void disconnect() {} |
|
Jeffrey Yasskin
2015/09/16 23:42:49
Like connectGatt(), I'd like to see assertions tha
scheib
2015/09/20 02:53:35
Done.
|
| + } |
| } |