Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: net/url_request/url_request_http_job_unittest.cc

Issue 2451233002: Make request fail with ERR_CONTENT_DECODING_INIT_FAILED if sdch is not supported (Closed)
Patch Set: self review Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/url_request/url_request_http_job.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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) {
mmenke 2016/10/26 16:45:43 Maybe add: // This test expects TestURLRequestCon
xunjieli 2016/10/26 16:49:22 Done.
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 std::unique_ptr<URLRequest> request = context_.CreateRequest(
176 GURL("http://www.example.com"), DEFAULT_PRIORITY, &delegate_);
177 std::unique_ptr<TestURLRequestHttpJob> job(
178 new TestURLRequestHttpJob(request.get()));
179 test_job_interceptor_->set_main_intercept_job(std::move(job));
180 request->Start();
181
182 base::RunLoop().Run();
183 EXPECT_EQ(ERR_CONTENT_DECODING_INIT_FAILED, delegate_.request_status());
184 }
185
162 class URLRequestHttpJobTest : public ::testing::Test { 186 class URLRequestHttpJobTest : public ::testing::Test {
163 protected: 187 protected:
164 URLRequestHttpJobTest() : context_(true) { 188 URLRequestHttpJobTest() : context_(true) {
165 context_.set_http_transaction_factory(&network_layer_); 189 context_.set_http_transaction_factory(&network_layer_);
166 190
167 // The |test_job_factory_| takes ownership of the interceptor. 191 // The |test_job_factory_| takes ownership of the interceptor.
168 test_job_interceptor_ = new TestJobInterceptor(); 192 test_job_interceptor_ = new TestJobInterceptor();
169 EXPECT_TRUE(test_job_factory_.SetProtocolHandler( 193 EXPECT_TRUE(test_job_factory_.SetProtocolHandler(
170 url::kHttpScheme, base::WrapUnique(test_job_interceptor_))); 194 url::kHttpScheme, base::WrapUnique(test_job_interceptor_)));
171 context_.set_job_factory(&test_job_factory_); 195 context_.set_job_factory(&test_job_factory_);
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 base::RunLoop().RunUntilIdle(); 1053 base::RunLoop().RunUntilIdle();
1030 EXPECT_THAT(delegate_.request_status(), IsError(ERR_IO_PENDING)); 1054 EXPECT_THAT(delegate_.request_status(), IsError(ERR_IO_PENDING));
1031 EXPECT_TRUE(fake_handshake_stream->initialize_stream_was_called()); 1055 EXPECT_TRUE(fake_handshake_stream->initialize_stream_was_called());
1032 } 1056 }
1033 1057
1034 #endif // defined(ENABLE_WEBSOCKETS) 1058 #endif // defined(ENABLE_WEBSOCKETS)
1035 1059
1036 } // namespace 1060 } // namespace
1037 1061
1038 } // namespace net 1062 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_http_job.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698