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

Side by Side Diff: net/spdy/spdy_http_stream_unittest.cc

Issue 3197018: Refactor: change the spdy session pool key to take a ProxyServer instead of a stri... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 months 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 | Annotate | Revision Log
« no previous file with comments | « net/proxy/proxy_server_unittest.cc ('k') | net/spdy/spdy_network_transaction_unittest.cc » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/spdy/spdy_http_stream.h" 5 #include "net/spdy/spdy_http_stream.h"
6 #include "net/spdy/spdy_session.h" 6 #include "net/spdy/spdy_session.h"
7 #include "net/spdy/spdy_test_util.h" 7 #include "net/spdy/spdy_test_util.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace net { 10 namespace net {
11 11
12 class SpdyHttpStreamTest : public testing::Test { 12 class SpdyHttpStreamTest : public testing::Test {
13 public: 13 public:
14 OrderedSocketData* data() { return data_; } 14 OrderedSocketData* data() { return data_; }
15 protected: 15 protected:
16 SpdyHttpStreamTest() {} 16 SpdyHttpStreamTest() {}
17 17
18 void EnableCompression(bool enabled) { 18 void EnableCompression(bool enabled) {
19 spdy::SpdyFramer::set_enable_compression_default(enabled); 19 spdy::SpdyFramer::set_enable_compression_default(enabled);
20 } 20 }
21 21
22 virtual void TearDown() { 22 virtual void TearDown() {
23 MessageLoop::current()->RunAllPending(); 23 MessageLoop::current()->RunAllPending();
24 } 24 }
25 int InitSession(MockRead* reads, size_t reads_count, 25 int InitSession(MockRead* reads, size_t reads_count,
26 MockWrite* writes, size_t writes_count, 26 MockWrite* writes, size_t writes_count,
27 HostPortPair& host_port_pair) { 27 HostPortPair& host_port_pair) {
28 HostPortProxyPair pair(host_port_pair, ""); 28 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct());
29 data_ = new OrderedSocketData(reads, reads_count, writes, writes_count); 29 data_ = new OrderedSocketData(reads, reads_count, writes, writes_count);
30 session_deps_.socket_factory->AddSocketDataProvider(data_.get()); 30 session_deps_.socket_factory->AddSocketDataProvider(data_.get());
31 http_session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_); 31 http_session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_);
32 session_ = http_session_->spdy_session_pool()-> 32 session_ = http_session_->spdy_session_pool()->
33 Get(pair, http_session_.get(), BoundNetLog()); 33 Get(pair, http_session_.get(), BoundNetLog());
34 tcp_params_ = new TCPSocketParams(host_port_pair.host(), 34 tcp_params_ = new TCPSocketParams(host_port_pair.host(),
35 host_port_pair.port(), 35 host_port_pair.port(),
36 MEDIUM, GURL(), false); 36 MEDIUM, GURL(), false);
37 return session_->Connect(host_port_pair.host(), tcp_params_, MEDIUM); 37 return session_->Connect(host_port_pair.host(), tcp_params_, MEDIUM);
38 } 38 }
(...skipping 12 matching lines...) Expand all
51 MockWrite writes[] = { 51 MockWrite writes[] = {
52 CreateMockWrite(*req.get(), 1), 52 CreateMockWrite(*req.get(), 1),
53 }; 53 };
54 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); 54 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
55 MockRead reads[] = { 55 MockRead reads[] = {
56 CreateMockRead(*resp, 2), 56 CreateMockRead(*resp, 2),
57 MockRead(false, 0, 3) // EOF 57 MockRead(false, 0, 3) // EOF
58 }; 58 };
59 59
60 HostPortPair host_port_pair("www.google.com", 80); 60 HostPortPair host_port_pair("www.google.com", 80);
61 HostPortProxyPair pair(host_port_pair, ""); 61 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct());
62 EXPECT_EQ(OK, InitSession(reads, arraysize(reads), writes, arraysize(writes), 62 EXPECT_EQ(OK, InitSession(reads, arraysize(reads), writes, arraysize(writes),
63 host_port_pair)); 63 host_port_pair));
64 64
65 HttpRequestInfo request; 65 HttpRequestInfo request;
66 request.method = "GET"; 66 request.method = "GET";
67 request.url = GURL("http://www.google.com/"); 67 request.url = GURL("http://www.google.com/");
68 TestCompletionCallback callback; 68 TestCompletionCallback callback;
69 HttpResponseInfo response; 69 HttpResponseInfo response;
70 BoundNetLog net_log; 70 BoundNetLog net_log;
71 scoped_ptr<SpdyHttpStream> http_stream(new SpdyHttpStream(session_.get())); 71 scoped_ptr<SpdyHttpStream> http_stream(new SpdyHttpStream(session_.get()));
(...skipping 29 matching lines...) Expand all
101 MockWrite writes[] = { 101 MockWrite writes[] = {
102 CreateMockWrite(*req.get(), 1), 102 CreateMockWrite(*req.get(), 1),
103 }; 103 };
104 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); 104 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
105 MockRead reads[] = { 105 MockRead reads[] = {
106 CreateMockRead(*resp, 2), 106 CreateMockRead(*resp, 2),
107 MockRead(false, 0, 3) // EOF 107 MockRead(false, 0, 3) // EOF
108 }; 108 };
109 109
110 HostPortPair host_port_pair("www.google.com", 80); 110 HostPortPair host_port_pair("www.google.com", 80);
111 HostPortProxyPair pair(host_port_pair, ""); 111 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct());
112 EXPECT_EQ(OK, InitSession(reads, arraysize(reads), writes, arraysize(writes), 112 EXPECT_EQ(OK, InitSession(reads, arraysize(reads), writes, arraysize(writes),
113 host_port_pair)); 113 host_port_pair));
114 114
115 HttpRequestInfo request; 115 HttpRequestInfo request;
116 request.method = "GET"; 116 request.method = "GET";
117 request.url = GURL(full_url); 117 request.url = GURL(full_url);
118 TestCompletionCallback callback; 118 TestCompletionCallback callback;
119 HttpResponseInfo response; 119 HttpResponseInfo response;
120 BoundNetLog net_log; 120 BoundNetLog net_log;
121 scoped_ptr<SpdyHttpStream> http_stream(new SpdyHttpStream(session_)); 121 scoped_ptr<SpdyHttpStream> http_stream(new SpdyHttpStream(session_));
(...skipping 22 matching lines...) Expand all
144 // pool anymore. 144 // pool anymore.
145 EXPECT_TRUE(!http_session_->spdy_session_pool()->HasSession(pair)); 145 EXPECT_TRUE(!http_session_->spdy_session_pool()->HasSession(pair));
146 EXPECT_TRUE(data()->at_read_eof()); 146 EXPECT_TRUE(data()->at_read_eof());
147 EXPECT_TRUE(data()->at_write_eof()); 147 EXPECT_TRUE(data()->at_write_eof());
148 } 148 }
149 149
150 // TODO(willchan): Write a longer test for SpdyStream that exercises all 150 // TODO(willchan): Write a longer test for SpdyStream that exercises all
151 // methods. 151 // methods.
152 152
153 } // namespace net 153 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_server_unittest.cc ('k') | net/spdy/spdy_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698