Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(532)

Unified Diff: device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java

Issue 1395783005: bluetooth: android: BluetoothRemoteGattServiceAndroid::GetUUID (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed jyasskin comments Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/bluetooth/bluetooth_remote_gatt_service_android.cc ('k') | device/bluetooth/test/bluetooth_test.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2499c7b255837b721b25c13aad626ea4a9785e9c 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);
@@ -297,9 +304,11 @@ class Fakes {
*/
static class FakeBluetoothGattService extends Wrappers.BluetoothGattServiceWrapper {
final int mInstanceId;
+ final UUID mUuid;
- 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() {
+ return mUuid;
+ }
}
// ---------------------------------------------------------------------------------------------
« no previous file with comments | « device/bluetooth/bluetooth_remote_gatt_service_android.cc ('k') | device/bluetooth/test/bluetooth_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698