Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: net/quic/quic_flow_controller_test.cc

Issue 968233004: Land Recent QUIC Changes until 03/02/2015. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quic_flow_controller.cc ('k') | net/quic/quic_headers_stream_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_utils.h" 9 #include "net/quic/quic_utils.h"
10 #include "net/quic/test_tools/quic_connection_peer.h" 10 #include "net/quic/test_tools/quic_connection_peer.h"
(...skipping 26 matching lines...) Expand all
37 QuicByteCount send_window_; 37 QuicByteCount send_window_;
38 QuicByteCount receive_window_; 38 QuicByteCount receive_window_;
39 QuicByteCount max_receive_window_; 39 QuicByteCount max_receive_window_;
40 scoped_ptr<QuicFlowController> flow_controller_; 40 scoped_ptr<QuicFlowController> flow_controller_;
41 MockConnection connection_; 41 MockConnection connection_;
42 }; 42 };
43 43
44 TEST_F(QuicFlowControllerTest, SendingBytes) { 44 TEST_F(QuicFlowControllerTest, SendingBytes) {
45 Initialize(); 45 Initialize();
46 46
47 EXPECT_TRUE(flow_controller_->IsEnabled());
48 EXPECT_FALSE(flow_controller_->IsBlocked()); 47 EXPECT_FALSE(flow_controller_->IsBlocked());
49 EXPECT_FALSE(flow_controller_->FlowControlViolation()); 48 EXPECT_FALSE(flow_controller_->FlowControlViolation());
50 EXPECT_EQ(send_window_, flow_controller_->SendWindowSize()); 49 EXPECT_EQ(send_window_, flow_controller_->SendWindowSize());
51 50
52 // Send some bytes, but not enough to block. 51 // Send some bytes, but not enough to block.
53 flow_controller_->AddBytesSent(send_window_ / 2); 52 flow_controller_->AddBytesSent(send_window_ / 2);
54 EXPECT_FALSE(flow_controller_->IsBlocked()); 53 EXPECT_FALSE(flow_controller_->IsBlocked());
55 EXPECT_EQ(send_window_ / 2, flow_controller_->SendWindowSize()); 54 EXPECT_EQ(send_window_ / 2, flow_controller_->SendWindowSize());
56 55
57 // Send enough bytes to block. 56 // Send enough bytes to block.
(...skipping 21 matching lines...) Expand all
79 flow_controller_->AddBytesSent(send_window_ * 10), 78 flow_controller_->AddBytesSent(send_window_ * 10),
80 base::StringPrintf("Trying to send an extra %" PRIu64 " bytes", 79 base::StringPrintf("Trying to send an extra %" PRIu64 " bytes",
81 send_window_ * 10)); 80 send_window_ * 10));
82 EXPECT_TRUE(flow_controller_->IsBlocked()); 81 EXPECT_TRUE(flow_controller_->IsBlocked());
83 EXPECT_EQ(0u, flow_controller_->SendWindowSize()); 82 EXPECT_EQ(0u, flow_controller_->SendWindowSize());
84 } 83 }
85 84
86 TEST_F(QuicFlowControllerTest, ReceivingBytes) { 85 TEST_F(QuicFlowControllerTest, ReceivingBytes) {
87 Initialize(); 86 Initialize();
88 87
89 EXPECT_TRUE(flow_controller_->IsEnabled());
90 EXPECT_FALSE(flow_controller_->IsBlocked()); 88 EXPECT_FALSE(flow_controller_->IsBlocked());
91 EXPECT_FALSE(flow_controller_->FlowControlViolation()); 89 EXPECT_FALSE(flow_controller_->FlowControlViolation());
92 EXPECT_EQ(kInitialSessionFlowControlWindowForTest, 90 EXPECT_EQ(kInitialSessionFlowControlWindowForTest,
93 QuicFlowControllerPeer::ReceiveWindowSize(flow_controller_.get())); 91 QuicFlowControllerPeer::ReceiveWindowSize(flow_controller_.get()));
94 92
95 // Receive some bytes, updating highest received offset, but not enough to 93 // Receive some bytes, updating highest received offset, but not enough to
96 // fill flow control receive window. 94 // fill flow control receive window.
97 EXPECT_TRUE( 95 EXPECT_TRUE(
98 flow_controller_->UpdateHighestReceivedOffset(1 + receive_window_ / 2)); 96 flow_controller_->UpdateHighestReceivedOffset(1 + receive_window_ / 2));
99 EXPECT_FALSE(flow_controller_->FlowControlViolation()); 97 EXPECT_FALSE(flow_controller_->FlowControlViolation());
100 EXPECT_EQ((receive_window_ / 2) - 1, 98 EXPECT_EQ((receive_window_ / 2) - 1,
101 QuicFlowControllerPeer::ReceiveWindowSize(flow_controller_.get())); 99 QuicFlowControllerPeer::ReceiveWindowSize(flow_controller_.get()));
102 100
103 // Consume enough bytes to send a WINDOW_UPDATE frame. 101 // Consume enough bytes to send a WINDOW_UPDATE frame.
104 EXPECT_CALL(connection_, SendWindowUpdate(stream_id_, ::testing::_)).Times(1); 102 EXPECT_CALL(connection_, SendWindowUpdate(stream_id_, ::testing::_)).Times(1);
105 103
106 flow_controller_->AddBytesConsumed(1 + receive_window_ / 2); 104 flow_controller_->AddBytesConsumed(1 + receive_window_ / 2);
107 105
108 // Result is that once again we have a fully open receive window. 106 // Result is that once again we have a fully open receive window.
109 EXPECT_FALSE(flow_controller_->FlowControlViolation()); 107 EXPECT_FALSE(flow_controller_->FlowControlViolation());
110 EXPECT_EQ(kInitialSessionFlowControlWindowForTest, 108 EXPECT_EQ(kInitialSessionFlowControlWindowForTest,
111 QuicFlowControllerPeer::ReceiveWindowSize(flow_controller_.get())); 109 QuicFlowControllerPeer::ReceiveWindowSize(flow_controller_.get()));
112 } 110 }
113 111
114 TEST_F(QuicFlowControllerTest, OnlySendBlockedFrameOncePerOffset) { 112 TEST_F(QuicFlowControllerTest, OnlySendBlockedFrameOncePerOffset) {
115 Initialize(); 113 Initialize();
116 114
117 // Test that we don't send duplicate BLOCKED frames. We should only send one 115 // Test that we don't send duplicate BLOCKED frames. We should only send one
118 // BLOCKED frame at a given send window offset. 116 // BLOCKED frame at a given send window offset.
119 EXPECT_TRUE(flow_controller_->IsEnabled());
120 EXPECT_FALSE(flow_controller_->IsBlocked()); 117 EXPECT_FALSE(flow_controller_->IsBlocked());
121 EXPECT_FALSE(flow_controller_->FlowControlViolation()); 118 EXPECT_FALSE(flow_controller_->FlowControlViolation());
122 EXPECT_EQ(send_window_, flow_controller_->SendWindowSize()); 119 EXPECT_EQ(send_window_, flow_controller_->SendWindowSize());
123 120
124 // Send enough bytes to block. 121 // Send enough bytes to block.
125 flow_controller_->AddBytesSent(send_window_); 122 flow_controller_->AddBytesSent(send_window_);
126 EXPECT_TRUE(flow_controller_->IsBlocked()); 123 EXPECT_TRUE(flow_controller_->IsBlocked());
127 EXPECT_EQ(0u, flow_controller_->SendWindowSize()); 124 EXPECT_EQ(0u, flow_controller_->SendWindowSize());
128 125
129 // Expect that 2 BLOCKED frames should get sent in total. 126 // Expect that 2 BLOCKED frames should get sent in total.
(...skipping 16 matching lines...) Expand all
146 flow_controller_->AddBytesSent(send_window_); 143 flow_controller_->AddBytesSent(send_window_);
147 EXPECT_TRUE(flow_controller_->IsBlocked()); 144 EXPECT_TRUE(flow_controller_->IsBlocked());
148 EXPECT_EQ(0u, flow_controller_->SendWindowSize()); 145 EXPECT_EQ(0u, flow_controller_->SendWindowSize());
149 146
150 // BLOCKED frame should get sent as send offset has changed. 147 // BLOCKED frame should get sent as send offset has changed.
151 flow_controller_->MaybeSendBlocked(); 148 flow_controller_->MaybeSendBlocked();
152 } 149 }
153 150
154 } // namespace test 151 } // namespace test
155 } // namespace net 152 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_flow_controller.cc ('k') | net/quic/quic_headers_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698