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

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

Issue 9817014: Created a new class SpdyTestStateHelper to serve as a helper to manage the state of a number of SPD… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add TODO Created 8 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 6
7 #include "crypto/ec_private_key.h" 7 #include "crypto/ec_private_key.h"
8 #include "crypto/ec_signature_creator.h" 8 #include "crypto/ec_signature_creator.h"
9 #include "crypto/signature_creator.h" 9 #include "crypto/signature_creator.h"
10 #include "net/base/asn1_util.h" 10 #include "net/base/asn1_util.h"
11 #include "net/base/default_origin_bound_cert_store.h" 11 #include "net/base/default_origin_bound_cert_store.h"
12 #include "net/http/http_response_headers.h" 12 #include "net/http/http_response_headers.h"
13 #include "net/http/http_response_info.h" 13 #include "net/http/http_response_info.h"
14 #include "net/spdy/spdy_session.h" 14 #include "net/spdy/spdy_session.h"
15 #include "net/spdy/spdy_test_util_spdy2.h" 15 #include "net/spdy/spdy_test_util_spdy2.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 using namespace net::test_spdy2; 18 using namespace net::test_spdy2;
19 19
20 namespace net { 20 namespace net {
21 21
22 class SpdyHttpStreamSpdy2Test : public testing::Test { 22 class SpdyHttpStreamSpdy2Test : public testing::Test {
23 public: 23 public:
24 OrderedSocketData* data() { return data_.get(); } 24 OrderedSocketData* data() { return data_.get(); }
25 protected: 25 protected:
26 SpdyHttpStreamSpdy2Test() {} 26 SpdyHttpStreamSpdy2Test() {}
27 27
28 void EnableCompression(bool enabled) {
29 spdy::SpdyFramer::set_enable_compression_default(enabled);
30 }
31
32 virtual void SetUp() { 28 virtual void SetUp() {
33 SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY2); 29 SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY2);
34 } 30 }
35 31
36 virtual void TearDown() { 32 virtual void TearDown() {
37 crypto::ECSignatureCreator::SetFactoryForTesting(NULL); 33 crypto::ECSignatureCreator::SetFactoryForTesting(NULL);
38 MessageLoop::current()->RunAllPending(); 34 MessageLoop::current()->RunAllPending();
39 } 35 }
40 36
41 int InitSession(MockRead* reads, size_t reads_count, 37 int InitSession(MockRead* reads, size_t reads_count,
(...skipping 19 matching lines...) Expand all
61 BoundNetLog())); 57 BoundNetLog()));
62 EXPECT_EQ(OK, callback.WaitForResult()); 58 EXPECT_EQ(OK, callback.WaitForResult());
63 return session_->InitializeWithSocket(connection.release(), false, OK); 59 return session_->InitializeWithSocket(connection.release(), false, OK);
64 } 60 }
65 61
66 SpdySessionDependencies session_deps_; 62 SpdySessionDependencies session_deps_;
67 scoped_ptr<OrderedSocketData> data_; 63 scoped_ptr<OrderedSocketData> data_;
68 scoped_refptr<HttpNetworkSession> http_session_; 64 scoped_refptr<HttpNetworkSession> http_session_;
69 scoped_refptr<SpdySession> session_; 65 scoped_refptr<SpdySession> session_;
70 scoped_refptr<TransportSocketParams> transport_params_; 66 scoped_refptr<TransportSocketParams> transport_params_;
67
68 private:
69 SpdyTestStateHelper spdy_state_;
71 }; 70 };
72 71
73 TEST_F(SpdyHttpStreamSpdy2Test, SendRequest) { 72 TEST_F(SpdyHttpStreamSpdy2Test, SendRequest) {
74 EnableCompression(false);
75
76 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 73 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
77 MockWrite writes[] = { 74 MockWrite writes[] = {
78 CreateMockWrite(*req.get(), 1), 75 CreateMockWrite(*req.get(), 1),
79 }; 76 };
80 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); 77 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
81 MockRead reads[] = { 78 MockRead reads[] = {
82 CreateMockRead(*resp, 2), 79 CreateMockRead(*resp, 2),
83 MockRead(SYNCHRONOUS, 0, 3) // EOF 80 MockRead(SYNCHRONOUS, 0, 3) // EOF
84 }; 81 };
85 82
(...skipping 26 matching lines...) Expand all
112 data()->CompleteRead(); 109 data()->CompleteRead();
113 110
114 // Because we abandoned the stream, we don't expect to find a session in the 111 // Because we abandoned the stream, we don't expect to find a session in the
115 // pool anymore. 112 // pool anymore.
116 EXPECT_FALSE(http_session_->spdy_session_pool()->HasSession(pair)); 113 EXPECT_FALSE(http_session_->spdy_session_pool()->HasSession(pair));
117 EXPECT_TRUE(data()->at_read_eof()); 114 EXPECT_TRUE(data()->at_read_eof());
118 EXPECT_TRUE(data()->at_write_eof()); 115 EXPECT_TRUE(data()->at_write_eof());
119 } 116 }
120 117
121 TEST_F(SpdyHttpStreamSpdy2Test, SendChunkedPost) { 118 TEST_F(SpdyHttpStreamSpdy2Test, SendChunkedPost) {
122 EnableCompression(false);
123 UploadDataStream::set_merge_chunks(false); 119 UploadDataStream::set_merge_chunks(false);
124 120
125 scoped_ptr<spdy::SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0)); 121 scoped_ptr<spdy::SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0));
126 scoped_ptr<spdy::SpdyFrame> chunk1(ConstructSpdyBodyFrame(1, false)); 122 scoped_ptr<spdy::SpdyFrame> chunk1(ConstructSpdyBodyFrame(1, false));
127 scoped_ptr<spdy::SpdyFrame> chunk2(ConstructSpdyBodyFrame(1, true)); 123 scoped_ptr<spdy::SpdyFrame> chunk2(ConstructSpdyBodyFrame(1, true));
128 MockWrite writes[] = { 124 MockWrite writes[] = {
129 CreateMockWrite(*req.get(), 1), 125 CreateMockWrite(*req.get(), 1),
130 CreateMockWrite(*chunk1, 2), // POST upload frames 126 CreateMockWrite(*chunk1, 2), // POST upload frames
131 CreateMockWrite(*chunk2, 3), 127 CreateMockWrite(*chunk2, 3),
132 }; 128 };
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 171
176 // Because we abandoned the stream, we don't expect to find a session in the 172 // Because we abandoned the stream, we don't expect to find a session in the
177 // pool anymore. 173 // pool anymore.
178 EXPECT_FALSE(http_session_->spdy_session_pool()->HasSession(pair)); 174 EXPECT_FALSE(http_session_->spdy_session_pool()->HasSession(pair));
179 EXPECT_TRUE(data()->at_read_eof()); 175 EXPECT_TRUE(data()->at_read_eof());
180 EXPECT_TRUE(data()->at_write_eof()); 176 EXPECT_TRUE(data()->at_write_eof());
181 } 177 }
182 178
183 // Test case for bug: http://code.google.com/p/chromium/issues/detail?id=50058 179 // Test case for bug: http://code.google.com/p/chromium/issues/detail?id=50058
184 TEST_F(SpdyHttpStreamSpdy2Test, SpdyURLTest) { 180 TEST_F(SpdyHttpStreamSpdy2Test, SpdyURLTest) {
185 EnableCompression(false);
186
187 const char * const full_url = "http://www.google.com/foo?query=what#anchor"; 181 const char * const full_url = "http://www.google.com/foo?query=what#anchor";
188 const char * const base_url = "http://www.google.com/foo?query=what"; 182 const char * const base_url = "http://www.google.com/foo?query=what";
189 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(base_url, false, 1, LOWEST)); 183 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(base_url, false, 1, LOWEST));
190 MockWrite writes[] = { 184 MockWrite writes[] = {
191 CreateMockWrite(*req.get(), 1), 185 CreateMockWrite(*req.get(), 1),
192 }; 186 };
193 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); 187 scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1));
194 MockRead reads[] = { 188 MockRead reads[] = {
195 CreateMockRead(*resp, 2), 189 CreateMockRead(*resp, 2),
196 MockRead(SYNCHRONOUS, 0, 3) // EOF 190 MockRead(SYNCHRONOUS, 0, 3) // EOF
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 // pool anymore. 228 // pool anymore.
235 EXPECT_FALSE(http_session_->spdy_session_pool()->HasSession(pair)); 229 EXPECT_FALSE(http_session_->spdy_session_pool()->HasSession(pair));
236 EXPECT_TRUE(data()->at_read_eof()); 230 EXPECT_TRUE(data()->at_read_eof());
237 EXPECT_TRUE(data()->at_write_eof()); 231 EXPECT_TRUE(data()->at_write_eof());
238 } 232 }
239 233
240 // TODO(willchan): Write a longer test for SpdyStream that exercises all 234 // TODO(willchan): Write a longer test for SpdyStream that exercises all
241 // methods. 235 // methods.
242 236
243 } // namespace net 237 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/buffered_spdy_framer_spdy3_unittest.cc ('k') | net/spdy/spdy_http_stream_spdy3_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698