diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/modules/peerconnection/adapters/p2p_quic_stream_unittest.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/modules/peerconnection/adapters/p2p_quic_stream_unittest.cc | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/chromium/third_party/blink/renderer/modules/peerconnection/adapters/p2p_quic_stream_unittest.cc b/chromium/third_party/blink/renderer/modules/peerconnection/adapters/p2p_quic_stream_unittest.cc index 0a36ce345dc..d3c03c73186 100644 --- a/chromium/third_party/blink/renderer/modules/peerconnection/adapters/p2p_quic_stream_unittest.cc +++ b/chromium/third_party/blink/renderer/modules/peerconnection/adapters/p2p_quic_stream_unittest.cc @@ -439,4 +439,64 @@ TEST_F(P2PQuicStreamTest, StreamReceivesMoreDataThanDelegateReadBufferSize) { // Just the last data received ("ta") is held in the delegate's read buffer. EXPECT_EQ(2u, stream_->DelegateReadBufferedAmountForTesting()); } + +// Tests that after a delegate unsets itself, it will no longer receive the +// OnWriteDataConsumed callback. +TEST_F(P2PQuicStreamTest, UnsetDelegateDoesNotFireOnWriteDataConsumed) { + InitializeStream(); + stream_->SetDelegate(nullptr); + // Mock out the QuicSession to get the QuicStream::OnStreamDataConsumed + // callback to fire. + EXPECT_CALL(session_, + WritevData(stream_, kStreamId, + /*write_length=*/base::size(kSomeData), _, _)) + .WillOnce(Invoke([](quic::QuicStream* stream, quic::QuicStreamId id, + size_t write_length, quic::QuicStreamOffset offset, + quic::StreamSendingState state) { + return quic::QuicConsumedData( + write_length, state != quic::StreamSendingState::NO_FIN); + })); + + EXPECT_CALL(delegate_, OnWriteDataConsumed(_)).Times(0); + + stream_->WriteData(VectorFromArray(kSomeData), /*fin=*/false); +} + +// Tests that after a delegate unsets itself, it will no longer receive the +// OnRemoteReset callback. +TEST_F(P2PQuicStreamTest, UnsetDelegateDoesNotFireOnRemoteReset) { + InitializeStream(); + stream_->SetDelegate(nullptr); + EXPECT_CALL(delegate_, OnRemoteReset()).Times(0); + + quic::QuicRstStreamFrame rst_frame(quic::kInvalidControlFrameId, kStreamId, + quic::QUIC_STREAM_CANCELLED, 0); + stream_->OnStreamReset(rst_frame); +} + +// Tests that after a delegate unsets itself, it will no longer receive the +// OnDataReceived callback when receiving a stream frame with data and no FIN +// bit. +TEST_F(P2PQuicStreamTest, UnsetDelegateDoesNotFireOnDataReceivedWithData) { + InitializeStream(); + stream_->SetDelegate(nullptr); + + EXPECT_CALL(delegate_, OnDataReceived(_, _)).Times(0); + + quic::QuicStreamFrame stream_frame(stream_->id(), /*fin=*/false, 0, + StringPieceFromArray(kSomeData)); + stream_->OnStreamFrame(stream_frame); +} + +// Tests that after a delegate unsets itself, it will no longer receive the +// OnDataReceived callback when receiving a stream frame with the FIN bit. +TEST_F(P2PQuicStreamTest, UnsetDelegateDoesNotFireOnDataReceivedWithFin) { + InitializeStream(); + stream_->SetDelegate(nullptr); + + EXPECT_CALL(delegate_, OnDataReceived(_, _)).Times(0); + + quic::QuicStreamFrame stream_frame(stream_->id(), /*fin=*/true, 0, {}); + stream_->OnStreamFrame(stream_frame); +} } // namespace blink |