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

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

Issue 11633030: Send the ClientHello handshake message. Fix a bug in (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Remove an extraneous test:: before TestCryptoVisitor Created 7 years, 11 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_crypto_stream_test.cc ('k') | net/quic/test_tools/quic_test_utils.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_stream_factory.h" 5 #include "net/quic/quic_stream_factory.h"
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "net/base/mock_host_resolver.h" 9 #include "net/base/mock_host_resolver.h"
10 #include "net/http/http_response_headers.h" 10 #include "net/http/http_response_headers.h"
11 #include "net/http/http_response_info.h" 11 #include "net/http/http_response_info.h"
12 #include "net/http/http_util.h" 12 #include "net/http/http_util.h"
13 #include "net/quic/quic_http_stream.h" 13 #include "net/quic/quic_http_stream.h"
14 #include "net/quic/test_tools/mock_clock.h" 14 #include "net/quic/test_tools/mock_clock.h"
15 #include "net/quic/test_tools/mock_random.h" 15 #include "net/quic/test_tools/mock_random.h"
16 #include "net/quic/test_tools/quic_test_utils.h" 16 #include "net/quic/test_tools/quic_test_utils.h"
17 #include "net/socket/socket_test_util.h" 17 #include "net/socket/socket_test_util.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 19
20 namespace net { 20 namespace net {
21 namespace test { 21 namespace test {
22 22
23 class QuicStreamFactoryTest : public ::testing::Test { 23 class QuicStreamFactoryTest : public ::testing::Test {
24 protected: 24 protected:
25 QuicStreamFactoryTest() 25 QuicStreamFactoryTest()
26 : factory_(&host_resolver_, &socket_factory_, 26 : clock_(new MockClock()),
27 &random_generator_, 27 factory_(&host_resolver_, &socket_factory_,
28 new MockClock()), 28 &random_generator_, clock_),
29 host_port_proxy_pair_(HostPortPair("www.google.com", 443), 29 host_port_proxy_pair_(HostPortPair("www.google.com", 443),
30 ProxyServer::Direct()) { 30 ProxyServer::Direct()) {
31 } 31 }
32 32
33 scoped_ptr<QuicEncryptedPacket> ConstructChlo() { 33 scoped_ptr<QuicEncryptedPacket> ConstructChlo() {
34 scoped_ptr<QuicPacket> chlo(ConstructHandshakePacket(0xDEADBEEF, kCHLO)); 34 scoped_ptr<QuicPacket> chlo(ConstructClientHelloPacket(0xDEADBEEF,
35 clock_,
36 &random_generator_));
35 QuicFramer framer(QuicDecrypter::Create(kNULL), 37 QuicFramer framer(QuicDecrypter::Create(kNULL),
36 QuicEncrypter::Create(kNULL)); 38 QuicEncrypter::Create(kNULL));
37 return scoped_ptr<QuicEncryptedPacket>(framer.EncryptPacket(*chlo)); 39 return scoped_ptr<QuicEncryptedPacket>(framer.EncryptPacket(*chlo));
38 } 40 }
39 41
40 scoped_ptr<QuicEncryptedPacket> ConstructShlo() { 42 scoped_ptr<QuicEncryptedPacket> ConstructShlo() {
41 scoped_ptr<QuicPacket> shlo(ConstructHandshakePacket(0xDEADBEEF, kSHLO)); 43 scoped_ptr<QuicPacket> shlo(ConstructHandshakePacket(0xDEADBEEF, kSHLO));
42 QuicFramer framer(QuicDecrypter::Create(kNULL), 44 QuicFramer framer(QuicDecrypter::Create(kNULL),
43 QuicEncrypter::Create(kNULL)); 45 QuicEncrypter::Create(kNULL));
44 return scoped_ptr<QuicEncryptedPacket>(framer.EncryptPacket(*shlo)); 46 return scoped_ptr<QuicEncryptedPacket>(framer.EncryptPacket(*shlo));
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 QuicFrames frames; 112 QuicFrames frames;
111 frames.push_back(frame); 113 frames.push_back(frame);
112 scoped_ptr<QuicPacket> packet( 114 scoped_ptr<QuicPacket> packet(
113 framer.ConstructFrameDataPacket(header, frames)); 115 framer.ConstructFrameDataPacket(header, frames));
114 return scoped_ptr<QuicEncryptedPacket>(framer.EncryptPacket(*packet)); 116 return scoped_ptr<QuicEncryptedPacket>(framer.EncryptPacket(*packet));
115 } 117 }
116 118
117 MockHostResolver host_resolver_; 119 MockHostResolver host_resolver_;
118 MockClientSocketFactory socket_factory_; 120 MockClientSocketFactory socket_factory_;
119 MockRandom random_generator_; 121 MockRandom random_generator_;
122 MockClock* clock_; // Owned by factory_.
120 QuicStreamFactory factory_; 123 QuicStreamFactory factory_;
121 HostPortProxyPair host_port_proxy_pair_; 124 HostPortProxyPair host_port_proxy_pair_;
122 BoundNetLog net_log_; 125 BoundNetLog net_log_;
123 TestCompletionCallback callback_; 126 TestCompletionCallback callback_;
124 }; 127 };
125 128
126 TEST_F(QuicStreamFactoryTest, CreateIfSessionExists) { 129 TEST_F(QuicStreamFactoryTest, CreateIfSessionExists) {
127 EXPECT_EQ(NULL, factory_.CreateIfSessionExists(host_port_proxy_pair_, 130 EXPECT_EQ(NULL, factory_.CreateIfSessionExists(host_port_proxy_pair_,
128 net_log_).get()); 131 net_log_).get());
129 } 132 }
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 stream.reset(); // Will reset stream 3. 287 stream.reset(); // Will reset stream 3.
285 288
286 EXPECT_TRUE(socket_data.at_read_eof()); 289 EXPECT_TRUE(socket_data.at_read_eof());
287 EXPECT_TRUE(socket_data.at_write_eof()); 290 EXPECT_TRUE(socket_data.at_write_eof());
288 EXPECT_TRUE(socket_data2.at_read_eof()); 291 EXPECT_TRUE(socket_data2.at_read_eof());
289 EXPECT_TRUE(socket_data2.at_write_eof()); 292 EXPECT_TRUE(socket_data2.at_write_eof());
290 } 293 }
291 294
292 } // namespace test 295 } // namespace test
293 } // namespace net 296 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_crypto_stream_test.cc ('k') | net/quic/test_tools/quic_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698