OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_http_job.h" | 5 #include "net/url_request/url_request_http_job.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 protected: | 45 protected: |
46 ~TestURLRequestHttpJob() override {} | 46 ~TestURLRequestHttpJob() override {} |
47 }; | 47 }; |
48 | 48 |
49 class URLRequestHttpJobTest : public ::testing::Test { | 49 class URLRequestHttpJobTest : public ::testing::Test { |
50 protected: | 50 protected: |
51 URLRequestHttpJobTest() | 51 URLRequestHttpJobTest() |
52 : req_(context_.CreateRequest(GURL("http://www.example.com"), | 52 : req_(context_.CreateRequest(GURL("http://www.example.com"), |
53 DEFAULT_PRIORITY, | 53 DEFAULT_PRIORITY, |
54 &delegate_, | 54 &delegate_)) { |
55 nullptr)) { | |
56 context_.set_http_transaction_factory(&network_layer_); | 55 context_.set_http_transaction_factory(&network_layer_); |
57 } | 56 } |
58 | 57 |
59 bool TransactionAcceptsSdchEncoding() { | 58 bool TransactionAcceptsSdchEncoding() { |
60 base::WeakPtr<MockNetworkTransaction> transaction( | 59 base::WeakPtr<MockNetworkTransaction> transaction( |
61 network_layer_.last_transaction()); | 60 network_layer_.last_transaction()); |
62 EXPECT_TRUE(transaction); | 61 EXPECT_TRUE(transaction); |
63 if (!transaction) return false; | 62 if (!transaction) return false; |
64 | 63 |
65 const HttpRequestInfo* request_info = transaction->request(); | 64 const HttpRequestInfo* request_info = transaction->request(); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 MockClientSocketFactory socket_factory_; | 203 MockClientSocketFactory socket_factory_; |
205 TestURLRequestContext context_; | 204 TestURLRequestContext context_; |
206 }; | 205 }; |
207 | 206 |
208 class URLRequestHttpJobWebSocketTest | 207 class URLRequestHttpJobWebSocketTest |
209 : public URLRequestHttpJobWebSocketTestBase { | 208 : public URLRequestHttpJobWebSocketTestBase { |
210 protected: | 209 protected: |
211 URLRequestHttpJobWebSocketTest() | 210 URLRequestHttpJobWebSocketTest() |
212 : req_(context_.CreateRequest(GURL("ws://www.example.com"), | 211 : req_(context_.CreateRequest(GURL("ws://www.example.com"), |
213 DEFAULT_PRIORITY, | 212 DEFAULT_PRIORITY, |
214 &delegate_, | 213 &delegate_)) { |
215 nullptr)) { | |
216 // The TestNetworkDelegate expects a call to NotifyBeforeURLRequest before | 214 // The TestNetworkDelegate expects a call to NotifyBeforeURLRequest before |
217 // anything else happens. | 215 // anything else happens. |
218 GURL url("ws://localhost/"); | 216 GURL url("ws://localhost/"); |
219 TestCompletionCallback dummy; | 217 TestCompletionCallback dummy; |
220 network_delegate_.NotifyBeforeURLRequest( | 218 network_delegate_.NotifyBeforeURLRequest( |
221 req_.get(), dummy.callback(), &url); | 219 req_.get(), dummy.callback(), &url); |
222 } | 220 } |
223 | 221 |
224 TestDelegate delegate_; | 222 TestDelegate delegate_; |
225 scoped_ptr<URLRequest> req_; | 223 scoped_ptr<URLRequest> req_; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 req_->SetLoadFlags(LOAD_DISABLE_CACHE); | 342 req_->SetLoadFlags(LOAD_DISABLE_CACHE); |
345 job->Start(); | 343 job->Start(); |
346 base::RunLoop().RunUntilIdle(); | 344 base::RunLoop().RunUntilIdle(); |
347 EXPECT_EQ(URLRequestStatus::IO_PENDING, req_->status().status()); | 345 EXPECT_EQ(URLRequestStatus::IO_PENDING, req_->status().status()); |
348 EXPECT_TRUE(fake_handshake_stream->initialize_stream_was_called()); | 346 EXPECT_TRUE(fake_handshake_stream->initialize_stream_was_called()); |
349 } | 347 } |
350 | 348 |
351 } // namespace | 349 } // namespace |
352 | 350 |
353 } // namespace net | 351 } // namespace net |
OLD | NEW |