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

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

Issue 1613513003: Early connection migration in QUIC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@home
Patch Set: Style nit fixed. Created 4 years, 10 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/quic_connection.h" 5 #include "net/quic/quic_connection.h"
6 6
7 #include <ostream> 7 #include <ostream>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 3465 matching lines...) Expand 10 before | Expand all | Expand 10 after
3476 InSequence s; 3476 InSequence s;
3477 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, first_packet_size, _)); 3477 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, first_packet_size, _));
3478 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, second_packet_size, _)); 3478 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, second_packet_size, _));
3479 } 3479 }
3480 connection_.GetRetransmissionAlarm()->Fire(); 3480 connection_.GetRetransmissionAlarm()->Fire();
3481 3481
3482 // Advance again and expect the packets to be sent again in the same order. 3482 // Advance again and expect the packets to be sent again in the same order.
3483 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(20)); 3483 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(20));
3484 { 3484 {
3485 InSequence s; 3485 InSequence s;
3486 EXPECT_CALL(visitor_, MaybeMigrateConnection());
3486 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, first_packet_size, _)); 3487 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, first_packet_size, _));
3487 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, second_packet_size, _)); 3488 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, second_packet_size, _));
3488 } 3489 }
3489 connection_.GetRetransmissionAlarm()->Fire(); 3490 connection_.GetRetransmissionAlarm()->Fire();
3490 } 3491 }
3491 3492
3492 TEST_P(QuicConnectionTest, SetRTOAfterWritingToSocket) { 3493 TEST_P(QuicConnectionTest, SetRTOAfterWritingToSocket) {
3493 BlockOnNextWrite(); 3494 BlockOnNextWrite();
3494 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, nullptr); 3495 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, nullptr);
3495 // Make sure that RTO is not started when the packet is queued. 3496 // Make sure that RTO is not started when the packet is queued.
(...skipping 2183 matching lines...) Expand 10 before | Expand all | Expand 10 after
5679 EXPECT_TRUE(connection_.connected()); 5680 EXPECT_TRUE(connection_.connected());
5680 EXPECT_FALSE(QuicConnectionPeer::IsMultipathEnabled(&connection_)); 5681 EXPECT_FALSE(QuicConnectionPeer::IsMultipathEnabled(&connection_));
5681 peer_creator_.SetCurrentPath(/*path_id=*/1u, 1u, 10u); 5682 peer_creator_.SetCurrentPath(/*path_id=*/1u, 1u, 10u);
5682 QuicStreamFrame stream_frame(1u, false, 0u, StringPiece()); 5683 QuicStreamFrame stream_frame(1u, false, 0u, StringPiece());
5683 EXPECT_DFATAL(ProcessFramePacket(QuicFrame(&stream_frame)), 5684 EXPECT_DFATAL(ProcessFramePacket(QuicFrame(&stream_frame)),
5684 "Received a packet with multipath flag on when multipath is " 5685 "Received a packet with multipath flag on when multipath is "
5685 "not enabled."); 5686 "not enabled.");
5686 EXPECT_FALSE(connection_.connected()); 5687 EXPECT_FALSE(connection_.connected());
5687 } 5688 }
5688 5689
5690 TEST_P(QuicConnectionTest, MaybeMigrateConnection) {
5691 QuicByteCount packet_size;
5692 const size_t kMinTimeoutsWhenPeerUnreachable = 2;
5693
5694 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
5695 .WillOnce(DoAll(SaveArg<3>(&packet_size), Return(true)));
5696 connection_.SendStreamDataWithString(3, "packet", 0, !kFin, nullptr);
5697 for (size_t i = 1; i < kMinTimeoutsWhenPeerUnreachable; ++i) {
5698 // Advance the clock by huge time; packet will be retransmitted.
5699 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10 * i));
5700 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, packet_size, _));
5701 connection_.GetRetransmissionAlarm()->Fire();
5702 }
5703 // Next RTO should cause early migration to be triggered before
5704 // retransmission is sent out.
5705 clock_.AdvanceTime(
5706 QuicTime::Delta::FromSeconds(kMinTimeoutsWhenPeerUnreachable * 10));
5707 {
5708 InSequence s;
5709 EXPECT_CALL(visitor_, MaybeMigrateConnection());
5710 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, packet_size, _));
5711 }
5712 connection_.GetRetransmissionAlarm()->Fire();
5713 }
5714
5689 } // namespace 5715 } // namespace
5690 } // namespace test 5716 } // namespace test
5691 } // namespace net 5717 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698