| 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 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 WebURLLoaderImpl::PopulateURLResponse(url, info, &response, true); | 679 WebURLLoaderImpl::PopulateURLResponse(url, info, &response, true); |
| 680 EXPECT_EQ(test.expected, response.remoteIPAddress().utf8()); | 680 EXPECT_EQ(test.expected, response.remoteIPAddress().utf8()); |
| 681 }; | 681 }; |
| 682 } | 682 } |
| 683 | 683 |
| 684 // Verifies that the lengths used by the PerformanceResourceTiming API are | 684 // Verifies that the lengths used by the PerformanceResourceTiming API are |
| 685 // correctly assigned for sync XHR. | 685 // correctly assigned for sync XHR. |
| 686 TEST_F(WebURLLoaderImplTest, SyncLengths) { | 686 TEST_F(WebURLLoaderImplTest, SyncLengths) { |
| 687 static const char kBodyData[] = "Today is Thursday"; | 687 static const char kBodyData[] = "Today is Thursday"; |
| 688 const int kEncodedBodyLength = 30; | 688 const int kEncodedBodyLength = 30; |
| 689 const int kEncodedDataLength = 130; |
| 689 const GURL url(kTestURL); | 690 const GURL url(kTestURL); |
| 690 blink::WebURLRequest request(url); | 691 blink::WebURLRequest request(url); |
| 691 | 692 |
| 692 // Prepare a mock response | 693 // Prepare a mock response |
| 693 SyncLoadResponse sync_load_response; | 694 SyncLoadResponse sync_load_response; |
| 694 sync_load_response.error_code = net::OK; | 695 sync_load_response.error_code = net::OK; |
| 695 sync_load_response.url = url; | 696 sync_load_response.url = url; |
| 696 sync_load_response.data = kBodyData; | 697 sync_load_response.data = kBodyData; |
| 697 ASSERT_EQ(17u, sync_load_response.data.size()); | 698 ASSERT_EQ(17u, sync_load_response.data.size()); |
| 698 sync_load_response.encoded_body_length = kEncodedBodyLength; | 699 sync_load_response.encoded_body_length = kEncodedBodyLength; |
| 700 sync_load_response.encoded_data_length = kEncodedDataLength; |
| 699 dispatcher()->set_sync_load_response(sync_load_response); | 701 dispatcher()->set_sync_load_response(sync_load_response); |
| 700 | 702 |
| 701 blink::WebURLResponse response; | 703 blink::WebURLResponse response; |
| 702 blink::WebURLError error; | 704 blink::WebURLError error; |
| 703 blink::WebData data; | 705 blink::WebData data; |
| 704 client()->loader()->loadSynchronously(request, response, error, data); | 706 int64_t encoded_data_length = 0; |
| 707 client()->loader()->loadSynchronously(request, response, error, data, |
| 708 encoded_data_length); |
| 705 | 709 |
| 706 EXPECT_EQ(kEncodedBodyLength, response.encodedBodyLength()); | 710 EXPECT_EQ(kEncodedBodyLength, response.encodedBodyLength()); |
| 711 EXPECT_EQ(kEncodedDataLength, encoded_data_length); |
| 707 int expected_decoded_body_length = strlen(kBodyData); | 712 int expected_decoded_body_length = strlen(kBodyData); |
| 708 EXPECT_EQ(expected_decoded_body_length, response.decodedBodyLength()); | 713 EXPECT_EQ(expected_decoded_body_length, response.decodedBodyLength()); |
| 709 } | 714 } |
| 710 | 715 |
| 711 } // namespace | 716 } // namespace |
| 712 } // namespace content | 717 } // namespace content |
| OLD | NEW |