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 "net/spdy/spdy_session.h" | 5 #include "net/spdy/spdy_session.h" |
6 | 6 |
7 #include "net/base/ip_endpoint.h" | 7 #include "net/base/ip_endpoint.h" |
8 #include "net/base/net_log_unittest.h" | 8 #include "net/base/net_log_unittest.h" |
9 #include "net/base/request_priority.h" | 9 #include "net/base/request_priority.h" |
10 #include "net/base/test_data_directory.h" | 10 #include "net/base/test_data_directory.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 scoped_refptr<TransportSocketParams> transport_params_; | 97 scoped_refptr<TransportSocketParams> transport_params_; |
98 SpdySessionDependencies session_deps_; | 98 SpdySessionDependencies session_deps_; |
99 scoped_refptr<HttpNetworkSession> http_session_; | 99 scoped_refptr<HttpNetworkSession> http_session_; |
100 SpdySessionPool* spdy_session_pool_; | 100 SpdySessionPool* spdy_session_pool_; |
101 GURL test_url_; | 101 GURL test_url_; |
102 HostPortPair test_host_port_pair_; | 102 HostPortPair test_host_port_pair_; |
103 HostPortProxyPair pair_; | 103 HostPortProxyPair pair_; |
104 }; | 104 }; |
105 | 105 |
106 // Test the SpdyIOBuffer class. | |
107 TEST_F(SpdySessionSpdy2Test, SpdyIOBuffer) { | |
108 std::priority_queue<SpdyIOBuffer> queue_; | |
109 const size_t kQueueSize = 100; | |
110 | |
111 // Insert items with random priority and increasing buffer size. | |
112 for (size_t index = 0; index < kQueueSize; ++index) { | |
113 queue_.push(SpdyIOBuffer( | |
114 new IOBufferWithSize(index + 1), | |
115 index + 1, | |
116 static_cast<RequestPriority>(rand() % NUM_PRIORITIES), | |
117 NULL)); | |
118 } | |
119 | |
120 EXPECT_EQ(kQueueSize, queue_.size()); | |
121 | |
122 // Verify items come out with decreasing priority or FIFO order. | |
123 RequestPriority last_priority = NUM_PRIORITIES; | |
124 size_t last_size = 0; | |
125 for (size_t index = 0; index < kQueueSize; ++index) { | |
126 SpdyIOBuffer buffer = queue_.top(); | |
127 EXPECT_LE(buffer.priority(), last_priority); | |
128 if (buffer.priority() < last_priority) | |
129 last_size = 0; | |
130 EXPECT_LT(last_size, buffer.size()); | |
131 last_priority = buffer.priority(); | |
132 last_size = buffer.size(); | |
133 queue_.pop(); | |
134 } | |
135 | |
136 EXPECT_EQ(0u, queue_.size()); | |
137 } | |
138 | |
139 TEST_F(SpdySessionSpdy2Test, GoAway) { | 106 TEST_F(SpdySessionSpdy2Test, GoAway) { |
140 session_deps_.host_resolver->set_synchronous_mode(true); | 107 session_deps_.host_resolver->set_synchronous_mode(true); |
141 | 108 |
142 MockConnect connect_data(SYNCHRONOUS, OK); | 109 MockConnect connect_data(SYNCHRONOUS, OK); |
143 scoped_ptr<SpdyFrame> goaway(ConstructSpdyGoAway()); | 110 scoped_ptr<SpdyFrame> goaway(ConstructSpdyGoAway()); |
144 MockRead reads[] = { | 111 MockRead reads[] = { |
145 CreateMockRead(*goaway), | 112 CreateMockRead(*goaway), |
146 MockRead(SYNCHRONOUS, 0, 0) // EOF | 113 MockRead(SYNCHRONOUS, 0, 0) // EOF |
147 }; | 114 }; |
148 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); | 115 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); |
(...skipping 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1606 http_session_.get(), session.get(), test_host_port_pair_); | 1573 http_session_.get(), session.get(), test_host_port_pair_); |
1607 | 1574 |
1608 EXPECT_EQ(SpdySession::FLOW_CONTROL_NONE, session->flow_control_state()); | 1575 EXPECT_EQ(SpdySession::FLOW_CONTROL_NONE, session->flow_control_state()); |
1609 EXPECT_EQ(kSpdyVersion2, session->buffered_spdy_framer_->protocol_version()); | 1576 EXPECT_EQ(kSpdyVersion2, session->buffered_spdy_framer_->protocol_version()); |
1610 EXPECT_EQ(0, session->session_send_window_size_); | 1577 EXPECT_EQ(0, session->session_send_window_size_); |
1611 EXPECT_EQ(0, session->session_recv_window_size_); | 1578 EXPECT_EQ(0, session->session_recv_window_size_); |
1612 EXPECT_EQ(0, session->session_unacked_recv_window_bytes_); | 1579 EXPECT_EQ(0, session->session_unacked_recv_window_bytes_); |
1613 } | 1580 } |
1614 | 1581 |
1615 } // namespace net | 1582 } // namespace net |
OLD | NEW |