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

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

Issue 908673002: Remove QUIC's ReceiveAlgorithmInterface now that it does nothing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Fixing_a_bug_0_85554888
Patch Set: Created 5 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
« no previous file with comments | « net/quic/congestion_control/tcp_receiver_test.cc ('k') | net/quic/quic_http_stream_test.cc » ('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 (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"
11 #include "net/quic/congestion_control/loss_detection_interface.h" 11 #include "net/quic/congestion_control/loss_detection_interface.h"
12 #include "net/quic/congestion_control/receive_algorithm_interface.h"
13 #include "net/quic/congestion_control/send_algorithm_interface.h" 12 #include "net/quic/congestion_control/send_algorithm_interface.h"
14 #include "net/quic/crypto/null_encrypter.h" 13 #include "net/quic/crypto/null_encrypter.h"
15 #include "net/quic/crypto/quic_decrypter.h" 14 #include "net/quic/crypto/quic_decrypter.h"
16 #include "net/quic/crypto/quic_encrypter.h" 15 #include "net/quic/crypto/quic_encrypter.h"
17 #include "net/quic/quic_ack_notifier.h" 16 #include "net/quic/quic_ack_notifier.h"
18 #include "net/quic/quic_flags.h" 17 #include "net/quic/quic_flags.h"
19 #include "net/quic/quic_protocol.h" 18 #include "net/quic/quic_protocol.h"
20 #include "net/quic/quic_utils.h" 19 #include "net/quic/quic_utils.h"
21 #include "net/quic/test_tools/mock_clock.h" 20 #include "net/quic/test_tools/mock_clock.h"
22 #include "net/quic/test_tools/mock_random.h" 21 #include "net/quic/test_tools/mock_random.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 const char data1[] = "foo"; 56 const char data1[] = "foo";
58 const char data2[] = "bar"; 57 const char data2[] = "bar";
59 58
60 const bool kFin = true; 59 const bool kFin = true;
61 const bool kEntropyFlag = true; 60 const bool kEntropyFlag = true;
62 61
63 const QuicPacketEntropyHash kTestEntropyHash = 76; 62 const QuicPacketEntropyHash kTestEntropyHash = 76;
64 63
65 const int kDefaultRetransmissionTimeMs = 500; 64 const int kDefaultRetransmissionTimeMs = 500;
66 65
67 class TestReceiveAlgorithm : public ReceiveAlgorithmInterface {
68 public:
69 TestReceiveAlgorithm() {}
70
71 MOCK_METHOD3(RecordIncomingPacket,
72 void(QuicByteCount, QuicPacketSequenceNumber, QuicTime));
73
74 private:
75 DISALLOW_COPY_AND_ASSIGN(TestReceiveAlgorithm);
76 };
77
78 // TaggingEncrypter appends kTagSize bytes of |tag| to the end of each message. 66 // TaggingEncrypter appends kTagSize bytes of |tag| to the end of each message.
79 class TaggingEncrypter : public QuicEncrypter { 67 class TaggingEncrypter : public QuicEncrypter {
80 public: 68 public:
81 explicit TaggingEncrypter(uint8 tag) 69 explicit TaggingEncrypter(uint8 tag)
82 : tag_(tag) { 70 : tag_(tag) {
83 } 71 }
84 72
85 ~TaggingEncrypter() override {} 73 ~TaggingEncrypter() override {}
86 74
87 // QuicEncrypter interface. 75 // QuicEncrypter interface.
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 // Disable tail loss probes for most tests. 389 // Disable tail loss probes for most tests.
402 QuicSentPacketManagerPeer::SetMaxTailLossProbes( 390 QuicSentPacketManagerPeer::SetMaxTailLossProbes(
403 QuicConnectionPeer::GetSentPacketManager(this), 0); 391 QuicConnectionPeer::GetSentPacketManager(this), 0);
404 writer()->set_is_server(is_server); 392 writer()->set_is_server(is_server);
405 } 393 }
406 394
407 void SendAck() { 395 void SendAck() {
408 QuicConnectionPeer::SendAck(this); 396 QuicConnectionPeer::SendAck(this);
409 } 397 }
410 398
411 void SetReceiveAlgorithm(TestReceiveAlgorithm* receive_algorithm) {
412 QuicConnectionPeer::SetReceiveAlgorithm(this, receive_algorithm);
413 }
414
415 void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) { 399 void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) {
416 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm); 400 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm);
417 } 401 }
418 402
419 void SetLossAlgorithm(LossDetectionInterface* loss_algorithm) { 403 void SetLossAlgorithm(LossDetectionInterface* loss_algorithm) {
420 QuicSentPacketManagerPeer::SetLossAlgorithm( 404 QuicSentPacketManagerPeer::SetLossAlgorithm(
421 QuicConnectionPeer::GetSentPacketManager(this), loss_algorithm); 405 QuicConnectionPeer::GetSentPacketManager(this), loss_algorithm);
422 } 406 }
423 407
424 void SendPacket(EncryptionLevel level, 408 void SendPacket(EncryptionLevel level,
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 }; 580 };
597 581
598 class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> { 582 class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
599 protected: 583 protected:
600 QuicConnectionTest() 584 QuicConnectionTest()
601 : connection_id_(42), 585 : connection_id_(42),
602 framer_(SupportedVersions(version()), QuicTime::Zero(), false), 586 framer_(SupportedVersions(version()), QuicTime::Zero(), false),
603 peer_creator_(connection_id_, &framer_, &random_generator_), 587 peer_creator_(connection_id_, &framer_, &random_generator_),
604 send_algorithm_(new StrictMock<MockSendAlgorithm>), 588 send_algorithm_(new StrictMock<MockSendAlgorithm>),
605 loss_algorithm_(new MockLossAlgorithm()), 589 loss_algorithm_(new MockLossAlgorithm()),
606 receive_algorithm_(new TestReceiveAlgorithm),
607 helper_(new TestConnectionHelper(&clock_, &random_generator_)), 590 helper_(new TestConnectionHelper(&clock_, &random_generator_)),
608 writer_(new TestPacketWriter(version(), &clock_)), 591 writer_(new TestPacketWriter(version(), &clock_)),
609 factory_(writer_.get()), 592 factory_(writer_.get()),
610 connection_(connection_id_, 593 connection_(connection_id_,
611 IPEndPoint(), 594 IPEndPoint(),
612 helper_.get(), 595 helper_.get(),
613 factory_, 596 factory_,
614 false, 597 false,
615 version()), 598 version()),
616 creator_(QuicConnectionPeer::GetPacketCreator(&connection_)), 599 creator_(QuicConnectionPeer::GetPacketCreator(&connection_)),
617 generator_(QuicConnectionPeer::GetPacketGenerator(&connection_)), 600 generator_(QuicConnectionPeer::GetPacketGenerator(&connection_)),
618 manager_(QuicConnectionPeer::GetSentPacketManager(&connection_)), 601 manager_(QuicConnectionPeer::GetSentPacketManager(&connection_)),
619 frame1_(1, false, 0, MakeIOVector(data1)), 602 frame1_(1, false, 0, MakeIOVector(data1)),
620 frame2_(1, false, 3, MakeIOVector(data2)), 603 frame2_(1, false, 3, MakeIOVector(data2)),
621 sequence_number_length_(PACKET_6BYTE_SEQUENCE_NUMBER), 604 sequence_number_length_(PACKET_6BYTE_SEQUENCE_NUMBER),
622 connection_id_length_(PACKET_8BYTE_CONNECTION_ID) { 605 connection_id_length_(PACKET_8BYTE_CONNECTION_ID) {
623 connection_.set_visitor(&visitor_); 606 connection_.set_visitor(&visitor_);
624 connection_.SetSendAlgorithm(send_algorithm_); 607 connection_.SetSendAlgorithm(send_algorithm_);
625 connection_.SetLossAlgorithm(loss_algorithm_); 608 connection_.SetLossAlgorithm(loss_algorithm_);
626 framer_.set_received_entropy_calculator(&entropy_calculator_); 609 framer_.set_received_entropy_calculator(&entropy_calculator_);
627 connection_.SetReceiveAlgorithm(receive_algorithm_);
628 EXPECT_CALL( 610 EXPECT_CALL(
629 *send_algorithm_, TimeUntilSend(_, _, _)).WillRepeatedly(Return( 611 *send_algorithm_, TimeUntilSend(_, _, _)).WillRepeatedly(Return(
630 QuicTime::Delta::Zero())); 612 QuicTime::Delta::Zero()));
631 EXPECT_CALL(*receive_algorithm_,
632 RecordIncomingPacket(_, _, _)).Times(AnyNumber());
633 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 613 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
634 .Times(AnyNumber()); 614 .Times(AnyNumber());
635 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()).WillRepeatedly( 615 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()).WillRepeatedly(
636 Return(QuicTime::Delta::Zero())); 616 Return(QuicTime::Delta::Zero()));
637 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly( 617 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly(
638 Return(kMaxPacketSize)); 618 Return(kMaxPacketSize));
639 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 619 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
640 .WillByDefault(Return(true)); 620 .WillByDefault(Return(true));
641 EXPECT_CALL(*send_algorithm_, HasReliableBandwidthEstimate()) 621 EXPECT_CALL(*send_algorithm_, HasReliableBandwidthEstimate())
642 .Times(AnyNumber()); 622 .Times(AnyNumber());
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 testing::Return(QuicTime::Delta::Zero())); 963 testing::Return(QuicTime::Delta::Zero()));
984 } 964 }
985 965
986 QuicConnectionId connection_id_; 966 QuicConnectionId connection_id_;
987 QuicFramer framer_; 967 QuicFramer framer_;
988 QuicPacketCreator peer_creator_; 968 QuicPacketCreator peer_creator_;
989 MockEntropyCalculator entropy_calculator_; 969 MockEntropyCalculator entropy_calculator_;
990 970
991 MockSendAlgorithm* send_algorithm_; 971 MockSendAlgorithm* send_algorithm_;
992 MockLossAlgorithm* loss_algorithm_; 972 MockLossAlgorithm* loss_algorithm_;
993 TestReceiveAlgorithm* receive_algorithm_;
994 MockClock clock_; 973 MockClock clock_;
995 MockRandom random_generator_; 974 MockRandom random_generator_;
996 scoped_ptr<TestConnectionHelper> helper_; 975 scoped_ptr<TestConnectionHelper> helper_;
997 scoped_ptr<TestPacketWriter> writer_; 976 scoped_ptr<TestPacketWriter> writer_;
998 NiceMock<MockPacketWriterFactory> factory_; 977 NiceMock<MockPacketWriterFactory> factory_;
999 TestConnection connection_; 978 TestConnection connection_;
1000 QuicPacketCreator* creator_; 979 QuicPacketCreator* creator_;
1001 QuicPacketGenerator* generator_; 980 QuicPacketGenerator* generator_;
1002 QuicSentPacketManager* manager_; 981 QuicSentPacketManager* manager_;
1003 StrictMock<MockConnectionVisitor> visitor_; 982 StrictMock<MockConnectionVisitor> visitor_;
(...skipping 3416 matching lines...) Expand 10 before | Expand all | Expand 10 after
4420 // Regression test for b/18594622 4399 // Regression test for b/18594622
4421 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); 4400 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate);
4422 EXPECT_DFATAL( 4401 EXPECT_DFATAL(
4423 connection_.SendStreamDataWithString(3, "", 0, !kFin, delegate.get()), 4402 connection_.SendStreamDataWithString(3, "", 0, !kFin, delegate.get()),
4424 "Attempt to send empty stream frame"); 4403 "Attempt to send empty stream frame");
4425 } 4404 }
4426 4405
4427 } // namespace 4406 } // namespace
4428 } // namespace test 4407 } // namespace test
4429 } // namespace net 4408 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/tcp_receiver_test.cc ('k') | net/quic/quic_http_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698