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 e7e96e3981a3be8c16abb453cbc2043f0370ddd9..9477bc95bda5fbe6247875c23007b41ae9c35339 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 |
@@ -3,7 +3,6 @@ |
// found in the LICENSE file. |
package org.chromium.chrome.browser.webapps; |
dominickn
2017/07/07 05:56:04
Nit: put this newline back in?
|
- |
import android.content.Intent; |
import android.graphics.Color; |
import android.support.test.InstrumentationRegistry; |
@@ -24,7 +23,9 @@ import org.chromium.chrome.browser.ChromeSwitches; |
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.DOMUtils; |
@@ -37,6 +38,7 @@ import org.chromium.ui.base.PageTransition; |
@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 = |
@@ -194,6 +196,45 @@ public class WebappNavigationTest { |
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"); |
+ |
+ activityListener.waitForExternalApp(); |
+ 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 = activityListener.waitFor(CustomTabActivity.class); |
+ |
+ activityListener.waitForExternalApp(); |
+ |
+ 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))); |