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

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

Issue 1177693002: Merge page serializers [6/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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 198
199 FrameTestHelpers::WebViewHelper m_helper; 199 FrameTestHelpers::WebViewHelper m_helper;
200 200
201 WebString m_htmlMimeType; 201 WebString m_htmlMimeType;
202 WebString m_xhtmlMimeType; 202 WebString m_xhtmlMimeType;
203 WebString m_cssMimeType; 203 WebString m_cssMimeType;
204 WebString m_pngMimeType; 204 WebString m_pngMimeType;
205 WebString m_svgMimeType; 205 WebString m_svgMimeType;
206 }; 206 };
207 207
208 // Test that when serializing a page, all CSS resources are reported, including url()'s
209 // and imports and links. Note that we don't test the resources contents, we onl y make sure
210 // they are all reported with the right mime type and that they contain some dat a.
211 TEST_F(WebPageNewSerializeTest, FAILS_CSSResources)
212 {
213 // Register the mocked frame and load it.
214 WebURL topFrameURL = setUpCSSTestPage();
215 loadURLInTopFrame(topFrameURL);
216
217 WebVector<WebPageSerializer::Resource> resources;
218 WebPageSerializer::serialize(webView(), &resources);
219 ASSERT_FALSE(resources.isEmpty());
220
221 // The first resource should be the main-frame.
222 const WebPageSerializer::Resource& resource = resources[0];
223 EXPECT_TRUE(resource.url == WebURL(toKURL(m_baseURL)));
224 EXPECT_EQ(0, resource.mimeType.compare(WebCString("text/html")));
225 EXPECT_FALSE(resource.data.isEmpty());
226
227 EXPECT_EQ(12U, resources.size()); // There should be no duplicates.
228 EXPECT_TRUE(resourceVectorContains(resources, m_baseURL + "link_styles.css", "text/css"));
229 EXPECT_TRUE(resourceVectorContains(resources, m_baseURL + "import_styles.css ", "text/css"));
230 EXPECT_TRUE(resourceVectorContains(resources, m_baseURL + "import_style_from _link.css", "text/css"));
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"));
233 EXPECT_TRUE(resourceVectorContains(resources, m_baseURL + "yellow_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"));
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"));
238 EXPECT_TRUE(resourceVectorContains(resources, m_baseURL + "ol-dot.png", "ima ge/png"));
239 }
240
241 TEST_F(WebPageNewSerializeTest, FAILS_TestMHTMLEncoding) 208 TEST_F(WebPageNewSerializeTest, FAILS_TestMHTMLEncoding)
242 { 209 {
243 // Load a page with some CSS and some images. 210 // Load a page with some CSS and some images.
244 WebURL topFrameURL = setUpCSSTestPage(); 211 WebURL topFrameURL = setUpCSSTestPage();
245 loadURLInTopFrame(topFrameURL); 212 loadURLInTopFrame(topFrameURL);
246 213
247 WebCString mhtmlData = WebPageSerializer::serializeToMHTML(webView()); 214 WebCString mhtmlData = WebPageSerializer::serializeToMHTML(webView());
248 ASSERT_FALSE(mhtmlData.isEmpty()); 215 ASSERT_FALSE(mhtmlData.isEmpty());
249 216
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. 217 // 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
271 ASSERT_TRUE(expectedEncoding); 238 ASSERT_TRUE(expectedEncoding);
272 EXPECT_TRUE(line.find(expectedEncoding) != std::string::npos); 239 EXPECT_TRUE(line.find(expectedEncoding) != std::string::npos);
273 expectedEncoding = 0; 240 expectedEncoding = 0;
274 sectionCheckedCount++; 241 sectionCheckedCount++;
275 } 242 }
276 } 243 }
277 EXPECT_EQ(12, sectionCheckedCount); 244 EXPECT_EQ(12, sectionCheckedCount);
278 } 245 }
279 246
280 } 247 }
OLDNEW
« no previous file with comments | « Source/web/tests/PageSerializerTest.cpp ('k') | Source/web/tests/data/pageserializer/css/css_test_page.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698