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

Side by Side Diff: webrtc/api/quicdatatransport_unittest.cc

Issue 1934723003: Stop QuicDataChannel and QuicDataTransport unit tests from segfaulting (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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/api/quicdatachannel_unittest.cc ('k') | no next file » | 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 private: 57 private:
58 std::vector<std::string> messages_; 58 std::vector<std::string> messages_;
59 }; 59 };
60 60
61 // A peer who uses a QUIC transport channel and fake ICE transport channel to 61 // A peer who uses a QUIC transport channel and fake ICE transport channel to
62 // send or receive data. 62 // send or receive data.
63 class QuicDataTransportPeer { 63 class QuicDataTransportPeer {
64 public: 64 public:
65 QuicDataTransportPeer() 65 QuicDataTransportPeer()
66 : quic_data_transport_(rtc::Thread::Current(), rtc::Thread::Current()), 66 : quic_data_transport_(rtc::Thread::Current(), rtc::Thread::Current()),
67 ice_transport_channel_("data", 0), 67 ice_transport_channel_(new FakeTransportChannel("data", 0)),
68 quic_transport_channel_(&ice_transport_channel_) { 68 quic_transport_channel_(ice_transport_channel_) {
69 ice_transport_channel_.SetAsync(true); 69 ice_transport_channel_->SetAsync(true);
70 } 70 }
71 71
72 void GenerateCertificateAndFingerprint() { 72 void GenerateCertificateAndFingerprint() {
73 rtc::scoped_refptr<rtc::RTCCertificate> local_cert = 73 rtc::scoped_refptr<rtc::RTCCertificate> local_cert =
74 rtc::RTCCertificate::Create(rtc::scoped_ptr<rtc::SSLIdentity>( 74 rtc::RTCCertificate::Create(rtc::scoped_ptr<rtc::SSLIdentity>(
75 rtc::SSLIdentity::Generate("cert_name", rtc::KT_DEFAULT))); 75 rtc::SSLIdentity::Generate("cert_name", rtc::KT_DEFAULT)));
76 quic_transport_channel_.SetLocalCertificate(local_cert); 76 quic_transport_channel_.SetLocalCertificate(local_cert);
77 local_fingerprint_.reset(CreateFingerprint(local_cert.get())); 77 local_fingerprint_.reset(CreateFingerprint(local_cert.get()));
78 } 78 }
79 79
80 // Connects |ice_transport_channel_| to that of the other peer. 80 // Connects |ice_transport_channel_| to that of the other peer.
81 void Connect(QuicDataTransportPeer* other_peer) { 81 void Connect(QuicDataTransportPeer* other_peer) {
82 ice_transport_channel_.Connect(); 82 ice_transport_channel_->Connect();
83 other_peer->ice_transport_channel_.Connect(); 83 other_peer->ice_transport_channel_->Connect();
84 ice_transport_channel_.SetDestination(&other_peer->ice_transport_channel_); 84 ice_transport_channel_->SetDestination(other_peer->ice_transport_channel_);
85 } 85 }
86 86
87 rtc::scoped_ptr<rtc::SSLFingerprint>& local_fingerprint() { 87 rtc::scoped_ptr<rtc::SSLFingerprint>& local_fingerprint() {
88 return local_fingerprint_; 88 return local_fingerprint_;
89 } 89 }
90 90
91 QuicTransportChannel* quic_transport_channel() { 91 QuicTransportChannel* quic_transport_channel() {
92 return &quic_transport_channel_; 92 return &quic_transport_channel_;
93 } 93 }
94 94
(...skipping 20 matching lines...) Expand all
115 // Creates a fingerprint from a certificate. 115 // Creates a fingerprint from a certificate.
116 rtc::SSLFingerprint* CreateFingerprint(rtc::RTCCertificate* cert) { 116 rtc::SSLFingerprint* CreateFingerprint(rtc::RTCCertificate* cert) {
117 std::string digest_algorithm; 117 std::string digest_algorithm;
118 cert->ssl_certificate().GetSignatureDigestAlgorithm(&digest_algorithm); 118 cert->ssl_certificate().GetSignatureDigestAlgorithm(&digest_algorithm);
119 rtc::scoped_ptr<rtc::SSLFingerprint> fingerprint( 119 rtc::scoped_ptr<rtc::SSLFingerprint> fingerprint(
120 rtc::SSLFingerprint::Create(digest_algorithm, cert->identity())); 120 rtc::SSLFingerprint::Create(digest_algorithm, cert->identity()));
121 return fingerprint.release(); 121 return fingerprint.release();
122 } 122 }
123 123
124 QuicDataTransport quic_data_transport_; 124 QuicDataTransport quic_data_transport_;
125 FakeTransportChannel ice_transport_channel_; 125 FakeTransportChannel* ice_transport_channel_;
126 QuicTransportChannel quic_transport_channel_; 126 QuicTransportChannel quic_transport_channel_;
127 rtc::scoped_ptr<rtc::SSLFingerprint> local_fingerprint_; 127 rtc::scoped_ptr<rtc::SSLFingerprint> local_fingerprint_;
128 }; 128 };
129 129
130 class QuicDataTransportTest : public testing::Test { 130 class QuicDataTransportTest : public testing::Test {
131 public: 131 public:
132 QuicDataTransportTest() {} 132 QuicDataTransportTest() {}
133 133
134 void ConnectTransportChannels() { 134 void ConnectTransportChannels() {
135 SetCryptoParameters(); 135 SetCryptoParameters();
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 QuicTransportChannel* transport_channel = peer1_.quic_transport_channel(); 346 QuicTransportChannel* transport_channel = peer1_.quic_transport_channel();
347 EXPECT_TRUE(quic_data_transport->SetTransportChannel(transport_channel)); 347 EXPECT_TRUE(quic_data_transport->SetTransportChannel(transport_channel));
348 EXPECT_TRUE(quic_data_transport->SetTransportChannel(transport_channel)); 348 EXPECT_TRUE(quic_data_transport->SetTransportChannel(transport_channel));
349 QuicTransportChannel* other_transport_channel = 349 QuicTransportChannel* other_transport_channel =
350 peer2_.quic_transport_channel(); 350 peer2_.quic_transport_channel();
351 EXPECT_FALSE( 351 EXPECT_FALSE(
352 quic_data_transport->SetTransportChannel(other_transport_channel)); 352 quic_data_transport->SetTransportChannel(other_transport_channel));
353 } 353 }
354 354
355 } // namespace 355 } // namespace
OLDNEW
« no previous file with comments | « webrtc/api/quicdatachannel_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698