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 998450a3a49b79e304583e73de3cb9a86d215947..826678c7c0286cff9e19ecc9a3293cc190e67e04 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 |
| @@ -74,6 +74,52 @@ class Fakes { |
| }); |
| } |
| + static class FakeBluetoothManager extends Wrappers.BluetoothManagerWrapper { |
| + final long mNativeBluetoothTestAndroid; |
| + ArrayList<BluetoothDeviceWrapper> mConnectedDevices; |
| + |
| + @CalledByNative("FakeBluetoothManager") |
| + public static FakeBluetoothManager create(long nativeBluetoothTestAndroid) { |
| + return new FakeBluetoothManager(nativeBluetoothTestAndroid); |
| + } |
| + |
| + private FakeBluetoothManager(long nativeBluetoothTestAndroid) { |
| + super(null); |
| + mNativeBluetoothTestAndroid = nativeBluetoothTestAndroid; |
| + mConnectedDevices = new ArrayList<>(); |
| + } |
| + |
| + @CalledByNative("FakeBluetoothManager") |
| + public void simulateConnectedLowEnergyDevice(int deviceType) { |
|
scheib
2016/11/28 20:42:22
// c++ enum BluetoothTest::ConnectedDeviceType
|
| + switch (deviceType) { |
| + case 0: { |
| + ParcelUuid[] uuids = new ParcelUuid[] { |
| + ParcelUuid.fromString("00001800-0000-1000-8000-00805f9b34fb")}; |
| + mConnectedDevices.add(new FakeBluetoothDevice( |
| + null /* adapter */, "01:00:00:90:1E:BE", "FakeBluetoothDevice", uuids)); |
| + break; |
| + } |
| + case 1: { |
| + ParcelUuid[] uuids = new ParcelUuid[] { |
| + ParcelUuid.fromString("00001800-0000-1000-8000-00805f9b34fb"), |
| + ParcelUuid.fromString("0000180d-0000-1000-8000-00805f9b34fb")}; |
| + mConnectedDevices.add(new FakeBluetoothDevice( |
| + null /* adapter */, "02:00:00:8B:74:63", "FakeBluetoothDevice", uuids)); |
| + break; |
| + } |
| + } |
| + } |
| + |
| + // ----------------------------------------------------------------------------------------- |
| + // BluetoothManagerWrapper overrides: |
| + |
| + @Override |
| + public List<BluetoothDeviceWrapper> getConnectedDevices(int profile) { |
| + nativeOnFakeManagerGetConnectedDevices(mNativeBluetoothTestAndroid); |
| + return mConnectedDevices; |
| + } |
| + } |
| + |
| /** |
| * Fakes android.bluetooth.BluetoothAdapter. |
| */ |
| @@ -299,7 +345,7 @@ class Fakes { |
| } |
| @Override |
| - public Wrappers.BluetoothDeviceWrapper getDevice() { |
| + public BluetoothDeviceWrapper getDevice() { |
| return mDevice; |
| } |
| @@ -322,20 +368,27 @@ class Fakes { |
| /** |
| * Fakes android.bluetooth.BluetoothDevice. |
| */ |
| - static class FakeBluetoothDevice extends Wrappers.BluetoothDeviceWrapper { |
| + static class FakeBluetoothDevice extends BluetoothDeviceWrapper { |
| final FakeBluetoothAdapter mAdapter; |
| private String mAddress; |
| private String mName; |
| + private ParcelUuid[] mUuids; |
| final FakeBluetoothGatt mGatt; |
| private Wrappers.BluetoothGattCallbackWrapper mGattCallback; |
| static FakeBluetoothDevice sRememberedDevice; |
| public FakeBluetoothDevice(FakeBluetoothAdapter adapter, String address, String name) { |
| + this(adapter, address, name, null); |
| + } |
| + |
| + public FakeBluetoothDevice( |
| + FakeBluetoothAdapter adapter, String address, String name, ParcelUuid[] uuids) { |
| super(null); |
| mAdapter = adapter; |
| mAddress = address; |
| mName = name; |
| + mUuids = uuids; |
| mGatt = new FakeBluetoothGatt(this); |
| } |
| @@ -385,7 +438,7 @@ class Fakes { |
| } |
| // ----------------------------------------------------------------------------------------- |
| - // Wrappers.BluetoothDeviceWrapper overrides: |
| + // BluetoothDeviceWrapper overrides: |
| @Override |
| public Wrappers.BluetoothGattWrapper connectGatt(Context context, boolean autoConnect, |
| @@ -407,7 +460,7 @@ class Fakes { |
| @Override |
| public int getBluetoothClass_getDeviceClass() { |
| - return Wrappers.DEVICE_CLASS_UNSPECIFIED; |
| + return BluetoothDeviceWrapper.DEVICE_CLASS_UNSPECIFIED; |
| } |
| @Override |
| @@ -419,6 +472,11 @@ class Fakes { |
| public String getName() { |
| return mName; |
| } |
| + |
| + @Override |
| + public ParcelUuid[] getUuids() { |
| + return mUuids; |
| + } |
| } |
| /** |
| @@ -838,6 +896,10 @@ class Fakes { |
| // --------------------------------------------------------------------------------------------- |
| // BluetoothTestAndroid C++ methods declared for access from java: |
| + // Bind to BluetoothTestAndroid::OnFakeManagerGetConnectedDevices. |
| + private static native void nativeOnFakeManagerGetConnectedDevices( |
| + long nativeBluetoothTestAndroid); |
| + |
| // Binds to BluetoothTestAndroid::OnFakeAdapterStateChanged. |
| private static native void nativeOnFakeAdapterStateChanged( |
| long nativeBluetoothTestAndroid, boolean powered); |