Upstream oodles of Chrome for Android code into Chromium.
[chromium-blink-merge.git] / chrome / android / javatests / src / org / chromium / chrome / browser / webapps / WebappVisibilityTest.java
blob07aa8c392295fcfee157c5f18ca551e15c47b0d1
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.
5 package org.chromium.chrome.browser.webapps;
7 import android.test.suitebuilder.annotation.MediumTest;
9 import org.chromium.base.test.util.Feature;
10 import org.chromium.chrome.browser.ssl.ConnectionSecurityHelperSecurityLevel;
11 import org.chromium.content_public.common.ScreenOrientationValues;
13 /**
14 * Tests the logic in top controls visibility delegate in WebappActivity.
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.DEFAULT);
23 getActivity().getWebappInfo().copy(mockInfo);
25 // Show top controls for out-of-domain URLs.
26 assertTrue(getActivity().shouldShowTopControls(
27 "http://notoriginalwebsite.com", ConnectionSecurityHelperSecurityLevel.NONE));
28 assertTrue(getActivity().shouldShowTopControls(
29 "http://otherwebsite.com", ConnectionSecurityHelperSecurityLevel.NONE));
31 // Do not show top controls for subdomains and private registries that are secure.
32 assertFalse(getActivity().shouldShowTopControls(
33 "http://sub.originalwebsite.com", ConnectionSecurityHelperSecurityLevel.NONE));
34 assertFalse(getActivity().shouldShowTopControls(
35 "http://thing.originalwebsite.com", ConnectionSecurityHelperSecurityLevel.NONE));
36 assertFalse(getActivity().shouldShowTopControls(webappUrl,
37 ConnectionSecurityHelperSecurityLevel.NONE));
38 assertFalse(getActivity().shouldShowTopControls(
39 webappUrl + "/things.html", ConnectionSecurityHelperSecurityLevel.NONE));
40 assertFalse(getActivity().shouldShowTopControls(
41 webappUrl + "/stuff.html", ConnectionSecurityHelperSecurityLevel.NONE));
43 // Do not show top controls when URL is not available yet.
44 assertFalse(getActivity().shouldShowTopControls("",
45 ConnectionSecurityHelperSecurityLevel.NONE));
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_WARNING));
62 assertTrue(getActivity().shouldShowTopControls(
63 webappUrl + "/things.html",
64 ConnectionSecurityHelperSecurityLevel.SECURITY_WARNING));
65 assertTrue(getActivity().shouldShowTopControls(
66 webappUrl + "/stuff.html",
67 ConnectionSecurityHelperSecurityLevel.SECURITY_WARNING));