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

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

Issue 312553003: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_flow_controller.cc ('k') | net/quic/quic_framer.h » ('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_flags.h" 8 #include "net/quic/quic_flags.h"
9 #include "net/quic/quic_utils.h" 9 #include "net/quic/quic_utils.h"
10 #include "net/quic/test_tools/quic_flow_controller_peer.h" 10 #include "net/quic/test_tools/quic_flow_controller_peer.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 } 90 }
91 91
92 TEST_F(QuicFlowControllerTest, ReceivingBytes) { 92 TEST_F(QuicFlowControllerTest, ReceivingBytes) {
93 Initialize(); 93 Initialize();
94 94
95 EXPECT_TRUE(flow_controller_->IsEnabled()); 95 EXPECT_TRUE(flow_controller_->IsEnabled());
96 EXPECT_FALSE(flow_controller_->IsBlocked()); 96 EXPECT_FALSE(flow_controller_->IsBlocked());
97 EXPECT_FALSE(flow_controller_->FlowControlViolation()); 97 EXPECT_FALSE(flow_controller_->FlowControlViolation());
98 98
99 // Buffer some bytes, not enough to fill window. 99 // Buffer some bytes, not enough to fill window.
100 flow_controller_->AddBytesBuffered(receive_window_ / 2); 100 EXPECT_TRUE(
101 flow_controller_->UpdateHighestReceivedOffset(1 + receive_window_ / 2));
101 EXPECT_FALSE(flow_controller_->FlowControlViolation()); 102 EXPECT_FALSE(flow_controller_->FlowControlViolation());
102 EXPECT_EQ(receive_window_ / 2, 103 EXPECT_EQ((receive_window_ / 2) - 1,
103 QuicFlowControllerPeer::ReceiveWindowSize(flow_controller_.get())); 104 QuicFlowControllerPeer::ReceiveWindowSize(flow_controller_.get()));
104 105
105 // Consume enough bytes to send a WINDOW_UPDATE frame. 106 // Consume enough bytes to send a WINDOW_UPDATE frame.
106 flow_controller_->RemoveBytesBuffered(receive_window_ / 2);
107 flow_controller_->AddBytesConsumed(1 + receive_window_ / 2); 107 flow_controller_->AddBytesConsumed(1 + receive_window_ / 2);
108 EXPECT_FALSE(flow_controller_->FlowControlViolation()); 108 EXPECT_FALSE(flow_controller_->FlowControlViolation());
109 EXPECT_EQ((receive_window_ / 2) - 1, 109 EXPECT_EQ((receive_window_ / 2) - 1,
110 QuicFlowControllerPeer::ReceiveWindowSize(flow_controller_.get())); 110 QuicFlowControllerPeer::ReceiveWindowSize(flow_controller_.get()));
111 111
112 MockConnection connection(false); 112 MockConnection connection(false);
113 EXPECT_CALL(connection, SendWindowUpdate(stream_id_, _)).Times(1); 113 EXPECT_CALL(connection, SendWindowUpdate(stream_id_, _)).Times(1);
114 flow_controller_->MaybeSendWindowUpdate(&connection); 114 flow_controller_->MaybeSendWindowUpdate(&connection);
115 } 115 }
116 116
117 TEST_F(QuicFlowControllerTest, 117 TEST_F(QuicFlowControllerTest,
118 DisabledWhenQuicVersionDoesNotSupportFlowControl) { 118 DisabledWhenQuicVersionDoesNotSupportFlowControl) {
119 set_version(QUIC_VERSION_16); 119 set_version(QUIC_VERSION_16);
120 Initialize(); 120 Initialize();
121 121
122 // Should not be enabled, and should not report as blocked. 122 // Should not be enabled, and should not report as blocked.
123 EXPECT_FALSE(flow_controller_->IsEnabled()); 123 EXPECT_FALSE(flow_controller_->IsEnabled());
124 EXPECT_FALSE(flow_controller_->IsBlocked()); 124 EXPECT_FALSE(flow_controller_->IsBlocked());
125 EXPECT_FALSE(flow_controller_->FlowControlViolation()); 125 EXPECT_FALSE(flow_controller_->FlowControlViolation());
126 126
127 // Any attempts to add/remove bytes should have no effect. 127 // Any attempts to add/remove bytes should have no effect.
128 EXPECT_EQ(send_window_, flow_controller_->SendWindowSize()); 128 EXPECT_EQ(send_window_, flow_controller_->SendWindowSize());
129 EXPECT_EQ(send_window_, 129 EXPECT_EQ(send_window_,
130 QuicFlowControllerPeer::SendWindowOffset(flow_controller_.get())); 130 QuicFlowControllerPeer::SendWindowOffset(flow_controller_.get()));
131 EXPECT_EQ(receive_window_, QuicFlowControllerPeer::ReceiveWindowOffset( 131 EXPECT_EQ(receive_window_, QuicFlowControllerPeer::ReceiveWindowOffset(
132 flow_controller_.get())); 132 flow_controller_.get()));
133 flow_controller_->AddBytesSent(123); 133 flow_controller_->AddBytesSent(123);
134 flow_controller_->AddBytesConsumed(456); 134 flow_controller_->AddBytesConsumed(456);
135 flow_controller_->AddBytesBuffered(789); 135 flow_controller_->UpdateHighestReceivedOffset(789);
136 flow_controller_->RemoveBytesBuffered(321);
137 EXPECT_EQ(send_window_, flow_controller_->SendWindowSize()); 136 EXPECT_EQ(send_window_, flow_controller_->SendWindowSize());
138 EXPECT_EQ(send_window_, 137 EXPECT_EQ(send_window_,
139 QuicFlowControllerPeer::SendWindowOffset(flow_controller_.get())); 138 QuicFlowControllerPeer::SendWindowOffset(flow_controller_.get()));
140 EXPECT_EQ(receive_window_, QuicFlowControllerPeer::ReceiveWindowOffset( 139 EXPECT_EQ(receive_window_, QuicFlowControllerPeer::ReceiveWindowOffset(
141 flow_controller_.get())); 140 flow_controller_.get()));
142 141
143 // Any attempt to change offset should have no effect. 142 // Any attempt to change offset should have no effect.
144 EXPECT_EQ(send_window_, flow_controller_->SendWindowSize()); 143 EXPECT_EQ(send_window_, flow_controller_->SendWindowSize());
145 EXPECT_EQ(send_window_, 144 EXPECT_EQ(send_window_,
146 QuicFlowControllerPeer::SendWindowOffset(flow_controller_.get())); 145 QuicFlowControllerPeer::SendWindowOffset(flow_controller_.get()));
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 flow_controller_->AddBytesSent(send_window_); 209 flow_controller_->AddBytesSent(send_window_);
211 EXPECT_TRUE(flow_controller_->IsBlocked()); 210 EXPECT_TRUE(flow_controller_->IsBlocked());
212 EXPECT_EQ(0u, flow_controller_->SendWindowSize()); 211 EXPECT_EQ(0u, flow_controller_->SendWindowSize());
213 212
214 // BLOCKED frame should get sent as send offset has changed. 213 // BLOCKED frame should get sent as send offset has changed.
215 flow_controller_->MaybeSendBlocked(&connection); 214 flow_controller_->MaybeSendBlocked(&connection);
216 } 215 }
217 216
218 } // namespace test 217 } // namespace test
219 } // namespace net 218 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_flow_controller.cc ('k') | net/quic/quic_framer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698