| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <stack> | 5 #include <stack> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // Subclasses to simulate particular responses so test cases can | 65 // Subclasses to simulate particular responses so test cases can |
| 66 // exercise fallback code paths. | 66 // exercise fallback code paths. |
| 67 | 67 |
| 68 class MockURLRequestDelegate : public net::URLRequest::Delegate { | 68 class MockURLRequestDelegate : public net::URLRequest::Delegate { |
| 69 virtual void OnResponseStarted(net::URLRequest* request) {} | 69 virtual void OnResponseStarted(net::URLRequest* request) {} |
| 70 virtual void OnReadCompleted(net::URLRequest* request, int bytes_read) {} | 70 virtual void OnReadCompleted(net::URLRequest* request, int bytes_read) {} |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 class MockURLRequestJob : public net::URLRequestJob { | 73 class MockURLRequestJob : public net::URLRequestJob { |
| 74 public: | 74 public: |
| 75 MockURLRequestJob( | 75 MockURLRequestJob(net::URLRequest* request, |
| 76 net::URLRequest* request, int response_code) | 76 int response_code) |
| 77 : net::URLRequestJob(request), | 77 : net::URLRequestJob(request), |
| 78 response_code_(response_code), | 78 response_code_(response_code), |
| 79 has_response_info_(false) {} | 79 has_response_info_(false) {} |
| 80 MockURLRequestJob( | 80 MockURLRequestJob(net::URLRequest* request, |
| 81 net::URLRequest* request, const net::HttpResponseInfo& info) | 81 const net::HttpResponseInfo& info) |
| 82 : net::URLRequestJob(request), | 82 : net::URLRequestJob(request), |
| 83 response_code_(info.headers->response_code()), | 83 response_code_(info.headers->response_code()), |
| 84 has_response_info_(true), | 84 has_response_info_(true), |
| 85 response_info_(info) {} | 85 response_info_(info) {} |
| 86 virtual void Start() { | 86 |
| 87 protected: |
| 88 virtual ~MockURLRequestJob() {} |
| 89 virtual void Start() OVERRIDE { |
| 87 NotifyHeadersComplete(); | 90 NotifyHeadersComplete(); |
| 88 } | 91 } |
| 89 virtual int GetResponseCode() const { | 92 virtual int GetResponseCode() const OVERRIDE { |
| 90 return response_code_; | 93 return response_code_; |
| 91 } | 94 } |
| 92 virtual void GetResponseInfo(net::HttpResponseInfo* info) { | 95 virtual void GetResponseInfo( |
| 96 net::HttpResponseInfo* info) OVERRIDE { |
| 93 if (!has_response_info_) | 97 if (!has_response_info_) |
| 94 return; | 98 return; |
| 95 *info = response_info_; | 99 *info = response_info_; |
| 96 } | 100 } |
| 101 |
| 102 private: |
| 97 int response_code_; | 103 int response_code_; |
| 98 bool has_response_info_; | 104 bool has_response_info_; |
| 99 net::HttpResponseInfo response_info_; | 105 net::HttpResponseInfo response_info_; |
| 100 }; | 106 }; |
| 101 | 107 |
| 102 class MockURLRequest : public net::URLRequest { | 108 class MockURLRequest : public net::URLRequest { |
| 103 public: | 109 public: |
| 104 explicit MockURLRequest(const GURL& url) : net::URLRequest(url, NULL) {} | 110 explicit MockURLRequest(const GURL& url) : net::URLRequest(url, NULL) {} |
| 105 | 111 |
| 106 void SimulateResponseCode(int http_response_code) { | 112 void SimulateResponseCode(int http_response_code) { |
| (...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 | 894 |
| 889 TEST_F(AppCacheRequestHandlerTest, WorkerRequest) { | 895 TEST_F(AppCacheRequestHandlerTest, WorkerRequest) { |
| 890 RunTestOnIOThread(&AppCacheRequestHandlerTest::WorkerRequest); | 896 RunTestOnIOThread(&AppCacheRequestHandlerTest::WorkerRequest); |
| 891 } | 897 } |
| 892 | 898 |
| 893 TEST_F(AppCacheRequestHandlerTest, MainResource_Blocked) { | 899 TEST_F(AppCacheRequestHandlerTest, MainResource_Blocked) { |
| 894 RunTestOnIOThread(&AppCacheRequestHandlerTest::MainResource_Blocked); | 900 RunTestOnIOThread(&AppCacheRequestHandlerTest::MainResource_Blocked); |
| 895 } | 901 } |
| 896 | 902 |
| 897 } // namespace appcache | 903 } // namespace appcache |
| OLD | NEW |