| 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_crypto_stream.h" | 5 #include "net/quic/quic_crypto_stream.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 vector<CryptoHandshakeMessage> messages_; | 41 vector<CryptoHandshakeMessage> messages_; |
| 42 | 42 |
| 43 DISALLOW_COPY_AND_ASSIGN(MockQuicCryptoStream); | 43 DISALLOW_COPY_AND_ASSIGN(MockQuicCryptoStream); |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 class QuicCryptoStreamTest : public ::testing::Test { | 46 class QuicCryptoStreamTest : public ::testing::Test { |
| 47 public: | 47 public: |
| 48 QuicCryptoStreamTest() | 48 QuicCryptoStreamTest() |
| 49 : addr_(IPAddressNumber(), 1), | 49 : connection_(new MockConnection(false)), |
| 50 connection_(new MockConnection(1, addr_, false)), | |
| 51 session_(connection_, true), | 50 session_(connection_, true), |
| 52 stream_(&session_) { | 51 stream_(&session_) { |
| 53 message_.set_tag(kSHLO); | 52 message_.set_tag(kSHLO); |
| 54 message_.SetStringPiece(1, "abc"); | 53 message_.SetStringPiece(1, "abc"); |
| 55 message_.SetStringPiece(2, "def"); | 54 message_.SetStringPiece(2, "def"); |
| 56 ConstructHandshakeMessage(); | 55 ConstructHandshakeMessage(); |
| 57 } | 56 } |
| 58 | 57 |
| 59 void ConstructHandshakeMessage() { | 58 void ConstructHandshakeMessage() { |
| 60 CryptoFramer framer; | 59 CryptoFramer framer; |
| 61 message_data_.reset(framer.ConstructHandshakeMessage(message_)); | 60 message_data_.reset(framer.ConstructHandshakeMessage(message_)); |
| 62 } | 61 } |
| 63 | 62 |
| 64 protected: | 63 protected: |
| 65 IPEndPoint addr_; | |
| 66 MockConnection* connection_; | 64 MockConnection* connection_; |
| 67 MockSession session_; | 65 MockSession session_; |
| 68 MockQuicCryptoStream stream_; | 66 MockQuicCryptoStream stream_; |
| 69 CryptoHandshakeMessage message_; | 67 CryptoHandshakeMessage message_; |
| 70 scoped_ptr<QuicData> message_data_; | 68 scoped_ptr<QuicData> message_data_; |
| 71 | 69 |
| 72 private: | 70 private: |
| 73 DISALLOW_COPY_AND_ASSIGN(QuicCryptoStreamTest); | 71 DISALLOW_COPY_AND_ASSIGN(QuicCryptoStreamTest); |
| 74 }; | 72 }; |
| 75 | 73 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 99 bad[kFirstTagIndex] = 0x7F; // out of order tag | 97 bad[kFirstTagIndex] = 0x7F; // out of order tag |
| 100 | 98 |
| 101 EXPECT_CALL(*connection_, | 99 EXPECT_CALL(*connection_, |
| 102 SendConnectionClose(QUIC_CRYPTO_TAGS_OUT_OF_ORDER)); | 100 SendConnectionClose(QUIC_CRYPTO_TAGS_OUT_OF_ORDER)); |
| 103 EXPECT_EQ(0u, stream_.ProcessRawData(bad.data(), bad.length())); | 101 EXPECT_EQ(0u, stream_.ProcessRawData(bad.data(), bad.length())); |
| 104 } | 102 } |
| 105 | 103 |
| 106 } // namespace | 104 } // namespace |
| 107 } // namespace test | 105 } // namespace test |
| 108 } // namespace net | 106 } // namespace net |
| OLD | NEW |