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

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

Issue 2975883003: Revert of Fixes redirects to external apps when navigating from PWA. (Closed)
Patch Set: Created 3 years, 5 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/javatests/src/org/chromium/chrome/browser/webapps/WebApkIntegrationTest.java ('k') | no next file » | 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/webapps/WebappNavigationTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappNavigationTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappNavigationTest.java
index 81b49915c7f897fb9d935e09a989d609ed61aefa..e7e96e3981a3be8c16abb453cbc2043f0370ddd9 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappNavigationTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappNavigationTest.java
@@ -4,11 +4,6 @@
package org.chromium.chrome.browser.webapps;
-import static org.chromium.base.ApplicationState.HAS_DESTROYED_ACTIVITIES;
-import static org.chromium.base.ApplicationState.HAS_PAUSED_ACTIVITIES;
-import static org.chromium.base.ApplicationState.HAS_STOPPED_ACTIVITIES;
-
-import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.support.test.InstrumentationRegistry;
@@ -22,7 +17,6 @@
import org.junit.runner.RunWith;
import org.chromium.base.ApiCompatibilityUtils;
-import org.chromium.base.ApplicationStatus;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature;
import org.chromium.chrome.R;
@@ -30,13 +24,9 @@
import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.ShortcutHelper;
import org.chromium.chrome.browser.customtabs.CustomTabActivity;
-import org.chromium.chrome.browser.externalnav.ExternalNavigationHandler.OverrideUrlLoadingResult;
import org.chromium.chrome.browser.firstrun.FirstRunStatus;
-import org.chromium.chrome.browser.tab.InterceptNavigationDelegateImpl;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.util.browser.contextmenu.ContextMenuUtils;
-import org.chromium.content.browser.test.util.Criteria;
-import org.chromium.content.browser.test.util.CriteriaHelper;
import org.chromium.content.browser.test.util.DOMUtils;
import org.chromium.net.test.EmbeddedTestServer;
import org.chromium.ui.base.PageTransition;
@@ -47,7 +37,6 @@
@RunWith(ChromeJUnit4ClassRunner.class)
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
public class WebappNavigationTest {
- private static final String YOUTUBE_URL = "https://www.youtube.com/watch?v=EYmjoW4vIX8";
private static final String OFF_ORIGIN_URL = "https://www.google.com/";
private static final String WEB_APP_PATH = "/chrome/test/data/banners/manifest_test_page.html";
private static final String IN_SCOPE_PAGE_PATH =
@@ -56,6 +45,9 @@
@Rule
public final WebappActivityTestRule mActivityTestRule = new WebappActivityTestRule();
+ @Rule
+ public final TopActivityListener activityListener = new TopActivityListener();
+
private EmbeddedTestServer mTestServer;
@Before
@@ -128,7 +120,7 @@
addAnchor("testId", mTestServer.getURL(IN_SCOPE_PAGE_PATH), "_blank");
DOMUtils.clickNode(
mActivityTestRule.getActivity().getActivityTab().getContentViewCore(), "testId");
- CustomTabActivity customTab = waitFor(CustomTabActivity.class);
+ CustomTabActivity customTab = activityListener.waitFor(CustomTabActivity.class);
mActivityTestRule.waitUntilIdle(customTab);
Assert.assertTrue(
mActivityTestRule.runJavaScriptCodeInCurrentTab("document.body.textContent")
@@ -177,7 +169,7 @@
otherPageUrl, mActivityTestRule.getActivity().getActivityTab().getUrl());
Assert.assertSame(
- mActivityTestRule.getActivity(), ApplicationStatus.getLastTrackedFocusedActivity());
+ mActivityTestRule.getActivity(), activityListener.getMostRecentActivity());
}
@Test
@@ -195,52 +187,13 @@
mActivityTestRule.getActivity().getActivityTab(), "myTestAnchorId",
R.id.menu_id_open_in_chrome);
- ChromeTabbedActivity tabbedChrome = waitFor(ChromeTabbedActivity.class);
+ ChromeTabbedActivity tabbedChrome = activityListener.waitFor(ChromeTabbedActivity.class);
mActivityTestRule.waitUntilIdle(tabbedChrome);
// Dropping the TLD as Google can redirect to a local site, so this could fail outside US.
Assert.assertTrue(tabbedChrome.getActivityTab().getUrl().startsWith("https://www.google."));
}
- @Test
- @SmallTest
- @Feature({"Webapps"})
- public void testRegularLinkToExternalApp() throws Exception {
- runWebappActivityAndWaitForIdle(mActivityTestRule.createIntent());
-
- InterceptNavigationDelegateImpl navigationDelegate =
- mActivityTestRule.getActivity().getActivityTab().getInterceptNavigationDelegate();
-
- addAnchor("testLink", YOUTUBE_URL, "_self");
- DOMUtils.clickNode(
- mActivityTestRule.getActivity().getActivityTab().getContentViewCore(), "testLink");
-
- waitForExternalAppOrIntentPicker();
- Assert.assertEquals(OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTENT,
- navigationDelegate.getLastOverrideUrlLoadingResultForTests());
- }
-
- @Test
- @SmallTest
- @Feature({"Webapps"})
- public void testNewTabLinkToExternalApp() throws Exception {
- runWebappActivityAndWaitForIdle(mActivityTestRule.createIntent());
-
- addAnchor("testLink", YOUTUBE_URL, "_blank");
- DOMUtils.clickNode(
- mActivityTestRule.getActivity().getActivityTab().getContentViewCore(), "testLink");
-
- // For _blank anchors, we open the CustomTab which does the redirecting if necessary.
- CustomTabActivity customTab = waitFor(CustomTabActivity.class);
-
- waitForExternalAppOrIntentPicker();
-
- InterceptNavigationDelegateImpl navigationDelegate =
- customTab.getActivityTab().getInterceptNavigationDelegate();
- Assert.assertEquals(OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTENT,
- navigationDelegate.getLastOverrideUrlLoadingResultForTests());
- }
-
private void runWebappActivityAndWaitForIdle(Intent intent) throws Exception {
mActivityTestRule.startWebappActivity(
intent.putExtra(ShortcutHelper.EXTRA_URL, mTestServer.getURL(WEB_APP_PATH)));
@@ -250,7 +203,7 @@
}
private CustomTabActivity assertCustomTabActivityLaunchedForOffOriginUrl() {
- CustomTabActivity customTab = waitFor(CustomTabActivity.class);
+ CustomTabActivity customTab = activityListener.waitFor(CustomTabActivity.class);
mActivityTestRule.waitUntilIdle(customTab);
// Dropping the TLD as Google can redirect to a local site, so this could fail outside US.
@@ -269,28 +222,4 @@
+ "document.body.appendChild(aTag);",
id, url, target));
}
-
- @SuppressWarnings("unchecked")
- private <T extends Activity> T waitFor(final Class<T> expectedClass) {
- final Activity[] holder = new Activity[1];
- CriteriaHelper.pollUiThread(new Criteria() {
- @Override
- public boolean isSatisfied() {
- holder[0] = ApplicationStatus.getLastTrackedFocusedActivity();
- return holder[0] != null && expectedClass.isAssignableFrom(holder[0].getClass());
- }
- });
- return (T) holder[0];
- }
-
- private void waitForExternalAppOrIntentPicker() {
- CriteriaHelper.pollUiThread(new Criteria() {
- @Override
- public boolean isSatisfied() {
- return ApplicationStatus.getStateForApplication() == HAS_PAUSED_ACTIVITIES
- || ApplicationStatus.getStateForApplication() == HAS_STOPPED_ACTIVITIES
- || ApplicationStatus.getStateForApplication() == HAS_DESTROYED_ACTIVITIES;
- }
- });
- }
}
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIntegrationTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698