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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappVisibilityTest.java

Issue 1989283002: Upstream: Launch WebApkActivity from WebAPK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 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.test.suitebuilder.annotation.MediumTest; 8 import android.test.suitebuilder.annotation.MediumTest;
8 9
9 import org.chromium.base.test.util.Feature; 10 import org.chromium.base.test.util.Feature;
10 import org.chromium.chrome.browser.ShortcutHelper; 11 import org.chromium.chrome.browser.ShortcutHelper;
11 import org.chromium.chrome.browser.ShortcutSource;
12 import org.chromium.components.security_state.ConnectionSecurityLevel; 12 import org.chromium.components.security_state.ConnectionSecurityLevel;
13 import org.chromium.content_public.common.ScreenOrientationValues;
14 13
15 /** 14 /**
16 * Tests the logic in top controls visibility delegate in WebappActivity. 15 * Tests the logic in top controls visibility delegate in WebappActivity.
17 */ 16 */
18 public class WebappVisibilityTest extends WebappActivityTestBase { 17 public class WebappVisibilityTest extends WebappActivityTestBase {
18 private static final String WEBAPP_URL = "http://originalwebsite.com";
19
20 @Override
21 protected Intent createIntent() {
pkotwicz 2016/05/18 23:00:18 Sorry I should have given you a link to the CL. Th
Xi Han 2016/05/19 18:31:50 That is ok, I follow that CL so the changes are co
22 Intent intent = super.createIntent();
23 intent.putExtra(ShortcutHelper.EXTRA_URL, WEBAPP_URL);
24 return intent;
25 }
26
19 @Override 27 @Override
20 protected void setUp() throws Exception { 28 protected void setUp() throws Exception {
21 super.setUp(); 29 super.setUp();
22 startWebappActivity(); 30 startWebappActivity();
23 } 31 }
24 32
25 @MediumTest 33 @MediumTest
26 @Feature({"Webapps"}) 34 @Feature({"Webapps"})
27 public void testShouldShowTopControls() { 35 public void testShouldShowTopControls() {
28 final String webappUrl = "http://originalwebsite.com";
29 WebappInfo mockInfo = WebappInfo.create(WEBAPP_ID, webappUrl, null,
30 null, null, ScreenOrientationValues.DEFAULT, ShortcutSource.UNKN OWN,
31 ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING,
32 ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING, false);
33 getActivity().getWebappInfo().copy(mockInfo);
34 36
35 // Show top controls for out-of-domain URLs. 37 // Show top controls for out-of-domain URLs.
36 assertTrue(getActivity().shouldShowTopControls( 38 assertTrue(getActivity().shouldShowTopControls(
37 "http://notoriginalwebsite.com", ConnectionSecurityLevel.NONE)); 39 "http://notoriginalwebsite.com", ConnectionSecurityLevel.NONE));
38 assertTrue(getActivity().shouldShowTopControls( 40 assertTrue(getActivity().shouldShowTopControls(
39 "http://otherwebsite.com", ConnectionSecurityLevel.NONE)); 41 "http://otherwebsite.com", ConnectionSecurityLevel.NONE));
40 42
41 // Do not show top controls for subdomains and private registries that a re secure. 43 // Do not show top controls for subdomains and private registries that a re secure.
42 assertFalse(getActivity().shouldShowTopControls( 44 assertFalse(getActivity().shouldShowTopControls(
43 "http://sub.originalwebsite.com", ConnectionSecurityLevel.NONE)) ; 45 "http://sub.originalwebsite.com", ConnectionSecurityLevel.NONE)) ;
44 assertFalse(getActivity().shouldShowTopControls( 46 assertFalse(getActivity().shouldShowTopControls(
45 "http://thing.originalwebsite.com", ConnectionSecurityLevel.NONE )); 47 "http://thing.originalwebsite.com", ConnectionSecurityLevel.NONE ));
46 assertFalse(getActivity().shouldShowTopControls(webappUrl, ConnectionSec urityLevel.NONE)); 48 assertFalse(getActivity().shouldShowTopControls(WEBAPP_URL, ConnectionSe curityLevel.NONE));
47 assertFalse(getActivity().shouldShowTopControls( 49 assertFalse(getActivity().shouldShowTopControls(
48 webappUrl + "/things.html", ConnectionSecurityLevel.NONE)); 50 WEBAPP_URL + "/things.html", ConnectionSecurityLevel.NONE));
49 assertFalse(getActivity().shouldShowTopControls( 51 assertFalse(getActivity().shouldShowTopControls(
50 webappUrl + "/stuff.html", ConnectionSecurityLevel.NONE)); 52 WEBAPP_URL + "/stuff.html", ConnectionSecurityLevel.NONE));
51 53
52 // Do not show top controls when URL is not available yet. 54 // Do not show top controls when URL is not available yet.
53 assertFalse(getActivity().shouldShowTopControls("", ConnectionSecurityLe vel.NONE)); 55 assertFalse(getActivity().shouldShowTopControls("", ConnectionSecurityLe vel.NONE));
54 56
55 // Show top controls for non secure URLs. 57 // Show top controls for non secure URLs.
56 assertTrue(getActivity().shouldShowTopControls( 58 assertTrue(getActivity().shouldShowTopControls(
57 "http://sub.originalwebsite.com", ConnectionSecurityLevel.SECURI TY_WARNING)); 59 "http://sub.originalwebsite.com", ConnectionSecurityLevel.SECURI TY_WARNING));
58 assertTrue(getActivity().shouldShowTopControls( 60 assertTrue(getActivity().shouldShowTopControls(
59 "http://notoriginalwebsite.com", ConnectionSecurityLevel.SECURIT Y_ERROR)); 61 "http://notoriginalwebsite.com", ConnectionSecurityLevel.SECURIT Y_ERROR));
60 assertTrue(getActivity().shouldShowTopControls( 62 assertTrue(getActivity().shouldShowTopControls(
61 "http://otherwebsite.com", ConnectionSecurityLevel.SECURITY_ERRO R)); 63 "http://otherwebsite.com", ConnectionSecurityLevel.SECURITY_ERRO R));
62 assertTrue(getActivity().shouldShowTopControls( 64 assertTrue(getActivity().shouldShowTopControls(
63 "http://thing.originalwebsite.com", ConnectionSecurityLevel.SECU RITY_ERROR)); 65 "http://thing.originalwebsite.com", ConnectionSecurityLevel.SECU RITY_ERROR));
64 assertTrue(getActivity().shouldShowTopControls( 66 assertTrue(getActivity().shouldShowTopControls(
65 webappUrl, ConnectionSecurityLevel.SECURITY_WARNING)); 67 WEBAPP_URL, ConnectionSecurityLevel.SECURITY_WARNING));
66 assertTrue(getActivity().shouldShowTopControls( 68 assertTrue(getActivity().shouldShowTopControls(
67 webappUrl + "/things.html", ConnectionSecurityLevel.SECURITY_WAR NING)); 69 WEBAPP_URL + "/things.html", ConnectionSecurityLevel.SECURITY_WA RNING));
68 assertTrue(getActivity().shouldShowTopControls( 70 assertTrue(getActivity().shouldShowTopControls(
69 webappUrl + "/stuff.html", ConnectionSecurityLevel.SECURITY_WARN ING)); 71 WEBAPP_URL + "/stuff.html", ConnectionSecurityLevel.SECURITY_WAR NING));
70 } 72 }
71 } 73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698