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

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

Issue 908493004: Landing Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix valgrind error Created 5 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/quic_framer.cc ('k') | net/quic/quic_http_stream_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/quic_framer.h" 5 #include "net/quic/quic_framer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 1305
1306 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 1306 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
1307 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); 1307 EXPECT_TRUE(framer_.ProcessPacket(encrypted));
1308 1308
1309 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); 1309 EXPECT_EQ(QUIC_NO_ERROR, framer_.error());
1310 ASSERT_TRUE(visitor_.header_.get()); 1310 ASSERT_TRUE(visitor_.header_.get());
1311 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion)); 1311 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion));
1312 1312
1313 ASSERT_EQ(1u, visitor_.stream_frames_.size()); 1313 ASSERT_EQ(1u, visitor_.stream_frames_.size());
1314 EXPECT_EQ(0u, visitor_.ack_frames_.size()); 1314 EXPECT_EQ(0u, visitor_.ack_frames_.size());
1315 EXPECT_EQ(GG_UINT64_C(0x00020304), 1315 EXPECT_EQ(GG_UINT64_C(0x00020304), visitor_.stream_frames_[0]->stream_id);
1316 visitor_.stream_frames_[0]->stream_id);
1317 EXPECT_TRUE(visitor_.stream_frames_[0]->fin); 1316 EXPECT_TRUE(visitor_.stream_frames_[0]->fin);
1318 EXPECT_EQ(GG_UINT64_C(0xBA98FEDC32107654), 1317 EXPECT_EQ(GG_UINT64_C(0xBA98FEDC32107654),
1319 visitor_.stream_frames_[0]->offset); 1318 visitor_.stream_frames_[0]->offset);
1320 CheckStreamFrameData("hello world!", visitor_.stream_frames_[0]); 1319 CheckStreamFrameData("hello world!", visitor_.stream_frames_[0]);
1321 1320
1322 // Now test framing boundaries. 1321 // Now test framing boundaries.
1323 const size_t stream_id_size = 3; 1322 const size_t stream_id_size = 3;
1324 CheckStreamFrameBoundaries(packet, stream_id_size, !kIncludeVersion); 1323 CheckStreamFrameBoundaries(packet, stream_id_size, !kIncludeVersion);
1325 } 1324 }
1326 1325
(...skipping 2602 matching lines...) Expand 10 before | Expand all | Expand 10 after
3929 // first fec protected packet offset 3928 // first fec protected packet offset
3930 0x01, 3929 0x01,
3931 3930
3932 // redundancy 3931 // redundancy
3933 'a', 'b', 'c', 'd', 3932 'a', 'b', 'c', 'd',
3934 'e', 'f', 'g', 'h', 3933 'e', 'f', 'g', 'h',
3935 'i', 'j', 'k', 'l', 3934 'i', 'j', 'k', 'l',
3936 'm', 'n', 'o', 'p', 3935 'm', 'n', 'o', 'p',
3937 }; 3936 };
3938 3937
3939 scoped_ptr<QuicPacket> raw( 3938 scoped_ptr<QuicPacket> raw(new QuicPacket(
3940 QuicPacket::NewDataPacket(AsChars(packet), arraysize(packet), false, 3939 AsChars(packet), arraysize(packet), false, PACKET_8BYTE_CONNECTION_ID,
3941 PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, 3940 !kIncludeVersion, PACKET_6BYTE_SEQUENCE_NUMBER));
3942 PACKET_6BYTE_SEQUENCE_NUMBER));
3943 scoped_ptr<QuicEncryptedPacket> encrypted( 3941 scoped_ptr<QuicEncryptedPacket> encrypted(
3944 framer_.EncryptPacket(ENCRYPTION_NONE, sequence_number, *raw)); 3942 framer_.EncryptPacket(ENCRYPTION_NONE, sequence_number, *raw));
3945 3943
3946 ASSERT_TRUE(encrypted.get() != nullptr); 3944 ASSERT_TRUE(encrypted.get() != nullptr);
3947 EXPECT_TRUE(CheckEncryption(sequence_number, raw.get())); 3945 EXPECT_TRUE(CheckEncryption(sequence_number, raw.get()));
3948 } 3946 }
3949 3947
3950 TEST_P(QuicFramerTest, EncryptPacketWithVersionFlag) { 3948 TEST_P(QuicFramerTest, EncryptPacketWithVersionFlag) {
3951 QuicPacketSequenceNumber sequence_number = GG_UINT64_C(0x123456789ABC); 3949 QuicPacketSequenceNumber sequence_number = GG_UINT64_C(0x123456789ABC);
3952 unsigned char packet[] = { 3950 unsigned char packet[] = {
(...skipping 12 matching lines...) Expand all
3965 // first fec protected packet offset 3963 // first fec protected packet offset
3966 0x01, 3964 0x01,
3967 3965
3968 // redundancy 3966 // redundancy
3969 'a', 'b', 'c', 'd', 3967 'a', 'b', 'c', 'd',
3970 'e', 'f', 'g', 'h', 3968 'e', 'f', 'g', 'h',
3971 'i', 'j', 'k', 'l', 3969 'i', 'j', 'k', 'l',
3972 'm', 'n', 'o', 'p', 3970 'm', 'n', 'o', 'p',
3973 }; 3971 };
3974 3972
3975 scoped_ptr<QuicPacket> raw( 3973 scoped_ptr<QuicPacket> raw(new QuicPacket(
3976 QuicPacket::NewDataPacket(AsChars(packet), arraysize(packet), false, 3974 AsChars(packet), arraysize(packet), false, PACKET_8BYTE_CONNECTION_ID,
3977 PACKET_8BYTE_CONNECTION_ID, kIncludeVersion, 3975 kIncludeVersion, PACKET_6BYTE_SEQUENCE_NUMBER));
3978 PACKET_6BYTE_SEQUENCE_NUMBER));
3979 scoped_ptr<QuicEncryptedPacket> encrypted( 3976 scoped_ptr<QuicEncryptedPacket> encrypted(
3980 framer_.EncryptPacket(ENCRYPTION_NONE, sequence_number, *raw)); 3977 framer_.EncryptPacket(ENCRYPTION_NONE, sequence_number, *raw));
3981 3978
3982 ASSERT_TRUE(encrypted.get() != nullptr); 3979 ASSERT_TRUE(encrypted.get() != nullptr);
3983 EXPECT_TRUE(CheckEncryption(sequence_number, raw.get())); 3980 EXPECT_TRUE(CheckEncryption(sequence_number, raw.get()));
3984 } 3981 }
3985 3982
3986 TEST_P(QuicFramerTest, AckTruncationLargePacket) { 3983 TEST_P(QuicFramerTest, AckTruncationLargePacket) {
3987 QuicPacketHeader header; 3984 QuicPacketHeader header;
3988 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 3985 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
4237 EXPECT_CALL(visitor, OnPacketComplete()); 4234 EXPECT_CALL(visitor, OnPacketComplete());
4238 EXPECT_CALL(visitor, OnUnauthenticatedPublicHeader(_)).WillOnce(Return(true)); 4235 EXPECT_CALL(visitor, OnUnauthenticatedPublicHeader(_)).WillOnce(Return(true));
4239 4236
4240 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 4237 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
4241 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); 4238 EXPECT_TRUE(framer_.ProcessPacket(encrypted));
4242 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); 4239 EXPECT_EQ(QUIC_NO_ERROR, framer_.error());
4243 } 4240 }
4244 4241
4245 } // namespace test 4242 } // namespace test
4246 } // namespace net 4243 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_framer.cc ('k') | net/quic/quic_http_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698