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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappDelegateFactoryTest.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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.webapps;
6
7 import android.test.suitebuilder.annotation.MediumTest;
8
9 import org.chromium.base.test.util.Feature;
10 import org.chromium.components.security_state.ConnectionSecurityLevel;
11 import org.chromium.content.browser.test.NativeLibraryTestBase;
12
13 /**
14 * Tests for {@link WebappDelegateFactory}.
15 */
16 public class WebappDelegateFactoryTest extends NativeLibraryTestBase {
17 private static final String WEBAPP_URL = "http://originalwebsite.com";
18
19 @Override
20 protected void setUp() throws Exception {
21 super.setUp();
22 loadNativeLibraryNoBrowserProcess();
23 }
24
25 @MediumTest
gone 2016/05/31 18:26:56 This test is disabled on trunk, which you didn't c
pkotwicz 2016/05/31 20:14:27 I changed the test to be more of a unit test than
26 @Feature({"Webapps"})
27 public void testShouldShowTopControls() {
28 // Show top controls for out-of-domain URLs.
29 assertTrue(shouldShowTopControls(
30 WEBAPP_URL, "http://notoriginalwebsite.com", ConnectionSecurityL evel.NONE));
31 assertTrue(shouldShowTopControls(
32 WEBAPP_URL, "http://otherwebsite.com", ConnectionSecurityLevel.N ONE));
33
34 // Do not show top controls for subdomains and private registries that a re secure.
35 assertFalse(shouldShowTopControls(
36 WEBAPP_URL, "http://sub.originalwebsite.com", ConnectionSecurity Level.NONE));
37 assertFalse(shouldShowTopControls(
38 WEBAPP_URL, "http://thing.originalwebsite.com", ConnectionSecuri tyLevel.NONE));
39 assertFalse(shouldShowTopControls(WEBAPP_URL, WEBAPP_URL, ConnectionSecu rityLevel.NONE));
40 assertFalse(shouldShowTopControls(
41 WEBAPP_URL, WEBAPP_URL + "/things.html", ConnectionSecurityLevel .NONE));
42 assertFalse(shouldShowTopControls(
43 WEBAPP_URL, WEBAPP_URL + "/stuff.html", ConnectionSecurityLevel. NONE));
44
45 // Do not show top controls when URL is not available yet.
46 assertFalse(shouldShowTopControls(WEBAPP_URL, "", ConnectionSecurityLeve l.NONE));
47
48 // Show top controls for non secure URLs.
49 assertTrue(shouldShowTopControls(WEBAPP_URL, "http://sub.originalwebsite .com",
50 ConnectionSecurityLevel.SECURITY_WARNING));
51 assertTrue(shouldShowTopControls(WEBAPP_URL, "http://notoriginalwebsite. com",
52 ConnectionSecurityLevel.SECURITY_ERROR));
53 assertTrue(shouldShowTopControls(
54 WEBAPP_URL, "http://otherwebsite.com", ConnectionSecurityLevel.S ECURITY_ERROR));
55 assertTrue(shouldShowTopControls(WEBAPP_URL, "http://thing.originalwebsi te.com",
56 ConnectionSecurityLevel.SECURITY_ERROR));
57 assertTrue(shouldShowTopControls(
58 WEBAPP_URL, WEBAPP_URL, ConnectionSecurityLevel.SECURITY_WARNING ));
59 assertTrue(shouldShowTopControls(
60 WEBAPP_URL, WEBAPP_URL + "/things.html", ConnectionSecurityLevel .SECURITY_WARNING));
61 assertTrue(shouldShowTopControls(
62 WEBAPP_URL, WEBAPP_URL + "/stuff.html", ConnectionSecurityLevel. SECURITY_WARNING));
63 }
64
65 /**
66 * Convenience wrapper for WebappDelegateFactory.TopControlsDelegate#shouldS howTopControls()
67 */
68 private boolean shouldShowTopControls(
69 String webappStartUrl, String url, int securityLevel) {
70 return WebappDelegateFactory.TopControlsDelegate.shouldShowTopControls(
71 webappStartUrl, url, securityLevel);
72 }
73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698