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

Side by Side Diff: Source/web/tests/WebPageSerializerTest.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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); 72 Platform::current()->unitTestSupport()->unregisterAllMockedURLs();
73 } 73 }
74 74
75 void registerMockedURLLoad(const std::string& url, const WebString& fileName ) 75 void registerMockedURLLoad(const std::string& url, const WebString& fileName )
76 { 76 {
77 URLTestHelpers::registerMockedURLLoad(toKURL(url), fileName, WebString:: fromUTF8("pageserialization/"), WebString::fromUTF8("text/html")); 77 URLTestHelpers::registerMockedURLLoad(toKURL(url), fileName, WebString:: fromUTF8("pageserialization/"), WebString::fromUTF8("text/html"));
78 } 78 }
79 79
80 void loadURLInTopFrame(const WebURL& url) 80 void loadURLInTopFrame(const WebURL& url)
81 { 81 {
82 WebURLRequest urlRequest; 82 FrameTestHelpers::loadFrame(m_helper.webView()->mainFrame(), url.string( ).utf8());
83 urlRequest.initialize();
84 urlRequest.setURL(url);
85 m_helper.webView()->mainFrame()->loadRequest(urlRequest);
86 // Make sure any pending request get served.
87 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests( );
88 } 83 }
89 84
90 static bool webVectorContains(const WebVector<WebURL>& vector, const char* u rl) 85 static bool webVectorContains(const WebVector<WebURL>& vector, const char* u rl)
91 { 86 {
92 return vector.contains(WebURL(toKURL(std::string(url)))); 87 return vector.contains(WebURL(toKURL(std::string(url))));
93 } 88 }
94 89
95 // Useful for debugging. 90 // Useful for debugging.
96 static void printWebURLs(const WebVector<WebURL>& urls) 91 static void printWebURLs(const WebVector<WebURL>& urls)
97 { 92 {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 WebString::fromUTF8("object_iframe.html")); 148 WebString::fromUTF8("object_iframe.html"));
154 registerMockedURLLoad("http://www.test.com/embed_iframe.html", 149 registerMockedURLLoad("http://www.test.com/embed_iframe.html",
155 WebString::fromUTF8("embed_iframe.html")); 150 WebString::fromUTF8("embed_iframe.html"));
156 // If we don't register a mocked resource for awesome.png, it causes the 151 // If we don't register a mocked resource for awesome.png, it causes the
157 // document loader of the iframe that has it as its src to assert on close, 152 // document loader of the iframe that has it as its src to assert on close,
158 // not sure why. 153 // not sure why.
159 registerMockedURLLoad("http://www.test.com/awesome.png", 154 registerMockedURLLoad("http://www.test.com/awesome.png",
160 WebString::fromUTF8("awesome.png")); 155 WebString::fromUTF8("awesome.png"));
161 156
162 loadURLInTopFrame(topFrameURL); 157 loadURLInTopFrame(topFrameURL);
163 // OBJECT/EMBED have some delay to start to load their content. The first
164 // serveAsynchronousMockedRequests call in loadURLInTopFrame() finishes
165 // before the start.
166 RefPtrWillBeRawPtr<Document> document = static_cast<PassRefPtrWillBeRawPtr<D ocument> >(webView()->mainFrame()->document());
167 document->updateLayoutIgnorePendingStylesheets(Document::RunPostLayoutTasksS ynchronously);
168 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
169 158
170 // Retrieve all resources. 159 // Retrieve all resources.
171 WebVector<WebURL> frames; 160 WebVector<WebURL> frames;
172 WebVector<WebURL> resources; 161 WebVector<WebURL> resources;
173 ASSERT_TRUE(WebPageSerializer::retrieveAllResources( 162 ASSERT_TRUE(WebPageSerializer::retrieveAllResources(
174 webView(), m_supportedSchemes, &resources, &frames)); 163 webView(), m_supportedSchemes, &resources, &frames));
175 164
176 // Tests that all resources from the frame have been retrieved. 165 // Tests that all resources from the frame have been retrieved.
177 EXPECT_EQ(4U, frames.size()); // There should be no duplicates. 166 EXPECT_EQ(4U, frames.size()); // There should be no duplicates.
178 EXPECT_TRUE(webVectorContains(frames, "http://www.test.com")); 167 EXPECT_TRUE(webVectorContains(frames, "http://www.test.com"));
179 EXPECT_TRUE(webVectorContains(frames, "http://www.test.com/simple_iframe.htm l")); 168 EXPECT_TRUE(webVectorContains(frames, "http://www.test.com/simple_iframe.htm l"));
180 EXPECT_TRUE(webVectorContains(frames, "http://www.test.com/object_iframe.htm l")); 169 EXPECT_TRUE(webVectorContains(frames, "http://www.test.com/object_iframe.htm l"));
181 EXPECT_TRUE(webVectorContains(frames, "http://www.test.com/embed_iframe.html ")); 170 EXPECT_TRUE(webVectorContains(frames, "http://www.test.com/embed_iframe.html "));
182 171
183 EXPECT_EQ(5U, resources.size()); // There should be no duplicates. 172 EXPECT_EQ(5U, resources.size()); // There should be no duplicates.
184 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/awesome.png")) ; 173 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/awesome.png")) ;
185 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/innerFrame.png ")); 174 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/innerFrame.png "));
186 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/flash.swf")); 175 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/flash.swf"));
187 // FIXME: for some reason the following resources is missing on one of the b ot 176 // FIXME: for some reason the following resources is missing on one of the b ot
188 // causing the test to fail. Probably a plugin issue. 177 // causing the test to fail. Probably a plugin issue.
189 // EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/music.mid") ); 178 // EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/music.mid") );
190 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/object.png")); 179 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/object.png"));
191 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/embed.png")); 180 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/embed.png"));
192 } 181 }
193 182
194 } 183 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698