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_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/quic_decrypter.h" | 8 #include "net/quic/crypto/quic_decrypter.h" |
9 #include "net/quic/crypto/quic_encrypter.h" | 9 #include "net/quic/crypto/quic_encrypter.h" |
10 #include "net/quic/test_tools/crypto_test_utils.h" | 10 #include "net/quic/test_tools/crypto_test_utils.h" |
11 #include "net/quic/test_tools/quic_test_utils.h" | 11 #include "net/quic/test_tools/quic_test_utils.h" |
12 #include "net/quic/test_tools/simple_quic_framer.h" | 12 #include "net/quic/test_tools/simple_quic_framer.h" |
13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 namespace net { | 16 namespace net { |
17 namespace test { | 17 namespace test { |
18 namespace { | 18 namespace { |
19 | 19 |
20 const char kServerHostname[] = "localhost"; | 20 const char kServerHostname[] = "localhost"; |
21 | 21 |
22 class TestQuicVisitor : public NoOpFramerVisitor { | 22 class TestQuicVisitor : public NoOpFramerVisitor { |
23 public: | 23 public: |
24 TestQuicVisitor() | 24 TestQuicVisitor() |
25 : frame_valid_(false) { | 25 : frame_valid_(false) { |
26 } | 26 } |
27 | 27 |
28 // NoOpFramerVisitor | 28 // NoOpFramerVisitor |
29 virtual void OnStreamFrame(const QuicStreamFrame& frame) { | 29 virtual void OnStreamFrame(const QuicStreamFrame& frame) OVERRIDE { |
30 frame_ = frame; | 30 frame_ = frame; |
31 frame_valid_ = true; | 31 frame_valid_ = true; |
32 } | 32 } |
33 | 33 |
34 bool frame_valid() const { | 34 bool frame_valid() const { |
35 return frame_valid_; | 35 return frame_valid_; |
36 } | 36 } |
37 QuicStreamFrame* frame() { return &frame_; } | 37 QuicStreamFrame* frame() { return &frame_; } |
38 | 38 |
39 private: | 39 private: |
40 QuicStreamFrame frame_; | 40 QuicStreamFrame frame_; |
41 bool frame_valid_; | 41 bool frame_valid_; |
42 | 42 |
43 DISALLOW_COPY_AND_ASSIGN(TestQuicVisitor); | 43 DISALLOW_COPY_AND_ASSIGN(TestQuicVisitor); |
44 }; | 44 }; |
45 | 45 |
46 // The same as MockSession, except that WriteData() is not mocked. | 46 // The same as MockSession, except that WriteData() is not mocked. |
47 class TestMockSession : public MockSession { | 47 class TestMockSession : public MockSession { |
48 public: | 48 public: |
49 TestMockSession(QuicConnection* connection, bool is_server) | 49 TestMockSession(QuicConnection* connection, bool is_server) |
50 : MockSession(connection, is_server) { | 50 : MockSession(connection, is_server) { |
51 } | 51 } |
52 virtual ~TestMockSession() {} | 52 virtual ~TestMockSession() {} |
53 | 53 |
54 virtual QuicConsumedData WriteData(QuicStreamId id, base::StringPiece data, | 54 virtual QuicConsumedData WriteData(QuicStreamId id, |
55 QuicStreamOffset offset, bool fin) { | 55 base::StringPiece data, |
| 56 QuicStreamOffset offset, |
| 57 bool fin) OVERRIDE { |
56 return QuicSession::WriteData(id, data, offset, fin); | 58 return QuicSession::WriteData(id, data, offset, fin); |
57 } | 59 } |
58 }; | 60 }; |
59 | 61 |
60 class QuicCryptoClientStreamTest : public ::testing::Test { | 62 class QuicCryptoClientStreamTest : public ::testing::Test { |
61 public: | 63 public: |
62 QuicCryptoClientStreamTest() | 64 QuicCryptoClientStreamTest() |
63 : addr_(), | 65 : addr_(), |
64 connection_(new PacketSavingConnection(1, addr_, true)), | 66 connection_(new PacketSavingConnection(1, addr_, true)), |
65 session_(connection_, true), | 67 session_(connection_, true), |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 stream_.ProcessData(message_data_->data(), message_data_->length()); | 174 stream_.ProcessData(message_data_->data(), message_data_->length()); |
173 } | 175 } |
174 | 176 |
175 TEST_F(QuicCryptoClientStreamTest, CryptoConnect) { | 177 TEST_F(QuicCryptoClientStreamTest, CryptoConnect) { |
176 EXPECT_TRUE(stream_.CryptoConnect()); | 178 EXPECT_TRUE(stream_.CryptoConnect()); |
177 } | 179 } |
178 | 180 |
179 } // namespace | 181 } // namespace |
180 } // namespace test | 182 } // namespace test |
181 } // namespace net | 183 } // namespace net |
OLD | NEW |