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 062c3c8b38c6486b7cbd3246d2b3a3f0ff380156..1280cc154aa230044f33b4635b5adac6d812ec1b 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 |
| @@ -17,7 +17,9 @@ import org.chromium.base.annotations.CalledByNative; |
| import org.chromium.base.annotations.JNINamespace; |
| import java.util.ArrayList; |
| +import java.util.HashMap; |
| import java.util.List; |
| +import java.util.UUID; |
| /** |
| * Fake implementations of android.bluetooth.* classes for testing. |
| @@ -212,15 +214,20 @@ class Fakes { |
| // Create a call to onServicesDiscovered on the |chrome_device| using parameter |
| // |status|. |
| @CalledByNative("FakeBluetoothDevice") |
| - private static void servicesDiscovered(ChromeBluetoothDevice chromeDevice, int status) { |
| + private static void servicesDiscovered( |
| + ChromeBluetoothDevice chromeDevice, int status, String uuidsSpaceDelimited) { |
| FakeBluetoothDevice fakeDevice = (FakeBluetoothDevice) chromeDevice.mDevice; |
| - // TODO(scheib): Add more control over how many services are created and |
| - // their properties. http://crbug.com/541400 |
| if (status == android.bluetooth.BluetoothGatt.GATT_SUCCESS) { |
| fakeDevice.mGatt.mServices.clear(); |
| - fakeDevice.mGatt.mServices.add(new FakeBluetoothGattService(0)); |
| - fakeDevice.mGatt.mServices.add(new FakeBluetoothGattService(1)); |
| + HashMap<String, Integer> uuidsToInstanceIdMap = new HashMap<String, Integer>(); |
| + for (String uuid : uuidsSpaceDelimited.split(" ")) { |
| + Integer previousId = uuidsToInstanceIdMap.get(uuid); |
| + int instanceId = (previousId == null) ? 0 : previousId + 1; |
| + uuidsToInstanceIdMap.put(uuid, instanceId); |
| + fakeDevice.mGatt.mServices.add( |
| + new FakeBluetoothGattService(UUID.fromString(uuid), instanceId)); |
| + } |
| } |
| fakeDevice.mGattCallback.onServicesDiscovered(status); |
| @@ -296,10 +303,12 @@ class Fakes { |
| * Fakes android.bluetooth.BluetoothGattService. |
| */ |
| static class FakeBluetoothGattService extends Wrappers.BluetoothGattServiceWrapper { |
| + final UUID mUuid; |
| final int mInstanceId; |
| - public FakeBluetoothGattService(int instanceId) { |
| + public FakeBluetoothGattService(UUID uuid, int instanceId) { |
| super(null); |
| + mUuid = uuid; |
| mInstanceId = instanceId; |
| } |
| @@ -307,6 +316,11 @@ class Fakes { |
| public int getInstanceId() { |
| return mInstanceId; |
| } |
| + |
| + @Override |
| + public UUID getUuid() { |
|
Jeffrey Yasskin
2015/10/15 23:48:30
Nit: Put the accessors in the same order as the fi
scheib
2015/10/16 00:23:36
Done. - but fixing fields. The method order here m
|
| + return mUuid; |
| + } |
| } |
| // --------------------------------------------------------------------------------------------- |