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

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

Issue 2018113002: Upstream: Do not show the add-to-homescreen/install-native-app infobar for WebAPKs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « chrome/android/java_sources.gni ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
8 import android.test.suitebuilder.annotation.MediumTest; 7 import android.test.suitebuilder.annotation.MediumTest;
9 8
10 import org.chromium.base.test.util.DisableIf;
11 import org.chromium.base.test.util.Feature; 9 import org.chromium.base.test.util.Feature;
12 import org.chromium.chrome.browser.ShortcutHelper;
13 import org.chromium.components.security_state.ConnectionSecurityLevel; 10 import org.chromium.components.security_state.ConnectionSecurityLevel;
11 import org.chromium.content.browser.test.NativeLibraryTestBase;
14 12
15 /** 13 /**
16 * Tests the logic in top controls visibility delegate in WebappActivity. 14 * Tests for {@link WebappDelegateFactory}.
17 */ 15 */
18 public class WebappVisibilityTest extends WebappActivityTestBase { 16 public class WebappVisibilityTest extends NativeLibraryTestBase {
19 private static final String WEBAPP_URL = "http://originalwebsite.com"; 17 private static final String WEBAPP_URL = "http://originalwebsite.com";
20 18
21 @Override 19 @Override
22 protected Intent createIntent() {
23 Intent intent = super.createIntent();
24 intent.putExtra(ShortcutHelper.EXTRA_URL, WEBAPP_URL);
25 return intent;
26 }
27
28 @Override
29 protected void setUp() throws Exception { 20 protected void setUp() throws Exception {
30 super.setUp(); 21 super.setUp();
31 startWebappActivity(); 22 loadNativeLibraryNoBrowserProcess();
32 } 23 }
33 24
34 @MediumTest 25 @MediumTest
35 @Feature({"Webapps"}) 26 @Feature({"Webapps"})
36 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/614336")
37 public void testShouldShowTopControls() { 27 public void testShouldShowTopControls() {
38 // Show top controls for out-of-domain URLs. 28 // Show top controls for out-of-domain URLs.
39 assertTrue(getActivity().shouldShowTopControls( 29 assertTrue(shouldShowTopControls(
40 "http://notoriginalwebsite.com", ConnectionSecurityLevel.NONE)); 30 WEBAPP_URL, "http://notoriginalwebsite.com", ConnectionSecurityL evel.NONE));
41 assertTrue(getActivity().shouldShowTopControls( 31 assertTrue(shouldShowTopControls(
42 "http://otherwebsite.com", ConnectionSecurityLevel.NONE)); 32 WEBAPP_URL, "http://otherwebsite.com", ConnectionSecurityLevel.N ONE));
43 33
44 // Do not show top controls for subdomains and private registries that a re secure. 34 // Do not show top controls for subdomains and private registries that a re secure.
45 assertFalse(getActivity().shouldShowTopControls( 35 assertFalse(shouldShowTopControls(
46 "http://sub.originalwebsite.com", ConnectionSecurityLevel.NONE)) ; 36 WEBAPP_URL, "http://sub.originalwebsite.com", ConnectionSecurity Level.NONE));
47 assertFalse(getActivity().shouldShowTopControls( 37 assertFalse(shouldShowTopControls(
48 "http://thing.originalwebsite.com", ConnectionSecurityLevel.NONE )); 38 WEBAPP_URL, "http://thing.originalwebsite.com", ConnectionSecuri tyLevel.NONE));
49 assertFalse(getActivity().shouldShowTopControls(WEBAPP_URL, ConnectionSe curityLevel.NONE)); 39 assertFalse(shouldShowTopControls(WEBAPP_URL, WEBAPP_URL, ConnectionSecu rityLevel.NONE));
50 assertFalse(getActivity().shouldShowTopControls( 40 assertFalse(shouldShowTopControls(
51 WEBAPP_URL + "/things.html", ConnectionSecurityLevel.NONE)); 41 WEBAPP_URL, WEBAPP_URL + "/things.html", ConnectionSecurityLevel .NONE));
52 assertFalse(getActivity().shouldShowTopControls( 42 assertFalse(shouldShowTopControls(
53 WEBAPP_URL + "/stuff.html", ConnectionSecurityLevel.NONE)); 43 WEBAPP_URL, WEBAPP_URL + "/stuff.html", ConnectionSecurityLevel. NONE));
54 44
55 // Do not show top controls when URL is not available yet. 45 // Do not show top controls when URL is not available yet.
56 assertFalse(getActivity().shouldShowTopControls("", ConnectionSecurityLe vel.NONE)); 46 assertFalse(shouldShowTopControls(WEBAPP_URL, "", ConnectionSecurityLeve l.NONE));
57 47
58 // Show top controls for non secure URLs. 48 // Show top controls for non secure URLs.
59 assertTrue(getActivity().shouldShowTopControls( 49 assertTrue(shouldShowTopControls(WEBAPP_URL, "http://sub.originalwebsite .com",
60 "http://sub.originalwebsite.com", ConnectionSecurityLevel.SECURI TY_WARNING)); 50 ConnectionSecurityLevel.SECURITY_WARNING));
61 assertTrue(getActivity().shouldShowTopControls( 51 assertTrue(shouldShowTopControls(WEBAPP_URL, "http://notoriginalwebsite. com",
62 "http://notoriginalwebsite.com", ConnectionSecurityLevel.SECURIT Y_ERROR)); 52 ConnectionSecurityLevel.SECURITY_ERROR));
63 assertTrue(getActivity().shouldShowTopControls( 53 assertTrue(shouldShowTopControls(
64 "http://otherwebsite.com", ConnectionSecurityLevel.SECURITY_ERRO R)); 54 WEBAPP_URL, "http://otherwebsite.com", ConnectionSecurityLevel.S ECURITY_ERROR));
65 assertTrue(getActivity().shouldShowTopControls( 55 assertTrue(shouldShowTopControls(WEBAPP_URL, "http://thing.originalwebsi te.com",
66 "http://thing.originalwebsite.com", ConnectionSecurityLevel.SECU RITY_ERROR)); 56 ConnectionSecurityLevel.SECURITY_ERROR));
67 assertTrue(getActivity().shouldShowTopControls( 57 assertTrue(shouldShowTopControls(
68 WEBAPP_URL, ConnectionSecurityLevel.SECURITY_WARNING)); 58 WEBAPP_URL, WEBAPP_URL, ConnectionSecurityLevel.SECURITY_WARNING ));
69 assertTrue(getActivity().shouldShowTopControls( 59 assertTrue(shouldShowTopControls(
70 WEBAPP_URL + "/things.html", ConnectionSecurityLevel.SECURITY_WA RNING)); 60 WEBAPP_URL, WEBAPP_URL + "/things.html", ConnectionSecurityLevel .SECURITY_WARNING));
71 assertTrue(getActivity().shouldShowTopControls( 61 assertTrue(shouldShowTopControls(
72 WEBAPP_URL + "/stuff.html", ConnectionSecurityLevel.SECURITY_WAR NING)); 62 WEBAPP_URL, WEBAPP_URL + "/stuff.html", ConnectionSecurityLevel. SECURITY_WARNING));
63 }
64
65 /**
66 * Convenience wrapper for WebappDelegateFactory.TopControlsDelegate#shouldS howTopControls()
67 */
68 private static boolean shouldShowTopControls(
69 String webappStartUrl, String url, int securityLevel) {
70 return WebappDelegateFactory.TopControlsDelegate.shouldShowTopControls(
71 webappStartUrl, url, securityLevel);
73 } 72 }
74 } 73 }
OLDNEW
« no previous file with comments | « chrome/android/java_sources.gni ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698