| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 private: | 72 private: |
| 73 DISALLOW_COPY_AND_ASSIGN(QuicCryptoStreamTest); | 73 DISALLOW_COPY_AND_ASSIGN(QuicCryptoStreamTest); |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 TEST_F(QuicCryptoStreamTest, NotInitiallyConected) { | 76 TEST_F(QuicCryptoStreamTest, NotInitiallyConected) { |
| 77 EXPECT_FALSE(stream_.encryption_established()); | 77 EXPECT_FALSE(stream_.encryption_established()); |
| 78 EXPECT_FALSE(stream_.handshake_confirmed()); | 78 EXPECT_FALSE(stream_.handshake_confirmed()); |
| 79 } | 79 } |
| 80 | 80 |
| 81 TEST_F(QuicCryptoStreamTest, ProcessData) { | 81 TEST_F(QuicCryptoStreamTest, ProcessRawData) { |
| 82 EXPECT_EQ(message_data_->length(), | 82 EXPECT_EQ(message_data_->length(), |
| 83 stream_.ProcessData(message_data_->data(), | 83 stream_.ProcessRawData(message_data_->data(), |
| 84 message_data_->length())); | 84 message_data_->length())); |
| 85 ASSERT_EQ(1u, stream_.messages()->size()); | 85 ASSERT_EQ(1u, stream_.messages()->size()); |
| 86 const CryptoHandshakeMessage& message = (*stream_.messages())[0]; | 86 const CryptoHandshakeMessage& message = (*stream_.messages())[0]; |
| 87 EXPECT_EQ(kSHLO, message.tag()); | 87 EXPECT_EQ(kSHLO, message.tag()); |
| 88 EXPECT_EQ(2u, message.tag_value_map().size()); | 88 EXPECT_EQ(2u, message.tag_value_map().size()); |
| 89 EXPECT_EQ("abc", CryptoTestUtils::GetValueForTag(message, 1)); | 89 EXPECT_EQ("abc", CryptoTestUtils::GetValueForTag(message, 1)); |
| 90 EXPECT_EQ("def", CryptoTestUtils::GetValueForTag(message, 2)); | 90 EXPECT_EQ("def", CryptoTestUtils::GetValueForTag(message, 2)); |
| 91 } | 91 } |
| 92 | 92 |
| 93 TEST_F(QuicCryptoStreamTest, ProcessBadData) { | 93 TEST_F(QuicCryptoStreamTest, ProcessBadData) { |
| 94 string bad(message_data_->data(), message_data_->length()); | 94 string bad(message_data_->data(), message_data_->length()); |
| 95 const int kFirstTagIndex = sizeof(uint32) + // message tag | 95 const int kFirstTagIndex = sizeof(uint32) + // message tag |
| 96 sizeof(uint16) + // number of tag-value pairs | 96 sizeof(uint16) + // number of tag-value pairs |
| 97 sizeof(uint16); // padding | 97 sizeof(uint16); // padding |
| 98 EXPECT_EQ(1, bad[kFirstTagIndex]); | 98 EXPECT_EQ(1, bad[kFirstTagIndex]); |
| 99 bad[kFirstTagIndex] = 0x7F; // out of order tag | 99 bad[kFirstTagIndex] = 0x7F; // out of order tag |
| 100 | 100 |
| 101 EXPECT_CALL(*connection_, | 101 EXPECT_CALL(*connection_, |
| 102 SendConnectionClose(QUIC_CRYPTO_TAGS_OUT_OF_ORDER)); | 102 SendConnectionClose(QUIC_CRYPTO_TAGS_OUT_OF_ORDER)); |
| 103 EXPECT_EQ(0u, stream_.ProcessData(bad.data(), bad.length())); | 103 EXPECT_EQ(0u, stream_.ProcessRawData(bad.data(), bad.length())); |
| 104 } | 104 } |
| 105 | 105 |
| 106 } // namespace | 106 } // namespace |
| 107 } // namespace test | 107 } // namespace test |
| 108 } // namespace net | 108 } // namespace net |
| OLD | NEW |