OLD | NEW |
| (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.content.Intent; | |
8 import android.test.suitebuilder.annotation.MediumTest; | |
9 | |
10 import org.chromium.base.test.util.DisableIf; | |
11 import org.chromium.base.test.util.Feature; | |
12 import org.chromium.chrome.browser.ShortcutHelper; | |
13 import org.chromium.components.security_state.ConnectionSecurityLevel; | |
14 | |
15 /** | |
16 * Tests the logic in top controls visibility delegate in WebappActivity. | |
17 */ | |
18 public class WebappVisibilityTest extends WebappActivityTestBase { | |
19 private static final String WEBAPP_URL = "http://originalwebsite.com"; | |
20 | |
21 @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 { | |
30 super.setUp(); | |
31 startWebappActivity(); | |
32 } | |
33 | |
34 @MediumTest | |
35 @Feature({"Webapps"}) | |
36 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/614336") | |
37 public void testShouldShowTopControls() { | |
38 // Show top controls for out-of-domain URLs. | |
39 assertTrue(getActivity().shouldShowTopControls( | |
40 "http://notoriginalwebsite.com", ConnectionSecurityLevel.NONE)); | |
41 assertTrue(getActivity().shouldShowTopControls( | |
42 "http://otherwebsite.com", ConnectionSecurityLevel.NONE)); | |
43 | |
44 // Do not show top controls for subdomains and private registries that a
re secure. | |
45 assertFalse(getActivity().shouldShowTopControls( | |
46 "http://sub.originalwebsite.com", ConnectionSecurityLevel.NONE))
; | |
47 assertFalse(getActivity().shouldShowTopControls( | |
48 "http://thing.originalwebsite.com", ConnectionSecurityLevel.NONE
)); | |
49 assertFalse(getActivity().shouldShowTopControls(WEBAPP_URL, ConnectionSe
curityLevel.NONE)); | |
50 assertFalse(getActivity().shouldShowTopControls( | |
51 WEBAPP_URL + "/things.html", ConnectionSecurityLevel.NONE)); | |
52 assertFalse(getActivity().shouldShowTopControls( | |
53 WEBAPP_URL + "/stuff.html", ConnectionSecurityLevel.NONE)); | |
54 | |
55 // Do not show top controls when URL is not available yet. | |
56 assertFalse(getActivity().shouldShowTopControls("", ConnectionSecurityLe
vel.NONE)); | |
57 | |
58 // Show top controls for non secure URLs. | |
59 assertTrue(getActivity().shouldShowTopControls( | |
60 "http://sub.originalwebsite.com", ConnectionSecurityLevel.SECURI
TY_WARNING)); | |
61 assertTrue(getActivity().shouldShowTopControls( | |
62 "http://notoriginalwebsite.com", ConnectionSecurityLevel.SECURIT
Y_ERROR)); | |
63 assertTrue(getActivity().shouldShowTopControls( | |
64 "http://otherwebsite.com", ConnectionSecurityLevel.SECURITY_ERRO
R)); | |
65 assertTrue(getActivity().shouldShowTopControls( | |
66 "http://thing.originalwebsite.com", ConnectionSecurityLevel.SECU
RITY_ERROR)); | |
67 assertTrue(getActivity().shouldShowTopControls( | |
68 WEBAPP_URL, ConnectionSecurityLevel.SECURITY_WARNING)); | |
69 assertTrue(getActivity().shouldShowTopControls( | |
70 WEBAPP_URL + "/things.html", ConnectionSecurityLevel.SECURITY_WA
RNING)); | |
71 assertTrue(getActivity().shouldShowTopControls( | |
72 WEBAPP_URL + "/stuff.html", ConnectionSecurityLevel.SECURITY_WAR
NING)); | |
73 } | |
74 } | |
OLD | NEW |