| OLD | NEW | 
|    1 /* |    1 /* | 
|    2  * libjingle |    2  * libjingle | 
|    3  * Copyright 2008 Google Inc. |    3  * Copyright 2008 Google Inc. | 
|    4  * |    4  * | 
|    5  * Redistribution and use in source and binary forms, with or without |    5  * Redistribution and use in source and binary forms, with or without | 
|    6  * modification, are permitted provided that the following conditions are met: |    6  * modification, are permitted provided that the following conditions are met: | 
|    7  * |    7  * | 
|    8  *  1. Redistributions of source code must retain the above copyright notice, |    8  *  1. Redistributions of source code must retain the above copyright notice, | 
|    9  *     this list of conditions and the following disclaimer. |    9  *     this list of conditions and the following disclaimer. | 
|   10  *  2. Redistributions in binary form must reproduce the above copyright notice, |   10  *  2. Redistributions in binary form must reproduce the above copyright notice, | 
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  110   EXPECT_TRUE(cm_->initialized()); |  110   EXPECT_TRUE(cm_->initialized()); | 
|  111   // Setting the worker thread while initialized should fail. |  111   // Setting the worker thread while initialized should fail. | 
|  112   EXPECT_FALSE(cm_->set_worker_thread(rtc::Thread::Current())); |  112   EXPECT_FALSE(cm_->set_worker_thread(rtc::Thread::Current())); | 
|  113   cm_->Terminate(); |  113   cm_->Terminate(); | 
|  114   EXPECT_FALSE(cm_->initialized()); |  114   EXPECT_FALSE(cm_->initialized()); | 
|  115 } |  115 } | 
|  116  |  116  | 
|  117 // Test that we can create and destroy a voice and video channel. |  117 // Test that we can create and destroy a voice and video channel. | 
|  118 TEST_F(ChannelManagerTest, CreateDestroyChannels) { |  118 TEST_F(ChannelManagerTest, CreateDestroyChannels) { | 
|  119   EXPECT_TRUE(cm_->Init()); |  119   EXPECT_TRUE(cm_->Init()); | 
|  120   cricket::VoiceChannel* voice_channel = |  120   cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( | 
|  121       cm_->CreateVoiceChannel(&fake_mc_, transport_controller_, |  121       &fake_mc_, transport_controller_, cricket::CN_AUDIO, false, | 
|  122                               cricket::CN_AUDIO, false, AudioOptions()); |  122       MediaChannelOptions(), AudioOptions()); | 
|  123   EXPECT_TRUE(voice_channel != nullptr); |  123   EXPECT_TRUE(voice_channel != nullptr); | 
|  124   cricket::VideoChannel* video_channel = |  124   cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( | 
|  125       cm_->CreateVideoChannel(&fake_mc_, transport_controller_, |  125       &fake_mc_, transport_controller_, cricket::CN_VIDEO, false, | 
|  126                               cricket::CN_VIDEO, false, VideoOptions()); |  126       MediaChannelOptions(), VideoOptions()); | 
|  127   EXPECT_TRUE(video_channel != nullptr); |  127   EXPECT_TRUE(video_channel != nullptr); | 
|  128   cricket::DataChannel* data_channel = cm_->CreateDataChannel( |  128   cricket::DataChannel* data_channel = cm_->CreateDataChannel( | 
|  129       transport_controller_, cricket::CN_DATA, false, cricket::DCT_RTP); |  129       transport_controller_, cricket::CN_DATA, false, cricket::DCT_RTP); | 
|  130   EXPECT_TRUE(data_channel != nullptr); |  130   EXPECT_TRUE(data_channel != nullptr); | 
|  131   cm_->DestroyVideoChannel(video_channel); |  131   cm_->DestroyVideoChannel(video_channel); | 
|  132   cm_->DestroyVoiceChannel(voice_channel); |  132   cm_->DestroyVoiceChannel(voice_channel); | 
|  133   cm_->DestroyDataChannel(data_channel); |  133   cm_->DestroyDataChannel(data_channel); | 
|  134   cm_->Terminate(); |  134   cm_->Terminate(); | 
|  135 } |  135 } | 
|  136  |  136  | 
|  137 // Test that we can create and destroy a voice and video channel with a worker. |  137 // Test that we can create and destroy a voice and video channel with a worker. | 
|  138 TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) { |  138 TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) { | 
|  139   worker_.Start(); |  139   worker_.Start(); | 
|  140   EXPECT_TRUE(cm_->set_worker_thread(&worker_)); |  140   EXPECT_TRUE(cm_->set_worker_thread(&worker_)); | 
|  141   EXPECT_TRUE(cm_->Init()); |  141   EXPECT_TRUE(cm_->Init()); | 
|  142   delete transport_controller_; |  142   delete transport_controller_; | 
|  143   transport_controller_ = |  143   transport_controller_ = | 
|  144       new cricket::FakeTransportController(&worker_, ICEROLE_CONTROLLING); |  144       new cricket::FakeTransportController(&worker_, ICEROLE_CONTROLLING); | 
|  145   cricket::VoiceChannel* voice_channel = |  145   cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( | 
|  146       cm_->CreateVoiceChannel(&fake_mc_, transport_controller_, |  146       &fake_mc_, transport_controller_, cricket::CN_AUDIO, false, | 
|  147                               cricket::CN_AUDIO, false, AudioOptions()); |  147       MediaChannelOptions(), AudioOptions()); | 
|  148   EXPECT_TRUE(voice_channel != nullptr); |  148   EXPECT_TRUE(voice_channel != nullptr); | 
|  149   cricket::VideoChannel* video_channel = |  149   cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( | 
|  150       cm_->CreateVideoChannel(&fake_mc_, transport_controller_, |  150       &fake_mc_, transport_controller_, cricket::CN_VIDEO, false, | 
|  151                               cricket::CN_VIDEO, false, VideoOptions()); |  151       MediaChannelOptions(), VideoOptions()); | 
|  152   EXPECT_TRUE(video_channel != nullptr); |  152   EXPECT_TRUE(video_channel != nullptr); | 
|  153   cricket::DataChannel* data_channel = cm_->CreateDataChannel( |  153   cricket::DataChannel* data_channel = cm_->CreateDataChannel( | 
|  154       transport_controller_, cricket::CN_DATA, false, cricket::DCT_RTP); |  154       transport_controller_, cricket::CN_DATA, false, cricket::DCT_RTP); | 
|  155   EXPECT_TRUE(data_channel != nullptr); |  155   EXPECT_TRUE(data_channel != nullptr); | 
|  156   cm_->DestroyVideoChannel(video_channel); |  156   cm_->DestroyVideoChannel(video_channel); | 
|  157   cm_->DestroyVoiceChannel(voice_channel); |  157   cm_->DestroyVoiceChannel(voice_channel); | 
|  158   cm_->DestroyDataChannel(data_channel); |  158   cm_->DestroyDataChannel(data_channel); | 
|  159   cm_->Terminate(); |  159   cm_->Terminate(); | 
|  160 } |  160 } | 
|  161  |  161  | 
|  162 // Test that we fail to create a voice/video channel if the session is unable |  162 // Test that we fail to create a voice/video channel if the session is unable | 
|  163 // to create a cricket::TransportChannel |  163 // to create a cricket::TransportChannel | 
|  164 TEST_F(ChannelManagerTest, NoTransportChannelTest) { |  164 TEST_F(ChannelManagerTest, NoTransportChannelTest) { | 
|  165   EXPECT_TRUE(cm_->Init()); |  165   EXPECT_TRUE(cm_->Init()); | 
|  166   transport_controller_->set_fail_channel_creation(true); |  166   transport_controller_->set_fail_channel_creation(true); | 
|  167   // The test is useless unless the session does not fail creating |  167   // The test is useless unless the session does not fail creating | 
|  168   // cricket::TransportChannel. |  168   // cricket::TransportChannel. | 
|  169   ASSERT_TRUE(transport_controller_->CreateTransportChannel_w( |  169   ASSERT_TRUE(transport_controller_->CreateTransportChannel_w( | 
|  170                   "audio", cricket::ICE_CANDIDATE_COMPONENT_RTP) == nullptr); |  170                   "audio", cricket::ICE_CANDIDATE_COMPONENT_RTP) == nullptr); | 
|  171  |  171  | 
|  172   cricket::VoiceChannel* voice_channel = |  172   cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( | 
|  173       cm_->CreateVoiceChannel(&fake_mc_, transport_controller_, |  173       &fake_mc_, transport_controller_, cricket::CN_AUDIO, false, | 
|  174                               cricket::CN_AUDIO, false, AudioOptions()); |  174       MediaChannelOptions(), AudioOptions()); | 
|  175   EXPECT_TRUE(voice_channel == nullptr); |  175   EXPECT_TRUE(voice_channel == nullptr); | 
|  176   cricket::VideoChannel* video_channel = |  176   cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( | 
|  177       cm_->CreateVideoChannel(&fake_mc_, transport_controller_, |  177       &fake_mc_, transport_controller_, cricket::CN_VIDEO, false, | 
|  178                               cricket::CN_VIDEO, false, VideoOptions()); |  178       MediaChannelOptions(), VideoOptions()); | 
|  179   EXPECT_TRUE(video_channel == nullptr); |  179   EXPECT_TRUE(video_channel == nullptr); | 
|  180   cricket::DataChannel* data_channel = cm_->CreateDataChannel( |  180   cricket::DataChannel* data_channel = cm_->CreateDataChannel( | 
|  181       transport_controller_, cricket::CN_DATA, false, cricket::DCT_RTP); |  181       transport_controller_, cricket::CN_DATA, false, cricket::DCT_RTP); | 
|  182   EXPECT_TRUE(data_channel == nullptr); |  182   EXPECT_TRUE(data_channel == nullptr); | 
|  183   cm_->Terminate(); |  183   cm_->Terminate(); | 
|  184 } |  184 } | 
|  185  |  185  | 
|  186 TEST_F(ChannelManagerTest, GetSetOutputVolumeBeforeInit) { |  186 TEST_F(ChannelManagerTest, GetSetOutputVolumeBeforeInit) { | 
|  187   int level; |  187   int level; | 
|  188   // Before init, SetOutputVolume() remembers the volume but does not change the |  188   // Before init, SetOutputVolume() remembers the volume but does not change the | 
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  242   EXPECT_FALSE(cm_->SetVideoRtxEnabled(false)); |  242   EXPECT_FALSE(cm_->SetVideoRtxEnabled(false)); | 
|  243  |  243  | 
|  244   // Can set again after terminate. |  244   // Can set again after terminate. | 
|  245   cm_->Terminate(); |  245   cm_->Terminate(); | 
|  246   EXPECT_TRUE(cm_->SetVideoRtxEnabled(true)); |  246   EXPECT_TRUE(cm_->SetVideoRtxEnabled(true)); | 
|  247   cm_->GetSupportedVideoCodecs(&codecs); |  247   cm_->GetSupportedVideoCodecs(&codecs); | 
|  248   EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec)); |  248   EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec)); | 
|  249 } |  249 } | 
|  250  |  250  | 
|  251 }  // namespace cricket |  251 }  // namespace cricket | 
| OLD | NEW |