Use an asynchronous API to create QUIC stream
so that we can handle the case where the QUIC session
already has reached the max open streams limit.
BUG=266564
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/21573003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215172 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/net/quic/quic_client_session_test.cc b/net/quic/quic_client_session_test.cc
index 7f277dc..6113f45 100644
--- a/net/quic/quic_client_session_test.cc
+++ b/net/quic/quic_client_session_test.cc
@@ -84,6 +84,35 @@
EXPECT_TRUE(session_.CreateOutgoingReliableStream());
}
+TEST_F(QuicClientSessionTest, MaxNumStreamsViaRequest) {
+ if (!Aes128Gcm12Encrypter::IsSupported()) {
+ LOG(INFO) << "AES GCM not supported. Test skipped.";
+ return;
+ }
+
+ CompleteCryptoHandshake();
+
+ std::vector<QuicReliableClientStream*> streams;
+ for (size_t i = 0; i < kDefaultMaxStreamsPerConnection; i++) {
+ QuicReliableClientStream* stream = session_.CreateOutgoingReliableStream();
+ EXPECT_TRUE(stream);
+ streams.push_back(stream);
+ }
+
+ QuicReliableClientStream* stream;
+ QuicClientSession::StreamRequest stream_request;
+ TestCompletionCallback callback;
+ ASSERT_EQ(ERR_IO_PENDING,
+ stream_request.StartRequest(session_.GetWeakPtr(), &stream,
+ callback.callback()));
+
+ // Close a stream and ensure I can now open a new one.
+ session_.CloseStream(streams[0]->id());
+ ASSERT_TRUE(callback.have_result());
+ EXPECT_EQ(OK, callback.WaitForResult());
+ EXPECT_TRUE(stream != NULL);
+}
+
TEST_F(QuicClientSessionTest, GoAwayReceived) {
if (!Aes128Gcm12Encrypter::IsSupported()) {
LOG(INFO) << "AES GCM not supported. Test skipped.";