Index: android_webview/javatests/src/org/chromium/android_webview/test/util/GraphicsTestUtils.java |
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/util/GraphicsTestUtils.java b/android_webview/javatests/src/org/chromium/android_webview/test/util/GraphicsTestUtils.java |
index acce0fe26130a2fe6ca7f19dc0ba433bb7c90c7d..d41b7a389706540fecd56db7f8fd38f4184134ff 100644 |
--- a/android_webview/javatests/src/org/chromium/android_webview/test/util/GraphicsTestUtils.java |
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/util/GraphicsTestUtils.java |
@@ -6,6 +6,7 @@ package org.chromium.android_webview.test.util; |
import android.graphics.Bitmap; |
import android.graphics.Canvas; |
+import android.view.View; |
import org.chromium.android_webview.AwContents; |
import org.chromium.android_webview.test.AwTestBase; |
@@ -43,6 +44,20 @@ public class GraphicsTestUtils { |
return doDrawAwContents(awContents, width, height, dx, dy); |
} |
+ /** |
+ * Draws the supplied {@link View} into the returned {@link Bitmap}. |
+ * |
+ * @param view The view to draw |
+ * @param width The width of the bitmap |
+ * @param height The height of the bitmap |
+ */ |
+ public static Bitmap drawView(View view, int width, int height) { |
+ Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); |
+ Canvas canvas = new Canvas(bitmap); |
+ view.draw(canvas); |
+ return bitmap; |
+ } |
+ |
public static int sampleBackgroundColorOnUiThread(final AwContents awContents) |
throws Exception { |
return ThreadUtils.runOnUiThreadBlocking(new Callable<Integer>() { |