| 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 |
| 11 #include "webrtc/api/fakemediacontroller.h" | 11 #include "webrtc/api/fakemediacontroller.h" |
| 12 #include "webrtc/base/gunit.h" | 12 #include "webrtc/base/gunit.h" |
| 13 #include "webrtc/base/logging.h" | 13 #include "webrtc/base/logging.h" |
| 14 #include "webrtc/base/thread.h" | 14 #include "webrtc/base/thread.h" |
| 15 #include "webrtc/media/base/fakecapturemanager.h" | |
| 16 #include "webrtc/media/base/fakemediaengine.h" | 15 #include "webrtc/media/base/fakemediaengine.h" |
| 17 #include "webrtc/media/base/fakevideocapturer.h" | 16 #include "webrtc/media/base/fakevideocapturer.h" |
| 18 #include "webrtc/media/base/testutils.h" | 17 #include "webrtc/media/base/testutils.h" |
| 19 #include "webrtc/media/engine/fakewebrtccall.h" | 18 #include "webrtc/media/engine/fakewebrtccall.h" |
| 20 #include "webrtc/p2p/base/faketransportcontroller.h" | 19 #include "webrtc/p2p/base/faketransportcontroller.h" |
| 21 #include "webrtc/pc/channelmanager.h" | 20 #include "webrtc/pc/channelmanager.h" |
| 22 | 21 |
| 23 namespace cricket { | 22 namespace cricket { |
| 24 | 23 |
| 25 static const AudioCodec kAudioCodecs[] = { | 24 static const AudioCodec kAudioCodecs[] = { |
| 26 AudioCodec(97, "voice", 1, 2, 3, 0), | 25 AudioCodec(97, "voice", 1, 2, 3, 0), |
| 27 AudioCodec(111, "OPUS", 48000, 32000, 2, 0), | 26 AudioCodec(111, "OPUS", 48000, 32000, 2, 0), |
| 28 }; | 27 }; |
| 29 | 28 |
| 30 static const VideoCodec kVideoCodecs[] = { | 29 static const VideoCodec kVideoCodecs[] = { |
| 31 VideoCodec(99, "H264", 100, 200, 300, 0), | 30 VideoCodec(99, "H264", 100, 200, 300, 0), |
| 32 VideoCodec(100, "VP8", 100, 200, 300, 0), | 31 VideoCodec(100, "VP8", 100, 200, 300, 0), |
| 33 VideoCodec(96, "rtx", 100, 200, 300, 0), | 32 VideoCodec(96, "rtx", 100, 200, 300, 0), |
| 34 }; | 33 }; |
| 35 | 34 |
| 36 class ChannelManagerTest : public testing::Test { | 35 class ChannelManagerTest : public testing::Test { |
| 37 protected: | 36 protected: |
| 38 ChannelManagerTest() | 37 ChannelManagerTest() |
| 39 : fme_(new cricket::FakeMediaEngine()), | 38 : fme_(new cricket::FakeMediaEngine()), |
| 40 fdme_(new cricket::FakeDataEngine()), | 39 fdme_(new cricket::FakeDataEngine()), |
| 41 fcm_(new cricket::FakeCaptureManager()), | |
| 42 cm_(new cricket::ChannelManager(fme_, | 40 cm_(new cricket::ChannelManager(fme_, |
| 43 fdme_, | 41 fdme_, |
| 44 fcm_, | |
| 45 rtc::Thread::Current())), | 42 rtc::Thread::Current())), |
| 46 fake_call_(webrtc::Call::Config()), | 43 fake_call_(webrtc::Call::Config()), |
| 47 fake_mc_(cm_, &fake_call_), | 44 fake_mc_(cm_, &fake_call_), |
| 48 transport_controller_( | 45 transport_controller_( |
| 49 new cricket::FakeTransportController(ICEROLE_CONTROLLING)) {} | 46 new cricket::FakeTransportController(ICEROLE_CONTROLLING)) {} |
| 50 | 47 |
| 51 virtual void SetUp() { | 48 virtual void SetUp() { |
| 52 fme_->SetAudioCodecs(MAKE_VECTOR(kAudioCodecs)); | 49 fme_->SetAudioCodecs(MAKE_VECTOR(kAudioCodecs)); |
| 53 fme_->SetVideoCodecs(MAKE_VECTOR(kVideoCodecs)); | 50 fme_->SetVideoCodecs(MAKE_VECTOR(kVideoCodecs)); |
| 54 } | 51 } |
| 55 | 52 |
| 56 virtual void TearDown() { | 53 virtual void TearDown() { |
| 57 delete transport_controller_; | 54 delete transport_controller_; |
| 58 delete cm_; | 55 delete cm_; |
| 59 cm_ = NULL; | 56 cm_ = NULL; |
| 60 fcm_ = NULL; | |
| 61 fdme_ = NULL; | 57 fdme_ = NULL; |
| 62 fme_ = NULL; | 58 fme_ = NULL; |
| 63 } | 59 } |
| 64 | 60 |
| 65 rtc::Thread worker_; | 61 rtc::Thread worker_; |
| 66 cricket::FakeMediaEngine* fme_; | 62 cricket::FakeMediaEngine* fme_; |
| 67 cricket::FakeDataEngine* fdme_; | 63 cricket::FakeDataEngine* fdme_; |
| 68 cricket::FakeCaptureManager* fcm_; | |
| 69 cricket::ChannelManager* cm_; | 64 cricket::ChannelManager* cm_; |
| 70 cricket::FakeCall fake_call_; | 65 cricket::FakeCall fake_call_; |
| 71 cricket::FakeMediaController fake_mc_; | 66 cricket::FakeMediaController fake_mc_; |
| 72 cricket::FakeTransportController* transport_controller_; | 67 cricket::FakeTransportController* transport_controller_; |
| 73 }; | 68 }; |
| 74 | 69 |
| 75 // Test that we startup/shutdown properly. | 70 // Test that we startup/shutdown properly. |
| 76 TEST_F(ChannelManagerTest, StartupShutdown) { | 71 TEST_F(ChannelManagerTest, StartupShutdown) { |
| 77 EXPECT_FALSE(cm_->initialized()); | 72 EXPECT_FALSE(cm_->initialized()); |
| 78 EXPECT_EQ(rtc::Thread::Current(), cm_->worker_thread()); | 73 EXPECT_EQ(rtc::Thread::Current(), cm_->worker_thread()); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 EXPECT_FALSE(cm_->SetVideoRtxEnabled(false)); | 220 EXPECT_FALSE(cm_->SetVideoRtxEnabled(false)); |
| 226 | 221 |
| 227 // Can set again after terminate. | 222 // Can set again after terminate. |
| 228 cm_->Terminate(); | 223 cm_->Terminate(); |
| 229 EXPECT_TRUE(cm_->SetVideoRtxEnabled(true)); | 224 EXPECT_TRUE(cm_->SetVideoRtxEnabled(true)); |
| 230 cm_->GetSupportedVideoCodecs(&codecs); | 225 cm_->GetSupportedVideoCodecs(&codecs); |
| 231 EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec)); | 226 EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec)); |
| 232 } | 227 } |
| 233 | 228 |
| 234 } // namespace cricket | 229 } // namespace cricket |
| OLD | NEW |