OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "net/quic/congestion_control/tcp_cubic_sender.h" | 9 #include "net/quic/congestion_control/tcp_cubic_sender.h" |
10 #include "net/quic/congestion_control/tcp_receiver.h" | 10 #include "net/quic/congestion_control/tcp_receiver.h" |
11 #include "net/quic/test_tools/mock_clock.h" | 11 #include "net/quic/test_tools/mock_clock.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 using std::min; | 14 using std::min; |
15 | 15 |
16 namespace net { | 16 namespace net { |
17 namespace test { | 17 namespace test { |
18 | 18 |
19 const uint32 kDefaultWindowTCP = 10 * kDefaultTCPMSS; | 19 const uint32 kDefaultWindowTCP = 10 * kDefaultTCPMSS; |
20 | 20 |
21 // TODO(ianswett): Remove 10000 once b/10075719 is fixed. | 21 // TODO(ianswett): Remove 10000 once b/10075719 is fixed. |
22 const QuicTcpCongestionWindow kDefaultMaxCongestionWindowTCP = 10000; | 22 const QuicTcpCongestionWindow kDefaultMaxCongestionWindowTCP = 10000; |
23 | 23 |
24 class TcpCubicSenderPeer : public TcpCubicSender { | 24 class TcpCubicSenderPeer : public TcpCubicSender { |
25 public: | 25 public: |
26 TcpCubicSenderPeer(const QuicClock* clock, | 26 TcpCubicSenderPeer(const QuicClock* clock, |
27 bool reno, | 27 bool reno, |
28 QuicTcpCongestionWindow max_tcp_congestion_window) | 28 QuicTcpCongestionWindow max_tcp_congestion_window) |
29 : TcpCubicSender(clock, reno, max_tcp_congestion_window) { | 29 : TcpCubicSender(clock, reno, max_tcp_congestion_window, &stats_) { |
30 } | 30 } |
31 | 31 |
32 QuicTcpCongestionWindow congestion_window() { | 32 QuicTcpCongestionWindow congestion_window() { |
33 return congestion_window_; | 33 return congestion_window_; |
34 } | 34 } |
35 | 35 |
| 36 QuicConnectionStats stats_; |
| 37 |
36 using TcpCubicSender::AvailableSendWindow; | 38 using TcpCubicSender::AvailableSendWindow; |
37 using TcpCubicSender::SendWindow; | 39 using TcpCubicSender::SendWindow; |
38 }; | 40 }; |
39 | 41 |
40 class TcpCubicSenderTest : public ::testing::Test { | 42 class TcpCubicSenderTest : public ::testing::Test { |
41 protected: | 43 protected: |
42 TcpCubicSenderTest() | 44 TcpCubicSenderTest() |
43 : one_ms_(QuicTime::Delta::FromMilliseconds(1)), | 45 : one_ms_(QuicTime::Delta::FromMilliseconds(1)), |
44 sender_(new TcpCubicSenderPeer(&clock_, true, | 46 sender_(new TcpCubicSenderPeer(&clock_, true, |
45 kDefaultMaxCongestionWindowTCP)), | 47 kDefaultMaxCongestionWindowTCP)), |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 } | 614 } |
613 | 615 |
614 // Next ack should cause congestion window to grow by 1MSS. | 616 // Next ack should cause congestion window to grow by 1MSS. |
615 AckNPackets(2); | 617 AckNPackets(2); |
616 expected_send_window += kDefaultTCPMSS; | 618 expected_send_window += kDefaultTCPMSS; |
617 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 619 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
618 } | 620 } |
619 | 621 |
620 } // namespace test | 622 } // namespace test |
621 } // namespace net | 623 } // namespace net |
OLD | NEW |