OLD | NEW |
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 "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 #include "net/base/completion_callback.h" | 6 #include "net/base/completion_callback.h" |
7 #include "net/base/net_log_unittest.h" | 7 #include "net/base/net_log_unittest.h" |
8 #include "net/spdy/buffered_spdy_framer.h" | 8 #include "net/spdy/buffered_spdy_framer.h" |
9 #include "net/spdy/spdy_stream.h" | 9 #include "net/spdy/spdy_stream.h" |
10 #include "net/spdy/spdy_http_utils.h" | 10 #include "net/spdy/spdy_http_utils.h" |
11 #include "net/spdy/spdy_session.h" | 11 #include "net/spdy/spdy_session.h" |
12 #include "net/spdy/spdy_stream_test_util.h" | 12 #include "net/spdy/spdy_stream_test_util.h" |
13 #include "net/spdy/spdy_test_util_spdy2.h" | 13 #include "net/spdy/spdy_test_util_spdy2.h" |
| 14 #include "net/spdy/spdy_websocket_test_util_spdy2.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 | 16 |
16 using namespace net::test_spdy2; | 17 using namespace net::test_spdy2; |
17 | 18 |
18 // TODO(ukai): factor out common part with spdy_http_stream_unittest.cc | 19 // TODO(ukai): factor out common part with spdy_http_stream_unittest.cc |
19 // | 20 // |
20 namespace net { | 21 namespace net { |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 EXPECT_EQ(8, delegate->data_sent()); | 173 EXPECT_EQ(8, delegate->data_sent()); |
173 EXPECT_TRUE(delegate->closed()); | 174 EXPECT_TRUE(delegate->closed()); |
174 } | 175 } |
175 | 176 |
176 TEST_F(SpdyStreamSpdy2Test, SendHeaderAndDataAfterOpen) { | 177 TEST_F(SpdyStreamSpdy2Test, SendHeaderAndDataAfterOpen) { |
177 SpdySessionDependencies session_deps; | 178 SpdySessionDependencies session_deps; |
178 | 179 |
179 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps); | 180 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps); |
180 SpdySessionPoolPeer pool_peer_(session_->spdy_session_pool()); | 181 SpdySessionPoolPeer pool_peer_(session_->spdy_session_pool()); |
181 | 182 |
182 scoped_ptr<SpdyFrame> expected_request(ConstructSpdyWebSocket( | 183 scoped_ptr<SpdyFrame> expected_request(ConstructSpdyWebSocketSynStream( |
183 1, | 184 1, |
184 "/chat", | 185 "/chat", |
185 "server.example.com", | 186 "server.example.com", |
186 "http://example.com")); | 187 "http://example.com")); |
187 scoped_ptr<SpdyFrame> expected_headers(ConstructSpdyWebSocketHeadersFrame( | 188 scoped_ptr<SpdyFrame> expected_headers(ConstructSpdyWebSocketHeadersFrame( |
188 1, "6", true)); | 189 1, "6", true)); |
189 scoped_ptr<SpdyFrame> expected_message(ConstructSpdyBodyFrame("hello!", 6)); | 190 scoped_ptr<SpdyFrame> expected_message(ConstructSpdyBodyFrame("hello!", 6)); |
190 MockWrite writes[] = { | 191 MockWrite writes[] = { |
191 CreateMockWrite(*expected_request), | 192 CreateMockWrite(*expected_request), |
192 CreateMockWrite(*expected_headers), | 193 CreateMockWrite(*expected_headers), |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 EXPECT_EQ(OK, connection->Init(host_port_pair.ToString(), transport_params, | 226 EXPECT_EQ(OK, connection->Init(host_port_pair.ToString(), transport_params, |
226 LOWEST, CompletionCallback(), | 227 LOWEST, CompletionCallback(), |
227 session_->GetTransportSocketPool( | 228 session_->GetTransportSocketPool( |
228 HttpNetworkSession::NORMAL_SOCKET_POOL), | 229 HttpNetworkSession::NORMAL_SOCKET_POOL), |
229 BoundNetLog())); | 230 BoundNetLog())); |
230 session->InitializeWithSocket(connection.release(), false, OK); | 231 session->InitializeWithSocket(connection.release(), false, OK); |
231 | 232 |
232 scoped_refptr<SpdyStream> stream; | 233 scoped_refptr<SpdyStream> stream; |
233 ASSERT_EQ( | 234 ASSERT_EQ( |
234 OK, | 235 OK, |
235 session->CreateStream(url, LOWEST, &stream, BoundNetLog(), | 236 session->CreateStream(url, HIGHEST, &stream, BoundNetLog(), |
236 CompletionCallback())); | 237 CompletionCallback())); |
237 scoped_refptr<IOBufferWithSize> buf(new IOBufferWithSize(6)); | 238 scoped_refptr<IOBufferWithSize> buf(new IOBufferWithSize(6)); |
238 memcpy(buf->data(), "hello!", 6); | 239 memcpy(buf->data(), "hello!", 6); |
239 TestCompletionCallback callback; | 240 TestCompletionCallback callback; |
240 scoped_ptr<SpdyHeaderBlock> message_headers(new SpdyHeaderBlock); | 241 scoped_ptr<SpdyHeaderBlock> message_headers(new SpdyHeaderBlock); |
241 (*message_headers)["opcode"] = "1"; | 242 (*message_headers)["opcode"] = "1"; |
242 (*message_headers)["length"] = "6"; | 243 (*message_headers)["length"] = "6"; |
243 (*message_headers)["fin"] = "1"; | 244 (*message_headers)["fin"] = "1"; |
244 | 245 |
245 scoped_ptr<TestSpdyStreamDelegate> delegate( | 246 scoped_ptr<TestSpdyStreamDelegate> delegate( |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 net::NetLog::PHASE_NONE); | 460 net::NetLog::PHASE_NONE); |
460 | 461 |
461 int stream_id2; | 462 int stream_id2; |
462 ASSERT_TRUE(entries[pos].GetIntegerValue("stream_id", &stream_id2)); | 463 ASSERT_TRUE(entries[pos].GetIntegerValue("stream_id", &stream_id2)); |
463 EXPECT_EQ(static_cast<int>(stream_id), stream_id2); | 464 EXPECT_EQ(static_cast<int>(stream_id), stream_id2); |
464 } | 465 } |
465 | 466 |
466 } //namespace test | 467 } //namespace test |
467 | 468 |
468 } // namespace net | 469 } // namespace net |
OLD | NEW |