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/tools/quic/quic_dispatcher.h" | 5 #include "net/tools/quic/quic_dispatcher.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <ostream> | 8 #include <ostream> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _, _, _)) | 520 EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _, _, _)) |
521 .Times(1); | 521 .Times(1); |
522 // A packet whose packet number is one to large to be allowed to start a | 522 // A packet whose packet number is one to large to be allowed to start a |
523 // connection. | 523 // connection. |
524 ProcessPacket(client_address, connection_id, true, SerializeCHLO(), | 524 ProcessPacket(client_address, connection_id, true, SerializeCHLO(), |
525 PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER, | 525 PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER, |
526 QuicDispatcher::kMaxReasonableInitialPacketNumber + 1); | 526 QuicDispatcher::kMaxReasonableInitialPacketNumber + 1); |
527 } | 527 } |
528 | 528 |
529 TEST_F(QuicDispatcherTest, SupportedVersionsChangeInFlight) { | 529 TEST_F(QuicDispatcherTest, SupportedVersionsChangeInFlight) { |
530 static_assert(arraysize(kSupportedQuicVersions) == 5u, | 530 static_assert(arraysize(kSupportedQuicVersions) == 6u, |
531 "Supported versions out of sync"); | 531 "Supported versions out of sync"); |
532 FLAGS_quic_reloadable_flag_quic_disable_version_34 = false; | 532 FLAGS_quic_reloadable_flag_quic_disable_version_34 = false; |
533 FLAGS_quic_reloadable_flag_quic_enable_version_36_v3 = true; | 533 FLAGS_quic_reloadable_flag_quic_enable_version_36_v3 = true; |
534 FLAGS_quic_reloadable_flag_quic_enable_version_37 = true; | 534 FLAGS_quic_reloadable_flag_quic_enable_version_37 = true; |
535 FLAGS_quic_reloadable_flag_quic_enable_version_38 = true; | 535 FLAGS_quic_reloadable_flag_quic_enable_version_38 = true; |
| 536 base::SetFlag(&FLAGS_quic_enable_version_39, true); |
536 QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 1); | 537 QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 1); |
537 server_address_ = QuicSocketAddress(QuicIpAddress::Any4(), 5); | 538 server_address_ = QuicSocketAddress(QuicIpAddress::Any4(), 5); |
538 QuicConnectionId connection_id = 1; | 539 QuicConnectionId connection_id = 1; |
539 | 540 |
540 EXPECT_CALL(*dispatcher_, CreateQuicSession(connection_id, client_address)) | 541 EXPECT_CALL(*dispatcher_, CreateQuicSession(connection_id, client_address)) |
541 .Times(0); | 542 .Times(0); |
542 ProcessPacket(client_address, connection_id, true, | 543 ProcessPacket(client_address, connection_id, true, |
543 static_cast<QuicVersion>(QuicVersionMin() - 1), SerializeCHLO(), | 544 static_cast<QuicVersion>(QuicVersionMin() - 1), SerializeCHLO(), |
544 PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER, 1); | 545 PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER, 1); |
545 ++connection_id; | 546 ++connection_id; |
(...skipping 17 matching lines...) Expand all Loading... |
563 &mock_helper_, &mock_alarm_factory_, &crypto_config_, | 564 &mock_helper_, &mock_alarm_factory_, &crypto_config_, |
564 QuicDispatcherPeer::GetCache(dispatcher_.get()), &session1_))); | 565 QuicDispatcherPeer::GetCache(dispatcher_.get()), &session1_))); |
565 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()), | 566 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()), |
566 ProcessUdpPacket(_, _, _)) | 567 ProcessUdpPacket(_, _, _)) |
567 .WillOnce(testing::WithArgs<2>( | 568 .WillOnce(testing::WithArgs<2>( |
568 Invoke(CreateFunctor(&QuicDispatcherTest::ValidatePacket, | 569 Invoke(CreateFunctor(&QuicDispatcherTest::ValidatePacket, |
569 base::Unretained(this), connection_id)))); | 570 base::Unretained(this), connection_id)))); |
570 ProcessPacket(client_address, connection_id, true, QuicVersionMax(), | 571 ProcessPacket(client_address, connection_id, true, QuicVersionMax(), |
571 SerializeCHLO(), PACKET_8BYTE_CONNECTION_ID, | 572 SerializeCHLO(), PACKET_8BYTE_CONNECTION_ID, |
572 PACKET_6BYTE_PACKET_NUMBER, 1); | 573 PACKET_6BYTE_PACKET_NUMBER, 1); |
| 574 |
| 575 // Turn off version 39. |
| 576 base::SetFlag(&FLAGS_quic_enable_version_39, false); |
| 577 ++connection_id; |
| 578 EXPECT_CALL(*dispatcher_, CreateQuicSession(connection_id, client_address)) |
| 579 .Times(0); |
| 580 ProcessPacket(client_address, connection_id, true, QUIC_VERSION_39, |
| 581 SerializeCHLO(), PACKET_8BYTE_CONNECTION_ID, |
| 582 PACKET_6BYTE_PACKET_NUMBER, 1); |
| 583 |
| 584 // Turn on version 39. |
| 585 base::SetFlag(&FLAGS_quic_enable_version_39, true); |
| 586 ++connection_id; |
| 587 EXPECT_CALL(*dispatcher_, CreateQuicSession(connection_id, client_address)) |
| 588 .WillOnce(testing::Return(CreateSession( |
| 589 dispatcher_.get(), config_, connection_id, client_address, |
| 590 &mock_helper_, &mock_alarm_factory_, &crypto_config_, |
| 591 QuicDispatcherPeer::GetCache(dispatcher_.get()), &session1_))); |
| 592 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()), |
| 593 ProcessUdpPacket(_, _, _)) |
| 594 .WillOnce(testing::WithArgs<2>( |
| 595 Invoke(CreateFunctor(&QuicDispatcherTest::ValidatePacket, |
| 596 base::Unretained(this), connection_id)))); |
| 597 ProcessPacket(client_address, connection_id, true, QUIC_VERSION_39, |
| 598 SerializeCHLO(), PACKET_8BYTE_CONNECTION_ID, |
| 599 PACKET_6BYTE_PACKET_NUMBER, 1); |
| 600 |
573 // Turn off version 36. | 601 // Turn off version 36. |
574 FLAGS_quic_reloadable_flag_quic_enable_version_36_v3 = false; | 602 FLAGS_quic_reloadable_flag_quic_enable_version_36_v3 = false; |
575 ++connection_id; | 603 ++connection_id; |
576 EXPECT_CALL(*dispatcher_, CreateQuicSession(connection_id, client_address)) | 604 EXPECT_CALL(*dispatcher_, CreateQuicSession(connection_id, client_address)) |
577 .Times(0); | 605 .Times(0); |
578 ProcessPacket(client_address, connection_id, true, QUIC_VERSION_36, | 606 ProcessPacket(client_address, connection_id, true, QUIC_VERSION_36, |
579 SerializeCHLO(), PACKET_8BYTE_CONNECTION_ID, | 607 SerializeCHLO(), PACKET_8BYTE_CONNECTION_ID, |
580 PACKET_6BYTE_PACKET_NUMBER, 1); | 608 PACKET_6BYTE_PACKET_NUMBER, 1); |
581 | 609 |
582 // Turn on version 36. | 610 // Turn on version 36. |
(...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2065 check.Call(2); | 2093 check.Call(2); |
2066 GetFakeProofSource()->InvokePendingCallback(0); | 2094 GetFakeProofSource()->InvokePendingCallback(0); |
2067 ASSERT_EQ(GetFakeProofSource()->NumPendingCallbacks(), 0); | 2095 ASSERT_EQ(GetFakeProofSource()->NumPendingCallbacks(), 0); |
2068 EXPECT_FALSE(store->HasBufferedPackets(conn_id)); | 2096 EXPECT_FALSE(store->HasBufferedPackets(conn_id)); |
2069 EXPECT_FALSE(time_wait_list_manager_->IsConnectionIdInTimeWait(conn_id)); | 2097 EXPECT_FALSE(time_wait_list_manager_->IsConnectionIdInTimeWait(conn_id)); |
2070 } | 2098 } |
2071 | 2099 |
2072 } // namespace | 2100 } // namespace |
2073 } // namespace test | 2101 } // namespace test |
2074 } // namespace net | 2102 } // namespace net |
OLD | NEW |