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

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

Issue 2030773002: Add unit tests for the Background Scheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Disable flaky test Created 4 years, 6 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
Index: chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/ShadowGcmNetworkManager.java
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/ShadowGcmNetworkManager.java b/chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/ShadowGcmNetworkManager.java
new file mode 100644
index 0000000000000000000000000000000000000000..8a2189e334336dd4e88b0ad0bf7a7a8fc032e901
--- /dev/null
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/ShadowGcmNetworkManager.java
@@ -0,0 +1,31 @@
+// Copyright 2016 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 com.google.android.gms.gcm.GcmNetworkManager;
+import com.google.android.gms.gcm.Task;
+
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+
+
+/**
+ * Custom shadow for the OS's GcmNetworkManager. We use this to hook the call to GcmNetworkManager
+ * to make sure it was invoked as we expect.
+ */
+@Implements(GcmNetworkManager.class)
+public class ShadowGcmNetworkManager {
+ private static Task sTask;
+
+ @Implementation
+ public void schedule(Task task) {
+ // Capture the string part divisions so we can check them.
+ sTask = task;
+ }
+
+ public static Task getScheduledTask() {
+ return sTask;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698