summaryrefslogtreecommitdiffstats
path: root/device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java
diff options
context:
space:
mode:
authorscheib <scheib@chromium.org>2015-10-22 20:23:24 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-23 03:24:16 +0000
commit41bcc6805171e2ab23a84b95f2c7cdfb1e3e473d (patch)
treef4d421bf5d0bc60825ef1d2f221907d63b043cb9 /device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java
parent36a9ce13a885ab83e7bcc74422b6f6b1a8c1e1e8 (diff)
downloadchromium_src-41bcc6805171e2ab23a84b95f2c7cdfb1e3e473d.zip
chromium_src-41bcc6805171e2ab23a84b95f2c7cdfb1e3e473d.tar.gz
chromium_src-41bcc6805171e2ab23a84b95f2c7cdfb1e3e473d.tar.bz2
bluetooth: android: Implement BluetoothRemoteGattServiceAndroid::GetCharacteristic{s}
Create intial C++ Stub for BluetoothRemoteGattCharacteristicAndroid. Return Characteristic objects from BluetoothRemoteGattServiceAndroid::GetCharacteristics() BluetoothRemoteGattServiceAndroid::GetCharacteristic() BUG=541400, 545682 Review URL: https://codereview.chromium.org/1406323004 Cr-Commit-Position: refs/heads/master@{#355723}
Diffstat (limited to 'device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java')
-rw-r--r--device/bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java54
1 files changed, 54 insertions, 0 deletions
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 2499c7b..7bf77c8 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
@@ -305,11 +305,65 @@ class Fakes {
static class FakeBluetoothGattService extends Wrappers.BluetoothGattServiceWrapper {
final int mInstanceId;
final UUID mUuid;
+ final ArrayList<Wrappers.BluetoothGattCharacteristicWrapper> mCharacteristics;
public FakeBluetoothGattService(UUID uuid, int instanceId) {
super(null);
mUuid = uuid;
mInstanceId = instanceId;
+ mCharacteristics = new ArrayList<Wrappers.BluetoothGattCharacteristicWrapper>();
+ }
+
+ // Create a characteristic and add it to this service.
+ @CalledByNative("FakeBluetoothGattService")
+ private static void addCharacteristic(
+ ChromeBluetoothRemoteGattService chromeService, String uuidString) {
+ FakeBluetoothGattService fakeService =
+ (FakeBluetoothGattService) chromeService.mService;
+ UUID uuid = UUID.fromString(uuidString);
+
+ int countOfDuplicateUUID = 0;
+ for (Wrappers.BluetoothGattCharacteristicWrapper characteristic :
+ fakeService.mCharacteristics) {
+ if (characteristic.getUuid().equals(uuid)) {
+ countOfDuplicateUUID++;
+ }
+ }
+ fakeService.mCharacteristics.add(new FakeBluetoothGattCharacteristic(
+ uuid, /* instanceId */ countOfDuplicateUUID));
+ }
+
+ // -----------------------------------------------------------------------------------------
+ // Wrappers.BluetoothGattServiceWrapper overrides:
+
+ @Override
+ public List<Wrappers.BluetoothGattCharacteristicWrapper> getCharacteristics() {
+ return mCharacteristics;
+ }
+
+ @Override
+ public int getInstanceId() {
+ return mInstanceId;
+ }
+
+ @Override
+ public UUID getUuid() {
+ return mUuid;
+ }
+ }
+
+ /**
+ * Fakes android.bluetooth.BluetoothGattCharacteristic.
+ */
+ static class FakeBluetoothGattCharacteristic
+ extends Wrappers.BluetoothGattCharacteristicWrapper {
+ final UUID mUuid;
+ final int mInstanceId;
+
+ public FakeBluetoothGattCharacteristic(UUID uuid, int instanceId) {
+ super(null);
+ mUuid = uuid;
+ mInstanceId = instanceId;
}
@Override