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

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

Issue 19883002: Expose a way to set a view's base background color. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix unittests for Android, to reland 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
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | public/web/WebView.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 b55bf1b2397eb197baad8d6adeb39ced62ac7e85..09bb6cf9ae2bf034e69f6073646b682f9d9ba722 100644
--- a/Source/web/tests/WebViewTest.cpp
+++ b/Source/web/tests/WebViewTest.cpp
@@ -185,6 +185,38 @@ protected:
std::string m_baseURL;
};
+TEST_F(WebViewTest, SetBaseBackgroundColor)
+{
+ const WebColor kWhite = 0xFFFFFFFF;
+ const WebColor kBlue = 0xFF0000FF;
+ const WebColor kDarkCyan = 0xFF227788;
+ const WebColor kTranslucentPutty = 0x80BFB196;
+
+ WebView* webView = FrameTestHelpers::createWebView();
+ EXPECT_EQ(kWhite, webView->backgroundColor());
+
+ webView->setBaseBackgroundColor(kBlue);
+ EXPECT_EQ(kBlue, webView->backgroundColor());
+
+ WebURL baseURL = URLTestHelpers::toKURL("http://example.com/");
+ webView->mainFrame()->loadHTMLString(
+ "<html><head><style>body {background-color:#227788}</style></head></html>", baseURL);
+ Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
+ EXPECT_EQ(kDarkCyan, webView->backgroundColor());
+
+ webView->mainFrame()->loadHTMLString(
+ "<html><head><style>body {background-color:rgba(255,0,0,0.5)}</style></head></html>", baseURL);
+ Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
+ // Expected: red (50% alpha) blended atop base of kBlue.
+ EXPECT_EQ(0xFF7F0080, webView->backgroundColor());
+
+ webView->setBaseBackgroundColor(kTranslucentPutty);
+ // Expected: red (50% alpha) blended atop kTranslucentPutty. Note the alpha.
+ EXPECT_EQ(0xBFE93B32, webView->backgroundColor());
+
+ webView->close();
+}
+
TEST_F(WebViewTest, FocusIsInactive)
{
URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), "visible_iframe.html");
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | public/web/WebView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698