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

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

Issue 699123002: Remove HttpStreamBase. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 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/net.gypi ('k') | net/websockets/websocket_basic_handshake_stream.h » ('j') | 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 <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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 NULL)) { 55 nullptr)) {
56 context_.set_http_transaction_factory(&network_layer_); 56 context_.set_http_transaction_factory(&network_layer_);
57 } 57 }
58 58
59 bool TransactionAcceptsSdchEncoding() { 59 bool TransactionAcceptsSdchEncoding() {
60 base::WeakPtr<MockNetworkTransaction> transaction( 60 base::WeakPtr<MockNetworkTransaction> transaction(
61 network_layer_.last_transaction()); 61 network_layer_.last_transaction());
62 EXPECT_TRUE(transaction); 62 EXPECT_TRUE(transaction);
63 if (!transaction) return false; 63 if (!transaction) return false;
64 64
65 const HttpRequestInfo* request_info = transaction->request(); 65 const HttpRequestInfo* request_info = transaction->request();
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 scoped_refptr<TestURLRequestHttpJob> job( 179 scoped_refptr<TestURLRequestHttpJob> job(
180 new TestURLRequestHttpJob(req_.get())); 180 new TestURLRequestHttpJob(req_.get()));
181 job->Start(); 181 job->Start();
182 EXPECT_FALSE(TransactionAcceptsSdchEncoding()); 182 EXPECT_FALSE(TransactionAcceptsSdchEncoding());
183 } 183 }
184 184
185 // This base class just serves to set up some things before the TestURLRequest 185 // This base class just serves to set up some things before the TestURLRequest
186 // constructor is called. 186 // constructor is called.
187 class URLRequestHttpJobWebSocketTestBase : public ::testing::Test { 187 class URLRequestHttpJobWebSocketTestBase : public ::testing::Test {
188 protected: 188 protected:
189 URLRequestHttpJobWebSocketTestBase() : socket_data_(NULL, 0, NULL, 0), 189 URLRequestHttpJobWebSocketTestBase() : socket_data_(nullptr, 0, nullptr, 0),
190 context_(true) { 190 context_(true) {
191 // A Network Delegate is required for the WebSocketHandshakeStreamBase 191 // A Network Delegate is required for the WebSocketHandshakeStreamBase
192 // object to be passed on to the HttpNetworkTransaction. 192 // object to be passed on to the HttpNetworkTransaction.
193 context_.set_network_delegate(&network_delegate_); 193 context_.set_network_delegate(&network_delegate_);
194 194
195 // Attempting to create real ClientSocketHandles is not going to work out so 195 // Attempting to create real ClientSocketHandles is not going to work out so
196 // well. Set up a fake socket factory. 196 // well. Set up a fake socket factory.
197 socket_factory_.AddSocketDataProvider(&socket_data_); 197 socket_factory_.AddSocketDataProvider(&socket_data_);
198 context_.set_client_socket_factory(&socket_factory_); 198 context_.set_client_socket_factory(&socket_factory_);
199 context_.Init(); 199 context_.Init();
200 } 200 }
201 201
202 StaticSocketDataProvider socket_data_; 202 StaticSocketDataProvider socket_data_;
203 TestNetworkDelegate network_delegate_; 203 TestNetworkDelegate network_delegate_;
204 MockClientSocketFactory socket_factory_; 204 MockClientSocketFactory socket_factory_;
205 TestURLRequestContext context_; 205 TestURLRequestContext context_;
206 }; 206 };
207 207
208 class URLRequestHttpJobWebSocketTest 208 class URLRequestHttpJobWebSocketTest
209 : public URLRequestHttpJobWebSocketTestBase { 209 : public URLRequestHttpJobWebSocketTestBase {
210 protected: 210 protected:
211 URLRequestHttpJobWebSocketTest() 211 URLRequestHttpJobWebSocketTest()
212 : req_(context_.CreateRequest(GURL("ws://www.example.com"), 212 : req_(context_.CreateRequest(GURL("ws://www.example.com"),
213 DEFAULT_PRIORITY, 213 DEFAULT_PRIORITY,
214 &delegate_, 214 &delegate_,
215 NULL)) { 215 nullptr)) {
216 // The TestNetworkDelegate expects a call to NotifyBeforeURLRequest before 216 // The TestNetworkDelegate expects a call to NotifyBeforeURLRequest before
217 // anything else happens. 217 // anything else happens.
218 GURL url("ws://localhost/"); 218 GURL url("ws://localhost/");
219 TestCompletionCallback dummy; 219 TestCompletionCallback dummy;
220 network_delegate_.NotifyBeforeURLRequest( 220 network_delegate_.NotifyBeforeURLRequest(
221 req_.get(), dummy.callback(), &url); 221 req_.get(), dummy.callback(), &url);
222 } 222 }
223 223
224 TestDelegate delegate_; 224 TestDelegate delegate_;
225 scoped_ptr<URLRequest> req_; 225 scoped_ptr<URLRequest> req_;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 void GetSSLInfo(SSLInfo* ssl_info) override {} 297 void GetSSLInfo(SSLInfo* ssl_info) override {}
298 298
299 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override {} 299 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override {}
300 300
301 bool IsSpdyHttpStream() const override { return false; } 301 bool IsSpdyHttpStream() const override { return false; }
302 302
303 void Drain(HttpNetworkSession* session) override {} 303 void Drain(HttpNetworkSession* session) override {}
304 304
305 void SetPriority(RequestPriority priority) override {} 305 void SetPriority(RequestPriority priority) override {}
306 306
307 UploadProgress GetUploadProgress() const override {
308 return UploadProgress();
309 }
310
311 HttpStream* RenewStreamForAuth() override { return nullptr; }
312
307 // Fake implementation of WebSocketHandshakeStreamBase method(s) 313 // Fake implementation of WebSocketHandshakeStreamBase method(s)
308 scoped_ptr<WebSocketStream> Upgrade() override { 314 scoped_ptr<WebSocketStream> Upgrade() override {
309 return scoped_ptr<WebSocketStream>(); 315 return scoped_ptr<WebSocketStream>();
310 } 316 }
311 317
312 private: 318 private:
313 bool initialize_stream_was_called_; 319 bool initialize_stream_was_called_;
314 }; 320 };
315 321
316 TEST_F(URLRequestHttpJobWebSocketTest, RejectedWithoutCreateHelper) { 322 TEST_F(URLRequestHttpJobWebSocketTest, RejectedWithoutCreateHelper) {
(...skipping 21 matching lines...) Expand all
338 req_->SetLoadFlags(LOAD_DISABLE_CACHE); 344 req_->SetLoadFlags(LOAD_DISABLE_CACHE);
339 job->Start(); 345 job->Start();
340 base::RunLoop().RunUntilIdle(); 346 base::RunLoop().RunUntilIdle();
341 EXPECT_EQ(URLRequestStatus::IO_PENDING, req_->status().status()); 347 EXPECT_EQ(URLRequestStatus::IO_PENDING, req_->status().status());
342 EXPECT_TRUE(fake_handshake_stream->initialize_stream_was_called()); 348 EXPECT_TRUE(fake_handshake_stream->initialize_stream_was_called());
343 } 349 }
344 350
345 } // namespace 351 } // namespace
346 352
347 } // namespace net 353 } // namespace net
OLDNEW
« no previous file with comments | « net/net.gypi ('k') | net/websockets/websocket_basic_handshake_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698