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

Side by Side Diff: net/quic/quic_client_session_test.cc

Issue 100173005: Break out the basic reliable QUIC stream functionality from the (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
« no previous file with comments | « net/quic/quic_client_session.cc ('k') | net/quic/quic_crypto_client_stream_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/quic/quic_client_session.h" 5 #include "net/quic/quic_client_session.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/rand_util.h" 9 #include "base/rand_util.h"
10 #include "net/base/capturing_net_log.h" 10 #include "net/base/capturing_net_log.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 109
110 TEST_F(QuicClientSessionTest, CryptoConnect) { 110 TEST_F(QuicClientSessionTest, CryptoConnect) {
111 CompleteCryptoHandshake(); 111 CompleteCryptoHandshake();
112 } 112 }
113 113
114 TEST_F(QuicClientSessionTest, MaxNumStreams) { 114 TEST_F(QuicClientSessionTest, MaxNumStreams) {
115 CompleteCryptoHandshake(); 115 CompleteCryptoHandshake();
116 116
117 std::vector<QuicReliableClientStream*> streams; 117 std::vector<QuicReliableClientStream*> streams;
118 for (size_t i = 0; i < kDefaultMaxStreamsPerConnection; i++) { 118 for (size_t i = 0; i < kDefaultMaxStreamsPerConnection; i++) {
119 QuicReliableClientStream* stream = session_.CreateOutgoingReliableStream(); 119 QuicReliableClientStream* stream = session_.CreateOutgoingDataStream();
120 EXPECT_TRUE(stream); 120 EXPECT_TRUE(stream);
121 streams.push_back(stream); 121 streams.push_back(stream);
122 } 122 }
123 EXPECT_FALSE(session_.CreateOutgoingReliableStream()); 123 EXPECT_FALSE(session_.CreateOutgoingDataStream());
124 124
125 // Close a stream and ensure I can now open a new one. 125 // Close a stream and ensure I can now open a new one.
126 session_.CloseStream(streams[0]->id()); 126 session_.CloseStream(streams[0]->id());
127 EXPECT_TRUE(session_.CreateOutgoingReliableStream()); 127 EXPECT_TRUE(session_.CreateOutgoingDataStream());
128 } 128 }
129 129
130 TEST_F(QuicClientSessionTest, MaxNumStreamsViaRequest) { 130 TEST_F(QuicClientSessionTest, MaxNumStreamsViaRequest) {
131 CompleteCryptoHandshake(); 131 CompleteCryptoHandshake();
132 132
133 std::vector<QuicReliableClientStream*> streams; 133 std::vector<QuicReliableClientStream*> streams;
134 for (size_t i = 0; i < kDefaultMaxStreamsPerConnection; i++) { 134 for (size_t i = 0; i < kDefaultMaxStreamsPerConnection; i++) {
135 QuicReliableClientStream* stream = session_.CreateOutgoingReliableStream(); 135 QuicReliableClientStream* stream = session_.CreateOutgoingDataStream();
136 EXPECT_TRUE(stream); 136 EXPECT_TRUE(stream);
137 streams.push_back(stream); 137 streams.push_back(stream);
138 } 138 }
139 139
140 QuicReliableClientStream* stream; 140 QuicReliableClientStream* stream;
141 QuicClientSession::StreamRequest stream_request; 141 QuicClientSession::StreamRequest stream_request;
142 TestCompletionCallback callback; 142 TestCompletionCallback callback;
143 ASSERT_EQ(ERR_IO_PENDING, 143 ASSERT_EQ(ERR_IO_PENDING,
144 stream_request.StartRequest(session_.GetWeakPtr(), &stream, 144 stream_request.StartRequest(session_.GetWeakPtr(), &stream,
145 callback.callback())); 145 callback.callback()));
146 146
147 // Close a stream and ensure I can now open a new one. 147 // Close a stream and ensure I can now open a new one.
148 session_.CloseStream(streams[0]->id()); 148 session_.CloseStream(streams[0]->id());
149 ASSERT_TRUE(callback.have_result()); 149 ASSERT_TRUE(callback.have_result());
150 EXPECT_EQ(OK, callback.WaitForResult()); 150 EXPECT_EQ(OK, callback.WaitForResult());
151 EXPECT_TRUE(stream != NULL); 151 EXPECT_TRUE(stream != NULL);
152 } 152 }
153 153
154 TEST_F(QuicClientSessionTest, GoAwayReceived) { 154 TEST_F(QuicClientSessionTest, GoAwayReceived) {
155 CompleteCryptoHandshake(); 155 CompleteCryptoHandshake();
156 156
157 // After receiving a GoAway, I should no longer be able to create outgoing 157 // After receiving a GoAway, I should no longer be able to create outgoing
158 // streams. 158 // streams.
159 session_.OnGoAway(QuicGoAwayFrame(QUIC_PEER_GOING_AWAY, 1u, "Going away.")); 159 session_.OnGoAway(QuicGoAwayFrame(QUIC_PEER_GOING_AWAY, 1u, "Going away."));
160 EXPECT_EQ(NULL, session_.CreateOutgoingReliableStream()); 160 EXPECT_EQ(NULL, session_.CreateOutgoingDataStream());
161 } 161 }
162 162
163 } // namespace 163 } // namespace
164 } // namespace test 164 } // namespace test
165 } // namespace net 165 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_client_session.cc ('k') | net/quic/quic_crypto_client_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698