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.FlakyTest; |
| 8 |
| 9 import org.chromium.chrome.browser.ssl.ConnectionSecurityHelperSecurityLevel; |
| 10 import org.chromium.content_public.common.ScreenOrientationValues; |
| 11 |
| 12 /** |
| 13 * Tests whether the URL bar updates itself properly. |
| 14 */ |
| 15 public class WebappUrlBarTest extends WebappActivityTestBase { |
| 16 private static final String WEBAPP_URL = "http://originalwebsite.com"; |
| 17 private WebappUrlBar mUrlBar; |
| 18 |
| 19 @Override |
| 20 protected void setUp() throws Exception { |
| 21 super.setUp(); |
| 22 |
| 23 WebappInfo mockInfo = WebappInfo.create(WEBAPP_ID, WEBAPP_URL, null, nul
l, |
| 24 ScreenOrientationValues.DEFAULT); |
| 25 getActivity().getWebappInfo().copy(mockInfo); |
| 26 mUrlBar = getActivity().getUrlBarForTests(); |
| 27 } |
| 28 |
| 29 /* |
| 30 @UiThreadTest |
| 31 @MediumTest |
| 32 @Feature({"Webapps"}) |
| 33 crbug/407332 |
| 34 */ |
| 35 @FlakyTest |
| 36 public void testUrlDisplay() { |
| 37 final String scheme = "somescheme://"; |
| 38 final String host = "lorem.com"; |
| 39 final String path = "/stuff/and/things.html"; |
| 40 final String url = scheme + host + path; |
| 41 final String urlExpectedWhenIconNotShown = scheme + host; |
| 42 final String urlExpectedWhenIconShown = host; |
| 43 final int[] securityLevels = { |
| 44 ConnectionSecurityHelperSecurityLevel.NONE, |
| 45 ConnectionSecurityHelperSecurityLevel.EV_SECURE, |
| 46 ConnectionSecurityHelperSecurityLevel.SECURE, |
| 47 ConnectionSecurityHelperSecurityLevel.SECURITY_WARNING, |
| 48 ConnectionSecurityHelperSecurityLevel.SECURITY_POLICY_WARNING, |
| 49 ConnectionSecurityHelperSecurityLevel.SECURITY_ERROR }; |
| 50 |
| 51 for (int i : securityLevels) { |
| 52 // http://crbug.com/297249 |
| 53 if (i == ConnectionSecurityHelperSecurityLevel.SECURITY_POLICY_WARNI
NG) continue; |
| 54 mUrlBar.update(url, i); |
| 55 |
| 56 int iconResource = mUrlBar.getCurrentIconResourceForTests(); |
| 57 if (iconResource == 0) { |
| 58 assertEquals( |
| 59 urlExpectedWhenIconNotShown, mUrlBar.getDisplayedUrlForT
ests().toString()); |
| 60 } else { |
| 61 assertEquals( |
| 62 urlExpectedWhenIconShown, mUrlBar.getDisplayedUrlForTest
s().toString()); |
| 63 } |
| 64 } |
| 65 } |
| 66 } |
OLD | NEW |