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

Side by Side Diff: net/quic/quic_framer_test.cc

Issue 1433703005: Pass in connection ID and supported version to QuicFramer::BuildVersionNegotiationPacket, instead … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@106947577
Patch Set: Created 5 years, 1 month 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/quic_framer.cc ('k') | net/quic/quic_packet_creator.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/quic_framer.h" 5 #include "net/quic/quic_framer.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 3177 matching lines...) Expand 10 before | Expand all | Expand 10 after
3188 QuicFramerPeer::SetPerspective(&framer_, Perspective::IS_CLIENT); 3188 QuicFramerPeer::SetPerspective(&framer_, Perspective::IS_CLIENT);
3189 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames)); 3189 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
3190 ASSERT_TRUE(data != nullptr); 3190 ASSERT_TRUE(data != nullptr);
3191 3191
3192 test::CompareCharArraysWithHexError("constructed packet", 3192 test::CompareCharArraysWithHexError("constructed packet",
3193 data->data(), data->length(), 3193 data->data(), data->length(),
3194 AsChars(packet), arraysize(packet)); 3194 AsChars(packet), arraysize(packet));
3195 } 3195 }
3196 3196
3197 TEST_P(QuicFramerTest, BuildVersionNegotiationPacket) { 3197 TEST_P(QuicFramerTest, BuildVersionNegotiationPacket) {
3198 QuicPacketPublicHeader header;
3199 header.connection_id = UINT64_C(0xFEDCBA9876543210);
3200 header.reset_flag = false;
3201 header.version_flag = true;
3202
3203 // clang-format off 3198 // clang-format off
3204 unsigned char packet[] = { 3199 unsigned char packet[] = {
3205 // public flags (version, 8 byte connection_id) 3200 // public flags (version, 8 byte connection_id)
3206 0x0D, 3201 0x0D,
3207 // connection_id 3202 // connection_id
3208 0x10, 3203 0x10,
3209 0x32, 3204 0x32,
3210 0x54, 3205 0x54,
3211 0x76, 3206 0x76,
3212 0x98, 3207 0x98,
3213 0xBA, 3208 0xBA,
3214 0xDC, 3209 0xDC,
3215 0xFE, 3210 0xFE,
3216 // version tag 3211 // version tag
3217 'Q', 3212 'Q',
3218 '0', 3213 '0',
3219 GetQuicVersionDigitTens(), 3214 GetQuicVersionDigitTens(),
3220 GetQuicVersionDigitOnes(), 3215 GetQuicVersionDigitOnes(),
3221 }; 3216 };
3222 // clang-format on 3217 // clang-format on
3223 3218
3224 QuicVersionVector versions; 3219 QuicConnectionId connection_id = UINT64_C(0xFEDCBA9876543210);
3225 versions.push_back(GetParam()); 3220 scoped_ptr<QuicEncryptedPacket> data(framer_.BuildVersionNegotiationPacket(
3226 scoped_ptr<QuicEncryptedPacket> data( 3221 connection_id, SupportedVersions(GetParam())));
3227 framer_.BuildVersionNegotiationPacket(header, versions));
3228
3229 test::CompareCharArraysWithHexError("constructed packet", data->data(), 3222 test::CompareCharArraysWithHexError("constructed packet", data->data(),
3230 data->length(), AsChars(packet), 3223 data->length(), AsChars(packet),
3231 arraysize(packet)); 3224 arraysize(packet));
3232 } 3225 }
3233 3226
3234 TEST_P(QuicFramerTest, BuildAckFramePacket) { 3227 TEST_P(QuicFramerTest, BuildAckFramePacket) {
3235 QuicPacketHeader header; 3228 QuicPacketHeader header;
3236 header.public_header.connection_id = UINT64_C(0xFEDCBA9876543210); 3229 header.public_header.connection_id = UINT64_C(0xFEDCBA9876543210);
3237 header.public_header.reset_flag = false; 3230 header.public_header.reset_flag = false;
3238 header.public_header.version_flag = false; 3231 header.public_header.version_flag = false;
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after
4401 EXPECT_CALL(visitor, OnStreamFrame(_)).Times(0); 4394 EXPECT_CALL(visitor, OnStreamFrame(_)).Times(0);
4402 EXPECT_CALL(visitor, OnAckFrame(_)).Times(0); 4395 EXPECT_CALL(visitor, OnAckFrame(_)).Times(0);
4403 EXPECT_CALL(visitor, OnPacketComplete()).Times(0); 4396 EXPECT_CALL(visitor, OnPacketComplete()).Times(0);
4404 4397
4405 EXPECT_FALSE(framer_.ProcessPacket(*packet)); 4398 EXPECT_FALSE(framer_.ProcessPacket(*packet));
4406 EXPECT_EQ(QUIC_INVALID_PACKET_HEADER, framer_.error()); 4399 EXPECT_EQ(QUIC_INVALID_PACKET_HEADER, framer_.error());
4407 } 4400 }
4408 4401
4409 } // namespace test 4402 } // namespace test
4410 } // namespace net 4403 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_framer.cc ('k') | net/quic/quic_packet_creator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698