| OLD | NEW |
| 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 "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "net/base/capturing_net_log.h" | 10 #include "net/base/capturing_net_log.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 namespace test { | 23 namespace test { |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 const char kServerHostname[] = "www.example.com"; | 26 const char kServerHostname[] = "www.example.com"; |
| 27 | 27 |
| 28 class QuicClientSessionTest : public ::testing::Test { | 28 class QuicClientSessionTest : public ::testing::Test { |
| 29 protected: | 29 protected: |
| 30 QuicClientSessionTest() | 30 QuicClientSessionTest() |
| 31 : guid_(1), | 31 : guid_(1), |
| 32 connection_(new PacketSavingConnection(guid_, IPEndPoint(), false)), | 32 connection_(new PacketSavingConnection(guid_, IPEndPoint(), false)), |
| 33 session_(connection_, NULL, NULL, NULL, kServerHostname, &net_log_) { | 33 session_(connection_, NULL, NULL, NULL, kServerHostname, |
| 34 &crypto_config_, &net_log_) { |
| 35 crypto_config_.SetDefaults(); |
| 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_; |
| 54 QuicConfig* config_; |
| 55 QuicCryptoClientConfig crypto_config_; |
| 52 }; | 56 }; |
| 53 | 57 |
| 54 TEST_F(QuicClientSessionTest, CryptoConnect) { | 58 TEST_F(QuicClientSessionTest, CryptoConnect) { |
| 55 if (!Aes128GcmEncrypter::IsSupported()) { | 59 if (!Aes128GcmEncrypter::IsSupported()) { |
| 56 LOG(INFO) << "AES GCM not supported. Test skipped."; | 60 LOG(INFO) << "AES GCM not supported. Test skipped."; |
| 57 return; | 61 return; |
| 58 } | 62 } |
| 59 | 63 |
| 60 CompleteCryptoHandshake(); | 64 CompleteCryptoHandshake(); |
| 61 } | 65 } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 ASSERT_TRUE(entries[pos].GetIntegerValue("error_code", &error_code)); | 166 ASSERT_TRUE(entries[pos].GetIntegerValue("error_code", &error_code)); |
| 163 EXPECT_EQ(frame.error_code, static_cast<QuicRstStreamErrorCode>(error_code)); | 167 EXPECT_EQ(frame.error_code, static_cast<QuicRstStreamErrorCode>(error_code)); |
| 164 std::string details; | 168 std::string details; |
| 165 ASSERT_TRUE(entries[pos].GetStringValue("details", &details)); | 169 ASSERT_TRUE(entries[pos].GetStringValue("details", &details)); |
| 166 EXPECT_EQ(frame.error_details, details); | 170 EXPECT_EQ(frame.error_details, details); |
| 167 } | 171 } |
| 168 | 172 |
| 169 } // namespace | 173 } // namespace |
| 170 } // namespace test | 174 } // namespace test |
| 171 } // namespace net | 175 } // namespace net |
| OLD | NEW |