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

Unified Diff: net/quic/quic_fec_group_test.cc

Issue 12334063: Land recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more EXPECT_FALSE Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/quic_fec_group.cc ('k') | net/quic/quic_framer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_fec_group_test.cc
diff --git a/net/quic/quic_fec_group_test.cc b/net/quic/quic_fec_group_test.cc
index 4e4dd2014cd88db8cc48aef9c62039fbf751b12d..2dd4a7de6092dd20947e90f7e34be221b0bb6102 100644
--- a/net/quic/quic_fec_group_test.cc
+++ b/net/quic/quic_fec_group_test.cc
@@ -18,14 +18,25 @@ namespace net {
namespace {
const char* kData[] = {
- "abc12345678",
- "987defg",
- "ghi12345",
- "987jlkmno",
- "mno4567890",
- "789pqrstuvw",
+ "abc12345678",
+ "987defg",
+ "ghi12345",
+ "987jlkmno",
+ "mno4567890",
+ "789pqrstuvw",
};
+const bool kEntropyFlag[] = {
+ false,
+ true,
+ true,
+ false,
+ true,
+ true,
+};
+
+const bool kTestFecEntropy = false;
+
} // namespace
class QuicFecGroupTest : public ::testing::Test {
@@ -33,14 +44,19 @@ class QuicFecGroupTest : public ::testing::Test {
void RunTest(size_t num_packets, size_t lost_packet, bool out_of_order) {
size_t max_len = strlen(kData[0]);
scoped_array<char>redundancy(new char[max_len]);
- for (size_t i = 0; i < max_len; i++) {
- // Initialize to the first packet.
- redundancy[i] = kData[0][i];
- // XOR in the remaining packets.
- for (size_t packet = 1; packet < num_packets; packet++) {
+ bool entropy_redundancy = false;
+ for (size_t packet = 0; packet < num_packets; ++packet) {
+ for (size_t i = 0; i < max_len; i++) {
+ if (packet == 0) {
+ // Initialize to the first packet.
+ redundancy[i] = kData[0][i];
+ continue;
+ }
+ // XOR in the remaining packets.
uint8 byte = i > strlen(kData[packet]) ? 0x00 : kData[packet][i];
redundancy[i] = redundancy[i] ^ byte;
}
+ entropy_redundancy = (entropy_redundancy != kEntropyFlag[packet]);
}
QuicFecGroup group;
@@ -55,10 +71,11 @@ class QuicFecGroupTest : public ::testing::Test {
QuicFecData fec;
fec.fec_group = 0;
fec.redundancy = StringPiece(redundancy.get(), strlen(kData[0]));
- ASSERT_TRUE(group.UpdateFec(num_packets, fec));
+ ASSERT_TRUE(group.UpdateFec(num_packets, entropy_redundancy, fec));
} else {
QuicPacketHeader header;
header.packet_sequence_number = packet;
+ header.entropy_flag = kEntropyFlag[packet];
ASSERT_TRUE(group.Update(header, kData[packet]));
}
ASSERT_TRUE(group.CanRevive() == (packet == num_packets - 1));
@@ -72,6 +89,7 @@ class QuicFecGroupTest : public ::testing::Test {
QuicPacketHeader header;
header.packet_sequence_number = packet;
+ header.entropy_flag = kEntropyFlag[packet];
ASSERT_TRUE(group.Update(header, kData[packet]));
ASSERT_FALSE(group.CanRevive());
}
@@ -82,7 +100,7 @@ class QuicFecGroupTest : public ::testing::Test {
fec.fec_group = 0;
fec.redundancy = StringPiece(redundancy.get(), strlen(kData[0]));
- ASSERT_TRUE(group.UpdateFec(num_packets, fec));
+ ASSERT_TRUE(group.UpdateFec(num_packets, entropy_redundancy, fec));
}
QuicPacketHeader header;
char recovered[kMaxPacketSize];
@@ -94,6 +112,7 @@ class QuicFecGroupTest : public ::testing::Test {
EXPECT_EQ(lost_packet, header.packet_sequence_number)
<< "Failed to revive packet " << lost_packet << " out of "
<< num_packets;
+ EXPECT_EQ(kEntropyFlag[lost_packet], header.entropy_flag);
ASSERT_GE(len, strlen(kData[lost_packet])) << "Incorrect length";
for (size_t i = 0; i < strlen(kData[lost_packet]); i++) {
EXPECT_EQ(kData[lost_packet][i], recovered[i]);
@@ -137,7 +156,8 @@ TEST_F(QuicFecGroupTest, UpdateFecIfReceivedPacketIsNotCovered) {
fec.fec_group = 1;
fec.redundancy = redundancy;
- ASSERT_FALSE(group.UpdateFec(2, fec));
+ header.packet_sequence_number = 2;
+ ASSERT_FALSE(group.UpdateFec(2, kTestFecEntropy, fec));
}
TEST_F(QuicFecGroupTest, ProtectsPacketsBefore) {
@@ -186,7 +206,7 @@ TEST_F(QuicFecGroupTest, ProtectsPacketsBeforeWithFecData) {
fec.redundancy = kData[0];
QuicFecGroup group;
- ASSERT_TRUE(group.UpdateFec(3, fec));
+ ASSERT_TRUE(group.UpdateFec(3, kTestFecEntropy, fec));
EXPECT_FALSE(group.ProtectsPacketsBefore(1));
EXPECT_FALSE(group.ProtectsPacketsBefore(2));
« no previous file with comments | « net/quic/quic_fec_group.cc ('k') | net/quic/quic_framer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698