Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(837)

Side by Side Diff: net/spdy/spdy_session_spdy2_unittest.cc

Issue 13009012: [SPDY] Refactor SpdySession's write queue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/memory/scoped_vector.h" 8 #include "base/memory/scoped_vector.h"
9 #include "net/base/cert_test_util.h" 9 #include "net/base/cert_test_util.h"
10 #include "net/base/host_cache.h" 10 #include "net/base/host_cache.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 scoped_refptr<TransportSocketParams> transport_params_; 102 scoped_refptr<TransportSocketParams> transport_params_;
103 SpdySessionDependencies session_deps_; 103 SpdySessionDependencies session_deps_;
104 scoped_refptr<HttpNetworkSession> http_session_; 104 scoped_refptr<HttpNetworkSession> http_session_;
105 SpdySessionPool* spdy_session_pool_; 105 SpdySessionPool* spdy_session_pool_;
106 GURL test_url_; 106 GURL test_url_;
107 HostPortPair test_host_port_pair_; 107 HostPortPair test_host_port_pair_;
108 HostPortProxyPair pair_; 108 HostPortProxyPair pair_;
109 }; 109 };
110 110
111 // Test the SpdyIOBuffer class.
112 TEST_F(SpdySessionSpdy2Test, SpdyIOBuffer) {
113 std::priority_queue<SpdyIOBuffer> queue_;
114 const size_t kQueueSize = 100;
115
116 // Insert items with random priority and increasing buffer size.
117 for (size_t index = 0; index < kQueueSize; ++index) {
118 queue_.push(SpdyIOBuffer(
119 new IOBufferWithSize(index + 1),
120 index + 1,
121 static_cast<RequestPriority>(rand() % NUM_PRIORITIES),
122 NULL));
123 }
124
125 EXPECT_EQ(kQueueSize, queue_.size());
126
127 // Verify items come out with decreasing priority or FIFO order.
128 RequestPriority last_priority = NUM_PRIORITIES;
129 size_t last_size = 0;
130 for (size_t index = 0; index < kQueueSize; ++index) {
131 SpdyIOBuffer buffer = queue_.top();
132 EXPECT_LE(buffer.priority(), last_priority);
133 if (buffer.priority() < last_priority)
134 last_size = 0;
135 EXPECT_LT(last_size, buffer.size());
136 last_priority = buffer.priority();
137 last_size = buffer.size();
138 queue_.pop();
139 }
140
141 EXPECT_EQ(0u, queue_.size());
142 }
143
144 TEST_F(SpdySessionSpdy2Test, GoAway) { 111 TEST_F(SpdySessionSpdy2Test, GoAway) {
145 session_deps_.host_resolver->set_synchronous_mode(true); 112 session_deps_.host_resolver->set_synchronous_mode(true);
146 113
147 MockConnect connect_data(SYNCHRONOUS, OK); 114 MockConnect connect_data(SYNCHRONOUS, OK);
148 scoped_ptr<SpdyFrame> goaway(ConstructSpdyGoAway()); 115 scoped_ptr<SpdyFrame> goaway(ConstructSpdyGoAway());
149 MockRead reads[] = { 116 MockRead reads[] = {
150 CreateMockRead(*goaway), 117 CreateMockRead(*goaway),
151 MockRead(SYNCHRONOUS, 0, 0) // EOF 118 MockRead(SYNCHRONOUS, 0, 0) // EOF
152 }; 119 };
153 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); 120 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0);
(...skipping 1827 matching lines...) Expand 10 before | Expand all | Expand 10 after
1981 http_session_.get(), session.get(), test_host_port_pair_); 1948 http_session_.get(), session.get(), test_host_port_pair_);
1982 1949
1983 EXPECT_EQ(SpdySession::FLOW_CONTROL_NONE, session->flow_control_state()); 1950 EXPECT_EQ(SpdySession::FLOW_CONTROL_NONE, session->flow_control_state());
1984 EXPECT_EQ(kSpdyVersion2, session->buffered_spdy_framer_->protocol_version()); 1951 EXPECT_EQ(kSpdyVersion2, session->buffered_spdy_framer_->protocol_version());
1985 EXPECT_EQ(0, session->session_send_window_size_); 1952 EXPECT_EQ(0, session->session_send_window_size_);
1986 EXPECT_EQ(0, session->session_recv_window_size_); 1953 EXPECT_EQ(0, session->session_recv_window_size_);
1987 EXPECT_EQ(0, session->session_unacked_recv_window_bytes_); 1954 EXPECT_EQ(0, session->session_unacked_recv_window_bytes_);
1988 } 1955 }
1989 1956
1990 } // namespace net 1957 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698