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

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

Issue 2030773002: Add unit tests for the Background Scheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR feedback per DougArnett 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/BackgroundOfflinerTaskTest.java
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/BackgroundOfflinerTaskTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/BackgroundOfflinerTaskTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..4efa287f3ff902150c84a8f9b2234f2a8c2aac9f
--- /dev/null
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/BackgroundOfflinerTaskTest.java
@@ -0,0 +1,57 @@
+// 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.assertTrue;
+
+import android.os.Bundle;
+
+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.annotation.Config;
+
+/**
+ * Unit tests for BackgroundOfflinerTask.
+ */
+@RunWith(LocalRobolectricTestRunner.class)
+@Config(manifest = Config.NONE,
+ application = BaseChromiumApplication.class)
+public class BackgroundOfflinerTaskTest {
+ private Bundle mTaskExtras;
+ private long mTestTime;
+ private StubBackgroundSchedulerBridge mStubBackgroundSchedulerBridge;
+
+ @Before
+ public void setUp() throws Exception {
+ // Build a bundle
+ mTaskExtras = new Bundle();
+ TaskExtrasPacker.packTimeInBundle(mTaskExtras);
+ mStubBackgroundSchedulerBridge = new StubBackgroundSchedulerBridge();
+ }
+
+ @Test
+ @Feature({"OfflinePages"})
+ public void testIncomingTask() {
+ BackgroundOfflinerTask task =
+ new BackgroundOfflinerTask(mStubBackgroundSchedulerBridge);
+ task.processBackgroundRequests(mTaskExtras);
+ // Call onProcessingDone here to make sure the code path is covered by a test.
+ // This will likely move to its own test later as we add more implementation.
+ task.onProcessingDone(true);
+
+ // Check with ShadowBackgroundSchedulerBridge that startProcessing got called.
+ assertTrue(mStubBackgroundSchedulerBridge.getStartProcessingCalled());
+ }
+
+ @Test
+ @Feature({"OfflinePages"})
+ public void testOnProcessingDone() {
+ // TODO(petewil): Implement the test
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698