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

Side by Side Diff: webrtc/p2p/quic/quictransportchannel_unittest.cc

Issue 2089553002: Refactoring on QUIC (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Split the CL Created 4 years, 5 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 | « webrtc/p2p/quic/quictransportchannel.cc ('k') | webrtc/p2p/quic/reliablequicstream_unittest.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 /* 1 /*
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 ice_channel_->SetAsync(true); 105 ice_channel_->SetAsync(true);
106 rtc::scoped_refptr<rtc::RTCCertificate> local_cert = 106 rtc::scoped_refptr<rtc::RTCCertificate> local_cert =
107 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>( 107 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>(
108 rtc::SSLIdentity::Generate(name_, rtc::KT_DEFAULT))); 108 rtc::SSLIdentity::Generate(name_, rtc::KT_DEFAULT)));
109 quic_channel_.SetLocalCertificate(local_cert); 109 quic_channel_.SetLocalCertificate(local_cert);
110 local_fingerprint_.reset(CreateFingerprint(local_cert.get())); 110 local_fingerprint_.reset(CreateFingerprint(local_cert.get()));
111 } 111 }
112 112
113 // Connects |ice_channel_| to that of the other peer. 113 // Connects |ice_channel_| to that of the other peer.
114 void Connect(QuicTestPeer* other_peer) { 114 void Connect(QuicTestPeer* other_peer) {
115 ice_channel_->Connect();
116 other_peer->ice_channel_->Connect();
117 ice_channel_->SetDestination(other_peer->ice_channel_); 115 ice_channel_->SetDestination(other_peer->ice_channel_);
118 } 116 }
119 117
120 // Disconnects |ice_channel_|. 118 // Disconnects |ice_channel_|.
121 void Disconnect() { ice_channel_->SetDestination(nullptr); } 119 void Disconnect() { ice_channel_->SetDestination(nullptr); }
122 120
123 // Generates ICE credentials and passes them to |quic_channel_|. 121 // Generates ICE credentials and passes them to |quic_channel_|.
124 void SetIceParameters(IceRole local_ice_role, 122 void SetIceParameters(IceRole local_ice_role,
125 ConnectionRole local_connection_role, 123 ConnectionRole local_connection_role,
126 ConnectionRole remote_connection_role, 124 ConnectionRole remote_connection_role,
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 Connect(); 410 Connect();
413 peer1_.ClearBytesSent(); 411 peer1_.ClearBytesSent();
414 peer2_.ClearBytesReceived(); 412 peer2_.ClearBytesReceived();
415 EXPECT_EQ(-1, peer1_.SendInvalidSrtpPacket()); 413 EXPECT_EQ(-1, peer1_.SendInvalidSrtpPacket());
416 EXPECT_EQ(0u, peer2_.bytes_received()); 414 EXPECT_EQ(0u, peer2_.bytes_received());
417 } 415 }
418 416
419 // Test that QuicTransportChannel::WritePacket blocks when the ICE 417 // Test that QuicTransportChannel::WritePacket blocks when the ICE
420 // channel is not writable, and otherwise succeeds. 418 // channel is not writable, and otherwise succeeds.
421 TEST_F(QuicTransportChannelTest, QuicWritePacket) { 419 TEST_F(QuicTransportChannelTest, QuicWritePacket) {
422 peer1_.ice_channel()->Connect();
423 peer2_.ice_channel()->Connect();
424 peer1_.ice_channel()->SetDestination(peer2_.ice_channel()); 420 peer1_.ice_channel()->SetDestination(peer2_.ice_channel());
425 std::string packet = "FAKEQUICPACKET"; 421 std::string packet = "FAKEQUICPACKET";
426 422
427 // QUIC should be write blocked when the ICE channel is not writable. 423 // QUIC should be write blocked when the ICE channel is not writable.
428 peer1_.ice_channel()->SetWritable(false); 424 peer1_.ice_channel()->SetWritable(false);
429 EXPECT_TRUE(peer1_.quic_channel()->IsWriteBlocked()); 425 EXPECT_TRUE(peer1_.quic_channel()->IsWriteBlocked());
430 net::WriteResult write_blocked_result = peer1_.quic_channel()->WritePacket( 426 net::WriteResult write_blocked_result = peer1_.quic_channel()->WritePacket(
431 packet.data(), packet.size(), kIpAddress, kIpEndpoint, nullptr); 427 packet.data(), packet.size(), kIpAddress, kIpEndpoint, nullptr);
432 EXPECT_EQ(net::WRITE_STATUS_BLOCKED, write_blocked_result.status); 428 EXPECT_EQ(net::WRITE_STATUS_BLOCKED, write_blocked_result.status);
433 EXPECT_EQ(EWOULDBLOCK, write_blocked_result.error_code); 429 EXPECT_EQ(EWOULDBLOCK, write_blocked_result.error_code);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 Connect(); 543 Connect();
548 ASSERT_TRUE_WAIT(quic_connected(), kTimeoutMs); 544 ASSERT_TRUE_WAIT(quic_connected(), kTimeoutMs);
549 ASSERT_FALSE(peer1_.signal_closed_emitted()); 545 ASSERT_FALSE(peer1_.signal_closed_emitted());
550 ReliableQuicStream* stream = peer1_.quic_channel()->CreateQuicStream(); 546 ReliableQuicStream* stream = peer1_.quic_channel()->CreateQuicStream();
551 ASSERT_NE(nullptr, stream); 547 ASSERT_NE(nullptr, stream);
552 stream->CloseConnectionWithDetails(net::QuicErrorCode::QUIC_NO_ERROR, 548 stream->CloseConnectionWithDetails(net::QuicErrorCode::QUIC_NO_ERROR,
553 "Closing QUIC for testing"); 549 "Closing QUIC for testing");
554 EXPECT_TRUE(peer1_.signal_closed_emitted()); 550 EXPECT_TRUE(peer1_.signal_closed_emitted());
555 EXPECT_TRUE_WAIT(peer2_.signal_closed_emitted(), kTimeoutMs); 551 EXPECT_TRUE_WAIT(peer2_.signal_closed_emitted(), kTimeoutMs);
556 } 552 }
OLDNEW
« no previous file with comments | « webrtc/p2p/quic/quictransportchannel.cc ('k') | webrtc/p2p/quic/reliablequicstream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698