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

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

Issue 2306173003: Add a new QuicFlagSaver class for saving/restoring the values of QUIC flags in tests. (Closed)
Patch Set: Better Created 4 years, 3 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
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_protocol.h" 5 #include "net/quic/core/quic_protocol.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "net/quic/core/quic_flags.h" 10 #include "net/quic/core/quic_flags.h"
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 278
279 TEST(QuicProtocolTest, PathCloseFrameToString) { 279 TEST(QuicProtocolTest, PathCloseFrameToString) {
280 QuicPathCloseFrame frame; 280 QuicPathCloseFrame frame;
281 frame.path_id = 1; 281 frame.path_id = 1;
282 std::ostringstream stream; 282 std::ostringstream stream;
283 stream << frame; 283 stream << frame;
284 EXPECT_EQ("{ path_id: 1 }\n", stream.str()); 284 EXPECT_EQ("{ path_id: 1 }\n", stream.str());
285 } 285 }
286 286
287 TEST(QuicProtocolTest, FilterSupportedVersions) { 287 TEST(QuicProtocolTest, FilterSupportedVersions) {
288 ValueRestore<bool> old_v35_flag(&FLAGS_quic_enable_version_35, 288 QuicFlagSaver flags;
289 FLAGS_quic_enable_version_35);
290 ValueRestore<bool> old_v36_flag(&FLAGS_quic_enable_version_36,
291 FLAGS_quic_enable_version_36);
292 ValueRestore<bool> old_v36_2_flag(&FLAGS_quic_enable_version_36_v2,
293 FLAGS_quic_enable_version_36_v2);
294 QuicVersionVector all_versions = { 289 QuicVersionVector all_versions = {
295 QUIC_VERSION_30, QUIC_VERSION_31, QUIC_VERSION_32, QUIC_VERSION_33, 290 QUIC_VERSION_30, QUIC_VERSION_31, QUIC_VERSION_32, QUIC_VERSION_33,
296 QUIC_VERSION_34, QUIC_VERSION_35, QUIC_VERSION_36}; 291 QUIC_VERSION_34, QUIC_VERSION_35, QUIC_VERSION_36};
297 292
298 FLAGS_quic_disable_pre_32 = true; 293 FLAGS_quic_disable_pre_32 = true;
299 FLAGS_quic_enable_version_35 = false; 294 FLAGS_quic_enable_version_35 = false;
300 FLAGS_quic_enable_version_36_v2 = false; 295 FLAGS_quic_enable_version_36_v2 = false;
301 296
302 QuicVersionVector filtered_versions = FilterSupportedVersions(all_versions); 297 QuicVersionVector filtered_versions = FilterSupportedVersions(all_versions);
303 ASSERT_EQ(3u, filtered_versions.size()); 298 ASSERT_EQ(3u, filtered_versions.size());
304 EXPECT_EQ(QUIC_VERSION_32, filtered_versions[0]); 299 EXPECT_EQ(QUIC_VERSION_32, filtered_versions[0]);
305 EXPECT_EQ(QUIC_VERSION_33, filtered_versions[1]); 300 EXPECT_EQ(QUIC_VERSION_33, filtered_versions[1]);
306 EXPECT_EQ(QUIC_VERSION_34, filtered_versions[2]); 301 EXPECT_EQ(QUIC_VERSION_34, filtered_versions[2]);
307 } 302 }
308 303
309 TEST(QuicProtocolTest, QuicVersionManager) { 304 TEST(QuicProtocolTest, QuicVersionManager) {
310 ValueRestore<bool> old_v35_flag(&FLAGS_quic_enable_version_35, 305 QuicFlagSaver flags;
311 FLAGS_quic_enable_version_35);
312 ValueRestore<bool> old_v36_2_flag(&FLAGS_quic_enable_version_36_v2,
313 FLAGS_quic_enable_version_36_v2);
314 FLAGS_quic_enable_version_35 = false; 306 FLAGS_quic_enable_version_35 = false;
315 FLAGS_quic_enable_version_36_v2 = false; 307 FLAGS_quic_enable_version_36_v2 = false;
316 QuicVersionManager manager(AllSupportedVersions()); 308 QuicVersionManager manager(AllSupportedVersions());
317 EXPECT_EQ(FilterSupportedVersions(AllSupportedVersions()), 309 EXPECT_EQ(FilterSupportedVersions(AllSupportedVersions()),
318 manager.GetSupportedVersions()); 310 manager.GetSupportedVersions());
319 FLAGS_quic_enable_version_35 = true; 311 FLAGS_quic_enable_version_35 = true;
320 FLAGS_quic_enable_version_36_v2 = true; 312 FLAGS_quic_enable_version_36_v2 = true;
321 EXPECT_EQ(FilterSupportedVersions(AllSupportedVersions()), 313 EXPECT_EQ(FilterSupportedVersions(AllSupportedVersions()),
322 manager.GetSupportedVersions()); 314 manager.GetSupportedVersions());
323 EXPECT_EQ(QUIC_VERSION_36, manager.GetSupportedVersions()[0]); 315 EXPECT_EQ(QUIC_VERSION_36, manager.GetSupportedVersions()[0]);
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 EXPECT_EQ(2u, queue.NumIntervals()); 461 EXPECT_EQ(2u, queue.NumIntervals());
470 EXPECT_TRUE(queue.Contains(10)); 462 EXPECT_TRUE(queue.Contains(10));
471 EXPECT_TRUE(queue.Contains(11)); 463 EXPECT_TRUE(queue.Contains(11));
472 EXPECT_TRUE(queue.Contains(20)); 464 EXPECT_TRUE(queue.Contains(20));
473 EXPECT_TRUE(queue.Contains(21)); 465 EXPECT_TRUE(queue.Contains(21));
474 } 466 }
475 467
476 } // namespace 468 } // namespace
477 } // namespace test 469 } // namespace test
478 } // namespace net 470 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_packet_generator_test.cc ('k') | net/quic/core/quic_sent_packet_manager_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698