| Index: chrome/android/javatests/src/org/chromium/chrome/browser/infobar/InfoBarTest.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/infobar/InfoBarTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/infobar/InfoBarTest.java
|
| index 312e703513c899cf24218a6d6c529f2ccd0589ab..7c1150bd7811cccc5cc3b2d893d4d737c90b8fec 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/infobar/InfoBarTest.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/infobar/InfoBarTest.java
|
| @@ -26,6 +26,7 @@ import org.chromium.base.test.util.DisabledTest;
|
| import org.chromium.base.test.util.Feature;
|
| import org.chromium.base.test.util.RetryOnFailure;
|
| import org.chromium.base.test.util.UrlUtils;
|
| +import org.chromium.chrome.R;
|
| import org.chromium.chrome.browser.ChromeActivity;
|
| import org.chromium.chrome.browser.ChromeSwitches;
|
| import org.chromium.chrome.browser.WebContentsFactory;
|
| @@ -72,6 +73,23 @@ public class InfoBarTest {
|
| private EmbeddedTestServer mTestServer;
|
| private InfoBarTestAnimationListener mListener;
|
|
|
| + private static class TestInfoBar extends ConfirmInfoBar {
|
| + private boolean mCompact;
|
| +
|
| + private TestInfoBar(String message) {
|
| + super(0, null, message, null, null, null);
|
| + }
|
| +
|
| + @Override
|
| + protected boolean usesCompactLayout() {
|
| + return mCompact;
|
| + }
|
| +
|
| + public void setUsesCompactLayout(boolean compact) {
|
| + mCompact = compact;
|
| + }
|
| + }
|
| +
|
| private void waitUntilDataReductionPromoInfoBarAppears() {
|
| CriteriaHelper.pollUiThread(new Criteria() {
|
| @Override
|
| @@ -121,6 +139,45 @@ public class InfoBarTest {
|
| }
|
| }
|
|
|
| + /**
|
| + * Verify getAccessibilityMessage().
|
| + */
|
| + @Test
|
| + @MediumTest
|
| + @Feature({"Browser", "Main"})
|
| + public void testGetAccessibilityMessage() {
|
| + TestInfoBar infoBarNoMessage = new TestInfoBar(null);
|
| + infoBarNoMessage.setContext(ContextUtils.getApplicationContext());
|
| + Assert.assertEquals("Infobar shouldn't have accessibility message before createView()", "",
|
| + infoBarNoMessage.getAccessibilityText());
|
| + infoBarNoMessage.createView();
|
| + Assert.assertEquals("Infobar should have accessibility message after createView()",
|
| + ContextUtils.getApplicationContext().getString(R.string.bottom_bar_screen_position),
|
| + infoBarNoMessage.getAccessibilityText());
|
| +
|
| + TestInfoBar infoBarCompact = new TestInfoBar(null);
|
| + infoBarCompact.setContext(ContextUtils.getApplicationContext());
|
| + Assert.assertEquals("Infobar shouldn't have accessibility message before createView()", "",
|
| + infoBarCompact.getAccessibilityText());
|
| + infoBarCompact.setUsesCompactLayout(true);
|
| + infoBarCompact.createView();
|
| + Assert.assertEquals("Infobar should have accessibility message after createView()",
|
| + ContextUtils.getApplicationContext().getString(R.string.bottom_bar_screen_position),
|
| + infoBarCompact.getAccessibilityText());
|
| +
|
| + String messsage = "Hello world";
|
| + TestInfoBar infoBarWithMessage = new TestInfoBar(messsage);
|
| + infoBarWithMessage.setContext(ContextUtils.getApplicationContext());
|
| + Assert.assertEquals("Infobar shouldn't have accessibility message before createView()", "",
|
| + infoBarWithMessage.getAccessibilityText());
|
| + infoBarWithMessage.createView();
|
| + Assert.assertEquals("Infobar should have accessibility message after createView()",
|
| + messsage
|
| + + ContextUtils.getApplicationContext().getString(
|
| + R.string.bottom_bar_screen_position),
|
| + infoBarWithMessage.getAccessibilityText());
|
| + }
|
| +
|
| /**
|
| * Verify PopUp InfoBar.
|
| */
|
|
|