| 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.test.suitebuilder.annotation.MediumTest; | 7 import android.test.suitebuilder.annotation.MediumTest; |
| 8 | 8 |
| 9 import org.chromium.base.test.util.Feature; | 9 import org.chromium.base.test.util.Feature; |
| 10 import org.chromium.chrome.browser.ssl.ConnectionSecurityHelperSecurityLevel; | 10 import org.chromium.chrome.browser.ssl.ConnectionSecurityLevel; |
| 11 import org.chromium.content_public.common.ScreenOrientationValues; | 11 import org.chromium.content_public.common.ScreenOrientationValues; |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * Tests the logic in top controls visibility delegate in WebappActivity. | 14 * Tests the logic in top controls visibility delegate in WebappActivity. |
| 15 */ | 15 */ |
| 16 public class WebappVisibilityTest extends WebappActivityTestBase { | 16 public class WebappVisibilityTest extends WebappActivityTestBase { |
| 17 @MediumTest | 17 @MediumTest |
| 18 @Feature({"Webapps"}) | 18 @Feature({"Webapps"}) |
| 19 public void testShouldShowTopControls() { | 19 public void testShouldShowTopControls() { |
| 20 final String webappUrl = "http://originalwebsite.com"; | 20 final String webappUrl = "http://originalwebsite.com"; |
| 21 WebappInfo mockInfo = WebappInfo.create( | 21 WebappInfo mockInfo = WebappInfo.create( |
| 22 WEBAPP_ID, webappUrl, null, null, ScreenOrientationValues.DEFAUL
T); | 22 WEBAPP_ID, webappUrl, null, null, ScreenOrientationValues.DEFAUL
T); |
| 23 getActivity().getWebappInfo().copy(mockInfo); | 23 getActivity().getWebappInfo().copy(mockInfo); |
| 24 | 24 |
| 25 // Show top controls for out-of-domain URLs. | 25 // Show top controls for out-of-domain URLs. |
| 26 assertTrue(getActivity().shouldShowTopControls( | 26 assertTrue(getActivity().shouldShowTopControls( |
| 27 "http://notoriginalwebsite.com", ConnectionSecurityHelperSecurit
yLevel.NONE)); | 27 "http://notoriginalwebsite.com", ConnectionSecurityLevel.NONE)); |
| 28 assertTrue(getActivity().shouldShowTopControls( | 28 assertTrue(getActivity().shouldShowTopControls( |
| 29 "http://otherwebsite.com", ConnectionSecurityHelperSecurityLevel
.NONE)); | 29 "http://otherwebsite.com", ConnectionSecurityLevel.NONE)); |
| 30 | 30 |
| 31 // Do not show top controls for subdomains and private registries that a
re secure. | 31 // Do not show top controls for subdomains and private registries that a
re secure. |
| 32 assertFalse(getActivity().shouldShowTopControls( | 32 assertFalse(getActivity().shouldShowTopControls( |
| 33 "http://sub.originalwebsite.com", ConnectionSecurityHelperSecuri
tyLevel.NONE)); | 33 "http://sub.originalwebsite.com", ConnectionSecurityLevel.NONE))
; |
| 34 assertFalse(getActivity().shouldShowTopControls( | 34 assertFalse(getActivity().shouldShowTopControls( |
| 35 "http://thing.originalwebsite.com", ConnectionSecurityHelperSecu
rityLevel.NONE)); | 35 "http://thing.originalwebsite.com", ConnectionSecurityLevel.NONE
)); |
| 36 assertFalse(getActivity().shouldShowTopControls(webappUrl, | 36 assertFalse(getActivity().shouldShowTopControls(webappUrl, ConnectionSec
urityLevel.NONE)); |
| 37 ConnectionSecurityHelperSecurityLevel.NONE)); | |
| 38 assertFalse(getActivity().shouldShowTopControls( | 37 assertFalse(getActivity().shouldShowTopControls( |
| 39 webappUrl + "/things.html", ConnectionSecurityHelperSecurityLeve
l.NONE)); | 38 webappUrl + "/things.html", ConnectionSecurityLevel.NONE)); |
| 40 assertFalse(getActivity().shouldShowTopControls( | 39 assertFalse(getActivity().shouldShowTopControls( |
| 41 webappUrl + "/stuff.html", ConnectionSecurityHelperSecurityLevel
.NONE)); | 40 webappUrl + "/stuff.html", ConnectionSecurityLevel.NONE)); |
| 42 | 41 |
| 43 // Do not show top controls when URL is not available yet. | 42 // Do not show top controls when URL is not available yet. |
| 44 assertFalse(getActivity().shouldShowTopControls("", | 43 assertFalse(getActivity().shouldShowTopControls("", ConnectionSecurityLe
vel.NONE)); |
| 45 ConnectionSecurityHelperSecurityLevel.NONE)); | |
| 46 | 44 |
| 47 // Show top controls for non secure URLs. | 45 // Show top controls for non secure URLs. |
| 48 assertTrue(getActivity().shouldShowTopControls( | 46 assertTrue(getActivity().shouldShowTopControls( |
| 49 "http://sub.originalwebsite.com", | 47 "http://sub.originalwebsite.com", ConnectionSecurityLevel.SECURI
TY_WARNING)); |
| 50 ConnectionSecurityHelperSecurityLevel.SECURITY_WARNING)); | |
| 51 assertTrue(getActivity().shouldShowTopControls( | 48 assertTrue(getActivity().shouldShowTopControls( |
| 52 "http://notoriginalwebsite.com", | 49 "http://notoriginalwebsite.com", ConnectionSecurityLevel.SECURIT
Y_ERROR)); |
| 53 ConnectionSecurityHelperSecurityLevel.SECURITY_ERROR)); | |
| 54 assertTrue(getActivity().shouldShowTopControls( | 50 assertTrue(getActivity().shouldShowTopControls( |
| 55 "http://otherwebsite.com", | 51 "http://otherwebsite.com", ConnectionSecurityLevel.SECURITY_ERRO
R)); |
| 56 ConnectionSecurityHelperSecurityLevel.SECURITY_ERROR)); | |
| 57 assertTrue(getActivity().shouldShowTopControls( | 52 assertTrue(getActivity().shouldShowTopControls( |
| 58 "http://thing.originalwebsite.com", | 53 "http://thing.originalwebsite.com", ConnectionSecurityLevel.SECU
RITY_ERROR)); |
| 59 ConnectionSecurityHelperSecurityLevel.SECURITY_ERROR)); | |
| 60 assertTrue(getActivity().shouldShowTopControls( | 54 assertTrue(getActivity().shouldShowTopControls( |
| 61 webappUrl, ConnectionSecurityHelperSecurityLevel.SECURITY_WARNIN
G)); | 55 webappUrl, ConnectionSecurityLevel.SECURITY_WARNING)); |
| 62 assertTrue(getActivity().shouldShowTopControls( | 56 assertTrue(getActivity().shouldShowTopControls( |
| 63 webappUrl + "/things.html", | 57 webappUrl + "/things.html", ConnectionSecurityLevel.SECURITY_WAR
NING)); |
| 64 ConnectionSecurityHelperSecurityLevel.SECURITY_WARNING)); | |
| 65 assertTrue(getActivity().shouldShowTopControls( | 58 assertTrue(getActivity().shouldShowTopControls( |
| 66 webappUrl + "/stuff.html", | 59 webappUrl + "/stuff.html", ConnectionSecurityLevel.SECURITY_WARN
ING)); |
| 67 ConnectionSecurityHelperSecurityLevel.SECURITY_WARNING)); | |
| 68 } | 60 } |
| 69 } | 61 } |
| OLD | NEW |