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

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

Issue 1215303006: bluetooth: android: Initial BluetoothDeviceAndroid implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bta-discovery-
Patch Set: Merge TOT Created 5 years, 5 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_device_unittest.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 9751247135ad4f61ef889d21b251dbdabdcb00db..5e63b66fbfa9d3bc63d5615d75d1f666a29e7048 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
@@ -5,12 +5,16 @@
package org.chromium.device.bluetooth;
import android.annotation.TargetApi;
+import android.bluetooth.BluetoothDevice;
import android.bluetooth.le.ScanFilter;
+import android.bluetooth.le.ScanSettings;
import android.os.Build;
+import android.os.ParcelUuid;
import org.chromium.base.CalledByNative;
import org.chromium.base.Log;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -40,6 +44,53 @@ class Fakes {
mFakeScanner = (FakeBluetoothLeScanner) mScanner;
}
+ /**
+ * Creates and discovers a new device.
+ */
+ @CalledByNative("FakeBluetoothAdapter")
+ public void discoverLowEnergyDevice(int deviceOrdinal) {
+ switch (deviceOrdinal) {
+ case 1: {
+ ArrayList<ParcelUuid> uuids = new ArrayList<ParcelUuid>(2);
+ uuids.add(ParcelUuid.fromString("00001800-0000-1000-8000-00805f9b34fb"));
+ uuids.add(ParcelUuid.fromString("00001801-0000-1000-8000-00805f9b34fb"));
+
+ mFakeScanner.mCallback.onScanResult(ScanSettings.CALLBACK_TYPE_ALL_MATCHES,
+ new FakeScanResult(new FakeBluetoothDevice(
+ "AA:00:00:00:00:01", "FakeBluetoothDevice"),
+ uuids));
+ break;
+ }
+ case 2: {
+ ArrayList<ParcelUuid> uuids = new ArrayList<ParcelUuid>(2);
+ uuids.add(ParcelUuid.fromString("00001802-0000-1000-8000-00805f9b34fb"));
+ uuids.add(ParcelUuid.fromString("00001803-0000-1000-8000-00805f9b34fb"));
+
+ mFakeScanner.mCallback.onScanResult(ScanSettings.CALLBACK_TYPE_ALL_MATCHES,
+ new FakeScanResult(new FakeBluetoothDevice(
+ "AA:00:00:00:00:01", "FakeBluetoothDevice"),
+ uuids));
+ break;
+ }
+ case 3: {
+ ArrayList<ParcelUuid> uuids = null;
+ mFakeScanner.mCallback.onScanResult(ScanSettings.CALLBACK_TYPE_ALL_MATCHES,
+ new FakeScanResult(new FakeBluetoothDevice("AA:00:00:00:00:01", ""),
+ uuids));
+
+ break;
+ }
+ case 4: {
+ ArrayList<ParcelUuid> uuids = null;
+ mFakeScanner.mCallback.onScanResult(ScanSettings.CALLBACK_TYPE_ALL_MATCHES,
+ new FakeScanResult(new FakeBluetoothDevice("BB:00:00:00:00:02", ""),
+ uuids));
+
+ break;
+ }
+ }
+ }
+
// -----------------------------------------------------------------------------------------
// BluetoothAdapterWrapper overrides:
@@ -103,37 +154,56 @@ class Fakes {
*/
static class FakeScanResult extends Wrappers.ScanResultWrapper {
private final FakeBluetoothDevice mDevice;
+ private final ArrayList<ParcelUuid> mUuids;
- FakeScanResult(FakeBluetoothDevice device) {
+ FakeScanResult(FakeBluetoothDevice device, ArrayList<ParcelUuid> uuids) {
super(null);
mDevice = device;
+ mUuids = uuids;
}
@Override
public Wrappers.BluetoothDeviceWrapper getDevice() {
return mDevice;
}
+
+ @Override
+ public List<ParcelUuid> getScanRecord_getServiceUuids() {
+ return mUuids;
+ }
}
/**
* Fakes android.bluetooth.BluetoothDevice.
*/
static class FakeBluetoothDevice extends Wrappers.BluetoothDeviceWrapper {
- private static final String ADDRESS = "A1:B2:C3:DD:DD:DD";
- private static final String NAME = "FakeBluetoothDevice";
+ private String mAddress;
+ private String mName;
- public FakeBluetoothDevice() {
+ public FakeBluetoothDevice(String address, String name) {
super(null);
+ mAddress = address;
+ mName = name;
}
@Override
public String getAddress() {
- return ADDRESS;
+ return mAddress;
+ }
+
+ @Override
+ public int getBluetoothClass_getDeviceClass() {
+ return 0x1F00; // Unspecified Device Class
+ }
+
+ @Override
+ public int getBondState() {
+ return BluetoothDevice.BOND_BONDED;
}
@Override
public String getName() {
- return NAME;
+ return mName;
}
}
}
« no previous file with comments | « device/bluetooth/bluetooth_device_unittest.cc ('k') | device/bluetooth/test/bluetooth_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698