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

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

Issue 1834233002: Update QuicTransportChannel to latest version of libquic (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 unified diff | Download patch
« no previous file with comments | « webrtc/p2p/quic/quictransportchannel.cc ('k') | webrtc/p2p/quic/reliablequicstream.h » ('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 28 matching lines...) Expand all
39 static const size_t kPacketSize = 100; 39 static const size_t kPacketSize = 100;
40 40
41 // Indicates ICE channel has no write error. 41 // Indicates ICE channel has no write error.
42 static const int kNoWriteError = 0; 42 static const int kNoWriteError = 0;
43 43
44 // ICE parameters. 44 // ICE parameters.
45 static const char kIceUfrag[] = "TESTICEUFRAG0001"; 45 static const char kIceUfrag[] = "TESTICEUFRAG0001";
46 static const char kIcePwd[] = "TESTICEPWD00000000000001"; 46 static const char kIcePwd[] = "TESTICEPWD00000000000001";
47 47
48 // QUIC packet parameters. 48 // QUIC packet parameters.
49 static const net::IPAddressNumber kIpAddress(net::kIPv4AddressSize, 0); 49 static const net::IPAddress kIpAddress(0, 0, 0, 0);
50 static const net::IPEndPoint kIpEndpoint(kIpAddress, 0); 50 static const net::IPEndPoint kIpEndpoint(kIpAddress, 0);
51 51
52 // Detects incoming RTP packets. 52 // Detects incoming RTP packets.
53 static bool IsRtpLeadByte(uint8_t b) { 53 static bool IsRtpLeadByte(uint8_t b) {
54 return (b & 0xC0) == 0x80; 54 return (b & 0xC0) == 0x80;
55 } 55 }
56 56
57 // Maps SSL role to ICE connection role. The peer with a client role is assumed 57 // Maps SSL role to ICE connection role. The peer with a client role is assumed
58 // to be the one who initiates the connection. 58 // to be the one who initiates the connection.
59 static ConnectionRole SslRoleToConnectionRole(rtc::SSLRole ssl_role) { 59 static ConnectionRole SslRoleToConnectionRole(rtc::SSLRole ssl_role) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 137 }
138 138
139 // Creates fingerprint from certificate. 139 // Creates fingerprint from certificate.
140 rtc::SSLFingerprint* CreateFingerprint(rtc::RTCCertificate* cert) { 140 rtc::SSLFingerprint* CreateFingerprint(rtc::RTCCertificate* cert) {
141 std::string digest_algorithm; 141 std::string digest_algorithm;
142 bool get_digest_algorithm = 142 bool get_digest_algorithm =
143 cert->ssl_certificate().GetSignatureDigestAlgorithm(&digest_algorithm); 143 cert->ssl_certificate().GetSignatureDigestAlgorithm(&digest_algorithm);
144 if (!get_digest_algorithm || digest_algorithm.empty()) { 144 if (!get_digest_algorithm || digest_algorithm.empty()) {
145 return nullptr; 145 return nullptr;
146 } 146 }
147 scoped_ptr<rtc::SSLFingerprint> fingerprint( 147 rtc::scoped_ptr<rtc::SSLFingerprint> fingerprint(
148 rtc::SSLFingerprint::Create(digest_algorithm, cert->identity())); 148 rtc::SSLFingerprint::Create(digest_algorithm, cert->identity()));
149 if (digest_algorithm != rtc::DIGEST_SHA_256) { 149 if (digest_algorithm != rtc::DIGEST_SHA_256) {
150 return nullptr; 150 return nullptr;
151 } 151 }
152 return fingerprint.release(); 152 return fingerprint.release();
153 } 153 }
154 154
155 // Sends SRTP packet to the other peer via |quic_channel_|. 155 // Sends SRTP packet to the other peer via |quic_channel_|.
156 int SendSrtpPacket() { 156 int SendSrtpPacket() {
157 char packet[kPacketSize]; 157 char packet[kPacketSize];
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 TEST_F(QuicTransportChannelTest, QuicWritePacket) { 402 TEST_F(QuicTransportChannelTest, QuicWritePacket) {
403 peer1_.ice_channel()->Connect(); 403 peer1_.ice_channel()->Connect();
404 peer2_.ice_channel()->Connect(); 404 peer2_.ice_channel()->Connect();
405 peer1_.ice_channel()->SetDestination(peer2_.ice_channel()); 405 peer1_.ice_channel()->SetDestination(peer2_.ice_channel());
406 std::string packet = "FAKEQUICPACKET"; 406 std::string packet = "FAKEQUICPACKET";
407 407
408 // QUIC should be write blocked when the ICE channel is not writable. 408 // QUIC should be write blocked when the ICE channel is not writable.
409 peer1_.ice_channel()->SetWritable(false); 409 peer1_.ice_channel()->SetWritable(false);
410 EXPECT_TRUE(peer1_.quic_channel()->IsWriteBlocked()); 410 EXPECT_TRUE(peer1_.quic_channel()->IsWriteBlocked());
411 net::WriteResult write_blocked_result = peer1_.quic_channel()->WritePacket( 411 net::WriteResult write_blocked_result = peer1_.quic_channel()->WritePacket(
412 packet.data(), packet.size(), kIpAddress, kIpEndpoint); 412 packet.data(), packet.size(), kIpAddress, kIpEndpoint, nullptr);
413 EXPECT_EQ(net::WRITE_STATUS_BLOCKED, write_blocked_result.status); 413 EXPECT_EQ(net::WRITE_STATUS_BLOCKED, write_blocked_result.status);
414 EXPECT_EQ(EWOULDBLOCK, write_blocked_result.error_code); 414 EXPECT_EQ(EWOULDBLOCK, write_blocked_result.error_code);
415 415
416 // QUIC should ignore errors when the ICE channel is writable. 416 // QUIC should ignore errors when the ICE channel is writable.
417 peer1_.ice_channel()->SetWritable(true); 417 peer1_.ice_channel()->SetWritable(true);
418 EXPECT_FALSE(peer1_.quic_channel()->IsWriteBlocked()); 418 EXPECT_FALSE(peer1_.quic_channel()->IsWriteBlocked());
419 peer1_.SetWriteError(EWOULDBLOCK); 419 peer1_.SetWriteError(EWOULDBLOCK);
420 net::WriteResult ignore_error_result = peer1_.quic_channel()->WritePacket( 420 net::WriteResult ignore_error_result = peer1_.quic_channel()->WritePacket(
421 packet.data(), packet.size(), kIpAddress, kIpEndpoint); 421 packet.data(), packet.size(), kIpAddress, kIpEndpoint, nullptr);
422 EXPECT_EQ(net::WRITE_STATUS_OK, ignore_error_result.status); 422 EXPECT_EQ(net::WRITE_STATUS_OK, ignore_error_result.status);
423 EXPECT_EQ(0, ignore_error_result.bytes_written); 423 EXPECT_EQ(0, ignore_error_result.bytes_written);
424 424
425 peer1_.SetWriteError(kNoWriteError); 425 peer1_.SetWriteError(kNoWriteError);
426 net::WriteResult no_error_result = peer1_.quic_channel()->WritePacket( 426 net::WriteResult no_error_result = peer1_.quic_channel()->WritePacket(
427 packet.data(), packet.size(), kIpAddress, kIpEndpoint); 427 packet.data(), packet.size(), kIpAddress, kIpEndpoint, nullptr);
428 EXPECT_EQ(net::WRITE_STATUS_OK, no_error_result.status); 428 EXPECT_EQ(net::WRITE_STATUS_OK, no_error_result.status);
429 EXPECT_EQ(static_cast<int>(packet.size()), no_error_result.bytes_written); 429 EXPECT_EQ(static_cast<int>(packet.size()), no_error_result.bytes_written);
430 } 430 }
431 431
432 // Test that SSL roles can be reversed before QUIC handshake. 432 // Test that SSL roles can be reversed before QUIC handshake.
433 TEST_F(QuicTransportChannelTest, QuicRoleReversalBeforeQuic) { 433 TEST_F(QuicTransportChannelTest, QuicRoleReversalBeforeQuic) {
434 EXPECT_TRUE(peer1_.quic_channel()->SetSslRole(rtc::SSL_SERVER)); 434 EXPECT_TRUE(peer1_.quic_channel()->SetSslRole(rtc::SSL_SERVER));
435 EXPECT_TRUE(peer1_.quic_channel()->SetSslRole(rtc::SSL_CLIENT)); 435 EXPECT_TRUE(peer1_.quic_channel()->SetSslRole(rtc::SSL_CLIENT));
436 EXPECT_TRUE(peer1_.quic_channel()->SetSslRole(rtc::SSL_SERVER)); 436 EXPECT_TRUE(peer1_.quic_channel()->SetSslRole(rtc::SSL_SERVER));
437 } 437 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 479
480 // Test that if the ICE channel becomes receiving before the QUIC channel is 480 // Test that if the ICE channel becomes receiving before the QUIC channel is
481 // connected, then the QUIC channel becomes receiving. 481 // connected, then the QUIC channel becomes receiving.
482 TEST_F(QuicTransportChannelTest, IceReceivingBeforeConnected) { 482 TEST_F(QuicTransportChannelTest, IceReceivingBeforeConnected) {
483 Connect(); 483 Connect();
484 peer1_.ice_channel()->SetReceiving(true); 484 peer1_.ice_channel()->SetReceiving(true);
485 ASSERT_TRUE(peer1_.ice_channel()->receiving()); 485 ASSERT_TRUE(peer1_.ice_channel()->receiving());
486 ASSERT_TRUE_WAIT(quic_connected(), kTimeoutMs); 486 ASSERT_TRUE_WAIT(quic_connected(), kTimeoutMs);
487 EXPECT_TRUE(peer1_.quic_channel()->receiving()); 487 EXPECT_TRUE(peer1_.quic_channel()->receiving());
488 } 488 }
OLDNEW
« 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