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

Side by Side Diff: net/tools/quic/quic_epoll_connection_helper_test.cc

Issue 25443002: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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
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/tools/quic/quic_epoll_connection_helper.h" 5 #include "net/tools/quic/quic_epoll_connection_helper.h"
6 6
7 #include "net/quic/crypto/crypto_protocol.h" 7 #include "net/quic/crypto/crypto_protocol.h"
8 #include "net/quic/crypto/quic_decrypter.h" 8 #include "net/quic/crypto/quic_decrypter.h"
9 #include "net/quic/crypto/quic_encrypter.h" 9 #include "net/quic/crypto/quic_encrypter.h"
10 #include "net/quic/crypto/quic_random.h" 10 #include "net/quic/crypto/quic_random.h"
(...skipping 12 matching lines...) Expand all
23 using net::tools::test::MockEpollServer; 23 using net::tools::test::MockEpollServer;
24 using testing::_; 24 using testing::_;
25 using testing::AnyNumber; 25 using testing::AnyNumber;
26 using testing::Return; 26 using testing::Return;
27 27
28 namespace net { 28 namespace net {
29 namespace tools { 29 namespace tools {
30 namespace test { 30 namespace test {
31 namespace { 31 namespace {
32 32
33 const char data1[] = "foo"; 33 const char kData[] = "foo";
34 const bool kFromPeer = true; 34 const bool kFromPeer = true;
35 35
36 class TestConnectionHelper : public QuicEpollConnectionHelper { 36 class TestConnectionHelper : public QuicEpollConnectionHelper {
37 public: 37 public:
38 TestConnectionHelper(int fd, EpollServer* eps) 38 TestConnectionHelper(int fd, EpollServer* eps)
39 : QuicEpollConnectionHelper(fd, eps) { 39 : QuicEpollConnectionHelper(fd, eps) {
40 } 40 }
41 41
42 virtual int WritePacketToWire(const QuicEncryptedPacket& packet, 42 virtual int WritePacketToWire(const QuicEncryptedPacket& packet,
43 int* error) OVERRIDE { 43 int* error) OVERRIDE {
(...skipping 30 matching lines...) Expand all
74 }; 74 };
75 75
76 class QuicEpollConnectionHelperTest : public ::testing::Test { 76 class QuicEpollConnectionHelperTest : public ::testing::Test {
77 protected: 77 protected:
78 QuicEpollConnectionHelperTest() 78 QuicEpollConnectionHelperTest()
79 : guid_(42), 79 : guid_(42),
80 framer_(QuicVersionMax(), QuicTime::Zero(), false), 80 framer_(QuicVersionMax(), QuicTime::Zero(), false),
81 send_algorithm_(new testing::StrictMock<MockSendAlgorithm>), 81 send_algorithm_(new testing::StrictMock<MockSendAlgorithm>),
82 helper_(new TestConnectionHelper(0, &epoll_server_)), 82 helper_(new TestConnectionHelper(0, &epoll_server_)),
83 connection_(guid_, IPEndPoint(), helper_), 83 connection_(guid_, IPEndPoint(), helper_),
84 frame1_(3, false, 0, data1) { 84 frame_(3, false, 0, kData) {
85 connection_.set_visitor(&visitor_); 85 connection_.set_visitor(&visitor_);
86 connection_.SetSendAlgorithm(send_algorithm_); 86 connection_.SetSendAlgorithm(send_algorithm_);
87 epoll_server_.set_timeout_in_us(-1); 87 epoll_server_.set_timeout_in_us(-1);
88 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _, _)). 88 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _, _)).
89 WillRepeatedly(Return(QuicTime::Delta::Zero())); 89 WillRepeatedly(Return(QuicTime::Delta::Zero()));
90 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillRepeatedly(Return( 90 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillRepeatedly(Return(
91 QuicBandwidth::FromKBitsPerSecond(100))); 91 QuicBandwidth::FromKBitsPerSecond(100)));
92 EXPECT_CALL(*send_algorithm_, SmoothedRtt()).WillRepeatedly(Return( 92 EXPECT_CALL(*send_algorithm_, SmoothedRtt()).WillRepeatedly(Return(
93 QuicTime::Delta::FromMilliseconds(100))); 93 QuicTime::Delta::FromMilliseconds(100)));
94 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 94 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
95 .WillByDefault(Return(true)); 95 .WillByDefault(Return(true));
96 } 96 }
97 97
98 QuicPacket* ConstructDataPacket(QuicPacketSequenceNumber number, 98 QuicPacket* ConstructDataPacket(QuicPacketSequenceNumber number,
99 QuicFecGroupNumber fec_group) { 99 QuicFecGroupNumber fec_group) {
100 header_.public_header.version_flag = false; 100 header_.public_header.version_flag = false;
101 header_.public_header.reset_flag = false; 101 header_.public_header.reset_flag = false;
102 header_.fec_flag = false; 102 header_.fec_flag = false;
103 header_.entropy_flag = false; 103 header_.entropy_flag = false;
104 header_.packet_sequence_number = number; 104 header_.packet_sequence_number = number;
105 header_.is_in_fec_group = fec_group == 0 ? NOT_IN_FEC_GROUP : IN_FEC_GROUP; 105 header_.is_in_fec_group = fec_group == 0 ? NOT_IN_FEC_GROUP : IN_FEC_GROUP;
106 header_.fec_group = fec_group; 106 header_.fec_group = fec_group;
107 107
108 QuicFrames frames; 108 QuicFrames frames;
109 QuicFrame frame(&frame1_); 109 frames.push_back(QuicFrame(&frame_));
110 frames.push_back(frame);
111 return framer_.BuildUnsizedDataPacket(header_, frames).packet; 110 return framer_.BuildUnsizedDataPacket(header_, frames).packet;
112 } 111 }
113 112
114 QuicGuid guid_; 113 QuicGuid guid_;
115 QuicFramer framer_; 114 QuicFramer framer_;
116 115
117 MockEpollServer epoll_server_; 116 MockEpollServer epoll_server_;
118 testing::StrictMock<MockSendAlgorithm>* send_algorithm_; 117 testing::StrictMock<MockSendAlgorithm>* send_algorithm_;
119 TestConnectionHelper* helper_; 118 TestConnectionHelper* helper_;
120 TestConnection connection_; 119 TestConnection connection_;
121 testing::StrictMock<MockConnectionVisitor> visitor_; 120 testing::StrictMock<MockConnectionVisitor> visitor_;
122 121
123 QuicPacketHeader header_; 122 QuicPacketHeader header_;
124 QuicStreamFrame frame1_; 123 QuicStreamFrame frame_;
125 }; 124 };
126 125
127 TEST_F(QuicEpollConnectionHelperTest, DISABLED_TestRTORetransmission) { 126 TEST_F(QuicEpollConnectionHelperTest, DISABLED_TestRTORetransmission) {
128 //FLAGS_fake_packet_loss_percentage = 100; 127 //FLAGS_fake_packet_loss_percentage = 100;
129 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()).WillRepeatedly( 128 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()).WillRepeatedly(
130 Return(QuicTime::Delta::Zero())); 129 Return(QuicTime::Delta::Zero()));
131 const int64 kDefaultRetransmissionTimeMs = 500; 130 const int64 kDefaultRetransmissionTimeMs = 500;
132 131
133 const char buffer[] = "foo"; 132 const char buffer[] = "foo";
134 const size_t packet_size = 133 const size_t packet_size =
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(Return(true)); 220 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(Return(true));
222 EXPECT_CALL(visitor_, HasPendingHandshake()).Times(AnyNumber()); 221 EXPECT_CALL(visitor_, HasPendingHandshake()).Times(AnyNumber());
223 epoll_server_.AdvanceByAndCallCallbacks(1); 222 epoll_server_.AdvanceByAndCallCallbacks(1);
224 EXPECT_EQ(0u, connection_.NumQueuedPackets()); 223 EXPECT_EQ(0u, connection_.NumQueuedPackets());
225 } 224 }
226 225
227 } // namespace 226 } // namespace
228 } // namespace test 227 } // namespace test
229 } // namespace tools 228 } // namespace tools
230 } // namespace net 229 } // namespace net
OLDNEW
« net/quic/quic_sent_packet_manager.cc ('K') | « net/quic/quic_sent_packet_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698