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

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

Issue 1009543004: Create a Perspective enum to use instead of a bool is_server to improve (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added NET_EXPORT_PRIVATE to fix compiler error Created 5 years, 9 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
« no previous file with comments | « net/quic/quic_sent_packet_manager.cc ('k') | net/quic/quic_session.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_sent_packet_manager.h" 5 #include "net/quic/quic_sent_packet_manager.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "net/quic/quic_flags.h" 8 #include "net/quic/quic_flags.h"
9 #include "net/quic/test_tools/quic_config_peer.h" 9 #include "net/quic/test_tools/quic_config_peer.h"
10 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" 10 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h"
(...skipping 28 matching lines...) Expand all
39 class MockDebugDelegate : public QuicSentPacketManager::DebugDelegate { 39 class MockDebugDelegate : public QuicSentPacketManager::DebugDelegate {
40 public: 40 public:
41 MOCK_METHOD2(OnSpuriousPacketRetransmission, 41 MOCK_METHOD2(OnSpuriousPacketRetransmission,
42 void(TransmissionType transmission_type, 42 void(TransmissionType transmission_type,
43 QuicByteCount byte_size)); 43 QuicByteCount byte_size));
44 }; 44 };
45 45
46 class QuicSentPacketManagerTest : public ::testing::TestWithParam<bool> { 46 class QuicSentPacketManagerTest : public ::testing::TestWithParam<bool> {
47 protected: 47 protected:
48 QuicSentPacketManagerTest() 48 QuicSentPacketManagerTest()
49 : manager_(true, &clock_, &stats_, kCubic, kNack, false), 49 : manager_(Perspective::IS_SERVER, &clock_, &stats_, kCubic, kNack, true),
50 send_algorithm_(new StrictMock<MockSendAlgorithm>), 50 send_algorithm_(new StrictMock<MockSendAlgorithm>),
51 network_change_visitor_(new StrictMock<MockNetworkChangeVisitor>) { 51 network_change_visitor_(new StrictMock<MockNetworkChangeVisitor>) {
52 QuicSentPacketManagerPeer::SetSendAlgorithm(&manager_, send_algorithm_); 52 QuicSentPacketManagerPeer::SetSendAlgorithm(&manager_, send_algorithm_);
53 // Disable tail loss probes for most tests. 53 // Disable tail loss probes for most tests.
54 QuicSentPacketManagerPeer::SetMaxTailLossProbes(&manager_, 0); 54 QuicSentPacketManagerPeer::SetMaxTailLossProbes(&manager_, 0);
55 // Advance the time 1s so the send times are never QuicTime::Zero. 55 // Advance the time 1s so the send times are never QuicTime::Zero.
56 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1000)); 56 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1000));
57 manager_.set_network_change_visitor(network_change_visitor_.get()); 57 manager_.set_network_change_visitor(network_change_visitor_.get());
58 58
59 EXPECT_CALL(*send_algorithm_, HasReliableBandwidthEstimate()) 59 EXPECT_CALL(*send_algorithm_, HasReliableBandwidthEstimate())
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange()); 1116 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1117 EXPECT_CALL(*network_change_visitor_, OnRttChange()); 1117 EXPECT_CALL(*network_change_visitor_, OnRttChange());
1118 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); 1118 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
1119 manager_.OnIncomingAck(ack_frame, clock_.Now()); 1119 manager_.OnIncomingAck(ack_frame, clock_.Now());
1120 } 1120 }
1121 1121
1122 TEST_F(QuicSentPacketManagerTest, NewRetransmissionTimeout) { 1122 TEST_F(QuicSentPacketManagerTest, NewRetransmissionTimeout) {
1123 QuicConfig client_config; 1123 QuicConfig client_config;
1124 QuicTagVector options; 1124 QuicTagVector options;
1125 options.push_back(kNRTO); 1125 options.push_back(kNRTO);
1126 QuicSentPacketManagerPeer::SetIsServer(&manager_, false); 1126 QuicSentPacketManagerPeer::SetPerspective(&manager_, Perspective::IS_CLIENT);
1127 client_config.SetConnectionOptionsToSend(options); 1127 client_config.SetConnectionOptionsToSend(options);
1128 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange()); 1128 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1129 EXPECT_CALL(*network_change_visitor_, OnRttChange()); 1129 EXPECT_CALL(*network_change_visitor_, OnRttChange());
1130 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _)); 1130 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _));
1131 EXPECT_CALL(*send_algorithm_, PacingRate()) 1131 EXPECT_CALL(*send_algorithm_, PacingRate())
1132 .WillRepeatedly(Return(QuicBandwidth::Zero())); 1132 .WillRepeatedly(Return(QuicBandwidth::Zero()));
1133 manager_.SetFromConfig(client_config); 1133 manager_.SetFromConfig(client_config);
1134 EXPECT_TRUE(QuicSentPacketManagerPeer::GetUseNewRto(&manager_)); 1134 EXPECT_TRUE(QuicSentPacketManagerPeer::GetUseNewRto(&manager_));
1135 1135
1136 // Send 100 packets. 1136 // Send 100 packets.
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1479 QuicTagVector options; 1479 QuicTagVector options;
1480 1480
1481 options.push_back(k1CON); 1481 options.push_back(k1CON);
1482 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); 1482 QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
1483 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange()); 1483 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1484 EXPECT_CALL(*network_change_visitor_, OnRttChange()); 1484 EXPECT_CALL(*network_change_visitor_, OnRttChange());
1485 EXPECT_CALL(*send_algorithm_, SetNumEmulatedConnections(1)); 1485 EXPECT_CALL(*send_algorithm_, SetNumEmulatedConnections(1));
1486 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _)); 1486 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _));
1487 manager_.SetFromConfig(config); 1487 manager_.SetFromConfig(config);
1488 1488
1489 QuicSentPacketManagerPeer::SetIsServer(&manager_, false); 1489 QuicSentPacketManagerPeer::SetPerspective(&manager_, Perspective::IS_CLIENT);
1490 QuicConfig client_config; 1490 QuicConfig client_config;
1491 client_config.SetConnectionOptionsToSend(options); 1491 client_config.SetConnectionOptionsToSend(options);
1492 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange()); 1492 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1493 EXPECT_CALL(*network_change_visitor_, OnRttChange()); 1493 EXPECT_CALL(*network_change_visitor_, OnRttChange());
1494 EXPECT_CALL(*send_algorithm_, SetNumEmulatedConnections(1)); 1494 EXPECT_CALL(*send_algorithm_, SetNumEmulatedConnections(1));
1495 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _)); 1495 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _));
1496 manager_.SetFromConfig(client_config); 1496 manager_.SetFromConfig(client_config);
1497 } 1497 }
1498 1498
1499 TEST_F(QuicSentPacketManagerTest, NegotiateNConnectionFromOptions) { 1499 TEST_F(QuicSentPacketManagerTest, NegotiateNConnectionFromOptions) {
(...skipping 25 matching lines...) Expand all
1525 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _)); 1525 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _));
1526 manager_.SetFromConfig(config); 1526 manager_.SetFromConfig(config);
1527 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetMaxTailLossProbes(&manager_)); 1527 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetMaxTailLossProbes(&manager_));
1528 } 1528 }
1529 1529
1530 TEST_F(QuicSentPacketManagerTest, NegotiateNoTLPFromOptionsAtClient) { 1530 TEST_F(QuicSentPacketManagerTest, NegotiateNoTLPFromOptionsAtClient) {
1531 QuicConfig client_config; 1531 QuicConfig client_config;
1532 QuicTagVector options; 1532 QuicTagVector options;
1533 1533
1534 options.push_back(kNTLP); 1534 options.push_back(kNTLP);
1535 QuicSentPacketManagerPeer::SetIsServer(&manager_, false); 1535 QuicSentPacketManagerPeer::SetPerspective(&manager_, Perspective::IS_CLIENT);
1536 client_config.SetConnectionOptionsToSend(options); 1536 client_config.SetConnectionOptionsToSend(options);
1537 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange()); 1537 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1538 EXPECT_CALL(*network_change_visitor_, OnRttChange()); 1538 EXPECT_CALL(*network_change_visitor_, OnRttChange());
1539 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _)); 1539 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _));
1540 manager_.SetFromConfig(client_config); 1540 manager_.SetFromConfig(client_config);
1541 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetMaxTailLossProbes(&manager_)); 1541 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetMaxTailLossProbes(&manager_));
1542 } 1542 }
1543 1543
1544 TEST_F(QuicSentPacketManagerTest, NegotiateNewRTOFromOptionsAtServer) { 1544 TEST_F(QuicSentPacketManagerTest, NegotiateNewRTOFromOptionsAtServer) {
1545 EXPECT_FALSE(QuicSentPacketManagerPeer::GetUseNewRto(&manager_)); 1545 EXPECT_FALSE(QuicSentPacketManagerPeer::GetUseNewRto(&manager_));
1546 QuicConfig config; 1546 QuicConfig config;
1547 QuicTagVector options; 1547 QuicTagVector options;
1548 1548
1549 options.push_back(kNRTO); 1549 options.push_back(kNRTO);
1550 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); 1550 QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
1551 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange()); 1551 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1552 EXPECT_CALL(*network_change_visitor_, OnRttChange()); 1552 EXPECT_CALL(*network_change_visitor_, OnRttChange());
1553 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _)); 1553 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _));
1554 manager_.SetFromConfig(config); 1554 manager_.SetFromConfig(config);
1555 EXPECT_TRUE(QuicSentPacketManagerPeer::GetUseNewRto(&manager_)); 1555 EXPECT_TRUE(QuicSentPacketManagerPeer::GetUseNewRto(&manager_));
1556 } 1556 }
1557 1557
1558 TEST_F(QuicSentPacketManagerTest, NegotiateNewRTOFromOptionsAtClient) { 1558 TEST_F(QuicSentPacketManagerTest, NegotiateNewRTOFromOptionsAtClient) {
1559 EXPECT_FALSE(QuicSentPacketManagerPeer::GetUseNewRto(&manager_)); 1559 EXPECT_FALSE(QuicSentPacketManagerPeer::GetUseNewRto(&manager_));
1560 QuicConfig client_config; 1560 QuicConfig client_config;
1561 QuicTagVector options; 1561 QuicTagVector options;
1562 1562
1563 options.push_back(kNRTO); 1563 options.push_back(kNRTO);
1564 QuicSentPacketManagerPeer::SetIsServer(&manager_, false); 1564 QuicSentPacketManagerPeer::SetPerspective(&manager_, Perspective::IS_CLIENT);
1565 client_config.SetConnectionOptionsToSend(options); 1565 client_config.SetConnectionOptionsToSend(options);
1566 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange()); 1566 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1567 EXPECT_CALL(*network_change_visitor_, OnRttChange()); 1567 EXPECT_CALL(*network_change_visitor_, OnRttChange());
1568 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _)); 1568 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _));
1569 manager_.SetFromConfig(client_config); 1569 manager_.SetFromConfig(client_config);
1570 EXPECT_TRUE(QuicSentPacketManagerPeer::GetUseNewRto(&manager_)); 1570 EXPECT_TRUE(QuicSentPacketManagerPeer::GetUseNewRto(&manager_));
1571 } 1571 }
1572 1572
1573 TEST_F(QuicSentPacketManagerTest, NegotiatePacingFromOptions) { 1573 TEST_F(QuicSentPacketManagerTest, NegotiatePacingFromOptions) {
1574 EXPECT_FALSE(manager_.using_pacing()); 1574 EXPECT_FALSE(manager_.using_pacing());
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1680 1680
1681 EXPECT_CALL(*send_algorithm_, ResumeConnectionState(_)); 1681 EXPECT_CALL(*send_algorithm_, ResumeConnectionState(_));
1682 manager_.ResumeConnectionState(cached_network_params); 1682 manager_.ResumeConnectionState(cached_network_params);
1683 EXPECT_EQ(kRttMs * kNumMicrosPerMilli, 1683 EXPECT_EQ(kRttMs * kNumMicrosPerMilli,
1684 static_cast<uint64>(manager_.GetRttStats()->initial_rtt_us())); 1684 static_cast<uint64>(manager_.GetRttStats()->initial_rtt_us()));
1685 } 1685 }
1686 1686
1687 } // namespace 1687 } // namespace
1688 } // namespace test 1688 } // namespace test
1689 } // namespace net 1689 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_sent_packet_manager.cc ('k') | net/quic/quic_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698