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_ftp_job.h" | 5 #include "net/url_request/url_request_ftp_job.h" |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 EXPECT_EQ(MEDIUM, job->priority()); | 155 EXPECT_EQ(MEDIUM, job->priority()); |
156 } | 156 } |
157 | 157 |
158 // Make sure that URLRequestFtpJob passes on its priority to its | 158 // Make sure that URLRequestFtpJob passes on its priority to its |
159 // transaction on start. | 159 // transaction on start. |
160 TEST_F(URLRequestFtpJobPriorityTest, SetTransactionPriorityOnStart) { | 160 TEST_F(URLRequestFtpJobPriorityTest, SetTransactionPriorityOnStart) { |
161 scoped_refptr<TestURLRequestFtpJob> job(new TestURLRequestFtpJob( | 161 scoped_refptr<TestURLRequestFtpJob> job(new TestURLRequestFtpJob( |
162 &req_, &ftp_factory_, &ftp_auth_cache_)); | 162 &req_, &ftp_factory_, &ftp_auth_cache_)); |
163 job->SetPriority(LOW); | 163 job->SetPriority(LOW); |
164 | 164 |
165 EXPECT_FALSE(network_layer_.last_transaction()); | 165 EXPECT_FALSE(network_layer_.last_transaction().get()); |
166 | 166 |
167 job->Start(); | 167 job->Start(); |
168 | 168 |
169 ASSERT_TRUE(network_layer_.last_transaction()); | 169 ASSERT_TRUE(network_layer_.last_transaction().get()); |
170 EXPECT_EQ(LOW, network_layer_.last_transaction()->priority()); | 170 EXPECT_EQ(LOW, network_layer_.last_transaction()->priority()); |
171 } | 171 } |
172 | 172 |
173 // Make sure that URLRequestFtpJob passes on its priority updates to | 173 // Make sure that URLRequestFtpJob passes on its priority updates to |
174 // its transaction. | 174 // its transaction. |
175 TEST_F(URLRequestFtpJobPriorityTest, SetTransactionPriority) { | 175 TEST_F(URLRequestFtpJobPriorityTest, SetTransactionPriority) { |
176 scoped_refptr<TestURLRequestFtpJob> job(new TestURLRequestFtpJob( | 176 scoped_refptr<TestURLRequestFtpJob> job(new TestURLRequestFtpJob( |
177 &req_, &ftp_factory_, &ftp_auth_cache_)); | 177 &req_, &ftp_factory_, &ftp_auth_cache_)); |
178 job->SetPriority(LOW); | 178 job->SetPriority(LOW); |
179 job->Start(); | 179 job->Start(); |
180 ASSERT_TRUE(network_layer_.last_transaction()); | 180 ASSERT_TRUE(network_layer_.last_transaction().get()); |
181 EXPECT_EQ(LOW, network_layer_.last_transaction()->priority()); | 181 EXPECT_EQ(LOW, network_layer_.last_transaction()->priority()); |
182 | 182 |
183 job->SetPriority(HIGHEST); | 183 job->SetPriority(HIGHEST); |
184 EXPECT_EQ(HIGHEST, network_layer_.last_transaction()->priority()); | 184 EXPECT_EQ(HIGHEST, network_layer_.last_transaction()->priority()); |
185 } | 185 } |
186 | 186 |
187 // Make sure that URLRequestFtpJob passes on its priority updates to | 187 // Make sure that URLRequestFtpJob passes on its priority updates to |
188 // newly-created transactions after the first one. | 188 // newly-created transactions after the first one. |
189 TEST_F(URLRequestFtpJobPriorityTest, SetSubsequentTransactionPriority) { | 189 TEST_F(URLRequestFtpJobPriorityTest, SetSubsequentTransactionPriority) { |
190 scoped_refptr<TestURLRequestFtpJob> job(new TestURLRequestFtpJob( | 190 scoped_refptr<TestURLRequestFtpJob> job(new TestURLRequestFtpJob( |
191 &req_, &ftp_factory_, &ftp_auth_cache_)); | 191 &req_, &ftp_factory_, &ftp_auth_cache_)); |
192 job->Start(); | 192 job->Start(); |
193 | 193 |
194 job->SetPriority(LOW); | 194 job->SetPriority(LOW); |
195 ASSERT_TRUE(network_layer_.last_transaction()); | 195 ASSERT_TRUE(network_layer_.last_transaction().get()); |
196 EXPECT_EQ(LOW, network_layer_.last_transaction()->priority()); | 196 EXPECT_EQ(LOW, network_layer_.last_transaction()->priority()); |
197 | 197 |
198 job->Kill(); | 198 job->Kill(); |
199 network_layer_.ClearLastTransaction(); | 199 network_layer_.ClearLastTransaction(); |
200 | 200 |
201 // Creates a second transaction. | 201 // Creates a second transaction. |
202 job->Start(); | 202 job->Start(); |
203 ASSERT_TRUE(network_layer_.last_transaction()); | 203 ASSERT_TRUE(network_layer_.last_transaction().get()); |
204 EXPECT_EQ(LOW, network_layer_.last_transaction()->priority()); | 204 EXPECT_EQ(LOW, network_layer_.last_transaction()->priority()); |
205 } | 205 } |
206 | 206 |
207 class URLRequestFtpJobTest : public testing::Test { | 207 class URLRequestFtpJobTest : public testing::Test { |
208 public: | 208 public: |
209 URLRequestFtpJobTest() | 209 URLRequestFtpJobTest() |
210 : request_context_(&socket_factory_, | 210 : request_context_(&socket_factory_, |
211 new ProxyService( | 211 new ProxyService( |
212 new SimpleProxyConfigService, NULL, NULL), | 212 new SimpleProxyConfigService, NULL, NULL), |
213 &network_delegate_, | 213 &network_delegate_, |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 EXPECT_TRUE(url_request2.status().is_success()); | 701 EXPECT_TRUE(url_request2.status().is_success()); |
702 EXPECT_EQ(2, network_delegate()->completed_requests()); | 702 EXPECT_EQ(2, network_delegate()->completed_requests()); |
703 EXPECT_EQ(0, network_delegate()->error_count()); | 703 EXPECT_EQ(0, network_delegate()->error_count()); |
704 EXPECT_FALSE(request_delegate2.auth_required_called()); | 704 EXPECT_FALSE(request_delegate2.auth_required_called()); |
705 EXPECT_EQ("test2.html", request_delegate2.data_received()); | 705 EXPECT_EQ("test2.html", request_delegate2.data_received()); |
706 } | 706 } |
707 | 707 |
708 } // namespace | 708 } // namespace |
709 | 709 |
710 } // namespace net | 710 } // namespace net |
OLD | NEW |