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