| 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/core/quic_received_packet_manager.h" | 5 #include "net/quic/core/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/core/quic_connection_stats.h" | 10 #include "net/quic/core/quic_connection_stats.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 explicit TestParams(QuicVersion version) : version(version) {} | 190 explicit TestParams(QuicVersion version) : version(version) {} |
| 191 | 191 |
| 192 friend std::ostream& operator<<(std::ostream& os, const TestParams& p) { | 192 friend std::ostream& operator<<(std::ostream& os, const TestParams& p) { |
| 193 os << "{ version: " << QuicVersionToString(p.version) << " }"; | 193 os << "{ version: " << QuicVersionToString(p.version) << " }"; |
| 194 return os; | 194 return os; |
| 195 } | 195 } |
| 196 | 196 |
| 197 QuicVersion version; | 197 QuicVersion version; |
| 198 }; | 198 }; |
| 199 | 199 |
| 200 vector<TestParams> GetTestParams() { | 200 std::vector<TestParams> GetTestParams() { |
| 201 vector<TestParams> params; | 201 std::vector<TestParams> params; |
| 202 QuicVersionVector all_supported_versions = AllSupportedVersions(); | 202 QuicVersionVector all_supported_versions = AllSupportedVersions(); |
| 203 for (size_t i = 0; i < all_supported_versions.size(); ++i) { | 203 for (size_t i = 0; i < all_supported_versions.size(); ++i) { |
| 204 params.push_back(TestParams(all_supported_versions[i])); | 204 params.push_back(TestParams(all_supported_versions[i])); |
| 205 } | 205 } |
| 206 return params; | 206 return params; |
| 207 } | 207 } |
| 208 | 208 |
| 209 class QuicReceivedPacketManagerTest | 209 class QuicReceivedPacketManagerTest |
| 210 : public ::testing::TestWithParam<TestParams> { | 210 : public ::testing::TestWithParam<TestParams> { |
| 211 protected: | 211 protected: |
| (...skipping 20 matching lines...) Expand all Loading... |
| 232 }; | 232 }; |
| 233 | 233 |
| 234 INSTANTIATE_TEST_CASE_P(QuicReceivedPacketManagerTest, | 234 INSTANTIATE_TEST_CASE_P(QuicReceivedPacketManagerTest, |
| 235 QuicReceivedPacketManagerTest, | 235 QuicReceivedPacketManagerTest, |
| 236 ::testing::ValuesIn(GetTestParams())); | 236 ::testing::ValuesIn(GetTestParams())); |
| 237 | 237 |
| 238 TEST_P(QuicReceivedPacketManagerTest, ReceivedPacketEntropyHash) { | 238 TEST_P(QuicReceivedPacketManagerTest, ReceivedPacketEntropyHash) { |
| 239 if (GetParam().version > QUIC_VERSION_33) { | 239 if (GetParam().version > QUIC_VERSION_33) { |
| 240 return; | 240 return; |
| 241 } | 241 } |
| 242 vector<pair<QuicPacketNumber, QuicPacketEntropyHash>> entropies; | 242 std::vector<std::pair<QuicPacketNumber, QuicPacketEntropyHash>> entropies; |
| 243 entropies.push_back(std::make_pair(1, 12)); | 243 entropies.push_back(std::make_pair(1, 12)); |
| 244 entropies.push_back(std::make_pair(7, 1)); | 244 entropies.push_back(std::make_pair(7, 1)); |
| 245 entropies.push_back(std::make_pair(2, 33)); | 245 entropies.push_back(std::make_pair(2, 33)); |
| 246 entropies.push_back(std::make_pair(5, 3)); | 246 entropies.push_back(std::make_pair(5, 3)); |
| 247 entropies.push_back(std::make_pair(8, 34)); | 247 entropies.push_back(std::make_pair(8, 34)); |
| 248 | 248 |
| 249 for (size_t i = 0; i < entropies.size(); ++i) { | 249 for (size_t i = 0; i < entropies.size(); ++i) { |
| 250 RecordPacketReceipt(entropies[i].first, entropies[i].second); | 250 RecordPacketReceipt(entropies[i].first, entropies[i].second); |
| 251 } | 251 } |
| 252 | 252 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 } | 284 } |
| 285 EXPECT_EQ(0, received_manager_.EntropyHash(0)); | 285 EXPECT_EQ(0, received_manager_.EntropyHash(0)); |
| 286 RecordPacketReceipt(4, 5); | 286 RecordPacketReceipt(4, 5); |
| 287 EXPECT_EQ(0, received_manager_.EntropyHash(3)); | 287 EXPECT_EQ(0, received_manager_.EntropyHash(3)); |
| 288 } | 288 } |
| 289 | 289 |
| 290 TEST_P(QuicReceivedPacketManagerTest, SetCumulativeEntropyUpTo) { | 290 TEST_P(QuicReceivedPacketManagerTest, SetCumulativeEntropyUpTo) { |
| 291 if (GetParam().version > QUIC_VERSION_33) { | 291 if (GetParam().version > QUIC_VERSION_33) { |
| 292 return; | 292 return; |
| 293 } | 293 } |
| 294 vector<pair<QuicPacketNumber, QuicPacketEntropyHash>> entropies; | 294 std::vector<std::pair<QuicPacketNumber, QuicPacketEntropyHash>> entropies; |
| 295 entropies.push_back(std::make_pair(1, 12)); | 295 entropies.push_back(std::make_pair(1, 12)); |
| 296 entropies.push_back(std::make_pair(2, 1)); | 296 entropies.push_back(std::make_pair(2, 1)); |
| 297 entropies.push_back(std::make_pair(3, 33)); | 297 entropies.push_back(std::make_pair(3, 33)); |
| 298 entropies.push_back(std::make_pair(4, 3)); | 298 entropies.push_back(std::make_pair(4, 3)); |
| 299 entropies.push_back(std::make_pair(6, 34)); | 299 entropies.push_back(std::make_pair(6, 34)); |
| 300 entropies.push_back(std::make_pair(7, 29)); | 300 entropies.push_back(std::make_pair(7, 29)); |
| 301 | 301 |
| 302 QuicPacketEntropyHash entropy_hash = 0; | 302 QuicPacketEntropyHash entropy_hash = 0; |
| 303 for (size_t i = 0; i < entropies.size(); ++i) { | 303 for (size_t i = 0; i < entropies.size(); ++i) { |
| 304 RecordPacketReceipt(entropies[i].first, entropies[i].second); | 304 RecordPacketReceipt(entropies[i].first, entropies[i].second); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 QuicTime::Zero() + QuicTime::Delta::FromMilliseconds(1)); | 387 QuicTime::Zero() + QuicTime::Delta::FromMilliseconds(1)); |
| 388 | 388 |
| 389 EXPECT_EQ(4u, stats_.max_sequence_reordering); | 389 EXPECT_EQ(4u, stats_.max_sequence_reordering); |
| 390 EXPECT_EQ(1000, stats_.max_time_reordering_us); | 390 EXPECT_EQ(1000, stats_.max_time_reordering_us); |
| 391 EXPECT_EQ(1u, stats_.packets_reordered); | 391 EXPECT_EQ(1u, stats_.packets_reordered); |
| 392 } | 392 } |
| 393 | 393 |
| 394 } // namespace | 394 } // namespace |
| 395 } // namespace test | 395 } // namespace test |
| 396 } // namespace net | 396 } // namespace net |
| OLD | NEW |