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

Unified Diff: net/quic/test_tools/quic_test_utils.cc

Issue 1138443003: Land Recent QUIC Changes until 05/13/2015 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compile error fixes Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/test_tools/quic_test_utils.h ('k') | net/tools/quic/quic_dispatcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/test_tools/quic_test_utils.cc
diff --git a/net/quic/test_tools/quic_test_utils.cc b/net/quic/test_tools/quic_test_utils.cc
index 2b426e8b2ce74700010943d624bbdde06e22c73f..676a37dcac8a64212c2044e7c02c2a4a3cde46c7 100644
--- a/net/quic/test_tools/quic_test_utils.cc
+++ b/net/quic/test_tools/quic_test_utils.cc
@@ -381,6 +381,14 @@ QuicCryptoStream* TestClientSession::GetCryptoStream() {
return crypto_stream_;
}
+TestServerSession::TestServerSession(const QuicConfig& config,
+ QuicConnection* connection)
+ : QuicServerSession(config, connection, nullptr) {
+}
+
+TestServerSession::~TestServerSession() {
+}
+
MockPacketWriter::MockPacketWriter() {
}
@@ -711,6 +719,14 @@ QuicConfig DefaultQuicConfig() {
return config;
}
+QuicConfig DefaultQuicConfigStatelessRejects() {
+ QuicConfig config = DefaultQuicConfig();
+ QuicTagVector copt;
+ copt.push_back(kSREJ);
+ config.SetConnectionOptionsToSend(copt);
+ return config;
+}
+
QuicVersionVector SupportedVersions(QuicVersion version) {
QuicVersionVector versions;
versions.push_back(version);
@@ -760,10 +776,8 @@ WriteResult TestWriterFactory::PerConnectionPacketWriter::WritePacket(
// in a different way, so TestWriterFactory::OnPacketSent might never be
// called.
factory_->current_writer_ = this;
- return tools::QuicPerConnectionPacketWriter::WritePacket(buffer,
- buf_len,
- self_address,
- peer_address);
+ return tools::QuicPerConnectionPacketWriter::WritePacket(
+ buffer, buf_len, self_address, peer_address);
}
MockQuicConnectionDebugVisitor::MockQuicConnectionDebugVisitor() {
@@ -772,5 +786,60 @@ MockQuicConnectionDebugVisitor::MockQuicConnectionDebugVisitor() {
MockQuicConnectionDebugVisitor::~MockQuicConnectionDebugVisitor() {
}
+void SetupCryptoClientStreamForTest(
+ QuicServerId server_id,
+ bool supports_stateless_rejects,
+ QuicTime::Delta connection_start_time,
+ QuicCryptoClientConfig* crypto_client_config,
+ PacketSavingConnection** client_connection,
+ TestClientSession** client_session,
+ QuicCryptoClientStream** client_stream) {
+ CHECK(crypto_client_config);
+ CHECK(client_connection);
+ CHECK(client_session);
+ CHECK(client_stream);
+ CHECK(!connection_start_time.IsZero())
+ << "Connections must start at non-zero times, otherwise the "
+ << "strike-register will be unhappy.";
+
+ QuicConfig config = supports_stateless_rejects
+ ? DefaultQuicConfigStatelessRejects()
+ : DefaultQuicConfig();
+ *client_connection = new PacketSavingConnection(Perspective::IS_CLIENT);
+ *client_session = new TestClientSession(*client_connection, config);
+ *client_stream = new QuicCryptoClientStream(server_id, *client_session,
+ nullptr, crypto_client_config);
+ (*client_session)->SetCryptoStream(*client_stream);
+ (*client_connection)->AdvanceTime(connection_start_time);
+}
+
+// Setup or create?
+void SetupCryptoServerStreamForTest(
+ QuicServerId server_id,
+ QuicTime::Delta connection_start_time,
+ QuicCryptoServerConfig* server_crypto_config,
+ PacketSavingConnection** server_connection,
+ TestServerSession** server_session,
+ QuicCryptoServerStream** server_stream) {
+ CHECK(server_crypto_config);
+ CHECK(server_connection);
+ CHECK(server_session);
+ CHECK(server_stream);
+ CHECK(!connection_start_time.IsZero())
+ << "Connections must start at non-zero times, otherwise the "
+ << "strike-register will be unhappy.";
+
+ *server_connection = new PacketSavingConnection(Perspective::IS_SERVER);
+ *server_session =
+ new TestServerSession(DefaultQuicConfig(), *server_connection);
+ *server_stream =
+ new QuicCryptoServerStream(server_crypto_config, *server_session);
+ (*server_session)->InitializeSession(server_crypto_config);
+
+ // We advance the clock initially because the default time is zero and the
+ // strike register worries that we've just overflowed a uint32 time.
+ (*server_connection)->AdvanceTime(connection_start_time);
+}
+
} // namespace test
} // namespace net
« no previous file with comments | « net/quic/test_tools/quic_test_utils.h ('k') | net/tools/quic/quic_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698