OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "net/quic/core/quic_frames.h" |
| 6 |
| 7 #include "testing/gmock/include/gmock/gmock.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 |
| 10 namespace net { |
| 11 namespace test { |
| 12 namespace { |
| 13 |
| 14 using testing::_; |
| 15 |
| 16 TEST(QuicProtocolTest, AckFrameToString) { |
| 17 QuicAckFrame frame; |
| 18 frame.largest_observed = 2; |
| 19 frame.ack_delay_time = QuicTime::Delta::FromMicroseconds(3); |
| 20 frame.packets.Add(4); |
| 21 frame.packets.Add(5); |
| 22 frame.received_packet_times = { |
| 23 {6, QuicTime::Zero() + QuicTime::Delta::FromMicroseconds(7)}}; |
| 24 std::ostringstream stream; |
| 25 stream << frame; |
| 26 EXPECT_EQ( |
| 27 "{ largest_observed: 2, ack_delay_time: 3, " |
| 28 "packets: [ 4 5 ], received_packets: [ 6 at 7 ] }\n", |
| 29 stream.str()); |
| 30 } |
| 31 |
| 32 TEST(QuicProtocolTest, PaddingFrameToString) { |
| 33 QuicPaddingFrame frame; |
| 34 frame.num_padding_bytes = 1; |
| 35 std::ostringstream stream; |
| 36 stream << frame; |
| 37 EXPECT_EQ("{ num_padding_bytes: 1 }\n", stream.str()); |
| 38 } |
| 39 |
| 40 TEST(QuicProtocolTest, RstStreamFrameToString) { |
| 41 QuicRstStreamFrame frame; |
| 42 frame.stream_id = 1; |
| 43 frame.error_code = QUIC_STREAM_CANCELLED; |
| 44 std::ostringstream stream; |
| 45 stream << frame; |
| 46 EXPECT_EQ("{ stream_id: 1, error_code: 6 }\n", stream.str()); |
| 47 } |
| 48 |
| 49 TEST(QuicProtocolTest, ConnectionCloseFrameToString) { |
| 50 QuicConnectionCloseFrame frame; |
| 51 frame.error_code = QUIC_NETWORK_IDLE_TIMEOUT; |
| 52 frame.error_details = "No recent network activity."; |
| 53 std::ostringstream stream; |
| 54 stream << frame; |
| 55 EXPECT_EQ( |
| 56 "{ error_code: 25, error_details: 'No recent network activity.' }\n", |
| 57 stream.str()); |
| 58 } |
| 59 |
| 60 TEST(QuicProtocolTest, GoAwayFrameToString) { |
| 61 QuicGoAwayFrame frame; |
| 62 frame.error_code = QUIC_NETWORK_IDLE_TIMEOUT; |
| 63 frame.last_good_stream_id = 2; |
| 64 frame.reason_phrase = "Reason"; |
| 65 std::ostringstream stream; |
| 66 stream << frame; |
| 67 EXPECT_EQ( |
| 68 "{ error_code: 25, last_good_stream_id: 2, reason_phrase: 'Reason' }\n", |
| 69 stream.str()); |
| 70 } |
| 71 |
| 72 TEST(QuicProtocolTest, WindowUpdateFrameToString) { |
| 73 QuicWindowUpdateFrame frame; |
| 74 std::ostringstream stream; |
| 75 frame.stream_id = 1; |
| 76 frame.byte_offset = 2; |
| 77 stream << frame; |
| 78 EXPECT_EQ("{ stream_id: 1, byte_offset: 2 }\n", stream.str()); |
| 79 } |
| 80 |
| 81 TEST(QuicProtocolTest, BlockedFrameToString) { |
| 82 QuicBlockedFrame frame; |
| 83 frame.stream_id = 1; |
| 84 std::ostringstream stream; |
| 85 stream << frame; |
| 86 EXPECT_EQ("{ stream_id: 1 }\n", stream.str()); |
| 87 } |
| 88 |
| 89 TEST(QuicProtocolTest, StreamFrameToString) { |
| 90 QuicStreamFrame frame; |
| 91 frame.stream_id = 1; |
| 92 frame.fin = false; |
| 93 frame.offset = 2; |
| 94 frame.data_length = 3; |
| 95 std::ostringstream stream; |
| 96 stream << frame; |
| 97 EXPECT_EQ("{ stream_id: 1, fin: 0, offset: 2, length: 3 }\n", stream.str()); |
| 98 } |
| 99 |
| 100 TEST(QuicProtocolTest, StopWaitingFrameToString) { |
| 101 QuicStopWaitingFrame frame; |
| 102 frame.least_unacked = 2; |
| 103 std::ostringstream stream; |
| 104 stream << frame; |
| 105 EXPECT_EQ("{ least_unacked: 2 }\n", stream.str()); |
| 106 } |
| 107 |
| 108 TEST(QuicProtocolTest, PathCloseFrameToString) { |
| 109 QuicPathCloseFrame frame; |
| 110 frame.path_id = 1; |
| 111 std::ostringstream stream; |
| 112 stream << frame; |
| 113 EXPECT_EQ("{ path_id: 1 }\n", stream.str()); |
| 114 } |
| 115 |
| 116 } // namespace |
| 117 } // namespace test |
| 118 } // namespace net |
OLD | NEW |