| 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.ShortcutHelper; | 10 import org.chromium.chrome.browser.ShortcutHelper; |
| 11 import org.chromium.chrome.browser.ssl.ConnectionSecurityLevel; | 11 import org.chromium.chrome.browser.ssl.ConnectionSecurityLevel; |
| 12 import org.chromium.content_public.common.ScreenOrientationValues; | 12 import org.chromium.content_public.common.ScreenOrientationValues; |
| 13 | 13 |
| 14 /** | 14 /** |
| 15 * Tests the logic in top controls visibility delegate in WebappActivity. | 15 * Tests the logic in top controls visibility delegate in WebappActivity. |
| 16 */ | 16 */ |
| 17 public class WebappVisibilityTest extends WebappActivityTestBase { | 17 public class WebappVisibilityTest extends WebappActivityTestBase { |
| 18 @MediumTest | 18 @MediumTest |
| 19 @Feature({"Webapps"}) | 19 @Feature({"Webapps"}) |
| 20 public void testShouldShowTopControls() { | 20 public void testShouldShowTopControls() { |
| 21 final String webappUrl = "http://originalwebsite.com"; | 21 final String webappUrl = "http://originalwebsite.com"; |
| 22 WebappInfo mockInfo = WebappInfo.create(WEBAPP_ID, webappUrl, | 22 WebappInfo mockInfo = WebappInfo.create(WEBAPP_ID, webappUrl, |
| 23 null, null, ScreenOrientationValues.DEFAULT, ShortcutHelper.SOUR
CE_UNKNOWN); | 23 null, null, ScreenOrientationValues.DEFAULT, ShortcutHelper.SOUR
CE_UNKNOWN, |
| 24 ShortcutHelper.THEME_COLOR_INVALID_OR_MISSING); |
| 24 getActivity().getWebappInfo().copy(mockInfo); | 25 getActivity().getWebappInfo().copy(mockInfo); |
| 25 | 26 |
| 26 // Show top controls for out-of-domain URLs. | 27 // Show top controls for out-of-domain URLs. |
| 27 assertTrue(getActivity().shouldShowTopControls( | 28 assertTrue(getActivity().shouldShowTopControls( |
| 28 "http://notoriginalwebsite.com", ConnectionSecurityLevel.NONE)); | 29 "http://notoriginalwebsite.com", ConnectionSecurityLevel.NONE)); |
| 29 assertTrue(getActivity().shouldShowTopControls( | 30 assertTrue(getActivity().shouldShowTopControls( |
| 30 "http://otherwebsite.com", ConnectionSecurityLevel.NONE)); | 31 "http://otherwebsite.com", ConnectionSecurityLevel.NONE)); |
| 31 | 32 |
| 32 // Do not show top controls for subdomains and private registries that a
re secure. | 33 // Do not show top controls for subdomains and private registries that a
re secure. |
| 33 assertFalse(getActivity().shouldShowTopControls( | 34 assertFalse(getActivity().shouldShowTopControls( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 53 assertTrue(getActivity().shouldShowTopControls( | 54 assertTrue(getActivity().shouldShowTopControls( |
| 54 "http://thing.originalwebsite.com", ConnectionSecurityLevel.SECU
RITY_ERROR)); | 55 "http://thing.originalwebsite.com", ConnectionSecurityLevel.SECU
RITY_ERROR)); |
| 55 assertTrue(getActivity().shouldShowTopControls( | 56 assertTrue(getActivity().shouldShowTopControls( |
| 56 webappUrl, ConnectionSecurityLevel.SECURITY_WARNING)); | 57 webappUrl, ConnectionSecurityLevel.SECURITY_WARNING)); |
| 57 assertTrue(getActivity().shouldShowTopControls( | 58 assertTrue(getActivity().shouldShowTopControls( |
| 58 webappUrl + "/things.html", ConnectionSecurityLevel.SECURITY_WAR
NING)); | 59 webappUrl + "/things.html", ConnectionSecurityLevel.SECURITY_WAR
NING)); |
| 59 assertTrue(getActivity().shouldShowTopControls( | 60 assertTrue(getActivity().shouldShowTopControls( |
| 60 webappUrl + "/stuff.html", ConnectionSecurityLevel.SECURITY_WARN
ING)); | 61 webappUrl + "/stuff.html", ConnectionSecurityLevel.SECURITY_WARN
ING)); |
| 61 } | 62 } |
| 62 } | 63 } |
| OLD | NEW |