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/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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 stream << frame; | 282 stream << frame; |
283 EXPECT_EQ("{ path_id: 1 }\n", stream.str()); | 283 EXPECT_EQ("{ path_id: 1 }\n", stream.str()); |
284 } | 284 } |
285 | 285 |
286 TEST(QuicProtocolTest, FilterSupportedVersions) { | 286 TEST(QuicProtocolTest, FilterSupportedVersions) { |
287 QuicVersionVector all_versions = { | 287 QuicVersionVector all_versions = { |
288 QUIC_VERSION_30, QUIC_VERSION_31, QUIC_VERSION_32, QUIC_VERSION_33, | 288 QUIC_VERSION_30, QUIC_VERSION_31, QUIC_VERSION_32, QUIC_VERSION_33, |
289 QUIC_VERSION_34, QUIC_VERSION_35, QUIC_VERSION_36}; | 289 QUIC_VERSION_34, QUIC_VERSION_35, QUIC_VERSION_36}; |
290 | 290 |
291 FLAGS_quic_enable_version_35 = false; | 291 FLAGS_quic_enable_version_35 = false; |
292 FLAGS_quic_enable_version_36 = false; | 292 FLAGS_quic_enable_version_36_v2 = false; |
293 | 293 |
294 QuicVersionVector filtered_versions = FilterSupportedVersions(all_versions); | 294 QuicVersionVector filtered_versions = FilterSupportedVersions(all_versions); |
295 ASSERT_EQ(5u, filtered_versions.size()); | 295 ASSERT_EQ(5u, filtered_versions.size()); |
296 EXPECT_EQ(QUIC_VERSION_30, filtered_versions[0]); | 296 EXPECT_EQ(QUIC_VERSION_30, filtered_versions[0]); |
297 EXPECT_EQ(QUIC_VERSION_31, filtered_versions[1]); | 297 EXPECT_EQ(QUIC_VERSION_31, filtered_versions[1]); |
298 EXPECT_EQ(QUIC_VERSION_32, filtered_versions[2]); | 298 EXPECT_EQ(QUIC_VERSION_32, filtered_versions[2]); |
299 EXPECT_EQ(QUIC_VERSION_33, filtered_versions[3]); | 299 EXPECT_EQ(QUIC_VERSION_33, filtered_versions[3]); |
300 EXPECT_EQ(QUIC_VERSION_34, filtered_versions[4]); | 300 EXPECT_EQ(QUIC_VERSION_34, filtered_versions[4]); |
301 } | 301 } |
302 | 302 |
303 TEST(QuicProtocolTest, QuicVersionManager) { | 303 TEST(QuicProtocolTest, QuicVersionManager) { |
304 FLAGS_quic_enable_version_35 = false; | 304 FLAGS_quic_enable_version_35 = false; |
305 FLAGS_quic_enable_version_36 = false; | 305 FLAGS_quic_enable_version_36_v2 = false; |
306 QuicVersionManager manager(QuicSupportedVersions()); | 306 QuicVersionManager manager(AllSupportedVersions()); |
307 EXPECT_EQ(FilterSupportedVersions(QuicSupportedVersions()), | 307 EXPECT_EQ(FilterSupportedVersions(AllSupportedVersions()), |
308 manager.GetSupportedVersions()); | 308 manager.GetSupportedVersions()); |
309 FLAGS_quic_enable_version_35 = true; | 309 FLAGS_quic_enable_version_35 = true; |
310 FLAGS_quic_enable_version_36 = true; | 310 FLAGS_quic_enable_version_36_v2 = true; |
311 EXPECT_EQ(FilterSupportedVersions(QuicSupportedVersions()), | 311 EXPECT_EQ(FilterSupportedVersions(AllSupportedVersions()), |
312 manager.GetSupportedVersions()); | 312 manager.GetSupportedVersions()); |
313 EXPECT_EQ(QUIC_VERSION_36, manager.GetSupportedVersions()[0]); | 313 EXPECT_EQ(QUIC_VERSION_36, manager.GetSupportedVersions()[0]); |
314 EXPECT_EQ(QUIC_VERSION_35, manager.GetSupportedVersions()[1]); | 314 EXPECT_EQ(QUIC_VERSION_35, manager.GetSupportedVersions()[1]); |
315 } | 315 } |
316 | 316 |
| 317 TEST(QuicProtocolTest, LookUpVersionByIndex) { |
| 318 QuicVersionVector all_versions = { |
| 319 QUIC_VERSION_30, QUIC_VERSION_31, QUIC_VERSION_32, QUIC_VERSION_33, |
| 320 QUIC_VERSION_34, QUIC_VERSION_35, QUIC_VERSION_36}; |
| 321 int version_count = all_versions.size(); |
| 322 for (int i = -5; i <= version_count + 1; ++i) { |
| 323 if (i >= 0 && i < version_count) { |
| 324 EXPECT_EQ(all_versions[i], VersionOfIndex(all_versions, i)[0]); |
| 325 } else { |
| 326 EXPECT_EQ(QUIC_VERSION_UNSUPPORTED, VersionOfIndex(all_versions, i)[0]); |
| 327 } |
| 328 } |
| 329 } |
| 330 |
317 // Tests that a queue contains the expected data after calls to Add(). | 331 // Tests that a queue contains the expected data after calls to Add(). |
318 TEST(PacketNumberQueueTest, AddRange) { | 332 TEST(PacketNumberQueueTest, AddRange) { |
319 PacketNumberQueue queue; | 333 PacketNumberQueue queue; |
320 queue.Add(1, 51); | 334 queue.Add(1, 51); |
321 queue.Add(53); | 335 queue.Add(53); |
322 | 336 |
323 EXPECT_FALSE(queue.Contains(0)); | 337 EXPECT_FALSE(queue.Contains(0)); |
324 for (int i = 1; i < 51; ++i) { | 338 for (int i = 1; i < 51; ++i) { |
325 EXPECT_TRUE(queue.Contains(i)); | 339 EXPECT_TRUE(queue.Contains(i)); |
326 } | 340 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 EXPECT_EQ(2u, queue.NumIntervals()); | 450 EXPECT_EQ(2u, queue.NumIntervals()); |
437 EXPECT_TRUE(queue.Contains(10)); | 451 EXPECT_TRUE(queue.Contains(10)); |
438 EXPECT_TRUE(queue.Contains(11)); | 452 EXPECT_TRUE(queue.Contains(11)); |
439 EXPECT_TRUE(queue.Contains(20)); | 453 EXPECT_TRUE(queue.Contains(20)); |
440 EXPECT_TRUE(queue.Contains(21)); | 454 EXPECT_TRUE(queue.Contains(21)); |
441 } | 455 } |
442 | 456 |
443 } // namespace | 457 } // namespace |
444 } // namespace test | 458 } // namespace test |
445 } // namespace net | 459 } // namespace net |
OLD | NEW |