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