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/pc/channelmanager_unittest.cc

Issue 2979963002: Revert of Make the default ctor of rtc::Thread, protected (Closed)
Patch Set: Created 3 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 | « no previous file | webrtc/pc/peerconnectionendtoend_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 2008 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2008 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 20 matching lines...) Expand all
31 AudioCodec(97, "voice", 1, 2, 3), AudioCodec(111, "OPUS", 48000, 32000, 2), 31 AudioCodec(97, "voice", 1, 2, 3), AudioCodec(111, "OPUS", 48000, 32000, 2),
32 }; 32 };
33 33
34 static const VideoCodec kVideoCodecs[] = { 34 static const VideoCodec kVideoCodecs[] = {
35 VideoCodec(99, "H264"), VideoCodec(100, "VP8"), VideoCodec(96, "rtx"), 35 VideoCodec(99, "H264"), VideoCodec(100, "VP8"), VideoCodec(96, "rtx"),
36 }; 36 };
37 37
38 class ChannelManagerTest : public testing::Test { 38 class ChannelManagerTest : public testing::Test {
39 protected: 39 protected:
40 ChannelManagerTest() 40 ChannelManagerTest()
41 : network_(rtc::Thread::CreateWithSocketServer()), 41 : fme_(new cricket::FakeMediaEngine()),
42 worker_(rtc::Thread::Create()),
43 fme_(new cricket::FakeMediaEngine()),
44 fdme_(new cricket::FakeDataEngine()), 42 fdme_(new cricket::FakeDataEngine()),
45 cm_(new cricket::ChannelManager( 43 cm_(new cricket::ChannelManager(
46 std::unique_ptr<MediaEngineInterface>(fme_), 44 std::unique_ptr<MediaEngineInterface>(fme_),
47 std::unique_ptr<DataEngineInterface>(fdme_), 45 std::unique_ptr<DataEngineInterface>(fdme_),
48 rtc::Thread::Current())), 46 rtc::Thread::Current())),
49 fake_call_(webrtc::Call::Config(&event_log_)), 47 fake_call_(webrtc::Call::Config(&event_log_)),
50 transport_controller_( 48 transport_controller_(
51 new cricket::FakeTransportController(ICEROLE_CONTROLLING)) { 49 new cricket::FakeTransportController(ICEROLE_CONTROLLING)) {
52 fme_->SetAudioCodecs(MAKE_VECTOR(kAudioCodecs)); 50 fme_->SetAudioCodecs(MAKE_VECTOR(kAudioCodecs));
53 fme_->SetVideoCodecs(MAKE_VECTOR(kVideoCodecs)); 51 fme_->SetVideoCodecs(MAKE_VECTOR(kVideoCodecs));
54 } 52 }
55 53
56 webrtc::RtcEventLogNullImpl event_log_; 54 webrtc::RtcEventLogNullImpl event_log_;
57 std::unique_ptr<rtc::Thread> network_; 55 rtc::Thread network_;
58 std::unique_ptr<rtc::Thread> worker_; 56 rtc::Thread worker_;
59 // |fme_| and |fdme_| are actually owned by |cm_|. 57 // |fme_| and |fdme_| are actually owned by |cm_|.
60 cricket::FakeMediaEngine* fme_; 58 cricket::FakeMediaEngine* fme_;
61 cricket::FakeDataEngine* fdme_; 59 cricket::FakeDataEngine* fdme_;
62 std::unique_ptr<cricket::ChannelManager> cm_; 60 std::unique_ptr<cricket::ChannelManager> cm_;
63 cricket::FakeCall fake_call_; 61 cricket::FakeCall fake_call_;
64 std::unique_ptr<cricket::FakeTransportController> transport_controller_; 62 std::unique_ptr<cricket::FakeTransportController> transport_controller_;
65 }; 63 };
66 64
67 // Test that we startup/shutdown properly. 65 // Test that we startup/shutdown properly.
68 TEST_F(ChannelManagerTest, StartupShutdown) { 66 TEST_F(ChannelManagerTest, StartupShutdown) {
69 EXPECT_FALSE(cm_->initialized()); 67 EXPECT_FALSE(cm_->initialized());
70 EXPECT_EQ(rtc::Thread::Current(), cm_->worker_thread()); 68 EXPECT_EQ(rtc::Thread::Current(), cm_->worker_thread());
71 EXPECT_TRUE(cm_->Init()); 69 EXPECT_TRUE(cm_->Init());
72 EXPECT_TRUE(cm_->initialized()); 70 EXPECT_TRUE(cm_->initialized());
73 cm_->Terminate(); 71 cm_->Terminate();
74 EXPECT_FALSE(cm_->initialized()); 72 EXPECT_FALSE(cm_->initialized());
75 } 73 }
76 74
77 // Test that we startup/shutdown properly with a worker thread. 75 // Test that we startup/shutdown properly with a worker thread.
78 TEST_F(ChannelManagerTest, StartupShutdownOnThread) { 76 TEST_F(ChannelManagerTest, StartupShutdownOnThread) {
79 network_->Start(); 77 network_.Start();
80 worker_->Start(); 78 worker_.Start();
81 EXPECT_FALSE(cm_->initialized()); 79 EXPECT_FALSE(cm_->initialized());
82 EXPECT_EQ(rtc::Thread::Current(), cm_->worker_thread()); 80 EXPECT_EQ(rtc::Thread::Current(), cm_->worker_thread());
83 EXPECT_TRUE(cm_->set_network_thread(network_.get())); 81 EXPECT_TRUE(cm_->set_network_thread(&network_));
84 EXPECT_EQ(network_.get(), cm_->network_thread()); 82 EXPECT_EQ(&network_, cm_->network_thread());
85 EXPECT_TRUE(cm_->set_worker_thread(worker_.get())); 83 EXPECT_TRUE(cm_->set_worker_thread(&worker_));
86 EXPECT_EQ(worker_.get(), cm_->worker_thread()); 84 EXPECT_EQ(&worker_, cm_->worker_thread());
87 EXPECT_TRUE(cm_->Init()); 85 EXPECT_TRUE(cm_->Init());
88 EXPECT_TRUE(cm_->initialized()); 86 EXPECT_TRUE(cm_->initialized());
89 // Setting the network or worker thread while initialized should fail. 87 // Setting the network or worker thread while initialized should fail.
90 EXPECT_FALSE(cm_->set_network_thread(rtc::Thread::Current())); 88 EXPECT_FALSE(cm_->set_network_thread(rtc::Thread::Current()));
91 EXPECT_FALSE(cm_->set_worker_thread(rtc::Thread::Current())); 89 EXPECT_FALSE(cm_->set_worker_thread(rtc::Thread::Current()));
92 cm_->Terminate(); 90 cm_->Terminate();
93 EXPECT_FALSE(cm_->initialized()); 91 EXPECT_FALSE(cm_->initialized());
94 } 92 }
95 93
96 // Test that we can create and destroy a voice and video channel. 94 // Test that we can create and destroy a voice and video channel.
(...skipping 19 matching lines...) Expand all
116 rtc::Thread::Current(), cricket::CN_DATA, kDefaultSrtpRequired); 114 rtc::Thread::Current(), cricket::CN_DATA, kDefaultSrtpRequired);
117 EXPECT_TRUE(rtp_data_channel != nullptr); 115 EXPECT_TRUE(rtp_data_channel != nullptr);
118 cm_->DestroyVideoChannel(video_channel); 116 cm_->DestroyVideoChannel(video_channel);
119 cm_->DestroyVoiceChannel(voice_channel); 117 cm_->DestroyVoiceChannel(voice_channel);
120 cm_->DestroyRtpDataChannel(rtp_data_channel); 118 cm_->DestroyRtpDataChannel(rtp_data_channel);
121 cm_->Terminate(); 119 cm_->Terminate();
122 } 120 }
123 121
124 // Test that we can create and destroy a voice and video channel with a worker. 122 // Test that we can create and destroy a voice and video channel with a worker.
125 TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) { 123 TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) {
126 network_->Start(); 124 network_.Start();
127 worker_->Start(); 125 worker_.Start();
128 EXPECT_TRUE(cm_->set_worker_thread(worker_.get())); 126 EXPECT_TRUE(cm_->set_worker_thread(&worker_));
129 EXPECT_TRUE(cm_->set_network_thread(network_.get())); 127 EXPECT_TRUE(cm_->set_network_thread(&network_));
130 EXPECT_TRUE(cm_->Init()); 128 EXPECT_TRUE(cm_->Init());
131 transport_controller_.reset(new cricket::FakeTransportController( 129 transport_controller_.reset(
132 network_.get(), ICEROLE_CONTROLLING)); 130 new cricket::FakeTransportController(&network_, ICEROLE_CONTROLLING));
133 cricket::DtlsTransportInternal* rtp_transport = 131 cricket::DtlsTransportInternal* rtp_transport =
134 transport_controller_->CreateDtlsTransport( 132 transport_controller_->CreateDtlsTransport(
135 cricket::CN_AUDIO, cricket::ICE_CANDIDATE_COMPONENT_RTP); 133 cricket::CN_AUDIO, cricket::ICE_CANDIDATE_COMPONENT_RTP);
136 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( 134 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel(
137 &fake_call_, cricket::MediaConfig(), 135 &fake_call_, cricket::MediaConfig(),
138 rtp_transport, nullptr /*rtcp_transport*/, 136 rtp_transport, nullptr /*rtcp_transport*/,
139 rtc::Thread::Current(), cricket::CN_AUDIO, kDefaultSrtpRequired, 137 rtc::Thread::Current(), cricket::CN_AUDIO, kDefaultSrtpRequired,
140 AudioOptions()); 138 AudioOptions());
141 EXPECT_TRUE(voice_channel != nullptr); 139 EXPECT_TRUE(voice_channel != nullptr);
142 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( 140 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 EXPECT_FALSE(cm_->SetVideoRtxEnabled(false)); 177 EXPECT_FALSE(cm_->SetVideoRtxEnabled(false));
180 178
181 // Can set again after terminate. 179 // Can set again after terminate.
182 cm_->Terminate(); 180 cm_->Terminate();
183 EXPECT_TRUE(cm_->SetVideoRtxEnabled(true)); 181 EXPECT_TRUE(cm_->SetVideoRtxEnabled(true));
184 cm_->GetSupportedVideoCodecs(&codecs); 182 cm_->GetSupportedVideoCodecs(&codecs);
185 EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec)); 183 EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec));
186 } 184 }
187 185
188 } // namespace cricket 186 } // namespace cricket
OLDNEW
« no previous file with comments | « no previous file | webrtc/pc/peerconnectionendtoend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698