| Index: chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappVisibilityTest.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappVisibilityTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappVisibilityTest.java
|
| index b64925cc4adc8d9a0afd29ded9040f7802d2b391..b0b704230bfdf7db39b81d8ff2d35250337d0432 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappVisibilityTest.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappVisibilityTest.java
|
| @@ -4,71 +4,70 @@
|
|
|
| package org.chromium.chrome.browser.webapps;
|
|
|
| -import android.content.Intent;
|
| import android.test.suitebuilder.annotation.MediumTest;
|
|
|
| -import org.chromium.base.test.util.DisableIf;
|
| import org.chromium.base.test.util.Feature;
|
| -import org.chromium.chrome.browser.ShortcutHelper;
|
| import org.chromium.components.security_state.ConnectionSecurityLevel;
|
| +import org.chromium.content.browser.test.NativeLibraryTestBase;
|
|
|
| /**
|
| - * Tests the logic in top controls visibility delegate in WebappActivity.
|
| + * Tests for {@link WebappDelegateFactory}.
|
| */
|
| -public class WebappVisibilityTest extends WebappActivityTestBase {
|
| +public class WebappVisibilityTest extends NativeLibraryTestBase {
|
| private static final String WEBAPP_URL = "http://originalwebsite.com";
|
|
|
| @Override
|
| - protected Intent createIntent() {
|
| - Intent intent = super.createIntent();
|
| - intent.putExtra(ShortcutHelper.EXTRA_URL, WEBAPP_URL);
|
| - return intent;
|
| - }
|
| -
|
| - @Override
|
| protected void setUp() throws Exception {
|
| super.setUp();
|
| - startWebappActivity();
|
| + loadNativeLibraryNoBrowserProcess();
|
| }
|
|
|
| @MediumTest
|
| @Feature({"Webapps"})
|
| - @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/614336")
|
| public void testShouldShowTopControls() {
|
| // Show top controls for out-of-domain URLs.
|
| - assertTrue(getActivity().shouldShowTopControls(
|
| - "http://notoriginalwebsite.com", ConnectionSecurityLevel.NONE));
|
| - assertTrue(getActivity().shouldShowTopControls(
|
| - "http://otherwebsite.com", ConnectionSecurityLevel.NONE));
|
| + 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(getActivity().shouldShowTopControls(
|
| - "http://sub.originalwebsite.com", ConnectionSecurityLevel.NONE));
|
| - assertFalse(getActivity().shouldShowTopControls(
|
| - "http://thing.originalwebsite.com", ConnectionSecurityLevel.NONE));
|
| - assertFalse(getActivity().shouldShowTopControls(WEBAPP_URL, ConnectionSecurityLevel.NONE));
|
| - assertFalse(getActivity().shouldShowTopControls(
|
| - WEBAPP_URL + "/things.html", ConnectionSecurityLevel.NONE));
|
| - assertFalse(getActivity().shouldShowTopControls(
|
| - WEBAPP_URL + "/stuff.html", ConnectionSecurityLevel.NONE));
|
| + 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(getActivity().shouldShowTopControls("", ConnectionSecurityLevel.NONE));
|
| + assertFalse(shouldShowTopControls(WEBAPP_URL, "", ConnectionSecurityLevel.NONE));
|
|
|
| // Show top controls for non secure URLs.
|
| - assertTrue(getActivity().shouldShowTopControls(
|
| - "http://sub.originalwebsite.com", ConnectionSecurityLevel.SECURITY_WARNING));
|
| - assertTrue(getActivity().shouldShowTopControls(
|
| - "http://notoriginalwebsite.com", ConnectionSecurityLevel.SECURITY_ERROR));
|
| - assertTrue(getActivity().shouldShowTopControls(
|
| - "http://otherwebsite.com", ConnectionSecurityLevel.SECURITY_ERROR));
|
| - assertTrue(getActivity().shouldShowTopControls(
|
| - "http://thing.originalwebsite.com", ConnectionSecurityLevel.SECURITY_ERROR));
|
| - assertTrue(getActivity().shouldShowTopControls(
|
| - WEBAPP_URL, ConnectionSecurityLevel.SECURITY_WARNING));
|
| - assertTrue(getActivity().shouldShowTopControls(
|
| - WEBAPP_URL + "/things.html", ConnectionSecurityLevel.SECURITY_WARNING));
|
| - assertTrue(getActivity().shouldShowTopControls(
|
| - WEBAPP_URL + "/stuff.html", ConnectionSecurityLevel.SECURITY_WARNING));
|
| + 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 static boolean shouldShowTopControls(
|
| + String webappStartUrl, String url, int securityLevel) {
|
| + return WebappDelegateFactory.TopControlsDelegate.shouldShowTopControls(
|
| + webappStartUrl, url, securityLevel);
|
| }
|
| }
|
|
|