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

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

Issue 19693016: Hooking up setBackgroundColor from AwContents to render process (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ity. Created 7 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: android_webview/javatests/src/org/chromium/android_webview/test/AwContentsRenderTest.java
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsRenderTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsRenderTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..7fc07a220587afeb562b91149f832a894dcd4141
--- /dev/null
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsRenderTest.java
@@ -0,0 +1,119 @@
+// Copyright (c) 2013 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;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.graphics.Bitmap;
+import android.graphics.Color;
+import android.net.Proxy;
+import android.test.FlakyTest;
+import android.test.mock.MockContext;
+import android.test.suitebuilder.annotation.SmallTest;
+
+import org.chromium.android_webview.AwContents;
+import org.chromium.base.test.util.DisabledTest;
+import org.chromium.base.test.util.Feature;
+import org.chromium.base.test.util.UrlUtils;
+import org.chromium.base.ThreadUtils;
+import org.chromium.content.browser.ContentViewCore;
+import org.chromium.content.browser.ContentViewStatics;
+import org.chromium.net.ProxyChangeListener;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.concurrent.Callable;
+
+/**
+ * AwContents rendering / pixel tests.
+ */
+public class AwContentsRenderTest extends AwTestBase {
+
+ private TestAwContentsClient mContentsClient;
+ private AwContents mAwContents;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ mContentsClient = new TestAwContentsClient();
+ final AwTestContainerView testContainerView =
+ createAwTestContainerViewOnMainSync(mContentsClient);
+ mAwContents = testContainerView.getAwContents();
+ }
+
+ void setBackgroundColorOnUiThread(final int c) {
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ mAwContents.setBackgroundColor(c);
+ }
+ });
+ }
+
+ Bitmap grabViewToBitmap() {
+ final Bitmap result = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888);
+ mAwContents.onDraw(new android.graphics.Canvas(result));
+ return result;
+ }
+
+ void waitForBackgroundColor(final int c) throws Throwable {
+ pollOnUiThread(new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws Exception {
+ return grabViewToBitmap().getPixel(0, 0) == c;
+ }
+ });
+ }
+
+ @SmallTest
+ @Feature({"AndroidWebView"})
+ public void testSetGetBackgroundColor() throws Throwable {
+ setBackgroundColorOnUiThread(Color.MAGENTA);
+ waitForBackgroundColor(Color.MAGENTA);
+
+ setBackgroundColorOnUiThread(Color.CYAN);
+ waitForBackgroundColor(Color.CYAN);
+
+ loadUrlSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), "about:blank");
+
+ // TODO(joth): Remove this bogus check and replace with commented out block when
+ // AwRenderViewExt::OnSetBackgroundColor() is fully implemented (i.e. when
+ // crrev.com/19883002/ has rolled in)
+ waitForBackgroundColor(Color.WHITE);
+
+ // waitForBackgroundColor(Color.CYAN);
+ // setBackgroundColorOnUiThread(Color.YELLOW);
+ // waitForBackgroundColor(Color.YELLOW);
+ // loadUrlSync(mAwContents, mContentsClient.getOnPageFinishedHelper(),
+ // "data:text/html,<html><head><style>body {background-color:#227788}</style></head>" +
+ // "<body><br>HelloWorld</body></html>");
+ // waitForBackgroundColor(Color.rgb(0x22, 0x77, 0x88));
+ //
+ // // Changing the base background should not override CSS background.
+ // setBackgroundColorOnUiThread(Color.MAGENTA);
+ // Thread.sleep(1000);
+ // waitForBackgroundColor(Color.rgb(0x22, 0x77, 0x88));
+
+ }
+
+ @SmallTest
+ @Feature({"AndroidWebView"})
+ public void testPictureListener() throws Throwable {
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ mAwContents.enableOnNewPicture(true, true);
+ }
+ });
+
+ int pictureCount = mContentsClient.getPictureListenerHelper().getCallCount();
+ loadUrlSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), "about:blank");
+ mContentsClient.getPictureListenerHelper().waitForCallback(pictureCount, 1);
+ // Invalidation only, so picture should be null.
+ assertNull(mContentsClient.getPictureListenerHelper().getPicture());
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698