Index: Source/web/tests/WebViewTest.cpp |
diff --git a/Source/web/tests/WebViewTest.cpp b/Source/web/tests/WebViewTest.cpp |
index 572b76f1a1a3aca9c838637061b049bf102a5df3..e65e64af4b6b1acedc38536e3cd29dfebedb98ad 100644 |
--- a/Source/web/tests/WebViewTest.cpp |
+++ b/Source/web/tests/WebViewTest.cpp |
@@ -58,11 +58,15 @@ |
#include "core/page/Chrome.h" |
#include "core/page/Settings.h" |
#include "core/platform/chromium/KeyboardCodes.h" |
+#include "platform/graphics/Color.h" |
#include "public/platform/Platform.h" |
#include "public/platform/WebSize.h" |
#include "public/platform/WebThread.h" |
#include "public/platform/WebUnitTestSupport.h" |
#include "public/web/WebWidgetClient.h" |
+#include "third_party/skia/include/core/SkBitmap.h" |
+#include "third_party/skia/include/core/SkBitmapDevice.h" |
+#include "third_party/skia/include/core/SkCanvas.h" |
using namespace blink; |
using blink::FrameTestHelpers::runPendingTasks; |
@@ -285,6 +289,35 @@ TEST_F(WebViewTest, SetBaseBackgroundColorBeforeMainFrame) |
EXPECT_EQ(kBlue, webView->backgroundColor()); |
} |
+TEST_F(WebViewTest, SetBaseBackgroundColorAndBlendWithExistingContent) |
+{ |
+ const WebColor kAlphaRed = 0x80FF0000; |
+ const WebColor kAlphaGreen = 0x8000FF00; |
+ const int kWidth = 100; |
+ const int kHeight = 100; |
+ |
+ // Set WebView background to green with alpha. |
+ WebView* webView = m_webViewHelper.initialize(); |
+ webView->setBaseBackgroundColor(kAlphaGreen); |
+ webView->settings()->setShouldClearDocumentBackground(false); |
+ webView->resize(WebSize(kWidth, kHeight)); |
+ webView->layout(); |
+ |
+ // Set canvas background to red with alpha. |
+ SkBitmap bitmap; |
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, kWidth, kHeight); |
+ bitmap.allocPixels(); |
+ SkBitmapDevice device(bitmap); |
+ SkCanvas canvas(&device); |
+ canvas.clear(kAlphaRed); |
+ webView->paint(&canvas, WebRect(0, 0, kWidth, kHeight)); |
+ |
+ // The result should be a blend of red and green. |
+ SkColor color = bitmap.getColor(kWidth / 2, kHeight / 2); |
+ EXPECT_TRUE(WebCore::redChannel(color)); |
+ EXPECT_TRUE(WebCore::greenChannel(color)); |
+} |
+ |
TEST_F(WebViewTest, FocusIsInactive) |
{ |
URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), "visible_iframe.html"); |