OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/url_request/url_request_job.h" | 5 #include "net/url_request/url_request_job.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "net/base/request_priority.h" | 10 #include "net/base/request_priority.h" |
11 #include "net/http/http_transaction_test_util.h" | 11 #include "net/http/http_transaction_test_util.h" |
12 #include "net/test/cert_test_util.h" | 12 #include "net/test/cert_test_util.h" |
| 13 #include "net/test/gtest_util.h" |
13 #include "net/test/test_data_directory.h" | 14 #include "net/test/test_data_directory.h" |
14 #include "net/url_request/url_request.h" | 15 #include "net/url_request/url_request.h" |
15 #include "net/url_request/url_request_test_util.h" | 16 #include "net/url_request/url_request_test_util.h" |
| 17 #include "testing/gmock/include/gmock/gmock.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
17 | 19 |
| 20 using net::test::IsError; |
| 21 using net::test::IsOk; |
| 22 |
18 namespace net { | 23 namespace net { |
19 | 24 |
20 namespace { | 25 namespace { |
21 | 26 |
22 // Data encoded in kBrotliHelloData. | 27 // Data encoded in kBrotliHelloData. |
23 const char kBrotliDecodedHelloData[] = "hello, world!\n"; | 28 const char kBrotliDecodedHelloData[] = "hello, world!\n"; |
24 // kBrotliDecodedHelloData encoded with brotli. | 29 // kBrotliDecodedHelloData encoded with brotli. |
25 const char kBrotliHelloData[] = | 30 const char kBrotliHelloData[] = |
26 "\033\015\0\0\244\024\102\152\020\111\152\072\235\126\034"; | 31 "\033\015\0\0\244\024\102\152\020\111\152\072\235\126\034"; |
27 | 32 |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 req->set_method("GET"); | 505 req->set_method("GET"); |
501 req->Start(); | 506 req->Start(); |
502 | 507 |
503 base::RunLoop().Run(); | 508 base::RunLoop().Run(); |
504 | 509 |
505 // Request failed indicates the request failed before headers were received, | 510 // Request failed indicates the request failed before headers were received, |
506 // so should be false. | 511 // so should be false. |
507 EXPECT_FALSE(d.request_failed()); | 512 EXPECT_FALSE(d.request_failed()); |
508 EXPECT_EQ(200, req->GetResponseCode()); | 513 EXPECT_EQ(200, req->GetResponseCode()); |
509 EXPECT_FALSE(req->status().is_success()); | 514 EXPECT_FALSE(req->status().is_success()); |
510 EXPECT_EQ(ERR_CONTENT_DECODING_FAILED, req->status().error()); | 515 EXPECT_THAT(req->status().error(), IsError(ERR_CONTENT_DECODING_FAILED)); |
511 EXPECT_TRUE(d.data_received().empty()); | 516 EXPECT_TRUE(d.data_received().empty()); |
512 EXPECT_FALSE(network_layer.done_reading_called()); | 517 EXPECT_FALSE(network_layer.done_reading_called()); |
513 | 518 |
514 RemoveMockTransaction(&kInvalidContentGZip_Transaction); | 519 RemoveMockTransaction(&kInvalidContentGZip_Transaction); |
515 } | 520 } |
516 | 521 |
517 // Regression test for crbug.com/553300. | 522 // Regression test for crbug.com/553300. |
518 TEST(URLRequestJob, SlowFilterRead) { | 523 TEST(URLRequestJob, SlowFilterRead) { |
519 MockNetworkLayer network_layer; | 524 MockNetworkLayer network_layer; |
520 TestURLRequestContext context; | 525 TestURLRequestContext context; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 | 560 |
556 EXPECT_FALSE(d.request_failed()); | 561 EXPECT_FALSE(d.request_failed()); |
557 EXPECT_EQ(200, req->GetResponseCode()); | 562 EXPECT_EQ(200, req->GetResponseCode()); |
558 EXPECT_EQ(kBrotliDecodedHelloData, d.data_received()); | 563 EXPECT_EQ(kBrotliDecodedHelloData, d.data_received()); |
559 EXPECT_TRUE(network_layer.done_reading_called()); | 564 EXPECT_TRUE(network_layer.done_reading_called()); |
560 | 565 |
561 RemoveMockTransaction(&kBrotli_Slow_Transaction); | 566 RemoveMockTransaction(&kBrotli_Slow_Transaction); |
562 } | 567 } |
563 | 568 |
564 } // namespace net | 569 } // namespace net |
OLD | NEW |