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

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: Fix test leak 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
« no previous file with comments | « net/quic/quic_connection_helper.cc ('k') | net/quic/quic_connection_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 (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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 mock_writes_.reset(new MockWrite[writes_.size()]); 93 mock_writes_.reset(new MockWrite[writes_.size()]);
94 for (size_t i = 0; i < writes_.size(); i++) { 94 for (size_t i = 0; i < writes_.size(); i++) {
95 mock_writes_[i] = MockWrite(writes_[i].mode, 95 mock_writes_[i] = MockWrite(writes_[i].mode,
96 writes_[i].packet->data(), 96 writes_[i].packet->data(),
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 socket_.reset(new MockUDPClientSocket(socket_data_.get(),
104 new MockUDPClientSocket(socket_data_.get(), net_log_.net_log()); 104 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_.get());
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_ptr<MockUDPClientSocket> socket_;
177 scoped_array<MockWrite> mock_writes_; 178 scoped_array<MockWrite> mock_writes_;
178 MockClock clock_; 179 MockClock clock_;
179 MockRandom random_generator_; 180 MockRandom random_generator_;
180 scoped_ptr<TestConnection> connection_; 181 scoped_ptr<TestConnection> connection_;
181 testing::StrictMock<MockConnectionVisitor> visitor_; 182 testing::StrictMock<MockConnectionVisitor> visitor_;
182 183
183 private: 184 private:
184 void InitializeHeader(QuicPacketSequenceNumber sequence_number) { 185 void InitializeHeader(QuicPacketSequenceNumber sequence_number) {
185 header_.public_header.guid = guid_; 186 header_.public_header.guid = guid_;
186 header_.public_header.reset_flag = false; 187 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, _)).WillRepeatedly( 415 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, false, _)).WillRepeatedly(
415 testing::Return(QuicTime::Delta::Zero())); 416 testing::Return(QuicTime::Delta::Zero()));
416 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(testing::Return(true)); 417 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(testing::Return(true));
417 runner_->RunNextTask(); 418 runner_->RunNextTask();
418 EXPECT_EQ(0u, connection_->NumQueuedPackets()); 419 EXPECT_EQ(0u, connection_->NumQueuedPackets());
419 EXPECT_TRUE(AtEof()); 420 EXPECT_TRUE(AtEof());
420 } 421 }
421 422
422 } // namespace test 423 } // namespace test
423 } // namespace net 424 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection_helper.cc ('k') | net/quic/quic_connection_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698