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_spdy3.h" | 13 #include "net/spdy/spdy_test_util_spdy3.h" |
| 14 #include "net/spdy/spdy_websocket_test_util_spdy3.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 | 16 |
16 using namespace net::test_spdy3; | 17 using namespace net::test_spdy3; |
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 EXPECT_EQ(8, delegate->data_sent()); | 174 EXPECT_EQ(8, delegate->data_sent()); |
174 EXPECT_TRUE(delegate->closed()); | 175 EXPECT_TRUE(delegate->closed()); |
175 } | 176 } |
176 | 177 |
177 TEST_F(SpdyStreamSpdy3Test, SendHeaderAndDataAfterOpen) { | 178 TEST_F(SpdyStreamSpdy3Test, SendHeaderAndDataAfterOpen) { |
178 SpdySessionDependencies session_deps; | 179 SpdySessionDependencies session_deps; |
179 | 180 |
180 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps); | 181 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps); |
181 SpdySessionPoolPeer pool_peer_(session_->spdy_session_pool()); | 182 SpdySessionPoolPeer pool_peer_(session_->spdy_session_pool()); |
182 | 183 |
183 scoped_ptr<SpdyFrame> expected_request(ConstructSpdyWebSocket( | 184 scoped_ptr<SpdyFrame> expected_request(ConstructSpdyWebSocketSynStream( |
184 1, | 185 1, |
185 "/chat", | 186 "/chat", |
186 "server.example.com", | 187 "server.example.com", |
187 "http://example.com")); | 188 "http://example.com")); |
188 scoped_ptr<SpdyFrame> expected_headers(ConstructSpdyWebSocketHeadersFrame( | 189 scoped_ptr<SpdyFrame> expected_headers(ConstructSpdyWebSocketHeadersFrame( |
189 1, "6", true)); | 190 1, "6", true)); |
190 scoped_ptr<SpdyFrame> expected_message(ConstructSpdyBodyFrame("hello!", 6)); | 191 scoped_ptr<SpdyFrame> expected_message(ConstructSpdyBodyFrame("hello!", 6)); |
191 MockWrite writes[] = { | 192 MockWrite writes[] = { |
192 CreateMockWrite(*expected_request), | 193 CreateMockWrite(*expected_request), |
193 CreateMockWrite(*expected_headers), | 194 CreateMockWrite(*expected_headers), |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 EXPECT_EQ(OK, connection->Init(host_port_pair.ToString(), transport_params, | 227 EXPECT_EQ(OK, connection->Init(host_port_pair.ToString(), transport_params, |
227 LOWEST, CompletionCallback(), | 228 LOWEST, CompletionCallback(), |
228 session_->GetTransportSocketPool( | 229 session_->GetTransportSocketPool( |
229 HttpNetworkSession::NORMAL_SOCKET_POOL), | 230 HttpNetworkSession::NORMAL_SOCKET_POOL), |
230 BoundNetLog())); | 231 BoundNetLog())); |
231 session->InitializeWithSocket(connection.release(), false, OK); | 232 session->InitializeWithSocket(connection.release(), false, OK); |
232 | 233 |
233 scoped_refptr<SpdyStream> stream; | 234 scoped_refptr<SpdyStream> stream; |
234 ASSERT_EQ( | 235 ASSERT_EQ( |
235 OK, | 236 OK, |
236 session->CreateStream(url, LOWEST, &stream, BoundNetLog(), | 237 session->CreateStream(url, HIGHEST, &stream, BoundNetLog(), |
237 CompletionCallback())); | 238 CompletionCallback())); |
238 scoped_refptr<IOBufferWithSize> buf(new IOBufferWithSize(6)); | 239 scoped_refptr<IOBufferWithSize> buf(new IOBufferWithSize(6)); |
239 memcpy(buf->data(), "hello!", 6); | 240 memcpy(buf->data(), "hello!", 6); |
240 TestCompletionCallback callback; | 241 TestCompletionCallback callback; |
241 scoped_ptr<SpdyHeaderBlock> message_headers(new SpdyHeaderBlock); | 242 scoped_ptr<SpdyHeaderBlock> message_headers(new SpdyHeaderBlock); |
242 (*message_headers)[":opcode"] = "1"; | 243 (*message_headers)[":opcode"] = "1"; |
243 (*message_headers)[":length"] = "6"; | 244 (*message_headers)[":length"] = "6"; |
244 (*message_headers)[":fin"] = "1"; | 245 (*message_headers)[":fin"] = "1"; |
245 | 246 |
246 scoped_ptr<TestSpdyStreamDelegate> delegate( | 247 scoped_ptr<TestSpdyStreamDelegate> delegate( |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 net::NetLog::PHASE_NONE); | 465 net::NetLog::PHASE_NONE); |
465 | 466 |
466 int stream_id2; | 467 int stream_id2; |
467 ASSERT_TRUE(entries[pos].GetIntegerValue("stream_id", &stream_id2)); | 468 ASSERT_TRUE(entries[pos].GetIntegerValue("stream_id", &stream_id2)); |
468 EXPECT_EQ(static_cast<int>(stream_id), stream_id2); | 469 EXPECT_EQ(static_cast<int>(stream_id), stream_id2); |
469 } | 470 } |
470 | 471 |
471 } // namespace test | 472 } // namespace test |
472 | 473 |
473 } // namespace net | 474 } // namespace net |
OLD | NEW |