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 636e67c8d6bdefd702adb84d79b6041631a4d854..0018c8194dcecdb5ef03d2177e4af5f8b6732237 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 |
@@ -41,6 +41,19 @@ import java.util.UUID; |
class Fakes { |
private static final String TAG = "cr.Bluetooth"; |
+ // Test values copied from src/device/bluetooth/test/bluetooth_test.h |
Jeffrey Yasskin
2016/08/24 04:32:02
Does GENERATED_JAVA_ENUM_PACKAGE work for mirrorin
ortuno
2016/08/24 21:29:09
Done.
|
+ private static final int TEST_RSSI1 = -81; |
+ private static final int TEST_RSSI2 = -61; |
+ private static final int TEST_RSSI3 = -41; |
+ private static final int TEST_RSSI4 = -21; |
+ private static final int TEST_RSSI5 = -1; |
+ private static final int TEST_TX_POWER1 = -40; |
+ private static final int TEST_TX_POWER2 = -20; |
+ |
+ // Android uses Integer.MIN_VALUE to signal no Tx Power in advertisement |
+ // packet. |
+ private static final int NO_TX_POWER = Integer.MIN_VALUE; |
+ |
/** |
* Sets the factory for LocationUtils to return an instance whose |
* hasAndroidLocationPermission and isSystemLocationSettingEnabled return |
@@ -107,10 +120,11 @@ class Fakes { |
uuids.add(ParcelUuid.fromString("00001800-0000-1000-8000-00805f9b34fb")); |
uuids.add(ParcelUuid.fromString("00001801-0000-1000-8000-00805f9b34fb")); |
- mFakeScanner.mScanCallback.onScanResult(ScanSettings.CALLBACK_TYPE_ALL_MATCHES, |
+ mFakeScanner.mScanCallback.onScanResult( |
+ ScanSettings.CALLBACK_TYPE_ALL_MATCHES, |
new FakeScanResult(new FakeBluetoothDevice(this, "01:00:00:90:1E:BE", |
"FakeBluetoothDevice"), |
- uuids)); |
+ TEST_RSSI1, uuids, TEST_TX_POWER1)); |
break; |
} |
case 2: { |
@@ -118,10 +132,11 @@ class Fakes { |
uuids.add(ParcelUuid.fromString("00001802-0000-1000-8000-00805f9b34fb")); |
uuids.add(ParcelUuid.fromString("00001803-0000-1000-8000-00805f9b34fb")); |
- mFakeScanner.mScanCallback.onScanResult(ScanSettings.CALLBACK_TYPE_ALL_MATCHES, |
+ mFakeScanner.mScanCallback.onScanResult( |
+ ScanSettings.CALLBACK_TYPE_ALL_MATCHES, |
new FakeScanResult(new FakeBluetoothDevice(this, "01:00:00:90:1E:BE", |
"FakeBluetoothDevice"), |
- uuids)); |
+ TEST_RSSI2, uuids, TEST_TX_POWER2)); |
break; |
} |
case 3: { |
@@ -129,7 +144,8 @@ class Fakes { |
mFakeScanner.mScanCallback.onScanResult( |
ScanSettings.CALLBACK_TYPE_ALL_MATCHES, |
new FakeScanResult( |
- new FakeBluetoothDevice(this, "01:00:00:90:1E:BE", ""), uuids)); |
+ new FakeBluetoothDevice(this, "01:00:00:90:1E:BE", ""), |
+ TEST_RSSI3, uuids, NO_TX_POWER)); |
break; |
} |
@@ -138,16 +154,18 @@ class Fakes { |
mFakeScanner.mScanCallback.onScanResult( |
ScanSettings.CALLBACK_TYPE_ALL_MATCHES, |
new FakeScanResult( |
- new FakeBluetoothDevice(this, "02:00:00:8B:74:63", ""), uuids)); |
+ new FakeBluetoothDevice(this, "02:00:00:8B:74:63", ""), |
+ TEST_RSSI4, uuids, NO_TX_POWER)); |
break; |
} |
case 5: { |
ArrayList<ParcelUuid> uuids = null; |
- mFakeScanner.mScanCallback.onScanResult(ScanSettings.CALLBACK_TYPE_ALL_MATCHES, |
- new FakeScanResult(new FakeBluetoothDevice( |
- this, "01:00:00:90:1E:BE", null), |
- uuids)); |
+ mFakeScanner.mScanCallback.onScanResult( |
+ ScanSettings.CALLBACK_TYPE_ALL_MATCHES, |
+ new FakeScanResult( |
+ new FakeBluetoothDevice(this, "01:00:00:90:1E:BE", null), |
+ TEST_RSSI5, uuids, NO_TX_POWER)); |
break; |
} |
} |
@@ -273,12 +291,17 @@ class Fakes { |
*/ |
static class FakeScanResult extends Wrappers.ScanResultWrapper { |
private final FakeBluetoothDevice mDevice; |
+ private final int mRssi; |
+ private final int mTxPower; |
private final ArrayList<ParcelUuid> mUuids; |
- FakeScanResult(FakeBluetoothDevice device, ArrayList<ParcelUuid> uuids) { |
+ FakeScanResult( |
+ FakeBluetoothDevice device, int rssi, ArrayList<ParcelUuid> uuids, int txPower) { |
super(null); |
mDevice = device; |
+ mRssi = rssi; |
mUuids = uuids; |
+ mTxPower = txPower; |
} |
@Override |
@@ -287,9 +310,19 @@ class Fakes { |
} |
@Override |
+ public int getRssi() { |
+ return mRssi; |
+ } |
+ |
+ @Override |
public List<ParcelUuid> getScanRecord_getServiceUuids() { |
return mUuids; |
} |
+ |
+ @Override |
+ public int getScanRecord_getTxPowerLevel() { |
+ return mTxPower; |
+ } |
} |
/** |