| 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 ae1873581adce554331f4e26fee34bd6a2b9e362..856f4c373c9a6963be605a2548eb3a420e05afdf 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
|
| @@ -16,9 +16,12 @@ import android.content.IntentFilter;
|
| import android.os.Build;
|
| import android.os.ParcelUuid;
|
|
|
| +import android.test.mock.MockContext;
|
| +
|
| import org.chromium.base.Log;
|
| import org.chromium.base.annotations.CalledByNative;
|
| import org.chromium.base.annotations.JNINamespace;
|
| +import org.chromium.components.location.LocationUtils;
|
|
|
| import java.util.ArrayList;
|
| import java.util.HashMap;
|
| @@ -39,6 +42,32 @@ class Fakes {
|
| private static final String TAG = "cr.Bluetooth";
|
|
|
| /**
|
| + * Sets the factory for LocationUtils to return an instance whose
|
| + * hasAndroidLocationPermission and isSystemLocationSettingEnabled return
|
| + * values depend on |hasPermission| and |isEnabled| respectively.
|
| + */
|
| + @CalledByNative
|
| + public static void setLocationServicesState(
|
| + final boolean hasPermission, final boolean isEnabled) {
|
| + LocationUtils.setFactory(new LocationUtils.Factory() {
|
| + @Override
|
| + public LocationUtils create() {
|
| + return new LocationUtils() {
|
| + @Override
|
| + public boolean hasAndroidLocationPermission(Context context) {
|
| + return hasPermission;
|
| + }
|
| +
|
| + @Override
|
| + public boolean isSystemLocationSettingEnabled(Context context) {
|
| + return isEnabled;
|
| + }
|
| + };
|
| + }
|
| + });
|
| + }
|
| +
|
| + /**
|
| * Fakes android.bluetooth.BluetoothAdapter.
|
| */
|
| static class FakeBluetoothAdapter extends Wrappers.BluetoothAdapterWrapper {
|
| @@ -63,11 +92,6 @@ class Fakes {
|
| mFakeScanner = new FakeBluetoothLeScanner();
|
| }
|
|
|
| - @CalledByNative("FakeBluetoothAdapter")
|
| - public void denyPermission() {
|
| - mFakeContext.mHasLocation = false;
|
| - }
|
| -
|
| /**
|
| * Creates and discovers a new device.
|
| */
|
| @@ -188,18 +212,11 @@ class Fakes {
|
| }
|
|
|
| /**
|
| - * Fakes android.content.Context.
|
| + * Fakes android.content.Context by extending MockContext.
|
| */
|
| - static class FakeContext extends Wrappers.ContextWrapper {
|
| - public boolean mHasLocation = true;
|
| -
|
| + static class FakeContext extends MockContext {
|
| public FakeContext() {
|
| - super(null);
|
| - }
|
| -
|
| - @Override
|
| - public boolean hasAndroidLocationPermission() {
|
| - return mHasLocation;
|
| + super();
|
| }
|
|
|
| @Override
|
|
|