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 <memory> | 5 #include <memory> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 7934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7945 std::unique_ptr<URLRequest> req( | 7945 std::unique_ptr<URLRequest> req( |
7946 default_context_.CreateRequest(test_url, DEFAULT_PRIORITY, &d)); | 7946 default_context_.CreateRequest(test_url, DEFAULT_PRIORITY, &d)); |
7947 req->SetLoadFlags(LOAD_ONLY_FROM_CACHE); | 7947 req->SetLoadFlags(LOAD_ONLY_FROM_CACHE); |
7948 | 7948 |
7949 req->Start(); | 7949 req->Start(); |
7950 base::RunLoop().Run(); | 7950 base::RunLoop().Run(); |
7951 | 7951 |
7952 EXPECT_FALSE(req->response_info().network_accessed); | 7952 EXPECT_FALSE(req->response_info().network_accessed); |
7953 } | 7953 } |
7954 | 7954 |
7955 // Test that a single job with a throttled priority completes | 7955 // Test that a single job with a THROTTLED priority completes |
7956 // correctly in the absence of contention. | 7956 // correctly in the absence of contention. |
7957 TEST_F(URLRequestTestHTTP, ThrottledPriority) { | 7957 TEST_F(URLRequestTestHTTP, ThrottledPriority) { |
7958 ASSERT_TRUE(http_test_server()->Start()); | 7958 ASSERT_TRUE(http_test_server()->Start()); |
7959 | 7959 |
7960 TestDelegate d; | 7960 TestDelegate d; |
7961 GURL test_url(http_test_server()->GetURL("/")); | 7961 GURL test_url(http_test_server()->GetURL("/")); |
7962 std::unique_ptr<URLRequest> req( | 7962 std::unique_ptr<URLRequest> req( |
7963 default_context_.CreateRequest(test_url, THROTTLED, &d)); | 7963 default_context_.CreateRequest(test_url, THROTTLED, &d)); |
7964 req->Start(); | 7964 req->Start(); |
7965 base::RunLoop().Run(); | 7965 base::RunLoop().Run(); |
7966 | 7966 |
7967 EXPECT_TRUE(req->status().is_success()); | 7967 EXPECT_TRUE(req->status().is_success()); |
7968 } | 7968 } |
7969 | 7969 |
| 7970 // Test that three jobs with THROTTLED priorities complete |
| 7971 // correctly in the absence of contention (the completion of the |
| 7972 // first one will unthrottle the third, but there is no visibility |
| 7973 // to that at this level). |
| 7974 TEST_F(URLRequestTestHTTP, MultiThrottledPriority) { |
| 7975 ASSERT_TRUE(http_test_server()->Start()); |
| 7976 |
| 7977 TestDelegate d; |
| 7978 GURL test_url(http_test_server()->GetURL("/")); |
| 7979 std::unique_ptr<URLRequest> req1( |
| 7980 default_context_.CreateRequest(test_url, THROTTLED, &d)); |
| 7981 std::unique_ptr<URLRequest> req2( |
| 7982 default_context_.CreateRequest(test_url, THROTTLED, &d)); |
| 7983 std::unique_ptr<URLRequest> req3( |
| 7984 default_context_.CreateRequest(test_url, THROTTLED, &d)); |
| 7985 req1->Start(); |
| 7986 req2->Start(); |
| 7987 req3->Start(); |
| 7988 base::RunLoop().Run(); |
| 7989 |
| 7990 EXPECT_TRUE(req1->status().is_success()); |
| 7991 EXPECT_TRUE(req2->status().is_success()); |
| 7992 EXPECT_TRUE(req3->status().is_success()); |
| 7993 } |
| 7994 |
7970 TEST_F(URLRequestTestHTTP, RawBodyBytesNoContentEncoding) { | 7995 TEST_F(URLRequestTestHTTP, RawBodyBytesNoContentEncoding) { |
7971 ASSERT_TRUE(http_test_server()->Start()); | 7996 ASSERT_TRUE(http_test_server()->Start()); |
7972 | 7997 |
7973 TestDelegate d; | 7998 TestDelegate d; |
7974 std::unique_ptr<URLRequest> req(default_context().CreateRequest( | 7999 std::unique_ptr<URLRequest> req(default_context().CreateRequest( |
7975 http_test_server()->GetURL("/simple.html"), DEFAULT_PRIORITY, &d)); | 8000 http_test_server()->GetURL("/simple.html"), DEFAULT_PRIORITY, &d)); |
7976 req->Start(); | 8001 req->Start(); |
7977 base::RunLoop().Run(); | 8002 base::RunLoop().Run(); |
7978 | 8003 |
7979 EXPECT_EQ(5, req->GetRawBodyBytes()); | 8004 EXPECT_EQ(5, req->GetRawBodyBytes()); |
(...skipping 2030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10010 AddTestInterceptor()->set_main_intercept_job(std::move(job)); | 10035 AddTestInterceptor()->set_main_intercept_job(std::move(job)); |
10011 | 10036 |
10012 req->Start(); | 10037 req->Start(); |
10013 req->Cancel(); | 10038 req->Cancel(); |
10014 base::RunLoop().RunUntilIdle(); | 10039 base::RunLoop().RunUntilIdle(); |
10015 EXPECT_EQ(URLRequestStatus::CANCELED, req->status().status()); | 10040 EXPECT_EQ(URLRequestStatus::CANCELED, req->status().status()); |
10016 EXPECT_EQ(0, d.received_redirect_count()); | 10041 EXPECT_EQ(0, d.received_redirect_count()); |
10017 } | 10042 } |
10018 | 10043 |
10019 } // namespace net | 10044 } // namespace net |
OLD | NEW |