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

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

Issue 1150833002: bluetooth: android: Initial Low Energy Discovery Sessions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bta-manifest-
Patch Set: https://codereview.chromium.org/1231883004 fixs runtime error. 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_adapter_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 c5adcf7053acde59ffe3569a0228d33445ab1885..9751247135ad4f61ef889d21b251dbdabdcb00db 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
@@ -4,12 +4,19 @@
package org.chromium.device.bluetooth;
+import android.annotation.TargetApi;
+import android.bluetooth.le.ScanFilter;
+import android.os.Build;
+
import org.chromium.base.CalledByNative;
import org.chromium.base.Log;
+import java.util.List;
+
/**
* Fake implementations of android.bluetooth.* classes for testing.
*/
+@TargetApi(Build.VERSION_CODES.LOLLIPOP)
class Fakes {
private static final String TAG = "cr.Bluetooth";
@@ -17,6 +24,8 @@ class Fakes {
* Fakes android.bluetooth.BluetoothAdapter.
*/
static class FakeBluetoothAdapter extends Wrappers.BluetoothAdapterWrapper {
+ private final FakeBluetoothLeScanner mFakeScanner;
+
/**
* Creates a FakeBluetoothAdapter.
*/
@@ -27,7 +36,8 @@ class Fakes {
}
private FakeBluetoothAdapter() {
- super(null);
+ super(null, new FakeBluetoothLeScanner());
+ mFakeScanner = (FakeBluetoothLeScanner) mScanner;
}
// -----------------------------------------------------------------------------------------
@@ -58,4 +68,72 @@ class Fakes {
return false;
}
}
+
+ /**
+ * Fakes android.bluetooth.le.BluetoothLeScanner.
+ */
+ static class FakeBluetoothLeScanner extends Wrappers.BluetoothLeScannerWrapper {
+ public Wrappers.ScanCallbackWrapper mCallback;
+
+ private FakeBluetoothLeScanner() {
+ super(null);
+ }
+
+ @Override
+ public void startScan(List<ScanFilter> filters, int scanSettingsScanMode,
+ Wrappers.ScanCallbackWrapper callback) {
+ if (mCallback != null) {
+ throw new IllegalArgumentException(
+ "FakeBluetoothLeScanner does not support multiple scans.");
+ }
+ mCallback = callback;
+ }
+
+ @Override
+ public void stopScan(Wrappers.ScanCallbackWrapper callback) {
+ if (mCallback != callback) {
+ throw new IllegalArgumentException("No scan in progress.");
+ }
+ mCallback = null;
+ }
+ }
+
+ /**
+ * Fakes android.bluetooth.le.ScanResult
+ */
+ static class FakeScanResult extends Wrappers.ScanResultWrapper {
+ private final FakeBluetoothDevice mDevice;
+
+ FakeScanResult(FakeBluetoothDevice device) {
+ super(null);
+ mDevice = device;
+ }
+
+ @Override
+ public Wrappers.BluetoothDeviceWrapper getDevice() {
+ return mDevice;
+ }
+ }
+
+ /**
+ * 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";
+
+ public FakeBluetoothDevice() {
+ super(null);
+ }
+
+ @Override
+ public String getAddress() {
+ return ADDRESS;
+ }
+
+ @Override
+ public String getName() {
+ return NAME;
+ }
+ }
}
« no previous file with comments | « device/bluetooth/bluetooth_adapter_unittest.cc ('k') | device/bluetooth/test/bluetooth_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698