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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/BackgroundSyncLauncherServiceTest.java

Issue 1699143002: [NTP Snippets] Schedule periodic fetching (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@snippets_feature
Patch Set: fix bots Created 4 years, 10 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/javatests/src/org/chromium/chrome/browser/BackgroundSyncLauncherServiceTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/BackgroundSyncLauncherServiceTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/BackgroundSyncLauncherServiceTest.java
deleted file mode 100644
index e626c25763da286a22ab61d58a1783e92bfa06e6..0000000000000000000000000000000000000000
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/BackgroundSyncLauncherServiceTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright 2015 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;
-
-import android.content.Context;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-
-import org.chromium.base.ThreadUtils;
-import org.chromium.base.metrics.RecordHistogram;
-import org.chromium.base.test.util.AdvancedMockContext;
-import org.chromium.base.test.util.Feature;
-
-/**
- * Tests {@link BackgroundSyncLauncherService}.
- */
-public class BackgroundSyncLauncherServiceTest extends InstrumentationTestCase {
- private Context mContext;
- private BackgroundSyncLauncher mLauncher;
- private MockLauncherService mLauncherService;
-
- static class MockLauncherService extends BackgroundSyncLauncherService {
- private boolean mDidStartService = false;
-
- @Override
- protected void launchBrowser(Context context) {
- mDidStartService = true;
- }
-
- // Posts an assertion task to the UI thread. Since this is only called after the call
- // to onRunTask, it will be enqueued after any possible call to launchBrowser, and we
- // can reliably check whether launchBrowser was called.
- protected void checkExpectations(final boolean expectedStartService) {
- ThreadUtils.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- assertEquals("StartedService", expectedStartService, mDidStartService);
- }
- });
- }
- }
-
- @Override
- protected void setUp() throws Exception {
- mContext = new AdvancedMockContext(getInstrumentation().getTargetContext());
- BackgroundSyncLauncher.setGCMEnabled(false);
- RecordHistogram.disableForTests();
- mLauncher = BackgroundSyncLauncher.create(mContext);
- mLauncherService = new MockLauncherService();
- }
-
- private void deleteLauncherInstance() {
- mLauncher.destroy();
- mLauncher = null;
- }
-
- private void startOnRunTaskAndVerify(boolean shouldStart) {
- mLauncherService.onRunTask(null);
- mLauncherService.checkExpectations(shouldStart);
- }
-
- @SmallTest
- @Feature({"BackgroundSync"})
- public void testNoFireWhenInstanceExists() {
- startOnRunTaskAndVerify(false);
- }
-
- @SmallTest
- @Feature({"BackgroundSync"})
- public void testFiresWhenInstanceDoesNotExist() {
- deleteLauncherInstance();
- startOnRunTaskAndVerify(true);
- }
-}

Powered by Google App Engine
This is Rietveld 408576698