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

Side by Side Diff: net/quic/core/quic_versions_test.cc

Issue 2820423002: Move quic_flags.h from net/quic/core to net/quic/platform and split into api and impl. (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « net/quic/core/quic_versions.cc ('k') | net/quic/test_tools/quic_connection_peer.cc » ('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/core/quic_versions.h" 5 #include "net/quic/core/quic_versions.h"
6 6
7 #include "net/quic/core/quic_flags.h" 7 #include "net/quic/platform/api/quic_flags.h"
8 #include "net/quic/test_tools/quic_test_utils.h" 8 #include "net/quic/test_tools/quic_test_utils.h"
9 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 11
11 namespace net { 12 namespace net {
12 namespace test { 13 namespace test {
13 namespace { 14 namespace {
14 15
15 TEST(QuicVersionsTest, QuicVersionToQuicTag) { 16 TEST(QuicVersionsTest, QuicVersionToQuicTag) {
16 // If you add a new version to the QuicVersion enum you will need to add a new 17 // If you add a new version to the QuicVersion enum you will need to add a new
17 // case to QuicVersionToQuicTag, otherwise this test will fail. 18 // case to QuicVersionToQuicTag, otherwise this test will fail.
18 19
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 EXPECT_EQ(QUIC_VERSION_36, filtered_versions[1]); 140 EXPECT_EQ(QUIC_VERSION_36, filtered_versions[1]);
140 EXPECT_EQ(QUIC_VERSION_37, filtered_versions[2]); 141 EXPECT_EQ(QUIC_VERSION_37, filtered_versions[2]);
141 } 142 }
142 143
143 TEST(QuicVersionsTest, FilterSupportedVersionsNo39) { 144 TEST(QuicVersionsTest, FilterSupportedVersionsNo39) {
144 QuicVersionVector all_versions = {QUIC_VERSION_35, QUIC_VERSION_36, 145 QuicVersionVector all_versions = {QUIC_VERSION_35, QUIC_VERSION_36,
145 QUIC_VERSION_37, QUIC_VERSION_38, 146 QUIC_VERSION_37, QUIC_VERSION_38,
146 QUIC_VERSION_39}; 147 QUIC_VERSION_39};
147 148
148 FLAGS_quic_reloadable_flag_quic_enable_version_38 = true; 149 FLAGS_quic_reloadable_flag_quic_enable_version_38 = true;
149 base::SetFlag(&FLAGS_quic_enable_version_39, false); 150 SetQuicFlag(&FLAGS_quic_enable_version_39, false);
150 151
151 QuicVersionVector filtered_versions = FilterSupportedVersions(all_versions); 152 QuicVersionVector filtered_versions = FilterSupportedVersions(all_versions);
152 ASSERT_EQ(4u, filtered_versions.size()); 153 ASSERT_EQ(4u, filtered_versions.size());
153 EXPECT_EQ(QUIC_VERSION_35, filtered_versions[0]); 154 EXPECT_EQ(QUIC_VERSION_35, filtered_versions[0]);
154 EXPECT_EQ(QUIC_VERSION_36, filtered_versions[1]); 155 EXPECT_EQ(QUIC_VERSION_36, filtered_versions[1]);
155 EXPECT_EQ(QUIC_VERSION_37, filtered_versions[2]); 156 EXPECT_EQ(QUIC_VERSION_37, filtered_versions[2]);
156 EXPECT_EQ(QUIC_VERSION_38, filtered_versions[3]); 157 EXPECT_EQ(QUIC_VERSION_38, filtered_versions[3]);
157 } 158 }
158 159
159 TEST(QuicVersionsTest, FilterSupportedVersionsAllVersions) { 160 TEST(QuicVersionsTest, FilterSupportedVersionsAllVersions) {
160 QuicFlagSaver flags; 161 QuicFlagSaver flags;
161 QuicVersionVector all_versions = {QUIC_VERSION_35, QUIC_VERSION_36, 162 QuicVersionVector all_versions = {QUIC_VERSION_35, QUIC_VERSION_36,
162 QUIC_VERSION_37, QUIC_VERSION_38, 163 QUIC_VERSION_37, QUIC_VERSION_38,
163 QUIC_VERSION_39}; 164 QUIC_VERSION_39};
164 165
165 FLAGS_quic_reloadable_flag_quic_enable_version_38 = true; 166 FLAGS_quic_reloadable_flag_quic_enable_version_38 = true;
166 base::SetFlag(&FLAGS_quic_enable_version_39, true); 167 SetQuicFlag(&FLAGS_quic_enable_version_39, true);
167 168
168 QuicVersionVector filtered_versions = FilterSupportedVersions(all_versions); 169 QuicVersionVector filtered_versions = FilterSupportedVersions(all_versions);
169 ASSERT_EQ(all_versions, filtered_versions); 170 ASSERT_EQ(all_versions, filtered_versions);
170 } 171 }
171 172
172 TEST(QuicVersionsTest, LookUpVersionByIndex) { 173 TEST(QuicVersionsTest, LookUpVersionByIndex) {
173 QuicVersionVector all_versions = {QUIC_VERSION_35, QUIC_VERSION_36, 174 QuicVersionVector all_versions = {QUIC_VERSION_35, QUIC_VERSION_36,
174 QUIC_VERSION_37, QUIC_VERSION_38, 175 QUIC_VERSION_37, QUIC_VERSION_38,
175 QUIC_VERSION_39}; 176 QUIC_VERSION_39};
176 int version_count = all_versions.size(); 177 int version_count = all_versions.size();
177 for (int i = -5; i <= version_count + 1; ++i) { 178 for (int i = -5; i <= version_count + 1; ++i) {
178 if (i >= 0 && i < version_count) { 179 if (i >= 0 && i < version_count) {
179 EXPECT_EQ(all_versions[i], VersionOfIndex(all_versions, i)[0]); 180 EXPECT_EQ(all_versions[i], VersionOfIndex(all_versions, i)[0]);
180 } else { 181 } else {
181 EXPECT_EQ(QUIC_VERSION_UNSUPPORTED, VersionOfIndex(all_versions, i)[0]); 182 EXPECT_EQ(QUIC_VERSION_UNSUPPORTED, VersionOfIndex(all_versions, i)[0]);
182 } 183 }
183 } 184 }
184 } 185 }
185 186
186 } // namespace 187 } // namespace
187 } // namespace test 188 } // namespace test
188 } // namespace net 189 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_versions.cc ('k') | net/quic/test_tools/quic_connection_peer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698