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

Unified Diff: chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/BackgroundSchedulerTest.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/BackgroundSchedulerTest.java
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/BackgroundSchedulerTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/BackgroundSchedulerTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..8c357117cfa689332e955cf85939a1424214fb45
--- /dev/null
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/BackgroundSchedulerTest.java
@@ -0,0 +1,52 @@
+// 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 static org.junit.Assert.assertNull;
+
+import android.content.Context;
+
+import org.chromium.base.BaseChromiumApplication;
+import org.chromium.base.test.util.Feature;
+import org.chromium.testing.local.LocalRobolectricTestRunner;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.Robolectric;
+import org.robolectric.annotation.Config;
+
+/**
+ * Unit tests for BackgroundScheduler.
+ */
+@RunWith(LocalRobolectricTestRunner.class)
+@Config(manifest = Config.NONE,
+ application = BaseChromiumApplication.class)
+public class BackgroundSchedulerTest {
+ private Context mContext;
+
+ @Before
+ public void setUp() throws Exception {
+ mContext = Robolectric.application;
+ }
+
+ @Test
+ @Config(shadows = {ShadowGcmNetworkManager.class})
+ @Feature({"OfflinePages"})
+ public void testSchedule() {
+ BackgroundScheduler scheduler = new BackgroundScheduler();
+ assertNull(ShadowGcmNetworkManager.getScheduledTask());
+
+ // TODO(petewil): Re-enable the test when I track down why the GCMNetworkManager shadow is
+ // flaky. I will need to call schedule, then assert that the shadow saw the scheduled task.
+
+ // TODO(petewil): Also assert that the date we see is what we expected
+ }
+
+ @Test
+ @Feature({"OfflinePages"})
+ public void testUnschedule() {
+ // TODO(petewil): Add this test.
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698