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

Unified Diff: net/quic/quic_client_session_test.cc

Issue 11364068: Add a QuicHttpStream class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move GetPeerAddress from QuicReliableClientStream to ReliableQuicStream Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: net/quic/quic_client_session_test.cc
diff --git a/net/quic/quic_client_session_test.cc b/net/quic/quic_client_session_test.cc
index 3f3ad04f9aece36dabccecd294ac54e480f341a7..4d47731e36d1a626c8588b2b04747080a12992fc 100644
--- a/net/quic/quic_client_session_test.cc
+++ b/net/quic/quic_client_session_test.cc
@@ -7,6 +7,7 @@
#include <vector>
#include "base/stl_util.h"
+#include "net/base/test_completion_callback.h"
#include "net/quic/crypto/crypto_protocol.h"
#include "net/quic/test_tools/quic_test_utils.h"
@@ -29,40 +30,44 @@ class QuicClientSessionTest : public ::testing::Test {
PacketSavingConnection* connection_;
QuicClientSession session_;
QuicConnectionVisitorInterface* visitor_;
+ TestCompletionCallback callback_;
};
-TEST_F(QuicClientSessionTest, CryptoConnect) {
- session_.CryptoConnect();
+TEST_F(QuicClientSessionTest, CryptoConnectSendsCorrectData) {
+ EXPECT_EQ(ERR_IO_PENDING, session_.CryptoConnect(callback_.callback()));
ASSERT_EQ(1u, connection_->packets_.size());
scoped_ptr<QuicPacket> chlo(ConstructHandshakePacket(guid_, kCHLO));
CompareQuicDataWithHexError("CHLO", connection_->packets_[0], chlo.get());
}
+TEST_F(QuicClientSessionTest, CryptoConnectSendsCompletesAfterSHLO) {
+ session_.CryptoConnect(callback_.callback());
+ // Send the SHLO message.
+ CryptoHandshakeMessage server_message;
+ server_message.tag = kSHLO;
+ session_.GetCryptoStream()->OnHandshakeMessage(server_message);
+ EXPECT_EQ(OK, callback_.WaitForResult());
+}
+
TEST_F(QuicClientSessionTest, MaxNumConnections) {
// Initialize crypto before the client session will create a stream.
- session_.CryptoConnect();
- ASSERT_EQ(1u, connection_->packets_.size());
- scoped_ptr<QuicPacket> chlo(ConstructHandshakePacket(guid_, kCHLO));
- CompareQuicDataWithHexError("CHLO", connection_->packets_[0], chlo.get());
- // Simulate the server crypto handshake.
+ session_.CryptoConnect(callback_.callback());
CryptoHandshakeMessage server_message;
server_message.tag = kSHLO;
session_.GetCryptoStream()->OnHandshakeMessage(server_message);
+ callback_.WaitForResult();
std::vector<QuicReliableClientStream*> streams;
for (size_t i = 0; i < kDefaultMaxStreamsPerConnection; i++) {
QuicReliableClientStream* stream = session_.CreateOutgoingReliableStream();
- streams.push_back(stream);
EXPECT_TRUE(stream);
+ streams.push_back(stream);
}
EXPECT_FALSE(session_.CreateOutgoingReliableStream());
// Close a stream and ensure I can now open a new one.
session_.CloseStream(streams[0]->id());
- scoped_ptr<QuicReliableClientStream> stream(
- session_.CreateOutgoingReliableStream());
- EXPECT_TRUE(stream.get());
- STLDeleteElements(&streams);
+ EXPECT_TRUE(session_.CreateOutgoingReliableStream());
}
} // namespace

Powered by Google App Engine
This is Rietveld 408576698