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 "net/spdy/spdy_websocket_test_util_spdy2.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 using namespace net::test_spdy2; | 17 using namespace net::test_spdy2; |
18 | 18 |
19 // 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 |
20 // | 20 // |
21 namespace net { | 21 namespace net { |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 SpdyFrame* ConstructSpdyBodyFrame(const char* data, int length) { | 25 SpdyFrame* ConstructSpdyBodyFrame(const char* data, int length) { |
26 BufferedSpdyFramer framer(2); | 26 BufferedSpdyFramer framer(2, false); |
27 return framer.CreateDataFrame(1, data, length, DATA_FLAG_NONE); | 27 return framer.CreateDataFrame(1, data, length, DATA_FLAG_NONE); |
28 } | 28 } |
29 | 29 |
30 } // anonymous namespace | 30 } // anonymous namespace |
31 | 31 |
32 namespace test { | 32 namespace test { |
33 | 33 |
34 class SpdyStreamSpdy2Test : public testing::Test { | 34 class SpdyStreamSpdy2Test : public testing::Test { |
35 protected: | 35 protected: |
36 SpdyStreamSpdy2Test() { | 36 SpdyStreamSpdy2Test() { |
37 } | 37 } |
38 | 38 |
39 scoped_refptr<SpdySession> CreateSpdySession() { | 39 scoped_refptr<SpdySession> CreateSpdySession() { |
40 HostPortPair host_port_pair("www.google.com", 80); | 40 HostPortPair host_port_pair("www.google.com", 80); |
41 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); | 41 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); |
42 scoped_refptr<SpdySession> session( | 42 scoped_refptr<SpdySession> session( |
43 session_->spdy_session_pool()->Get(pair, BoundNetLog())); | 43 session_->spdy_session_pool()->Get(pair, BoundNetLog())); |
44 return session; | 44 return session; |
45 } | 45 } |
46 | 46 |
47 virtual void SetUp() { | |
48 SpdySession::set_default_protocol(kProtoSPDY2); | |
49 } | |
50 | |
51 virtual void TearDown() { | 47 virtual void TearDown() { |
52 MessageLoop::current()->RunUntilIdle(); | 48 MessageLoop::current()->RunUntilIdle(); |
53 } | 49 } |
54 | 50 |
55 scoped_refptr<HttpNetworkSession> session_; | 51 scoped_refptr<HttpNetworkSession> session_; |
56 | |
57 private: | |
58 SpdyTestStateHelper spdy_state_; | |
59 }; | 52 }; |
60 | 53 |
61 TEST_F(SpdyStreamSpdy2Test, SendDataAfterOpen) { | 54 TEST_F(SpdyStreamSpdy2Test, SendDataAfterOpen) { |
62 SpdySessionDependencies session_deps; | 55 SpdySessionDependencies session_deps; |
63 | 56 |
64 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps); | 57 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps); |
65 SpdySessionPoolPeer pool_peer_(session_->spdy_session_pool()); | 58 SpdySessionPoolPeer pool_peer_(session_->spdy_session_pool()); |
66 | 59 |
67 const SpdyHeaderInfo kSynStartHeader = { | 60 const SpdyHeaderInfo kSynStartHeader = { |
68 SYN_STREAM, | 61 SYN_STREAM, |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 net::NetLog::PHASE_NONE); | 453 net::NetLog::PHASE_NONE); |
461 | 454 |
462 int stream_id2; | 455 int stream_id2; |
463 ASSERT_TRUE(entries[pos].GetIntegerValue("stream_id", &stream_id2)); | 456 ASSERT_TRUE(entries[pos].GetIntegerValue("stream_id", &stream_id2)); |
464 EXPECT_EQ(static_cast<int>(stream_id), stream_id2); | 457 EXPECT_EQ(static_cast<int>(stream_id), stream_id2); |
465 } | 458 } |
466 | 459 |
467 } //namespace test | 460 } //namespace test |
468 | 461 |
469 } // namespace net | 462 } // namespace net |
OLD | NEW |