OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/browser/loader/url_loader_factory_impl.h" | 5 #include "content/browser/loader/url_loader_factory_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 ASSERT_TRUE(url_request); | 175 ASSERT_TRUE(url_request); |
176 ResourceRequestInfoImpl* request_info = | 176 ResourceRequestInfoImpl* request_info = |
177 ResourceRequestInfoImpl::ForRequest(url_request); | 177 ResourceRequestInfoImpl::ForRequest(url_request); |
178 ASSERT_TRUE(request_info); | 178 ASSERT_TRUE(request_info); |
179 EXPECT_EQ(kChildId, request_info->GetChildID()); | 179 EXPECT_EQ(kChildId, request_info->GetChildID()); |
180 EXPECT_EQ(kRoutingId, request_info->GetRouteID()); | 180 EXPECT_EQ(kRoutingId, request_info->GetRouteID()); |
181 EXPECT_EQ(kRequestId, request_info->GetRequestID()); | 181 EXPECT_EQ(kRequestId, request_info->GetRequestID()); |
182 | 182 |
183 ASSERT_FALSE(client.has_received_completion()); | 183 ASSERT_FALSE(client.has_received_completion()); |
184 | 184 |
185 client.RunUntilResponseBodyArrived(); | 185 client.RunUntilComplete(); |
186 ASSERT_TRUE(client.response_body().is_valid()); | 186 ASSERT_TRUE(client.response_body().is_valid()); |
187 ASSERT_FALSE(client.has_received_completion()); | 187 ASSERT_TRUE(client.has_received_completion()); |
188 | |
189 client.RunUntilComplete(); | |
190 | 188 |
191 EXPECT_EQ(200, client.response_head().headers->response_code()); | 189 EXPECT_EQ(200, client.response_head().headers->response_code()); |
192 std::string content_type; | 190 std::string content_type; |
193 client.response_head().headers->GetNormalizedHeader("content-type", | 191 client.response_head().headers->GetNormalizedHeader("content-type", |
194 &content_type); | 192 &content_type); |
195 EXPECT_EQ("text/html", content_type); | 193 EXPECT_EQ("text/html", content_type); |
196 EXPECT_EQ(0, client.completion_status().error_code); | 194 EXPECT_EQ(0, client.completion_status().error_code); |
197 | 195 |
198 std::string contents; | 196 std::string contents; |
199 while (true) { | 197 while (true) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 // must be blob scheme. | 264 // must be blob scheme. |
267 request.resource_type = RESOURCE_TYPE_XHR; | 265 request.resource_type = RESOURCE_TYPE_XHR; |
268 // Need to set |request_initiator| for non main frame type request. | 266 // Need to set |request_initiator| for non main frame type request. |
269 request.request_initiator = url::Origin(); | 267 request.request_initiator = url::Origin(); |
270 factory_->CreateLoaderAndStart( | 268 factory_->CreateLoaderAndStart( |
271 mojo::MakeRequest(&loader, factory_.associated_group()), 2, 1, request, | 269 mojo::MakeRequest(&loader, factory_.associated_group()), 2, 1, request, |
272 client.CreateRemoteAssociatedPtrInfo(factory_.associated_group())); | 270 client.CreateRemoteAssociatedPtrInfo(factory_.associated_group())); |
273 | 271 |
274 client.RunUntilComplete(); | 272 client.RunUntilComplete(); |
275 ASSERT_FALSE(client.has_received_response()); | 273 ASSERT_FALSE(client.has_received_response()); |
276 ASSERT_TRUE(client.response_body().is_valid()); | 274 ASSERT_FALSE(client.response_body().is_valid()); |
277 | 275 |
278 EXPECT_EQ(net::ERR_TIMED_OUT, client.completion_status().error_code); | 276 EXPECT_EQ(net::ERR_TIMED_OUT, client.completion_status().error_code); |
279 EXPECT_GT(client.completion_status().encoded_data_length, 0); | 277 EXPECT_GT(client.completion_status().encoded_data_length, 0); |
280 EXPECT_EQ(0, client.completion_status().encoded_body_length); | 278 EXPECT_EQ(0, client.completion_status().encoded_body_length); |
281 } | 279 } |
282 | 280 |
283 // This test tests a case where resource loading is cancelled before started. | 281 // This test tests a case where resource loading is cancelled before started. |
284 TEST_P(URLLoaderFactoryImplTest, InvalidURL) { | 282 TEST_P(URLLoaderFactoryImplTest, InvalidURL) { |
285 mojom::URLLoaderAssociatedPtr loader; | 283 mojom::URLLoaderAssociatedPtr loader; |
286 ResourceRequest request; | 284 ResourceRequest request; |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 ASSERT_FALSE(rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId))); | 557 ASSERT_FALSE(rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId))); |
560 } | 558 } |
561 | 559 |
562 INSTANTIATE_TEST_CASE_P(URLLoaderFactoryImplTest, | 560 INSTANTIATE_TEST_CASE_P(URLLoaderFactoryImplTest, |
563 URLLoaderFactoryImplTest, | 561 URLLoaderFactoryImplTest, |
564 ::testing::Values(128, 32 * 1024)); | 562 ::testing::Values(128, 32 * 1024)); |
565 | 563 |
566 } // namespace | 564 } // namespace |
567 | 565 |
568 } // namespace content | 566 } // namespace content |
OLD | NEW |