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

Unified Diff: chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkInfoTest.java

Issue 2956193002: [Android] Enable WebAPK to have multiple intent filters (Closed)
Patch Set: Merge branch 'rewriting0' into rewriting Created 3 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
Index: chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkInfoTest.java
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkInfoTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkInfoTest.java
index d7c6f1caabc76af09c180c858eaaf46e0e5357cb..fdb02886a5b35bcfe7142c5d79d816f56b3a7e81 100644
--- a/chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkInfoTest.java
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkInfoTest.java
@@ -177,6 +177,33 @@ public class WebApkInfoTest {
Assert.assertEquals(START_URL, info.manifestStartUrl());
}
+ /**
+ * Test that {@link WebApkInfo#create()} rewrites {@link WebApkInfo#uri()} when the start URL
+ * from the intent is outside of the scope in the WebAPK Android Manifest.
+ */
+ @Test
+ public void testRewriteStartUrlSchemeAndHost() {
+ final String intentStartUrl = "http://www.google.ca/search_results?q=eh#cr=countryCA";
+ final String expectedRewrittenStartUrl =
+ "https://www.google.com/search_results?q=eh#cr=countryCA";
+ final String manifestStartUrl = "https://www.google.com/";
+ final String manifestScope = "https://www.google.com/";
+
+ Bundle bundle = new Bundle();
+ bundle.putString(WebApkMetaDataKeys.START_URL, manifestStartUrl);
+ bundle.putString(WebApkMetaDataKeys.SCOPE, manifestScope);
+ WebApkTestHelper.registerWebApkWithMetaData(WEBAPK_PACKAGE_NAME, bundle);
+
+ Intent intent = new Intent();
+ intent.putExtra(WebApkConstants.EXTRA_WEBAPK_PACKAGE_NAME, WEBAPK_PACKAGE_NAME);
+ intent.putExtra(ShortcutHelper.EXTRA_URL, intentStartUrl);
+
+ WebApkInfo info = WebApkInfo.create(intent);
+
+ Assert.assertEquals(expectedRewrittenStartUrl, info.uri().toString());
+ Assert.assertEquals(manifestStartUrl, info.manifestStartUrl());
+ }
+
/**
* Test that if the scope is empty that the scope is computed from the "start URL specified from
* the Web Manifest" not the "URL the WebAPK initially navigated to". Deep links can open a

Powered by Google App Engine
This is Rietveld 408576698