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

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

Issue 831903004: [WebView] Add a new flushVisualState API to AwContents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: int -> uint62 everywhere for real. Created 5 years, 10 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/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
new file mode 100644
index 0000000000000000000000000000000000000000..95c6758ad9675603cc280f74abd754a067a95d0c
--- /dev/null
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/util/GraphicsTestUtils.java
@@ -0,0 +1,52 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.android_webview.test.util;
+
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+
+import org.chromium.android_webview.AwContents;
+
+/**
+ * Graphics-related test utils.
+ */
+public class GraphicsTestUtils {
+ /**
+ * Draws the supplied {@link AwContents} into the returned {@link Bitmap}.
+ *
+ * @param awContents The contents to draw
+ * @param width The width of the bitmap
+ * @param height The height of the bitmap
+ */
+ public static Bitmap drawAwContents(AwContents awContents, int width, int height) {
+ return doDrawAwContents(awContents, width, height, null, null);
+ }
+
+ /**
+ * Draws the supplied {@link AwContents} after applying a translate into the returned
+ * {@link Bitmap}.
+ *
+ * @param awContents The contents to draw
+ * @param width The width of the bitmap
+ * @param height The height of the bitmap
+ * @param dx The distance to translate in X
+ * @param dy The distance to translate in Y
+ */
+ public static Bitmap drawAwContents(
+ AwContents awContents, int width, int height, float dx, float dy) {
+ return doDrawAwContents(awContents, width, height, dx, dy);
+ }
+
+ private static Bitmap doDrawAwContents(
+ AwContents awContents, int width, int height, Float dx, Float dy) {
+ Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+ Canvas canvas = new Canvas(bitmap);
+ if (dx != null && dy != null) {
+ canvas.translate(dx, dy);
+ }
+ awContents.onDraw(canvas);
+ return bitmap;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698