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

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

Issue 126283002: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed extra space Created 6 years, 11 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/quic_end_to_end_unittest.cc ('k') | net/quic/quic_headers_stream.h » ('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 <algorithm> 5 #include <algorithm>
6 #include <map> 6 #include <map>
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // Public resets always have full guids. 90 // Public resets always have full guids.
91 const size_t kPublicResetPacketNonceProofOffset = 91 const size_t kPublicResetPacketNonceProofOffset =
92 kGuidOffset + PACKET_8BYTE_GUID; 92 kGuidOffset + PACKET_8BYTE_GUID;
93 93
94 // Index into the rejected sequence number of the public reset packet. 94 // Index into the rejected sequence number of the public reset packet.
95 const size_t kPublicResetPacketRejectedSequenceNumberOffset = 95 const size_t kPublicResetPacketRejectedSequenceNumberOffset =
96 kPublicResetPacketNonceProofOffset + kPublicResetNonceSize; 96 kPublicResetPacketNonceProofOffset + kPublicResetNonceSize;
97 97
98 class TestEncrypter : public QuicEncrypter { 98 class TestEncrypter : public QuicEncrypter {
99 public: 99 public:
100 virtual ~TestEncrypter() {} 100 virtual ~TestEncrypter() OVERRIDE {}
101 virtual bool SetKey(StringPiece key) OVERRIDE { 101 virtual bool SetKey(StringPiece key) OVERRIDE {
102 return true; 102 return true;
103 } 103 }
104 virtual bool SetNoncePrefix(StringPiece nonce_prefix) OVERRIDE { 104 virtual bool SetNoncePrefix(StringPiece nonce_prefix) OVERRIDE {
105 return true; 105 return true;
106 } 106 }
107 virtual bool Encrypt(StringPiece nonce, 107 virtual bool Encrypt(StringPiece nonce,
108 StringPiece associated_data, 108 StringPiece associated_data,
109 StringPiece plaintext, 109 StringPiece plaintext,
110 unsigned char* output) OVERRIDE { 110 unsigned char* output) OVERRIDE {
(...skipping 26 matching lines...) Expand all
137 virtual StringPiece GetNoncePrefix() const OVERRIDE { 137 virtual StringPiece GetNoncePrefix() const OVERRIDE {
138 return StringPiece(); 138 return StringPiece();
139 } 139 }
140 QuicPacketSequenceNumber sequence_number_; 140 QuicPacketSequenceNumber sequence_number_;
141 string associated_data_; 141 string associated_data_;
142 string plaintext_; 142 string plaintext_;
143 }; 143 };
144 144
145 class TestDecrypter : public QuicDecrypter { 145 class TestDecrypter : public QuicDecrypter {
146 public: 146 public:
147 virtual ~TestDecrypter() {} 147 virtual ~TestDecrypter() OVERRIDE {}
148 virtual bool SetKey(StringPiece key) OVERRIDE { 148 virtual bool SetKey(StringPiece key) OVERRIDE {
149 return true; 149 return true;
150 } 150 }
151 virtual bool SetNoncePrefix(StringPiece nonce_prefix) OVERRIDE { 151 virtual bool SetNoncePrefix(StringPiece nonce_prefix) OVERRIDE {
152 return true; 152 return true;
153 } 153 }
154 virtual bool Decrypt(StringPiece nonce, 154 virtual bool Decrypt(StringPiece nonce,
155 StringPiece associated_data, 155 StringPiece associated_data,
156 StringPiece ciphertext, 156 StringPiece ciphertext,
157 unsigned char* output, 157 unsigned char* output,
(...skipping 27 matching lines...) Expand all
185 version_mismatch_(0), 185 version_mismatch_(0),
186 packet_count_(0), 186 packet_count_(0),
187 frame_count_(0), 187 frame_count_(0),
188 fec_count_(0), 188 fec_count_(0),
189 complete_packets_(0), 189 complete_packets_(0),
190 revived_packets_(0), 190 revived_packets_(0),
191 accept_packet_(true), 191 accept_packet_(true),
192 accept_public_header_(true) { 192 accept_public_header_(true) {
193 } 193 }
194 194
195 virtual ~TestQuicVisitor() { 195 virtual ~TestQuicVisitor() OVERRIDE {
196 STLDeleteElements(&stream_frames_); 196 STLDeleteElements(&stream_frames_);
197 STLDeleteElements(&ack_frames_); 197 STLDeleteElements(&ack_frames_);
198 STLDeleteElements(&congestion_feedback_frames_); 198 STLDeleteElements(&congestion_feedback_frames_);
199 STLDeleteElements(&fec_data_); 199 STLDeleteElements(&fec_data_);
200 } 200 }
201 201
202 virtual void OnError(QuicFramer* f) OVERRIDE { 202 virtual void OnError(QuicFramer* f) OVERRIDE {
203 DLOG(INFO) << "QuicFramer Error: " << QuicUtils::ErrorToString(f->error()) 203 DLOG(INFO) << "QuicFramer Error: " << QuicUtils::ErrorToString(f->error())
204 << " (" << f->error() << ")"; 204 << " (" << f->error() << ")";
205 error_count_++; 205 error_count_++;
(...skipping 3239 matching lines...) Expand 10 before | Expand all | Expand 10 after
3445 3445
3446 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 3446 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
3447 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); 3447 EXPECT_TRUE(framer_.ProcessPacket(encrypted));
3448 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); 3448 EXPECT_EQ(QUIC_NO_ERROR, framer_.error());
3449 ASSERT_TRUE(visitor_.header_.get()); 3449 ASSERT_TRUE(visitor_.header_.get());
3450 EXPECT_TRUE(visitor_.header_->fec_flag); 3450 EXPECT_TRUE(visitor_.header_->fec_flag);
3451 EXPECT_TRUE(visitor_.header_->entropy_flag); 3451 EXPECT_TRUE(visitor_.header_->entropy_flag);
3452 EXPECT_EQ(1 << 4, visitor_.header_->entropy_hash); 3452 EXPECT_EQ(1 << 4, visitor_.header_->entropy_hash);
3453 }; 3453 };
3454 3454
3455 // http://crbug.com/331630. TODO(rtenneti): fix the uninitialized memory issue. 3455 TEST_P(QuicFramerTest, StopPacketProcessing) {
3456 TEST_P(QuicFramerTest, DISABLED_StopPacketProcessing) {
3457 unsigned char packet[] = { 3456 unsigned char packet[] = {
3458 // public flags (8 byte guid) 3457 // public flags (8 byte guid)
3459 0x3C, 3458 0x3C,
3460 // guid 3459 // guid
3461 0x10, 0x32, 0x54, 0x76, 3460 0x10, 0x32, 0x54, 0x76,
3462 0x98, 0xBA, 0xDC, 0xFE, 3461 0x98, 0xBA, 0xDC, 0xFE,
3463 // packet sequence number 3462 // packet sequence number
3464 0xBC, 0x9A, 0x78, 0x56, 3463 0xBC, 0x9A, 0x78, 0x56,
3465 0x34, 0x12, 3464 0x34, 0x12,
3466 // Entropy 3465 // Entropy
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3499 0x34, 0x12, 3498 0x34, 0x12,
3500 }; 3499 };
3501 3500
3502 MockFramerVisitor visitor; 3501 MockFramerVisitor visitor;
3503 framer_.set_visitor(&visitor); 3502 framer_.set_visitor(&visitor);
3504 EXPECT_CALL(visitor, OnPacket()); 3503 EXPECT_CALL(visitor, OnPacket());
3505 EXPECT_CALL(visitor, OnPacketHeader(_)); 3504 EXPECT_CALL(visitor, OnPacketHeader(_));
3506 EXPECT_CALL(visitor, OnStreamFrame(_)).WillOnce(Return(false)); 3505 EXPECT_CALL(visitor, OnStreamFrame(_)).WillOnce(Return(false));
3507 EXPECT_CALL(visitor, OnAckFrame(_)).Times(0); 3506 EXPECT_CALL(visitor, OnAckFrame(_)).Times(0);
3508 EXPECT_CALL(visitor, OnPacketComplete()); 3507 EXPECT_CALL(visitor, OnPacketComplete());
3508 EXPECT_CALL(visitor, OnUnauthenticatedPublicHeader(_)).WillOnce(Return(true));
3509 3509
3510 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 3510 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
3511 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); 3511 EXPECT_TRUE(framer_.ProcessPacket(encrypted));
3512 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); 3512 EXPECT_EQ(QUIC_NO_ERROR, framer_.error());
3513 } 3513 }
3514 3514
3515 } // namespace test 3515 } // namespace test
3516 } // namespace net 3516 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_end_to_end_unittest.cc ('k') | net/quic/quic_headers_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698