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

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

Issue 15937012: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Small bug fixes Created 7 years, 6 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 <algorithm> 5 #include <algorithm>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "net/quic/quic_fec_group.h" 10 #include "net/quic/quic_fec_group.h"
(...skipping 17 matching lines...) Expand all
28 28
29 const bool kEntropyFlag[] = { 29 const bool kEntropyFlag[] = {
30 false, 30 false,
31 true, 31 true,
32 true, 32 true,
33 false, 33 false,
34 true, 34 true,
35 true, 35 true,
36 }; 36 };
37 37
38 const bool kTestFecEntropy = false; 38 const bool kTestFecPacketEntropy = false;
39 39
40 } // namespace 40 } // namespace
41 41
42 class QuicFecGroupTest : public ::testing::Test { 42 class QuicFecGroupTest : public ::testing::Test {
43 protected: 43 protected:
44 void RunTest(size_t num_packets, size_t lost_packet, bool out_of_order) { 44 void RunTest(size_t num_packets, size_t lost_packet, bool out_of_order) {
45 size_t max_len = strlen(kData[0]); 45 size_t max_len = strlen(kData[0]);
46 scoped_ptr<char[]>redundancy(new char[max_len]); 46 scoped_ptr<char[]>redundancy(new char[max_len]);
47 bool entropy_redundancy = false; 47 bool entropy_redundancy = false;
48 for (size_t packet = 0; packet < num_packets; ++packet) { 48 for (size_t packet = 0; packet < num_packets; ++packet) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 150
151 QuicPacketHeader header; 151 QuicPacketHeader header;
152 header.packet_sequence_number = 3; 152 header.packet_sequence_number = 3;
153 group.Update(header, data1); 153 group.Update(header, data1);
154 154
155 QuicFecData fec; 155 QuicFecData fec;
156 fec.fec_group = 1; 156 fec.fec_group = 1;
157 fec.redundancy = redundancy; 157 fec.redundancy = redundancy;
158 158
159 header.packet_sequence_number = 2; 159 header.packet_sequence_number = 2;
160 ASSERT_FALSE(group.UpdateFec(2, kTestFecEntropy, fec)); 160 ASSERT_FALSE(group.UpdateFec(2, kTestFecPacketEntropy, fec));
161 } 161 }
162 162
163 TEST_F(QuicFecGroupTest, ProtectsPacketsBefore) { 163 TEST_F(QuicFecGroupTest, ProtectsPacketsBefore) {
164 QuicPacketHeader header; 164 QuicPacketHeader header;
165 header.packet_sequence_number = 3; 165 header.packet_sequence_number = 3;
166 166
167 QuicFecGroup group; 167 QuicFecGroup group;
168 ASSERT_TRUE(group.Update(header, kData[0])); 168 ASSERT_TRUE(group.Update(header, kData[0]));
169 169
170 EXPECT_FALSE(group.ProtectsPacketsBefore(1)); 170 EXPECT_FALSE(group.ProtectsPacketsBefore(1));
(...skipping 28 matching lines...) Expand all
199 EXPECT_TRUE(group.ProtectsPacketsBefore(9)); 199 EXPECT_TRUE(group.ProtectsPacketsBefore(9));
200 EXPECT_TRUE(group.ProtectsPacketsBefore(50)); 200 EXPECT_TRUE(group.ProtectsPacketsBefore(50));
201 } 201 }
202 202
203 TEST_F(QuicFecGroupTest, ProtectsPacketsBeforeWithFecData) { 203 TEST_F(QuicFecGroupTest, ProtectsPacketsBeforeWithFecData) {
204 QuicFecData fec; 204 QuicFecData fec;
205 fec.fec_group = 2; 205 fec.fec_group = 2;
206 fec.redundancy = kData[0]; 206 fec.redundancy = kData[0];
207 207
208 QuicFecGroup group; 208 QuicFecGroup group;
209 ASSERT_TRUE(group.UpdateFec(3, kTestFecEntropy, fec)); 209 ASSERT_TRUE(group.UpdateFec(3, kTestFecPacketEntropy, fec));
210 210
211 EXPECT_FALSE(group.ProtectsPacketsBefore(1)); 211 EXPECT_FALSE(group.ProtectsPacketsBefore(1));
212 EXPECT_FALSE(group.ProtectsPacketsBefore(2)); 212 EXPECT_FALSE(group.ProtectsPacketsBefore(2));
213 EXPECT_TRUE(group.ProtectsPacketsBefore(3)); 213 EXPECT_TRUE(group.ProtectsPacketsBefore(3));
214 EXPECT_TRUE(group.ProtectsPacketsBefore(4)); 214 EXPECT_TRUE(group.ProtectsPacketsBefore(4));
215 EXPECT_TRUE(group.ProtectsPacketsBefore(5)); 215 EXPECT_TRUE(group.ProtectsPacketsBefore(5));
216 EXPECT_TRUE(group.ProtectsPacketsBefore(50)); 216 EXPECT_TRUE(group.ProtectsPacketsBefore(50));
217 } 217 }
218 218
219 } // namespace net 219 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698