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" |
11 #include "net/quic/test_tools/quic_connection_peer.h" | 11 #include "net/quic/test_tools/quic_connection_peer.h" |
12 #include "net/quic/test_tools/quic_flow_controller_peer.h" | 12 #include "net/quic/test_tools/quic_flow_controller_peer.h" |
13 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" | 13 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" |
14 #include "net/quic/test_tools/quic_test_utils.h" | 14 #include "net/quic/test_tools/quic_test_utils.h" |
15 #include "net/test/gtest_util.h" | 15 #include "net/test/gtest_util.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
17 | 17 |
| 18 using testing::_; |
| 19 |
18 namespace net { | 20 namespace net { |
19 namespace test { | 21 namespace test { |
20 | 22 |
21 // Receive window auto-tuning uses RTT in its logic. | 23 // Receive window auto-tuning uses RTT in its logic. |
22 const int64 kRtt = 100; | 24 const int64 kRtt = 100; |
23 | 25 |
24 class QuicFlowControllerTest : public ::testing::Test { | 26 class QuicFlowControllerTest : public ::testing::Test { |
25 public: | 27 public: |
26 QuicFlowControllerTest() | 28 QuicFlowControllerTest() |
27 : stream_id_(1234), | 29 : stream_id_(1234), |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // Update the send window, and verify this has unblocked. | 70 // Update the send window, and verify this has unblocked. |
69 EXPECT_TRUE(flow_controller_->UpdateSendWindowOffset(2 * send_window_)); | 71 EXPECT_TRUE(flow_controller_->UpdateSendWindowOffset(2 * send_window_)); |
70 EXPECT_FALSE(flow_controller_->IsBlocked()); | 72 EXPECT_FALSE(flow_controller_->IsBlocked()); |
71 EXPECT_EQ(send_window_, flow_controller_->SendWindowSize()); | 73 EXPECT_EQ(send_window_, flow_controller_->SendWindowSize()); |
72 | 74 |
73 // Updating with a smaller offset doesn't change anything. | 75 // Updating with a smaller offset doesn't change anything. |
74 EXPECT_FALSE(flow_controller_->UpdateSendWindowOffset(send_window_ / 10)); | 76 EXPECT_FALSE(flow_controller_->UpdateSendWindowOffset(send_window_ / 10)); |
75 EXPECT_EQ(send_window_, flow_controller_->SendWindowSize()); | 77 EXPECT_EQ(send_window_, flow_controller_->SendWindowSize()); |
76 | 78 |
77 // Try to send more bytes, violating flow control. | 79 // Try to send more bytes, violating flow control. |
78 EXPECT_CALL(connection_, | 80 EXPECT_CALL(connection_, SendConnectionCloseWithDetails( |
79 SendConnectionClose(QUIC_FLOW_CONTROL_SENT_TOO_MUCH_DATA)); | 81 QUIC_FLOW_CONTROL_SENT_TOO_MUCH_DATA, _)); |
80 EXPECT_DFATAL( | 82 EXPECT_DFATAL( |
81 flow_controller_->AddBytesSent(send_window_ * 10), | 83 flow_controller_->AddBytesSent(send_window_ * 10), |
82 base::StringPrintf("Trying to send an extra %" PRIu64 " bytes", | 84 base::StringPrintf("Trying to send an extra %" PRIu64 " bytes", |
83 send_window_ * 10)); | 85 send_window_ * 10)); |
84 EXPECT_TRUE(flow_controller_->IsBlocked()); | 86 EXPECT_TRUE(flow_controller_->IsBlocked()); |
85 EXPECT_EQ(0u, flow_controller_->SendWindowSize()); | 87 EXPECT_EQ(0u, flow_controller_->SendWindowSize()); |
86 } | 88 } |
87 | 89 |
88 TEST_F(QuicFlowControllerTest, ReceivingBytes) { | 90 TEST_F(QuicFlowControllerTest, ReceivingBytes) { |
89 Initialize(); | 91 Initialize(); |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 EXPECT_FALSE(flow_controller_->FlowControlViolation()); | 368 EXPECT_FALSE(flow_controller_->FlowControlViolation()); |
367 | 369 |
368 QuicByteCount new_threshold = | 370 QuicByteCount new_threshold = |
369 QuicFlowControllerPeer::WindowUpdateThreshold(flow_controller_.get()); | 371 QuicFlowControllerPeer::WindowUpdateThreshold(flow_controller_.get()); |
370 | 372 |
371 EXPECT_EQ(new_threshold, threshold); | 373 EXPECT_EQ(new_threshold, threshold); |
372 } | 374 } |
373 | 375 |
374 } // namespace test | 376 } // namespace test |
375 } // namespace net | 377 } // namespace net |
OLD | NEW |