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

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

Issue 12806002: Land Recent QUIC Changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: minor comment fix Created 7 years, 9 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_packet_generator.cc ('k') | net/quic/quic_protocol.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 "net/quic/quic_packet_generator.h" 5 #include "net/quic/quic_packet_generator.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "net/quic/crypto/crypto_protocol.h" 9 #include "net/quic/crypto/crypto_protocol.h"
10 #include "net/quic/crypto/null_encrypter.h" 10 #include "net/quic/crypto/null_encrypter.h"
(...skipping 13 matching lines...) Expand all
24 24
25 namespace net { 25 namespace net {
26 namespace test { 26 namespace test {
27 namespace { 27 namespace {
28 28
29 class MockDelegate : public QuicPacketGenerator::DelegateInterface { 29 class MockDelegate : public QuicPacketGenerator::DelegateInterface {
30 public: 30 public:
31 MockDelegate() {} 31 MockDelegate() {}
32 virtual ~MockDelegate() {} 32 virtual ~MockDelegate() {}
33 33
34 MOCK_METHOD1(CanWrite, bool(bool is_retransmission)); 34 MOCK_METHOD2(CanWrite, bool(bool is_retransmission,
35 bool has_retransmittable_data));
35 36
36 MOCK_METHOD0(CreateAckFrame, QuicAckFrame*()); 37 MOCK_METHOD0(CreateAckFrame, QuicAckFrame*());
37 MOCK_METHOD0(CreateFeedbackFrame, QuicCongestionFeedbackFrame*()); 38 MOCK_METHOD0(CreateFeedbackFrame, QuicCongestionFeedbackFrame*());
38 MOCK_METHOD1(OnSerializedPacket, bool(const SerializedPacket& packet)); 39 MOCK_METHOD1(OnSerializedPacket, bool(const SerializedPacket& packet));
39 40
40 void SetCanWrite(bool can_write) { 41 void SetCanWrite(bool can_write) {
41 EXPECT_CALL(*this, CanWrite(false)).WillRepeatedly(Return(can_write)); 42 EXPECT_CALL(*this, CanWrite(false, _)).WillRepeatedly(Return(can_write));
42 } 43 }
43 44
44 private: 45 private:
45 DISALLOW_COPY_AND_ASSIGN(MockDelegate); 46 DISALLOW_COPY_AND_ASSIGN(MockDelegate);
46 }; 47 };
47 48
48 // Simple struct for describing the contents of a packet. 49 // Simple struct for describing the contents of a packet.
49 // Useful in conjunction with a SimpleQuicFrame for validating 50 // Useful in conjunction with a SimpleQuicFrame for validating
50 // that a packet contains the expected frames. 51 // that a packet contains the expected frames.
51 struct PacketContents { 52 struct PacketContents {
(...skipping 17 matching lines...) Expand all
69 QuicFecGroupNumber fec_group; 70 QuicFecGroupNumber fec_group;
70 }; 71 };
71 72
72 } // namespace 73 } // namespace
73 74
74 class QuicPacketGeneratorTest : public ::testing::Test { 75 class QuicPacketGeneratorTest : public ::testing::Test {
75 protected: 76 protected:
76 QuicPacketGeneratorTest() 77 QuicPacketGeneratorTest()
77 : framer_(kQuicVersion1, 78 : framer_(kQuicVersion1,
78 QuicDecrypter::Create(kNULL), 79 QuicDecrypter::Create(kNULL),
79 QuicEncrypter::Create(kNULL)), 80 QuicEncrypter::Create(kNULL),
80 creator_(42, &framer_, &random_), 81 false),
82 creator_(42, &framer_, &random_, false),
81 generator_(&delegate_, &creator_), 83 generator_(&delegate_, &creator_),
82 packet_(0, NULL, 0, NULL), 84 packet_(0, NULL, 0, NULL),
83 packet2_(0, NULL, 0, NULL), 85 packet2_(0, NULL, 0, NULL),
84 packet3_(0, NULL, 0, NULL), 86 packet3_(0, NULL, 0, NULL),
85 packet4_(0, NULL, 0, NULL), 87 packet4_(0, NULL, 0, NULL),
86 packet5_(0, NULL, 0, NULL) { 88 packet5_(0, NULL, 0, NULL) {
87 } 89 }
88 90
89 ~QuicPacketGeneratorTest() { 91 ~QuicPacketGeneratorTest() {
90 delete packet_.packet; 92 delete packet_.packet;
91 delete packet_.retransmittable_frames; 93 delete packet_.retransmittable_frames;
92 delete packet2_.packet; 94 delete packet2_.packet;
93 delete packet2_.retransmittable_frames; 95 delete packet2_.retransmittable_frames;
94 delete packet3_.packet; 96 delete packet3_.packet;
95 delete packet3_.retransmittable_frames; 97 delete packet3_.retransmittable_frames;
96 delete packet4_.packet; 98 delete packet4_.packet;
97 delete packet4_.retransmittable_frames; 99 delete packet4_.retransmittable_frames;
98 delete packet5_.packet; 100 delete packet5_.packet;
99 delete packet5_.retransmittable_frames; 101 delete packet5_.retransmittable_frames;
100 } 102 }
101 103
102 QuicAckFrame* CreateAckFrame() { 104 QuicAckFrame* CreateAckFrame() {
103 // TODO(rch): Initialize this so it can be verified later. 105 // TODO(rch): Initialize this so it can be verified later.
104 return new QuicAckFrame(0, 0); 106 return new QuicAckFrame(0, QuicTime::Zero(), 0);
105 } 107 }
106 108
107 QuicCongestionFeedbackFrame* CreateFeedbackFrame() { 109 QuicCongestionFeedbackFrame* CreateFeedbackFrame() {
108 QuicCongestionFeedbackFrame* frame = new QuicCongestionFeedbackFrame; 110 QuicCongestionFeedbackFrame* frame = new QuicCongestionFeedbackFrame;
109 frame->type = kFixRate; 111 frame->type = kFixRate;
110 frame->fix_rate.bitrate = QuicBandwidth::FromBytesPerSecond(42); 112 frame->fix_rate.bitrate = QuicBandwidth::FromBytesPerSecond(42);
111 return frame; 113 return frame;
112 } 114 }
113 115
114 QuicRstStreamFrame* CreateRstStreamFrame() { 116 QuicRstStreamFrame* CreateRstStreamFrame() {
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 503
502 // The second should have the remainder of the stream data. 504 // The second should have the remainder of the stream data.
503 PacketContents contents2; 505 PacketContents contents2;
504 contents2.num_goaway_frames = 1; 506 contents2.num_goaway_frames = 1;
505 contents2.num_stream_frames = 1; 507 contents2.num_stream_frames = 1;
506 CheckPacketContains(contents2, packet2_); 508 CheckPacketContains(contents2, packet2_);
507 } 509 }
508 510
509 } // namespace test 511 } // namespace test
510 } // namespace net 512 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_packet_generator.cc ('k') | net/quic/quic_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698