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

Unified Diff: content/public/test/android/javatests/src/org/chromium/content/browser/test/util/UiUtils.java

Issue 700013002: Delete UiUtils.runOnUiThread(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: typo fix Created 6 years, 1 month 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
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/input/SelectPopupOtherContentViewTest.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/test/android/javatests/src/org/chromium/content/browser/test/util/UiUtils.java
diff --git a/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/UiUtils.java b/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/UiUtils.java
index 7bfa2f96f3f910e3a6b98d8c287b553c32e0bb43..c0915f07222fb7ef600afc226f333b7ad1abc038 100644
--- a/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/UiUtils.java
+++ b/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/UiUtils.java
@@ -4,50 +4,20 @@
package org.chromium.content.browser.test.util;
-import android.app.Activity;
import android.app.Instrumentation;
-import junit.framework.Assert;
-
-import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout;
-
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
-
/**
* Collection of UI utilities.
*/
public class UiUtils {
- // timeout to wait for runOnUiThread()
- private static final long WAIT_FOR_RESPONSE_MS = scaleTimeout(10000);
-
- /**
- * Runs the runnable on the UI thread.
- *
- * @param activity The activity on which the runnable must run.
- * @param runnable The runnable to run.
- */
- public static void runOnUiThread(Activity activity, final Runnable runnable) {
- final Semaphore finishedSemaphore = new Semaphore(0);
- activity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- runnable.run();
- finishedSemaphore.release();
- }
- });
- try {
- Assert.assertTrue(finishedSemaphore.tryAcquire(1, WAIT_FOR_RESPONSE_MS,
- TimeUnit.MILLISECONDS));
- } catch (InterruptedException ignored) {
- Assert.assertTrue("Interrupted while waiting for main thread Runnable", false);
- }
- }
/**
- * Waits for the UI thread to settle down.
+ * Waits for the UI thread to settle down and then waits for another second.
* <p>
- * Waits for an extra period of time after the UI loop is idle.
+ * Avoid this method like the plague. It's a fantastically evil source of flakiness in tests.
+ * Instead, you should either:
+ * - Use an observer interface if possible (preferred), or
+ * - Use CriteriaHelper to poll for the desired condition becoming true
*
* @param instrumentation Instrumentation object used by the test.
*/
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/input/SelectPopupOtherContentViewTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698