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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1573 SendAckPacketToPeer(); // Packet 7 | 1573 SendAckPacketToPeer(); // Packet 7 |
1574 EXPECT_EQ(7u, least_unacked()); | 1574 EXPECT_EQ(7u, least_unacked()); |
1575 | 1575 |
1576 // But if we send more data it should. | 1576 // But if we send more data it should. |
1577 SendStreamDataToPeer(1, "eep", 6, !kFin, &last_packet); // Packet 8 | 1577 SendStreamDataToPeer(1, "eep", 6, !kFin, &last_packet); // Packet 8 |
1578 EXPECT_EQ(8u, last_packet); | 1578 EXPECT_EQ(8u, last_packet); |
1579 SendAckPacketToPeer(); // Packet 9 | 1579 SendAckPacketToPeer(); // Packet 9 |
1580 EXPECT_EQ(7u, least_unacked()); | 1580 EXPECT_EQ(7u, least_unacked()); |
1581 } | 1581 } |
1582 | 1582 |
1583 // If FLAGS_quic_record_send_time_before_write is disabled, QuicConnection | 1583 // QuicConnection should record the the packet sent-time prior to sending the |
1584 // should record the packet sen-tdime after the packet is sent. | 1584 // packet. |
1585 TEST_P(QuicConnectionTest, RecordSentTimeAfterPacketSent) { | 1585 TEST_P(QuicConnectionTest, RecordSentTimeBeforePacketSent) { |
1586 ValueRestore<bool> old_flag(&FLAGS_quic_record_send_time_before_write, false); | |
1587 // We're using a MockClock for the tests, so we have complete control over the | 1586 // We're using a MockClock for the tests, so we have complete control over the |
1588 // time. | 1587 // time. |
1589 // Our recorded timestamp for the last packet sent time will be passed in to | 1588 // Our recorded timestamp for the last packet sent time will be passed in to |
1590 // the send_algorithm. Make sure that it is set to the correct value. | |
1591 QuicTime actual_recorded_send_time = QuicTime::Zero(); | |
1592 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | |
1593 .WillOnce(DoAll(SaveArg<0>(&actual_recorded_send_time), Return(true))); | |
1594 | |
1595 // First send without any pause and check the result. | |
1596 QuicTime expected_recorded_send_time = clock_.Now(); | |
1597 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, nullptr); | |
1598 EXPECT_EQ(expected_recorded_send_time, actual_recorded_send_time) | |
1599 << "Expected time = " << expected_recorded_send_time.ToDebuggingValue() | |
1600 << ". Actual time = " << actual_recorded_send_time.ToDebuggingValue(); | |
1601 | |
1602 // Now pause during the write, and check the results. | |
1603 actual_recorded_send_time = QuicTime::Zero(); | |
1604 const QuicTime::Delta kWritePauseTimeDelta = | |
1605 QuicTime::Delta::FromMilliseconds(5000); | |
1606 SetWritePauseTimeDelta(kWritePauseTimeDelta); | |
1607 expected_recorded_send_time = clock_.Now().Add(kWritePauseTimeDelta); | |
1608 | |
1609 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | |
1610 .WillOnce(DoAll(SaveArg<0>(&actual_recorded_send_time), Return(true))); | |
1611 connection_.SendStreamDataWithString(2, "baz", 0, !kFin, nullptr); | |
1612 EXPECT_EQ(expected_recorded_send_time, actual_recorded_send_time) | |
1613 << "Expected time = " << expected_recorded_send_time.ToDebuggingValue() | |
1614 << ". Actual time = " << actual_recorded_send_time.ToDebuggingValue(); | |
1615 } | |
1616 | |
1617 // If FLAGS_quic_record_send_time_before_write is enabled, QuicConnection should | |
1618 // record the the packet sent-time prior to sending the packet. | |
1619 TEST_P(QuicConnectionTest, RecordSentTimeBeforePacketSent) { | |
1620 ValueRestore<bool> old_flag(&FLAGS_quic_record_send_time_before_write, true); | |
1621 // We're using a MockClock for the tests, so we have complete control over the | |
1622 // time. | |
1623 // Our recorded timestamp for the last packet sent time will be passed in to | |
1624 // the send_algorithm. Make sure that it is set to the correct value. | 1589 // the send_algorithm. Make sure that it is set to the correct value. |
1625 QuicTime actual_recorded_send_time = QuicTime::Zero(); | 1590 QuicTime actual_recorded_send_time = QuicTime::Zero(); |
1626 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 1591 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
1627 .WillOnce(DoAll(SaveArg<0>(&actual_recorded_send_time), Return(true))); | 1592 .WillOnce(DoAll(SaveArg<0>(&actual_recorded_send_time), Return(true))); |
1628 | 1593 |
1629 // First send without any pause and check the result. | 1594 // First send without any pause and check the result. |
1630 QuicTime expected_recorded_send_time = clock_.Now(); | 1595 QuicTime expected_recorded_send_time = clock_.Now(); |
1631 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, nullptr); | 1596 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, nullptr); |
1632 EXPECT_EQ(expected_recorded_send_time, actual_recorded_send_time) | 1597 EXPECT_EQ(expected_recorded_send_time, actual_recorded_send_time) |
1633 << "Expected time = " << expected_recorded_send_time.ToDebuggingValue() | 1598 << "Expected time = " << expected_recorded_send_time.ToDebuggingValue() |
(...skipping 2780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4414 // Regression test for b/18594622 | 4379 // Regression test for b/18594622 |
4415 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); | 4380 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); |
4416 EXPECT_DFATAL( | 4381 EXPECT_DFATAL( |
4417 connection_.SendStreamDataWithString(3, "", 0, !kFin, delegate.get()), | 4382 connection_.SendStreamDataWithString(3, "", 0, !kFin, delegate.get()), |
4418 "Attempt to send empty stream frame"); | 4383 "Attempt to send empty stream frame"); |
4419 } | 4384 } |
4420 | 4385 |
4421 } // namespace | 4386 } // namespace |
4422 } // namespace test | 4387 } // namespace test |
4423 } // namespace net | 4388 } // namespace net |
OLD | NEW |