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

Side by Side Diff: net/tools/quic/quic_client_session_test.cc

Issue 1009543004: Create a Perspective enum to use instead of a bool is_server to improve (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added NET_EXPORT_PRIVATE to fix compiler error Created 5 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
« no previous file with comments | « net/tools/quic/quic_client.cc ('k') | net/tools/quic/quic_dispatcher.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/tools/quic/quic_client_session.h" 5 #include "net/tools/quic/quic_client_session.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "net/base/ip_endpoint.h" 9 #include "net/base/ip_endpoint.h"
10 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" 10 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h"
(...skipping 21 matching lines...) Expand all
32 namespace test { 32 namespace test {
33 namespace { 33 namespace {
34 34
35 const char kServerHostname[] = "www.example.org"; 35 const char kServerHostname[] = "www.example.org";
36 const uint16 kPort = 80; 36 const uint16 kPort = 80;
37 37
38 class ToolsQuicClientSessionTest 38 class ToolsQuicClientSessionTest
39 : public ::testing::TestWithParam<QuicVersion> { 39 : public ::testing::TestWithParam<QuicVersion> {
40 protected: 40 protected:
41 ToolsQuicClientSessionTest() 41 ToolsQuicClientSessionTest()
42 : connection_( 42 : connection_(new PacketSavingConnection(Perspective::IS_CLIENT,
43 new PacketSavingConnection(false, SupportedVersions(GetParam()))) { 43 SupportedVersions(GetParam()))) {
44 session_.reset(new QuicClientSession(DefaultQuicConfig(), connection_)); 44 session_.reset(new QuicClientSession(DefaultQuicConfig(), connection_));
45 session_->InitializeSession( 45 session_->InitializeSession(
46 QuicServerId(kServerHostname, kPort, false, PRIVACY_MODE_DISABLED), 46 QuicServerId(kServerHostname, kPort, false, PRIVACY_MODE_DISABLED),
47 &crypto_config_); 47 &crypto_config_);
48 // Advance the time, because timers do not like uninitialized times. 48 // Advance the time, because timers do not like uninitialized times.
49 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); 49 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1));
50 } 50 }
51 51
52 void CompleteCryptoHandshake() { 52 void CompleteCryptoHandshake() {
53 session_->CryptoConnect(); 53 session_->CryptoConnect();
54 CryptoTestUtils::HandshakeWithFakeServer( 54 CryptoTestUtils::HandshakeWithFakeServer(
55 connection_, session_->GetCryptoStream()); 55 connection_, session_->GetCryptoStream());
56 } 56 }
57 57
58 PacketSavingConnection* connection_; 58 PacketSavingConnection* connection_;
59 scoped_ptr<QuicClientSession> session_; 59 scoped_ptr<QuicClientSession> session_;
60 QuicCryptoClientConfig crypto_config_; 60 QuicCryptoClientConfig crypto_config_;
61 }; 61 };
62 62
63 INSTANTIATE_TEST_CASE_P(Tests, ToolsQuicClientSessionTest, 63 INSTANTIATE_TEST_CASE_P(Tests, ToolsQuicClientSessionTest,
64 ::testing::ValuesIn(QuicSupportedVersions())); 64 ::testing::ValuesIn(QuicSupportedVersions()));
65 65
66 TEST_P(ToolsQuicClientSessionTest, CryptoConnect) { 66 TEST_P(ToolsQuicClientSessionTest, CryptoConnect) {
67 CompleteCryptoHandshake(); 67 CompleteCryptoHandshake();
68 } 68 }
69 69
70 TEST_P(ToolsQuicClientSessionTest, MaxNumStreams) { 70 TEST_P(ToolsQuicClientSessionTest, MaxNumStreams) {
71 session_->config()->SetMaxStreamsPerConnection(1, 1); 71 session_->config()->SetMaxStreamsPerConnection(1, 1);
72 // FLAGS_max_streams_per_connection = 1; 72
73 // Initialize crypto before the client session will create a stream. 73 // Initialize crypto before the client session will create a stream.
74 CompleteCryptoHandshake(); 74 CompleteCryptoHandshake();
75 75
76 QuicSpdyClientStream* stream = session_->CreateOutgoingDataStream(); 76 QuicSpdyClientStream* stream = session_->CreateOutgoingDataStream();
77 ASSERT_TRUE(stream); 77 ASSERT_TRUE(stream);
78 EXPECT_FALSE(session_->CreateOutgoingDataStream()); 78 EXPECT_FALSE(session_->CreateOutgoingDataStream());
79 79
80 // Close a stream and ensure I can now open a new one. 80 // Close a stream and ensure I can now open a new one.
81 session_->CloseStream(stream->id()); 81 session_->CloseStream(stream->id());
82 stream = session_->CreateOutgoingDataStream(); 82 stream = session_->CreateOutgoingDataStream();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 // Close connection shouldn't be called. 136 // Close connection shouldn't be called.
137 EXPECT_CALL(*connection_, SendConnectionCloseWithDetails(_, _)).Times(0); 137 EXPECT_CALL(*connection_, SendConnectionCloseWithDetails(_, _)).Times(0);
138 session_->connection()->ProcessUdpPacket(client_address, server_address, 138 session_->connection()->ProcessUdpPacket(client_address, server_address,
139 valid_packet); 139 valid_packet);
140 } 140 }
141 141
142 } // namespace 142 } // namespace
143 } // namespace test 143 } // namespace test
144 } // namespace tools 144 } // namespace tools
145 } // namespace net 145 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_client.cc ('k') | net/tools/quic/quic_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698