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

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

Issue 2537293002: Instant Apps: Allow custom tab redirects to Instant Apps. (Closed)
Patch Set: Created 4 years, 1 month 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/src/org/chromium/chrome/browser/tab/TabRedirectHandler.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/externalnav/ExternalNavigationHandlerTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandlerTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandlerTest.java
index 92420e8b21024b1f2be76c384faa3867ca850275..9c37eb92e8290f4d73238bfdc4eced9d5b6e0e41 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandlerTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandlerTest.java
@@ -516,6 +516,30 @@ public class ExternalNavigationHandlerTest extends NativeLibraryTestBase {
}
@SmallTest
+ public void testInstantAppsIntent_customTabRedirect() throws Exception {
+ TestContext context = new TestContext();
+ TabRedirectHandler redirectHandler = new TabRedirectHandler(context);
+ int transTypeLinkFromIntent = PageTransition.LINK | PageTransition.FROM_API;
+
+ // In Custom Tabs, if the first url is a redirect, don't allow it to intent out, unless
+ // the redirect is going to Instant Apps.
+ Intent fooIntent = Intent.parseUri("http://foo.com/", Intent.URI_INTENT_SCHEME);
+ fooIntent.putExtra(CustomTabsIntent.EXTRA_SESSION, "");
+ fooIntent.putExtra(CustomTabsIntent.EXTRA_ENABLE_INSTANT_APPS, true);
+ fooIntent.setPackage(context.getPackageName());
+ redirectHandler.updateIntent(fooIntent);
+ redirectHandler.updateNewUrlLoading(transTypeLinkFromIntent, false, false, 0, 0);
+ redirectHandler.updateNewUrlLoading(transTypeLinkFromIntent, true, false, 0, 0);
+
+ mDelegate.setCanHandleWithInstantApp(true);
+ checkUrl("http://instantappenabled.com")
+ .withPageTransition(transTypeLinkFromIntent)
+ .withIsRedirect(true)
+ .withRedirectHandler(redirectHandler)
+ .expecting(OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTENT, IGNORE);
+ }
+
+ @SmallTest
public void testFallbackUrl_IntentResolutionSucceeds() {
// IMDB app is installed.
mDelegate.setCanResolveActivity(true);
@@ -1167,7 +1191,7 @@ public class ExternalNavigationHandlerTest extends NativeLibraryTestBase {
@Override
public boolean maybeLaunchInstantApp(Tab tab, String url, String referrerUrl,
boolean isIncomingRedirect) {
- return false;
+ return mCanHandleWithInstantApp;
}
@Override
@@ -1201,6 +1225,10 @@ public class ExternalNavigationHandlerTest extends NativeLibraryTestBase {
mIsWithinCurrentWebappScope = value;
}
+ public void setCanHandleWithInstantApp(boolean value) {
+ mCanHandleWithInstantApp = value;
+ }
+
public Intent startActivityIntent = null;
public boolean startIncognitoIntentCalled = false;
@@ -1209,6 +1237,7 @@ public class ExternalNavigationHandlerTest extends NativeLibraryTestBase {
private String mNewUrlAfterClobbering;
private String mReferrerUrlForClobbering;
+ private boolean mCanHandleWithInstantApp;
public boolean mIsChromeAppInForeground = true;
public boolean mIsWithinCurrentWebappScope;
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/tab/TabRedirectHandler.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698