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

Unified Diff: android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java

Issue 1026723002: [Android WebView] Deflake new OnReceived*Error tests that simulate tap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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: android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java
index 49af5c2928fc53bb851d964c32c08e85788c2407..a431f1a13cd8b133f2c416504af05b6962441a43 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java
@@ -6,6 +6,7 @@ package org.chromium.android_webview.test;
import android.app.Instrumentation;
import android.content.Context;
+import android.graphics.Bitmap;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;
@@ -16,6 +17,7 @@ import org.chromium.android_webview.AwBrowserProcess;
import org.chromium.android_webview.AwContents;
import org.chromium.android_webview.AwContentsClient;
import org.chromium.android_webview.AwSettings;
+import org.chromium.android_webview.test.util.GraphicsTestUtils;
import org.chromium.android_webview.test.util.JSUtils;
import org.chromium.base.test.util.InMemorySharedPreferences;
import org.chromium.content.browser.test.util.CallbackHelper;
@@ -293,6 +295,22 @@ public class AwTestBase
ch.waitForCallback(chCount);
}
+ // Waits for the pixel at the center of AwContents to color up into expectedColor.
+ // Note that this is a stricter condition that waiting for a visual state callback,
+ // as visual state callback only indicates that *something* has appeared in WebView.
+ public void waitForPixelColorAtCenterOfView(final AwContents awContents,
+ final AwTestContainerView testContainerView, final int expectedColor) throws Exception {
+ pollOnUiThread(new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws Exception {
+ Bitmap bitmap = GraphicsTestUtils.drawAwContents(awContents, 2, 2,
+ -(float) testContainerView.getWidth() / 2,
+ -(float) testContainerView.getHeight() / 2);
+ return bitmap.getPixel(0, 0) == expectedColor;
+ }
+ });
+ }
+
/**
* Checks the current test has |clazz| annotation. Note this swallows NoSuchMethodException
* and returns false in that case.

Powered by Google App Engine
This is Rietveld 408576698