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..c242cf165e667d8d80111faac09358dd08e0c521 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,33 @@ class Fakes { |
| mName = name; |
| } |
| + // Create a call to onConnectionStateChange on the |chrome_device| using parameters |
| + // |success| & |connected|. |
| + @CalledByNative("FakeBluetoothDevice") |
| + private static void connectionStateChange( |
| + ChromeBluetoothDevice chromeDevice, boolean success, boolean connected) { |
| + FakeBluetoothDevice fakeDevice = (FakeBluetoothDevice) chromeDevice.mDevice; |
| + fakeDevice.mGattCallback.onConnectionStateChange(success |
| + ? android.bluetooth.BluetoothGatt.GATT_SUCCESS |
| + : android.bluetooth.BluetoothGatt.GATT_FAILURE, |
|
Jeffrey Yasskin
2015/08/20 21:35:14
Make it possible to test more status codes?
scheib
2015/09/13 02:41:01
Done.
|
| + 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) { |
| + throw new IllegalArgumentException( |
| + "FakeBluetoothDevice does not support multiple calls to connectGatt."); |
| + } |
| + mGattCallback = callback; |
| + return new FakeBluetoothGatt(); |
| + } |
| + |
| @Override |
| public String getAddress() { |
| return mAddress; |
| @@ -206,4 +235,24 @@ class Fakes { |
| return mName; |
| } |
| } |
| + |
| + /** |
| + * Fakes android.bluetooth.BluetoothDevice. |
| + */ |
| + static class FakeBluetoothGatt extends Wrappers.BluetoothGattWrapper { |
| + public FakeBluetoothGatt() { |
| + super(null); |
| + } |
| + |
| + @Override |
| + public boolean connect() { |
| + // TODO test |
| + // TODO test |
| + // TODO test |
| + return true; |
| + } |
| + |
| + @Override |
| + public void disconnect() {} |
| + } |
| } |