Chromium Code Reviews| Index: chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappDelegateFactoryTest.java |
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappDelegateFactoryTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappDelegateFactoryTest.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9895e9ad3f1311aea2f78217a7c561f7f224b1a0 |
| --- /dev/null |
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappDelegateFactoryTest.java |
| @@ -0,0 +1,73 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.chrome.browser.webapps; |
| + |
| +import android.test.suitebuilder.annotation.MediumTest; |
| + |
| +import org.chromium.base.test.util.Feature; |
| +import org.chromium.components.security_state.ConnectionSecurityLevel; |
| +import org.chromium.content.browser.test.NativeLibraryTestBase; |
| + |
| +/** |
| + * Tests for {@link WebappDelegateFactory}. |
| + */ |
| +public class WebappDelegateFactoryTest extends NativeLibraryTestBase { |
| + private static final String WEBAPP_URL = "http://originalwebsite.com"; |
| + |
| + @Override |
| + protected void setUp() throws Exception { |
| + super.setUp(); |
| + loadNativeLibraryNoBrowserProcess(); |
| + } |
| + |
| + @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
|
| + @Feature({"Webapps"}) |
| + public void testShouldShowTopControls() { |
| + // Show top controls for out-of-domain URLs. |
| + assertTrue(shouldShowTopControls( |
| + WEBAPP_URL, "http://notoriginalwebsite.com", ConnectionSecurityLevel.NONE)); |
| + assertTrue(shouldShowTopControls( |
| + WEBAPP_URL, "http://otherwebsite.com", ConnectionSecurityLevel.NONE)); |
| + |
| + // Do not show top controls for subdomains and private registries that are secure. |
| + assertFalse(shouldShowTopControls( |
| + WEBAPP_URL, "http://sub.originalwebsite.com", ConnectionSecurityLevel.NONE)); |
| + assertFalse(shouldShowTopControls( |
| + WEBAPP_URL, "http://thing.originalwebsite.com", ConnectionSecurityLevel.NONE)); |
| + assertFalse(shouldShowTopControls(WEBAPP_URL, WEBAPP_URL, ConnectionSecurityLevel.NONE)); |
| + assertFalse(shouldShowTopControls( |
| + WEBAPP_URL, WEBAPP_URL + "/things.html", ConnectionSecurityLevel.NONE)); |
| + assertFalse(shouldShowTopControls( |
| + WEBAPP_URL, WEBAPP_URL + "/stuff.html", ConnectionSecurityLevel.NONE)); |
| + |
| + // Do not show top controls when URL is not available yet. |
| + assertFalse(shouldShowTopControls(WEBAPP_URL, "", ConnectionSecurityLevel.NONE)); |
| + |
| + // Show top controls for non secure URLs. |
| + assertTrue(shouldShowTopControls(WEBAPP_URL, "http://sub.originalwebsite.com", |
| + ConnectionSecurityLevel.SECURITY_WARNING)); |
| + assertTrue(shouldShowTopControls(WEBAPP_URL, "http://notoriginalwebsite.com", |
| + ConnectionSecurityLevel.SECURITY_ERROR)); |
| + assertTrue(shouldShowTopControls( |
| + WEBAPP_URL, "http://otherwebsite.com", ConnectionSecurityLevel.SECURITY_ERROR)); |
| + assertTrue(shouldShowTopControls(WEBAPP_URL, "http://thing.originalwebsite.com", |
| + ConnectionSecurityLevel.SECURITY_ERROR)); |
| + assertTrue(shouldShowTopControls( |
| + WEBAPP_URL, WEBAPP_URL, ConnectionSecurityLevel.SECURITY_WARNING)); |
| + assertTrue(shouldShowTopControls( |
| + WEBAPP_URL, WEBAPP_URL + "/things.html", ConnectionSecurityLevel.SECURITY_WARNING)); |
| + assertTrue(shouldShowTopControls( |
| + WEBAPP_URL, WEBAPP_URL + "/stuff.html", ConnectionSecurityLevel.SECURITY_WARNING)); |
| + } |
| + |
| + /** |
| + * Convenience wrapper for WebappDelegateFactory.TopControlsDelegate#shouldShowTopControls() |
| + */ |
| + private boolean shouldShowTopControls( |
| + String webappStartUrl, String url, int securityLevel) { |
| + return WebappDelegateFactory.TopControlsDelegate.shouldShowTopControls( |
| + webappStartUrl, url, securityLevel); |
| + } |
| +} |