diff options
Diffstat (limited to 'Source/web/tests/WebViewTest.cpp')
-rw-r--r-- | Source/web/tests/WebViewTest.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Source/web/tests/WebViewTest.cpp b/Source/web/tests/WebViewTest.cpp index b55bf1b23..09bb6cf9a 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"); |