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

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

Issue 1178483002: Merge page serializers [5/12] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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
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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 EXPECT_TRUE(resourceVectorContains(resources, m_baseURL + "red_background.pn g", "image/png")); 231 EXPECT_TRUE(resourceVectorContains(resources, m_baseURL + "red_background.pn g", "image/png"));
232 EXPECT_TRUE(resourceVectorContains(resources, m_baseURL + "orange_background .png", "image/png")); 232 EXPECT_TRUE(resourceVectorContains(resources, m_baseURL + "orange_background .png", "image/png"));
233 EXPECT_TRUE(resourceVectorContains(resources, m_baseURL + "yellow_background .png", "image/png")); 233 EXPECT_TRUE(resourceVectorContains(resources, m_baseURL + "yellow_background .png", "image/png"));
234 EXPECT_TRUE(resourceVectorContains(resources, m_baseURL + "green_background. png", "image/png")); 234 EXPECT_TRUE(resourceVectorContains(resources, m_baseURL + "green_background. png", "image/png"));
235 EXPECT_TRUE(resourceVectorContains(resources, m_baseURL + "blue_background.p ng", "image/png")); 235 EXPECT_TRUE(resourceVectorContains(resources, m_baseURL + "blue_background.p ng", "image/png"));
236 EXPECT_TRUE(resourceVectorContains(resources, m_baseURL + "purple_background .png", "image/png")); 236 EXPECT_TRUE(resourceVectorContains(resources, m_baseURL + "purple_background .png", "image/png"));
237 EXPECT_TRUE(resourceVectorContains(resources, m_baseURL + "ul-dot.png", "ima ge/png")); 237 EXPECT_TRUE(resourceVectorContains(resources, m_baseURL + "ul-dot.png", "ima ge/png"));
238 EXPECT_TRUE(resourceVectorContains(resources, m_baseURL + "ol-dot.png", "ima ge/png")); 238 EXPECT_TRUE(resourceVectorContains(resources, m_baseURL + "ol-dot.png", "ima ge/png"));
239 } 239 }
240 240
241 TEST_F(WebPageNewSerializeTest, SerializeXMLHasRightDeclaration)
242 {
243 WebURL topFrameURL = toTestURL("simple.xhtml");
244 registerMockedURLLoad(topFrameURL, WebString::fromUTF8("simple.xhtml"), WebS tring::fromUTF8("pageserializer/"), xhtmlMimeType());
245
246 loadURLInTopFrame(topFrameURL);
247
248 WebVector<WebPageSerializer::Resource> resources;
249 WebPageSerializer::serialize(webView(), &resources);
250 ASSERT_FALSE(resources.isEmpty());
251
252 // We expect only one resource, the XML.
253 ASSERT_EQ(1U, resources.size());
254 std::string xml = std::string(resources[0].data.data());
255
256 // We should have one and only one instance of the XML declaration.
257 size_t pos = xml.find("<?xml version=");
258 ASSERT_TRUE(pos != std::string::npos);
259
260 pos = xml.find("<?xml version=", pos + 1);
261 ASSERT_TRUE(pos == std::string::npos);
262 }
263
264 TEST_F(WebPageNewSerializeTest, FAILS_TestMHTMLEncoding) 241 TEST_F(WebPageNewSerializeTest, FAILS_TestMHTMLEncoding)
265 { 242 {
266 // Load a page with some CSS and some images. 243 // Load a page with some CSS and some images.
267 WebURL topFrameURL = setUpCSSTestPage(); 244 WebURL topFrameURL = setUpCSSTestPage();
268 loadURLInTopFrame(topFrameURL); 245 loadURLInTopFrame(topFrameURL);
269 246
270 WebCString mhtmlData = WebPageSerializer::serializeToMHTML(webView()); 247 WebCString mhtmlData = WebPageSerializer::serializeToMHTML(webView());
271 ASSERT_FALSE(mhtmlData.isEmpty()); 248 ASSERT_FALSE(mhtmlData.isEmpty());
272 249
273 // Read the MHTML data line per line and do some pseudo-parsing to make sure the right encoding is used for the different sections. 250 // Read the MHTML data line per line and do some pseudo-parsing to make sure the right encoding is used for the different sections.
(...skipping 20 matching lines...) Expand all
294 ASSERT_TRUE(expectedEncoding); 271 ASSERT_TRUE(expectedEncoding);
295 EXPECT_TRUE(line.find(expectedEncoding) != std::string::npos); 272 EXPECT_TRUE(line.find(expectedEncoding) != std::string::npos);
296 expectedEncoding = 0; 273 expectedEncoding = 0;
297 sectionCheckedCount++; 274 sectionCheckedCount++;
298 } 275 }
299 } 276 }
300 EXPECT_EQ(12, sectionCheckedCount); 277 EXPECT_EQ(12, sectionCheckedCount);
301 } 278 }
302 279
303 } 280 }
OLDNEW
« no previous file with comments | « Source/web/tests/PageSerializerTest.cpp ('k') | Source/web/tests/data/pageserializer/simple.xhtml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698