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

Side by Side Diff: net/quic/core/quic_crypto_client_stream_test.cc

Issue 2306173003: Add a new QuicFlagSaver class for saving/restoring the values of QUIC flags in tests. (Closed)
Patch Set: Better Created 4 years, 3 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/quic/core/quic_connection_test.cc ('k') | net/quic/core/quic_crypto_server_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/core/quic_crypto_client_stream.h" 5 #include "net/quic/core/quic_crypto_client_stream.h"
6 6
7 #include <memory> 7 #include <memory>
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/crypto/quic_decrypter.h" 10 #include "net/quic/core/crypto/quic_decrypter.h"
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 &server_connection_, &server_session); 302 &server_connection_, &server_session);
303 CHECK(server_session); 303 CHECK(server_session);
304 server_session_.reset(server_session); 304 server_session_.reset(server_session);
305 CryptoTestUtils::FakeServerOptions options; 305 CryptoTestUtils::FakeServerOptions options;
306 CryptoTestUtils::SetupCryptoServerConfigForTest( 306 CryptoTestUtils::SetupCryptoServerConfigForTest(
307 server_connection_->clock(), server_connection_->random_generator(), 307 server_connection_->clock(), server_connection_->random_generator(),
308 server_session_->config(), &server_crypto_config_, options); 308 server_session_->config(), &server_crypto_config_, options);
309 FLAGS_enable_quic_stateless_reject_support = true; 309 FLAGS_enable_quic_stateless_reject_support = true;
310 } 310 }
311 311
312 QuicFlagSaver flags_; // Save/restore all QUIC flag values.
313
312 MockQuicConnectionHelper helper_; 314 MockQuicConnectionHelper helper_;
313 MockAlarmFactory alarm_factory_; 315 MockAlarmFactory alarm_factory_;
314 316
315 // Client crypto stream state 317 // Client crypto stream state
316 PacketSavingConnection* client_connection_; 318 PacketSavingConnection* client_connection_;
317 std::unique_ptr<TestQuicSpdyClientSession> client_session_; 319 std::unique_ptr<TestQuicSpdyClientSession> client_session_;
318 QuicCryptoClientConfig client_crypto_config_; 320 QuicCryptoClientConfig client_crypto_config_;
319 321
320 // Server crypto stream state 322 // Server crypto stream state
321 PacketSavingConnection* server_connection_; 323 PacketSavingConnection* server_connection_;
322 std::unique_ptr<TestQuicSpdyServerSession> server_session_; 324 std::unique_ptr<TestQuicSpdyServerSession> server_session_;
323 QuicCryptoServerConfig server_crypto_config_; 325 QuicCryptoServerConfig server_crypto_config_;
324 QuicCompressedCertsCache server_compressed_certs_cache_; 326 QuicCompressedCertsCache server_compressed_certs_cache_;
325 QuicServerId server_id_; 327 QuicServerId server_id_;
326 }; 328 };
327 329
328 TEST_F(QuicCryptoClientStreamStatelessTest, StatelessReject) { 330 TEST_F(QuicCryptoClientStreamStatelessTest, StatelessReject) {
329 ValueRestore<bool> old_flag(&FLAGS_enable_quic_stateless_reject_support, 331 FLAGS_enable_quic_stateless_reject_support = true;
330 true);
331 332
332 QuicCryptoClientConfig::CachedState* client_state = 333 QuicCryptoClientConfig::CachedState* client_state =
333 client_crypto_config_.LookupOrCreate(server_id_); 334 client_crypto_config_.LookupOrCreate(server_id_);
334 335
335 EXPECT_FALSE(client_state->has_server_designated_connection_id()); 336 EXPECT_FALSE(client_state->has_server_designated_connection_id());
336 EXPECT_CALL(*client_session_, OnProofValid(testing::_)); 337 EXPECT_CALL(*client_session_, OnProofValid(testing::_));
337 338
338 InitializeFakeStatelessRejectServer(); 339 InitializeFakeStatelessRejectServer();
339 AdvanceHandshakeWithFakeServer(); 340 AdvanceHandshakeWithFakeServer();
340 341
(...skipping 13 matching lines...) Expand all
354 client_state->GetNextServerDesignatedConnectionId(); 355 client_state->GetNextServerDesignatedConnectionId();
355 QuicConnectionId expected_id = 356 QuicConnectionId expected_id =
356 server_session_->connection()->random_generator()->RandUint64(); 357 server_session_->connection()->random_generator()->RandUint64();
357 EXPECT_EQ(expected_id, server_designated_id); 358 EXPECT_EQ(expected_id, server_designated_id);
358 EXPECT_FALSE(client_state->has_server_designated_connection_id()); 359 EXPECT_FALSE(client_state->has_server_designated_connection_id());
359 } 360 }
360 361
361 } // namespace 362 } // namespace
362 } // namespace test 363 } // namespace test
363 } // namespace net 364 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_connection_test.cc ('k') | net/quic/core/quic_crypto_server_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698