Chromium Code Reviews| Index: webrtc/p2p/quic/quictransportchannel_unittest.cc |
| diff --git a/webrtc/p2p/quic/quictransportchannel_unittest.cc b/webrtc/p2p/quic/quictransportchannel_unittest.cc |
| index c64aa40f94f63f47973878904a16129461ffc4df..74f365fe0b4787bc3b79c3d81b3fd180d0bbfb00 100644 |
| --- a/webrtc/p2p/quic/quictransportchannel_unittest.cc |
| +++ b/webrtc/p2p/quic/quictransportchannel_unittest.cc |
| @@ -95,7 +95,8 @@ class QuicTestPeer : public sigslot::has_slots<> { |
| : name_(name), |
| bytes_sent_(0), |
| ice_channel_(name_, 0), |
| - quic_channel_(&ice_channel_) { |
| + quic_channel_(&ice_channel_), |
| + num_incoming_quic_streams_(0) { |
| quic_channel_.SignalReadPacket.connect( |
| this, &QuicTestPeer::OnTransportChannelReadPacket); |
| quic_channel_.SignalIncomingStream.connect(this, |
| @@ -204,6 +205,10 @@ class QuicTestPeer : public sigslot::has_slots<> { |
| ReliableQuicStream* incoming_quic_stream() { return incoming_quic_stream_; } |
| + size_t num_incoming_quic_streams() const { |
| + return num_incoming_quic_streams_; |
|
pthatcher1
2016/04/29 20:15:46
I'd prefer incoming_stream_count() and incoming_st
mikescarlett
2016/04/29 23:29:50
Done.
|
| + } |
| + |
| bool signal_closed_emitted() const { return signal_closed_emitted_; } |
| private: |
| @@ -220,6 +225,7 @@ class QuicTestPeer : public sigslot::has_slots<> { |
| } |
| void OnIncomingStream(ReliableQuicStream* stream) { |
| incoming_quic_stream_ = stream; |
| + ++num_incoming_quic_streams_; |
| } |
| void OnClosed() { signal_closed_emitted_ = true; } |
| @@ -230,6 +236,7 @@ class QuicTestPeer : public sigslot::has_slots<> { |
| QuicTransportChannel quic_channel_; // QUIC channel to test. |
| rtc::scoped_ptr<rtc::SSLFingerprint> local_fingerprint_; |
| ReliableQuicStream* incoming_quic_stream_ = nullptr; |
| + size_t num_incoming_quic_streams_; |
| bool signal_closed_emitted_ = false; |
| }; |
| @@ -514,6 +521,39 @@ TEST_F(QuicTransportChannelTest, CreateOutgoingAndIncomingQuicStream) { |
| EXPECT_EQ(stream->id(), peer2_.incoming_quic_stream()->id()); |
| } |
| +// Test that if the QuicTransportChannel is unwritable, then all outgoing QUIC |
| +// streams can send data once the QuicTransprotChannel becomes writable again. |
| +TEST_F(QuicTransportChannelTest, OutgoingQuicStreamSendsDataAfterReconnect) { |
| + Connect(); |
| + ASSERT_TRUE_WAIT(quic_connected(), kTimeoutMs); |
| + ReliableQuicStream* stream1 = peer1_.quic_channel()->CreateQuicStream(); |
| + ASSERT_NE(nullptr, stream1); |
| + ReliableQuicStream* stream2 = peer1_.quic_channel()->CreateQuicStream(); |
| + ASSERT_NE(nullptr, stream2); |
| + ReliableQuicStream* stream3 = peer1_.quic_channel()->CreateQuicStream(); |
| + ASSERT_NE(nullptr, stream3); |
| + ReliableQuicStream* stream4 = peer1_.quic_channel()->CreateQuicStream(); |
| + ASSERT_NE(nullptr, stream4); |
|
pthatcher1
2016/04/29 20:15:47
Why do we need 4 streams for this? Isn't 1 or 2 e
mikescarlett
2016/04/29 23:29:50
2 is fine. I agree 4 is redundant but wanted to te
|
| + |
| + peer1_.ice_channel()->SetWritable(false); |
| + stream1->Write("First", 5); |
| + EXPECT_EQ(5u, stream1->queued_data_bytes()); |
| + stream2->Write("Second", 6); |
| + EXPECT_EQ(6u, stream2->queued_data_bytes()); |
| + stream3->Write("Third", 5); |
| + EXPECT_EQ(5u, stream3->queued_data_bytes()); |
| + stream4->Write("Fourth", 6); |
| + EXPECT_EQ(6u, stream4->queued_data_bytes()); |
| + EXPECT_EQ(0u, peer2_.num_incoming_quic_streams()); |
| + |
| + peer1_.ice_channel()->SetWritable(true); |
| + EXPECT_EQ_WAIT(0u, stream1->queued_data_bytes(), kTimeoutMs); |
| + EXPECT_EQ_WAIT(0u, stream2->queued_data_bytes(), kTimeoutMs); |
| + EXPECT_EQ_WAIT(0u, stream3->queued_data_bytes(), kTimeoutMs); |
| + EXPECT_EQ_WAIT(0u, stream4->queued_data_bytes(), kTimeoutMs); |
| + EXPECT_EQ_WAIT(4u, peer2_.num_incoming_quic_streams(), kTimeoutMs); |
| +} |
| + |
| // Test that SignalClosed is emitted when the QuicConnection closes. |
| TEST_F(QuicTransportChannelTest, SignalClosedEmitted) { |
| Connect(); |