OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_received_packet_manager.h" | 5 #include "net/quic/quic_received_packet_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "net/quic/quic_connection_stats.h" | 10 #include "net/quic/quic_connection_stats.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 | 205 |
206 void RecordPacketRevived(QuicPacketSequenceNumber sequence_number) { | 206 void RecordPacketRevived(QuicPacketSequenceNumber sequence_number) { |
207 received_manager_.RecordPacketRevived(sequence_number); | 207 received_manager_.RecordPacketRevived(sequence_number); |
208 } | 208 } |
209 | 209 |
210 QuicConnectionStats stats_; | 210 QuicConnectionStats stats_; |
211 QuicReceivedPacketManager received_manager_; | 211 QuicReceivedPacketManager received_manager_; |
212 }; | 212 }; |
213 | 213 |
214 TEST_F(QuicReceivedPacketManagerTest, ReceivedPacketEntropyHash) { | 214 TEST_F(QuicReceivedPacketManagerTest, ReceivedPacketEntropyHash) { |
215 vector<pair<QuicPacketSequenceNumber, QuicPacketEntropyHash> > entropies; | 215 vector<pair<QuicPacketSequenceNumber, QuicPacketEntropyHash>> entropies; |
216 entropies.push_back(std::make_pair(1, 12)); | 216 entropies.push_back(std::make_pair(1, 12)); |
217 entropies.push_back(std::make_pair(7, 1)); | 217 entropies.push_back(std::make_pair(7, 1)); |
218 entropies.push_back(std::make_pair(2, 33)); | 218 entropies.push_back(std::make_pair(2, 33)); |
219 entropies.push_back(std::make_pair(5, 3)); | 219 entropies.push_back(std::make_pair(5, 3)); |
220 entropies.push_back(std::make_pair(8, 34)); | 220 entropies.push_back(std::make_pair(8, 34)); |
221 | 221 |
222 for (size_t i = 0; i < entropies.size(); ++i) { | 222 for (size_t i = 0; i < entropies.size(); ++i) { |
223 RecordPacketReceipt(entropies[i].first, entropies[i].second); | 223 RecordPacketReceipt(entropies[i].first, entropies[i].second); |
224 } | 224 } |
225 | 225 |
(...skipping 21 matching lines...) Expand all Loading... |
247 EXPECT_EQ(0, received_manager_.EntropyHash(3)); | 247 EXPECT_EQ(0, received_manager_.EntropyHash(3)); |
248 } | 248 } |
249 | 249 |
250 TEST_F(QuicReceivedPacketManagerTest, EntropyHashAboveLargestObserved) { | 250 TEST_F(QuicReceivedPacketManagerTest, EntropyHashAboveLargestObserved) { |
251 EXPECT_EQ(0, received_manager_.EntropyHash(0)); | 251 EXPECT_EQ(0, received_manager_.EntropyHash(0)); |
252 RecordPacketReceipt(4, 5); | 252 RecordPacketReceipt(4, 5); |
253 EXPECT_EQ(0, received_manager_.EntropyHash(3)); | 253 EXPECT_EQ(0, received_manager_.EntropyHash(3)); |
254 } | 254 } |
255 | 255 |
256 TEST_F(QuicReceivedPacketManagerTest, SetCumulativeEntropyUpTo) { | 256 TEST_F(QuicReceivedPacketManagerTest, SetCumulativeEntropyUpTo) { |
257 vector<pair<QuicPacketSequenceNumber, QuicPacketEntropyHash> > entropies; | 257 vector<pair<QuicPacketSequenceNumber, QuicPacketEntropyHash>> entropies; |
258 entropies.push_back(std::make_pair(1, 12)); | 258 entropies.push_back(std::make_pair(1, 12)); |
259 entropies.push_back(std::make_pair(2, 1)); | 259 entropies.push_back(std::make_pair(2, 1)); |
260 entropies.push_back(std::make_pair(3, 33)); | 260 entropies.push_back(std::make_pair(3, 33)); |
261 entropies.push_back(std::make_pair(4, 3)); | 261 entropies.push_back(std::make_pair(4, 3)); |
262 entropies.push_back(std::make_pair(6, 34)); | 262 entropies.push_back(std::make_pair(6, 34)); |
263 entropies.push_back(std::make_pair(7, 29)); | 263 entropies.push_back(std::make_pair(7, 29)); |
264 | 264 |
265 QuicPacketEntropyHash entropy_hash = 0; | 265 QuicPacketEntropyHash entropy_hash = 0; |
266 for (size_t i = 0; i < entropies.size(); ++i) { | 266 for (size_t i = 0; i < entropies.size(); ++i) { |
267 RecordPacketReceipt(entropies[i].first, entropies[i].second); | 267 RecordPacketReceipt(entropies[i].first, entropies[i].second); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 QuicAckFrame ack; | 356 QuicAckFrame ack; |
357 received_manager_.UpdateReceivedPacketInfo(&ack, QuicTime::Zero()); | 357 received_manager_.UpdateReceivedPacketInfo(&ack, QuicTime::Zero()); |
358 EXPECT_TRUE(ack.missing_packets.empty()); | 358 EXPECT_TRUE(ack.missing_packets.empty()); |
359 EXPECT_TRUE(ack.revived_packets.empty()); | 359 EXPECT_TRUE(ack.revived_packets.empty()); |
360 } | 360 } |
361 | 361 |
362 | 362 |
363 } // namespace | 363 } // namespace |
364 } // namespace test | 364 } // namespace test |
365 } // namespace net | 365 } // namespace net |
OLD | NEW |