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

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

Issue 15074007: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix for windows Created 7 years, 7 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_client_session.cc ('k') | net/quic/quic_config.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_client_session.h" 5 #include "net/quic/quic_client_session.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "net/base/capturing_net_log.h" 9 #include "net/base/capturing_net_log.h"
10 #include "net/base/test_completion_callback.h" 10 #include "net/base/test_completion_callback.h"
11 #include "net/quic/crypto/aes_128_gcm_encrypter.h" 11 #include "net/quic/crypto/aes_128_gcm_encrypter.h"
12 #include "net/quic/crypto/crypto_protocol.h" 12 #include "net/quic/crypto/crypto_protocol.h"
13 #include "net/quic/crypto/quic_decrypter.h" 13 #include "net/quic/crypto/quic_decrypter.h"
14 #include "net/quic/crypto/quic_encrypter.h" 14 #include "net/quic/crypto/quic_encrypter.h"
15 #include "net/quic/test_tools/crypto_test_utils.h" 15 #include "net/quic/test_tools/crypto_test_utils.h"
16 #include "net/quic/test_tools/quic_client_session_peer.h"
16 #include "net/quic/test_tools/quic_test_utils.h" 17 #include "net/quic/test_tools/quic_test_utils.h"
17 18
18 using testing::_; 19 using testing::_;
19 20
20 namespace net { 21 namespace net {
21 namespace test { 22 namespace test {
22 namespace { 23 namespace {
23 24
24 const char kServerHostname[] = "www.example.com"; 25 const char kServerHostname[] = "www.example.com";
25 26
26 class QuicClientSessionTest : public ::testing::Test { 27 class QuicClientSessionTest : public ::testing::Test {
27 protected: 28 protected:
28 QuicClientSessionTest() 29 QuicClientSessionTest()
29 : guid_(1), 30 : guid_(1),
30 connection_(new PacketSavingConnection(guid_, IPEndPoint(), false)), 31 connection_(new PacketSavingConnection(guid_, IPEndPoint(), false)),
31 session_(connection_, NULL, NULL, NULL, kServerHostname, 32 session_(connection_, NULL, NULL, NULL, kServerHostname,
32 &crypto_config_, &net_log_) { 33 QuicConfig(), &crypto_config_, &net_log_) {
33 crypto_config_.SetDefaults(); 34 crypto_config_.SetDefaults();
35 QuicClientSessionPeer::SetMaxOpenStreams(&session_, 1, 1);
34 } 36 }
35 37
36 void CompleteCryptoHandshake() { 38 void CompleteCryptoHandshake() {
37 ASSERT_EQ(ERR_IO_PENDING, 39 ASSERT_EQ(ERR_IO_PENDING,
38 session_.CryptoConnect(callback_.callback())); 40 session_.CryptoConnect(callback_.callback()));
39 CryptoTestUtils::HandshakeWithFakeServer( 41 CryptoTestUtils::HandshakeWithFakeServer(
40 connection_, session_.GetCryptoStream()); 42 connection_, session_.GetCryptoStream());
41 ASSERT_EQ(OK, callback_.WaitForResult()); 43 ASSERT_EQ(OK, callback_.WaitForResult());
42 } 44 }
43 45
44 QuicGuid guid_; 46 QuicGuid guid_;
45 PacketSavingConnection* connection_; 47 PacketSavingConnection* connection_;
46 CapturingNetLog net_log_; 48 CapturingNetLog net_log_;
47 QuicClientSession session_; 49 QuicClientSession session_;
48 MockClock clock_; 50 MockClock clock_;
49 MockRandom random_; 51 MockRandom random_;
50 QuicConnectionVisitorInterface* visitor_; 52 QuicConnectionVisitorInterface* visitor_;
51 TestCompletionCallback callback_; 53 TestCompletionCallback callback_;
52 QuicConfig* config_;
53 QuicCryptoClientConfig crypto_config_; 54 QuicCryptoClientConfig crypto_config_;
54 }; 55 };
55 56
56 TEST_F(QuicClientSessionTest, CryptoConnect) { 57 TEST_F(QuicClientSessionTest, CryptoConnect) {
57 if (!Aes128GcmEncrypter::IsSupported()) { 58 if (!Aes128GcmEncrypter::IsSupported()) {
58 LOG(INFO) << "AES GCM not supported. Test skipped."; 59 LOG(INFO) << "AES GCM not supported. Test skipped.";
59 return; 60 return;
60 } 61 }
61 62
62 CompleteCryptoHandshake(); 63 CompleteCryptoHandshake();
(...skipping 30 matching lines...) Expand all
93 94
94 // After receiving a GoAway, I should no longer be able to create outgoing 95 // After receiving a GoAway, I should no longer be able to create outgoing
95 // streams. 96 // streams.
96 session_.OnGoAway(QuicGoAwayFrame(QUIC_PEER_GOING_AWAY, 1u, "Going away.")); 97 session_.OnGoAway(QuicGoAwayFrame(QUIC_PEER_GOING_AWAY, 1u, "Going away."));
97 EXPECT_EQ(NULL, session_.CreateOutgoingReliableStream()); 98 EXPECT_EQ(NULL, session_.CreateOutgoingReliableStream());
98 } 99 }
99 100
100 } // namespace 101 } // namespace
101 } // namespace test 102 } // namespace test
102 } // namespace net 103 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_client_session.cc ('k') | net/quic/quic_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698