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

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

Issue 14816006: Land Recent QUIC changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added missing NET_PRIVATE_EXPORT to QuicWallTime 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_crypto_client_stream.cc ('k') | net/quic/quic_crypto_server_stream.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_crypto_client_stream.h" 5 #include "net/quic/quic_crypto_client_stream.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "net/quic/crypto/aes_128_gcm_encrypter.h" 8 #include "net/quic/crypto/aes_128_gcm_encrypter.h"
9 #include "net/quic/crypto/quic_decrypter.h" 9 #include "net/quic/crypto/quic_decrypter.h"
10 #include "net/quic/crypto/quic_encrypter.h" 10 #include "net/quic/crypto/quic_encrypter.h"
(...skipping 27 matching lines...) Expand all
38 } 38 }
39 QuicStreamFrame* frame() { return &frame_; } 39 QuicStreamFrame* frame() { return &frame_; }
40 40
41 private: 41 private:
42 QuicStreamFrame frame_; 42 QuicStreamFrame frame_;
43 bool frame_valid_; 43 bool frame_valid_;
44 44
45 DISALLOW_COPY_AND_ASSIGN(TestQuicVisitor); 45 DISALLOW_COPY_AND_ASSIGN(TestQuicVisitor);
46 }; 46 };
47 47
48 // The same as MockSession, except that WriteData() is not mocked.
49 class TestMockSession : public MockSession {
50 public:
51 TestMockSession(QuicConnection* connection, bool is_server)
52 : MockSession(connection, is_server) {
53 }
54 virtual ~TestMockSession() {}
55
56 virtual QuicConsumedData WriteData(QuicStreamId id,
57 base::StringPiece data,
58 QuicStreamOffset offset,
59 bool fin) OVERRIDE {
60 return QuicSession::WriteData(id, data, offset, fin);
61 }
62 };
63
64 class QuicCryptoClientStreamTest : public ::testing::Test { 48 class QuicCryptoClientStreamTest : public ::testing::Test {
65 public: 49 public:
66 QuicCryptoClientStreamTest() 50 QuicCryptoClientStreamTest()
67 : addr_(), 51 : addr_(),
68 connection_(new PacketSavingConnection(1, addr_, true)), 52 connection_(new PacketSavingConnection(1, addr_, true)),
69 session_(connection_, true), 53 session_(connection_, true),
70 stream_(kServerHostname, config_, &session_, &crypto_config_) { 54 stream_(kServerHostname, config_, &session_, &crypto_config_) {
55 session_.SetCryptoStream(&stream_);
71 config_.SetDefaults(); 56 config_.SetDefaults();
72 crypto_config_.SetDefaults(); 57 crypto_config_.SetDefaults();
73 } 58 }
74 59
75 void CompleteCryptoHandshake() { 60 void CompleteCryptoHandshake() {
76 EXPECT_TRUE(stream_.CryptoConnect()); 61 EXPECT_TRUE(stream_.CryptoConnect());
77 CryptoTestUtils::HandshakeWithFakeServer(connection_, &stream_); 62 CryptoTestUtils::HandshakeWithFakeServer(connection_, &stream_);
78 } 63 }
79 64
80 void ConstructHandshakeMessage() { 65 void ConstructHandshakeMessage() {
81 CryptoFramer framer; 66 CryptoFramer framer;
82 message_data_.reset(framer.ConstructHandshakeMessage(message_)); 67 message_data_.reset(framer.ConstructHandshakeMessage(message_));
83 } 68 }
84 69
85 IPEndPoint addr_; 70 IPEndPoint addr_;
86 PacketSavingConnection* connection_; 71 PacketSavingConnection* connection_;
87 TestMockSession session_; 72 TestSession session_;
88 QuicCryptoClientStream stream_; 73 QuicCryptoClientStream stream_;
89 CryptoHandshakeMessage message_; 74 CryptoHandshakeMessage message_;
90 scoped_ptr<QuicData> message_data_; 75 scoped_ptr<QuicData> message_data_;
91 QuicConfig config_; 76 QuicConfig config_;
92 QuicCryptoClientConfig crypto_config_; 77 QuicCryptoClientConfig crypto_config_;
93 }; 78 };
94 79
95 TEST_F(QuicCryptoClientStreamTest, NotInitiallyConected) { 80 TEST_F(QuicCryptoClientStreamTest, NotInitiallyConected) {
96 if (!Aes128GcmEncrypter::IsSupported()) { 81 if (!Aes128GcmEncrypter::IsSupported()) {
97 LOG(INFO) << "AES GCM not supported. Test skipped."; 82 LOG(INFO) << "AES GCM not supported. Test skipped.";
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 144
160 const QuicCryptoNegotiatedParameters& crypto_params( 145 const QuicCryptoNegotiatedParameters& crypto_params(
161 stream_.crypto_negotiated_params()); 146 stream_.crypto_negotiated_params());
162 EXPECT_EQ(kAESG, crypto_params.aead); 147 EXPECT_EQ(kAESG, crypto_params.aead);
163 EXPECT_EQ(kC255, crypto_params.key_exchange); 148 EXPECT_EQ(kC255, crypto_params.key_exchange);
164 } 149 }
165 150
166 } // namespace 151 } // namespace
167 } // namespace test 152 } // namespace test
168 } // namespace net 153 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_crypto_client_stream.cc ('k') | net/quic/quic_crypto_server_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698