| OLD | NEW |
| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // Setting the network or 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())); | 92 EXPECT_FALSE(cm_->set_network_thread(rtc::Thread::Current())); |
| 93 EXPECT_FALSE(cm_->set_worker_thread(rtc::Thread::Current())); | 93 EXPECT_FALSE(cm_->set_worker_thread(rtc::Thread::Current())); |
| 94 cm_->Terminate(); | 94 cm_->Terminate(); |
| 95 EXPECT_FALSE(cm_->initialized()); | 95 EXPECT_FALSE(cm_->initialized()); |
| 96 } | 96 } |
| 97 | 97 |
| 98 // 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. |
| 99 TEST_F(ChannelManagerTest, CreateDestroyChannels) { | 99 TEST_F(ChannelManagerTest, CreateDestroyChannels) { |
| 100 EXPECT_TRUE(cm_->Init()); | 100 EXPECT_TRUE(cm_->Init()); |
| 101 cricket::VoiceChannel* voice_channel = | 101 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( |
| 102 cm_->CreateVoiceChannel(&fake_mc_, transport_controller_, | 102 &fake_mc_, transport_controller_, cricket::CN_AUDIO, nullptr, false, |
| 103 cricket::CN_AUDIO, false, AudioOptions()); | 103 AudioOptions()); |
| 104 EXPECT_TRUE(voice_channel != nullptr); | 104 EXPECT_TRUE(voice_channel != nullptr); |
| 105 cricket::VideoChannel* video_channel = | 105 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( |
| 106 cm_->CreateVideoChannel(&fake_mc_, transport_controller_, | 106 &fake_mc_, transport_controller_, cricket::CN_VIDEO, nullptr, false, |
| 107 cricket::CN_VIDEO, false, VideoOptions()); | 107 VideoOptions()); |
| 108 EXPECT_TRUE(video_channel != nullptr); | 108 EXPECT_TRUE(video_channel != nullptr); |
| 109 cricket::DataChannel* data_channel = cm_->CreateDataChannel( | 109 cricket::DataChannel* data_channel = |
| 110 transport_controller_, cricket::CN_DATA, false, cricket::DCT_RTP); | 110 cm_->CreateDataChannel(transport_controller_, cricket::CN_DATA, nullptr, |
| 111 false, cricket::DCT_RTP); |
| 111 EXPECT_TRUE(data_channel != nullptr); | 112 EXPECT_TRUE(data_channel != nullptr); |
| 112 cm_->DestroyVideoChannel(video_channel); | 113 cm_->DestroyVideoChannel(video_channel); |
| 113 cm_->DestroyVoiceChannel(voice_channel); | 114 cm_->DestroyVoiceChannel(voice_channel); |
| 114 cm_->DestroyDataChannel(data_channel); | 115 cm_->DestroyDataChannel(data_channel); |
| 115 cm_->Terminate(); | 116 cm_->Terminate(); |
| 116 } | 117 } |
| 117 | 118 |
| 118 // Test that we can create and destroy a voice and video channel with a worker. | 119 // Test that we can create and destroy a voice and video channel with a worker. |
| 119 TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) { | 120 TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) { |
| 120 network_.Start(); | 121 network_.Start(); |
| 121 worker_.Start(); | 122 worker_.Start(); |
| 122 EXPECT_TRUE(cm_->set_worker_thread(&worker_)); | 123 EXPECT_TRUE(cm_->set_worker_thread(&worker_)); |
| 123 EXPECT_TRUE(cm_->set_network_thread(&network_)); | 124 EXPECT_TRUE(cm_->set_network_thread(&network_)); |
| 124 EXPECT_TRUE(cm_->Init()); | 125 EXPECT_TRUE(cm_->Init()); |
| 125 delete transport_controller_; | 126 delete transport_controller_; |
| 126 transport_controller_ = | 127 transport_controller_ = |
| 127 new cricket::FakeTransportController(&network_, ICEROLE_CONTROLLING); | 128 new cricket::FakeTransportController(&network_, ICEROLE_CONTROLLING); |
| 128 cricket::VoiceChannel* voice_channel = | 129 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( |
| 129 cm_->CreateVoiceChannel(&fake_mc_, transport_controller_, | 130 &fake_mc_, transport_controller_, cricket::CN_AUDIO, nullptr, false, |
| 130 cricket::CN_AUDIO, false, AudioOptions()); | 131 AudioOptions()); |
| 131 EXPECT_TRUE(voice_channel != nullptr); | 132 EXPECT_TRUE(voice_channel != nullptr); |
| 132 cricket::VideoChannel* video_channel = | 133 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( |
| 133 cm_->CreateVideoChannel(&fake_mc_, transport_controller_, | 134 &fake_mc_, transport_controller_, cricket::CN_VIDEO, nullptr, false, |
| 134 cricket::CN_VIDEO, false, VideoOptions()); | 135 VideoOptions()); |
| 135 EXPECT_TRUE(video_channel != nullptr); | 136 EXPECT_TRUE(video_channel != nullptr); |
| 136 cricket::DataChannel* data_channel = cm_->CreateDataChannel( | 137 cricket::DataChannel* data_channel = |
| 137 transport_controller_, cricket::CN_DATA, false, cricket::DCT_RTP); | 138 cm_->CreateDataChannel(transport_controller_, cricket::CN_DATA, nullptr, |
| 139 false, cricket::DCT_RTP); |
| 138 EXPECT_TRUE(data_channel != nullptr); | 140 EXPECT_TRUE(data_channel != nullptr); |
| 139 cm_->DestroyVideoChannel(video_channel); | 141 cm_->DestroyVideoChannel(video_channel); |
| 140 cm_->DestroyVoiceChannel(voice_channel); | 142 cm_->DestroyVoiceChannel(voice_channel); |
| 141 cm_->DestroyDataChannel(data_channel); | 143 cm_->DestroyDataChannel(data_channel); |
| 142 cm_->Terminate(); | 144 cm_->Terminate(); |
| 143 } | 145 } |
| 144 | 146 |
| 145 // Test that we fail to create a voice/video channel if the session is unable | 147 // Test that we fail to create a voice/video channel if the session is unable |
| 146 // to create a cricket::TransportChannel | 148 // to create a cricket::TransportChannel |
| 147 TEST_F(ChannelManagerTest, NoTransportChannelTest) { | 149 TEST_F(ChannelManagerTest, NoTransportChannelTest) { |
| 148 EXPECT_TRUE(cm_->Init()); | 150 EXPECT_TRUE(cm_->Init()); |
| 149 transport_controller_->set_fail_channel_creation(true); | 151 transport_controller_->set_fail_channel_creation(true); |
| 150 // The test is useless unless the session does not fail creating | 152 // The test is useless unless the session does not fail creating |
| 151 // cricket::TransportChannel. | 153 // cricket::TransportChannel. |
| 152 ASSERT_TRUE(transport_controller_->CreateTransportChannel_n( | 154 ASSERT_TRUE(transport_controller_->CreateTransportChannel_n( |
| 153 "audio", cricket::ICE_CANDIDATE_COMPONENT_RTP) == nullptr); | 155 "audio", cricket::ICE_CANDIDATE_COMPONENT_RTP) == nullptr); |
| 154 | 156 |
| 155 cricket::VoiceChannel* voice_channel = | 157 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( |
| 156 cm_->CreateVoiceChannel(&fake_mc_, transport_controller_, | 158 &fake_mc_, transport_controller_, cricket::CN_AUDIO, nullptr, false, |
| 157 cricket::CN_AUDIO, false, AudioOptions()); | 159 AudioOptions()); |
| 158 EXPECT_TRUE(voice_channel == nullptr); | 160 EXPECT_TRUE(voice_channel == nullptr); |
| 159 cricket::VideoChannel* video_channel = | 161 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( |
| 160 cm_->CreateVideoChannel(&fake_mc_, transport_controller_, | 162 &fake_mc_, transport_controller_, cricket::CN_VIDEO, nullptr, false, |
| 161 cricket::CN_VIDEO, false, VideoOptions()); | 163 VideoOptions()); |
| 162 EXPECT_TRUE(video_channel == nullptr); | 164 EXPECT_TRUE(video_channel == nullptr); |
| 163 cricket::DataChannel* data_channel = cm_->CreateDataChannel( | 165 cricket::DataChannel* data_channel = |
| 164 transport_controller_, cricket::CN_DATA, false, cricket::DCT_RTP); | 166 cm_->CreateDataChannel(transport_controller_, cricket::CN_DATA, nullptr, |
| 167 false, cricket::DCT_RTP); |
| 165 EXPECT_TRUE(data_channel == nullptr); | 168 EXPECT_TRUE(data_channel == nullptr); |
| 166 cm_->Terminate(); | 169 cm_->Terminate(); |
| 167 } | 170 } |
| 168 | 171 |
| 169 TEST_F(ChannelManagerTest, GetSetOutputVolumeBeforeInit) { | 172 TEST_F(ChannelManagerTest, GetSetOutputVolumeBeforeInit) { |
| 170 int level; | 173 int level; |
| 171 // Before init, SetOutputVolume() remembers the volume but does not change the | 174 // Before init, SetOutputVolume() remembers the volume but does not change the |
| 172 // volume of the engine. GetOutputVolume() should fail. | 175 // volume of the engine. GetOutputVolume() should fail. |
| 173 EXPECT_EQ(-1, fme_->output_volume()); | 176 EXPECT_EQ(-1, fme_->output_volume()); |
| 174 EXPECT_FALSE(cm_->GetOutputVolume(&level)); | 177 EXPECT_FALSE(cm_->GetOutputVolume(&level)); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 EXPECT_FALSE(cm_->SetVideoRtxEnabled(false)); | 228 EXPECT_FALSE(cm_->SetVideoRtxEnabled(false)); |
| 226 | 229 |
| 227 // Can set again after terminate. | 230 // Can set again after terminate. |
| 228 cm_->Terminate(); | 231 cm_->Terminate(); |
| 229 EXPECT_TRUE(cm_->SetVideoRtxEnabled(true)); | 232 EXPECT_TRUE(cm_->SetVideoRtxEnabled(true)); |
| 230 cm_->GetSupportedVideoCodecs(&codecs); | 233 cm_->GetSupportedVideoCodecs(&codecs); |
| 231 EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec)); | 234 EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec)); |
| 232 } | 235 } |
| 233 | 236 |
| 234 } // namespace cricket | 237 } // namespace cricket |
| OLD | NEW |