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

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

Issue 188333003: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compilation error - added NET_EXPORT_PRIVATE to QuicFixedUint32 Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/test_tools/quic_test_utils.h ('k') | net/quic/test_tools/simple_quic_framer.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 "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "net/quic/crypto/crypto_framer.h" 9 #include "net/quic/crypto/crypto_framer.h"
10 #include "net/quic/crypto/crypto_handshake.h" 10 #include "net/quic/crypto/crypto_handshake.h"
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 QuicVersion QuicVersionMax() { return QuicSupportedVersions().front(); } 434 QuicVersion QuicVersionMax() { return QuicSupportedVersions().front(); }
435 435
436 QuicVersion QuicVersionMin() { return QuicSupportedVersions().back(); } 436 QuicVersion QuicVersionMin() { return QuicSupportedVersions().back(); }
437 437
438 IPAddressNumber Loopback4() { 438 IPAddressNumber Loopback4() {
439 IPAddressNumber addr; 439 IPAddressNumber addr;
440 CHECK(ParseIPLiteralToNumber("127.0.0.1", &addr)); 440 CHECK(ParseIPLiteralToNumber("127.0.0.1", &addr));
441 return addr; 441 return addr;
442 } 442 }
443 443
444 QuicEncryptedPacket* ConstructEncryptedPacket(
445 QuicConnectionId connection_id,
446 bool version_flag,
447 bool reset_flag,
448 QuicPacketSequenceNumber sequence_number,
449 const string& data) {
450 QuicPacketHeader header;
451 header.public_header.connection_id = connection_id;
452 header.public_header.connection_id_length = PACKET_8BYTE_CONNECTION_ID;
453 header.public_header.version_flag = version_flag;
454 header.public_header.reset_flag = reset_flag;
455 header.public_header.sequence_number_length = PACKET_6BYTE_SEQUENCE_NUMBER;
456 header.packet_sequence_number = sequence_number;
457 header.entropy_flag = false;
458 header.entropy_hash = 0;
459 header.fec_flag = false;
460 header.is_in_fec_group = NOT_IN_FEC_GROUP;
461 header.fec_group = 0;
462 QuicStreamFrame stream_frame(1, false, 0, MakeIOVector(data));
463 QuicFrame frame(&stream_frame);
464 QuicFrames frames;
465 frames.push_back(frame);
466 QuicFramer framer(QuicSupportedVersions(), QuicTime::Zero(), false);
467 scoped_ptr<QuicPacket> packet(
468 framer.BuildUnsizedDataPacket(header, frames).packet);
469 EXPECT_TRUE(packet != NULL);
470 QuicEncryptedPacket* encrypted = framer.EncryptPacket(ENCRYPTION_NONE,
471 sequence_number,
472 *packet);
473 EXPECT_TRUE(encrypted != NULL);
474 return encrypted;
475 }
476
444 void CompareCharArraysWithHexError( 477 void CompareCharArraysWithHexError(
445 const string& description, 478 const string& description,
446 const char* actual, 479 const char* actual,
447 const int actual_len, 480 const int actual_len,
448 const char* expected, 481 const char* expected,
449 const int expected_len) { 482 const int expected_len) {
450 EXPECT_EQ(actual_len, expected_len); 483 EXPECT_EQ(actual_len, expected_len);
451 const int min_len = min(actual_len, expected_len); 484 const int min_len = min(actual_len, expected_len);
452 const int max_len = max(actual_len, expected_len); 485 const int max_len = max(actual_len, expected_len);
453 scoped_ptr<bool[]> marks(new bool[max_len]); 486 scoped_ptr<bool[]> marks(new bool[max_len]);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 } 599 }
567 600
568 QuicVersionVector SupportedVersions(QuicVersion version) { 601 QuicVersionVector SupportedVersions(QuicVersion version) {
569 QuicVersionVector versions; 602 QuicVersionVector versions;
570 versions.push_back(version); 603 versions.push_back(version);
571 return versions; 604 return versions;
572 } 605 }
573 606
574 } // namespace test 607 } // namespace test
575 } // namespace net 608 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/quic_test_utils.h ('k') | net/quic/test_tools/simple_quic_framer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698