Chromium Code Reviews| Index: webrtc/api/peerconnectioninterface_unittest.cc |
| diff --git a/webrtc/api/peerconnectioninterface_unittest.cc b/webrtc/api/peerconnectioninterface_unittest.cc |
| index 7178ac3b5c216456104e3483896b345f7a58dafa..9acb4e766536a97c4942faccf4502688b69b2af8 100644 |
| --- a/webrtc/api/peerconnectioninterface_unittest.cc |
| +++ b/webrtc/api/peerconnectioninterface_unittest.cc |
| @@ -2328,6 +2328,132 @@ TEST_F(PeerConnectionInterfaceTest, SignalSameTracksInSeparateMediaStream) { |
| EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); |
| } |
| +// The PeerConnectionMediaConfig tests below verify 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 these unittest. |
| +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, so they can be modified in the above const-declared method. |
| + mutable bool create_media_controller_called_ = false; |
|
pbos-webrtc
2016/02/11 09:22:16
If these aren't race prone then I think you can ac
nisse-webrtc
2016/02/11 09:31:32
To get a SetUp method, I'd need to define a "test
pbos-webrtc
2016/02/11 11:34:10
I think that's fine, you can also use rtc::AtomicO
|
| + mutable cricket::MediaConfig create_media_controller_config_; |
| +}; |
| + |
| +// This test verifies the DSCP constraint is recognized and passed to |
| +// the CreateMediaController. |
| +TEST(PeerConnectionMediaConfig, TestDscpConstraint) { |
| + scoped_refptr<PeerConnectionFactoryForTest> pcf( |
| + new rtc::RefCountedObject<PeerConnectionFactoryForTest>()); |
| + pcf->Initialize(); |
| + |
| + EXPECT_FALSE(pcf->create_media_controller_config_.enable_dscp); |
| + |
| + // Without constraint, default value is false |
| + scoped_refptr<PeerConnectionInterface> pc; |
| + PeerConnectionInterface::RTCConfiguration config; |
| + FakeConstraints constraints; |
| + MockPeerConnectionObserver observer; |
| + |
| + pc = pcf->CreatePeerConnection(config, &constraints, |
| + nullptr, nullptr, &observer); |
| + ASSERT_TRUE(pc.get() != nullptr); |
| + EXPECT_TRUE(pcf->create_media_controller_called_); |
| + EXPECT_FALSE(pcf->create_media_controller_config_.enable_dscp); |
| + |
| + // With constraint set to true |
| + pcf->create_media_controller_called_ = false; |
| + |
| + constraints.AddOptional( |
| + webrtc::MediaConstraintsInterface::kEnableDscp, true); |
| + |
| + pc = pcf->CreatePeerConnection(config, &constraints, |
| + nullptr, nullptr, &observer); |
| + EXPECT_TRUE(pc.get() != nullptr); |
| + EXPECT_TRUE(pcf->create_media_controller_called_); |
| + EXPECT_TRUE(pcf->create_media_controller_config_.enable_dscp); |
| +} |
| + |
| +// This test verifies the cpu overuse detection constraint is |
| +// recognized and passed to the CreateMediaController. |
| +TEST(PeerConnectionMediaConfig, TestCpuOveruseConstraint) { |
| + scoped_refptr<PeerConnectionFactoryForTest> pcf( |
| + new rtc::RefCountedObject<PeerConnectionFactoryForTest>()); |
| + pcf->Initialize(); |
| + |
| + EXPECT_FALSE(pcf->create_media_controller_config_.enable_dscp); |
| + |
| + // Without constraint, default value is true |
| + PeerConnectionInterface::RTCConfiguration config; |
| + FakeConstraints constraints; |
| + MockPeerConnectionObserver observer; |
| + scoped_refptr<PeerConnectionInterface> pc; |
| + |
| + pc = pcf->CreatePeerConnection(config, &constraints, |
| + nullptr, nullptr, &observer); |
| + ASSERT_TRUE(pc.get() != nullptr); |
| + EXPECT_TRUE(pcf->create_media_controller_called_); |
| + EXPECT_TRUE( |
| + pcf->create_media_controller_config_.enable_cpu_overuse_detection); |
| + |
| + // With constraint set to false |
| + pcf->create_media_controller_called_ = false; |
| + |
| + constraints.AddOptional( |
| + webrtc::MediaConstraintsInterface::kCpuOveruseDetection, false); |
| + |
| + pc = pcf->CreatePeerConnection(config, &constraints, |
| + nullptr, nullptr, &observer); |
| + ASSERT_TRUE(pc.get() != nullptr); |
| + EXPECT_TRUE(pcf->create_media_controller_called_); |
| + EXPECT_FALSE( |
| + pcf->create_media_controller_config_.enable_cpu_overuse_detection); |
| +} |
| + |
| +// This test verifies the disable_prerenderer_smoothing flag is |
| +// propagated from RTCConfiguration to the CreateMediaController call. |
| +TEST(PeerConnectionMediaConfig, TestDisablePrerenderFlag) { |
| + scoped_refptr<PeerConnectionFactoryForTest> pcf( |
| + new rtc::RefCountedObject<PeerConnectionFactoryForTest>()); |
| + pcf->Initialize(); |
| + |
| + EXPECT_FALSE(pcf->create_media_controller_config_.enable_dscp); |
| + |
| + // Default value, false |
| + PeerConnectionInterface::RTCConfiguration config; |
| + FakeConstraints constraints; |
| + MockPeerConnectionObserver observer; |
| + scoped_refptr<PeerConnectionInterface> pc; |
| + |
| + pc = pcf->CreatePeerConnection(config, &constraints, |
| + nullptr, nullptr, &observer); |
| + ASSERT_TRUE(pc.get() != nullptr); |
| + EXPECT_TRUE(pcf->create_media_controller_called_); |
| + EXPECT_FALSE( |
| + pcf->create_media_controller_config_.disable_prerenderer_smoothing); |
| + |
| + // Flag set |
| + pcf->create_media_controller_called_ = false; |
| + |
| + config.disable_prerenderer_smoothing = true; |
| + pc = pcf->CreatePeerConnection(config, &constraints, |
| + nullptr, nullptr, &observer); |
| + EXPECT_TRUE(pc.get() != nullptr); |
| + EXPECT_TRUE(pcf->create_media_controller_called_); |
| + EXPECT_TRUE( |
| + pcf->create_media_controller_config_.disable_prerenderer_smoothing); |
| +} |
| + |
| // 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 |