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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 const WebColor kDarkCyan = 0xFF227788; | 216 const WebColor kDarkCyan = 0xFF227788; |
217 const WebColor kTranslucentPutty = 0x80BFB196; | 217 const WebColor kTranslucentPutty = 0x80BFB196; |
218 | 218 |
219 WebView* webView = m_webViewHelper.initialize(); | 219 WebView* webView = m_webViewHelper.initialize(); |
220 EXPECT_EQ(kWhite, webView->backgroundColor()); | 220 EXPECT_EQ(kWhite, webView->backgroundColor()); |
221 | 221 |
222 webView->setBaseBackgroundColor(kBlue); | 222 webView->setBaseBackgroundColor(kBlue); |
223 EXPECT_EQ(kBlue, webView->backgroundColor()); | 223 EXPECT_EQ(kBlue, webView->backgroundColor()); |
224 | 224 |
225 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/"); | 225 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/"); |
226 FrameTestHelpers::loadHTMLString(webView->mainFrame(), "<html><head><style>b
ody {background-color:#227788}</style></head></html>", baseURL); | 226 webView->mainFrame()->loadHTMLString( |
| 227 "<html><head><style>body {background-color:#227788}</style></head></html
>", baseURL); |
| 228 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); |
227 EXPECT_EQ(kDarkCyan, webView->backgroundColor()); | 229 EXPECT_EQ(kDarkCyan, webView->backgroundColor()); |
228 | 230 |
229 FrameTestHelpers::loadHTMLString(webView->mainFrame(), "<html><head><style>b
ody {background-color:rgba(255,0,0,0.5)}</style></head></html>", baseURL); | 231 webView->mainFrame()->loadHTMLString( |
| 232 "<html><head><style>body {background-color:rgba(255,0,0,0.5)}</style></h
ead></html>", baseURL); |
| 233 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); |
230 // Expected: red (50% alpha) blended atop base of kBlue. | 234 // Expected: red (50% alpha) blended atop base of kBlue. |
231 EXPECT_EQ(0xFF7F0080, webView->backgroundColor()); | 235 EXPECT_EQ(0xFF7F0080, webView->backgroundColor()); |
232 | 236 |
233 webView->setBaseBackgroundColor(kTranslucentPutty); | 237 webView->setBaseBackgroundColor(kTranslucentPutty); |
234 // Expected: red (50% alpha) blended atop kTranslucentPutty. Note the alpha. | 238 // Expected: red (50% alpha) blended atop kTranslucentPutty. Note the alpha. |
235 EXPECT_EQ(0xBFE93B32, webView->backgroundColor()); | 239 EXPECT_EQ(0xBFE93B32, webView->backgroundColor()); |
236 } | 240 } |
237 | 241 |
238 TEST_F(WebViewTest, SetBaseBackgroundColorBeforeMainFrame) | 242 TEST_F(WebViewTest, SetBaseBackgroundColorBeforeMainFrame) |
239 { | 243 { |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 // Confirm that exiting fullscreen restores the parameters. | 826 // Confirm that exiting fullscreen restores the parameters. |
823 webViewImpl->willExitFullScreen(); | 827 webViewImpl->willExitFullScreen(); |
824 webViewImpl->didExitFullScreen(); | 828 webViewImpl->didExitFullScreen(); |
825 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); | 829 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); |
826 EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); | 830 EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); |
827 EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); | 831 EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); |
828 | 832 |
829 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally
scoped client. | 833 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally
scoped client. |
830 } | 834 } |
831 | 835 |
832 class DropTask : public WebThread::Task { | |
833 public: | |
834 explicit DropTask(WebView* webView) : m_webView(webView) | |
835 { | |
836 } | |
837 | |
838 virtual void run() OVERRIDE | |
839 { | |
840 const WebPoint clientPoint(0, 0); | |
841 const WebPoint screenPoint(0, 0); | |
842 m_webView->dragTargetDrop(clientPoint, screenPoint, 0); | |
843 } | |
844 | |
845 private: | |
846 WebView* const m_webView; | |
847 }; | |
848 static void DragAndDropURL(WebViewImpl* webView, const std::string& url) | 836 static void DragAndDropURL(WebViewImpl* webView, const std::string& url) |
849 { | 837 { |
850 blink::WebDragData dragData; | 838 blink::WebDragData dragData; |
851 dragData.initialize(); | 839 dragData.initialize(); |
852 | 840 |
853 WebDragData::Item item; | 841 WebDragData::Item item; |
854 item.storageType = WebDragData::Item::StorageTypeString; | 842 item.storageType = WebDragData::Item::StorageTypeString; |
855 item.stringType = "text/uri-list"; | 843 item.stringType = "text/uri-list"; |
856 item.stringData = WebString::fromUTF8(url); | 844 item.stringData = WebString::fromUTF8(url); |
857 dragData.addItem(item); | 845 dragData.addItem(item); |
858 | 846 |
859 const WebPoint clientPoint(0, 0); | 847 const WebPoint clientPoint(0, 0); |
860 const WebPoint screenPoint(0, 0); | 848 const WebPoint screenPoint(0, 0); |
861 webView->dragTargetDragEnter(dragData, clientPoint, screenPoint, blink::WebD
ragOperationCopy, 0); | 849 webView->dragTargetDragEnter(dragData, clientPoint, screenPoint, blink::WebD
ragOperationCopy, 0); |
862 Platform::current()->currentThread()->postTask(new DropTask(webView)); | 850 webView->dragTargetDrop(clientPoint, screenPoint, 0); |
863 FrameTestHelpers::pumpPendingRequestsDoNotUse(webView->mainFrame()); | 851 FrameTestHelpers::runPendingTasks(); |
| 852 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); |
864 } | 853 } |
865 | 854 |
866 TEST_F(WebViewTest, DragDropURL) | 855 TEST_F(WebViewTest, DragDropURL) |
867 { | 856 { |
868 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), "foo.html"); | 857 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), "foo.html"); |
869 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), "bar.html"); | 858 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), "bar.html"); |
870 | 859 |
871 const std::string fooUrl = m_baseURL + "foo.html"; | 860 const std::string fooUrl = m_baseURL + "foo.html"; |
872 const std::string barUrl = m_baseURL + "bar.html"; | 861 const std::string barUrl = m_baseURL + "bar.html"; |
873 | 862 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 { | 1090 { |
1102 OwnPtr<FrameTestHelpers::TestWebViewClient> fakeCompositingWebViewClient = a
doptPtr(new FrameTestHelpers::TestWebViewClient()); | 1091 OwnPtr<FrameTestHelpers::TestWebViewClient> fakeCompositingWebViewClient = a
doptPtr(new FrameTestHelpers::TestWebViewClient()); |
1103 FrameTestHelpers::WebViewHelper webViewHelper; | 1092 FrameTestHelpers::WebViewHelper webViewHelper; |
1104 WebViewImpl* webViewImpl = webViewHelper.initialize(true, 0, fakeCompositing
WebViewClient.get(), &configueCompositingWebView); | 1093 WebViewImpl* webViewImpl = webViewHelper.initialize(true, 0, fakeCompositing
WebViewClient.get(), &configueCompositingWebView); |
1105 | 1094 |
1106 int pageWidth = 640; | 1095 int pageWidth = 640; |
1107 int pageHeight = 480; | 1096 int pageHeight = 480; |
1108 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | 1097 webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
1109 | 1098 |
1110 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/"); | 1099 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/"); |
1111 FrameTestHelpers::loadHTMLString(webViewImpl->mainFrame(), "<a href='http://
www.test.com' style='position: absolute; left: 20px; top: 20px; width: 200px; -w
ebkit-transform:translateZ(0);'>A link to highlight</a>", baseURL); | 1100 webViewImpl->mainFrame()->loadHTMLString( |
| 1101 "<a href='http://www.test.com' style='position: absolute; left: 20px; to
p: 20px; width: 200px; -webkit-transform:translateZ(0);'>A link to highlight</a>
", baseURL); |
| 1102 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); |
1112 | 1103 |
1113 WebGestureEvent event; | 1104 WebGestureEvent event; |
1114 event.type = WebInputEvent::GestureShowPress; | 1105 event.type = WebInputEvent::GestureShowPress; |
1115 event.x = 20; | 1106 event.x = 20; |
1116 event.y = 20; | 1107 event.y = 20; |
1117 | 1108 |
1118 // Just make sure we don't hit any asserts. | 1109 // Just make sure we don't hit any asserts. |
1119 webViewImpl->handleInputEvent(event); | 1110 webViewImpl->handleInputEvent(event); |
1120 } | 1111 } |
1121 | 1112 |
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1935 | 1926 |
1936 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); | 1927 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); |
1937 | 1928 |
1938 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr
omUTF8("target"))); | 1929 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr
omUTF8("target"))); |
1939 | 1930 |
1940 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); | 1931 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); |
1941 webView->setAutofillClient(0); | 1932 webView->setAutofillClient(0); |
1942 } | 1933 } |
1943 | 1934 |
1944 } // namespace | 1935 } // namespace |
OLD | NEW |