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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shlobj.h> | 9 #include <shlobj.h> |
10 #endif | 10 #endif |
(...skipping 9071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9082 base::GetFileSize(app_path, &file_size); | 9082 base::GetFileSize(app_path, &file_size); |
9083 | 9083 |
9084 EXPECT_FALSE(r->is_pending()); | 9084 EXPECT_FALSE(r->is_pending()); |
9085 EXPECT_EQ(1, d->response_started_count()); | 9085 EXPECT_EQ(1, d->response_started_count()); |
9086 EXPECT_FALSE(d->received_data_before_response()); | 9086 EXPECT_FALSE(d->received_data_before_response()); |
9087 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); | 9087 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); |
9088 } | 9088 } |
9089 } | 9089 } |
9090 #endif // !defined(DISABLE_FTP_SUPPORT) | 9090 #endif // !defined(DISABLE_FTP_SUPPORT) |
9091 | 9091 |
9092 TEST_F(URLRequestTest, NetworkAccessedClearBeforeNetworkStart) { | |
9093 TestDelegate d; | |
9094 scoped_ptr<URLRequest> req(default_context_.CreateRequest( | |
9095 GURL("http://test_intercept/foo"), DEFAULT_PRIORITY, &d)); | |
9096 d.set_quit_on_network_start(true); | |
9097 | |
9098 EXPECT_FALSE(req->response_info().network_accessed); | |
9099 | |
9100 req->Start(); | |
9101 base::RunLoop().Run(); | |
9102 | |
9103 EXPECT_EQ(1, d.received_before_network_start_count()); | |
9104 EXPECT_EQ(0, d.response_started_count()); | |
9105 EXPECT_FALSE(req->response_info().network_accessed); | |
9106 | |
9107 req->ResumeNetworkStart(); | |
9108 base::RunLoop().Run(); | |
9109 } | |
9110 | |
9111 TEST_F(URLRequestTest, NetworkAccessedClearOnDataRequest) { | |
9112 TestDelegate d; | |
9113 scoped_ptr<URLRequest> req( | |
9114 default_context_.CreateRequest(GURL("data:,"), DEFAULT_PRIORITY, &d)); | |
9115 | |
9116 EXPECT_FALSE(req->response_info().network_accessed); | |
9117 | |
9118 req->Start(); | |
9119 base::RunLoop().Run(); | |
9120 | |
9121 EXPECT_EQ(1, default_network_delegate_.completed_requests()); | |
9122 EXPECT_FALSE(req->response_info().network_accessed); | |
9123 } | |
9124 | |
9125 TEST_F(URLRequestTest, NetworkAccessedSetOnHostResolutionFailure) { | |
9126 MockHostResolver host_resolver; | |
9127 TestNetworkDelegate network_delegate; // Must outlive URLRequest. | |
9128 TestURLRequestContext context(true); | |
9129 context.set_network_delegate(&network_delegate); | |
9130 context.set_host_resolver(&host_resolver); | |
9131 host_resolver.rules()->AddSimulatedFailure("*"); | |
9132 context.Init(); | |
9133 | |
9134 TestDelegate d; | |
9135 scoped_ptr<URLRequest> req(context.CreateRequest( | |
9136 GURL("http://test_intercept/foo"), DEFAULT_PRIORITY, &d)); | |
9137 | |
9138 EXPECT_FALSE(req->response_info().network_accessed); | |
9139 | |
9140 req->Start(); | |
9141 base::RunLoop().Run(); | |
9142 EXPECT_TRUE(req->response_info().network_accessed); | |
9143 } | |
9144 | |
9145 TEST_F(URLRequestTestHTTP, NetworkAccessedSetOnNetworkRequest) { | |
9146 ASSERT_TRUE(test_server_.Start()); | |
9147 | |
9148 TestDelegate d; | |
9149 GURL test_url(test_server_.GetURL(std::string())); | |
9150 scoped_ptr<URLRequest> req( | |
9151 default_context_.CreateRequest(test_url, DEFAULT_PRIORITY, &d)); | |
9152 | |
9153 req->Start(); | |
9154 base::RunLoop().Run(); | |
9155 | |
9156 EXPECT_TRUE(req->response_info().network_accessed); | |
9157 } | |
9158 | |
9159 TEST_F(URLRequestTestHTTP, NetworkAccessedClearOnCachedResponse) { | |
9160 ASSERT_TRUE(test_server_.Start()); | |
9161 | |
9162 // Populate the cache. | |
9163 TestDelegate d; | |
9164 scoped_ptr<URLRequest> req(default_context_.CreateRequest( | |
9165 test_server_.GetURL("cachetime"), DEFAULT_PRIORITY, &d)); | |
9166 req->Start(); | |
9167 base::RunLoop().Run(); | |
9168 | |
9169 EXPECT_EQ(URLRequestStatus::SUCCESS, req->status().status()); | |
9170 EXPECT_TRUE(req->response_info().network_accessed); | |
9171 EXPECT_FALSE(req->response_info().was_cached); | |
9172 | |
9173 req = default_context_.CreateRequest(test_server_.GetURL("cachetime"), | |
9174 DEFAULT_PRIORITY, &d); | |
9175 req->Start(); | |
9176 base::RunLoop().Run(); | |
9177 | |
9178 EXPECT_EQ(URLRequestStatus::SUCCESS, req->status().status()); | |
9179 EXPECT_FALSE(req->response_info().network_accessed); | |
9180 EXPECT_TRUE(req->response_info().was_cached); | |
9181 } | |
9182 | |
9183 TEST_F(URLRequestTestHTTP, NetworkAccessedClearOnLoadOnlyFromCache) { | |
9184 ASSERT_TRUE(test_server_.Start()); | |
9185 | |
9186 TestDelegate d; | |
9187 GURL test_url(test_server_.GetURL(std::string())); | |
9188 scoped_ptr<URLRequest> req( | |
9189 default_context_.CreateRequest(test_url, DEFAULT_PRIORITY, &d)); | |
9190 req->SetLoadFlags(LOAD_ONLY_FROM_CACHE); | |
9191 | |
9192 req->Start(); | |
9193 base::RunLoop().Run(); | |
9194 | |
9195 EXPECT_FALSE(req->response_info().network_accessed); | |
9196 } | |
9197 | |
davidben
2015/05/14 22:28:14
Revalidate case? Perhaps do that test at the HttpC
Deprecated (see juliatuttle)
2015/05/14 23:52:10
Done.
davidben
2015/05/14 23:55:04
[For posterity, we noticed out-of-band that http_c
| |
9092 } // namespace net | 9198 } // namespace net |
OLD | NEW |