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

Side by Side Diff: Source/web/tests/WebViewTest.cpp

Issue 271793007: Fix webkit_unit_tests to use the threaded parser and enable everywhere. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add loadHistoryItem wrapper Created 6 years, 7 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 | Annotate | Revision Log
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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 webView->mainFrame()->loadHTMLString( 226 FrameTestHelpers::loadHTMLString(webView->mainFrame(), "<html><head><style>b ody {background-color:#227788}</style></head></html>", baseURL);
227 "<html><head><style>body {background-color:#227788}</style></head></html >", baseURL);
228 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
229 EXPECT_EQ(kDarkCyan, webView->backgroundColor()); 227 EXPECT_EQ(kDarkCyan, webView->backgroundColor());
230 228
231 webView->mainFrame()->loadHTMLString( 229 FrameTestHelpers::loadHTMLString(webView->mainFrame(), "<html><head><style>b ody {background-color:rgba(255,0,0,0.5)}</style></head></html>", baseURL);
232 "<html><head><style>body {background-color:rgba(255,0,0,0.5)}</style></h ead></html>", baseURL);
233 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
234 // Expected: red (50% alpha) blended atop base of kBlue. 230 // Expected: red (50% alpha) blended atop base of kBlue.
235 EXPECT_EQ(0xFF7F0080, webView->backgroundColor()); 231 EXPECT_EQ(0xFF7F0080, webView->backgroundColor());
236 232
237 webView->setBaseBackgroundColor(kTranslucentPutty); 233 webView->setBaseBackgroundColor(kTranslucentPutty);
238 // Expected: red (50% alpha) blended atop kTranslucentPutty. Note the alpha. 234 // Expected: red (50% alpha) blended atop kTranslucentPutty. Note the alpha.
239 EXPECT_EQ(0xBFE93B32, webView->backgroundColor()); 235 EXPECT_EQ(0xBFE93B32, webView->backgroundColor());
240 } 236 }
241 237
242 TEST_F(WebViewTest, SetBaseBackgroundColorBeforeMainFrame) 238 TEST_F(WebViewTest, SetBaseBackgroundColorBeforeMainFrame)
243 { 239 {
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 // Confirm that exiting fullscreen restores the parameters. 822 // Confirm that exiting fullscreen restores the parameters.
827 webViewImpl->willExitFullScreen(); 823 webViewImpl->willExitFullScreen();
828 webViewImpl->didExitFullScreen(); 824 webViewImpl->didExitFullScreen();
829 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); 825 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor());
830 EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); 826 EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width);
831 EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); 827 EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height);
832 828
833 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client. 829 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client.
834 } 830 }
835 831
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 };
836 static void DragAndDropURL(WebViewImpl* webView, const std::string& url) 848 static void DragAndDropURL(WebViewImpl* webView, const std::string& url)
837 { 849 {
838 blink::WebDragData dragData; 850 blink::WebDragData dragData;
839 dragData.initialize(); 851 dragData.initialize();
840 852
841 WebDragData::Item item; 853 WebDragData::Item item;
842 item.storageType = WebDragData::Item::StorageTypeString; 854 item.storageType = WebDragData::Item::StorageTypeString;
843 item.stringType = "text/uri-list"; 855 item.stringType = "text/uri-list";
844 item.stringData = WebString::fromUTF8(url); 856 item.stringData = WebString::fromUTF8(url);
845 dragData.addItem(item); 857 dragData.addItem(item);
846 858
847 const WebPoint clientPoint(0, 0); 859 const WebPoint clientPoint(0, 0);
848 const WebPoint screenPoint(0, 0); 860 const WebPoint screenPoint(0, 0);
849 webView->dragTargetDragEnter(dragData, clientPoint, screenPoint, blink::WebD ragOperationCopy, 0); 861 webView->dragTargetDragEnter(dragData, clientPoint, screenPoint, blink::WebD ragOperationCopy, 0);
850 webView->dragTargetDrop(clientPoint, screenPoint, 0); 862 Platform::current()->currentThread()->postTask(new DropTask(webView));
851 FrameTestHelpers::runPendingTasks(); 863 FrameTestHelpers::pumpPendingRequestsDoNotUse(webView->mainFrame());
852 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
853 } 864 }
854 865
855 TEST_F(WebViewTest, DragDropURL) 866 TEST_F(WebViewTest, DragDropURL)
856 { 867 {
857 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), "foo.html"); 868 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), "foo.html");
858 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), "bar.html"); 869 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), "bar.html");
859 870
860 const std::string fooUrl = m_baseURL + "foo.html"; 871 const std::string fooUrl = m_baseURL + "foo.html";
861 const std::string barUrl = m_baseURL + "bar.html"; 872 const std::string barUrl = m_baseURL + "bar.html";
862 873
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 { 1101 {
1091 OwnPtr<FrameTestHelpers::TestWebViewClient> fakeCompositingWebViewClient = a doptPtr(new FrameTestHelpers::TestWebViewClient()); 1102 OwnPtr<FrameTestHelpers::TestWebViewClient> fakeCompositingWebViewClient = a doptPtr(new FrameTestHelpers::TestWebViewClient());
1092 FrameTestHelpers::WebViewHelper webViewHelper; 1103 FrameTestHelpers::WebViewHelper webViewHelper;
1093 WebViewImpl* webViewImpl = webViewHelper.initialize(true, 0, fakeCompositing WebViewClient.get(), &configueCompositingWebView); 1104 WebViewImpl* webViewImpl = webViewHelper.initialize(true, 0, fakeCompositing WebViewClient.get(), &configueCompositingWebView);
1094 1105
1095 int pageWidth = 640; 1106 int pageWidth = 640;
1096 int pageHeight = 480; 1107 int pageHeight = 480;
1097 webViewImpl->resize(WebSize(pageWidth, pageHeight)); 1108 webViewImpl->resize(WebSize(pageWidth, pageHeight));
1098 1109
1099 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/"); 1110 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/");
1100 webViewImpl->mainFrame()->loadHTMLString( 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);
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();
1103 1112
1104 WebGestureEvent event; 1113 WebGestureEvent event;
1105 event.type = WebInputEvent::GestureShowPress; 1114 event.type = WebInputEvent::GestureShowPress;
1106 event.x = 20; 1115 event.x = 20;
1107 event.y = 20; 1116 event.y = 20;
1108 1117
1109 // Just make sure we don't hit any asserts. 1118 // Just make sure we don't hit any asserts.
1110 webViewImpl->handleInputEvent(event); 1119 webViewImpl->handleInputEvent(event);
1111 } 1120 }
1112 1121
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
1926 1935
1927 EXPECT_EQ(0, client.getUserGestureNotificationsCount()); 1936 EXPECT_EQ(0, client.getUserGestureNotificationsCount());
1928 1937
1929 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr omUTF8("target"))); 1938 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr omUTF8("target")));
1930 1939
1931 EXPECT_EQ(1, client.getUserGestureNotificationsCount()); 1940 EXPECT_EQ(1, client.getUserGestureNotificationsCount());
1932 webView->setAutofillClient(0); 1941 webView->setAutofillClient(0);
1933 } 1942 }
1934 1943
1935 } // namespace 1944 } // namespace
OLDNEW
« Source/web/tests/FrameTestHelpers.h ('K') | « Source/web/tests/WebPageSerializerTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698