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

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

Issue 2130083002: Re-enable DataReductionPromoInfoBar tests and fix flakiness (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@settingsPage
Patch Set: include other file reads Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
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 94e66c4c6a848269e4e9313ae61d843db4315d74..19fd568ef022b4e4868687cd85f48f05f18d5740 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
@@ -6,6 +6,7 @@ package org.chromium.chrome.browser.infobar;
import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout;
+import android.content.Context;
import android.os.Environment;
import android.test.UiThreadTest;
import android.test.suitebuilder.annotation.MediumTest;
@@ -14,6 +15,7 @@ import android.test.suitebuilder.annotation.Smoke;
import org.chromium.base.CommandLine;
import org.chromium.base.ContextUtils;
import org.chromium.base.ThreadUtils;
+import org.chromium.base.test.util.AdvancedMockContext;
import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.UrlUtils;
@@ -82,6 +84,11 @@ public class InfoBarTest extends ChromeActivityTestCaseBase<ChromeActivity> {
mTestServer = EmbeddedTestServer.createAndStartFileServer(
getInstrumentation().getContext(), Environment.getExternalStorageDirectory());
+
+ // Using an AdvancedMockContext allows us to use a fresh in-memory SharedPreference.
+ Context context = new AdvancedMockContext(
+ getInstrumentation().getTargetContext().getApplicationContext());
+ ContextUtils.initApplicationContextForTests(context);
}
@Override
@@ -175,9 +182,8 @@ public class InfoBarTest extends ChromeActivityTestCaseBase<ChromeActivity> {
*/
@MediumTest
@Feature({"Browser", "Main"})
- @DisabledTest // crbug.com/625038
public void testDataReductionPromoInfoBar() throws InterruptedException {
- ThreadUtils.runOnUiThread(new Runnable() {
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
assertFalse("Data Reduction Proxy enabled",
@@ -189,12 +195,13 @@ public class InfoBarTest extends ChromeActivityTestCaseBase<ChromeActivity> {
.putString(SHARED_PREF_DISPLAYED_FRE_OR_SECOND_PROMO_VERSION, M51_VERSION)
.apply();
// Add an infobar.
- DataReductionPromoInfoBar.maybeLaunchPromoInfoBar(
+ assertTrue(DataReductionPromoInfoBar.maybeLaunchPromoInfoBar(
getActivity(), getActivity().getActivityTab().getWebContents(),
- "http://google.com", false, false, HttpURLConnection.HTTP_OK);
+ "http://google.com", false, false, HttpURLConnection.HTTP_OK));
}
});
+ getInstrumentation().waitForIdleSync();
gone 2016/07/12 23:28:07 Judging by how you only put this line here and not
megjablon 2016/07/13 01:03:28 Sorry I've been jumping back and forth between the
assertTrue("InfoBar not added", mListener.addInfoBarAnimationFinished());
final List<InfoBar> infoBars = getInfoBars();
assertEquals("Wrong infobar count", 1, infoBars.size());
@@ -203,7 +210,7 @@ public class InfoBarTest extends ChromeActivityTestCaseBase<ChromeActivity> {
assertTrue("InfoBar does not have secondary button",
InfoBarUtil.hasSecondaryButton(infoBars.get(0)));
- ThreadUtils.runOnUiThread(new Runnable() {
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
InfoBarUtil.clickPrimaryButton(infoBars.get(0));
@@ -214,7 +221,7 @@ public class InfoBarTest extends ChromeActivityTestCaseBase<ChromeActivity> {
assertTrue("InfoBar not removed.", mListener.removeInfoBarAnimationFinished());
assertTrue("Wrong infobar count", getInfoBars().isEmpty());
- ThreadUtils.runOnUiThread(new Runnable() {
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
assertTrue("Data Reduction Proxy not enabled",
@@ -237,9 +244,8 @@ public class InfoBarTest extends ChromeActivityTestCaseBase<ChromeActivity> {
*/
@MediumTest
@Feature({"Browser", "Main"})
- @DisabledTest // crbug.com/625038
public void testDataReductionPromoInfoBarDismissed() throws InterruptedException {
- ThreadUtils.runOnUiThread(new Runnable() {
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
assertFalse("Data Reduction Proxy enabled",
@@ -251,9 +257,9 @@ public class InfoBarTest extends ChromeActivityTestCaseBase<ChromeActivity> {
.putString(SHARED_PREF_DISPLAYED_FRE_OR_SECOND_PROMO_VERSION, M51_VERSION)
.apply();
// Add an infobar.
- DataReductionPromoInfoBar.maybeLaunchPromoInfoBar(
+ assertTrue(DataReductionPromoInfoBar.maybeLaunchPromoInfoBar(
getActivity(), getActivity().getActivityTab().getWebContents(),
- "http://google.com", false, false, HttpURLConnection.HTTP_OK);
+ "http://google.com", false, false, HttpURLConnection.HTTP_OK));
}
});
@@ -265,7 +271,7 @@ public class InfoBarTest extends ChromeActivityTestCaseBase<ChromeActivity> {
assertTrue("InfoBar does not have secondary button",
InfoBarUtil.hasSecondaryButton(infoBars.get(0)));
- ThreadUtils.runOnUiThread(new Runnable() {
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
InfoBarUtil.clickSecondaryButton(infoBars.get(0));
@@ -276,7 +282,7 @@ public class InfoBarTest extends ChromeActivityTestCaseBase<ChromeActivity> {
assertTrue("InfoBar not removed.", mListener.removeInfoBarAnimationFinished());
assertTrue("Wrong infobar count", getInfoBars().isEmpty());
- ThreadUtils.runOnUiThread(new Runnable() {
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
assertFalse("Data Reduction Proxy enabled",
@@ -297,7 +303,6 @@ public class InfoBarTest extends ChromeActivityTestCaseBase<ChromeActivity> {
@UiThreadTest
@MediumTest
@Feature({"Browser", "Main"})
- @DisabledTest // crbug.com/625038
public void testDataReductionPromoInfoBarPostM48Install() {
assertFalse("Data Reduction Proxy enabled",
DataReductionProxySettings.getInstance().isDataReductionProxyEnabled());
@@ -322,7 +327,6 @@ public class InfoBarTest extends ChromeActivityTestCaseBase<ChromeActivity> {
@UiThreadTest
@MediumTest
@Feature({"Browser", "Main"})
- @DisabledTest // crbug.com/625038
public void testDataReductionPromoInfoBarFreOptOut() {
// Try to add an infobar. Infobar should not be added since the first run experience or
// second run promo hasn't been shown.

Powered by Google App Engine
This is Rietveld 408576698