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

Unified Diff: webrtc/p2p/quic/quictransportchannel_unittest.cc

Issue 1856513002: Add QuicTransportChannel methods for QUIC streams (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/p2p/quic/quictransportchannel.cc ('k') | webrtc/p2p/quic/reliablequicstream.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/quic/quictransportchannel_unittest.cc
diff --git a/webrtc/p2p/quic/quictransportchannel_unittest.cc b/webrtc/p2p/quic/quictransportchannel_unittest.cc
index 7b5b51848aae75da9cfa4964ea2bee289e33e925..cc8b0c17fe03e42abee1766e458343af6a894f1f 100644
--- a/webrtc/p2p/quic/quictransportchannel_unittest.cc
+++ b/webrtc/p2p/quic/quictransportchannel_unittest.cc
@@ -23,6 +23,7 @@
using cricket::ConnectionRole;
using cricket::IceRole;
using cricket::QuicTransportChannel;
+using cricket::ReliableQuicStream;
using cricket::TransportChannel;
using cricket::TransportDescription;
@@ -97,6 +98,9 @@ class QuicTestPeer : public sigslot::has_slots<> {
quic_channel_(&ice_channel_) {
quic_channel_.SignalReadPacket.connect(
this, &QuicTestPeer::OnTransportChannelReadPacket);
+ quic_channel_.SignalIncomingStream.connect(this,
+ &QuicTestPeer::OnIncomingStream);
+ quic_channel_.SignalClosed.connect(this, &QuicTestPeer::OnClosed);
ice_channel_.SetAsync(true);
rtc::scoped_refptr<rtc::RTCCertificate> local_cert =
rtc::RTCCertificate::Create(rtc::scoped_ptr<rtc::SSLIdentity>(
@@ -198,8 +202,12 @@ class QuicTestPeer : public sigslot::has_slots<> {
return local_fingerprint_;
}
+ ReliableQuicStream* incoming_quic_stream() { return incoming_quic_stream_; }
+
+ bool signal_closed_emitted() const { return signal_closed_emitted_; }
+
private:
- // QUIC channel callback.
+ // QuicTransportChannel callbacks.
void OnTransportChannelReadPacket(TransportChannel* channel,
const char* data,
size_t size,
@@ -210,6 +218,10 @@ class QuicTestPeer : public sigslot::has_slots<> {
int expected_flags = IsRtpLeadByte(data[0]) ? cricket::PF_SRTP_BYPASS : 0;
ASSERT_EQ(expected_flags, flags);
}
+ void OnIncomingStream(ReliableQuicStream* stream) {
+ incoming_quic_stream_ = stream;
+ }
+ void OnClosed() { signal_closed_emitted_ = true; }
std::string name_; // Channel name.
size_t bytes_sent_; // Bytes sent by QUIC channel.
@@ -217,6 +229,8 @@ class QuicTestPeer : public sigslot::has_slots<> {
FailableTransportChannel ice_channel_; // Simulates an ICE channel.
QuicTransportChannel quic_channel_; // QUIC channel to test.
rtc::scoped_ptr<rtc::SSLFingerprint> local_fingerprint_;
+ ReliableQuicStream* incoming_quic_stream_ = nullptr;
+ bool signal_closed_emitted_ = false;
};
class QuicTransportChannelTest : public testing::Test {
@@ -486,3 +500,28 @@ TEST_F(QuicTransportChannelTest, IceReceivingBeforeConnected) {
ASSERT_TRUE_WAIT(quic_connected(), kTimeoutMs);
EXPECT_TRUE(peer1_.quic_channel()->receiving());
}
+
+// Test that when peer 1 creates an outgoing stream, peer 2 creates an incoming
+// QUIC stream with the same ID and fires OnIncomingStream.
+TEST_F(QuicTransportChannelTest, CreateOutgoingAndIncomingQuicStream) {
+ Connect();
+ EXPECT_EQ(nullptr, peer1_.quic_channel()->CreateQuicStream());
+ ASSERT_TRUE_WAIT(quic_connected(), kTimeoutMs);
+ ReliableQuicStream* stream = peer1_.quic_channel()->CreateQuicStream();
+ ASSERT_NE(nullptr, stream);
+ stream->Write("Hi", 2);
+ EXPECT_TRUE_WAIT(peer2_.incoming_quic_stream() != nullptr, kTimeoutMs);
+ EXPECT_EQ(stream->id(), peer2_.incoming_quic_stream()->id());
+}
+
+// Test that SignalClosed is emitted when the QuicConnection closes.
+TEST_F(QuicTransportChannelTest, SignalClosedEmmitted) {
Taylor Brandstetter 2016/04/05 22:19:35 Emmitted => Emitted
mikescarlett 2016/04/06 17:31:54 Done.
+ Connect();
+ ASSERT_TRUE_WAIT(quic_connected(), kTimeoutMs);
+ ASSERT_FALSE(peer1_.signal_closed_emitted());
+ ReliableQuicStream* stream = peer1_.quic_channel()->CreateQuicStream();
+ ASSERT_NE(nullptr, stream);
+ stream->CloseConnectionWithDetails(net::QuicErrorCode::QUIC_NO_ERROR,
+ "Closing QUIC for testing");
+ ASSERT_TRUE(peer1_.signal_closed_emitted());
+}
Taylor Brandstetter 2016/04/05 22:19:35 Should this also wait for peer2_signal_closed_emit
mikescarlett 2016/04/06 17:31:54 Yes it should. Fixed.
« no previous file with comments | « webrtc/p2p/quic/quictransportchannel.cc ('k') | webrtc/p2p/quic/reliablequicstream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698