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

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

Issue 2322233004: Landing Recent QUIC changes until Sun Sep 4 03:41:00 (Closed)
Patch Set: Remove simulation files from the build. Created 4 years, 3 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/core/quic_connection.cc ('k') | net/quic/core/quic_crypto_client_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/core/quic_connection.h" 5 #include "net/quic/core/quic_connection.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <memory> 8 #include <memory>
9 #include <ostream> 9 #include <ostream>
10 #include <utility> 10 #include <utility>
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 QuicVersion version) 469 QuicVersion version)
470 : QuicConnection(connection_id, 470 : QuicConnection(connection_id,
471 address, 471 address,
472 helper, 472 helper,
473 alarm_factory, 473 alarm_factory,
474 writer, 474 writer,
475 /* owns_writer= */ false, 475 /* owns_writer= */ false,
476 perspective, 476 perspective,
477 SupportedVersions(version)) { 477 SupportedVersions(version)) {
478 writer->set_perspective(perspective); 478 writer->set_perspective(perspective);
479 SetEncrypter(ENCRYPTION_FORWARD_SECURE, new NullEncrypter());
479 } 480 }
480 481
481 void SendAck() { QuicConnectionPeer::SendAck(this); } 482 void SendAck() { QuicConnectionPeer::SendAck(this); }
482 483
483 void SetSendAlgorithm(QuicPathId path_id, 484 void SetSendAlgorithm(QuicPathId path_id,
484 SendAlgorithmInterface* send_algorithm) { 485 SendAlgorithmInterface* send_algorithm) {
485 QuicConnectionPeer::SetSendAlgorithm(this, path_id, send_algorithm); 486 QuicConnectionPeer::SetSendAlgorithm(this, path_id, send_algorithm);
486 } 487 }
487 488
488 void SetLossAlgorithm(QuicPathId path_id, 489 void SetLossAlgorithm(QuicPathId path_id,
(...skipping 24 matching lines...) Expand all
513 } 514 }
514 OnSerializedPacket(&serialized_packet); 515 OnSerializedPacket(&serialized_packet);
515 } 516 }
516 517
517 QuicConsumedData SendStreamDataWithString( 518 QuicConsumedData SendStreamDataWithString(
518 QuicStreamId id, 519 QuicStreamId id,
519 StringPiece data, 520 StringPiece data,
520 QuicStreamOffset offset, 521 QuicStreamOffset offset,
521 bool fin, 522 bool fin,
522 QuicAckListenerInterface* listener) { 523 QuicAckListenerInterface* listener) {
524 if (id != kCryptoStreamId && this->encryption_level() == ENCRYPTION_NONE) {
525 this->SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE);
526 }
523 struct iovec iov; 527 struct iovec iov;
524 QuicIOVector data_iov(MakeIOVector(data, &iov)); 528 QuicIOVector data_iov(MakeIOVector(data, &iov));
525 return QuicConnection::SendStreamData(id, data_iov, offset, fin, listener); 529 return QuicConnection::SendStreamData(id, data_iov, offset, fin, listener);
526 } 530 }
527 531
528 QuicConsumedData SendStreamData3() { 532 QuicConsumedData SendStreamData3() {
529 return SendStreamDataWithString(kClientDataStreamId1, "food", 0, !kFin, 533 return SendStreamDataWithString(kClientDataStreamId1, "food", 0, !kFin,
530 nullptr); 534 nullptr);
531 } 535 }
532 536
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 EXPECT_CALL(visitor_, OnCanWrite()).Times(AnyNumber()); 743 EXPECT_CALL(visitor_, OnCanWrite()).Times(AnyNumber());
740 EXPECT_CALL(visitor_, PostProcessAfterData()).Times(AnyNumber()); 744 EXPECT_CALL(visitor_, PostProcessAfterData()).Times(AnyNumber());
741 EXPECT_CALL(visitor_, HasOpenDynamicStreams()) 745 EXPECT_CALL(visitor_, HasOpenDynamicStreams())
742 .WillRepeatedly(Return(false)); 746 .WillRepeatedly(Return(false));
743 EXPECT_CALL(visitor_, OnCongestionWindowChange(_)).Times(AnyNumber()); 747 EXPECT_CALL(visitor_, OnCongestionWindowChange(_)).Times(AnyNumber());
744 748
745 EXPECT_CALL(*loss_algorithm_, GetLossTimeout()) 749 EXPECT_CALL(*loss_algorithm_, GetLossTimeout())
746 .WillRepeatedly(Return(QuicTime::Zero())); 750 .WillRepeatedly(Return(QuicTime::Zero()));
747 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _, _)) 751 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _, _))
748 .Times(AnyNumber()); 752 .Times(AnyNumber());
749 // TODO(ianswett): Fix QuicConnectionTests so they don't attempt to write
750 // non-crypto stream data at ENCRYPTION_NONE.
751 FLAGS_quic_never_write_unencrypted_data = false;
752 } 753 }
753 754
754 QuicVersion version() { return GetParam().version; } 755 QuicVersion version() { return GetParam().version; }
755 756
756 QuicAckFrame* outgoing_ack() { 757 QuicAckFrame* outgoing_ack() {
757 QuicFrame ack_frame = QuicConnectionPeer::GetUpdatedAckFrame(&connection_); 758 QuicFrame ack_frame = QuicConnectionPeer::GetUpdatedAckFrame(&connection_);
758 ack_ = *ack_frame.ack_frame; 759 ack_ = *ack_frame.ack_frame;
759 return &ack_; 760 return &ack_;
760 } 761 }
761 762
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 connection_.ProcessUdpPacket( 802 connection_.ProcessUdpPacket(
802 self_address, peer_address, 803 self_address, peer_address,
803 QuicReceivedPacket(serialized_packet.encrypted_buffer, 804 QuicReceivedPacket(serialized_packet.encrypted_buffer,
804 serialized_packet.encrypted_length, clock_.Now())); 805 serialized_packet.encrypted_length, clock_.Now()));
805 if (connection_.GetSendAlarm()->IsSet()) { 806 if (connection_.GetSendAlarm()->IsSet()) {
806 connection_.GetSendAlarm()->Fire(); 807 connection_.GetSendAlarm()->Fire();
807 } 808 }
808 return serialized_packet.entropy_hash; 809 return serialized_packet.entropy_hash;
809 } 810 }
810 811
812 // Bypassing the packet creator is unrealistic, but allows us to process
813 // packets the QuicPacketCreator won't allow us to create.
814 void ForceProcessFramePacket(QuicFrame frame) {
815 QuicFrames frames;
816 frames.push_back(QuicFrame(frame));
817 QuicPacketCreatorPeer::SetSendVersionInPacket(
818 &peer_creator_, connection_.perspective() == Perspective::IS_SERVER);
819 QuicPacketHeader header;
820 QuicPacketCreatorPeer::FillPacketHeader(&peer_creator_, &header);
821 char encrypted_buffer[kMaxPacketSize];
822 size_t length = peer_framer_.BuildDataPacket(
823 header, frames, encrypted_buffer, kMaxPacketSize);
824 DCHECK_GT(length, 0u);
825
826 const size_t encrypted_length = peer_framer_.EncryptInPlace(
827 ENCRYPTION_NONE, kDefaultPathId, header.packet_number,
828 GetStartOfEncryptedData(peer_framer_.version(), header), length,
829 kMaxPacketSize, encrypted_buffer);
830 DCHECK_GT(encrypted_length, 0u);
831
832 connection_.ProcessUdpPacket(
833 kSelfAddress, kPeerAddress,
834 QuicReceivedPacket(encrypted_buffer, encrypted_length, clock_.Now()));
835 }
836
811 QuicPacketEntropyHash ProcessFramePacketAtLevel(QuicPathId path_id, 837 QuicPacketEntropyHash ProcessFramePacketAtLevel(QuicPathId path_id,
812 QuicPacketNumber number, 838 QuicPacketNumber number,
813 QuicFrame frame, 839 QuicFrame frame,
814 EncryptionLevel level) { 840 EncryptionLevel level) {
815 QuicPacketHeader header; 841 QuicPacketHeader header;
816 header.public_header.connection_id = connection_id_; 842 header.public_header.connection_id = connection_id_;
817 header.public_header.packet_number_length = packet_number_length_; 843 header.public_header.packet_number_length = packet_number_length_;
818 header.public_header.connection_id_length = connection_id_length_; 844 header.public_header.connection_id_length = connection_id_length_;
819 header.public_header.multipath_flag = path_id != kDefaultPathId; 845 header.public_header.multipath_flag = path_id != kDefaultPathId;
820 header.path_id = path_id; 846 header.path_id = path_id;
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
1496 // Should ack immediately since we have missing packets. 1522 // Should ack immediately since we have missing packets.
1497 EXPECT_EQ(2u, writer_->packets_write_attempts()); 1523 EXPECT_EQ(2u, writer_->packets_write_attempts());
1498 1524
1499 ProcessAckPacket(1, &ack1); 1525 ProcessAckPacket(1, &ack1);
1500 // Should not ack an ack filling a missing packet. 1526 // Should not ack an ack filling a missing packet.
1501 EXPECT_EQ(2u, writer_->packets_write_attempts()); 1527 EXPECT_EQ(2u, writer_->packets_write_attempts());
1502 } 1528 }
1503 1529
1504 TEST_P(QuicConnectionTest, AckReceiptCausesAckSend) { 1530 TEST_P(QuicConnectionTest, AckReceiptCausesAckSend) {
1505 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 1531 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
1506
1507 QuicPacketNumber original; 1532 QuicPacketNumber original;
1508 QuicByteCount packet_size; 1533 QuicByteCount packet_size;
1509 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 1534 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
1510 .WillOnce( 1535 .WillOnce(
1511 DoAll(SaveArg<2>(&original), SaveArg<3>(&packet_size), Return(true))); 1536 DoAll(SaveArg<2>(&original), SaveArg<3>(&packet_size), Return(true)));
1512 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); 1537 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr);
1513 QuicAckFrame frame = InitAckFrame(original); 1538 QuicAckFrame frame = InitAckFrame(original);
1514 NackPacket(original, &frame); 1539 NackPacket(original, &frame);
1515 // First nack triggers early retransmit. 1540 // First nack triggers early retransmit.
1516 SendAlgorithmInterface::CongestionVector lost_packets; 1541 SendAlgorithmInterface::CongestionVector lost_packets;
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1909 connection_.OnCanWrite(); 1934 connection_.OnCanWrite();
1910 EXPECT_EQ(0u, connection_.NumQueuedPackets()); 1935 EXPECT_EQ(0u, connection_.NumQueuedPackets());
1911 1936
1912 // Parse the last packet and ensure it's one stream frame from one stream. 1937 // Parse the last packet and ensure it's one stream frame from one stream.
1913 EXPECT_EQ(1u, writer_->frame_count()); 1938 EXPECT_EQ(1u, writer_->frame_count());
1914 EXPECT_EQ(1u, writer_->stream_frames().size()); 1939 EXPECT_EQ(1u, writer_->stream_frames().size());
1915 EXPECT_EQ(1u, writer_->stream_frames()[0]->stream_id); 1940 EXPECT_EQ(1u, writer_->stream_frames()[0]->stream_id);
1916 } 1941 }
1917 1942
1918 TEST_P(QuicConnectionTest, SendingZeroBytes) { 1943 TEST_P(QuicConnectionTest, SendingZeroBytes) {
1944 connection_.SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE);
1919 // Send a zero byte write with a fin using writev. 1945 // Send a zero byte write with a fin using writev.
1920 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); 1946 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
1921 QuicIOVector empty_iov(nullptr, 0, 0); 1947 QuicIOVector empty_iov(nullptr, 0, 0);
1922 connection_.SendStreamData(kHeadersStreamId, empty_iov, 0, kFin, nullptr); 1948 connection_.SendStreamData(kHeadersStreamId, empty_iov, 0, kFin, nullptr);
1923 1949
1924 EXPECT_EQ(0u, connection_.NumQueuedPackets()); 1950 EXPECT_EQ(0u, connection_.NumQueuedPackets());
1925 EXPECT_FALSE(connection_.HasQueuedData()); 1951 EXPECT_FALSE(connection_.HasQueuedData());
1926 1952
1927 // Parse the last packet and ensure it's one stream frame from one stream. 1953 // Parse the last packet and ensure it's one stream frame from one stream.
1928 EXPECT_EQ(1u, writer_->frame_count()); 1954 EXPECT_EQ(1u, writer_->frame_count());
1929 EXPECT_EQ(1u, writer_->stream_frames().size()); 1955 EXPECT_EQ(1u, writer_->stream_frames().size());
1930 EXPECT_EQ(kHeadersStreamId, writer_->stream_frames()[0]->stream_id); 1956 EXPECT_EQ(kHeadersStreamId, writer_->stream_frames()[0]->stream_id);
1931 EXPECT_TRUE(writer_->stream_frames()[0]->fin); 1957 EXPECT_TRUE(writer_->stream_frames()[0]->fin);
1932 } 1958 }
1933 1959
1934 TEST_P(QuicConnectionTest, LargeSendWithPendingAck) { 1960 TEST_P(QuicConnectionTest, LargeSendWithPendingAck) {
1961 connection_.SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE);
1935 // Set the ack alarm by processing a ping frame. 1962 // Set the ack alarm by processing a ping frame.
1936 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 1963 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
1937 1964
1938 // Processs a PING frame. 1965 // Processs a PING frame.
1939 ProcessFramePacket(QuicFrame(QuicPingFrame())); 1966 ProcessFramePacket(QuicFrame(QuicPingFrame()));
1940 // Ensure that this has caused the ACK alarm to be set. 1967 // Ensure that this has caused the ACK alarm to be set.
1941 QuicAlarm* ack_alarm = QuicConnectionPeer::GetAckAlarm(&connection_); 1968 QuicAlarm* ack_alarm = QuicConnectionPeer::GetAckAlarm(&connection_);
1942 EXPECT_TRUE(ack_alarm->IsSet()); 1969 EXPECT_TRUE(ack_alarm->IsSet());
1943 1970
1944 // Send data and ensure the ack is bundled. 1971 // Send data and ensure the ack is bundled.
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
2511 connection_.GetRetransmissionAlarm()->deadline()); 2538 connection_.GetRetransmissionAlarm()->deadline());
2512 // Simulate the retransmission alarm firing. 2539 // Simulate the retransmission alarm firing.
2513 clock_.AdvanceTime(DefaultRetransmissionTime()); 2540 clock_.AdvanceTime(DefaultRetransmissionTime());
2514 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 2u, _, _)); 2541 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 2u, _, _));
2515 connection_.GetRetransmissionAlarm()->Fire(); 2542 connection_.GetRetransmissionAlarm()->Fire();
2516 EXPECT_EQ(2u, writer_->header().packet_number); 2543 EXPECT_EQ(2u, writer_->header().packet_number);
2517 // We do not raise the high water mark yet. 2544 // We do not raise the high water mark yet.
2518 EXPECT_EQ(1u, stop_waiting()->least_unacked); 2545 EXPECT_EQ(1u, stop_waiting()->least_unacked);
2519 } 2546 }
2520 2547
2521 TEST_P(QuicConnectionTest, RTOWithSameEncryptionLevel) { 2548 TEST_P(QuicConnectionTest, RetransmitWithSameEncryptionLevel) {
2522 connection_.SetMaxTailLossProbes(kDefaultPathId, 0);
2523
2524 QuicTime default_retransmission_time =
2525 clock_.ApproximateNow() + DefaultRetransmissionTime();
2526 use_tagging_decrypter(); 2549 use_tagging_decrypter();
2527 2550
2528 // A TaggingEncrypter puts kTagSize copies of the given byte (0x01 here) at 2551 // A TaggingEncrypter puts kTagSize copies of the given byte (0x01 here) at
2529 // the end of the packet. We can test this to check which encrypter was used. 2552 // the end of the packet. We can test this to check which encrypter was used.
2530 connection_.SetEncrypter(ENCRYPTION_NONE, new TaggingEncrypter(0x01)); 2553 connection_.SetEncrypter(ENCRYPTION_NONE, new TaggingEncrypter(0x01));
2531 SendStreamDataToPeer(3, "foo", 0, !kFin, nullptr); 2554 SendStreamDataToPeer(kCryptoStreamId, "foo", 0, !kFin, nullptr);
2532 EXPECT_EQ(0x01010101u, writer_->final_bytes_of_last_packet()); 2555 EXPECT_EQ(0x01010101u, writer_->final_bytes_of_last_packet());
2533 2556
2534 connection_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(0x02)); 2557 connection_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(0x02));
2535 connection_.SetDefaultEncryptionLevel(ENCRYPTION_INITIAL); 2558 connection_.SetDefaultEncryptionLevel(ENCRYPTION_INITIAL);
2536 SendStreamDataToPeer(3, "foo", 0, !kFin, nullptr); 2559 SendStreamDataToPeer(3, "foo", 0, !kFin, nullptr);
2537 EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet()); 2560 EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet());
2538 2561
2539 EXPECT_EQ(default_retransmission_time,
2540 connection_.GetRetransmissionAlarm()->deadline());
2541 { 2562 {
2542 InSequence s; 2563 InSequence s;
2543 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 3, _, _)); 2564 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 3, _, _));
2544 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 4, _, _)); 2565 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 4, _, _));
2545 } 2566 }
2546 2567
2547 // Simulate the retransmission alarm firing. 2568 // Manually mark both packets for retransmission.
2548 clock_.AdvanceTime(DefaultRetransmissionTime()); 2569 connection_.RetransmitUnackedPackets(ALL_UNACKED_RETRANSMISSION);
2549 connection_.GetRetransmissionAlarm()->Fire();
2550 2570
2551 // Packet should have been sent with ENCRYPTION_NONE. 2571 // Packet should have been sent with ENCRYPTION_NONE.
2552 EXPECT_EQ(0x01010101u, writer_->final_bytes_of_previous_packet()); 2572 EXPECT_EQ(0x01010101u, writer_->final_bytes_of_previous_packet());
2553 2573
2554 // Packet should have been sent with ENCRYPTION_INITIAL. 2574 // Packet should have been sent with ENCRYPTION_INITIAL.
2555 EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet()); 2575 EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet());
2556 } 2576 }
2557 2577
2558 TEST_P(QuicConnectionTest, SendHandshakeMessages) { 2578 TEST_P(QuicConnectionTest, SendHandshakeMessages) {
2559 use_tagging_decrypter(); 2579 use_tagging_decrypter();
(...skipping 21 matching lines...) Expand all
2581 2601
2582 // Verify that the handshake packet went out at the null encryption. 2602 // Verify that the handshake packet went out at the null encryption.
2583 EXPECT_EQ(0x01010101u, writer_->final_bytes_of_last_packet()); 2603 EXPECT_EQ(0x01010101u, writer_->final_bytes_of_last_packet());
2584 } 2604 }
2585 2605
2586 TEST_P(QuicConnectionTest, 2606 TEST_P(QuicConnectionTest,
2587 DropRetransmitsForNullEncryptedPacketAfterForwardSecure) { 2607 DropRetransmitsForNullEncryptedPacketAfterForwardSecure) {
2588 use_tagging_decrypter(); 2608 use_tagging_decrypter();
2589 connection_.SetEncrypter(ENCRYPTION_NONE, new TaggingEncrypter(0x01)); 2609 connection_.SetEncrypter(ENCRYPTION_NONE, new TaggingEncrypter(0x01));
2590 QuicPacketNumber packet_number; 2610 QuicPacketNumber packet_number;
2591 SendStreamDataToPeer(3, "foo", 0, !kFin, &packet_number); 2611 SendStreamDataToPeer(kCryptoStreamId, "foo", 0, !kFin, &packet_number);
2592 2612
2593 // Simulate the retransmission alarm firing and the socket blocking. 2613 // Simulate the retransmission alarm firing and the socket blocking.
2594 BlockOnNextWrite(); 2614 BlockOnNextWrite();
2595 clock_.AdvanceTime(DefaultRetransmissionTime()); 2615 clock_.AdvanceTime(DefaultRetransmissionTime());
2596 connection_.GetRetransmissionAlarm()->Fire(); 2616 connection_.GetRetransmissionAlarm()->Fire();
2597 2617
2598 // Go forward secure. 2618 // Go forward secure.
2599 connection_.SetEncrypter(ENCRYPTION_FORWARD_SECURE, 2619 connection_.SetEncrypter(ENCRYPTION_FORWARD_SECURE,
2600 new TaggingEncrypter(0x02)); 2620 new TaggingEncrypter(0x02));
2601 connection_.SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); 2621 connection_.SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE);
(...skipping 2437 matching lines...) Expand 10 before | Expand all | Expand 10 after
5039 } 5059 }
5040 5060
5041 TEST_P(QuicConnectionTest, SendPingImmediately) { 5061 TEST_P(QuicConnectionTest, SendPingImmediately) {
5042 CongestionBlockWrites(); 5062 CongestionBlockWrites();
5043 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); 5063 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
5044 connection_.SendPing(); 5064 connection_.SendPing();
5045 EXPECT_FALSE(connection_.HasQueuedData()); 5065 EXPECT_FALSE(connection_.HasQueuedData());
5046 } 5066 }
5047 5067
5048 TEST_P(QuicConnectionTest, SendingUnencryptedStreamDataFails) { 5068 TEST_P(QuicConnectionTest, SendingUnencryptedStreamDataFails) {
5049 FLAGS_quic_never_write_unencrypted_data = true;
5050 EXPECT_CALL(visitor_, 5069 EXPECT_CALL(visitor_,
5051 OnConnectionClosed(QUIC_ATTEMPT_TO_SEND_UNENCRYPTED_STREAM_DATA, 5070 OnConnectionClosed(QUIC_ATTEMPT_TO_SEND_UNENCRYPTED_STREAM_DATA,
5052 _, ConnectionCloseSource::FROM_SELF)); 5071 _, ConnectionCloseSource::FROM_SELF));
5053 EXPECT_QUIC_BUG(connection_.SendStreamDataWithString(3, "", 0, kFin, nullptr), 5072 struct iovec iov;
5073 QuicIOVector data_iov(MakeIOVector("", &iov));
5074 EXPECT_QUIC_BUG(connection_.SendStreamData(3, data_iov, 0, kFin, nullptr),
5054 "Cannot send stream data without encryption."); 5075 "Cannot send stream data without encryption.");
5055 EXPECT_FALSE(connection_.connected()); 5076 EXPECT_FALSE(connection_.connected());
5056 } 5077 }
5057 5078
5058 TEST_P(QuicConnectionTest, EnableMultipathNegotiation) { 5079 TEST_P(QuicConnectionTest, EnableMultipathNegotiation) {
5059 // Test multipath negotiation during crypto handshake. Multipath is enabled 5080 // Test multipath negotiation during crypto handshake. Multipath is enabled
5060 // when both endpoints enable multipath. 5081 // when both endpoints enable multipath.
5061 FLAGS_quic_enable_multipath = true; 5082 FLAGS_quic_enable_multipath = true;
5062 EXPECT_TRUE(connection_.connected()); 5083 EXPECT_TRUE(connection_.connected());
5063 EXPECT_FALSE(QuicConnectionPeer::IsMultipathEnabled(&connection_)); 5084 EXPECT_FALSE(QuicConnectionPeer::IsMultipathEnabled(&connection_));
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
5151 CryptoHandshakeMessage message; 5172 CryptoHandshakeMessage message;
5152 CryptoFramer framer; 5173 CryptoFramer framer;
5153 message.set_tag(kCHLO); 5174 message.set_tag(kCHLO);
5154 std::unique_ptr<QuicData> data(framer.ConstructHandshakeMessage(message)); 5175 std::unique_ptr<QuicData> data(framer.ConstructHandshakeMessage(message));
5155 frame1_.stream_id = 10; 5176 frame1_.stream_id = 10;
5156 frame1_.data_buffer = data->data(); 5177 frame1_.data_buffer = data->data();
5157 frame1_.data_length = data->length(); 5178 frame1_.data_length = data->length();
5158 5179
5159 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_MAYBE_CORRUPTED_MEMORY, _, 5180 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_MAYBE_CORRUPTED_MEMORY, _,
5160 ConnectionCloseSource::FROM_SELF)); 5181 ConnectionCloseSource::FROM_SELF));
5161 ProcessFramePacket(QuicFrame(&frame1_)); 5182 ForceProcessFramePacket(QuicFrame(&frame1_));
5162 } 5183 }
5163 5184
5164 TEST_P(QuicConnectionTest, ClientReceivesRejOnNonCryptoStream) { 5185 TEST_P(QuicConnectionTest, ClientReceivesRejOnNonCryptoStream) {
5165 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 5186 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
5166 5187
5167 CryptoHandshakeMessage message; 5188 CryptoHandshakeMessage message;
5168 CryptoFramer framer; 5189 CryptoFramer framer;
5169 message.set_tag(kREJ); 5190 message.set_tag(kREJ);
5170 std::unique_ptr<QuicData> data(framer.ConstructHandshakeMessage(message)); 5191 std::unique_ptr<QuicData> data(framer.ConstructHandshakeMessage(message));
5171 frame1_.stream_id = 10; 5192 frame1_.stream_id = 10;
5172 frame1_.data_buffer = data->data(); 5193 frame1_.data_buffer = data->data();
5173 frame1_.data_length = data->length(); 5194 frame1_.data_length = data->length();
5174 5195
5175 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_MAYBE_CORRUPTED_MEMORY, _, 5196 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_MAYBE_CORRUPTED_MEMORY, _,
5176 ConnectionCloseSource::FROM_SELF)); 5197 ConnectionCloseSource::FROM_SELF));
5177 ProcessFramePacket(QuicFrame(&frame1_)); 5198 ForceProcessFramePacket(QuicFrame(&frame1_));
5178 } 5199 }
5179 5200
5180 TEST_P(QuicConnectionTest, CloseConnectionOnPacketTooLarge) { 5201 TEST_P(QuicConnectionTest, CloseConnectionOnPacketTooLarge) {
5181 FLAGS_quic_close_connection_on_packet_too_large = true; 5202 FLAGS_quic_close_connection_on_packet_too_large = true;
5182 SimulateNextPacketTooLarge(); 5203 SimulateNextPacketTooLarge();
5183 // Although the data packet cannot be written, the send packet manager is 5204 // Although the data packet cannot be written, the send packet manager is
5184 // informed. Also a connection close packet is sent. 5205 // informed. Also a connection close packet is sent.
5185 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2); 5206 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2);
5186 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PACKET_WRITE_ERROR, _, 5207 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PACKET_WRITE_ERROR, _,
5187 ConnectionCloseSource::FROM_SELF)) 5208 ConnectionCloseSource::FROM_SELF))
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
5279 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); 5300 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr);
5280 EXPECT_EQ(1u, writer_->frame_count()); 5301 EXPECT_EQ(1u, writer_->frame_count());
5281 EXPECT_FALSE(writer_->connection_close_frames().empty()); 5302 EXPECT_FALSE(writer_->connection_close_frames().empty());
5282 // Ack frame is not bundled in connection close packet. 5303 // Ack frame is not bundled in connection close packet.
5283 EXPECT_TRUE(writer_->ack_frames().empty()); 5304 EXPECT_TRUE(writer_->ack_frames().empty());
5284 } 5305 }
5285 5306
5286 } // namespace 5307 } // namespace
5287 } // namespace test 5308 } // namespace test
5288 } // namespace net 5309 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_connection.cc ('k') | net/quic/core/quic_crypto_client_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698