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

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

Issue 2548333006: [WebAPKs] Compute the default scope from the manifest start URL. (Closed)
Patch Set: Merge branch 'update_fail_refactor0' into update_fail_refactor01 Created 4 years 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/WebApkUpdateDataFetcherTest.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 419e68d50f97945618873c0b8f548fe6e6e6dfee..a237f8cdffe0801a83510a1c34f70f44fe8e674d 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
@@ -129,6 +129,34 @@ public class WebApkInfoTest {
}
/**
+ * 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
+ * WebAPK at an arbitrary URL.
+ */
+ @Test
+ public void testDefaultScopeFromManifestStartUrl() {
+ String manifestStartUrl = START_URL;
+ String intentStartUrl = "https://www.google.com/a/b/c";
+
+ String scopeFromManifestStartUrl = ShortcutHelper.getScopeFromUrl(manifestStartUrl);
+ String scopeFromIntentStartUrl = ShortcutHelper.getScopeFromUrl(intentStartUrl);
+ Assert.assertNotEquals(scopeFromManifestStartUrl, scopeFromIntentStartUrl);
+
+ Bundle bundle = new Bundle();
+ bundle.putString(WebApkMetaDataKeys.START_URL, manifestStartUrl);
+ bundle.putString(WebApkMetaDataKeys.SCOPE, "");
+ WebApkTestHelper.registerWebApkWithMetaData(bundle);
+
+ Intent intent = new Intent();
+ intent.putExtra(
+ ShortcutHelper.EXTRA_WEBAPK_PACKAGE_NAME, WebApkTestHelper.WEBAPK_PACKAGE_NAME);
+ intent.putExtra(ShortcutHelper.EXTRA_URL, intentStartUrl);
+
+ WebApkInfo info = WebApkInfo.create(intent);
+ Assert.assertEquals(scopeFromManifestStartUrl, info.scopeUri().toString());
+ }
+
+ /**
* Test that {@link WebApkInfo#create} can read multiple icon URLs and multiple icon murmur2
* hashes from the WebAPK's meta data.
*/
@@ -140,6 +168,7 @@ public class WebApkInfoTest {
String murmur2Hash2 = "2";
Bundle bundle = new Bundle();
+ bundle.putString(WebApkMetaDataKeys.START_URL, START_URL);
bundle.putString(WebApkMetaDataKeys.ICON_URLS_AND_ICON_MURMUR2_HASHES,
iconUrl1 + " " + murmur2Hash1 + " " + iconUrl2 + " " + murmur2Hash2);
WebApkTestHelper.registerWebApkWithMetaData(bundle);
@@ -165,6 +194,7 @@ public class WebApkInfoTest {
String hash = "18446744073709551615"; // 2^64 - 1
Bundle bundle = new Bundle();
+ bundle.putString(WebApkMetaDataKeys.START_URL, START_URL);
bundle.putString(WebApkMetaDataKeys.ICON_URLS_AND_ICON_MURMUR2_HASHES, "randomUrl " + hash);
WebApkTestHelper.registerWebApkWithMetaData(bundle);
Intent intent = new Intent();
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkUpdateDataFetcherTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698