| 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 <ostream> | 7 #include <ostream> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 | 732 |
| 733 EXPECT_CALL(*loss_algorithm_, GetLossTimeout()) | 733 EXPECT_CALL(*loss_algorithm_, GetLossTimeout()) |
| 734 .WillRepeatedly(Return(QuicTime::Zero())); | 734 .WillRepeatedly(Return(QuicTime::Zero())); |
| 735 if (FLAGS_quic_general_loss_algorithm) { | 735 if (FLAGS_quic_general_loss_algorithm) { |
| 736 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) | 736 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)) |
| 737 .Times(AnyNumber()); | 737 .Times(AnyNumber()); |
| 738 } else { | 738 } else { |
| 739 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | 739 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
| 740 .WillRepeatedly(Return(PacketNumberSet())); | 740 .WillRepeatedly(Return(PacketNumberSet())); |
| 741 } | 741 } |
| 742 // TODO(ianswett): Fix QuicConnectionTests so they don't attempt to write |
| 743 // non-crypto stream data at ENCRYPTION_NONE. |
| 744 FLAGS_quic_never_write_unencrypted_data = false; |
| 742 } | 745 } |
| 743 | 746 |
| 744 QuicVersion version() { return GetParam().version; } | 747 QuicVersion version() { return GetParam().version; } |
| 745 | 748 |
| 746 QuicAckFrame* outgoing_ack() { | 749 QuicAckFrame* outgoing_ack() { |
| 747 QuicConnectionPeer::PopulateAckFrame(&connection_, &ack_); | 750 QuicConnectionPeer::PopulateAckFrame(&connection_, &ack_); |
| 748 return &ack_; | 751 return &ack_; |
| 749 } | 752 } |
| 750 | 753 |
| 751 QuicStopWaitingFrame* stop_waiting() { | 754 QuicStopWaitingFrame* stop_waiting() { |
| (...skipping 4746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5498 .WillRepeatedly(Return(QuicTime::Delta::FromMilliseconds(2))); | 5501 .WillRepeatedly(Return(QuicTime::Delta::FromMilliseconds(2))); |
| 5499 ProcessAckPacket(&ack); | 5502 ProcessAckPacket(&ack); |
| 5500 EXPECT_EQ(1u, writer_->frame_count()); | 5503 EXPECT_EQ(1u, writer_->frame_count()); |
| 5501 EXPECT_EQ(1u, writer_->stream_frames().size()); | 5504 EXPECT_EQ(1u, writer_->stream_frames().size()); |
| 5502 EXPECT_TRUE(connection_.GetSendAlarm()->IsSet()); | 5505 EXPECT_TRUE(connection_.GetSendAlarm()->IsSet()); |
| 5503 EXPECT_EQ(clock_.Now().Add(QuicTime::Delta::FromMilliseconds(2)), | 5506 EXPECT_EQ(clock_.Now().Add(QuicTime::Delta::FromMilliseconds(2)), |
| 5504 connection_.GetSendAlarm()->deadline()); | 5507 connection_.GetSendAlarm()->deadline()); |
| 5505 writer_->Reset(); | 5508 writer_->Reset(); |
| 5506 } | 5509 } |
| 5507 | 5510 |
| 5511 TEST_P(QuicConnectionTest, SendingUnencryptedStreamDataFails) { |
| 5512 FLAGS_quic_never_write_unencrypted_data = true; |
| 5513 EXPECT_CALL(visitor_, |
| 5514 OnConnectionClosed(QUIC_UNENCRYPTED_STREAM_DATA, false)); |
| 5515 EXPECT_DFATAL(connection_.SendStreamDataWithString(3, "", 0, kFin, nullptr), |
| 5516 "Cannot send stream data without encryption."); |
| 5517 EXPECT_FALSE(connection_.connected()); |
| 5518 } |
| 5519 |
| 5508 } // namespace | 5520 } // namespace |
| 5509 } // namespace test | 5521 } // namespace test |
| 5510 } // namespace net | 5522 } // namespace net |
| OLD | NEW |