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 "base/location.h" | 7 #include "base/location.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/pending_task.h" | 10 #include "base/pending_task.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 122 |
123 scoped_refptr<TransportSocketParams> transport_params_; | 123 scoped_refptr<TransportSocketParams> transport_params_; |
124 SpdySessionDependencies session_deps_; | 124 SpdySessionDependencies session_deps_; |
125 scoped_refptr<HttpNetworkSession> http_session_; | 125 scoped_refptr<HttpNetworkSession> http_session_; |
126 SpdySessionPool* spdy_session_pool_; | 126 SpdySessionPool* spdy_session_pool_; |
127 GURL test_url_; | 127 GURL test_url_; |
128 HostPortPair test_host_port_pair_; | 128 HostPortPair test_host_port_pair_; |
129 HostPortProxyPair pair_; | 129 HostPortProxyPair pair_; |
130 }; | 130 }; |
131 | 131 |
132 // Test the SpdyIOBuffer class. | |
133 TEST_F(SpdySessionSpdy3Test, SpdyIOBuffer) { | |
134 std::priority_queue<SpdyIOBuffer> queue_; | |
135 const size_t kQueueSize = 100; | |
136 | |
137 // Insert items with random priority and increasing buffer size. | |
138 for (size_t index = 0; index < kQueueSize; ++index) { | |
139 queue_.push(SpdyIOBuffer( | |
140 new IOBufferWithSize(index + 1), | |
141 index + 1, | |
142 static_cast<RequestPriority>(rand() % NUM_PRIORITIES), | |
143 NULL)); | |
144 } | |
145 | |
146 EXPECT_EQ(kQueueSize, queue_.size()); | |
147 | |
148 // Verify items come out with decreasing priority or FIFO order. | |
149 RequestPriority last_priority = NUM_PRIORITIES; | |
150 size_t last_size = 0; | |
151 for (size_t index = 0; index < kQueueSize; ++index) { | |
152 SpdyIOBuffer buffer = queue_.top(); | |
153 EXPECT_LE(buffer.priority(), last_priority); | |
154 if (buffer.priority() < last_priority) | |
155 last_size = 0; | |
156 EXPECT_LT(last_size, buffer.size()); | |
157 last_priority = buffer.priority(); | |
158 last_size = buffer.size(); | |
159 queue_.pop(); | |
160 } | |
161 | |
162 EXPECT_EQ(0u, queue_.size()); | |
163 } | |
164 | |
165 TEST_F(SpdySessionSpdy3Test, GoAway) { | 132 TEST_F(SpdySessionSpdy3Test, GoAway) { |
166 session_deps_.host_resolver->set_synchronous_mode(true); | 133 session_deps_.host_resolver->set_synchronous_mode(true); |
167 | 134 |
168 MockConnect connect_data(SYNCHRONOUS, OK); | 135 MockConnect connect_data(SYNCHRONOUS, OK); |
169 scoped_ptr<SpdyFrame> goaway(ConstructSpdyGoAway()); | 136 scoped_ptr<SpdyFrame> goaway(ConstructSpdyGoAway()); |
170 MockRead reads[] = { | 137 MockRead reads[] = { |
171 CreateMockRead(*goaway), | 138 CreateMockRead(*goaway), |
172 MockRead(SYNCHRONOUS, 0, 0) // EOF | 139 MockRead(SYNCHRONOUS, 0, 0) // EOF |
173 }; | 140 }; |
174 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); | 141 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); |
(...skipping 2799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2974 EXPECT_EQ(0, delegate1.body_data_sent()); | 2941 EXPECT_EQ(0, delegate1.body_data_sent()); |
2975 | 2942 |
2976 EXPECT_TRUE(delegate2.send_headers_completed()); | 2943 EXPECT_TRUE(delegate2.send_headers_completed()); |
2977 EXPECT_EQ("200", delegate2.GetResponseHeaderValue(":status")); | 2944 EXPECT_EQ("200", delegate2.GetResponseHeaderValue(":status")); |
2978 EXPECT_EQ("HTTP/1.1", delegate2.GetResponseHeaderValue(":version")); | 2945 EXPECT_EQ("HTTP/1.1", delegate2.GetResponseHeaderValue(":version")); |
2979 EXPECT_EQ("", delegate2.received_data()); | 2946 EXPECT_EQ("", delegate2.received_data()); |
2980 EXPECT_EQ(0, delegate2.body_data_sent()); | 2947 EXPECT_EQ(0, delegate2.body_data_sent()); |
2981 } | 2948 } |
2982 | 2949 |
2983 } // namespace net | 2950 } // namespace net |
OLD | NEW |