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

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

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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_framer_test.cc ('k') | net/quic/quic_packet_creator.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_http_stream.h" 5 #include "net/quic/quic_http_stream.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "net/base/chunked_upload_data_stream.h" 9 #include "net/base/chunked_upload_data_stream.h"
10 #include "net/base/elements_upload_data_stream.h" 10 #include "net/base/elements_upload_data_stream.h"
11 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
12 #include "net/base/test_completion_callback.h" 12 #include "net/base/test_completion_callback.h"
13 #include "net/base/upload_bytes_element_reader.h" 13 #include "net/base/upload_bytes_element_reader.h"
14 #include "net/http/http_response_headers.h" 14 #include "net/http/http_response_headers.h"
15 #include "net/http/transport_security_state.h" 15 #include "net/http/transport_security_state.h"
16 #include "net/quic/congestion_control/receive_algorithm_interface.h"
17 #include "net/quic/congestion_control/send_algorithm_interface.h" 16 #include "net/quic/congestion_control/send_algorithm_interface.h"
18 #include "net/quic/crypto/crypto_protocol.h" 17 #include "net/quic/crypto/crypto_protocol.h"
19 #include "net/quic/crypto/quic_decrypter.h" 18 #include "net/quic/crypto/quic_decrypter.h"
20 #include "net/quic/crypto/quic_encrypter.h" 19 #include "net/quic/crypto/quic_encrypter.h"
21 #include "net/quic/crypto/quic_server_info.h" 20 #include "net/quic/crypto/quic_server_info.h"
22 #include "net/quic/quic_client_session.h" 21 #include "net/quic/quic_client_session.h"
23 #include "net/quic/quic_connection.h" 22 #include "net/quic/quic_connection.h"
24 #include "net/quic/quic_connection_helper.h" 23 #include "net/quic/quic_connection_helper.h"
25 #include "net/quic/quic_default_packet_writer.h" 24 #include "net/quic/quic_default_packet_writer.h"
26 #include "net/quic/quic_http_utils.h" 25 #include "net/quic/quic_http_utils.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 writer_factory, 66 writer_factory,
68 true /* owns_writer */, 67 true /* owns_writer */,
69 false /* is_server */, 68 false /* is_server */,
70 false /* is_secure */, 69 false /* is_secure */,
71 versions) { 70 versions) {
72 } 71 }
73 72
74 void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) { 73 void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) {
75 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm); 74 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm);
76 } 75 }
77
78 void SetReceiveAlgorithm(ReceiveAlgorithmInterface* receive_algorithm) {
79 QuicConnectionPeer::SetReceiveAlgorithm(this, receive_algorithm);
80 }
81 };
82
83 class TestReceiveAlgorithm : public ReceiveAlgorithmInterface {
84 public:
85 MOCK_METHOD3(RecordIncomingPacket,
86 void(QuicByteCount, QuicPacketSequenceNumber, QuicTime));
87 }; 76 };
88 77
89 // Subclass of QuicHttpStream that closes itself when the first piece of data 78 // Subclass of QuicHttpStream that closes itself when the first piece of data
90 // is received. 79 // is received.
91 class AutoClosingStream : public QuicHttpStream { 80 class AutoClosingStream : public QuicHttpStream {
92 public: 81 public:
93 explicit AutoClosingStream(const base::WeakPtr<QuicClientSession>& session) 82 explicit AutoClosingStream(const base::WeakPtr<QuicClientSession>& session)
94 : QuicHttpStream(session) { 83 : QuicHttpStream(session) {
95 } 84 }
96 85
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 }; 180 };
192 181
193 socket_data_.reset(new StaticSocketDataProvider( 182 socket_data_.reset(new StaticSocketDataProvider(
194 nullptr, 0, mock_writes_.get(), writes_.size())); 183 nullptr, 0, mock_writes_.get(), writes_.size()));
195 184
196 MockUDPClientSocket* socket = new MockUDPClientSocket(socket_data_.get(), 185 MockUDPClientSocket* socket = new MockUDPClientSocket(socket_data_.get(),
197 net_log_.net_log()); 186 net_log_.net_log());
198 socket->Connect(peer_addr_); 187 socket->Connect(peer_addr_);
199 runner_ = new TestTaskRunner(&clock_); 188 runner_ = new TestTaskRunner(&clock_);
200 send_algorithm_ = new MockSendAlgorithm(); 189 send_algorithm_ = new MockSendAlgorithm();
201 receive_algorithm_ = new TestReceiveAlgorithm();
202 EXPECT_CALL(*receive_algorithm_, RecordIncomingPacket(_, _, _)).
203 Times(AnyNumber());
204 EXPECT_CALL(*send_algorithm_, 190 EXPECT_CALL(*send_algorithm_,
205 OnPacketSent(_, _, _, _, _)).WillRepeatedly(Return(true)); 191 OnPacketSent(_, _, _, _, _)).WillRepeatedly(Return(true));
206 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()).WillRepeatedly( 192 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()).WillRepeatedly(
207 Return(QuicTime::Delta::Zero())); 193 Return(QuicTime::Delta::Zero()));
208 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly( 194 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly(
209 Return(kMaxPacketSize)); 195 Return(kMaxPacketSize));
210 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)). 196 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)).
211 WillRepeatedly(Return(QuicTime::Delta::Zero())); 197 WillRepeatedly(Return(QuicTime::Delta::Zero()));
212 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillRepeatedly( 198 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillRepeatedly(
213 Return(QuicBandwidth::Zero())); 199 Return(QuicBandwidth::Zero()));
214 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _)).Times(AnyNumber()); 200 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _)).Times(AnyNumber());
215 helper_.reset(new QuicConnectionHelper(runner_.get(), &clock_, 201 helper_.reset(new QuicConnectionHelper(runner_.get(), &clock_,
216 &random_generator_)); 202 &random_generator_));
217 TestPacketWriterFactory writer_factory(socket); 203 TestPacketWriterFactory writer_factory(socket);
218 connection_ = new TestQuicConnection(SupportedVersions(GetParam()), 204 connection_ = new TestQuicConnection(SupportedVersions(GetParam()),
219 connection_id_, peer_addr_, 205 connection_id_, peer_addr_,
220 helper_.get(), writer_factory); 206 helper_.get(), writer_factory);
221 connection_->set_visitor(&visitor_); 207 connection_->set_visitor(&visitor_);
222 connection_->SetSendAlgorithm(send_algorithm_); 208 connection_->SetSendAlgorithm(send_algorithm_);
223 connection_->SetReceiveAlgorithm(receive_algorithm_);
224 session_.reset( 209 session_.reset(
225 new QuicClientSession(connection_, 210 new QuicClientSession(connection_,
226 scoped_ptr<DatagramClientSocket>(socket), 211 scoped_ptr<DatagramClientSocket>(socket),
227 nullptr, 212 nullptr,
228 &transport_security_state_, 213 &transport_security_state_,
229 make_scoped_ptr((QuicServerInfo*)nullptr), 214 make_scoped_ptr((QuicServerInfo*)nullptr),
230 DefaultQuicConfig(), 215 DefaultQuicConfig(),
231 base::MessageLoop::current()-> 216 base::MessageLoop::current()->
232 message_loop_proxy().get(), 217 message_loop_proxy().get(),
233 nullptr)); 218 nullptr));
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 QuicPacketSequenceNumber sequence_number, 285 QuicPacketSequenceNumber sequence_number,
301 QuicPacketSequenceNumber largest_received, 286 QuicPacketSequenceNumber largest_received,
302 QuicPacketSequenceNumber least_unacked) { 287 QuicPacketSequenceNumber least_unacked) {
303 return maker_.MakeAckPacket(sequence_number, largest_received, 288 return maker_.MakeAckPacket(sequence_number, largest_received,
304 least_unacked, !kIncludeCongestionFeedback); 289 least_unacked, !kIncludeCongestionFeedback);
305 } 290 }
306 291
307 BoundNetLog net_log_; 292 BoundNetLog net_log_;
308 bool use_closing_stream_; 293 bool use_closing_stream_;
309 MockSendAlgorithm* send_algorithm_; 294 MockSendAlgorithm* send_algorithm_;
310 TestReceiveAlgorithm* receive_algorithm_;
311 scoped_refptr<TestTaskRunner> runner_; 295 scoped_refptr<TestTaskRunner> runner_;
312 scoped_ptr<MockWrite[]> mock_writes_; 296 scoped_ptr<MockWrite[]> mock_writes_;
313 MockClock clock_; 297 MockClock clock_;
314 TestQuicConnection* connection_; 298 TestQuicConnection* connection_;
315 scoped_ptr<QuicConnectionHelper> helper_; 299 scoped_ptr<QuicConnectionHelper> helper_;
316 testing::StrictMock<MockConnectionVisitor> visitor_; 300 testing::StrictMock<MockConnectionVisitor> visitor_;
317 scoped_ptr<QuicHttpStream> stream_; 301 scoped_ptr<QuicHttpStream> stream_;
318 TransportSecurityState transport_security_state_; 302 TransportSecurityState transport_security_state_;
319 scoped_ptr<QuicClientSession> session_; 303 scoped_ptr<QuicClientSession> session_;
320 QuicCryptoClientConfig crypto_config_; 304 QuicCryptoClientConfig crypto_config_;
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 // Set Delegate to nullptr and make sure EffectivePriority returns highest 757 // Set Delegate to nullptr and make sure EffectivePriority returns highest
774 // priority. 758 // priority.
775 reliable_stream->SetDelegate(nullptr); 759 reliable_stream->SetDelegate(nullptr);
776 DCHECK_EQ(QuicWriteBlockedList::kHighestPriority, 760 DCHECK_EQ(QuicWriteBlockedList::kHighestPriority,
777 reliable_stream->EffectivePriority()); 761 reliable_stream->EffectivePriority());
778 reliable_stream->SetDelegate(delegate); 762 reliable_stream->SetDelegate(delegate);
779 } 763 }
780 764
781 } // namespace test 765 } // namespace test
782 } // namespace net 766 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_framer_test.cc ('k') | net/quic/quic_packet_creator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698