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

Side by Side Diff: net/quic/congestion_control/general_loss_algorithm_test.cc

Issue 1667583004: Landing Recent QUIC changes until 01/31/2016 05:22 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Final_0203
Patch Set: Rebase Created 4 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 unified diff | Download patch
« no previous file with comments | « components/domain_reliability/util.cc ('k') | net/quic/quic_chromium_client_session.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/congestion_control/general_loss_algorithm.h" 5 #include "net/quic/congestion_control/general_loss_algorithm.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 11 matching lines...) Expand all
22 // Default packet length. 22 // Default packet length.
23 const uint32_t kDefaultLength = 1000; 23 const uint32_t kDefaultLength = 1000;
24 24
25 class GeneralLossAlgorithmTest : public ::testing::Test { 25 class GeneralLossAlgorithmTest : public ::testing::Test {
26 protected: 26 protected:
27 GeneralLossAlgorithmTest() { 27 GeneralLossAlgorithmTest() {
28 rtt_stats_.UpdateRtt(QuicTime::Delta::FromMilliseconds(100), 28 rtt_stats_.UpdateRtt(QuicTime::Delta::FromMilliseconds(100),
29 QuicTime::Delta::Zero(), clock_.Now()); 29 QuicTime::Delta::Zero(), clock_.Now());
30 } 30 }
31 31
32 ~GeneralLossAlgorithmTest() override { STLDeleteElements(&packets_); } 32 ~GeneralLossAlgorithmTest() override {}
33 33
34 void SendDataPacket(QuicPacketNumber packet_number) { 34 void SendDataPacket(QuicPacketNumber packet_number) {
35 packets_.push_back(new QuicEncryptedPacket(nullptr, kDefaultLength));
36 QuicStreamFrame* frame = new QuicStreamFrame(); 35 QuicStreamFrame* frame = new QuicStreamFrame();
37 frame->stream_id = kHeadersStreamId; 36 frame->stream_id = kHeadersStreamId;
38 SerializedPacket packet(kDefaultPathId, packet_number, 37 SerializedPacket packet(kDefaultPathId, packet_number,
39 PACKET_1BYTE_PACKET_NUMBER, packets_.back(), 0, 38 PACKET_1BYTE_PACKET_NUMBER, nullptr, kDefaultLength,
40 false, false); 39 0, false, false);
41 packet.retransmittable_frames.push_back(QuicFrame(frame)); 40 packet.retransmittable_frames.push_back(QuicFrame(frame));
42 unacked_packets_.AddSentPacket(&packet, 0, NOT_RETRANSMISSION, clock_.Now(), 41 unacked_packets_.AddSentPacket(&packet, 0, NOT_RETRANSMISSION, clock_.Now(),
43 1000, true); 42 1000, true);
44 } 43 }
45 44
46 void VerifyLosses(QuicPacketNumber largest_observed, 45 void VerifyLosses(QuicPacketNumber largest_observed,
47 QuicPacketNumber* losses_expected, 46 QuicPacketNumber* losses_expected,
48 size_t num_losses) { 47 size_t num_losses) {
49 unacked_packets_.IncreaseLargestObserved(largest_observed); 48 unacked_packets_.IncreaseLargestObserved(largest_observed);
50 PacketNumberSet lost_packets = loss_algorithm_.DetectLostPackets( 49 PacketNumberSet lost_packets = loss_algorithm_.DetectLostPackets(
51 unacked_packets_, clock_.Now(), largest_observed, rtt_stats_); 50 unacked_packets_, clock_.Now(), largest_observed, rtt_stats_);
52 EXPECT_EQ(num_losses, lost_packets.size()); 51 EXPECT_EQ(num_losses, lost_packets.size());
53 for (size_t i = 0; i < num_losses; ++i) { 52 for (size_t i = 0; i < num_losses; ++i) {
54 EXPECT_TRUE(ContainsKey(lost_packets, losses_expected[i])); 53 EXPECT_TRUE(ContainsKey(lost_packets, losses_expected[i]));
55 } 54 }
56 } 55 }
57 56
58 vector<QuicEncryptedPacket*> packets_;
59 QuicUnackedPacketMap unacked_packets_; 57 QuicUnackedPacketMap unacked_packets_;
60 GeneralLossAlgorithm loss_algorithm_; 58 GeneralLossAlgorithm loss_algorithm_;
61 RttStats rtt_stats_; 59 RttStats rtt_stats_;
62 MockClock clock_; 60 MockClock clock_;
63 }; 61 };
64 62
65 TEST_F(GeneralLossAlgorithmTest, NackRetransmit1Packet) { 63 TEST_F(GeneralLossAlgorithmTest, NackRetransmit1Packet) {
66 const size_t kNumSentPackets = 5; 64 const size_t kNumSentPackets = 5;
67 // Transmit 5 packets. 65 // Transmit 5 packets.
68 for (size_t i = 1; i <= kNumSentPackets; ++i) { 66 for (size_t i = 1; i <= kNumSentPackets; ++i) {
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 loss_algorithm_.GetLossTimeout().Subtract(clock_.Now())); 295 loss_algorithm_.GetLossTimeout().Subtract(clock_.Now()));
298 clock_.AdvanceTime(rtt_stats_.smoothed_rtt().Multiply(0.25)); 296 clock_.AdvanceTime(rtt_stats_.smoothed_rtt().Multiply(0.25));
299 QuicPacketNumber lost[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; 297 QuicPacketNumber lost[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
300 VerifyLosses(10, lost, arraysize(lost)); 298 VerifyLosses(10, lost, arraysize(lost));
301 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 299 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
302 } 300 }
303 301
304 } // namespace 302 } // namespace
305 } // namespace test 303 } // namespace test
306 } // namespace net 304 } // namespace net
OLDNEW
« no previous file with comments | « components/domain_reliability/util.cc ('k') | net/quic/quic_chromium_client_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698