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

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

Issue 605163004: Land Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Final_0925
Patch Set: Created 6 years, 2 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_framer.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/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "net/quic/quic_utils.h" 8 #include "net/quic/quic_utils.h"
9 #include "net/quic/test_tools/quic_connection_peer.h" 9 #include "net/quic/test_tools/quic_connection_peer.h"
10 #include "net/quic/test_tools/quic_flow_controller_peer.h" 10 #include "net/quic/test_tools/quic_flow_controller_peer.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 EXPECT_CALL(connection_, SendWindowUpdate(stream_id_, _)).Times(1); 107 EXPECT_CALL(connection_, SendWindowUpdate(stream_id_, _)).Times(1);
108 108
109 flow_controller_->AddBytesConsumed(1 + receive_window_ / 2); 109 flow_controller_->AddBytesConsumed(1 + receive_window_ / 2);
110 110
111 // Result is that once again we have a fully open receive window. 111 // Result is that once again we have a fully open receive window.
112 EXPECT_FALSE(flow_controller_->FlowControlViolation()); 112 EXPECT_FALSE(flow_controller_->FlowControlViolation());
113 EXPECT_EQ(kInitialSessionFlowControlWindowForTest, 113 EXPECT_EQ(kInitialSessionFlowControlWindowForTest,
114 QuicFlowControllerPeer::ReceiveWindowSize(flow_controller_.get())); 114 QuicFlowControllerPeer::ReceiveWindowSize(flow_controller_.get()));
115 } 115 }
116 116
117 TEST_F(QuicFlowControllerTest,
118 DisabledWhenQuicVersionDoesNotSupportFlowControl) {
119 // Only support version 16: no flow control.
120 QuicConnectionPeer::SetSupportedVersions(&connection_,
121 SupportedVersions(QUIC_VERSION_16));
122
123 Initialize();
124
125 MockConnection connection(false);
126
127 // Should not be enabled, and should not report as blocked.
128 EXPECT_FALSE(flow_controller_->IsEnabled());
129 EXPECT_FALSE(flow_controller_->IsBlocked());
130 EXPECT_FALSE(flow_controller_->FlowControlViolation());
131
132 // Any attempts to add/remove bytes should have no effect.
133 EXPECT_EQ(send_window_, flow_controller_->SendWindowSize());
134 EXPECT_EQ(send_window_,
135 QuicFlowControllerPeer::SendWindowOffset(flow_controller_.get()));
136 EXPECT_EQ(receive_window_, QuicFlowControllerPeer::ReceiveWindowOffset(
137 flow_controller_.get()));
138 flow_controller_->AddBytesSent(123);
139 flow_controller_->AddBytesConsumed(456);
140 flow_controller_->UpdateHighestReceivedOffset(789);
141 EXPECT_EQ(send_window_, flow_controller_->SendWindowSize());
142 EXPECT_EQ(send_window_,
143 QuicFlowControllerPeer::SendWindowOffset(flow_controller_.get()));
144 EXPECT_EQ(receive_window_, QuicFlowControllerPeer::ReceiveWindowOffset(
145 flow_controller_.get()));
146
147 // Any attempt to change offset should have no effect.
148 EXPECT_EQ(send_window_, flow_controller_->SendWindowSize());
149 EXPECT_EQ(send_window_,
150 QuicFlowControllerPeer::SendWindowOffset(flow_controller_.get()));
151 flow_controller_->UpdateSendWindowOffset(send_window_ + 12345);
152 EXPECT_EQ(send_window_, flow_controller_->SendWindowSize());
153 EXPECT_EQ(send_window_,
154 QuicFlowControllerPeer::SendWindowOffset(flow_controller_.get()));
155
156 // The connection should never send WINDOW_UPDATE or BLOCKED frames, even if
157 // the internal state implies that it should.
158
159 // If the flow controller was enabled, then a send window size of 0 would
160 // trigger a BLOCKED frame to be sent.
161 EXPECT_EQ(send_window_, flow_controller_->SendWindowSize());
162 EXPECT_CALL(connection_, SendBlocked(_)).Times(0);
163 flow_controller_->MaybeSendBlocked();
164
165 // If the flow controller was enabled, then a WINDOW_UPDATE would be sent if
166 // (receive window) < (max receive window / 2)
167 QuicFlowControllerPeer::SetReceiveWindowOffset(flow_controller_.get(),
168 max_receive_window_ / 10);
169 EXPECT_TRUE(QuicFlowControllerPeer::ReceiveWindowSize(
170 flow_controller_.get()) < (max_receive_window_ / 2));
171 EXPECT_CALL(connection_, SendWindowUpdate(_, _)).Times(0);
172 flow_controller_->AddBytesConsumed(0);
173
174 // Should not be enabled, and should not report as blocked.
175 EXPECT_FALSE(flow_controller_->IsEnabled());
176 EXPECT_FALSE(flow_controller_->IsBlocked());
177 EXPECT_FALSE(flow_controller_->FlowControlViolation());
178 }
179
180 TEST_F(QuicFlowControllerTest, OnlySendBlockedFrameOncePerOffset) { 117 TEST_F(QuicFlowControllerTest, OnlySendBlockedFrameOncePerOffset) {
181 Initialize(); 118 Initialize();
182 119
183 // Test that we don't send duplicate BLOCKED frames. We should only send one 120 // Test that we don't send duplicate BLOCKED frames. We should only send one
184 // BLOCKED frame at a given send window offset. 121 // BLOCKED frame at a given send window offset.
185 EXPECT_TRUE(flow_controller_->IsEnabled()); 122 EXPECT_TRUE(flow_controller_->IsEnabled());
186 EXPECT_FALSE(flow_controller_->IsBlocked()); 123 EXPECT_FALSE(flow_controller_->IsBlocked());
187 EXPECT_FALSE(flow_controller_->FlowControlViolation()); 124 EXPECT_FALSE(flow_controller_->FlowControlViolation());
188 EXPECT_EQ(send_window_, flow_controller_->SendWindowSize()); 125 EXPECT_EQ(send_window_, flow_controller_->SendWindowSize());
189 126
(...skipping 22 matching lines...) Expand all
212 flow_controller_->AddBytesSent(send_window_); 149 flow_controller_->AddBytesSent(send_window_);
213 EXPECT_TRUE(flow_controller_->IsBlocked()); 150 EXPECT_TRUE(flow_controller_->IsBlocked());
214 EXPECT_EQ(0u, flow_controller_->SendWindowSize()); 151 EXPECT_EQ(0u, flow_controller_->SendWindowSize());
215 152
216 // BLOCKED frame should get sent as send offset has changed. 153 // BLOCKED frame should get sent as send offset has changed.
217 flow_controller_->MaybeSendBlocked(); 154 flow_controller_->MaybeSendBlocked();
218 } 155 }
219 156
220 } // namespace test 157 } // namespace test
221 } // namespace net 158 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_flow_controller.cc ('k') | net/quic/quic_framer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698