OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.test.InstrumentationTestCase; | 8 import android.test.InstrumentationTestCase; |
9 import android.test.suitebuilder.annotation.SmallTest; | 9 import android.test.suitebuilder.annotation.SmallTest; |
10 | 10 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 String url = "https://www.foo.com/homepage.html"; | 204 String url = "https://www.foo.com/homepage.html"; |
205 Intent intent = createIntentWithUrlAndId(); | 205 Intent intent = createIntentWithUrlAndId(); |
206 intent.putExtra(ShortcutHelper.EXTRA_URL, url); | 206 intent.putExtra(ShortcutHelper.EXTRA_URL, url); |
207 WebappInfo info = WebappInfo.create(intent); | 207 WebappInfo info = WebappInfo.create(intent); |
208 assertEquals(ShortcutHelper.getScopeFromUrl(url), info.scopeUri().toStri
ng()); | 208 assertEquals(ShortcutHelper.getScopeFromUrl(url), info.scopeUri().toStri
ng()); |
209 } | 209 } |
210 | 210 |
211 @SmallTest | 211 @SmallTest |
212 @Feature({"Webapps", "WebApk"}) | 212 @Feature({"Webapps", "WebApk"}) |
213 public void testIntentDisplayMode() { | 213 public void testIntentDisplayMode() { |
214 { | 214 Intent intent = createIntentWithUrlAndId(); |
215 Intent intent = createIntentWithUrlAndId(); | 215 intent.putExtra(ShortcutHelper.EXTRA_DISPLAY_MODE, WebDisplayMode.Minima
lUi); |
216 intent.putExtra(ShortcutHelper.EXTRA_DISPLAY_MODE, WebDisplayMode.Mi
nimalUi); | 216 WebappInfo info = WebappInfo.create(intent); |
217 WebappInfo info = WebappInfo.create(intent); | 217 assertEquals(WebDisplayMode.MinimalUi, info.displayMode()); |
218 assertEquals(WebDisplayMode.MinimalUi, info.displayMode()); | |
219 } | |
220 { | |
221 Intent intent = createIntentWithUrlAndId(); | |
222 intent.putExtra(WebApkConstants.EXTRA_WEBAPK_DISPLAY_MODE, "fullscre
en"); | |
223 WebappInfo info = WebappInfo.create(intent); | |
224 assertEquals(WebDisplayMode.Fullscreen, info.displayMode()); | |
225 } | |
226 { | |
227 // EXTRA_WEBAPK_DISPLAY_MODE takes precedence over EXTRA_DISPLAY_MOD
E. | |
228 Intent intent = createIntentWithUrlAndId(); | |
229 intent.putExtra(WebApkConstants.EXTRA_WEBAPK_DISPLAY_MODE, "fullscre
en"); | |
230 intent.putExtra(ShortcutHelper.EXTRA_DISPLAY_MODE, WebDisplayMode.Mi
nimalUi); | |
231 WebappInfo info = WebappInfo.create(intent); | |
232 assertEquals(WebDisplayMode.Fullscreen, info.displayMode()); | |
233 } | |
234 { | |
235 Intent intent = createIntentWithUrlAndId(); | |
236 intent.putExtra(WebApkConstants.EXTRA_WEBAPK_DISPLAY_MODE, "invalid"
); | |
237 WebappInfo info = WebappInfo.create(intent); | |
238 assertEquals(WebDisplayMode.Standalone, info.displayMode()); | |
239 } | |
240 } | 218 } |
241 | 219 |
242 @SmallTest | 220 @SmallTest |
243 @Feature({"Webapps", "WebApk"}) | 221 @Feature({"Webapps", "WebApk"}) |
244 public void testIntentOrientation() { | 222 public void testIntentOrientation() { |
245 { | 223 Intent intent = createIntentWithUrlAndId(); |
246 Intent intent = createIntentWithUrlAndId(); | 224 intent.putExtra(ShortcutHelper.EXTRA_ORIENTATION, ScreenOrientationValue
s.LANDSCAPE); |
247 intent.putExtra(ShortcutHelper.EXTRA_ORIENTATION, ScreenOrientationV
alues.LANDSCAPE); | 225 WebappInfo info = WebappInfo.create(intent); |
248 WebappInfo info = WebappInfo.create(intent); | 226 assertEquals(ScreenOrientationValues.LANDSCAPE, info.orientation()); |
249 assertEquals(ScreenOrientationValues.LANDSCAPE, info.orientation()); | |
250 } | |
251 { | |
252 Intent intent = createIntentWithUrlAndId(); | |
253 intent.putExtra(WebApkConstants.EXTRA_WEBAPK_ORIENTATION, "natural")
; | |
254 WebappInfo info = WebappInfo.create(intent); | |
255 assertEquals(ScreenOrientationValues.NATURAL, info.orientation()); | |
256 } | |
257 { | |
258 // EXTRA_WEBAPK_ORIENTATION takes precedence over EXTRA_ORIENTATION. | |
259 Intent intent = createIntentWithUrlAndId(); | |
260 intent.putExtra(WebApkConstants.EXTRA_WEBAPK_ORIENTATION, "natural")
; | |
261 intent.putExtra(ShortcutHelper.EXTRA_ORIENTATION, ScreenOrientationV
alues.LANDSCAPE); | |
262 WebappInfo info = WebappInfo.create(intent); | |
263 assertEquals(ScreenOrientationValues.NATURAL, info.orientation()); | |
264 } | |
265 { | |
266 Intent intent = createIntentWithUrlAndId(); | |
267 intent.putExtra(WebApkConstants.EXTRA_WEBAPK_ORIENTATION, "invalid")
; | |
268 WebappInfo info = WebappInfo.create(intent); | |
269 assertEquals(ScreenOrientationValues.DEFAULT, info.orientation()); | |
270 } | |
271 } | 227 } |
272 | 228 |
273 @SmallTest | 229 @SmallTest |
274 @Feature({"Webapps"}) | 230 @Feature({"Webapps"}) |
275 public void testIntentGeneratedIcon() { | 231 public void testIntentGeneratedIcon() { |
276 String id = "webapp id"; | 232 String id = "webapp id"; |
277 String name = "longName"; | 233 String name = "longName"; |
278 String shortName = "name"; | 234 String shortName = "name"; |
279 String url = "about:blank"; | 235 String url = "about:blank"; |
280 | 236 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 * Creates intent with url and id. If the url or id are not set WebappInfo#c
reate() returns | 298 * Creates intent with url and id. If the url or id are not set WebappInfo#c
reate() returns |
343 * null. | 299 * null. |
344 */ | 300 */ |
345 private Intent createIntentWithUrlAndId() { | 301 private Intent createIntentWithUrlAndId() { |
346 Intent intent = new Intent(); | 302 Intent intent = new Intent(); |
347 intent.putExtra(ShortcutHelper.EXTRA_ID, "web app id"); | 303 intent.putExtra(ShortcutHelper.EXTRA_ID, "web app id"); |
348 intent.putExtra(ShortcutHelper.EXTRA_URL, "about:blank"); | 304 intent.putExtra(ShortcutHelper.EXTRA_URL, "about:blank"); |
349 return intent; | 305 return intent; |
350 } | 306 } |
351 } | 307 } |
OLD | NEW |