| 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/core/quic_flow_controller.h" | 5 #include "net/quic/core/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" |
| 11 #include "net/quic/platform/api/quic_str_cat.h" |
| 11 #include "net/quic/test_tools/quic_connection_peer.h" | 12 #include "net/quic/test_tools/quic_connection_peer.h" |
| 12 #include "net/quic/test_tools/quic_flow_controller_peer.h" | 13 #include "net/quic/test_tools/quic_flow_controller_peer.h" |
| 13 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" | 14 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" |
| 14 #include "net/quic/test_tools/quic_test_utils.h" | 15 #include "net/quic/test_tools/quic_test_utils.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 17 |
| 17 using testing::_; | 18 using testing::_; |
| 18 | 19 |
| 19 namespace net { | 20 namespace net { |
| 20 namespace test { | 21 namespace test { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 75 |
| 75 // Updating with a smaller offset doesn't change anything. | 76 // Updating with a smaller offset doesn't change anything. |
| 76 EXPECT_FALSE(flow_controller_->UpdateSendWindowOffset(send_window_ / 10)); | 77 EXPECT_FALSE(flow_controller_->UpdateSendWindowOffset(send_window_ / 10)); |
| 77 EXPECT_EQ(send_window_, flow_controller_->SendWindowSize()); | 78 EXPECT_EQ(send_window_, flow_controller_->SendWindowSize()); |
| 78 | 79 |
| 79 // Try to send more bytes, violating flow control. | 80 // Try to send more bytes, violating flow control. |
| 80 EXPECT_CALL(connection_, | 81 EXPECT_CALL(connection_, |
| 81 CloseConnection(QUIC_FLOW_CONTROL_SENT_TOO_MUCH_DATA, _, _)); | 82 CloseConnection(QUIC_FLOW_CONTROL_SENT_TOO_MUCH_DATA, _, _)); |
| 82 EXPECT_QUIC_BUG( | 83 EXPECT_QUIC_BUG( |
| 83 flow_controller_->AddBytesSent(send_window_ * 10), | 84 flow_controller_->AddBytesSent(send_window_ * 10), |
| 84 base::StringPrintf("Trying to send an extra %" PRIu64 " bytes", | 85 QuicStrCat("Trying to send an extra ", send_window_ * 10, " bytes")); |
| 85 send_window_ * 10)); | |
| 86 EXPECT_TRUE(flow_controller_->IsBlocked()); | 86 EXPECT_TRUE(flow_controller_->IsBlocked()); |
| 87 EXPECT_EQ(0u, flow_controller_->SendWindowSize()); | 87 EXPECT_EQ(0u, flow_controller_->SendWindowSize()); |
| 88 } | 88 } |
| 89 | 89 |
| 90 TEST_F(QuicFlowControllerTest, ReceivingBytes) { | 90 TEST_F(QuicFlowControllerTest, ReceivingBytes) { |
| 91 Initialize(); | 91 Initialize(); |
| 92 | 92 |
| 93 EXPECT_FALSE(flow_controller_->IsBlocked()); | 93 EXPECT_FALSE(flow_controller_->IsBlocked()); |
| 94 EXPECT_FALSE(flow_controller_->FlowControlViolation()); | 94 EXPECT_FALSE(flow_controller_->FlowControlViolation()); |
| 95 EXPECT_EQ(kInitialSessionFlowControlWindowForTest, | 95 EXPECT_EQ(kInitialSessionFlowControlWindowForTest, |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 EXPECT_FALSE(flow_controller_->FlowControlViolation()); | 364 EXPECT_FALSE(flow_controller_->FlowControlViolation()); |
| 365 | 365 |
| 366 QuicByteCount new_threshold = | 366 QuicByteCount new_threshold = |
| 367 QuicFlowControllerPeer::WindowUpdateThreshold(flow_controller_.get()); | 367 QuicFlowControllerPeer::WindowUpdateThreshold(flow_controller_.get()); |
| 368 | 368 |
| 369 EXPECT_EQ(new_threshold, threshold); | 369 EXPECT_EQ(new_threshold, threshold); |
| 370 } | 370 } |
| 371 | 371 |
| 372 } // namespace test | 372 } // namespace test |
| 373 } // namespace net | 373 } // namespace net |
| OLD | NEW |