Chromium Code Reviews| Index: talk/app/webrtc/peerconnectioninterface_unittest.cc |
| diff --git a/talk/app/webrtc/peerconnectioninterface_unittest.cc b/talk/app/webrtc/peerconnectioninterface_unittest.cc |
| index 2388e71c04de7560ab9aaa6a0ba656fa1af6ba89..a576e1e9c9c0f94d819830d7caac12c218ea056c 100644 |
| --- a/talk/app/webrtc/peerconnectioninterface_unittest.cc |
| +++ b/talk/app/webrtc/peerconnectioninterface_unittest.cc |
| @@ -2355,6 +2355,91 @@ TEST_F(PeerConnectionInterfaceTest, SignalSameTracksInSeparateMediaStream) { |
| EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); |
| } |
| +class PeerConnectionFactoryForTest : public webrtc::PeerConnectionFactory { |
| + public: |
| + webrtc::MediaControllerInterface* CreateMediaController( |
| + const cricket::MediaConfig &config) const override { |
| + create_media_controller_called_ = true; |
| + create_media_controller_config_ = config; |
| + |
| + webrtc::MediaControllerInterface* mc = |
| + PeerConnectionFactory::CreateMediaController(config); |
| + EXPECT_TRUE(mc != nullptr); |
| + return mc; |
| + } |
| + |
| + mutable bool create_media_controller_called_ = false; |
| + mutable cricket::MediaConfig create_media_controller_config_; |
| +}; |
| + |
| +// This test verifies that configuration and constraints are |
| +// propagated into the MediaConfig passed to CreateMediaController. |
| +// These settings are intended for MediaChannel constructors, but that |
| +// is not exercised by this unittest. |
| +TEST(PeerConnection, TestSettingOfMediaConfig) { |
|
perkj_webrtc
2016/02/10 10:41:26
please split into separate tests.
1. Test constri
nisse-webrtc
2016/02/10 13:42:01
Done.
|
| + struct OneTest{ |
| + bool disable_prerenderer_smoothing; |
| + rtc::Optional<bool> input_enable_dscp; |
| + bool output_enable_dscp; |
| + rtc::Optional<bool> input_enable_cpu_overuse_detection; |
| + bool output_enable_cpu_overuse_detection; |
| + }; |
| + |
| + const std::vector<OneTest> tests = { |
| + // No disable_prerenderer_smoothing, no constraints |
| + { false, |
| + rtc::Optional<bool>(), false, |
| + rtc::Optional<bool>(), true }, |
| + // Non-default constraints |
| + { true, |
| + rtc::Optional<bool>(true), true, |
| + rtc::Optional<bool>(false), false }, |
| + // Explicit constraints implying default settings |
| + { false, |
| + rtc::Optional<bool>(false), false, |
| + rtc::Optional<bool>(true), true }, |
| + }; |
| + |
| + scoped_refptr<PeerConnectionFactoryForTest> pcf( |
| + new rtc::RefCountedObject<PeerConnectionFactoryForTest>()); |
| + |
| + pcf->Initialize(); |
| + |
| + for (auto test : tests) { |
| + FakeConstraints constraints; |
| + if (test.input_enable_dscp) { |
| + constraints.AddOptional( |
| + webrtc::MediaConstraintsInterface::kEnableDscp, |
| + *test.input_enable_dscp); |
| + } |
| + if (test.input_enable_cpu_overuse_detection) { |
| + constraints.AddOptional( |
| + webrtc::MediaConstraintsInterface::kCpuOveruseDetection, |
| + *test.input_enable_cpu_overuse_detection); |
| + } |
| + PeerConnectionInterface::RTCConfiguration config; |
| + config.disable_prerenderer_smoothing = test.disable_prerenderer_smoothing; |
| + |
| + pcf->create_media_controller_called_ = false; |
| + |
| + MockPeerConnectionObserver observer; |
| + scoped_refptr<PeerConnectionInterface> pc = |
| + pcf->CreatePeerConnection(config, &constraints, |
| + nullptr, nullptr, &observer); |
| + EXPECT_TRUE(pc.get() != nullptr); |
| + EXPECT_TRUE(pcf->create_media_controller_called_); |
| + EXPECT_EQ( |
| + test.disable_prerenderer_smoothing, |
| + pcf->create_media_controller_config_.disable_prerenderer_smoothing); |
| + EXPECT_EQ( |
| + test.output_enable_dscp, |
| + pcf->create_media_controller_config_.enable_dscp); |
| + EXPECT_EQ( |
| + test.output_enable_cpu_overuse_detection, |
| + pcf->create_media_controller_config_.enable_cpu_overuse_detection); |
| + } |
| +} |
| + |
| // The following tests verify that session options are created correctly. |
| // TODO(deadbeef): Convert these tests to be more end-to-end. Instead of |
| // "verify options are converted correctly", should be "pass options into |