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

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

Issue 1979763002: Landing Recent QUIC changes until Sun May 8 00:39:29 2016 +0000 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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/quic_framer.cc ('k') | net/quic/quic_headers_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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } 248 }
249 ++packet_count_; 249 ++packet_count_;
250 header_.reset(new QuicPacketHeader(header)); 250 header_.reset(new QuicPacketHeader(header));
251 return accept_packet_; 251 return accept_packet_;
252 } 252 }
253 253
254 bool OnStreamFrame(const QuicStreamFrame& frame) override { 254 bool OnStreamFrame(const QuicStreamFrame& frame) override {
255 ++frame_count_; 255 ++frame_count_;
256 // Save a copy of the data so it is valid after the packet is processed. 256 // Save a copy of the data so it is valid after the packet is processed.
257 string* string_data = new string(); 257 string* string_data = new string();
258 StringPiece(frame.frame_buffer, frame.frame_length) 258 StringPiece(frame.data_buffer, frame.data_length)
259 .AppendToString(string_data); 259 .AppendToString(string_data);
260 stream_data_.push_back(string_data); 260 stream_data_.push_back(string_data);
261 stream_frames_.push_back(new QuicStreamFrame(frame.stream_id, frame.fin, 261 stream_frames_.push_back(new QuicStreamFrame(frame.stream_id, frame.fin,
262 frame.offset, *string_data)); 262 frame.offset, *string_data));
263 return true; 263 return true;
264 } 264 }
265 265
266 bool OnAckFrame(const QuicAckFrame& frame) override { 266 bool OnAckFrame(const QuicAckFrame& frame) override {
267 ++frame_count_; 267 ++frame_count_;
268 ack_frames_.push_back(new QuicAckFrame(frame)); 268 ack_frames_.push_back(new QuicAckFrame(frame));
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 string expected_error, 439 string expected_error,
440 QuicErrorCode error_code) { 440 QuicErrorCode error_code) {
441 QuicEncryptedPacket encrypted(AsChars(packet), len, false); 441 QuicEncryptedPacket encrypted(AsChars(packet), len, false);
442 EXPECT_FALSE(framer_.ProcessPacket(encrypted)) << "len: " << len; 442 EXPECT_FALSE(framer_.ProcessPacket(encrypted)) << "len: " << len;
443 EXPECT_EQ(expected_error, framer_.detailed_error()) << "len: " << len; 443 EXPECT_EQ(expected_error, framer_.detailed_error()) << "len: " << len;
444 EXPECT_EQ(error_code, framer_.error()) << "len: " << len; 444 EXPECT_EQ(error_code, framer_.error()) << "len: " << len;
445 } 445 }
446 446
447 // Checks if the supplied string matches data in the supplied StreamFrame. 447 // Checks if the supplied string matches data in the supplied StreamFrame.
448 void CheckStreamFrameData(string str, QuicStreamFrame* frame) { 448 void CheckStreamFrameData(string str, QuicStreamFrame* frame) {
449 EXPECT_EQ(str, string(frame->frame_buffer, frame->frame_length)); 449 EXPECT_EQ(str, string(frame->data_buffer, frame->data_length));
450 } 450 }
451 451
452 void CheckStreamFrameBoundaries(unsigned char* packet, 452 void CheckStreamFrameBoundaries(unsigned char* packet,
453 size_t stream_id_size, 453 size_t stream_id_size,
454 bool include_version) { 454 bool include_version) {
455 // Now test framing boundaries. 455 // Now test framing boundaries.
456 for (size_t i = kQuicFrameTypeSize; i < GetMinStreamFrameSize(); ++i) { 456 for (size_t i = kQuicFrameTypeSize; i < GetMinStreamFrameSize(); ++i) {
457 string expected_error; 457 string expected_error;
458 if (i < kQuicFrameTypeSize + stream_id_size) { 458 if (i < kQuicFrameTypeSize + stream_id_size) {
459 expected_error = "Unable to read stream_id."; 459 expected_error = "Unable to read stream_id.";
(...skipping 6492 matching lines...) Expand 10 before | Expand all | Expand 10 after
6952 false); 6952 false);
6953 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); 6953 EXPECT_TRUE(framer_.ProcessPacket(encrypted));
6954 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); 6954 EXPECT_EQ(QUIC_NO_ERROR, framer_.error());
6955 } 6955 }
6956 6956
6957 static char kTestString[] = "At least 20 characters."; 6957 static char kTestString[] = "At least 20 characters.";
6958 static QuicStreamId kTestQuicStreamId = 1; 6958 static QuicStreamId kTestQuicStreamId = 1;
6959 static bool ExpectedStreamFrame(const QuicStreamFrame& frame) { 6959 static bool ExpectedStreamFrame(const QuicStreamFrame& frame) {
6960 return frame.stream_id == kTestQuicStreamId && !frame.fin && 6960 return frame.stream_id == kTestQuicStreamId && !frame.fin &&
6961 frame.offset == 0 && 6961 frame.offset == 0 &&
6962 string(frame.frame_buffer, frame.frame_length) == kTestString; 6962 string(frame.data_buffer, frame.data_length) == kTestString;
6963 // FIN is hard-coded false in ConstructEncryptedPacket. 6963 // FIN is hard-coded false in ConstructEncryptedPacket.
6964 // Offset 0 is hard-coded in ConstructEncryptedPacket. 6964 // Offset 0 is hard-coded in ConstructEncryptedPacket.
6965 } 6965 }
6966 6966
6967 // Verify that the packet returned by ConstructEncryptedPacket() can be properly 6967 // Verify that the packet returned by ConstructEncryptedPacket() can be properly
6968 // parsed by the framer. 6968 // parsed by the framer.
6969 TEST_P(QuicFramerTest, ConstructEncryptedPacket) { 6969 TEST_P(QuicFramerTest, ConstructEncryptedPacket) {
6970 // Since we are using ConstructEncryptedPacket, we have to set the framer's 6970 // Since we are using ConstructEncryptedPacket, we have to set the framer's
6971 // crypto to be Null. 6971 // crypto to be Null.
6972 framer_.SetDecrypter(ENCRYPTION_NONE, QuicDecrypter::Create(kNULL)); 6972 framer_.SetDecrypter(ENCRYPTION_NONE, QuicDecrypter::Create(kNULL));
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
7096 'o', ' ', 'w', 'o', 7096 'o', ' ', 'w', 'o',
7097 'r', 'l', 'd', '!', 7097 'r', 'l', 'd', '!',
7098 }; 7098 };
7099 // clang-format on 7099 // clang-format on
7100 7100
7101 QuicFramerFuzzFunc(packet, arraysize(packet)); 7101 QuicFramerFuzzFunc(packet, arraysize(packet));
7102 } 7102 }
7103 7103
7104 } // namespace test 7104 } // namespace test
7105 } // namespace net 7105 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_framer.cc ('k') | net/quic/quic_headers_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698