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