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

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

Issue 640853005: Simplify QuicUnackedPacketMap to expose AddSentPacket, instead of (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Making_whole_host_of_QUIC_framing_errors_77961885
Patch Set: Created 6 years, 2 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "net/quic/congestion_control/rtt_stats.h" 9 #include "net/quic/congestion_control/rtt_stats.h"
10 #include "net/quic/congestion_control/time_loss_algorithm.h" 10 #include "net/quic/congestion_control/time_loss_algorithm.h"
11 #include "net/quic/quic_unacked_packet_map.h" 11 #include "net/quic/quic_unacked_packet_map.h"
12 #include "net/quic/test_tools/mock_clock.h" 12 #include "net/quic/test_tools/mock_clock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace net { 15 namespace net {
16 namespace test { 16 namespace test {
17 17
18 class TimeLossAlgorithmTest : public ::testing::Test { 18 class TimeLossAlgorithmTest : public ::testing::Test {
19 protected: 19 protected:
20 TimeLossAlgorithmTest() 20 TimeLossAlgorithmTest()
21 : unacked_packets_() { 21 : unacked_packets_() {
22 rtt_stats_.UpdateRtt(QuicTime::Delta::FromMilliseconds(100), 22 rtt_stats_.UpdateRtt(QuicTime::Delta::FromMilliseconds(100),
23 QuicTime::Delta::Zero(), 23 QuicTime::Delta::Zero(),
24 clock_.Now()); 24 clock_.Now());
25 } 25 }
26 26
27 void SendDataPacket(QuicPacketSequenceNumber sequence_number) { 27 void SendDataPacket(QuicPacketSequenceNumber sequence_number) {
28 SerializedPacket packet(sequence_number, PACKET_1BYTE_SEQUENCE_NUMBER, 28 SerializedPacket packet(sequence_number, PACKET_1BYTE_SEQUENCE_NUMBER,
29 nullptr, 0, new RetransmittableFrames()); 29 nullptr, 0, new RetransmittableFrames());
30 unacked_packets_.AddPacket(packet); 30 unacked_packets_.AddSentPacket(packet, 0, NOT_RETRANSMISSION, clock_.Now(),
31 unacked_packets_.SetSent(sequence_number, clock_.Now(), 1000, true); 31 1000, true);
32 } 32 }
33 33
34 void VerifyLosses(QuicPacketSequenceNumber largest_observed, 34 void VerifyLosses(QuicPacketSequenceNumber largest_observed,
35 QuicPacketSequenceNumber* losses_expected, 35 QuicPacketSequenceNumber* losses_expected,
36 size_t num_losses) { 36 size_t num_losses) {
37 SequenceNumberSet lost_packets = 37 SequenceNumberSet lost_packets =
38 loss_algorithm_.DetectLostPackets( 38 loss_algorithm_.DetectLostPackets(
39 unacked_packets_, clock_.Now(), largest_observed, rtt_stats_); 39 unacked_packets_, clock_.Now(), largest_observed, rtt_stats_);
40 EXPECT_EQ(num_losses, lost_packets.size()); 40 EXPECT_EQ(num_losses, lost_packets.size());
41 for (size_t i = 0; i < num_losses; ++i) { 41 for (size_t i = 0; i < num_losses; ++i) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 EXPECT_EQ(rtt_stats_.SmoothedRtt().Multiply(0.25), 129 EXPECT_EQ(rtt_stats_.SmoothedRtt().Multiply(0.25),
130 loss_algorithm_.GetLossTimeout().Subtract(clock_.Now())); 130 loss_algorithm_.GetLossTimeout().Subtract(clock_.Now()));
131 clock_.AdvanceTime(rtt_stats_.SmoothedRtt().Multiply(0.25)); 131 clock_.AdvanceTime(rtt_stats_.SmoothedRtt().Multiply(0.25));
132 QuicPacketSequenceNumber lost[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; 132 QuicPacketSequenceNumber lost[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
133 VerifyLosses(10, lost, arraysize(lost)); 133 VerifyLosses(10, lost, arraysize(lost));
134 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout()); 134 EXPECT_EQ(QuicTime::Zero(), loss_algorithm_.GetLossTimeout());
135 } 135 }
136 136
137 } // namespace test 137 } // namespace test
138 } // namespace net 138 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/tcp_loss_algorithm_test.cc ('k') | net/quic/quic_sent_packet_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698