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 // Common utilities for Quic tests |
| 6 |
5 #ifndef NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 7 #ifndef NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
6 #define NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 8 #define NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
7 | 9 |
8 #include <string> | 10 #include <string> |
9 | 11 |
10 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
11 #include "net/quic/quic_connection.h" | 13 #include "net/quic/quic_connection.h" |
12 #include "net/quic/quic_packet_writer.h" | 14 #include "net/quic/quic_packet_writer.h" |
13 #include "net/quic/quic_session.h" | 15 #include "net/quic/quic_session.h" |
14 #include "net/quic/quic_spdy_decompressor.h" | 16 #include "net/quic/quic_spdy_decompressor.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 53 |
52 // Uses a MockHelper, GUID of 42. | 54 // Uses a MockHelper, GUID of 42. |
53 MockConnection(IPEndPoint address, bool is_server); | 55 MockConnection(IPEndPoint address, bool is_server); |
54 | 56 |
55 // Uses a MockHelper, and 127.0.0.1:123 | 57 // Uses a MockHelper, and 127.0.0.1:123 |
56 MockConnection(QuicGuid guid, bool is_server); | 58 MockConnection(QuicGuid guid, bool is_server); |
57 | 59 |
58 // Uses a Mock helper, GUID of 42, and 127.0.0.1:123. | 60 // Uses a Mock helper, GUID of 42, and 127.0.0.1:123. |
59 MockConnection(bool is_server, const QuicVersionVector& supported_versions); | 61 MockConnection(bool is_server, const QuicVersionVector& supported_versions); |
60 | 62 |
61 virtual ~MockConnection(); | 63 virtual ~MockConnection() OVERRIDE; |
62 | 64 |
63 // If the constructor that uses a MockHelper has been used then this method | 65 // If the constructor that uses a MockHelper has been used then this method |
64 // will advance the time of the MockClock. | 66 // will advance the time of the MockClock. |
65 void AdvanceTime(QuicTime::Delta delta); | 67 void AdvanceTime(QuicTime::Delta delta); |
66 | 68 |
67 MOCK_METHOD3(ProcessUdpPacket, void(const IPEndPoint& self_address, | 69 MOCK_METHOD3(ProcessUdpPacket, void(const IPEndPoint& self_address, |
68 const IPEndPoint& peer_address, | 70 const IPEndPoint& peer_address, |
69 const QuicEncryptedPacket& packet)); | 71 const QuicEncryptedPacket& packet)); |
70 MOCK_METHOD1(SendConnectionClose, void(QuicErrorCode error)); | 72 MOCK_METHOD1(SendConnectionClose, void(QuicErrorCode error)); |
71 MOCK_METHOD2(SendConnectionCloseWithDetails, void( | 73 MOCK_METHOD2(SendConnectionCloseWithDetails, void( |
(...skipping 17 matching lines...) Expand all Loading... |
89 private: | 91 private: |
90 scoped_ptr<QuicPacketWriter> writer_; | 92 scoped_ptr<QuicPacketWriter> writer_; |
91 scoped_ptr<QuicConnectionHelperInterface> helper_; | 93 scoped_ptr<QuicConnectionHelperInterface> helper_; |
92 | 94 |
93 DISALLOW_COPY_AND_ASSIGN(MockConnection); | 95 DISALLOW_COPY_AND_ASSIGN(MockConnection); |
94 }; | 96 }; |
95 | 97 |
96 class TestSession : public QuicSession { | 98 class TestSession : public QuicSession { |
97 public: | 99 public: |
98 TestSession(QuicConnection* connection, const QuicConfig& config); | 100 TestSession(QuicConnection* connection, const QuicConfig& config); |
99 virtual ~TestSession(); | 101 virtual ~TestSession() OVERRIDE; |
100 | 102 |
101 MOCK_METHOD1(CreateIncomingDataStream, QuicDataStream*(QuicStreamId id)); | 103 MOCK_METHOD1(CreateIncomingDataStream, QuicDataStream*(QuicStreamId id)); |
102 MOCK_METHOD0(CreateOutgoingDataStream, QuicDataStream*()); | 104 MOCK_METHOD0(CreateOutgoingDataStream, QuicDataStream*()); |
103 | 105 |
104 void SetCryptoStream(QuicCryptoStream* stream); | 106 void SetCryptoStream(QuicCryptoStream* stream); |
105 | 107 |
106 virtual QuicCryptoStream* GetCryptoStream(); | 108 virtual QuicCryptoStream* GetCryptoStream(); |
107 | 109 |
108 private: | 110 private: |
109 QuicCryptoStream* crypto_stream_; | 111 QuicCryptoStream* crypto_stream_; |
110 DISALLOW_COPY_AND_ASSIGN(TestSession); | 112 DISALLOW_COPY_AND_ASSIGN(TestSession); |
111 }; | 113 }; |
112 | 114 |
113 class MockPacketWriter : public QuicPacketWriter { | 115 class MockPacketWriter : public QuicPacketWriter { |
114 public: | 116 public: |
115 MockPacketWriter(); | 117 MockPacketWriter(); |
116 virtual ~MockPacketWriter(); | 118 virtual ~MockPacketWriter() OVERRIDE; |
117 | 119 |
118 MOCK_METHOD5(WritePacket, | 120 MOCK_METHOD5(WritePacket, |
119 WriteResult(const char* buffer, | 121 WriteResult(const char* buffer, |
120 size_t buf_len, | 122 size_t buf_len, |
121 const IPAddressNumber& self_address, | 123 const IPAddressNumber& self_address, |
122 const IPEndPoint& peer_address, | 124 const IPEndPoint& peer_address, |
123 QuicBlockedWriterInterface* blocked_writer)); | 125 QuicBlockedWriterInterface* blocked_writer)); |
124 MOCK_CONST_METHOD0(IsWriteBlockedDataBuffered, bool()); | 126 MOCK_CONST_METHOD0(IsWriteBlockedDataBuffered, bool()); |
125 }; | 127 }; |
126 | 128 |
127 class MockQuicSessionOwner : public QuicSessionOwner { | 129 class MockQuicSessionOwner : public QuicSessionOwner { |
128 public: | 130 public: |
129 MockQuicSessionOwner(); | 131 MockQuicSessionOwner(); |
130 ~MockQuicSessionOwner(); | 132 virtual ~MockQuicSessionOwner() OVERRIDE; |
131 MOCK_METHOD2(OnConnectionClosed, void(QuicGuid guid, QuicErrorCode error)); | 133 MOCK_METHOD2(OnConnectionClosed, void(QuicGuid guid, QuicErrorCode error)); |
132 }; | 134 }; |
133 | 135 |
134 class TestDecompressorVisitor : public QuicSpdyDecompressor::Visitor { | 136 class TestDecompressorVisitor : public QuicSpdyDecompressor::Visitor { |
135 public: | 137 public: |
136 virtual ~TestDecompressorVisitor() {} | 138 virtual ~TestDecompressorVisitor() OVERRIDE {} |
137 virtual bool OnDecompressedData(base::StringPiece data) OVERRIDE; | 139 virtual bool OnDecompressedData(base::StringPiece data) OVERRIDE; |
138 virtual void OnDecompressionError() OVERRIDE; | 140 virtual void OnDecompressionError() OVERRIDE; |
139 | 141 |
140 std::string data() { return data_; } | 142 std::string data() { return data_; } |
141 bool error() { return error_; } | 143 bool error() { return error_; } |
142 | 144 |
143 private: | 145 private: |
144 std::string data_; | 146 std::string data_; |
145 bool error_; | 147 bool error_; |
146 }; | 148 }; |
147 | 149 |
148 class MockAckNotifierDelegate : public QuicAckNotifier::DelegateInterface { | 150 class MockAckNotifierDelegate : public QuicAckNotifier::DelegateInterface { |
149 public: | 151 public: |
150 MockAckNotifierDelegate(); | 152 MockAckNotifierDelegate(); |
151 virtual ~MockAckNotifierDelegate(); | 153 virtual ~MockAckNotifierDelegate() OVERRIDE; |
152 | 154 |
153 MOCK_METHOD0(OnAckNotification, void()); | 155 MOCK_METHOD0(OnAckNotification, void()); |
154 }; | 156 }; |
155 | 157 |
156 } // namespace test | 158 } // namespace test |
157 } // namespace tools | 159 } // namespace tools |
158 } // namespace net | 160 } // namespace net |
159 | 161 |
160 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 162 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
OLD | NEW |