| 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 | 5 // Common utilities for Quic tests |
| 6 | 6 |
| 7 #ifndef NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 7 #ifndef NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
| 8 #define NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 8 #define NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "net/quic/congestion_control/send_algorithm_interface.h" | 12 #include "net/quic/congestion_control/send_algorithm_interface.h" |
| 13 #include "net/quic/quic_connection.h" | 13 #include "net/quic/quic_connection.h" |
| 14 #include "net/quic/quic_framer.h" | 14 #include "net/quic/quic_framer.h" |
| 15 #include "net/quic/quic_session.h" | 15 #include "net/quic/quic_session.h" |
| 16 #include "net/quic/quic_spdy_decompressor.h" |
| 16 #include "net/quic/test_tools/mock_clock.h" | 17 #include "net/quic/test_tools/mock_clock.h" |
| 17 #include "net/quic/test_tools/mock_random.h" | 18 #include "net/quic/test_tools/mock_random.h" |
| 19 #include "net/spdy/spdy_framer.h" |
| 18 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
| 19 | 21 |
| 20 namespace net { | 22 namespace net { |
| 21 | 23 |
| 22 namespace test { | 24 namespace test { |
| 23 | 25 |
| 24 void CompareCharArraysWithHexError(const std::string& description, | 26 void CompareCharArraysWithHexError(const std::string& description, |
| 25 const char* actual, | 27 const char* actual, |
| 26 const int actual_len, | 28 const int actual_len, |
| 27 const char* expected, | 29 const char* expected, |
| 28 const int expected_len); | 30 const int expected_len); |
| 29 | 31 |
| 30 void CompareQuicDataWithHexError(const std::string& description, | 32 void CompareQuicDataWithHexError(const std::string& description, |
| 31 QuicData* actual, | 33 QuicData* actual, |
| 32 QuicData* expected); | 34 QuicData* expected); |
| 33 | 35 |
| 34 // Returns the length of the QuicPacket that will be created if it contains | 36 // Returns the length of the QuicPacket that will be created if it contains |
| 35 // a stream frame that has |payload| bytes. | 37 // a stream frame that has |payload| bytes. |
| 36 size_t GetPacketLengthForOneStream(bool include_version, size_t payload); | 38 size_t GetPacketLengthForOneStream(bool include_version, size_t payload); |
| 37 | 39 |
| 40 string SerializeUncompressedHeaders(const SpdyHeaderBlock& headers); |
| 41 |
| 38 class MockFramerVisitor : public QuicFramerVisitorInterface { | 42 class MockFramerVisitor : public QuicFramerVisitorInterface { |
| 39 public: | 43 public: |
| 40 MockFramerVisitor(); | 44 MockFramerVisitor(); |
| 41 ~MockFramerVisitor(); | 45 ~MockFramerVisitor(); |
| 42 | 46 |
| 43 MOCK_METHOD1(OnError, void(QuicFramer* framer)); | 47 MOCK_METHOD1(OnError, void(QuicFramer* framer)); |
| 44 // The constructor sets this up to return false by default. | 48 // The constructor sets this up to return false by default. |
| 45 MOCK_METHOD1(OnProtocolVersionMismatch, bool(QuicVersionTag version)); | 49 MOCK_METHOD1(OnProtocolVersionMismatch, bool(QuicVersionTag version)); |
| 46 MOCK_METHOD0(OnPacket, void()); | 50 MOCK_METHOD0(OnPacket, void()); |
| 47 MOCK_METHOD1(OnPublicResetPacket, void(const QuicPublicResetPacket& header)); | 51 MOCK_METHOD1(OnPublicResetPacket, void(const QuicPublicResetPacket& header)); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 class TestEntropyCalculator : | 319 class TestEntropyCalculator : |
| 316 public QuicReceivedEntropyHashCalculatorInterface { | 320 public QuicReceivedEntropyHashCalculatorInterface { |
| 317 public: | 321 public: |
| 318 TestEntropyCalculator() { } | 322 TestEntropyCalculator() { } |
| 319 virtual ~TestEntropyCalculator() { } | 323 virtual ~TestEntropyCalculator() { } |
| 320 | 324 |
| 321 virtual QuicPacketEntropyHash ReceivedEntropyHash( | 325 virtual QuicPacketEntropyHash ReceivedEntropyHash( |
| 322 QuicPacketSequenceNumber sequence_number) const OVERRIDE; | 326 QuicPacketSequenceNumber sequence_number) const OVERRIDE; |
| 323 }; | 327 }; |
| 324 | 328 |
| 329 class TestDecompressorVisitor : public QuicSpdyDecompressor::Visitor { |
| 330 public: |
| 331 virtual ~TestDecompressorVisitor() {} |
| 332 virtual bool OnDecompressedData(base::StringPiece data) OVERRIDE; |
| 333 |
| 334 string data() { return data_; } |
| 335 |
| 336 private: |
| 337 string data_; |
| 338 }; |
| 339 |
| 325 } // namespace test | 340 } // namespace test |
| 326 | |
| 327 } // namespace net | 341 } // namespace net |
| 328 | 342 |
| 329 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 343 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
| OLD | NEW |