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

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

Issue 2681793002: Landing Recent QUIC changes until 5:30 PM, Feb 3, 2017 UTC-5 (Closed)
Patch Set: sync and rebase 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/quic/test_tools/quic_stream_peer.cc ('k') | net/tools/quic/chlo_extractor_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/test_tools/quic_test_utils.h" 5 #include "net/quic/test_tools/quic_test_utils.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "net/quic/core/crypto/crypto_framer.h" 9 #include "net/quic/core/crypto/crypto_framer.h"
10 #include "net/quic/core/crypto/crypto_handshake.h" 10 #include "net/quic/core/crypto/crypto_handshake.h"
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 rendezvous_stream_ = stream; 454 rendezvous_stream_ = stream;
455 } 455 }
456 456
457 TestQuicSpdyClientSession::TestQuicSpdyClientSession( 457 TestQuicSpdyClientSession::TestQuicSpdyClientSession(
458 QuicConnection* connection, 458 QuicConnection* connection,
459 const QuicConfig& config, 459 const QuicConfig& config,
460 const QuicServerId& server_id, 460 const QuicServerId& server_id,
461 QuicCryptoClientConfig* crypto_config) 461 QuicCryptoClientConfig* crypto_config)
462 : QuicClientSessionBase(connection, &push_promise_index_, config) { 462 : QuicClientSessionBase(connection, &push_promise_index_, config) {
463 crypto_stream_.reset(new QuicCryptoClientStream( 463 crypto_stream_.reset(new QuicCryptoClientStream(
464 server_id, this, CryptoTestUtils::ProofVerifyContextForTesting(), 464 server_id, this, crypto_test_utils::ProofVerifyContextForTesting(),
465 crypto_config, this)); 465 crypto_config, this));
466 Initialize(); 466 Initialize();
467 } 467 }
468 468
469 TestQuicSpdyClientSession::~TestQuicSpdyClientSession() {} 469 TestQuicSpdyClientSession::~TestQuicSpdyClientSession() {}
470 470
471 bool TestQuicSpdyClientSession::IsAuthorized(const string& authority) { 471 bool TestQuicSpdyClientSession::IsAuthorized(const string& authority) {
472 return true; 472 return true;
473 } 473 }
474 474
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 frames.push_back(frame); 638 frames.push_back(frame);
639 QuicFramer framer( 639 QuicFramer framer(
640 versions != nullptr ? *versions : CurrentSupportedVersions(), 640 versions != nullptr ? *versions : CurrentSupportedVersions(),
641 QuicTime::Zero(), perspective); 641 QuicTime::Zero(), perspective);
642 642
643 std::unique_ptr<QuicPacket> packet( 643 std::unique_ptr<QuicPacket> packet(
644 BuildUnsizedDataPacket(&framer, header, frames)); 644 BuildUnsizedDataPacket(&framer, header, frames));
645 EXPECT_TRUE(packet != nullptr); 645 EXPECT_TRUE(packet != nullptr);
646 char* buffer = new char[kMaxPacketSize]; 646 char* buffer = new char[kMaxPacketSize];
647 size_t encrypted_length = framer.EncryptPayload( 647 size_t encrypted_length = framer.EncryptPayload(
648 ENCRYPTION_NONE, path_id, packet_number, *packet, buffer, kMaxPacketSize); 648 ENCRYPTION_NONE, packet_number, *packet, buffer, kMaxPacketSize);
649 EXPECT_NE(0u, encrypted_length); 649 EXPECT_NE(0u, encrypted_length);
650 return new QuicEncryptedPacket(buffer, encrypted_length, true); 650 return new QuicEncryptedPacket(buffer, encrypted_length, true);
651 } 651 }
652 652
653 QuicReceivedPacket* ConstructReceivedPacket( 653 QuicReceivedPacket* ConstructReceivedPacket(
654 const QuicEncryptedPacket& encrypted_packet, 654 const QuicEncryptedPacket& encrypted_packet,
655 QuicTime receipt_time) { 655 QuicTime receipt_time) {
656 char* buffer = new char[encrypted_packet.length()]; 656 char* buffer = new char[encrypted_packet.length()];
657 memcpy(buffer, encrypted_packet.data(), encrypted_packet.length()); 657 memcpy(buffer, encrypted_packet.data(), encrypted_packet.length());
658 return new QuicReceivedPacket(buffer, encrypted_packet.length(), receipt_time, 658 return new QuicReceivedPacket(buffer, encrypted_packet.length(), receipt_time,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 EXPECT_TRUE(packet != nullptr); 692 EXPECT_TRUE(packet != nullptr);
693 693
694 // Now set the frame type to 0x1F, which is an invalid frame type. 694 // Now set the frame type to 0x1F, which is an invalid frame type.
695 reinterpret_cast<unsigned char*>( 695 reinterpret_cast<unsigned char*>(
696 packet->mutable_data())[GetStartOfEncryptedData( 696 packet->mutable_data())[GetStartOfEncryptedData(
697 framer.version(), connection_id_length, version_flag, multipath_flag, 697 framer.version(), connection_id_length, version_flag, multipath_flag,
698 false /* no diversification nonce */, packet_number_length)] = 0x1F; 698 false /* no diversification nonce */, packet_number_length)] = 0x1F;
699 699
700 char* buffer = new char[kMaxPacketSize]; 700 char* buffer = new char[kMaxPacketSize];
701 size_t encrypted_length = framer.EncryptPayload( 701 size_t encrypted_length = framer.EncryptPayload(
702 ENCRYPTION_NONE, path_id, packet_number, *packet, buffer, kMaxPacketSize); 702 ENCRYPTION_NONE, packet_number, *packet, buffer, kMaxPacketSize);
703 EXPECT_NE(0u, encrypted_length); 703 EXPECT_NE(0u, encrypted_length);
704 return new QuicEncryptedPacket(buffer, encrypted_length, true); 704 return new QuicEncryptedPacket(buffer, encrypted_length, true);
705 } 705 }
706 706
707 void CompareCharArraysWithHexError(const string& description, 707 void CompareCharArraysWithHexError(const string& description,
708 const char* actual, 708 const char* actual,
709 const int actual_len, 709 const int actual_len,
710 const char* expected, 710 const char* expected,
711 const int expected_len) { 711 const int expected_len) {
712 EXPECT_EQ(actual_len, expected_len); 712 EXPECT_EQ(actual_len, expected_len);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 // strike register worries that we've just overflowed a uint32_t time. 887 // strike register worries that we've just overflowed a uint32_t time.
888 (*server_connection)->AdvanceTime(connection_start_time); 888 (*server_connection)->AdvanceTime(connection_start_time);
889 } 889 }
890 890
891 QuicStreamId QuicClientDataStreamId(int i) { 891 QuicStreamId QuicClientDataStreamId(int i) {
892 return kClientDataStreamId1 + 2 * i; 892 return kClientDataStreamId1 + 2 * i;
893 } 893 }
894 894
895 } // namespace test 895 } // namespace test
896 } // namespace net 896 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/quic_stream_peer.cc ('k') | net/tools/quic/chlo_extractor_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698