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

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

Issue 1165093002: Merge page serializers [1/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
« no previous file with comments | « no previous file | 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 11 matching lines...) Expand all
22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28 * OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/page/PageSerializer.h"
32 33
33 #include "bindings/core/v8/V8Binding.h" 34 #include "bindings/core/v8/V8Binding.h"
34 #include "bindings/core/v8/V8BindingForTesting.h" 35 #include "bindings/core/v8/V8BindingForTesting.h"
35 #include "core/page/Page.h" 36 #include "core/page/Page.h"
36 #include "core/page/PageSerializer.h"
37 #include "platform/SerializedResource.h" 37 #include "platform/SerializedResource.h"
38 #include "platform/testing/URLTestHelpers.h" 38 #include "platform/testing/URLTestHelpers.h"
39 #include "public/platform/Platform.h" 39 #include "public/platform/Platform.h"
40 #include "public/platform/WebString.h" 40 #include "public/platform/WebString.h"
41 #include "public/platform/WebThread.h" 41 #include "public/platform/WebThread.h"
42 #include "public/platform/WebURL.h" 42 #include "public/platform/WebURL.h"
43 #include "public/platform/WebURLRequest.h" 43 #include "public/platform/WebURLRequest.h"
44 #include "public/platform/WebURLResponse.h" 44 #include "public/platform/WebURLResponse.h"
45 #include "public/platform/WebUnitTestSupport.h" 45 #include "public/platform/WebUnitTestSupport.h"
46 #include "public/web/WebSettings.h" 46 #include "public/web/WebSettings.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 132 }
133 133
134 String getSerializedData(const char* url, const char* mimeType = 0) 134 String getSerializedData(const char* url, const char* mimeType = 0)
135 { 135 {
136 const SerializedResource* resource = getResource(url, mimeType); 136 const SerializedResource* resource = getResource(url, mimeType);
137 if (resource) 137 if (resource)
138 return String(resource->data->data(), resource->data->size()); 138 return String(resource->data->data(), resource->data->size());
139 return String(); 139 return String();
140 } 140 }
141 141
142 // For debugging
143 void printResources()
philipj_slow 2015/06/05 11:59:16 I don't know, I'd probably leave this out. If you
Tiger (Sony Mobile) 2015/06/05 13:47:50 Agreed, it is not that important.
144 {
145 printf("Printing resources (%zu resources in total)\n", m_resources.size ());
146 for (size_t i = 0; i < m_resources.size(); ++i) {
147 printf("%zu. '%s', '%s'\n", i, m_resources[i].url.string().utf8().da ta(),
148 m_resources[i].mimeType.utf8().data());
149 }
150 }
151
142 private: 152 private:
143 static void configureSettings(WebSettings* settings) 153 static void configureSettings(WebSettings* settings)
144 { 154 {
145 settings->setImagesEnabled(true); 155 settings->setImagesEnabled(true);
146 settings->setLoadsImagesAutomatically(true); 156 settings->setLoadsImagesAutomatically(true);
147 settings->setJavaScriptEnabled(true); 157 settings->setJavaScriptEnabled(true);
148 } 158 }
149 159
150 FrameTestHelpers::WebViewHelper m_helper; 160 FrameTestHelpers::WebViewHelper m_helper;
151 WebString m_folder; 161 WebString m_folder;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 setBaseFolder("pageserializer/font/"); 223 setBaseFolder("pageserializer/font/");
214 224
215 registerURL("font.html", "text/html"); 225 registerURL("font.html", "text/html");
216 registerURL("font.ttf", "application/octet-stream"); 226 registerURL("font.ttf", "application/octet-stream");
217 227
218 serialize("font.html"); 228 serialize("font.html");
219 229
220 EXPECT_TRUE(isSerialized("font.ttf", "application/octet-stream")); 230 EXPECT_TRUE(isSerialized("font.ttf", "application/octet-stream"));
221 } 231 }
222 232
233 TEST_F(PageSerializerTest, DontIncludeErrorImage)
234 {
235 setBaseFolder("pageserializer/image/");
236
237 registerURL("page_with_img_error.html", "text/html");
238 registerURL("error_image.png", "image/png");
239
240 serialize("page_with_img_error.html");
241
242 EXPECT_EQ(1U, getResources().size());
243 EXPECT_TRUE(isSerialized("page_with_img_error.html", "text/html"));
244 EXPECT_FALSE(isSerialized("error_image.png", "image/png"));
223 } 245 }
246
247 }
OLDNEW
« no previous file with comments | « no previous file | Source/web/tests/WebPageNewSerializerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698