| Index: chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/ShadowDeviceConditions.java
|
| diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/ShadowDeviceConditions.java b/chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/ShadowDeviceConditions.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..0862b5562458ba7a14bdf98f63b47ee485af291f
|
| --- /dev/null
|
| +++ b/chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/ShadowDeviceConditions.java
|
| @@ -0,0 +1,42 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +package org.chromium.chrome.browser.offlinepages;
|
| +
|
| +import android.content.Context;
|
| +
|
| +import org.robolectric.annotation.Implementation;
|
| +import org.robolectric.annotation.Implements;
|
| +
|
| +/** Custom shadow for the OfflinePageUtils. */
|
| +@Implements(DeviceConditions.class)
|
| +public class ShadowDeviceConditions {
|
| + /** Device conditions for testing. */
|
| + private static DeviceConditions sDeviceConditions = new DeviceConditions();
|
| +
|
| + /** Sets device conditions that will be used in test. */
|
| + public static void setCurrentConditions(DeviceConditions deviceConditions) {
|
| + sDeviceConditions = deviceConditions;
|
| + }
|
| +
|
| + @Implementation
|
| + public static DeviceConditions getCurrentConditions(Context context) {
|
| + return sDeviceConditions;
|
| + }
|
| +
|
| + @Implementation
|
| + public static boolean isPowerConnected(Context context) {
|
| + return sDeviceConditions.isPowerConnected();
|
| + }
|
| +
|
| + @Implementation
|
| + public static int getBatteryPercentage(Context context) {
|
| + return sDeviceConditions.getBatteryPercentage();
|
| + }
|
| +
|
| + @Implementation
|
| + public static int getNetConnectionType(Context context) {
|
| + return sDeviceConditions.getNetConnectionType();
|
| + }
|
| +}
|
|
|