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

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

Issue 1937693002: Replace scoped_ptr with unique_ptr everywhere (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@unique5
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/p2p/quic/quictransport.h ('k') | webrtc/pc/yuvscaler_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
11 #include "webrtc/p2p/quic/quictransport.h" 11 #include "webrtc/p2p/quic/quictransport.h"
12 12
13 #include <memory>
13 #include <string> 14 #include <string>
14 #include <vector> 15 #include <vector>
15 16
16 #include "webrtc/base/gunit.h" 17 #include "webrtc/base/gunit.h"
17 #include "webrtc/base/rtccertificate.h" 18 #include "webrtc/base/rtccertificate.h"
18 #include "webrtc/base/sslidentity.h" 19 #include "webrtc/base/sslidentity.h"
19 20
20 using cricket::TransportChannelImpl; 21 using cricket::TransportChannelImpl;
21 using cricket::QuicTransport; 22 using cricket::QuicTransport;
22 using cricket::Transport; 23 using cricket::Transport;
23 using cricket::TransportDescription; 24 using cricket::TransportDescription;
24 25
25 static const char kIceUfrag1[] = "TESTICEUFRAG0001"; 26 static const char kIceUfrag1[] = "TESTICEUFRAG0001";
26 static const char kIcePwd1[] = "TESTICEPWD00000000000001"; 27 static const char kIcePwd1[] = "TESTICEPWD00000000000001";
27 28
28 static const char kIceUfrag2[] = "TESTICEUFRAG0002"; 29 static const char kIceUfrag2[] = "TESTICEUFRAG0002";
29 static const char kIcePwd2[] = "TESTICEPWD00000000000002"; 30 static const char kIcePwd2[] = "TESTICEPWD00000000000002";
30 31
31 static rtc::scoped_refptr<rtc::RTCCertificate> CreateCertificate( 32 static rtc::scoped_refptr<rtc::RTCCertificate> CreateCertificate(
32 std::string name) { 33 std::string name) {
33 return rtc::RTCCertificate::Create(rtc::scoped_ptr<rtc::SSLIdentity>( 34 return rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>(
34 rtc::SSLIdentity::Generate(name, rtc::KT_DEFAULT))); 35 rtc::SSLIdentity::Generate(name, rtc::KT_DEFAULT)));
35 } 36 }
36 37
37 static rtc::scoped_ptr<rtc::SSLFingerprint> CreateFingerprint( 38 static std::unique_ptr<rtc::SSLFingerprint> CreateFingerprint(
38 rtc::RTCCertificate* cert) { 39 rtc::RTCCertificate* cert) {
39 std::string digest_algorithm; 40 std::string digest_algorithm;
40 cert->ssl_certificate().GetSignatureDigestAlgorithm(&digest_algorithm); 41 cert->ssl_certificate().GetSignatureDigestAlgorithm(&digest_algorithm);
41 return rtc::scoped_ptr<rtc::SSLFingerprint>( 42 return std::unique_ptr<rtc::SSLFingerprint>(
42 rtc::SSLFingerprint::Create(digest_algorithm, cert->identity())); 43 rtc::SSLFingerprint::Create(digest_algorithm, cert->identity()));
43 } 44 }
44 45
45 class QuicTransportTest : public testing::Test { 46 class QuicTransportTest : public testing::Test {
46 public: 47 public:
47 QuicTransportTest() : transport_("testing", nullptr, nullptr) {} 48 QuicTransportTest() : transport_("testing", nullptr, nullptr) {}
48 49
49 void SetTransportDescription(cricket::ConnectionRole local_role, 50 void SetTransportDescription(cricket::ConnectionRole local_role,
50 cricket::ConnectionRole remote_role, 51 cricket::ConnectionRole remote_role,
51 cricket::ContentAction local_action, 52 cricket::ContentAction local_action,
52 cricket::ContentAction remote_action, 53 cricket::ContentAction remote_action,
53 rtc::SSLRole expected_ssl_role) { 54 rtc::SSLRole expected_ssl_role) {
54 TransportChannelImpl* channel = transport_.CreateChannel(1); 55 TransportChannelImpl* channel = transport_.CreateChannel(1);
55 ASSERT_NE(nullptr, channel); 56 ASSERT_NE(nullptr, channel);
56 57
57 rtc::scoped_refptr<rtc::RTCCertificate> local_certificate( 58 rtc::scoped_refptr<rtc::RTCCertificate> local_certificate(
58 CreateCertificate("local")); 59 CreateCertificate("local"));
59 ASSERT_NE(nullptr, local_certificate); 60 ASSERT_NE(nullptr, local_certificate);
60 transport_.SetLocalCertificate(local_certificate); 61 transport_.SetLocalCertificate(local_certificate);
61 62
62 rtc::scoped_ptr<rtc::SSLFingerprint> local_fingerprint = 63 std::unique_ptr<rtc::SSLFingerprint> local_fingerprint =
63 CreateFingerprint(local_certificate.get()); 64 CreateFingerprint(local_certificate.get());
64 ASSERT_NE(nullptr, local_fingerprint); 65 ASSERT_NE(nullptr, local_fingerprint);
65 TransportDescription local_desc(std::vector<std::string>(), kIceUfrag1, 66 TransportDescription local_desc(std::vector<std::string>(), kIceUfrag1,
66 kIcePwd1, cricket::ICEMODE_FULL, local_role, 67 kIcePwd1, cricket::ICEMODE_FULL, local_role,
67 local_fingerprint.get()); 68 local_fingerprint.get());
68 ASSERT_TRUE(transport_.SetLocalTransportDescription(local_desc, 69 ASSERT_TRUE(transport_.SetLocalTransportDescription(local_desc,
69 local_action, nullptr)); 70 local_action, nullptr));
70 // The certificate is applied to QuicTransportChannel when the local 71 // The certificate is applied to QuicTransportChannel when the local
71 // description is set. 72 // description is set.
72 rtc::scoped_refptr<rtc::RTCCertificate> channel_local_certificate = 73 rtc::scoped_refptr<rtc::RTCCertificate> channel_local_certificate =
73 channel->GetLocalCertificate(); 74 channel->GetLocalCertificate();
74 ASSERT_NE(nullptr, channel_local_certificate); 75 ASSERT_NE(nullptr, channel_local_certificate);
75 EXPECT_EQ(local_certificate, channel_local_certificate); 76 EXPECT_EQ(local_certificate, channel_local_certificate);
76 rtc::scoped_ptr<rtc::SSLFingerprint> remote_fingerprint = 77 std::unique_ptr<rtc::SSLFingerprint> remote_fingerprint =
77 CreateFingerprint(CreateCertificate("remote").get()); 78 CreateFingerprint(CreateCertificate("remote").get());
78 // NegotiateTransportDescription was not called yet. The SSL role should 79 // NegotiateTransportDescription was not called yet. The SSL role should
79 // not be set and neither should the remote fingerprint. 80 // not be set and neither should the remote fingerprint.
80 rtc::scoped_ptr<rtc::SSLRole> role(new rtc::SSLRole()); 81 std::unique_ptr<rtc::SSLRole> role(new rtc::SSLRole());
81 EXPECT_FALSE(channel->GetSslRole(role.get())); 82 EXPECT_FALSE(channel->GetSslRole(role.get()));
82 // Setting the remote description should set the SSL role. 83 // Setting the remote description should set the SSL role.
83 ASSERT_NE(nullptr, remote_fingerprint); 84 ASSERT_NE(nullptr, remote_fingerprint);
84 TransportDescription remote_desc(std::vector<std::string>(), kIceUfrag2, 85 TransportDescription remote_desc(std::vector<std::string>(), kIceUfrag2,
85 kIcePwd2, cricket::ICEMODE_FULL, 86 kIcePwd2, cricket::ICEMODE_FULL,
86 remote_role, remote_fingerprint.get()); 87 remote_role, remote_fingerprint.get());
87 ASSERT_TRUE(transport_.SetRemoteTransportDescription( 88 ASSERT_TRUE(transport_.SetRemoteTransportDescription(
88 remote_desc, remote_action, nullptr)); 89 remote_desc, remote_action, nullptr));
89 ASSERT_TRUE(channel->GetSslRole(role.get())); 90 ASSERT_TRUE(channel->GetSslRole(role.get()));
90 // SSL role should be client because the remote description is an ANSWER. 91 // SSL role should be client because the remote description is an ANSWER.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 ASSERT_NE(nullptr, channel2); 151 ASSERT_NE(nullptr, channel2);
151 EXPECT_TRUE(transport_.HasChannel(2)); 152 EXPECT_TRUE(transport_.HasChannel(2));
152 EXPECT_EQ(channel2, transport_.GetChannel(2)); 153 EXPECT_EQ(channel2, transport_.GetChannel(2));
153 transport_.DestroyChannel(1); 154 transport_.DestroyChannel(1);
154 EXPECT_FALSE(transport_.HasChannel(1)); 155 EXPECT_FALSE(transport_.HasChannel(1));
155 EXPECT_EQ(nullptr, transport_.GetChannel(1)); 156 EXPECT_EQ(nullptr, transport_.GetChannel(1));
156 transport_.DestroyChannel(2); 157 transport_.DestroyChannel(2);
157 EXPECT_FALSE(transport_.HasChannel(2)); 158 EXPECT_FALSE(transport_.HasChannel(2));
158 EXPECT_EQ(nullptr, transport_.GetChannel(2)); 159 EXPECT_EQ(nullptr, transport_.GetChannel(2));
159 } 160 }
OLDNEW
« no previous file with comments | « webrtc/p2p/quic/quictransport.h ('k') | webrtc/pc/yuvscaler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698