| 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/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 3545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3556 .WillOnce(Return(lost_packets)); | 3556 .WillOnce(Return(lost_packets)); |
| 3557 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 3557 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 3558 EXPECT_CALL(visitor_, OnCanWrite()).Times(2); | 3558 EXPECT_CALL(visitor_, OnCanWrite()).Times(2); |
| 3559 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3559 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 3560 EXPECT_CALL(*send_algorithm_, RevertRetransmissionTimeout()); | 3560 EXPECT_CALL(*send_algorithm_, RevertRetransmissionTimeout()); |
| 3561 ProcessAckPacket(&nack_three); | 3561 ProcessAckPacket(&nack_three); |
| 3562 | 3562 |
| 3563 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillOnce( | 3563 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillOnce( |
| 3564 Return(QuicBandwidth::Zero())); | 3564 Return(QuicBandwidth::Zero())); |
| 3565 | 3565 |
| 3566 const uint32 kSlowStartThreshold = 23u; |
| 3567 EXPECT_CALL(*send_algorithm_, GetSlowStartThreshold()).WillOnce( |
| 3568 Return(kSlowStartThreshold)); |
| 3569 |
| 3566 const QuicConnectionStats& stats = connection_.GetStats(); | 3570 const QuicConnectionStats& stats = connection_.GetStats(); |
| 3567 EXPECT_EQ(3 * first_packet_size + 2 * second_packet_size - kQuicVersionSize, | 3571 EXPECT_EQ(3 * first_packet_size + 2 * second_packet_size - kQuicVersionSize, |
| 3568 stats.bytes_sent); | 3572 stats.bytes_sent); |
| 3569 EXPECT_EQ(5u, stats.packets_sent); | 3573 EXPECT_EQ(5u, stats.packets_sent); |
| 3570 EXPECT_EQ(2 * first_packet_size + second_packet_size - kQuicVersionSize, | 3574 EXPECT_EQ(2 * first_packet_size + second_packet_size - kQuicVersionSize, |
| 3571 stats.bytes_retransmitted); | 3575 stats.bytes_retransmitted); |
| 3572 EXPECT_EQ(3u, stats.packets_retransmitted); | 3576 EXPECT_EQ(3u, stats.packets_retransmitted); |
| 3573 EXPECT_EQ(1u, stats.rto_count); | 3577 EXPECT_EQ(1u, stats.rto_count); |
| 3578 EXPECT_EQ(kMaxPacketSize, stats.congestion_window); |
| 3579 EXPECT_EQ(kSlowStartThreshold, stats.slow_start_threshold); |
| 3580 EXPECT_EQ(kDefaultMaxPacketSize, stats.max_packet_size); |
| 3574 } | 3581 } |
| 3575 | 3582 |
| 3576 TEST_P(QuicConnectionTest, CheckReceiveStats) { | 3583 TEST_P(QuicConnectionTest, CheckReceiveStats) { |
| 3577 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3584 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 3578 | 3585 |
| 3579 size_t received_bytes = 0; | 3586 size_t received_bytes = 0; |
| 3580 received_bytes += ProcessFecProtectedPacket(1, false, !kEntropyFlag); | 3587 received_bytes += ProcessFecProtectedPacket(1, false, !kEntropyFlag); |
| 3581 received_bytes += ProcessFecProtectedPacket(3, false, !kEntropyFlag); | 3588 received_bytes += ProcessFecProtectedPacket(3, false, !kEntropyFlag); |
| 3582 // Should be counted against dropped packets. | 3589 // Should be counted against dropped packets. |
| 3583 received_bytes += ProcessDataPacket(3, 1, !kEntropyFlag); | 3590 received_bytes += ProcessDataPacket(3, 1, !kEntropyFlag); |
| 3584 received_bytes += ProcessFecPacket(4, 1, true, !kEntropyFlag, NULL); | 3591 received_bytes += ProcessFecPacket(4, 1, true, !kEntropyFlag, NULL); |
| 3585 | 3592 |
| 3586 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillOnce( | 3593 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillOnce( |
| 3587 Return(QuicBandwidth::Zero())); | 3594 Return(QuicBandwidth::Zero())); |
| 3595 const uint32 kSlowStartThreshold = 23u; |
| 3596 EXPECT_CALL(*send_algorithm_, GetSlowStartThreshold()).WillOnce( |
| 3597 Return(kSlowStartThreshold)); |
| 3588 | 3598 |
| 3589 const QuicConnectionStats& stats = connection_.GetStats(); | 3599 const QuicConnectionStats& stats = connection_.GetStats(); |
| 3590 EXPECT_EQ(received_bytes, stats.bytes_received); | 3600 EXPECT_EQ(received_bytes, stats.bytes_received); |
| 3591 EXPECT_EQ(4u, stats.packets_received); | 3601 EXPECT_EQ(4u, stats.packets_received); |
| 3592 | 3602 |
| 3593 EXPECT_EQ(1u, stats.packets_revived); | 3603 EXPECT_EQ(1u, stats.packets_revived); |
| 3594 EXPECT_EQ(1u, stats.packets_dropped); | 3604 EXPECT_EQ(1u, stats.packets_dropped); |
| 3605 |
| 3606 EXPECT_EQ(kSlowStartThreshold, stats.slow_start_threshold); |
| 3595 } | 3607 } |
| 3596 | 3608 |
| 3597 TEST_P(QuicConnectionTest, TestFecGroupLimits) { | 3609 TEST_P(QuicConnectionTest, TestFecGroupLimits) { |
| 3598 // Create and return a group for 1. | 3610 // Create and return a group for 1. |
| 3599 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 1) != NULL); | 3611 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 1) != NULL); |
| 3600 | 3612 |
| 3601 // Create and return a group for 2. | 3613 // Create and return a group for 2. |
| 3602 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 2) != NULL); | 3614 ASSERT_TRUE(QuicConnectionPeer::GetFecGroup(&connection_, 2) != NULL); |
| 3603 | 3615 |
| 3604 // Create and return a group for 4. This should remove 1 but not 2. | 3616 // Create and return a group for 4. This should remove 1 but not 2. |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4029 QuicBlockedFrame blocked; | 4041 QuicBlockedFrame blocked; |
| 4030 blocked.stream_id = 3; | 4042 blocked.stream_id = 3; |
| 4031 EXPECT_CALL(visitor_, OnBlockedFrames(_)); | 4043 EXPECT_CALL(visitor_, OnBlockedFrames(_)); |
| 4032 ProcessFramePacket(QuicFrame(&blocked)); | 4044 ProcessFramePacket(QuicFrame(&blocked)); |
| 4033 EXPECT_TRUE(ack_alarm->IsSet()); | 4045 EXPECT_TRUE(ack_alarm->IsSet()); |
| 4034 } | 4046 } |
| 4035 | 4047 |
| 4036 } // namespace | 4048 } // namespace |
| 4037 } // namespace test | 4049 } // namespace test |
| 4038 } // namespace net | 4050 } // namespace net |
| OLD | NEW |