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

Unified Diff: chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/ShadowDeviceConditions.java

Issue 2737093002: [Offline pages] Clean up of device conditions related code (Closed)
Patch Set: Compilation fix and small code update Created 3 years, 9 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 | « chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/OfflinePageTestRunner.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
+ }
+}
« no previous file with comments | « chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/OfflinePageTestRunner.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698