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_protocol.h" | 5 #include "net/quic/quic_protocol.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace net { | 10 namespace net { |
(...skipping 17 matching lines...) Expand all Loading... |
28 QuicTag tag = MakeQuicTag('A', 'B', 'C', 'D'); | 28 QuicTag tag = MakeQuicTag('A', 'B', 'C', 'D'); |
29 char bytes[4]; | 29 char bytes[4]; |
30 memcpy(bytes, &tag, 4); | 30 memcpy(bytes, &tag, 4); |
31 EXPECT_EQ('A', bytes[0]); | 31 EXPECT_EQ('A', bytes[0]); |
32 EXPECT_EQ('B', bytes[1]); | 32 EXPECT_EQ('B', bytes[1]); |
33 EXPECT_EQ('C', bytes[2]); | 33 EXPECT_EQ('C', bytes[2]); |
34 EXPECT_EQ('D', bytes[3]); | 34 EXPECT_EQ('D', bytes[3]); |
35 } | 35 } |
36 | 36 |
37 TEST(QuicProtocolTest, IsAawaitingPacket) { | 37 TEST(QuicProtocolTest, IsAawaitingPacket) { |
38 ReceivedPacketInfo received_info; | 38 QuicAckFrame ack_frame; |
39 received_info.largest_observed = 10u; | 39 ack_frame.largest_observed = 10u; |
40 EXPECT_TRUE(IsAwaitingPacket(received_info, 11u)); | 40 EXPECT_TRUE(IsAwaitingPacket(ack_frame, 11u)); |
41 EXPECT_FALSE(IsAwaitingPacket(received_info, 1u)); | 41 EXPECT_FALSE(IsAwaitingPacket(ack_frame, 1u)); |
42 | 42 |
43 received_info.missing_packets.insert(10); | 43 ack_frame.missing_packets.insert(10); |
44 EXPECT_TRUE(IsAwaitingPacket(received_info, 10u)); | 44 EXPECT_TRUE(IsAwaitingPacket(ack_frame, 10u)); |
45 } | 45 } |
46 | 46 |
47 TEST(QuicProtocolTest, InsertMissingPacketsBetween) { | 47 TEST(QuicProtocolTest, InsertMissingPacketsBetween) { |
48 ReceivedPacketInfo received_info; | 48 QuicAckFrame ack_frame; |
49 InsertMissingPacketsBetween(&received_info, 4u, 10u); | 49 InsertMissingPacketsBetween(&ack_frame, 4u, 10u); |
50 EXPECT_EQ(6u, received_info.missing_packets.size()); | 50 EXPECT_EQ(6u, ack_frame.missing_packets.size()); |
51 | 51 |
52 QuicPacketSequenceNumber i = 4; | 52 QuicPacketSequenceNumber i = 4; |
53 for (SequenceNumberSet::iterator it = received_info.missing_packets.begin(); | 53 for (SequenceNumberSet::iterator it = ack_frame.missing_packets.begin(); |
54 it != received_info.missing_packets.end(); ++it, ++i) { | 54 it != ack_frame.missing_packets.end(); ++it, ++i) { |
55 EXPECT_EQ(i, *it); | 55 EXPECT_EQ(i, *it); |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 TEST(QuicProtocolTest, QuicVersionToQuicTag) { | 59 TEST(QuicProtocolTest, QuicVersionToQuicTag) { |
60 // If you add a new version to the QuicVersion enum you will need to add a new | 60 // If you add a new version to the QuicVersion enum you will need to add a new |
61 // case to QuicVersionToQuicTag, otherwise this test will fail. | 61 // case to QuicVersionToQuicTag, otherwise this test will fail. |
62 | 62 |
63 // TODO(rtenneti): Enable checking of Log(ERROR) messages. | 63 // TODO(rtenneti): Enable checking of Log(ERROR) messages. |
64 #if 0 | 64 #if 0 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 // Make sure that all supported versions are present in QuicVersionToString. | 162 // Make sure that all supported versions are present in QuicVersionToString. |
163 for (size_t i = 0; i < arraysize(kSupportedQuicVersions); ++i) { | 163 for (size_t i = 0; i < arraysize(kSupportedQuicVersions); ++i) { |
164 QuicVersion version = kSupportedQuicVersions[i]; | 164 QuicVersion version = kSupportedQuicVersions[i]; |
165 EXPECT_NE("QUIC_VERSION_UNSUPPORTED", QuicVersionToString(version)); | 165 EXPECT_NE("QUIC_VERSION_UNSUPPORTED", QuicVersionToString(version)); |
166 } | 166 } |
167 } | 167 } |
168 | 168 |
169 } // namespace | 169 } // namespace |
170 } // namespace test | 170 } // namespace test |
171 } // namespace net | 171 } // namespace net |
OLD | NEW |