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

Side by Side Diff: webrtc/pc/channelmanager_unittest.cc

Issue 1903393004: Added network thread to rtc::BaseChannel (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: fix flakiness of WebRtcSessionTest.TestPacketOptionsAndOnPacketSent 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/pc/channelmanager.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 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 } 49 }
50 50
51 virtual void TearDown() { 51 virtual void TearDown() {
52 delete transport_controller_; 52 delete transport_controller_;
53 delete cm_; 53 delete cm_;
54 cm_ = NULL; 54 cm_ = NULL;
55 fdme_ = NULL; 55 fdme_ = NULL;
56 fme_ = NULL; 56 fme_ = NULL;
57 } 57 }
58 58
59 rtc::Thread network_;
59 rtc::Thread worker_; 60 rtc::Thread worker_;
60 cricket::FakeMediaEngine* fme_; 61 cricket::FakeMediaEngine* fme_;
61 cricket::FakeDataEngine* fdme_; 62 cricket::FakeDataEngine* fdme_;
62 cricket::ChannelManager* cm_; 63 cricket::ChannelManager* cm_;
63 cricket::FakeCall fake_call_; 64 cricket::FakeCall fake_call_;
64 cricket::FakeMediaController fake_mc_; 65 cricket::FakeMediaController fake_mc_;
65 cricket::FakeTransportController* transport_controller_; 66 cricket::FakeTransportController* transport_controller_;
66 }; 67 };
67 68
68 // Test that we startup/shutdown properly. 69 // Test that we startup/shutdown properly.
69 TEST_F(ChannelManagerTest, StartupShutdown) { 70 TEST_F(ChannelManagerTest, StartupShutdown) {
70 EXPECT_FALSE(cm_->initialized()); 71 EXPECT_FALSE(cm_->initialized());
71 EXPECT_EQ(rtc::Thread::Current(), cm_->worker_thread()); 72 EXPECT_EQ(rtc::Thread::Current(), cm_->worker_thread());
72 EXPECT_TRUE(cm_->Init()); 73 EXPECT_TRUE(cm_->Init());
73 EXPECT_TRUE(cm_->initialized()); 74 EXPECT_TRUE(cm_->initialized());
74 cm_->Terminate(); 75 cm_->Terminate();
75 EXPECT_FALSE(cm_->initialized()); 76 EXPECT_FALSE(cm_->initialized());
76 } 77 }
77 78
78 // Test that we startup/shutdown properly with a worker thread. 79 // Test that we startup/shutdown properly with a worker thread.
79 TEST_F(ChannelManagerTest, StartupShutdownOnThread) { 80 TEST_F(ChannelManagerTest, StartupShutdownOnThread) {
81 network_.Start();
80 worker_.Start(); 82 worker_.Start();
81 EXPECT_FALSE(cm_->initialized()); 83 EXPECT_FALSE(cm_->initialized());
82 EXPECT_EQ(rtc::Thread::Current(), cm_->worker_thread()); 84 EXPECT_EQ(rtc::Thread::Current(), cm_->worker_thread());
85 EXPECT_TRUE(cm_->set_network_thread(&network_));
86 EXPECT_EQ(&network_, cm_->network_thread());
83 EXPECT_TRUE(cm_->set_worker_thread(&worker_)); 87 EXPECT_TRUE(cm_->set_worker_thread(&worker_));
84 EXPECT_EQ(&worker_, cm_->worker_thread()); 88 EXPECT_EQ(&worker_, cm_->worker_thread());
85 EXPECT_TRUE(cm_->Init()); 89 EXPECT_TRUE(cm_->Init());
86 EXPECT_TRUE(cm_->initialized()); 90 EXPECT_TRUE(cm_->initialized());
87 // Setting the worker thread while initialized should fail. 91 // Setting the network or worker thread while initialized should fail.
92 EXPECT_FALSE(cm_->set_network_thread(rtc::Thread::Current()));
88 EXPECT_FALSE(cm_->set_worker_thread(rtc::Thread::Current())); 93 EXPECT_FALSE(cm_->set_worker_thread(rtc::Thread::Current()));
89 cm_->Terminate(); 94 cm_->Terminate();
90 EXPECT_FALSE(cm_->initialized()); 95 EXPECT_FALSE(cm_->initialized());
91 } 96 }
92 97
93 // Test that we can create and destroy a voice and video channel. 98 // Test that we can create and destroy a voice and video channel.
94 TEST_F(ChannelManagerTest, CreateDestroyChannels) { 99 TEST_F(ChannelManagerTest, CreateDestroyChannels) {
95 EXPECT_TRUE(cm_->Init()); 100 EXPECT_TRUE(cm_->Init());
96 cricket::VoiceChannel* voice_channel = 101 cricket::VoiceChannel* voice_channel =
97 cm_->CreateVoiceChannel(&fake_mc_, transport_controller_, 102 cm_->CreateVoiceChannel(&fake_mc_, transport_controller_,
98 cricket::CN_AUDIO, false, AudioOptions()); 103 cricket::CN_AUDIO, false, AudioOptions());
99 EXPECT_TRUE(voice_channel != nullptr); 104 EXPECT_TRUE(voice_channel != nullptr);
100 cricket::VideoChannel* video_channel = 105 cricket::VideoChannel* video_channel =
101 cm_->CreateVideoChannel(&fake_mc_, transport_controller_, 106 cm_->CreateVideoChannel(&fake_mc_, transport_controller_,
102 cricket::CN_VIDEO, false, VideoOptions()); 107 cricket::CN_VIDEO, false, VideoOptions());
103 EXPECT_TRUE(video_channel != nullptr); 108 EXPECT_TRUE(video_channel != nullptr);
104 cricket::DataChannel* data_channel = cm_->CreateDataChannel( 109 cricket::DataChannel* data_channel = cm_->CreateDataChannel(
105 transport_controller_, cricket::CN_DATA, false, cricket::DCT_RTP); 110 transport_controller_, cricket::CN_DATA, false, cricket::DCT_RTP);
106 EXPECT_TRUE(data_channel != nullptr); 111 EXPECT_TRUE(data_channel != nullptr);
107 cm_->DestroyVideoChannel(video_channel); 112 cm_->DestroyVideoChannel(video_channel);
108 cm_->DestroyVoiceChannel(voice_channel); 113 cm_->DestroyVoiceChannel(voice_channel);
109 cm_->DestroyDataChannel(data_channel); 114 cm_->DestroyDataChannel(data_channel);
110 cm_->Terminate(); 115 cm_->Terminate();
111 } 116 }
112 117
113 // Test that we can create and destroy a voice and video channel with a worker. 118 // Test that we can create and destroy a voice and video channel with a worker.
114 TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) { 119 TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) {
120 network_.Start();
115 worker_.Start(); 121 worker_.Start();
116 EXPECT_TRUE(cm_->set_worker_thread(&worker_)); 122 EXPECT_TRUE(cm_->set_worker_thread(&worker_));
123 EXPECT_TRUE(cm_->set_network_thread(&network_));
117 EXPECT_TRUE(cm_->Init()); 124 EXPECT_TRUE(cm_->Init());
118 delete transport_controller_; 125 delete transport_controller_;
119 transport_controller_ = 126 transport_controller_ =
120 new cricket::FakeTransportController(&worker_, ICEROLE_CONTROLLING); 127 new cricket::FakeTransportController(&network_, ICEROLE_CONTROLLING);
121 cricket::VoiceChannel* voice_channel = 128 cricket::VoiceChannel* voice_channel =
122 cm_->CreateVoiceChannel(&fake_mc_, transport_controller_, 129 cm_->CreateVoiceChannel(&fake_mc_, transport_controller_,
123 cricket::CN_AUDIO, false, AudioOptions()); 130 cricket::CN_AUDIO, false, AudioOptions());
124 EXPECT_TRUE(voice_channel != nullptr); 131 EXPECT_TRUE(voice_channel != nullptr);
125 cricket::VideoChannel* video_channel = 132 cricket::VideoChannel* video_channel =
126 cm_->CreateVideoChannel(&fake_mc_, transport_controller_, 133 cm_->CreateVideoChannel(&fake_mc_, transport_controller_,
127 cricket::CN_VIDEO, false, VideoOptions()); 134 cricket::CN_VIDEO, false, VideoOptions());
128 EXPECT_TRUE(video_channel != nullptr); 135 EXPECT_TRUE(video_channel != nullptr);
129 cricket::DataChannel* data_channel = cm_->CreateDataChannel( 136 cricket::DataChannel* data_channel = cm_->CreateDataChannel(
130 transport_controller_, cricket::CN_DATA, false, cricket::DCT_RTP); 137 transport_controller_, cricket::CN_DATA, false, cricket::DCT_RTP);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 EXPECT_FALSE(cm_->SetVideoRtxEnabled(false)); 225 EXPECT_FALSE(cm_->SetVideoRtxEnabled(false));
219 226
220 // Can set again after terminate. 227 // Can set again after terminate.
221 cm_->Terminate(); 228 cm_->Terminate();
222 EXPECT_TRUE(cm_->SetVideoRtxEnabled(true)); 229 EXPECT_TRUE(cm_->SetVideoRtxEnabled(true));
223 cm_->GetSupportedVideoCodecs(&codecs); 230 cm_->GetSupportedVideoCodecs(&codecs);
224 EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec)); 231 EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec));
225 } 232 }
226 233
227 } // namespace cricket 234 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/pc/channelmanager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698