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

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

Issue 2848203002: Add a platform implementation of QuicTest and QuicTestWithParam (Closed)
Patch Set: net/quic/platform/impl/quic_test_impl.cc Created 3 years, 7 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/quic_test_utils_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 <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"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 size_t length = framer->BuildDataPacket(header, frames, buffer, packet_size); 75 size_t length = framer->BuildDataPacket(header, frames, buffer, packet_size);
76 DCHECK_NE(0u, length); 76 DCHECK_NE(0u, length);
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() {
86 #define QUIC_FLAG(type, flag, value) \
87 CHECK_EQ(value, GetQuicFlag(flag)) \
88 << "Flag set to an unexpected value. A prior test is likely " \
89 << "setting a flag without using a QuicFlagSaver";
90 #include "net/quic/core/quic_flags_list.h"
91 #undef QUIC_FLAG
92 }
93
94 QuicFlagSaver::~QuicFlagSaver() {
95 #define QUIC_FLAG(type, flag, value) SetQuicFlag(&flag, value);
96 #include "net/quic/core/quic_flags_list.h"
97 #undef QUIC_FLAG
98 }
99
100 string Sha1Hash(QuicStringPiece data) { 85 string Sha1Hash(QuicStringPiece data) {
101 char buffer[SHA_DIGEST_LENGTH]; 86 char buffer[SHA_DIGEST_LENGTH];
102 SHA1(reinterpret_cast<const uint8_t*>(data.data()), data.size(), 87 SHA1(reinterpret_cast<const uint8_t*>(data.data()), data.size(),
103 reinterpret_cast<uint8_t*>(buffer)); 88 reinterpret_cast<uint8_t*>(buffer));
104 return string(buffer, arraysize(buffer)); 89 return string(buffer, arraysize(buffer));
105 } 90 }
106 91
107 uint64_t SimpleRandom::RandUint64() { 92 uint64_t SimpleRandom::RandUint64() {
108 string hash = 93 string hash =
109 Sha1Hash(QuicStringPiece(reinterpret_cast<char*>(&seed_), sizeof(seed_))); 94 Sha1Hash(QuicStringPiece(reinterpret_cast<char*>(&seed_), sizeof(seed_)));
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 // strike register worries that we've just overflowed a uint32_t time. 835 // strike register worries that we've just overflowed a uint32_t time.
851 (*server_connection)->AdvanceTime(connection_start_time); 836 (*server_connection)->AdvanceTime(connection_start_time);
852 } 837 }
853 838
854 QuicStreamId QuicClientDataStreamId(int i) { 839 QuicStreamId QuicClientDataStreamId(int i) {
855 return kClientDataStreamId1 + 2 * i; 840 return kClientDataStreamId1 + 2 * i;
856 } 841 }
857 842
858 } // namespace test 843 } // namespace test
859 } // namespace net 844 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/quic_test_utils.h ('k') | net/quic/test_tools/quic_test_utils_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698