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

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

Issue 12545035: Refactor QuicClientSession so that it owns the underlying socket (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
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_connection_helper.h" 5 #include "net/quic/quic_connection_helper.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/quic/crypto/quic_decrypter.h" 10 #include "net/quic/crypto/quic_decrypter.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 writes_[i].packet->length()); 97 writes_[i].packet->length());
98 }; 98 };
99 99
100 socket_data_.reset(new StaticSocketDataProvider(NULL, 0, mock_writes_.get(), 100 socket_data_.reset(new StaticSocketDataProvider(NULL, 0, mock_writes_.get(),
101 writes_.size())); 101 writes_.size()));
102 102
103 MockUDPClientSocket* socket = 103 MockUDPClientSocket* socket =
104 new MockUDPClientSocket(socket_data_.get(), net_log_.net_log()); 104 new MockUDPClientSocket(socket_data_.get(), net_log_.net_log());
105 socket->Connect(IPEndPoint()); 105 socket->Connect(IPEndPoint());
106 runner_ = new TestTaskRunner(&clock_); 106 runner_ = new TestTaskRunner(&clock_);
107 helper_.reset(new QuicConnectionHelper(runner_.get(), &clock_, 107 helper_ = new QuicConnectionHelper(runner_.get(), &clock_,
108 &random_generator_, socket)); 108 &random_generator_, socket);
109 send_algorithm_ = new testing::StrictMock<MockSendAlgorithm>(); 109 send_algorithm_ = new testing::StrictMock<MockSendAlgorithm>();
110 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _)). 110 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _)).
111 WillRepeatedly(testing::Return(QuicTime::Delta::Zero())); 111 WillRepeatedly(testing::Return(QuicTime::Delta::Zero()));
112 connection_.reset(new TestConnection(guid_, IPEndPoint(), helper_.get())); 112 connection_.reset(new TestConnection(guid_, IPEndPoint(), helper_));
113 connection_->set_visitor(&visitor_); 113 connection_->set_visitor(&visitor_);
114 connection_->SetSendAlgorithm(send_algorithm_); 114 connection_->SetSendAlgorithm(send_algorithm_);
115 } 115 }
116 116
117 // Returns a newly created packet to send kData on stream 1. 117 // Returns a newly created packet to send kData on stream 1.
118 QuicEncryptedPacket* ConstructDataPacket( 118 QuicEncryptedPacket* ConstructDataPacket(
119 QuicPacketSequenceNumber sequence_number) { 119 QuicPacketSequenceNumber sequence_number) {
120 InitializeHeader(sequence_number); 120 InitializeHeader(sequence_number);
121 121
122 return ConstructPacket(header_, QuicFrame(&frame_)); 122 return ConstructPacket(header_, QuicFrame(&frame_));
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 ack.received_info.entropy_hash = 0; 166 ack.received_info.entropy_hash = 0;
167 QuicConnectionCloseFrame close; 167 QuicConnectionCloseFrame close;
168 close.error_code = QUIC_CONNECTION_TIMED_OUT; 168 close.error_code = QUIC_CONNECTION_TIMED_OUT;
169 close.ack_frame = ack; 169 close.ack_frame = ack;
170 170
171 return ConstructPacket(header_, QuicFrame(&close)); 171 return ConstructPacket(header_, QuicFrame(&close));
172 } 172 }
173 173
174 testing::StrictMock<MockSendAlgorithm>* send_algorithm_; 174 testing::StrictMock<MockSendAlgorithm>* send_algorithm_;
175 scoped_refptr<TestTaskRunner> runner_; 175 scoped_refptr<TestTaskRunner> runner_;
176 scoped_ptr<QuicConnectionHelper> helper_; 176 QuicConnectionHelper* helper_;
177 scoped_array<MockWrite> mock_writes_; 177 scoped_array<MockWrite> mock_writes_;
178 MockClock clock_; 178 MockClock clock_;
179 MockRandom random_generator_; 179 MockRandom random_generator_;
180 scoped_ptr<TestConnection> connection_; 180 scoped_ptr<TestConnection> connection_;
181 testing::StrictMock<MockConnectionVisitor> visitor_; 181 testing::StrictMock<MockConnectionVisitor> visitor_;
182 182
183 private: 183 private:
184 void InitializeHeader(QuicPacketSequenceNumber sequence_number) { 184 void InitializeHeader(QuicPacketSequenceNumber sequence_number) {
185 header_.public_header.guid = guid_; 185 header_.public_header.guid = guid_;
186 header_.public_header.reset_flag = false; 186 header_.public_header.reset_flag = false;
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, false)).WillOnce( 414 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, false)).WillOnce(
415 testing::Return(QuicTime::Delta::Zero())); 415 testing::Return(QuicTime::Delta::Zero()));
416 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(testing::Return(true)); 416 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(testing::Return(true));
417 runner_->RunNextTask(); 417 runner_->RunNextTask();
418 EXPECT_EQ(0u, connection_->NumQueuedPackets()); 418 EXPECT_EQ(0u, connection_->NumQueuedPackets());
419 EXPECT_TRUE(AtEof()); 419 EXPECT_TRUE(AtEof());
420 } 420 }
421 421
422 } // namespace test 422 } // namespace test
423 } // namespace net 423 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698