| OLD | NEW |
| 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 "net/quic/quic_flow_controller.h" | 5 #include "net/quic/quic_flow_controller.h" |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "net/quic/quic_flags.h" | 9 #include "net/quic/quic_flags.h" |
| 10 #include "net/quic/quic_utils.h" | 10 #include "net/quic/quic_utils.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 // Receive window auto-tuning uses RTT in its logic. | 23 // Receive window auto-tuning uses RTT in its logic. |
| 24 const int64_t kRtt = 100; | 24 const int64_t kRtt = 100; |
| 25 | 25 |
| 26 class QuicFlowControllerTest : public ::testing::Test { | 26 class QuicFlowControllerTest : public ::testing::Test { |
| 27 public: | 27 public: |
| 28 QuicFlowControllerTest() | 28 QuicFlowControllerTest() |
| 29 : stream_id_(1234), | 29 : stream_id_(1234), |
| 30 send_window_(kInitialSessionFlowControlWindowForTest), | 30 send_window_(kInitialSessionFlowControlWindowForTest), |
| 31 receive_window_(kInitialSessionFlowControlWindowForTest), | 31 receive_window_(kInitialSessionFlowControlWindowForTest), |
| 32 connection_(&helper_, Perspective::IS_CLIENT) {} | 32 connection_(&helper_, &alarm_factory_, Perspective::IS_CLIENT) {} |
| 33 | 33 |
| 34 void Initialize() { | 34 void Initialize() { |
| 35 flow_controller_.reset( | 35 flow_controller_.reset( |
| 36 new QuicFlowController(&connection_, stream_id_, Perspective::IS_CLIENT, | 36 new QuicFlowController(&connection_, stream_id_, Perspective::IS_CLIENT, |
| 37 send_window_, receive_window_, false)); | 37 send_window_, receive_window_, false)); |
| 38 } | 38 } |
| 39 | 39 |
| 40 protected: | 40 protected: |
| 41 QuicStreamId stream_id_; | 41 QuicStreamId stream_id_; |
| 42 QuicByteCount send_window_; | 42 QuicByteCount send_window_; |
| 43 QuicByteCount receive_window_; | 43 QuicByteCount receive_window_; |
| 44 std::unique_ptr<QuicFlowController> flow_controller_; | 44 std::unique_ptr<QuicFlowController> flow_controller_; |
| 45 MockConnectionHelper helper_; | 45 MockConnectionHelper helper_; |
| 46 MockAlarmFactory alarm_factory_; |
| 46 MockConnection connection_; | 47 MockConnection connection_; |
| 47 }; | 48 }; |
| 48 | 49 |
| 49 TEST_F(QuicFlowControllerTest, SendingBytes) { | 50 TEST_F(QuicFlowControllerTest, SendingBytes) { |
| 50 Initialize(); | 51 Initialize(); |
| 51 | 52 |
| 52 EXPECT_FALSE(flow_controller_->IsBlocked()); | 53 EXPECT_FALSE(flow_controller_->IsBlocked()); |
| 53 EXPECT_FALSE(flow_controller_->FlowControlViolation()); | 54 EXPECT_FALSE(flow_controller_->FlowControlViolation()); |
| 54 EXPECT_EQ(send_window_, flow_controller_->SendWindowSize()); | 55 EXPECT_EQ(send_window_, flow_controller_->SendWindowSize()); |
| 55 | 56 |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 EXPECT_FALSE(flow_controller_->FlowControlViolation()); | 256 EXPECT_FALSE(flow_controller_->FlowControlViolation()); |
| 256 | 257 |
| 257 QuicByteCount new_threshold = | 258 QuicByteCount new_threshold = |
| 258 QuicFlowControllerPeer::WindowUpdateThreshold(flow_controller_.get()); | 259 QuicFlowControllerPeer::WindowUpdateThreshold(flow_controller_.get()); |
| 259 | 260 |
| 260 EXPECT_EQ(new_threshold, threshold); | 261 EXPECT_EQ(new_threshold, threshold); |
| 261 } | 262 } |
| 262 | 263 |
| 263 } // namespace test | 264 } // namespace test |
| 264 } // namespace net | 265 } // namespace net |
| OLD | NEW |