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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <cstddef> | 9 #include <cstddef> |
10 #include <memory> | 10 #include <memory> |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 std::unique_ptr<TestURLRequestHttpJob> job( | 152 std::unique_ptr<TestURLRequestHttpJob> job( |
153 new TestURLRequestHttpJob(request.get())); | 153 new TestURLRequestHttpJob(request.get())); |
154 test_job_interceptor_->set_main_intercept_job(std::move(job)); | 154 test_job_interceptor_->set_main_intercept_job(std::move(job)); |
155 request->Start(); | 155 request->Start(); |
156 | 156 |
157 base::RunLoop().Run(); | 157 base::RunLoop().Run(); |
158 EXPECT_EQ(OK, delegate_.request_status()); | 158 EXPECT_EQ(OK, delegate_.request_status()); |
159 EXPECT_EQ("Test Content", delegate_.data_received()); | 159 EXPECT_EQ("Test Content", delegate_.data_received()); |
160 } | 160 } |
161 | 161 |
| 162 // Received a malformed SDCH encoded response when there is no SdchManager. |
| 163 TEST_F(URLRequestHttpJobSetUpSourceTest, |
| 164 SdchNotAdvertisedGotMalformedSdchResponse) { |
| 165 MockWrite writes[] = {MockWrite(kSimpleGetMockWrite)}; |
| 166 MockRead reads[] = {MockRead("HTTP/1.1 200 OK\r\n" |
| 167 "Content-Encoding: sdch\r\n" |
| 168 "Content-Length: 12\r\n\r\n"), |
| 169 MockRead("Test Content")}; |
| 170 |
| 171 StaticSocketDataProvider socket_data(reads, arraysize(reads), writes, |
| 172 arraysize(writes)); |
| 173 socket_factory_.AddSocketDataProvider(&socket_data); |
| 174 |
| 175 // This test expects TestURLRequestContexts to have no SdchManager. |
| 176 DCHECK(!context_.sdch_manager()); |
| 177 |
| 178 std::unique_ptr<URLRequest> request = context_.CreateRequest( |
| 179 GURL("http://www.example.com"), DEFAULT_PRIORITY, &delegate_); |
| 180 std::unique_ptr<TestURLRequestHttpJob> job( |
| 181 new TestURLRequestHttpJob(request.get())); |
| 182 test_job_interceptor_->set_main_intercept_job(std::move(job)); |
| 183 request->Start(); |
| 184 |
| 185 base::RunLoop().Run(); |
| 186 EXPECT_EQ(ERR_CONTENT_DECODING_INIT_FAILED, delegate_.request_status()); |
| 187 } |
| 188 |
162 class URLRequestHttpJobTest : public ::testing::Test { | 189 class URLRequestHttpJobTest : public ::testing::Test { |
163 protected: | 190 protected: |
164 URLRequestHttpJobTest() : context_(true) { | 191 URLRequestHttpJobTest() : context_(true) { |
165 context_.set_http_transaction_factory(&network_layer_); | 192 context_.set_http_transaction_factory(&network_layer_); |
166 | 193 |
167 // The |test_job_factory_| takes ownership of the interceptor. | 194 // The |test_job_factory_| takes ownership of the interceptor. |
168 test_job_interceptor_ = new TestJobInterceptor(); | 195 test_job_interceptor_ = new TestJobInterceptor(); |
169 EXPECT_TRUE(test_job_factory_.SetProtocolHandler( | 196 EXPECT_TRUE(test_job_factory_.SetProtocolHandler( |
170 url::kHttpScheme, base::WrapUnique(test_job_interceptor_))); | 197 url::kHttpScheme, base::WrapUnique(test_job_interceptor_))); |
171 context_.set_job_factory(&test_job_factory_); | 198 context_.set_job_factory(&test_job_factory_); |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 base::RunLoop().RunUntilIdle(); | 1056 base::RunLoop().RunUntilIdle(); |
1030 EXPECT_THAT(delegate_.request_status(), IsError(ERR_IO_PENDING)); | 1057 EXPECT_THAT(delegate_.request_status(), IsError(ERR_IO_PENDING)); |
1031 EXPECT_TRUE(fake_handshake_stream->initialize_stream_was_called()); | 1058 EXPECT_TRUE(fake_handshake_stream->initialize_stream_was_called()); |
1032 } | 1059 } |
1033 | 1060 |
1034 #endif // defined(ENABLE_WEBSOCKETS) | 1061 #endif // defined(ENABLE_WEBSOCKETS) |
1035 | 1062 |
1036 } // namespace | 1063 } // namespace |
1037 | 1064 |
1038 } // namespace net | 1065 } // namespace net |
OLD | NEW |