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

Side by Side 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, 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.webapps; 5 package org.chromium.chrome.browser.webapps;
6 6
7 import android.content.Intent; 7 import android.content.Intent;
8 import android.content.res.AssetManager; 8 import android.content.res.AssetManager;
9 import android.content.res.Resources; 9 import android.content.res.Resources;
10 import android.os.Bundle; 10 import android.os.Bundle;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 171
172 WebApkInfo info = WebApkInfo.create(intent); 172 WebApkInfo info = WebApkInfo.create(intent);
173 Assert.assertEquals(intentStartUrl, info.uri().toString()); 173 Assert.assertEquals(intentStartUrl, info.uri().toString());
174 174
175 // {@link WebApkInfo#manifestStartUrl()} should contain the start URL fr om the Android 175 // {@link WebApkInfo#manifestStartUrl()} should contain the start URL fr om the Android
176 // Manifest. 176 // Manifest.
177 Assert.assertEquals(START_URL, info.manifestStartUrl()); 177 Assert.assertEquals(START_URL, info.manifestStartUrl());
178 } 178 }
179 179
180 /** 180 /**
181 * Test that {@link WebApkInfo#create()} rewrites {@link WebApkInfo#uri()} w hen the start URL
182 * from the intent is outside of the scope in the WebAPK Android Manifest.
183 */
184 @Test
185 public void testRewriteStartUrlSchemeAndHost() {
186 final String intentStartUrl = "http://www.google.ca/search_results?q=eh# cr=countryCA";
187 final String expectedRewrittenStartUrl =
188 "https://www.google.com/search_results?q=eh#cr=countryCA";
189 final String manifestStartUrl = "https://www.google.com/";
190 final String manifestScope = "https://www.google.com/";
191
192 Bundle bundle = new Bundle();
193 bundle.putString(WebApkMetaDataKeys.START_URL, manifestStartUrl);
194 bundle.putString(WebApkMetaDataKeys.SCOPE, manifestScope);
195 WebApkTestHelper.registerWebApkWithMetaData(WEBAPK_PACKAGE_NAME, bundle) ;
196
197 Intent intent = new Intent();
198 intent.putExtra(WebApkConstants.EXTRA_WEBAPK_PACKAGE_NAME, WEBAPK_PACKAG E_NAME);
199 intent.putExtra(ShortcutHelper.EXTRA_URL, intentStartUrl);
200
201 WebApkInfo info = WebApkInfo.create(intent);
202
203 Assert.assertEquals(expectedRewrittenStartUrl, info.uri().toString());
204 Assert.assertEquals(manifestStartUrl, info.manifestStartUrl());
205 }
206
207 /**
181 * Test that if the scope is empty that the scope is computed from the "star t URL specified from 208 * Test that if the scope is empty that the scope is computed from the "star t URL specified from
182 * the Web Manifest" not the "URL the WebAPK initially navigated to". Deep l inks can open a 209 * the Web Manifest" not the "URL the WebAPK initially navigated to". Deep l inks can open a
183 * WebAPK at an arbitrary URL. 210 * WebAPK at an arbitrary URL.
184 */ 211 */
185 @Test 212 @Test
186 public void testDefaultScopeFromManifestStartUrl() { 213 public void testDefaultScopeFromManifestStartUrl() {
187 String manifestStartUrl = START_URL; 214 String manifestStartUrl = START_URL;
188 String intentStartUrl = "https://www.google.com/a/b/c"; 215 String intentStartUrl = "https://www.google.com/a/b/c";
189 216
190 String scopeFromManifestStartUrl = ShortcutHelper.getScopeFromUrl(manife stStartUrl); 217 String scopeFromManifestStartUrl = ShortcutHelper.getScopeFromUrl(manife stStartUrl);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 365
339 Intent intent = new Intent(); 366 Intent intent = new Intent();
340 intent.putExtra(WebApkConstants.EXTRA_WEBAPK_PACKAGE_NAME, WEBAPK_PACKAG E_NAME); 367 intent.putExtra(WebApkConstants.EXTRA_WEBAPK_PACKAGE_NAME, WEBAPK_PACKAG E_NAME);
341 intent.putExtra(ShortcutHelper.EXTRA_URL, START_URL); 368 intent.putExtra(ShortcutHelper.EXTRA_URL, START_URL);
342 369
343 WebApkInfo info = WebApkInfo.create(intent); 370 WebApkInfo info = WebApkInfo.create(intent);
344 Assert.assertEquals(name, info.name()); 371 Assert.assertEquals(name, info.name());
345 Assert.assertEquals(shortName, info.shortName()); 372 Assert.assertEquals(shortName, info.shortName());
346 } 373 }
347 } 374 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698