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

Side by Side Diff: webrtc/p2p/base/transportcontroller_unittest.cc

Issue 1920043002: Replace scoped_ptr with unique_ptr in webrtc/base/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebased 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
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2015 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 <map> 11 #include <map>
12 #include <memory>
12 13
13 #include "webrtc/base/fakesslidentity.h" 14 #include "webrtc/base/fakesslidentity.h"
14 #include "webrtc/base/gunit.h" 15 #include "webrtc/base/gunit.h"
15 #include "webrtc/base/helpers.h" 16 #include "webrtc/base/helpers.h"
16 #include "webrtc/base/scoped_ptr.h"
17 #include "webrtc/base/sslidentity.h" 17 #include "webrtc/base/sslidentity.h"
18 #include "webrtc/base/thread.h" 18 #include "webrtc/base/thread.h"
19 #include "webrtc/p2p/base/dtlstransportchannel.h" 19 #include "webrtc/p2p/base/dtlstransportchannel.h"
20 #include "webrtc/p2p/base/faketransportcontroller.h" 20 #include "webrtc/p2p/base/faketransportcontroller.h"
21 #include "webrtc/p2p/base/p2ptransportchannel.h" 21 #include "webrtc/p2p/base/p2ptransportchannel.h"
22 #include "webrtc/p2p/base/portallocator.h" 22 #include "webrtc/p2p/base/portallocator.h"
23 #include "webrtc/p2p/base/transportcontroller.h" 23 #include "webrtc/p2p/base/transportcontroller.h"
24 #include "webrtc/p2p/client/fakeportallocator.h" 24 #include "webrtc/p2p/client/fakeportallocator.h"
25 25
26 static const int kTimeout = 100; 26 static const int kTimeout = 100;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 void OnCandidatesGathered(const std::string& transport_name, 170 void OnCandidatesGathered(const std::string& transport_name,
171 const Candidates& candidates) { 171 const Candidates& candidates) {
172 if (!signaling_thread_->IsCurrent()) { 172 if (!signaling_thread_->IsCurrent()) {
173 signaled_on_non_signaling_thread_ = true; 173 signaled_on_non_signaling_thread_ = true;
174 } 174 }
175 candidates_[transport_name].insert(candidates_[transport_name].end(), 175 candidates_[transport_name].insert(candidates_[transport_name].end(),
176 candidates.begin(), candidates.end()); 176 candidates.begin(), candidates.end());
177 ++candidates_signal_count_; 177 ++candidates_signal_count_;
178 } 178 }
179 179
180 rtc::scoped_ptr<rtc::Thread> worker_thread_; // Not used for most tests. 180 std::unique_ptr<rtc::Thread> worker_thread_; // Not used for most tests.
181 rtc::scoped_ptr<TransportControllerForTest> transport_controller_; 181 std::unique_ptr<TransportControllerForTest> transport_controller_;
182 182
183 // Information received from signals from transport controller. 183 // Information received from signals from transport controller.
184 IceConnectionState connection_state_ = cricket::kIceConnectionConnecting; 184 IceConnectionState connection_state_ = cricket::kIceConnectionConnecting;
185 bool receiving_ = false; 185 bool receiving_ = false;
186 IceGatheringState gathering_state_ = cricket::kIceGatheringNew; 186 IceGatheringState gathering_state_ = cricket::kIceGatheringNew;
187 // transport_name => candidates 187 // transport_name => candidates
188 std::map<std::string, Candidates> candidates_; 188 std::map<std::string, Candidates> candidates_;
189 // Counts of each signal emitted. 189 // Counts of each signal emitted.
190 int connection_state_signal_count_ = 0; 190 int connection_state_signal_count_ = 0;
191 int receiving_signal_count_ = 0; 191 int receiving_signal_count_ = 0;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 ASSERT_NE(nullptr, channel); 262 ASSERT_NE(nullptr, channel);
263 ASSERT_TRUE(channel->SetSslRole(rtc::SSL_CLIENT)); 263 ASSERT_TRUE(channel->SetSslRole(rtc::SSL_CLIENT));
264 rtc::SSLRole role; 264 rtc::SSLRole role;
265 EXPECT_FALSE(transport_controller_->GetSslRole("video", &role)); 265 EXPECT_FALSE(transport_controller_->GetSslRole("video", &role));
266 EXPECT_TRUE(transport_controller_->GetSslRole("audio", &role)); 266 EXPECT_TRUE(transport_controller_->GetSslRole("audio", &role));
267 EXPECT_EQ(rtc::SSL_CLIENT, role); 267 EXPECT_EQ(rtc::SSL_CLIENT, role);
268 } 268 }
269 269
270 TEST_F(TransportControllerTest, TestSetAndGetLocalCertificate) { 270 TEST_F(TransportControllerTest, TestSetAndGetLocalCertificate) {
271 rtc::scoped_refptr<rtc::RTCCertificate> certificate1 = 271 rtc::scoped_refptr<rtc::RTCCertificate> certificate1 =
272 rtc::RTCCertificate::Create(rtc::scoped_ptr<rtc::SSLIdentity>( 272 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>(
273 rtc::SSLIdentity::Generate("session1", rtc::KT_DEFAULT))); 273 rtc::SSLIdentity::Generate("session1", rtc::KT_DEFAULT)));
274 rtc::scoped_refptr<rtc::RTCCertificate> certificate2 = 274 rtc::scoped_refptr<rtc::RTCCertificate> certificate2 =
275 rtc::RTCCertificate::Create(rtc::scoped_ptr<rtc::SSLIdentity>( 275 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>(
276 rtc::SSLIdentity::Generate("session2", rtc::KT_DEFAULT))); 276 rtc::SSLIdentity::Generate("session2", rtc::KT_DEFAULT)));
277 rtc::scoped_refptr<rtc::RTCCertificate> returned_certificate; 277 rtc::scoped_refptr<rtc::RTCCertificate> returned_certificate;
278 278
279 FakeTransportChannel* channel1 = CreateChannel("audio", 1); 279 FakeTransportChannel* channel1 = CreateChannel("audio", 1);
280 ASSERT_NE(nullptr, channel1); 280 ASSERT_NE(nullptr, channel1);
281 281
282 EXPECT_TRUE(transport_controller_->SetLocalCertificate(certificate1)); 282 EXPECT_TRUE(transport_controller_->SetLocalCertificate(certificate1));
283 EXPECT_TRUE(transport_controller_->GetLocalCertificate( 283 EXPECT_TRUE(transport_controller_->GetLocalCertificate(
284 "audio", &returned_certificate)); 284 "audio", &returned_certificate));
285 EXPECT_EQ(certificate1->identity()->certificate().ToPEMString(), 285 EXPECT_EQ(certificate1->identity()->certificate().ToPEMString(),
(...skipping 15 matching lines...) Expand all
301 EXPECT_FALSE(transport_controller_->SetLocalCertificate(certificate2)); 301 EXPECT_FALSE(transport_controller_->SetLocalCertificate(certificate2));
302 } 302 }
303 303
304 TEST_F(TransportControllerTest, TestGetRemoteSSLCertificate) { 304 TEST_F(TransportControllerTest, TestGetRemoteSSLCertificate) {
305 rtc::FakeSSLCertificate fake_certificate("fake_data"); 305 rtc::FakeSSLCertificate fake_certificate("fake_data");
306 306
307 FakeTransportChannel* channel = CreateChannel("audio", 1); 307 FakeTransportChannel* channel = CreateChannel("audio", 1);
308 ASSERT_NE(nullptr, channel); 308 ASSERT_NE(nullptr, channel);
309 309
310 channel->SetRemoteSSLCertificate(&fake_certificate); 310 channel->SetRemoteSSLCertificate(&fake_certificate);
311 rtc::scoped_ptr<rtc::SSLCertificate> returned_certificate = 311 std::unique_ptr<rtc::SSLCertificate> returned_certificate =
312 transport_controller_->GetRemoteSSLCertificate("audio"); 312 transport_controller_->GetRemoteSSLCertificate("audio");
313 EXPECT_TRUE(returned_certificate); 313 EXPECT_TRUE(returned_certificate);
314 EXPECT_EQ(fake_certificate.ToPEMString(), 314 EXPECT_EQ(fake_certificate.ToPEMString(),
315 returned_certificate->ToPEMString()); 315 returned_certificate->ToPEMString());
316 316
317 // Should fail if called for a nonexistant transport. 317 // Should fail if called for a nonexistant transport.
318 EXPECT_FALSE(transport_controller_->GetRemoteSSLCertificate("video")); 318 EXPECT_FALSE(transport_controller_->GetRemoteSSLCertificate("video"));
319 } 319 }
320 320
321 TEST_F(TransportControllerTest, TestSetLocalTransportDescription) { 321 TEST_F(TransportControllerTest, TestSetLocalTransportDescription) {
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 // new --> gathering --> complete 676 // new --> gathering --> complete
677 EXPECT_EQ_WAIT(cricket::kIceGatheringComplete, gathering_state_, kTimeout); 677 EXPECT_EQ_WAIT(cricket::kIceGatheringComplete, gathering_state_, kTimeout);
678 EXPECT_EQ(2, gathering_state_signal_count_); 678 EXPECT_EQ(2, gathering_state_signal_count_);
679 679
680 EXPECT_EQ_WAIT(1U, candidates_["audio"].size(), kTimeout); 680 EXPECT_EQ_WAIT(1U, candidates_["audio"].size(), kTimeout);
681 EXPECT_EQ_WAIT(1U, candidates_["video"].size(), kTimeout); 681 EXPECT_EQ_WAIT(1U, candidates_["video"].size(), kTimeout);
682 EXPECT_EQ(2, candidates_signal_count_); 682 EXPECT_EQ(2, candidates_signal_count_);
683 683
684 EXPECT_TRUE(!signaled_on_non_signaling_thread_); 684 EXPECT_TRUE(!signaled_on_non_signaling_thread_);
685 } 685 }
OLDNEW
« no previous file with comments | « webrtc/p2p/base/transportcontroller.cc ('k') | webrtc/p2p/base/transportdescriptionfactory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698