| 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 25 matching lines...) Expand all Loading... |
| 36 explicit TestURLRequestHttpJob(URLRequest* request) | 36 explicit TestURLRequestHttpJob(URLRequest* request) |
| 37 : URLRequestHttpJob(request, request->context()->network_delegate(), | 37 : URLRequestHttpJob(request, request->context()->network_delegate(), |
| 38 request->context()->http_user_agent_settings()) {} | 38 request->context()->http_user_agent_settings()) {} |
| 39 | 39 |
| 40 using URLRequestHttpJob::SetPriority; | 40 using URLRequestHttpJob::SetPriority; |
| 41 using URLRequestHttpJob::Start; | 41 using URLRequestHttpJob::Start; |
| 42 using URLRequestHttpJob::Kill; | 42 using URLRequestHttpJob::Kill; |
| 43 using URLRequestHttpJob::priority; | 43 using URLRequestHttpJob::priority; |
| 44 | 44 |
| 45 protected: | 45 protected: |
| 46 virtual ~TestURLRequestHttpJob() {} | 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 NULL)) { | 55 NULL)) { |
| 56 context_.set_http_transaction_factory(&network_layer_); | 56 context_.set_http_transaction_factory(&network_layer_); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 | 246 |
| 247 class FakeWebSocketHandshakeStream : public WebSocketHandshakeStreamBase { | 247 class FakeWebSocketHandshakeStream : public WebSocketHandshakeStreamBase { |
| 248 public: | 248 public: |
| 249 FakeWebSocketHandshakeStream() : initialize_stream_was_called_(false) {} | 249 FakeWebSocketHandshakeStream() : initialize_stream_was_called_(false) {} |
| 250 | 250 |
| 251 bool initialize_stream_was_called() const { | 251 bool initialize_stream_was_called() const { |
| 252 return initialize_stream_was_called_; | 252 return initialize_stream_was_called_; |
| 253 } | 253 } |
| 254 | 254 |
| 255 // Fake implementation of HttpStreamBase methods. | 255 // Fake implementation of HttpStreamBase methods. |
| 256 virtual int InitializeStream(const HttpRequestInfo* request_info, | 256 int InitializeStream(const HttpRequestInfo* request_info, |
| 257 RequestPriority priority, | 257 RequestPriority priority, |
| 258 const BoundNetLog& net_log, | 258 const BoundNetLog& net_log, |
| 259 const CompletionCallback& callback) override { | 259 const CompletionCallback& callback) override { |
| 260 initialize_stream_was_called_ = true; | 260 initialize_stream_was_called_ = true; |
| 261 return ERR_IO_PENDING; | 261 return ERR_IO_PENDING; |
| 262 } | 262 } |
| 263 | 263 |
| 264 virtual int SendRequest(const HttpRequestHeaders& request_headers, | 264 int SendRequest(const HttpRequestHeaders& request_headers, |
| 265 HttpResponseInfo* response, | 265 HttpResponseInfo* response, |
| 266 const CompletionCallback& callback) override { | 266 const CompletionCallback& callback) override { |
| 267 return ERR_IO_PENDING; | 267 return ERR_IO_PENDING; |
| 268 } | 268 } |
| 269 | 269 |
| 270 virtual int ReadResponseHeaders(const CompletionCallback& callback) override { | 270 int ReadResponseHeaders(const CompletionCallback& callback) override { |
| 271 return ERR_IO_PENDING; | 271 return ERR_IO_PENDING; |
| 272 } | 272 } |
| 273 | 273 |
| 274 virtual int ReadResponseBody(IOBuffer* buf, | 274 int ReadResponseBody(IOBuffer* buf, |
| 275 int buf_len, | 275 int buf_len, |
| 276 const CompletionCallback& callback) override { | 276 const CompletionCallback& callback) override { |
| 277 return ERR_IO_PENDING; | 277 return ERR_IO_PENDING; |
| 278 } | 278 } |
| 279 | 279 |
| 280 virtual void Close(bool not_reusable) override {} | 280 void Close(bool not_reusable) override {} |
| 281 | 281 |
| 282 virtual bool IsResponseBodyComplete() const override { return false; } | 282 bool IsResponseBodyComplete() const override { return false; } |
| 283 | 283 |
| 284 virtual bool CanFindEndOfResponse() const override { return false; } | 284 bool CanFindEndOfResponse() const override { return false; } |
| 285 | 285 |
| 286 virtual bool IsConnectionReused() const override { return false; } | 286 bool IsConnectionReused() const override { return false; } |
| 287 virtual void SetConnectionReused() override {} | 287 void SetConnectionReused() override {} |
| 288 | 288 |
| 289 virtual bool IsConnectionReusable() const override { return false; } | 289 bool IsConnectionReusable() const override { return false; } |
| 290 | 290 |
| 291 virtual int64 GetTotalReceivedBytes() const override { return 0; } | 291 int64 GetTotalReceivedBytes() const override { return 0; } |
| 292 | 292 |
| 293 virtual bool GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const | 293 bool GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const override { |
| 294 override { | |
| 295 return false; | 294 return false; |
| 296 } | 295 } |
| 297 | 296 |
| 298 virtual void GetSSLInfo(SSLInfo* ssl_info) override {} | 297 void GetSSLInfo(SSLInfo* ssl_info) override {} |
| 299 | 298 |
| 300 virtual void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) | 299 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override {} |
| 301 override {} | |
| 302 | 300 |
| 303 virtual bool IsSpdyHttpStream() const override { return false; } | 301 bool IsSpdyHttpStream() const override { return false; } |
| 304 | 302 |
| 305 virtual void Drain(HttpNetworkSession* session) override {} | 303 void Drain(HttpNetworkSession* session) override {} |
| 306 | 304 |
| 307 virtual void SetPriority(RequestPriority priority) override {} | 305 void SetPriority(RequestPriority priority) override {} |
| 308 | 306 |
| 309 // Fake implementation of WebSocketHandshakeStreamBase method(s) | 307 // Fake implementation of WebSocketHandshakeStreamBase method(s) |
| 310 virtual scoped_ptr<WebSocketStream> Upgrade() override { | 308 scoped_ptr<WebSocketStream> Upgrade() override { |
| 311 return scoped_ptr<WebSocketStream>(); | 309 return scoped_ptr<WebSocketStream>(); |
| 312 } | 310 } |
| 313 | 311 |
| 314 private: | 312 private: |
| 315 bool initialize_stream_was_called_; | 313 bool initialize_stream_was_called_; |
| 316 }; | 314 }; |
| 317 | 315 |
| 318 TEST_F(URLRequestHttpJobWebSocketTest, RejectedWithoutCreateHelper) { | 316 TEST_F(URLRequestHttpJobWebSocketTest, RejectedWithoutCreateHelper) { |
| 319 scoped_refptr<TestURLRequestHttpJob> job( | 317 scoped_refptr<TestURLRequestHttpJob> job( |
| 320 new TestURLRequestHttpJob(req_.get())); | 318 new TestURLRequestHttpJob(req_.get())); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 340 req_->SetLoadFlags(LOAD_DISABLE_CACHE); | 338 req_->SetLoadFlags(LOAD_DISABLE_CACHE); |
| 341 job->Start(); | 339 job->Start(); |
| 342 base::RunLoop().RunUntilIdle(); | 340 base::RunLoop().RunUntilIdle(); |
| 343 EXPECT_EQ(URLRequestStatus::IO_PENDING, req_->status().status()); | 341 EXPECT_EQ(URLRequestStatus::IO_PENDING, req_->status().status()); |
| 344 EXPECT_TRUE(fake_handshake_stream->initialize_stream_was_called()); | 342 EXPECT_TRUE(fake_handshake_stream->initialize_stream_was_called()); |
| 345 } | 343 } |
| 346 | 344 |
| 347 } // namespace | 345 } // namespace |
| 348 | 346 |
| 349 } // namespace net | 347 } // namespace net |
| OLD | NEW |