OLD | NEW |
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 16 matching lines...) Expand all Loading... |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "public/web/WebView.h" | 32 #include "public/web/WebView.h" |
33 | 33 |
34 #include "core/dom/Document.h" | 34 #include "core/dom/Document.h" |
35 #include "core/dom/Element.h" | 35 #include "core/dom/Element.h" |
36 #include "core/frame/FrameView.h" | 36 #include "core/frame/FrameView.h" |
| 37 #include "core/frame/LocalFrame.h" |
37 #include "core/frame/Settings.h" | 38 #include "core/frame/Settings.h" |
38 #include "core/html/HTMLDocument.h" | 39 #include "core/html/HTMLDocument.h" |
39 #include "core/html/HTMLIFrameElement.h" | 40 #include "core/html/HTMLIFrameElement.h" |
40 #include "core/html/HTMLInputElement.h" | 41 #include "core/html/HTMLInputElement.h" |
41 #include "core/html/HTMLTextAreaElement.h" | 42 #include "core/html/HTMLTextAreaElement.h" |
42 #include "core/loader/FrameLoadRequest.h" | 43 #include "core/loader/FrameLoadRequest.h" |
43 #include "core/page/Chrome.h" | 44 #include "core/page/Chrome.h" |
44 #include "core/rendering/RenderLayer.h" | 45 #include "core/rendering/RenderLayer.h" |
45 #include "core/rendering/RenderView.h" | 46 #include "core/rendering/RenderView.h" |
46 #include "platform/KeyboardCodes.h" | 47 #include "platform/KeyboardCodes.h" |
| 48 #include "platform/geometry/IntSize.h" |
47 #include "platform/graphics/Color.h" | 49 #include "platform/graphics/Color.h" |
48 #include "public/platform/Platform.h" | 50 #include "public/platform/Platform.h" |
49 #include "public/platform/WebDragData.h" | 51 #include "public/platform/WebDragData.h" |
50 #include "public/platform/WebSize.h" | 52 #include "public/platform/WebSize.h" |
51 #include "public/platform/WebThread.h" | 53 #include "public/platform/WebThread.h" |
52 #include "public/platform/WebUnitTestSupport.h" | 54 #include "public/platform/WebUnitTestSupport.h" |
53 #include "public/web/WebAutofillClient.h" | 55 #include "public/web/WebAutofillClient.h" |
54 #include "public/web/WebContentDetectionResult.h" | 56 #include "public/web/WebContentDetectionResult.h" |
55 #include "public/web/WebDateTimeChooserCompletion.h" | 57 #include "public/web/WebDateTimeChooserCompletion.h" |
56 #include "public/web/WebDocument.h" | 58 #include "public/web/WebDocument.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 std::string m_baseURL; | 212 std::string m_baseURL; |
211 FrameTestHelpers::WebViewHelper m_webViewHelper; | 213 FrameTestHelpers::WebViewHelper m_webViewHelper; |
212 }; | 214 }; |
213 | 215 |
214 TEST_F(WebViewTest, SetBaseBackgroundColor) | 216 TEST_F(WebViewTest, SetBaseBackgroundColor) |
215 { | 217 { |
216 const WebColor kWhite = 0xFFFFFFFF; | 218 const WebColor kWhite = 0xFFFFFFFF; |
217 const WebColor kBlue = 0xFF0000FF; | 219 const WebColor kBlue = 0xFF0000FF; |
218 const WebColor kDarkCyan = 0xFF227788; | 220 const WebColor kDarkCyan = 0xFF227788; |
219 const WebColor kTranslucentPutty = 0x80BFB196; | 221 const WebColor kTranslucentPutty = 0x80BFB196; |
| 222 const WebColor kTransparent = 0x00000000; |
220 | 223 |
221 WebView* webView = m_webViewHelper.initialize(); | 224 WebViewImpl* webView = m_webViewHelper.initialize(); |
222 EXPECT_EQ(kWhite, webView->backgroundColor()); | 225 EXPECT_EQ(kWhite, webView->backgroundColor()); |
223 | 226 |
224 webView->setBaseBackgroundColor(kBlue); | 227 webView->setBaseBackgroundColor(kBlue); |
225 EXPECT_EQ(kBlue, webView->backgroundColor()); | 228 EXPECT_EQ(kBlue, webView->backgroundColor()); |
226 | 229 |
227 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/"); | 230 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/"); |
228 FrameTestHelpers::loadHTMLString(webView->mainFrame(), "<html><head><style>b
ody {background-color:#227788}</style></head></html>", baseURL); | 231 FrameTestHelpers::loadHTMLString(webView->mainFrame(), "<html><head><style>b
ody {background-color:#227788}</style></head></html>", baseURL); |
229 EXPECT_EQ(kDarkCyan, webView->backgroundColor()); | 232 EXPECT_EQ(kDarkCyan, webView->backgroundColor()); |
230 | 233 |
231 FrameTestHelpers::loadHTMLString(webView->mainFrame(), "<html><head><style>b
ody {background-color:rgba(255,0,0,0.5)}</style></head></html>", baseURL); | 234 FrameTestHelpers::loadHTMLString(webView->mainFrame(), "<html><head><style>b
ody {background-color:rgba(255,0,0,0.5)}</style></head></html>", baseURL); |
232 // Expected: red (50% alpha) blended atop base of kBlue. | 235 // Expected: red (50% alpha) blended atop base of kBlue. |
233 EXPECT_EQ(0xFF7F0080, webView->backgroundColor()); | 236 EXPECT_EQ(0xFF7F0080, webView->backgroundColor()); |
234 | 237 |
235 webView->setBaseBackgroundColor(kTranslucentPutty); | 238 webView->setBaseBackgroundColor(kTranslucentPutty); |
236 // Expected: red (50% alpha) blended atop kTranslucentPutty. Note the alpha. | 239 // Expected: red (50% alpha) blended atop kTranslucentPutty. Note the alpha. |
237 EXPECT_EQ(0xBFE93B32, webView->backgroundColor()); | 240 EXPECT_EQ(0xBFE93B32, webView->backgroundColor()); |
| 241 |
| 242 webView->setBaseBackgroundColor(kTransparent); |
| 243 FrameTestHelpers::loadHTMLString(webView->mainFrame(), "<html><head><style>b
ody {background-color:transparent}</style></head></html>", baseURL); |
| 244 // Expected: transparent on top of kTransparent will still be transparent. |
| 245 EXPECT_EQ(kTransparent, webView->backgroundColor()); |
| 246 |
| 247 WebCore::LocalFrame* frame = webView->mainFrameImpl()->frame(); |
| 248 |
| 249 // Creating a new frame view with the background color having 0 alpha. |
| 250 frame->createView(WebCore::IntSize(1024, 768), WebCore::Color::transparent,
true); |
| 251 EXPECT_EQ(kTransparent, frame->view()->baseBackgroundColor()); |
| 252 |
| 253 WebCore::Color kTransparentRed(100, 0, 0, 0); |
| 254 frame->createView(WebCore::IntSize(1024, 768), kTransparentRed, true); |
| 255 EXPECT_EQ(kTransparentRed, frame->view()->baseBackgroundColor()); |
238 } | 256 } |
239 | 257 |
240 TEST_F(WebViewTest, SetBaseBackgroundColorBeforeMainFrame) | 258 TEST_F(WebViewTest, SetBaseBackgroundColorBeforeMainFrame) |
241 { | 259 { |
242 const WebColor kBlue = 0xFF0000FF; | 260 const WebColor kBlue = 0xFF0000FF; |
243 WebView* webView = WebViewImpl::create(0); | 261 WebView* webView = WebViewImpl::create(0); |
244 EXPECT_NE(kBlue, webView->backgroundColor()); | 262 EXPECT_NE(kBlue, webView->backgroundColor()); |
245 // webView does not have a frame yet, but we should still be able to set the
background color. | 263 // webView does not have a frame yet, but we should still be able to set the
background color. |
246 webView->setBaseBackgroundColor(kBlue); | 264 webView->setBaseBackgroundColor(kBlue); |
247 EXPECT_EQ(kBlue, webView->backgroundColor()); | 265 EXPECT_EQ(kBlue, webView->backgroundColor()); |
(...skipping 1729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1977 | 1995 |
1978 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); | 1996 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); |
1979 | 1997 |
1980 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr
omUTF8("target"))); | 1998 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr
omUTF8("target"))); |
1981 | 1999 |
1982 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); | 2000 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); |
1983 webView->setAutofillClient(0); | 2001 webView->setAutofillClient(0); |
1984 } | 2002 } |
1985 | 2003 |
1986 } // namespace | 2004 } // namespace |
OLD | NEW |