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

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

Issue 1190823003: Remove dependency on headers stream from QuicSession. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Final_0616
Patch Set: deleted an include Created 5 years, 6 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_session.cc ('k') | net/tools/quic/quic_dispatcher_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/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"
11 #include "net/quic/quic_flags.h" 11 #include "net/quic/quic_flags.h"
12 #include "net/quic/test_tools/crypto_test_utils.h" 12 #include "net/quic/test_tools/crypto_test_utils.h"
13 #include "net/quic/test_tools/quic_session_peer.h" 13 #include "net/quic/test_tools/quic_spdy_session_peer.h"
14 #include "net/quic/test_tools/quic_test_utils.h" 14 #include "net/quic/test_tools/quic_test_utils.h"
15 #include "net/tools/quic/quic_spdy_client_stream.h" 15 #include "net/tools/quic/quic_spdy_client_stream.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 using net::test::ConstructEncryptedPacket; 18 using net::test::ConstructEncryptedPacket;
19 using net::test::ConstructMisFramedEncryptedPacket; 19 using net::test::ConstructMisFramedEncryptedPacket;
20 using net::test::CryptoTestUtils; 20 using net::test::CryptoTestUtils;
21 using net::test::DefaultQuicConfig; 21 using net::test::DefaultQuicConfig;
22 using net::test::MockConnection; 22 using net::test::MockConnection;
23 using net::test::PacketSavingConnection; 23 using net::test::PacketSavingConnection;
24 using net::test::QuicSessionPeer; 24 using net::test::QuicSpdySessionPeer;
25 using net::test::SupportedVersions; 25 using net::test::SupportedVersions;
26 using net::test::TestPeerIPAddress; 26 using net::test::TestPeerIPAddress;
27 using net::test::ValueRestore; 27 using net::test::ValueRestore;
28 using net::test::kTestPort; 28 using net::test::kTestPort;
29 using testing::AnyNumber; 29 using testing::AnyNumber;
30 using testing::Invoke; 30 using testing::Invoke;
31 using testing::Truly; 31 using testing::Truly;
32 using testing::_; 32 using testing::_;
33 33
34 namespace net { 34 namespace net {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 73 }
74 74
75 TEST_P(ToolsQuicClientSessionTest, MaxNumStreams) { 75 TEST_P(ToolsQuicClientSessionTest, MaxNumStreams) {
76 EXPECT_CALL(*connection_, SendRstStream(_, _, _)).Times(AnyNumber()); 76 EXPECT_CALL(*connection_, SendRstStream(_, _, _)).Times(AnyNumber());
77 77
78 session_->config()->SetMaxStreamsPerConnection(1, 1); 78 session_->config()->SetMaxStreamsPerConnection(1, 1);
79 79
80 // Initialize crypto before the client session will create a stream. 80 // Initialize crypto before the client session will create a stream.
81 CompleteCryptoHandshake(); 81 CompleteCryptoHandshake();
82 82
83 QuicSpdyClientStream* stream = session_->CreateOutgoingDataStream(); 83 QuicSpdyClientStream* stream = session_->CreateOutgoingDynamicStream();
84 ASSERT_TRUE(stream); 84 ASSERT_TRUE(stream);
85 EXPECT_FALSE(session_->CreateOutgoingDataStream()); 85 EXPECT_FALSE(session_->CreateOutgoingDynamicStream());
86 86
87 // Close a stream and ensure I can now open a new one. 87 // Close a stream and ensure I can now open a new one.
88 session_->CloseStream(stream->id()); 88 session_->CloseStream(stream->id());
89 stream = session_->CreateOutgoingDataStream(); 89 stream = session_->CreateOutgoingDynamicStream();
90 EXPECT_TRUE(stream); 90 EXPECT_TRUE(stream);
91 } 91 }
92 92
93 TEST_P(ToolsQuicClientSessionTest, GoAwayReceived) { 93 TEST_P(ToolsQuicClientSessionTest, GoAwayReceived) {
94 CompleteCryptoHandshake(); 94 CompleteCryptoHandshake();
95 95
96 // After receiving a GoAway, I should no longer be able to create outgoing 96 // After receiving a GoAway, I should no longer be able to create outgoing
97 // streams. 97 // streams.
98 session_->OnGoAway(QuicGoAwayFrame(QUIC_PEER_GOING_AWAY, 1u, "Going away.")); 98 session_->OnGoAway(QuicGoAwayFrame(QUIC_PEER_GOING_AWAY, 1u, "Going away."));
99 EXPECT_EQ(nullptr, session_->CreateOutgoingDataStream()); 99 EXPECT_EQ(nullptr, session_->CreateOutgoingDynamicStream());
100 } 100 }
101 101
102 TEST_P(ToolsQuicClientSessionTest, SetFecProtectionFromConfig) { 102 TEST_P(ToolsQuicClientSessionTest, SetFecProtectionFromConfig) {
103 ValueRestore<bool> old_flag(&FLAGS_enable_quic_fec, true); 103 ValueRestore<bool> old_flag(&FLAGS_enable_quic_fec, true);
104 104
105 // Set FEC config in client's connection options. 105 // Set FEC config in client's connection options.
106 QuicTagVector copt; 106 QuicTagVector copt;
107 copt.push_back(kFHDR); 107 copt.push_back(kFHDR);
108 session_->config()->SetConnectionOptionsToSend(copt); 108 session_->config()->SetConnectionOptionsToSend(copt);
109 109
110 // Doing the handshake should set up FEC config correctly. 110 // Doing the handshake should set up FEC config correctly.
111 CompleteCryptoHandshake(); 111 CompleteCryptoHandshake();
112 112
113 // Verify that headers stream is always protected and data streams are 113 // Verify that headers stream is always protected and data streams are
114 // optionally protected. 114 // optionally protected.
115 EXPECT_EQ(FEC_PROTECT_ALWAYS, 115 EXPECT_EQ(FEC_PROTECT_ALWAYS, QuicSpdySessionPeer::GetHeadersStream(
116 QuicSessionPeer::GetHeadersStream(session_.get())->fec_policy()); 116 session_.get())->fec_policy());
117 QuicSpdyClientStream* stream = session_->CreateOutgoingDataStream(); 117 QuicSpdyClientStream* stream = session_->CreateOutgoingDynamicStream();
118 ASSERT_TRUE(stream); 118 ASSERT_TRUE(stream);
119 EXPECT_EQ(FEC_PROTECT_OPTIONAL, stream->fec_policy()); 119 EXPECT_EQ(FEC_PROTECT_OPTIONAL, stream->fec_policy());
120 } 120 }
121 121
122 static bool CheckForDecryptionError(QuicFramer* framer) { 122 static bool CheckForDecryptionError(QuicFramer* framer) {
123 return framer->error() == QUIC_DECRYPTION_FAILURE; 123 return framer->error() == QUIC_DECRYPTION_FAILURE;
124 } 124 }
125 125
126 // Regression test for b/17206611. 126 // Regression test for b/17206611.
127 TEST_P(ToolsQuicClientSessionTest, InvalidPacketReceived) { 127 TEST_P(ToolsQuicClientSessionTest, InvalidPacketReceived) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 PACKET_6BYTE_SEQUENCE_NUMBER, nullptr)); 177 PACKET_6BYTE_SEQUENCE_NUMBER, nullptr));
178 EXPECT_CALL(*connection_, SendConnectionCloseWithDetails(_, _)).Times(1); 178 EXPECT_CALL(*connection_, SendConnectionCloseWithDetails(_, _)).Times(1);
179 session_->connection()->ProcessUdpPacket(client_address, server_address, 179 session_->connection()->ProcessUdpPacket(client_address, server_address,
180 *packet); 180 *packet);
181 } 181 }
182 182
183 } // namespace 183 } // namespace
184 } // namespace test 184 } // namespace test
185 } // namespace tools 185 } // namespace tools
186 } // namespace net 186 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_client_session.cc ('k') | net/tools/quic/quic_dispatcher_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698