Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: net/quic/quic_protocol_test.cc

Issue 20227003: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Land Recent QUIC changes Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_protocol.cc ('k') | net/quic/quic_received_entropy_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 25 matching lines...) Expand all
36 InsertMissingPacketsBetween(&received_info, 4u, 10u); 36 InsertMissingPacketsBetween(&received_info, 4u, 10u);
37 EXPECT_EQ(6u, received_info.missing_packets.size()); 37 EXPECT_EQ(6u, received_info.missing_packets.size());
38 38
39 QuicPacketSequenceNumber i = 4; 39 QuicPacketSequenceNumber i = 4;
40 for (SequenceNumberSet::iterator it = received_info.missing_packets.begin(); 40 for (SequenceNumberSet::iterator it = received_info.missing_packets.begin();
41 it != received_info.missing_packets.end(); ++it, ++i) { 41 it != received_info.missing_packets.end(); ++it, ++i) {
42 EXPECT_EQ(i, *it); 42 EXPECT_EQ(i, *it);
43 } 43 }
44 } 44 }
45 45
46 TEST(QuicProtocolTest, QuicVersionToQuicTag) {
47 // If you add a new version to the QuicVersion enum you will need to add a new
48 // case to QuicVersionToQuicTag, otherwise this test will fail.
49
50 // TODO(rtenneti): Enable checking of Log(ERROR) messages.
51 #if 0
52 // Any logs would indicate an unsupported version which we don't expect.
53 ScopedMockLog log(kDoNotCaptureLogsYet);
54 EXPECT_CALL(log, Log(_, _, _)).Times(0);
55 log.StartCapturingLogs();
56 #endif
57
58 // Explicitly test a specific version.
59 EXPECT_EQ(MakeQuicTag('Q', '0', '0', '6'),
60 QuicVersionToQuicTag(QUIC_VERSION_6));
61
62 // Loop over all supported versions and make sure that we never hit the
63 // default case (i.e. all supported versions should be successfully converted
64 // to valid QuicTags).
65 for (size_t i = 0; i < arraysize(kSupportedQuicVersions); ++i) {
66 const QuicVersion& version = kSupportedQuicVersions[i];
67 EXPECT_LT(0u, QuicVersionToQuicTag(version));
68 }
69 }
70
71 TEST(QuicProtocolTest, QuicVersionToQuicTagUnsupported) {
72 // TODO(rtenneti): Enable checking of Log(ERROR) messages.
73 #if 0
74 // TODO(rjshade): Change to DFATAL once we actually support multiple versions,
75 // and QuicConnectionTest::SendVersionNegotiationPacket can be changed to use
76 // mis-matched versions rather than relying on QUIC_VERSION_UNSUPPORTED.
77 ScopedMockLog log(kDoNotCaptureLogsYet);
78 EXPECT_CALL(log, Log(ERROR, _, "Unsupported QuicVersion: 0")).Times(1);
79 log.StartCapturingLogs();
80 #endif
81
82 EXPECT_EQ(0u, QuicVersionToQuicTag(QUIC_VERSION_UNSUPPORTED));
83 }
84
85 TEST(QuicProtocolTest, QuicTagToQuicVersion) {
86 // If you add a new version to the QuicVersion enum you will need to add a new
87 // case to QuicTagToQuicVersion, otherwise this test will fail.
88
89 // TODO(rtenneti): Enable checking of Log(ERROR) messages.
90 #if 0
91 // Any logs would indicate an unsupported version which we don't expect.
92 ScopedMockLog log(kDoNotCaptureLogsYet);
93 EXPECT_CALL(log, Log(_, _, _)).Times(0);
94 log.StartCapturingLogs();
95 #endif
96
97 // Explicitly test specific versions.
98 EXPECT_EQ(QUIC_VERSION_6,
99 QuicTagToQuicVersion(MakeQuicTag('Q', '0', '0', '6')));
100
101 for (size_t i = 0; i < arraysize(kSupportedQuicVersions); ++i) {
102 const QuicVersion& version = kSupportedQuicVersions[i];
103
104 // Get the tag from the version (we can loop over QuicVersions easily).
105 QuicTag tag = QuicVersionToQuicTag(version);
106 EXPECT_LT(0u, tag);
107
108 // Now try converting back.
109 QuicVersion tag_to_quic_version = QuicTagToQuicVersion(tag);
110 EXPECT_EQ(version, tag_to_quic_version);
111 EXPECT_NE(QUIC_VERSION_UNSUPPORTED, tag_to_quic_version);
112 }
113 }
114
115 TEST(QuicProtocolTest, QuicTagToQuicVersionUnsupported) {
116 // TODO(rtenneti): Enable checking of Log(ERROR) messages.
117 #if 0
118 ScopedMockLog log(kDoNotCaptureLogsYet);
119 #ifndef NDEBUG
120 EXPECT_CALL(log, Log(INFO, _, "Unsupported QuicTag version: FAKE")).Times(1);
121 #endif
122 log.StartCapturingLogs();
123 #endif
124
125 EXPECT_EQ(QUIC_VERSION_UNSUPPORTED,
126 QuicTagToQuicVersion(MakeQuicTag('F', 'A', 'K', 'E')));
127 }
128
129 TEST(QuicProtocolTest, QuicVersionToString) {
130 EXPECT_EQ("QUIC_VERSION_6",
131 QuicVersionToString(QUIC_VERSION_6));
132 EXPECT_EQ("QUIC_VERSION_UNSUPPORTED",
133 QuicVersionToString(QUIC_VERSION_UNSUPPORTED));
134
135 QuicVersion single_version[] = {QUIC_VERSION_6};
136 EXPECT_EQ("QUIC_VERSION_6,", QuicVersionArrayToString(single_version,
137 arraysize(single_version)));
138 // QuicVersion multiple_versions[] = {QUIC_VERSION_7, QUIC_VERSION_6};
139 // EXPECT_EQ("QUIC_VERSION_7,QUIC_VERSION_6,",
140 // QuicVersionArrayToString(multiple_versions,
141 // arraysize(multiple_versions)));
142 }
143
46 } // namespace 144 } // namespace
47 } // namespace test 145 } // namespace test
48 } // namespace net 146 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_protocol.cc ('k') | net/quic/quic_received_entropy_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698