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

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

Issue 2060423003: Watch for RenderFrameHost switch in distillability (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add VisibleForTesting to ChromeActivity 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
« no previous file with comments | « chrome/android/java_sources.gni ('k') | components/dom_distiller/content/browser/distillability_driver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/javatests/src/org/chromium/chrome/browser/dom_distiller/DistillabilityServiceTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/dom_distiller/DistillabilityServiceTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/dom_distiller/DistillabilityServiceTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..6e71aa8e797583c4a0f6074b6859de0cdc4293b7
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/dom_distiller/DistillabilityServiceTest.java
@@ -0,0 +1,70 @@
+// 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.dom_distiller;
+
+import android.os.Environment;
+import android.test.suitebuilder.annotation.MediumTest;
+
+import org.chromium.base.test.util.CommandLineFlags;
+import org.chromium.base.test.util.Feature;
+import org.chromium.base.test.util.Restriction;
+import org.chromium.chrome.browser.ChromeActivity;
+import org.chromium.chrome.browser.compositor.bottombar.readermode.ReaderModePanel;
+import org.chromium.chrome.test.ChromeActivityTestCaseBase;
+import org.chromium.chrome.test.util.ChromeRestriction;
+import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnPageFinishedHelper;
+import org.chromium.content.browser.test.util.TestWebContentsObserver;
+import org.chromium.net.test.EmbeddedTestServer;
+
+import java.util.concurrent.TimeoutException;
+
+/**
+ * Tests for making sure the distillability service is communicating correctly.
+ */
+@CommandLineFlags.Add({"enable-dom-distiller", "reader-mode-heuristics=alwaystrue"})
+public class DistillabilityServiceTest extends ChromeActivityTestCaseBase<ChromeActivity> {
+
+ private static final String TEST_PAGE = "/chrome/test/data/android/simple.html";
+
+ public DistillabilityServiceTest() {
+ super(ChromeActivity.class);
+ }
+
+ @Override
+ public void startMainActivity() throws InterruptedException {
+ startMainActivityOnBlankPage();
+ }
+
+ /**
+ * Make sure that Reader Mode appears after navigating from a native page.
+ */
+ @Feature({"Distillability-Service"})
+ @MediumTest
+ @Restriction(ChromeRestriction.RESTRICTION_TYPE_PHONE)
+ public void testServiceAliveAfterNativePage()
+ throws InterruptedException, TimeoutException {
+
+ EmbeddedTestServer testServer = EmbeddedTestServer.createAndStartFileServer(
+ getInstrumentation().getContext(), Environment.getExternalStorageDirectory());
+
+ final ReaderModePanel panel = getActivity().getReaderModeManager().getPanelForTesting();
+
+ TestWebContentsObserver observer =
+ new TestWebContentsObserver(getActivity().getActivityTab().getWebContents());
+ OnPageFinishedHelper finishHelper = observer.getOnPageFinishedHelper();
+
+ // Navigate to a native page.
+ int curCallCount = finishHelper.getCallCount();
+ loadUrl("chrome://history");
+ finishHelper.waitForCallback(curCallCount, 1);
+ assertFalse(panel.isShowing());
+
+ // Navigate to a normal page.
+ curCallCount = finishHelper.getCallCount();
+ loadUrl(testServer.getURL(TEST_PAGE));
+ finishHelper.waitForCallback(curCallCount, 1);
+ assertTrue(panel.isShowing());
+ }
+}
« no previous file with comments | « chrome/android/java_sources.gni ('k') | components/dom_distiller/content/browser/distillability_driver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698