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: webkit/glue/multipart_response_delegate_unittest.cc

Issue 2320006: Revert r47599 because it breaks PDF viewing on windows.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 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 | Annotate | Revision Log
« no previous file with comments | « webkit/glue/multipart_response_delegate.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <vector> 5 #include <vector>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" 8 #include "third_party/WebKit/WebKit/chromium/public/WebString.h"
9 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" 9 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
10 #include "third_party/WebKit/WebKit/chromium/public/WebURLLoaderClient.h" 10 #include "third_party/WebKit/WebKit/chromium/public/WebURLLoaderClient.h"
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 230
231 // No end boundary 231 // No end boundary
232 client.Reset(); 232 client.Reset();
233 MultipartResponseDelegate delegate2(&client, NULL, response, "bound"); 233 MultipartResponseDelegate delegate2(&client, NULL, response, "bound");
234 string no_end_boundary( 234 string no_end_boundary(
235 "bound\nContent-type: text/plain\n\n" 235 "bound\nContent-type: text/plain\n\n"
236 "This is a sample response\n"); 236 "This is a sample response\n");
237 delegate2.OnReceivedData(no_end_boundary.c_str(), 237 delegate2.OnReceivedData(no_end_boundary.c_str(),
238 static_cast<int>(no_end_boundary.length())); 238 static_cast<int>(no_end_boundary.length()));
239 EXPECT_EQ(1, client.received_response_); 239 EXPECT_EQ(1, client.received_response_);
240 EXPECT_EQ(1, client.received_data_); 240 EXPECT_EQ(0, client.received_data_);
241 EXPECT_EQ("This is a sample response\n", client.data_); 241 EXPECT_EQ(string(), client.data_);
242 242
243 delegate2.OnCompletedRequest(); 243 delegate2.OnCompletedRequest();
244 EXPECT_EQ(1, client.received_response_); 244 EXPECT_EQ(1, client.received_response_);
245 EXPECT_EQ(1, client.received_data_); 245 EXPECT_EQ(1, client.received_data_);
246 EXPECT_EQ(string("This is a sample response\n"), 246 EXPECT_EQ(string("This is a sample response\n"),
247 client.data_); 247 client.data_);
248 248
249 // Neither boundary 249 // Neither boundary
250 client.Reset(); 250 client.Reset();
251 MultipartResponseDelegate delegate3(&client, NULL, response, "bound"); 251 MultipartResponseDelegate delegate3(&client, NULL, response, "bound");
252 string no_boundaries( 252 string no_boundaries(
253 "Content-type: text/plain\n\n" 253 "Content-type: text/plain\n\n"
254 "This is a sample response\n"); 254 "This is a sample response\n");
255 delegate3.OnReceivedData(no_boundaries.c_str(), 255 delegate3.OnReceivedData(no_boundaries.c_str(),
256 static_cast<int>(no_boundaries.length())); 256 static_cast<int>(no_boundaries.length()));
257 EXPECT_EQ(1, client.received_response_); 257 EXPECT_EQ(1, client.received_response_);
258 EXPECT_EQ(1, client.received_data_); 258 EXPECT_EQ(0, client.received_data_);
259 EXPECT_EQ("This is a sample response\n", client.data_); 259 EXPECT_EQ(string(), client.data_);
260 260
261 delegate3.OnCompletedRequest(); 261 delegate3.OnCompletedRequest();
262 EXPECT_EQ(1, client.received_response_); 262 EXPECT_EQ(1, client.received_response_);
263 EXPECT_EQ(1, client.received_data_); 263 EXPECT_EQ(1, client.received_data_);
264 EXPECT_EQ(string("This is a sample response\n"), 264 EXPECT_EQ(string("This is a sample response\n"),
265 client.data_); 265 client.data_);
266 } 266 }
267 267
268 TEST(MultipartResponseTest, MalformedBoundary) { 268 TEST(MultipartResponseTest, MalformedBoundary) {
269 // Some servers send a boundary that is prefixed by "--". See bug 5786. 269 // Some servers send a boundary that is prefixed by "--". See bug 5786.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 const TestChunk bound1[] = { 348 const TestChunk bound1[] = {
349 { 0, 4, 0, 0, ""}, 349 { 0, 4, 0, 0, ""},
350 { 4, 110, 2, 2, "foofoofoofoofoo" }, 350 { 4, 110, 2, 2, "foofoofoofoofoo" },
351 }; 351 };
352 VariousChunkSizesTest(bound1, arraysize(bound1), 352 VariousChunkSizesTest(bound1, arraysize(bound1),
353 2, 2, "foofoofoofoofoo"); 353 2, 2, "foofoofoofoofoo");
354 354
355 // Break in first and second 355 // Break in first and second
356 const TestChunk bound2[] = { 356 const TestChunk bound2[] = {
357 { 0, 4, 0, 0, ""}, 357 { 0, 4, 0, 0, ""},
358 { 4, 55, 1, 1, "datadatadatadat" }, 358 { 4, 55, 1, 0, "" },
359 { 55, 65, 1, 2, "datadatadatadatadata" }, 359 { 55, 65, 1, 1, "datadatadatadatadata" },
360 { 65, 110, 2, 3, "foofoofoofoofoo" }, 360 { 65, 110, 2, 2, "foofoofoofoofoo" },
361 }; 361 };
362 VariousChunkSizesTest(bound2, arraysize(bound2), 362 VariousChunkSizesTest(bound2, arraysize(bound2),
363 2, 3, "foofoofoofoofoo"); 363 2, 2, "foofoofoofoofoo");
364 364
365 // Break in second only 365 // Break in second only
366 const TestChunk bound3[] = { 366 const TestChunk bound3[] = {
367 { 0, 55, 1, 1, "datadatadatadat" }, 367 { 0, 55, 1, 0, "" },
368 { 55, 110, 2, 3, "foofoofoofoofoo" }, 368 { 55, 110, 2, 2, "foofoofoofoofoo" },
369 }; 369 };
370 VariousChunkSizesTest(bound3, arraysize(bound3), 370 VariousChunkSizesTest(bound3, arraysize(bound3),
371 2, 3, "foofoofoofoofoo"); 371 2, 2, "foofoofoofoofoo");
372 } 372 }
373 373
374 TEST(MultipartResponseTest, BreakInHeaders) { 374 TEST(MultipartResponseTest, BreakInHeaders) {
375 // Break in first header 375 // Break in first header
376 const TestChunk header1[] = { 376 const TestChunk header1[] = {
377 { 0, 10, 0, 0, "" }, 377 { 0, 10, 0, 0, "" },
378 { 10, 35, 1, 0, "" }, 378 { 10, 35, 1, 0, "" },
379 { 35, 110, 2, 2, "foofoofoofoofoo" }, 379 { 35, 110, 2, 2, "foofoofoofoofoo" },
380 }; 380 };
381 VariousChunkSizesTest(header1, arraysize(header1), 381 VariousChunkSizesTest(header1, arraysize(header1),
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 "--bound\n"); 628 "--bound\n");
629 delegate.OnReceivedData(data2.c_str(), static_cast<int>(data2.length())); 629 delegate.OnReceivedData(data2.c_str(), static_cast<int>(data2.length()));
630 EXPECT_EQ(2, 630 EXPECT_EQ(2,
631 client.received_response_); 631 client.received_response_);
632 EXPECT_EQ(string("response data2\n"), 632 EXPECT_EQ(string("response data2\n"),
633 client.data_); 633 client.data_);
634 EXPECT_EQ(true, client.response_.isMultipartPayload()); 634 EXPECT_EQ(true, client.response_.isMultipartPayload());
635 } 635 }
636 636
637 } // namespace 637 } // namespace
OLDNEW
« no previous file with comments | « webkit/glue/multipart_response_delegate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698