Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/infobar/InfoBarTest.java

Issue 2939143002: Update Previews infbar accessibility string (Closed)
Patch Set: static class Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/android/java/strings/android_chrome_strings.grd ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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.infobar; 5 package org.chromium.chrome.browser.infobar;
6 6
7 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; 7 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout;
8 8
9 import android.content.Context; 9 import android.content.Context;
10 import android.support.test.InstrumentationRegistry; 10 import android.support.test.InstrumentationRegistry;
11 import android.support.test.filters.MediumTest; 11 import android.support.test.filters.MediumTest;
12 12
13 import org.junit.After; 13 import org.junit.After;
14 import org.junit.Assert; 14 import org.junit.Assert;
15 import org.junit.Before; 15 import org.junit.Before;
16 import org.junit.Rule; 16 import org.junit.Rule;
17 import org.junit.Test; 17 import org.junit.Test;
18 import org.junit.runner.RunWith; 18 import org.junit.runner.RunWith;
19 19
20 import org.chromium.base.CommandLine; 20 import org.chromium.base.CommandLine;
21 import org.chromium.base.ContextUtils; 21 import org.chromium.base.ContextUtils;
22 import org.chromium.base.ThreadUtils; 22 import org.chromium.base.ThreadUtils;
23 import org.chromium.base.test.util.AdvancedMockContext; 23 import org.chromium.base.test.util.AdvancedMockContext;
24 import org.chromium.base.test.util.CommandLineFlags; 24 import org.chromium.base.test.util.CommandLineFlags;
25 import org.chromium.base.test.util.DisabledTest; 25 import org.chromium.base.test.util.DisabledTest;
26 import org.chromium.base.test.util.Feature; 26 import org.chromium.base.test.util.Feature;
27 import org.chromium.base.test.util.RetryOnFailure; 27 import org.chromium.base.test.util.RetryOnFailure;
28 import org.chromium.base.test.util.UrlUtils; 28 import org.chromium.base.test.util.UrlUtils;
29 import org.chromium.chrome.R;
29 import org.chromium.chrome.browser.ChromeActivity; 30 import org.chromium.chrome.browser.ChromeActivity;
30 import org.chromium.chrome.browser.ChromeSwitches; 31 import org.chromium.chrome.browser.ChromeSwitches;
31 import org.chromium.chrome.browser.WebContentsFactory; 32 import org.chromium.chrome.browser.WebContentsFactory;
32 import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings; 33 import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings;
33 import org.chromium.chrome.browser.preferences.datareduction.DataReductionPromoU tils; 34 import org.chromium.chrome.browser.preferences.datareduction.DataReductionPromoU tils;
34 import org.chromium.chrome.test.ChromeActivityTestRule; 35 import org.chromium.chrome.test.ChromeActivityTestRule;
35 import org.chromium.chrome.test.ChromeJUnit4ClassRunner; 36 import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
36 import org.chromium.chrome.test.util.InfoBarTestAnimationListener; 37 import org.chromium.chrome.test.util.InfoBarTestAnimationListener;
37 import org.chromium.chrome.test.util.InfoBarUtil; 38 import org.chromium.chrome.test.util.InfoBarUtil;
38 import org.chromium.chrome.test.util.browser.LocationSettingsTestUtil; 39 import org.chromium.chrome.test.util.browser.LocationSettingsTestUtil;
(...skipping 26 matching lines...) Expand all
65 + "<head><title>Hello, World!</title></head>" 66 + "<head><title>Hello, World!</title></head>"
66 + "<body>Hello, World!</body>" 67 + "<body>Hello, World!</body>"
67 + "</html>"); 68 + "</html>");
68 private static final String SHARED_PREF_DISPLAYED_FRE_OR_SECOND_PROMO_VERSIO N = 69 private static final String SHARED_PREF_DISPLAYED_FRE_OR_SECOND_PROMO_VERSIO N =
69 "displayed_data_reduction_promo_version"; 70 "displayed_data_reduction_promo_version";
70 private static final String M51_VERSION = "Chrome 51.0.2704.0"; 71 private static final String M51_VERSION = "Chrome 51.0.2704.0";
71 72
72 private EmbeddedTestServer mTestServer; 73 private EmbeddedTestServer mTestServer;
73 private InfoBarTestAnimationListener mListener; 74 private InfoBarTestAnimationListener mListener;
74 75
76 private static class TestInfoBar extends ConfirmInfoBar {
77 private boolean mCompact;
78
79 private TestInfoBar(String message) {
80 super(0, null, message, null, null, null);
81 }
82
83 @Override
84 protected boolean usesCompactLayout() {
85 return mCompact;
86 }
87
88 public void setUsesCompactLayout(boolean compact) {
89 mCompact = compact;
90 }
91 }
92
75 private void waitUntilDataReductionPromoInfoBarAppears() { 93 private void waitUntilDataReductionPromoInfoBarAppears() {
76 CriteriaHelper.pollUiThread(new Criteria() { 94 CriteriaHelper.pollUiThread(new Criteria() {
77 @Override 95 @Override
78 public boolean isSatisfied() { 96 public boolean isSatisfied() {
79 List<InfoBar> infobars = mActivityTestRule.getInfoBars(); 97 List<InfoBar> infobars = mActivityTestRule.getInfoBars();
80 if (infobars.size() != 1) return false; 98 if (infobars.size() != 1) return false;
81 return infobars.get(0) instanceof DataReductionPromoInfoBar; 99 return infobars.get(0) instanceof DataReductionPromoInfoBar;
82 } 100 }
83 }); 101 });
84 } 102 }
(...skipping 30 matching lines...) Expand all
115 } 133 }
116 134
117 @After 135 @After
118 public void tearDown() throws Exception { 136 public void tearDown() throws Exception {
119 if (mTestServer != null) { 137 if (mTestServer != null) {
120 mTestServer.stopAndDestroyServer(); 138 mTestServer.stopAndDestroyServer();
121 } 139 }
122 } 140 }
123 141
124 /** 142 /**
143 * Verify getAccessibilityMessage().
144 */
145 @Test
146 @MediumTest
147 @Feature({"Browser", "Main"})
148 public void testGetAccessibilityMessage() {
149 TestInfoBar infoBarNoMessage = new TestInfoBar(null);
150 infoBarNoMessage.setContext(ContextUtils.getApplicationContext());
151 Assert.assertEquals("Infobar shouldn't have accessibility message before createView()", "",
152 infoBarNoMessage.getAccessibilityText());
153 infoBarNoMessage.createView();
154 Assert.assertEquals("Infobar should have accessibility message after cre ateView()",
155 ContextUtils.getApplicationContext().getString(R.string.bottom_b ar_screen_position),
156 infoBarNoMessage.getAccessibilityText());
157
158 TestInfoBar infoBarCompact = new TestInfoBar(null);
159 infoBarCompact.setContext(ContextUtils.getApplicationContext());
160 Assert.assertEquals("Infobar shouldn't have accessibility message before createView()", "",
161 infoBarCompact.getAccessibilityText());
162 infoBarCompact.setUsesCompactLayout(true);
163 infoBarCompact.createView();
164 Assert.assertEquals("Infobar should have accessibility message after cre ateView()",
165 ContextUtils.getApplicationContext().getString(R.string.bottom_b ar_screen_position),
166 infoBarCompact.getAccessibilityText());
167
168 String messsage = "Hello world";
169 TestInfoBar infoBarWithMessage = new TestInfoBar(messsage);
170 infoBarWithMessage.setContext(ContextUtils.getApplicationContext());
171 Assert.assertEquals("Infobar shouldn't have accessibility message before createView()", "",
172 infoBarWithMessage.getAccessibilityText());
173 infoBarWithMessage.createView();
174 Assert.assertEquals("Infobar should have accessibility message after cre ateView()",
175 messsage
176 + ContextUtils.getApplicationContext().getString(
177 R.string.bottom_bar_screen_position),
178 infoBarWithMessage.getAccessibilityText());
179 }
180
181 /**
125 * Verify PopUp InfoBar. 182 * Verify PopUp InfoBar.
126 */ 183 */
127 @Test 184 @Test
128 @MediumTest 185 @MediumTest
129 @Feature({"Browser", "Main"}) 186 @Feature({"Browser", "Main"})
130 @DisabledTest(message = "crbug.com/593003") 187 @DisabledTest(message = "crbug.com/593003")
131 public void testInfoBarForPopUp() throws InterruptedException, TimeoutExcept ion { 188 public void testInfoBarForPopUp() throws InterruptedException, TimeoutExcept ion {
132 mActivityTestRule.loadUrl(mTestServer.getURL(POPUP_PAGE)); 189 mActivityTestRule.loadUrl(mTestServer.getURL(POPUP_PAGE));
133 mListener.addInfoBarAnimationFinished("InfoBar not added"); 190 mListener.addInfoBarAnimationFinished("InfoBar not added");
134 191
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 584
528 // Revisiting the original page should make the InfoBar reappear. 585 // Revisiting the original page should make the InfoBar reappear.
529 InfoBarTestAnimationListener addListener = new InfoBarTestAnimationListe ner(); 586 InfoBarTestAnimationListener addListener = new InfoBarTestAnimationListe ner();
530 mActivityTestRule.getActivity().getActivityTab().getInfoBarContainer().a ddAnimationListener( 587 mActivityTestRule.getActivity().getActivityTab().getInfoBarContainer().a ddAnimationListener(
531 addListener); 588 addListener);
532 mActivityTestRule.loadUrl(mTestServer.getURL(GEOLOCATION_PAGE)); 589 mActivityTestRule.loadUrl(mTestServer.getURL(GEOLOCATION_PAGE));
533 addListener.addInfoBarAnimationFinished("InfoBar not added"); 590 addListener.addInfoBarAnimationFinished("InfoBar not added");
534 Assert.assertEquals("Wrong infobar count", 1, mActivityTestRule.getInfoB ars().size()); 591 Assert.assertEquals("Wrong infobar count", 1, mActivityTestRule.getInfoB ars().size());
535 } 592 }
536 } 593 }
OLDNEW
« no previous file with comments | « chrome/android/java/strings/android_chrome_strings.grd ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698