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

Side by Side Diff: Source/web/tests/WebPageNewSerializerTest.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 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 registerMockedURLLoad(toKURL("http://www.test.com/green_background.png") , WebString::fromUTF8("green_background.png"), WebString::fromUTF8("pageserializ er/"), pngMimeType()); 152 registerMockedURLLoad(toKURL("http://www.test.com/green_background.png") , WebString::fromUTF8("green_background.png"), WebString::fromUTF8("pageserializ er/"), pngMimeType());
153 registerMockedURLLoad(toKURL("http://www.test.com/blue_background.png"), WebString::fromUTF8("blue_background.png"), WebString::fromUTF8("pageserializer /"), pngMimeType()); 153 registerMockedURLLoad(toKURL("http://www.test.com/blue_background.png"), WebString::fromUTF8("blue_background.png"), WebString::fromUTF8("pageserializer /"), pngMimeType());
154 registerMockedURLLoad(toKURL("http://www.test.com/purple_background.png" ), WebString::fromUTF8("purple_background.png"), WebString::fromUTF8("pageserial izer/"), pngMimeType()); 154 registerMockedURLLoad(toKURL("http://www.test.com/purple_background.png" ), WebString::fromUTF8("purple_background.png"), WebString::fromUTF8("pageserial izer/"), pngMimeType());
155 registerMockedURLLoad(toKURL("http://www.test.com/ul-dot.png"), WebStrin g::fromUTF8("ul-dot.png"), WebString::fromUTF8("pageserializer/"), pngMimeType() ); 155 registerMockedURLLoad(toKURL("http://www.test.com/ul-dot.png"), WebStrin g::fromUTF8("ul-dot.png"), WebString::fromUTF8("pageserializer/"), pngMimeType() );
156 registerMockedURLLoad(toKURL("http://www.test.com/ol-dot.png"), WebStrin g::fromUTF8("ol-dot.png"), WebString::fromUTF8("pageserializer/"), pngMimeType() ); 156 registerMockedURLLoad(toKURL("http://www.test.com/ol-dot.png"), WebStrin g::fromUTF8("ol-dot.png"), WebString::fromUTF8("pageserializer/"), pngMimeType() );
157 return topFrameURL; 157 return topFrameURL;
158 } 158 }
159 159
160 void loadURLInTopFrame(const WebURL& url) 160 void loadURLInTopFrame(const WebURL& url)
161 { 161 {
162 WebURLRequest urlRequest; 162 FrameTestHelpers::loadFrame(m_helper.webView()->mainFrame(), url.string( ).utf8());
163 urlRequest.initialize();
164 urlRequest.setURL(url);
165 m_helper.webView()->mainFrame()->loadRequest(urlRequest);
166 // Make sure any pending request get served.
167 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests( );
168 // Some requests get delayed, run the timer.
169 runPendingTasks();
170 // Server the delayed resources.
171 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests( );
172 } 163 }
173 164
174 const WebString& htmlMimeType() const { return m_htmlMimeType; } 165 const WebString& htmlMimeType() const { return m_htmlMimeType; }
175 const WebString& xhtmlMimeType() const { return m_xhtmlMimeType; } 166 const WebString& xhtmlMimeType() const { return m_xhtmlMimeType; }
176 const WebString& cssMimeType() const { return m_cssMimeType; } 167 const WebString& cssMimeType() const { return m_cssMimeType; }
177 const WebString& pngMimeType() const { return m_pngMimeType; } 168 const WebString& pngMimeType() const { return m_pngMimeType; }
178 const WebString& svgMimeType() const { return m_svgMimeType; } 169 const WebString& svgMimeType() const { return m_svgMimeType; }
179 170
180 static bool resourceVectorContains(const WebVector<WebPageSerializer::Resour ce>& resources, const char* url, const char* mimeType) 171 static bool resourceVectorContains(const WebVector<WebPageSerializer::Resour ce>& resources, const char* url, const char* mimeType)
181 { 172 {
(...skipping 30 matching lines...) Expand all
212 // Register the mocked frames. 203 // Register the mocked frames.
213 WebURL topFrameURL = toKURL("http://www.test.com"); 204 WebURL topFrameURL = toKURL("http://www.test.com");
214 registerMockedURLLoad(topFrameURL, WebString::fromUTF8("top_frame.html"), We bString::fromUTF8("pageserializer/"), htmlMimeType()); 205 registerMockedURLLoad(topFrameURL, WebString::fromUTF8("top_frame.html"), We bString::fromUTF8("pageserializer/"), htmlMimeType());
215 registerMockedURLLoad(toKURL("http://www.test.com/iframe.html"), WebString:: fromUTF8("iframe.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType()) ; 206 registerMockedURLLoad(toKURL("http://www.test.com/iframe.html"), WebString:: fromUTF8("iframe.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType()) ;
216 registerMockedURLLoad(toKURL("http://www.test.com/iframe2.html"), WebString: :fromUTF8("iframe2.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType( )); 207 registerMockedURLLoad(toKURL("http://www.test.com/iframe2.html"), WebString: :fromUTF8("iframe2.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType( ));
217 registerMockedURLLoad(toKURL("http://www.test.com/red_background.png"), WebS tring::fromUTF8("red_background.png"), WebString::fromUTF8("pageserializer/"), p ngMimeType()); 208 registerMockedURLLoad(toKURL("http://www.test.com/red_background.png"), WebS tring::fromUTF8("red_background.png"), WebString::fromUTF8("pageserializer/"), p ngMimeType());
218 registerMockedURLLoad(toKURL("http://www.test.com/green_background.png"), We bString::fromUTF8("green_background.png"), WebString::fromUTF8("pageserializer/" ), pngMimeType()); 209 registerMockedURLLoad(toKURL("http://www.test.com/green_background.png"), We bString::fromUTF8("green_background.png"), WebString::fromUTF8("pageserializer/" ), pngMimeType());
219 registerMockedURLLoad(toKURL("http://www.test.com/blue_background.png"), Web String::fromUTF8("blue_background.png"), WebString::fromUTF8("pageserializer/"), pngMimeType()); 210 registerMockedURLLoad(toKURL("http://www.test.com/blue_background.png"), Web String::fromUTF8("blue_background.png"), WebString::fromUTF8("pageserializer/"), pngMimeType());
220 211
221 loadURLInTopFrame(topFrameURL); 212 loadURLInTopFrame(topFrameURL);
222 // OBJECT/EMBED have some delay to start to load their content. The first
223 // serveAsynchronousMockedRequests call in loadURLInTopFrame() finishes
224 // before the start.
225 RefPtrWillBeRawPtr<Document> document = static_cast<PassRefPtrWillBeRawPtr<D ocument> >(webView()->mainFrame()->document());
226 document->updateLayoutIgnorePendingStylesheets(Document::RunPostLayoutTasksS ynchronously);
227 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
228 213
229 WebVector<WebPageSerializer::Resource> resources; 214 WebVector<WebPageSerializer::Resource> resources;
230 WebPageSerializer::serialize(webView(), &resources); 215 WebPageSerializer::serialize(webView(), &resources);
231 ASSERT_FALSE(resources.isEmpty()); 216 ASSERT_FALSE(resources.isEmpty());
232 217
233 // The first resource should be the main-frame. 218 // The first resource should be the main-frame.
234 const WebPageSerializer::Resource& resource = resources[0]; 219 const WebPageSerializer::Resource& resource = resources[0];
235 EXPECT_TRUE(resource.url == WebURL(toKURL("http://www.test.com"))); 220 EXPECT_TRUE(resource.url == WebURL(toKURL("http://www.test.com")));
236 EXPECT_EQ(0, resource.mimeType.compare(WebCString("text/html"))); 221 EXPECT_EQ(0, resource.mimeType.compare(WebCString("text/html")));
237 EXPECT_FALSE(resource.data.isEmpty()); 222 EXPECT_FALSE(resource.data.isEmpty());
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 WebURL pageUrl = toKURL("http://www.test.com"); 424 WebURL pageUrl = toKURL("http://www.test.com");
440 registerMockedURLLoad(pageUrl, WebString::fromUTF8("top_frame.html"), WebStr ing::fromUTF8("pageserializer/"), htmlMimeType()); 425 registerMockedURLLoad(pageUrl, WebString::fromUTF8("top_frame.html"), WebStr ing::fromUTF8("pageserializer/"), htmlMimeType());
441 registerMockedURLLoad(toKURL("http://www.test.com/iframe.html"), WebString:: fromUTF8("iframe.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType()) ; 426 registerMockedURLLoad(toKURL("http://www.test.com/iframe.html"), WebString:: fromUTF8("iframe.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType()) ;
442 registerMockedURLLoad(toKURL("http://www.test.com/iframe2.html"), WebString: :fromUTF8("iframe2.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType( )); 427 registerMockedURLLoad(toKURL("http://www.test.com/iframe2.html"), WebString: :fromUTF8("iframe2.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType( ));
443 registerMockedURLLoad(toKURL("http://www.test.com/red_background.png"), WebS tring::fromUTF8("red_background.png"), WebString::fromUTF8("pageserializer/"), p ngMimeType()); 428 registerMockedURLLoad(toKURL("http://www.test.com/red_background.png"), WebS tring::fromUTF8("red_background.png"), WebString::fromUTF8("pageserializer/"), p ngMimeType());
444 registerMockedURLLoad(toKURL("http://www.test.com/green_background.png"), We bString::fromUTF8("green_background.png"), WebString::fromUTF8("pageserializer/" ), pngMimeType()); 429 registerMockedURLLoad(toKURL("http://www.test.com/green_background.png"), We bString::fromUTF8("green_background.png"), WebString::fromUTF8("pageserializer/" ), pngMimeType());
445 registerMockedURLLoad(toKURL("http://www.test.com/blue_background.png"), Web String::fromUTF8("blue_background.png"), WebString::fromUTF8("pageserializer/"), pngMimeType()); 430 registerMockedURLLoad(toKURL("http://www.test.com/blue_background.png"), Web String::fromUTF8("blue_background.png"), WebString::fromUTF8("pageserializer/"), pngMimeType());
446 431
447 loadURLInTopFrame(pageUrl); 432 loadURLInTopFrame(pageUrl);
448 433
449 // OBJECT/EMBED have some delay to start to load their content. The first
450 // serveAsynchronousMockedRequests call in loadURLInTopFrame() finishes
451 // before the start.
452 RefPtrWillBeRawPtr<Document> document = static_cast<PassRefPtrWillBeRawPtr<D ocument> >(webView()->mainFrame()->document());
453 document->updateLayoutIgnorePendingStylesheets(Document::RunPostLayoutTasksS ynchronously);
454 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
455
456 WebVector<WebURL> localLinks(static_cast<size_t>(2)); 434 WebVector<WebURL> localLinks(static_cast<size_t>(2));
457 WebVector<WebString> localPaths(static_cast<size_t>(2)); 435 WebVector<WebString> localPaths(static_cast<size_t>(2));
458 localLinks[0] = pageUrl; 436 localLinks[0] = pageUrl;
459 localPaths[0] = WebString("/"); 437 localPaths[0] = WebString("/");
460 localLinks[1] = toKURL("http://www.test.com/iframe.html"); 438 localLinks[1] = toKURL("http://www.test.com/iframe.html");
461 localPaths[1] = WebString("SavedFiles/iframe.html"); 439 localPaths[1] = WebString("SavedFiles/iframe.html");
462 440
463 WebString serializedData; 441 WebString serializedData;
464 FrameDataWebPageSerializerClient client(pageUrl, &serializedData); 442 FrameDataWebPageSerializerClient client(pageUrl, &serializedData);
465 443
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 // exactly two times. 489 // exactly two times.
512 size_t nbDataURLs = 0; 490 size_t nbDataURLs = 0;
513 LineReader lineReader(std::string(mhtmlData.data())); 491 LineReader lineReader(std::string(mhtmlData.data()));
514 std::string line; 492 std::string line;
515 while (lineReader.getNextLine(&line)) { 493 while (lineReader.getNextLine(&line)) {
516 if (line.find("data:text") != std::string::npos) 494 if (line.find("data:text") != std::string::npos)
517 nbDataURLs++; 495 nbDataURLs++;
518 } 496 }
519 EXPECT_EQ(2u, nbDataURLs); 497 EXPECT_EQ(2u, nbDataURLs);
520 } 498 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698