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

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

Issue 243533003: Sent QUIC "PING" frames when a stream is open and the connection (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 6 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 | Annotate | Revision Log
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 "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 TestConnectionHelper::TestAlarm* GetSendAlarm() { 518 TestConnectionHelper::TestAlarm* GetSendAlarm() {
519 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( 519 return reinterpret_cast<TestConnectionHelper::TestAlarm*>(
520 QuicConnectionPeer::GetSendAlarm(this)); 520 QuicConnectionPeer::GetSendAlarm(this));
521 } 521 }
522 522
523 TestConnectionHelper::TestAlarm* GetResumeWritesAlarm() { 523 TestConnectionHelper::TestAlarm* GetResumeWritesAlarm() {
524 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( 524 return reinterpret_cast<TestConnectionHelper::TestAlarm*>(
525 QuicConnectionPeer::GetResumeWritesAlarm(this)); 525 QuicConnectionPeer::GetResumeWritesAlarm(this));
526 } 526 }
527 527
528 TestConnectionHelper::TestAlarm* GetPingAlarm() {
529 return reinterpret_cast<TestConnectionHelper::TestAlarm*>(
530 QuicConnectionPeer::GetPingAlarm(this));
531 }
528 TestConnectionHelper::TestAlarm* GetTimeoutAlarm() { 532 TestConnectionHelper::TestAlarm* GetTimeoutAlarm() {
529 return reinterpret_cast<TestConnectionHelper::TestAlarm*>( 533 return reinterpret_cast<TestConnectionHelper::TestAlarm*>(
530 QuicConnectionPeer::GetTimeoutAlarm(this)); 534 QuicConnectionPeer::GetTimeoutAlarm(this));
531 } 535 }
532 536
533 using QuicConnection::SelectMutualVersion; 537 using QuicConnection::SelectMutualVersion;
534 538
535 private: 539 private:
536 TestPacketWriter* writer_; 540 TestPacketWriter* writer_;
537 541
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 .Times(AnyNumber()); 573 .Times(AnyNumber());
570 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()).WillRepeatedly( 574 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()).WillRepeatedly(
571 Return(QuicTime::Delta::Zero())); 575 Return(QuicTime::Delta::Zero()));
572 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly( 576 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly(
573 Return(kMaxPacketSize)); 577 Return(kMaxPacketSize));
574 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)) 578 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _))
575 .WillByDefault(Return(true)); 579 .WillByDefault(Return(true));
576 EXPECT_CALL(visitor_, HasPendingWrites()).Times(AnyNumber()); 580 EXPECT_CALL(visitor_, HasPendingWrites()).Times(AnyNumber());
577 EXPECT_CALL(visitor_, HasPendingHandshake()).Times(AnyNumber()); 581 EXPECT_CALL(visitor_, HasPendingHandshake()).Times(AnyNumber());
578 EXPECT_CALL(visitor_, OnCanWrite()).Times(AnyNumber()); 582 EXPECT_CALL(visitor_, OnCanWrite()).Times(AnyNumber());
583 EXPECT_CALL(visitor_, HasOpenStreams()).WillRepeatedly(Return(false));
579 584
580 EXPECT_CALL(*loss_algorithm_, GetLossTimeout()) 585 EXPECT_CALL(*loss_algorithm_, GetLossTimeout())
581 .WillRepeatedly(Return(QuicTime::Zero())); 586 .WillRepeatedly(Return(QuicTime::Zero()));
582 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) 587 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
583 .WillRepeatedly(Return(SequenceNumberSet())); 588 .WillRepeatedly(Return(SequenceNumberSet()));
584 } 589 }
585 590
586 QuicVersion version() { 591 QuicVersion version() {
587 return GetParam(); 592 return GetParam();
588 } 593 }
(...skipping 1980 matching lines...) Expand 10 before | Expand all | Expand 10 after
2569 EXPECT_EQ(default_timeout, connection_.GetTimeoutAlarm()->deadline()); 2574 EXPECT_EQ(default_timeout, connection_.GetTimeoutAlarm()->deadline());
2570 2575
2571 // Simulate the timeout alarm firing. 2576 // Simulate the timeout alarm firing.
2572 clock_.AdvanceTime( 2577 clock_.AdvanceTime(
2573 QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs)); 2578 QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs));
2574 connection_.GetTimeoutAlarm()->Fire(); 2579 connection_.GetTimeoutAlarm()->Fire();
2575 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); 2580 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet());
2576 EXPECT_FALSE(connection_.connected()); 2581 EXPECT_FALSE(connection_.connected());
2577 2582
2578 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); 2583 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
2584 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet());
2579 EXPECT_FALSE(connection_.GetResumeWritesAlarm()->IsSet()); 2585 EXPECT_FALSE(connection_.GetResumeWritesAlarm()->IsSet());
2580 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); 2586 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet());
2581 EXPECT_FALSE(connection_.GetSendAlarm()->IsSet()); 2587 EXPECT_FALSE(connection_.GetSendAlarm()->IsSet());
2582 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); 2588 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet());
2583 } 2589 }
2584 2590
2591 TEST_P(QuicConnectionTest, PingAfterSend) {
2592 EXPECT_TRUE(connection_.connected());
2593 EXPECT_CALL(visitor_, HasOpenStreams()).WillRepeatedly(Return(true));
2594 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet());
2595
2596 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
2597 // Send an ack so we don't set the retransmission alarm.
2598 SendAckPacketToPeer();
2599 QuicTime ping_timeout = clock_.ApproximateNow().Add(
2600 QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs / 2));
2601 EXPECT_EQ(ping_timeout, connection_.GetPingAlarm()->deadline());
2602
2603 writer_->Reset();
2604 EXPECT_CALL(*send_algorithm_,
2605 TimeUntilSend(_, _)).WillRepeatedly(
2606 testing::Return(QuicTime::Delta::Zero()));
2607 connection_.GetPingAlarm()->Fire();
2608 EXPECT_EQ(1u, writer_->frame_count());
2609 EXPECT_EQ(1u, writer_->stream_frames()->size());
2610 EXPECT_EQ(kCryptoStreamId, (*writer_->stream_frames())[0].stream_id);
2611 EXPECT_EQ(0u, (*writer_->stream_frames())[0].offset);
2612 writer_->Reset();
2613
2614 EXPECT_CALL(visitor_, HasOpenStreams()).WillRepeatedly(Return(false));
2615 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
2616 SendAckPacketToPeer();
2617
2618 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet());
2619
2620 }
2621
2585 TEST_P(QuicConnectionTest, TimeoutAfterSend) { 2622 TEST_P(QuicConnectionTest, TimeoutAfterSend) {
2586 EXPECT_TRUE(connection_.connected()); 2623 EXPECT_TRUE(connection_.connected());
2587 2624
2588 QuicTime default_timeout = clock_.ApproximateNow().Add( 2625 QuicTime default_timeout = clock_.ApproximateNow().Add(
2589 QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs)); 2626 QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs));
2590 2627
2591 // When we send a packet, the timeout will change to 5000 + 2628 // When we send a packet, the timeout will change to 5000 +
2592 // kDefaultInitialTimeoutSecs. 2629 // kDefaultInitialTimeoutSecs.
2593 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); 2630 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
2594 2631
(...skipping 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after
3951 TestConnection connection(connection_id_, IPEndPoint(), helper_.get(), 3988 TestConnection connection(connection_id_, IPEndPoint(), helper_.get(),
3952 writer_.get(), true, version(), 3989 writer_.get(), true, version(),
3953 kSmallerFlowControlWindow); 3990 kSmallerFlowControlWindow);
3954 EXPECT_EQ(kDefaultFlowControlSendWindow, 3991 EXPECT_EQ(kDefaultFlowControlSendWindow,
3955 connection.max_flow_control_receive_window_bytes()); 3992 connection.max_flow_control_receive_window_bytes());
3956 } 3993 }
3957 3994
3958 } // namespace 3995 } // namespace
3959 } // namespace test 3996 } // namespace test
3960 } // namespace net 3997 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698