| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 113 |
| 114 scoped_refptr<TransportSocketParams> transport_params_; | 114 scoped_refptr<TransportSocketParams> transport_params_; |
| 115 SpdySessionDependencies session_deps_; | 115 SpdySessionDependencies session_deps_; |
| 116 scoped_refptr<HttpNetworkSession> http_session_; | 116 scoped_refptr<HttpNetworkSession> http_session_; |
| 117 SpdySessionPool* spdy_session_pool_; | 117 SpdySessionPool* spdy_session_pool_; |
| 118 GURL test_url_; | 118 GURL test_url_; |
| 119 HostPortPair test_host_port_pair_; | 119 HostPortPair test_host_port_pair_; |
| 120 HostPortProxyPair pair_; | 120 HostPortProxyPair pair_; |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 // Test the SpdyIOBuffer class. | |
| 124 TEST_F(SpdySessionSpdy3Test, SpdyIOBuffer) { | |
| 125 std::priority_queue<SpdyIOBuffer> queue_; | |
| 126 const size_t kQueueSize = 100; | |
| 127 | |
| 128 // Insert items with random priority and increasing buffer size. | |
| 129 for (size_t index = 0; index < kQueueSize; ++index) { | |
| 130 queue_.push(SpdyIOBuffer( | |
| 131 new IOBufferWithSize(index + 1), | |
| 132 index + 1, | |
| 133 static_cast<RequestPriority>(rand() % NUM_PRIORITIES), | |
| 134 NULL)); | |
| 135 } | |
| 136 | |
| 137 EXPECT_EQ(kQueueSize, queue_.size()); | |
| 138 | |
| 139 // Verify items come out with decreasing priority or FIFO order. | |
| 140 RequestPriority last_priority = NUM_PRIORITIES; | |
| 141 size_t last_size = 0; | |
| 142 for (size_t index = 0; index < kQueueSize; ++index) { | |
| 143 SpdyIOBuffer buffer = queue_.top(); | |
| 144 EXPECT_LE(buffer.priority(), last_priority); | |
| 145 if (buffer.priority() < last_priority) | |
| 146 last_size = 0; | |
| 147 EXPECT_LT(last_size, buffer.size()); | |
| 148 last_priority = buffer.priority(); | |
| 149 last_size = buffer.size(); | |
| 150 queue_.pop(); | |
| 151 } | |
| 152 | |
| 153 EXPECT_EQ(0u, queue_.size()); | |
| 154 } | |
| 155 | |
| 156 TEST_F(SpdySessionSpdy3Test, GoAway) { | 123 TEST_F(SpdySessionSpdy3Test, GoAway) { |
| 157 session_deps_.host_resolver->set_synchronous_mode(true); | 124 session_deps_.host_resolver->set_synchronous_mode(true); |
| 158 | 125 |
| 159 MockConnect connect_data(SYNCHRONOUS, OK); | 126 MockConnect connect_data(SYNCHRONOUS, OK); |
| 160 scoped_ptr<SpdyFrame> goaway(ConstructSpdyGoAway()); | 127 scoped_ptr<SpdyFrame> goaway(ConstructSpdyGoAway()); |
| 161 MockRead reads[] = { | 128 MockRead reads[] = { |
| 162 CreateMockRead(*goaway), | 129 CreateMockRead(*goaway), |
| 163 MockRead(SYNCHRONOUS, 0, 0) // EOF | 130 MockRead(SYNCHRONOUS, 0, 0) // EOF |
| 164 }; | 131 }; |
| 165 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); | 132 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); |
| (...skipping 2495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2661 EXPECT_EQ(0, delegate1.body_data_sent()); | 2628 EXPECT_EQ(0, delegate1.body_data_sent()); |
| 2662 | 2629 |
| 2663 EXPECT_TRUE(delegate2.send_headers_completed()); | 2630 EXPECT_TRUE(delegate2.send_headers_completed()); |
| 2664 EXPECT_EQ("200", delegate2.GetResponseHeaderValue(":status")); | 2631 EXPECT_EQ("200", delegate2.GetResponseHeaderValue(":status")); |
| 2665 EXPECT_EQ("HTTP/1.1", delegate2.GetResponseHeaderValue(":version")); | 2632 EXPECT_EQ("HTTP/1.1", delegate2.GetResponseHeaderValue(":version")); |
| 2666 EXPECT_EQ("", delegate2.received_data()); | 2633 EXPECT_EQ("", delegate2.received_data()); |
| 2667 EXPECT_EQ(0, delegate2.body_data_sent()); | 2634 EXPECT_EQ(0, delegate2.body_data_sent()); |
| 2668 } | 2635 } |
| 2669 | 2636 |
| 2670 } // namespace net | 2637 } // namespace net |
| OLD | NEW |