OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/child/web_url_loader_impl.h" | 5 #include "content/child/web_url_loader_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <utility> | 10 #include <utility> |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 EXPECT_FALSE(client()->did_receive_response()); | 313 EXPECT_FALSE(client()->did_receive_response()); |
314 peer()->OnReceivedResponse(content::ResourceResponseInfo()); | 314 peer()->OnReceivedResponse(content::ResourceResponseInfo()); |
315 EXPECT_TRUE(client()->did_receive_response()); | 315 EXPECT_TRUE(client()->did_receive_response()); |
316 } | 316 } |
317 | 317 |
318 // Assumes it is called only once for a request. | 318 // Assumes it is called only once for a request. |
319 void DoReceiveData() { | 319 void DoReceiveData() { |
320 EXPECT_EQ("", client()->received_data()); | 320 EXPECT_EQ("", client()->received_data()); |
321 auto size = strlen(kTestData); | 321 auto size = strlen(kTestData); |
322 peer()->OnReceivedData( | 322 peer()->OnReceivedData( |
323 base::WrapUnique(new FixedReceivedData(kTestData, size, size, size))); | 323 base::MakeUnique<FixedReceivedData>(kTestData, size, size, size)); |
324 EXPECT_EQ(kTestData, client()->received_data()); | 324 EXPECT_EQ(kTestData, client()->received_data()); |
325 } | 325 } |
326 | 326 |
327 void DoCompleteRequest() { | 327 void DoCompleteRequest() { |
328 EXPECT_FALSE(client()->did_finish()); | 328 EXPECT_FALSE(client()->did_finish()); |
329 peer()->OnCompletedRequest(net::OK, false, false, "", base::TimeTicks(), | 329 peer()->OnCompletedRequest(net::OK, false, false, "", base::TimeTicks(), |
330 strlen(kTestData)); | 330 strlen(kTestData)); |
331 EXPECT_TRUE(client()->did_finish()); | 331 EXPECT_TRUE(client()->did_finish()); |
332 // There should be no error. | 332 // There should be no error. |
333 EXPECT_EQ(net::OK, client()->error().reason); | 333 EXPECT_EQ(net::OK, client()->error().reason); |
(...skipping 12 matching lines...) Expand all Loading... |
346 void DoReceiveResponseFtp() { | 346 void DoReceiveResponseFtp() { |
347 EXPECT_FALSE(client()->did_receive_response()); | 347 EXPECT_FALSE(client()->did_receive_response()); |
348 content::ResourceResponseInfo response_info; | 348 content::ResourceResponseInfo response_info; |
349 response_info.mime_type = kFtpDirMimeType; | 349 response_info.mime_type = kFtpDirMimeType; |
350 peer()->OnReceivedResponse(response_info); | 350 peer()->OnReceivedResponse(response_info); |
351 EXPECT_TRUE(client()->did_receive_response()); | 351 EXPECT_TRUE(client()->did_receive_response()); |
352 } | 352 } |
353 | 353 |
354 void DoReceiveDataFtp() { | 354 void DoReceiveDataFtp() { |
355 auto size = strlen(kFtpDirListing); | 355 auto size = strlen(kFtpDirListing); |
356 peer()->OnReceivedData(base::WrapUnique( | 356 peer()->OnReceivedData( |
357 new FixedReceivedData(kFtpDirListing, size, size, size))); | 357 base::MakeUnique<FixedReceivedData>(kFtpDirListing, size, size, size)); |
358 // The FTP delegate should modify the data the client sees. | 358 // The FTP delegate should modify the data the client sees. |
359 EXPECT_NE(kFtpDirListing, client()->received_data()); | 359 EXPECT_NE(kFtpDirListing, client()->received_data()); |
360 } | 360 } |
361 | 361 |
362 TestWebURLLoaderClient* client() { return client_.get(); } | 362 TestWebURLLoaderClient* client() { return client_.get(); } |
363 TestResourceDispatcher* dispatcher() { return &dispatcher_; } | 363 TestResourceDispatcher* dispatcher() { return &dispatcher_; } |
364 RequestPeer* peer() { return dispatcher()->peer(); } | 364 RequestPeer* peer() { return dispatcher()->peer(); } |
365 base::MessageLoop* message_loop() { return &message_loop_; } | 365 base::MessageLoop* message_loop() { return &message_loop_; } |
366 | 366 |
367 private: | 367 private: |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 encoded_data_length); | 698 encoded_data_length); |
699 | 699 |
700 EXPECT_EQ(kEncodedBodyLength, response.encodedBodyLength()); | 700 EXPECT_EQ(kEncodedBodyLength, response.encodedBodyLength()); |
701 EXPECT_EQ(kEncodedDataLength, encoded_data_length); | 701 EXPECT_EQ(kEncodedDataLength, encoded_data_length); |
702 int expected_decoded_body_length = strlen(kBodyData); | 702 int expected_decoded_body_length = strlen(kBodyData); |
703 EXPECT_EQ(expected_decoded_body_length, response.decodedBodyLength()); | 703 EXPECT_EQ(expected_decoded_body_length, response.decodedBodyLength()); |
704 } | 704 } |
705 | 705 |
706 } // namespace | 706 } // namespace |
707 } // namespace content | 707 } // namespace content |
OLD | NEW |