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

Side by Side Diff: net/quic/test_tools/quic_test_utils.cc

Issue 2825083003: Landing Recent QUIC changes until Mon Apr 17 2017 (Closed)
Patch Set: Format Created 3 years, 8 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/test_tools/quic_test_utils.h ('k') | net/quic/test_tools/simple_quic_framer.h » ('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/test_tools/quic_test_utils.h" 5 #include "net/quic/test_tools/quic_test_utils.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 9
10 #include "net/quic/core/crypto/crypto_framer.h" 10 #include "net/quic/core/crypto/crypto_framer.h"
11 #include "net/quic/core/crypto/crypto_handshake.h" 11 #include "net/quic/core/crypto/crypto_handshake.h"
12 #include "net/quic/core/crypto/crypto_utils.h" 12 #include "net/quic/core/crypto/crypto_utils.h"
13 #include "net/quic/core/crypto/null_encrypter.h" 13 #include "net/quic/core/crypto/null_encrypter.h"
14 #include "net/quic/core/crypto/quic_decrypter.h" 14 #include "net/quic/core/crypto/quic_decrypter.h"
15 #include "net/quic/core/crypto/quic_encrypter.h" 15 #include "net/quic/core/crypto/quic_encrypter.h"
16 #include "net/quic/core/quic_data_writer.h" 16 #include "net/quic/core/quic_data_writer.h"
17 #include "net/quic/core/quic_flags.h"
18 #include "net/quic/core/quic_framer.h" 17 #include "net/quic/core/quic_framer.h"
19 #include "net/quic/core/quic_packet_creator.h" 18 #include "net/quic/core/quic_packet_creator.h"
20 #include "net/quic/core/quic_utils.h" 19 #include "net/quic/core/quic_utils.h"
21 #include "net/quic/platform/api/quic_endian.h" 20 #include "net/quic/platform/api/quic_endian.h"
21 #include "net/quic/platform/api/quic_flags.h"
22 #include "net/quic/platform/api/quic_logging.h" 22 #include "net/quic/platform/api/quic_logging.h"
23 #include "net/quic/platform/api/quic_ptr_util.h" 23 #include "net/quic/platform/api/quic_ptr_util.h"
24 #include "net/quic/test_tools/crypto_test_utils.h" 24 #include "net/quic/test_tools/crypto_test_utils.h"
25 #include "net/quic/test_tools/quic_connection_peer.h" 25 #include "net/quic/test_tools/quic_connection_peer.h"
26 #include "net/spdy/spdy_frame_builder.h" 26 #include "net/spdy/spdy_frame_builder.h"
27 #include "third_party/boringssl/src/include/openssl/sha.h" 27 #include "third_party/boringssl/src/include/openssl/sha.h"
28 28
29 using std::string; 29 using std::string;
30 using testing::_; 30 using testing::_;
31 using testing::Invoke; 31 using testing::Invoke;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // Re-construct the data packet with data ownership. 77 // Re-construct the data packet with data ownership.
78 return new QuicPacket(buffer, length, /* owns_buffer */ true, 78 return new QuicPacket(buffer, length, /* owns_buffer */ true,
79 header.public_header.connection_id_length, 79 header.public_header.connection_id_length,
80 header.public_header.version_flag, 80 header.public_header.version_flag,
81 header.public_header.nonce != nullptr, 81 header.public_header.nonce != nullptr,
82 header.public_header.packet_number_length); 82 header.public_header.packet_number_length);
83 } 83 }
84 84
85 QuicFlagSaver::QuicFlagSaver() { 85 QuicFlagSaver::QuicFlagSaver() {
86 #define QUIC_FLAG(type, flag, value) \ 86 #define QUIC_FLAG(type, flag, value) \
87 CHECK_EQ(value, base::GetFlag(flag)) \ 87 CHECK_EQ(value, GetQuicFlag(flag)) \
88 << "Flag set to an unexpected value. A prior test is likely " \ 88 << "Flag set to an unexpected value. A prior test is likely " \
89 << "setting a flag without using a QuicFlagSaver"; 89 << "setting a flag without using a QuicFlagSaver";
90 #include "net/quic/core/quic_flags_list.h" 90 #include "net/quic/core/quic_flags_list.h"
91 #undef QUIC_FLAG 91 #undef QUIC_FLAG
92 } 92 }
93 93
94 QuicFlagSaver::~QuicFlagSaver() { 94 QuicFlagSaver::~QuicFlagSaver() {
95 #define QUIC_FLAG(type, flag, value) base::SetFlag(&flag, value); 95 #define QUIC_FLAG(type, flag, value) SetQuicFlag(&flag, value);
96 #include "net/quic/core/quic_flags_list.h" 96 #include "net/quic/core/quic_flags_list.h"
97 #undef QUIC_FLAG 97 #undef QUIC_FLAG
98 } 98 }
99 99
100 string Sha1Hash(QuicStringPiece data) { 100 string Sha1Hash(QuicStringPiece data) {
101 char buffer[SHA_DIGEST_LENGTH]; 101 char buffer[SHA_DIGEST_LENGTH];
102 SHA1(reinterpret_cast<const uint8_t*>(data.data()), data.size(), 102 SHA1(reinterpret_cast<const uint8_t*>(data.data()), data.size(),
103 reinterpret_cast<uint8_t*>(buffer)); 103 reinterpret_cast<uint8_t*>(buffer));
104 return string(buffer, arraysize(buffer)); 104 return string(buffer, arraysize(buffer));
105 } 105 }
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 MockQuicSession::~MockQuicSession() { 387 MockQuicSession::~MockQuicSession() {
388 delete connection(); 388 delete connection();
389 } 389 }
390 390
391 // static 391 // static
392 QuicConsumedData MockQuicSession::ConsumeAllData( 392 QuicConsumedData MockQuicSession::ConsumeAllData(
393 QuicStream* /*stream*/, 393 QuicStream* /*stream*/,
394 QuicStreamId /*id*/, 394 QuicStreamId /*id*/,
395 const QuicIOVector& data, 395 const QuicIOVector& data,
396 QuicStreamOffset /*offset*/, 396 QuicStreamOffset /*offset*/,
397 bool fin, 397 StreamSendingState state,
398 const QuicReferenceCountedPointer< 398 const QuicReferenceCountedPointer<
399 QuicAckListenerInterface>& /*ack_listener*/) { 399 QuicAckListenerInterface>& /*ack_listener*/) {
400 return QuicConsumedData(data.total_length, fin); 400 return QuicConsumedData(data.total_length, state != NO_FIN);
401 } 401 }
402 402
403 MockQuicSpdySession::MockQuicSpdySession(QuicConnection* connection) 403 MockQuicSpdySession::MockQuicSpdySession(QuicConnection* connection)
404 : QuicSpdySession(connection, nullptr, DefaultQuicConfig()) { 404 : QuicSpdySession(connection, nullptr, DefaultQuicConfig()) {
405 crypto_stream_.reset(new QuicCryptoStream(this)); 405 crypto_stream_.reset(new QuicCryptoStream(this));
406 Initialize(); 406 Initialize();
407 ON_CALL(*this, WritevData(_, _, _, _, _, _)) 407 ON_CALL(*this, WritevData(_, _, _, _, _, _))
408 .WillByDefault(testing::Return(QuicConsumedData(0, false))); 408 .WillByDefault(testing::Return(QuicConsumedData(0, false)));
409 } 409 }
410 410
(...skipping 27 matching lines...) Expand all
438 QuicCryptoServerStreamBase* 438 QuicCryptoServerStreamBase*
439 TestQuicSpdyServerSession::CreateQuicCryptoServerStream( 439 TestQuicSpdyServerSession::CreateQuicCryptoServerStream(
440 const QuicCryptoServerConfig* crypto_config, 440 const QuicCryptoServerConfig* crypto_config,
441 QuicCompressedCertsCache* compressed_certs_cache) { 441 QuicCompressedCertsCache* compressed_certs_cache) {
442 return new QuicCryptoServerStream( 442 return new QuicCryptoServerStream(
443 crypto_config, compressed_certs_cache, 443 crypto_config, compressed_certs_cache,
444 FLAGS_quic_reloadable_flag_enable_quic_stateless_reject_support, this, 444 FLAGS_quic_reloadable_flag_enable_quic_stateless_reject_support, this,
445 &helper_); 445 &helper_);
446 } 446 }
447 447
448 QuicCryptoServerStream* TestQuicSpdyServerSession::GetCryptoStream() { 448 QuicCryptoServerStream* TestQuicSpdyServerSession::GetMutableCryptoStream() {
449 return static_cast<QuicCryptoServerStream*>( 449 return static_cast<QuicCryptoServerStream*>(
450 QuicServerSessionBase::GetMutableCryptoStream());
451 }
452
453 const QuicCryptoServerStream* TestQuicSpdyServerSession::GetCryptoStream()
454 const {
455 return static_cast<const QuicCryptoServerStream*>(
450 QuicServerSessionBase::GetCryptoStream()); 456 QuicServerSessionBase::GetCryptoStream());
451 } 457 }
452 458
453 TestQuicSpdyClientSession::TestQuicSpdyClientSession( 459 TestQuicSpdyClientSession::TestQuicSpdyClientSession(
454 QuicConnection* connection, 460 QuicConnection* connection,
455 const QuicConfig& config, 461 const QuicConfig& config,
456 const QuicServerId& server_id, 462 const QuicServerId& server_id,
457 QuicCryptoClientConfig* crypto_config) 463 QuicCryptoClientConfig* crypto_config)
458 : QuicClientSessionBase(connection, &push_promise_index_, config) { 464 : QuicClientSessionBase(connection, &push_promise_index_, config) {
459 crypto_stream_.reset(new QuicCryptoClientStream( 465 crypto_stream_.reset(new QuicCryptoClientStream(
460 server_id, this, crypto_test_utils::ProofVerifyContextForTesting(), 466 server_id, this, crypto_test_utils::ProofVerifyContextForTesting(),
461 crypto_config, this)); 467 crypto_config, this));
462 Initialize(); 468 Initialize();
463 } 469 }
464 470
465 TestQuicSpdyClientSession::~TestQuicSpdyClientSession() {} 471 TestQuicSpdyClientSession::~TestQuicSpdyClientSession() {}
466 472
467 bool TestQuicSpdyClientSession::IsAuthorized(const string& authority) { 473 bool TestQuicSpdyClientSession::IsAuthorized(const string& authority) {
468 return true; 474 return true;
469 } 475 }
470 476
471 QuicCryptoClientStream* TestQuicSpdyClientSession::GetCryptoStream() { 477 QuicCryptoClientStream* TestQuicSpdyClientSession::GetMutableCryptoStream() {
472 return crypto_stream_.get(); 478 return crypto_stream_.get();
473 } 479 }
474 480
481 const QuicCryptoClientStream* TestQuicSpdyClientSession::GetCryptoStream()
482 const {
483 return crypto_stream_.get();
484 }
485
475 TestPushPromiseDelegate::TestPushPromiseDelegate(bool match) 486 TestPushPromiseDelegate::TestPushPromiseDelegate(bool match)
476 : match_(match), rendezvous_fired_(false), rendezvous_stream_(nullptr) {} 487 : match_(match), rendezvous_fired_(false), rendezvous_stream_(nullptr) {}
477 488
478 bool TestPushPromiseDelegate::CheckVary( 489 bool TestPushPromiseDelegate::CheckVary(
479 const SpdyHeaderBlock& client_request, 490 const SpdyHeaderBlock& client_request,
480 const SpdyHeaderBlock& promise_request, 491 const SpdyHeaderBlock& promise_request,
481 const SpdyHeaderBlock& promise_response) { 492 const SpdyHeaderBlock& promise_response) {
482 QUIC_DVLOG(1) << "match " << match_; 493 QUIC_DVLOG(1) << "match " << match_;
483 return match_; 494 return match_;
484 } 495 }
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 // strike register worries that we've just overflowed a uint32_t time. 850 // strike register worries that we've just overflowed a uint32_t time.
840 (*server_connection)->AdvanceTime(connection_start_time); 851 (*server_connection)->AdvanceTime(connection_start_time);
841 } 852 }
842 853
843 QuicStreamId QuicClientDataStreamId(int i) { 854 QuicStreamId QuicClientDataStreamId(int i) {
844 return kClientDataStreamId1 + 2 * i; 855 return kClientDataStreamId1 + 2 * i;
845 } 856 }
846 857
847 } // namespace test 858 } // namespace test
848 } // namespace net 859 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/quic_test_utils.h ('k') | net/quic/test_tools/simple_quic_framer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698