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

Unified Diff: Source/web/tests/WebViewTest.cpp

Issue 23483051: Blend background with existing content (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix test in android Created 7 years 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
« no previous file with comments | « Source/web/WebSettingsImpl.cpp ('k') | public/web/WebSettings.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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");
« no previous file with comments | « Source/web/WebSettingsImpl.cpp ('k') | public/web/WebSettings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698