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

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

Issue 1167413004: Merge page serializers [4/12] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix nits Created 5 years, 6 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
« no previous file with comments | « Source/core/page/PageSerializer.cpp ('k') | Source/web/tests/WebPageNewSerializerTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013, Opera Software ASA. All rights reserved. 2 * Copyright (c) 2013, Opera Software ASA. 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 virtual void TearDown() 74 virtual void TearDown()
75 { 75 {
76 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); 76 Platform::current()->unitTestSupport()->unregisterAllMockedURLs();
77 } 77 }
78 78
79 void setBaseFolder(const char* folder) 79 void setBaseFolder(const char* folder)
80 { 80 {
81 m_folder = WebString::fromUTF8(folder); 81 m_folder = WebString::fromUTF8(folder);
82 } 82 }
83 83
84 void registerURL(const char* url, const char* file, const char* mimeType)
85 {
86 registerMockedURLLoad(KURL(m_baseUrl, url), WebString::fromUTF8(file), m _folder, WebString::fromUTF8(mimeType));
87 }
88
84 void registerURL(const char* file, const char* mimeType) 89 void registerURL(const char* file, const char* mimeType)
85 { 90 {
86 registerMockedURLLoad(KURL(m_baseUrl, file), WebString::fromUTF8(file), m_folder, WebString::fromUTF8(mimeType)); 91 registerURL(file, file, mimeType);
87 } 92 }
88 93
89 void registerErrorURL(const char* file, int statusCode) 94 void registerErrorURL(const char* file, int statusCode)
90 { 95 {
91 WebURLError error; 96 WebURLError error;
92 error.reason = 0xdead + statusCode; 97 error.reason = 0xdead + statusCode;
93 error.domain = "PageSerializerTest"; 98 error.domain = "PageSerializerTest";
94 99
95 WebURLResponse response; 100 WebURLResponse response;
96 response.initialize(); 101 response.initialize();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 settings->setLoadsImagesAutomatically(true); 151 settings->setLoadsImagesAutomatically(true);
147 settings->setJavaScriptEnabled(true); 152 settings->setJavaScriptEnabled(true);
148 } 153 }
149 154
150 FrameTestHelpers::WebViewHelper m_helper; 155 FrameTestHelpers::WebViewHelper m_helper;
151 WebString m_folder; 156 WebString m_folder;
152 KURL m_baseUrl; 157 KURL m_baseUrl;
153 Vector<SerializedResource> m_resources; 158 Vector<SerializedResource> m_resources;
154 }; 159 };
155 160
156
157 TEST_F(PageSerializerTest, InputImage) 161 TEST_F(PageSerializerTest, InputImage)
158 { 162 {
159 setBaseFolder("pageserializer/input-image/"); 163 setBaseFolder("pageserializer/input-image/");
160 164
161 registerURL("input-image.html", "text/html"); 165 registerURL("input-image.html", "text/html");
162 registerURL("button.png", "image/png"); 166 registerURL("button.png", "image/png");
163 registerErrorURL("non-existing-button.png", 404); 167 registerErrorURL("non-existing-button.png", 404);
164 168
165 serialize("input-image.html"); 169 serialize("input-image.html");
166 170
167 EXPECT_TRUE(isSerialized("button.png", "image/png")); 171 EXPECT_TRUE(isSerialized("button.png", "image/png"));
168 EXPECT_FALSE(isSerialized("non-existing-button.png", "image/png")); 172 EXPECT_FALSE(isSerialized("non-existing-button.png", "image/png"));
169 } 173 }
170 174
175 TEST_F(PageSerializerTest, Frames)
176 {
177 setBaseFolder("pageserializer/frames/");
178
179 registerURL("simple_frames.html", "text/html");
180 registerURL("simple_frames_top.html", "text/html");
181 registerURL("simple_frames_1.html", "text/html");
182 registerURL("simple_frames_3.html", "text/html");
183
184 registerURL("frame_1.png", "image.png", "image/png");
185 registerURL("frame_2.png", "image.png", "image/png");
186 registerURL("frame_3.png", "image.png", "image/png");
187 registerURL("frame_4.png", "image.png", "image/png");
188
189 serialize("simple_frames.html");
190
191 EXPECT_EQ(8U, getResources().size());
192
193 EXPECT_TRUE(isSerialized("simple_frames.html", "text/html"));
194 EXPECT_TRUE(isSerialized("simple_frames_top.html", "text/html"));
195 EXPECT_TRUE(isSerialized("simple_frames_1.html", "text/html"));
196 EXPECT_TRUE(isSerialized("simple_frames_3.html", "text/html"));
197
198 EXPECT_TRUE(isSerialized("frame_1.png", "image/png"));
199 EXPECT_TRUE(isSerialized("frame_2.png", "image/png"));
200 EXPECT_TRUE(isSerialized("frame_3.png", "image/png"));
201 EXPECT_TRUE(isSerialized("frame_4.png", "image/png"));
202 }
203
204 TEST_F(PageSerializerTest, IFrames)
205 {
206 setBaseFolder("pageserializer/frames/");
207
208 registerURL("top_frame.html", "text/html");
209 registerURL("simple_iframe.html", "text/html");
210 registerURL("object_iframe.html", "text/html");
211 registerURL("embed_iframe.html", "text/html");
212
213 registerURL("top.png", "image.png", "image/png");
214 registerURL("simple.png", "image.png", "image/png");
215 registerURL("object.png", "image.png", "image/png");
216 registerURL("embed.png", "image.png", "image/png");
217
218 serialize("top_frame.html");
219
220 EXPECT_EQ(8U, getResources().size());
221
222 EXPECT_TRUE(isSerialized("top_frame.html", "text/html"));
223 EXPECT_TRUE(isSerialized("simple_iframe.html", "text/html"));
224 EXPECT_TRUE(isSerialized("object_iframe.html", "text/html"));
225 EXPECT_TRUE(isSerialized("embed_iframe.html", "text/html"));
226
227 EXPECT_TRUE(isSerialized("top.png", "image/png"));
228 EXPECT_TRUE(isSerialized("simple.png", "image/png"));
229 EXPECT_TRUE(isSerialized("object.png", "image/png"));
230 EXPECT_TRUE(isSerialized("embed.png", "image/png"));
231 }
232
233 // Tests that when serializing a page with blank frames these are reported with their resources.
234 TEST_F(PageSerializerTest, BlankFrames)
235 {
236 setBaseFolder("pageserializer/frames/");
237
238 registerURL("blank_frames.html", "text/html");
239 registerURL("red_background.png", "image.png", "image/png");
240 registerURL("orange_background.png", "image.png", "image/png");
241 registerURL("blue_background.png", "image.png", "image/png");
242
243 serialize("blank_frames.html");
244
245 EXPECT_EQ(7U, getResources().size());
246
247 EXPECT_TRUE(isSerialized("http://www.test.com/red_background.png", "image/pn g"));
248 EXPECT_TRUE(isSerialized("http://www.test.com/orange_background.png", "image /png"));
249 EXPECT_TRUE(isSerialized("http://www.test.com/blue_background.png", "image/p ng"));
250 // The blank frames should have got a magic URL.
251 EXPECT_TRUE(isSerialized("wyciwyg://frame/0", "text/html"));
252 EXPECT_TRUE(isSerialized("wyciwyg://frame/1", "text/html"));
253 EXPECT_TRUE(isSerialized("wyciwyg://frame/2", "text/html"));
254 }
255
171 TEST_F(PageSerializerTest, CSSImport) 256 TEST_F(PageSerializerTest, CSSImport)
172 { 257 {
173 setBaseFolder("pageserializer/css/"); 258 setBaseFolder("pageserializer/css/");
174 259
175 registerURL("import.html", "text/html"); 260 registerURL("import.html", "text/html");
176 registerURL("import/base.css", "text/css"); 261 registerURL("import/base.css", "text/css");
177 registerURL("import/relative/red-background.css", "text/css"); 262 registerURL("import/relative/red-background.css", "text/css");
178 registerURL("import/absolute/green-header.css", "text/css"); 263 registerURL("import/absolute/green-header.css", "text/css");
179 264
180 serialize("import.html"); 265 serialize("import.html");
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 registerURL("namespace_element.html", "text/html"); 366 registerURL("namespace_element.html", "text/html");
282 367
283 serialize("namespace_element.html"); 368 serialize("namespace_element.html");
284 369
285 EXPECT_EQ(1U, getResources().size()); 370 EXPECT_EQ(1U, getResources().size());
286 EXPECT_TRUE(isSerialized("namespace_element.html", "text/html")); 371 EXPECT_TRUE(isSerialized("namespace_element.html", "text/html"));
287 EXPECT_GT(getSerializedData("namespace_element.html", "text/html").length(), 0U); 372 EXPECT_GT(getSerializedData("namespace_element.html", "text/html").length(), 0U);
288 } 373 }
289 374
290 } 375 }
OLDNEW
« no previous file with comments | « Source/core/page/PageSerializer.cpp ('k') | Source/web/tests/WebPageNewSerializerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698