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

Side by Side 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: jamesr comments 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 const std::string& pageWidth, const std::string& pageHei ght, 178 const std::string& pageWidth, const std::string& pageHei ght,
179 int expectedWidth, int expectedHeight, 179 int expectedWidth, int expectedHeight,
180 HorizontalScrollbarState expectedHorizontalState, Vertic alScrollbarState expectedVerticalState); 180 HorizontalScrollbarState expectedHorizontalState, Vertic alScrollbarState expectedVerticalState);
181 181
182 void testTextInputType(WebTextInputType expectedType, const std::string& htm lFile); 182 void testTextInputType(WebTextInputType expectedType, const std::string& htm lFile);
183 void testInputMode(const WebString& expectedInputMode, const std::string& ht mlFile); 183 void testInputMode(const WebString& expectedInputMode, const std::string& ht mlFile);
184 184
185 std::string m_baseURL; 185 std::string m_baseURL;
186 }; 186 };
187 187
188 TEST_F(WebViewTest, SetBaseBackgroundColor)
189 {
190 const WebColor kWhite = 0xFFFFFFFF;
191 const WebColor kBlue = 0xFF0000FF;
192 const WebColor kDarkCyan = 0xFF227788;
193 const WebColor kTranslucentPutty = 0x80BFB196;
194
195 WebView* webView = FrameTestHelpers::createWebView();
196 EXPECT_EQ(kWhite, webView->backgroundColor());
197
198 webView->setBaseBackgroundColor(kBlue);
199 EXPECT_EQ(kBlue, webView->backgroundColor());
200
201 FrameTestHelpers::loadFrame(webView->mainFrame(),
202 "data:text/html,<html><head><style>body {background-color:#227788}</styl e></head></html>");
203 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
204 EXPECT_EQ(kDarkCyan, webView->backgroundColor());
205
206 FrameTestHelpers::loadFrame(webView->mainFrame(),
207 "data:text/html,<html><head><style>body {background-color:rgba(255,0,0,0 .5)}</style></head></html>");
208 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
209 // Expected: red (50% alpha) blended atop base of kBlue.
210 EXPECT_EQ(0xFF7F0080, webView->backgroundColor());
211
212 webView->setBaseBackgroundColor(kTranslucentPutty);
213 // Expected: red (50% alpha) blended atop kTranslucentPutty. Note the alpha.
214 EXPECT_EQ(0xBFE93B32, webView->backgroundColor());
215
216 webView->close();
217 }
218
188 TEST_F(WebViewTest, FocusIsInactive) 219 TEST_F(WebViewTest, FocusIsInactive)
189 { 220 {
190 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), "visible_iframe.html"); 221 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), "visible_iframe.html");
191 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "visib le_iframe.html"); 222 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "visib le_iframe.html");
192 223
193 webView->setFocus(true); 224 webView->setFocus(true);
194 webView->setIsActive(true); 225 webView->setIsActive(true);
195 WebFrameImpl* frame = static_cast<WebFrameImpl*>(webView->mainFrame()); 226 WebFrameImpl* frame = static_cast<WebFrameImpl*>(webView->mainFrame());
196 EXPECT_TRUE(frame->frame()->document()->isHTMLDocument()); 227 EXPECT_TRUE(frame->frame()->document()->isHTMLDocument());
197 228
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 { 1021 {
991 WebElement elementWithoutShadowRoot = document.getElementById("noshadowr oot"); 1022 WebElement elementWithoutShadowRoot = document.getElementById("noshadowr oot");
992 EXPECT_FALSE(elementWithoutShadowRoot.isNull()); 1023 EXPECT_FALSE(elementWithoutShadowRoot.isNull());
993 WebNode shadowRoot = elementWithoutShadowRoot.shadowRoot(); 1024 WebNode shadowRoot = elementWithoutShadowRoot.shadowRoot();
994 EXPECT_TRUE(shadowRoot.isNull()); 1025 EXPECT_TRUE(shadowRoot.isNull());
995 } 1026 }
996 webViewImpl->close(); 1027 webViewImpl->close();
997 } 1028 }
998 1029
999 } 1030 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698