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

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

Issue 2671333004: Convert class-full-of-statics CryptoTestUtils into a namespace (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « net/tools/quic/end_to_end_test.cc ('k') | net/tools/quic/quic_client_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/tools/quic/quic_client_session.h" 5 #include "net/tools/quic/quic_client_session.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "net/quic/core/crypto/aes_128_gcm_12_encrypter.h" 9 #include "net/quic/core/crypto/aes_128_gcm_12_encrypter.h"
10 #include "net/quic/core/quic_flags.h" 10 #include "net/quic/core/quic_flags.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 QuicStreamId id) override { 58 QuicStreamId id) override {
59 MockQuicSpdyClientStream* stream = new MockQuicSpdyClientStream(id, this); 59 MockQuicSpdyClientStream* stream = new MockQuicSpdyClientStream(id, this);
60 ActivateStream(QuicWrapUnique(stream)); 60 ActivateStream(QuicWrapUnique(stream));
61 return stream; 61 return stream;
62 } 62 }
63 }; 63 };
64 64
65 class QuicClientSessionTest : public ::testing::TestWithParam<QuicVersion> { 65 class QuicClientSessionTest : public ::testing::TestWithParam<QuicVersion> {
66 protected: 66 protected:
67 QuicClientSessionTest() 67 QuicClientSessionTest()
68 : crypto_config_(CryptoTestUtils::ProofVerifierForTesting()), 68 : crypto_config_(crypto_test_utils::ProofVerifierForTesting()),
69 promised_stream_id_(kServerDataStreamId1), 69 promised_stream_id_(kServerDataStreamId1),
70 associated_stream_id_(kClientDataStreamId1) { 70 associated_stream_id_(kClientDataStreamId1) {
71 Initialize(); 71 Initialize();
72 // Advance the time, because timers do not like uninitialized times. 72 // Advance the time, because timers do not like uninitialized times.
73 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); 73 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1));
74 } 74 }
75 75
76 ~QuicClientSessionTest() override { 76 ~QuicClientSessionTest() override {
77 // Session must be destroyed before promised_by_url_ 77 // Session must be destroyed before promised_by_url_
78 session_.reset(nullptr); 78 session_.reset(nullptr);
(...skipping 18 matching lines...) Expand all
97 } 97 }
98 98
99 void CompleteCryptoHandshake() { 99 void CompleteCryptoHandshake() {
100 CompleteCryptoHandshake(kDefaultMaxStreamsPerConnection); 100 CompleteCryptoHandshake(kDefaultMaxStreamsPerConnection);
101 } 101 }
102 102
103 void CompleteCryptoHandshake(uint32_t server_max_incoming_streams) { 103 void CompleteCryptoHandshake(uint32_t server_max_incoming_streams) {
104 session_->CryptoConnect(); 104 session_->CryptoConnect();
105 QuicCryptoClientStream* stream = 105 QuicCryptoClientStream* stream =
106 static_cast<QuicCryptoClientStream*>(session_->GetCryptoStream()); 106 static_cast<QuicCryptoClientStream*>(session_->GetCryptoStream());
107 CryptoTestUtils::FakeServerOptions options; 107 crypto_test_utils::FakeServerOptions options;
108 QuicConfig config = DefaultQuicConfig(); 108 QuicConfig config = DefaultQuicConfig();
109 config.SetMaxIncomingDynamicStreamsToSend(server_max_incoming_streams); 109 config.SetMaxIncomingDynamicStreamsToSend(server_max_incoming_streams);
110 CryptoTestUtils::HandshakeWithFakeServer(&config, &helper_, &alarm_factory_, 110 crypto_test_utils::HandshakeWithFakeServer(
111 connection_, stream, options); 111 &config, &helper_, &alarm_factory_, connection_, stream, options);
112 } 112 }
113 113
114 QuicCryptoClientConfig crypto_config_; 114 QuicCryptoClientConfig crypto_config_;
115 MockQuicConnectionHelper helper_; 115 MockQuicConnectionHelper helper_;
116 MockAlarmFactory alarm_factory_; 116 MockAlarmFactory alarm_factory_;
117 PacketSavingConnection* connection_; 117 PacketSavingConnection* connection_;
118 std::unique_ptr<TestQuicClientSession> session_; 118 std::unique_ptr<TestQuicClientSession> session_;
119 QuicClientPushPromiseIndex push_promise_index_; 119 QuicClientPushPromiseIndex push_promise_index_;
120 SpdyHeaderBlock push_promise_; 120 SpdyHeaderBlock push_promise_;
121 string promise_url_; 121 string promise_url_;
(...skipping 22 matching lines...) Expand all
144 EXPECT_TRUE(session_->IsEncryptionEstablished()); 144 EXPECT_TRUE(session_->IsEncryptionEstablished());
145 QuicSpdyClientStream* stream = 145 QuicSpdyClientStream* stream =
146 session_->CreateOutgoingDynamicStream(kDefaultPriority); 146 session_->CreateOutgoingDynamicStream(kDefaultPriority);
147 ASSERT_TRUE(stream != nullptr); 147 ASSERT_TRUE(stream != nullptr);
148 EXPECT_NE(kCryptoStreamId, stream->id()); 148 EXPECT_NE(kCryptoStreamId, stream->id());
149 149
150 // Process an "inchoate" REJ from the server which will cause 150 // Process an "inchoate" REJ from the server which will cause
151 // an inchoate CHLO to be sent and will leave the encryption level 151 // an inchoate CHLO to be sent and will leave the encryption level
152 // at NONE. 152 // at NONE.
153 CryptoHandshakeMessage rej; 153 CryptoHandshakeMessage rej;
154 CryptoTestUtils::FillInDummyReject(&rej, /* stateless */ false); 154 crypto_test_utils::FillInDummyReject(&rej, /* stateless */ false);
155 EXPECT_TRUE(session_->IsEncryptionEstablished()); 155 EXPECT_TRUE(session_->IsEncryptionEstablished());
156 session_->GetCryptoStream()->OnHandshakeMessage(rej); 156 session_->GetCryptoStream()->OnHandshakeMessage(rej);
157 EXPECT_FALSE(session_->IsEncryptionEstablished()); 157 EXPECT_FALSE(session_->IsEncryptionEstablished());
158 EXPECT_EQ(ENCRYPTION_NONE, 158 EXPECT_EQ(ENCRYPTION_NONE,
159 QuicPacketCreatorPeer::GetEncryptionLevel( 159 QuicPacketCreatorPeer::GetEncryptionLevel(
160 QuicConnectionPeer::GetPacketCreator(connection_))); 160 QuicConnectionPeer::GetPacketCreator(connection_)));
161 // Verify that no new streams may be created. 161 // Verify that no new streams may be created.
162 EXPECT_TRUE(session_->CreateOutgoingDynamicStream(kDefaultPriority) == 162 EXPECT_TRUE(session_->CreateOutgoingDynamicStream(kDefaultPriority) ==
163 nullptr); 163 nullptr);
164 // Verify that no data may be send on existing streams. 164 // Verify that no data may be send on existing streams.
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 QuicClientPromisedInfo* promised = 498 QuicClientPromisedInfo* promised =
499 session_->GetPromisedById(promised_stream_id_); 499 session_->GetPromisedById(promised_stream_id_);
500 EXPECT_NE(promised, nullptr); 500 EXPECT_NE(promised, nullptr);
501 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); 501 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr);
502 EXPECT_EQ(session_->GetPromisedStream(promised_stream_id_), nullptr); 502 EXPECT_EQ(session_->GetPromisedStream(promised_stream_id_), nullptr);
503 } 503 }
504 504
505 } // namespace 505 } // namespace
506 } // namespace test 506 } // namespace test
507 } // namespace net 507 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/end_to_end_test.cc ('k') | net/tools/quic/quic_client_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698