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..a4e85a743c585c1ede29a48c9168cc7a267962ad 100644 |
| --- a/talk/app/webrtc/peerconnectioninterface_unittest.cc |
| +++ b/talk/app/webrtc/peerconnectioninterface_unittest.cc |
| @@ -2355,6 +2355,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. |
| + |
|
perkj_webrtc
2016/02/11 08:04:06
nit: remove empty line
|
| +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_; |
|
pthatcher1
2016/02/10 19:24:23
What's the purpose of marking these "mutable"? So
nisse-webrtc
2016/02/11 07:54:33
So I can change them in the CreateMediaController
perkj_webrtc
2016/02/11 08:04:06
maybe add a comment.
|
| +}; |
| + |
| +// 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 true |
|
perkj_webrtc
2016/02/11 08:04:06
false
|
| + scoped_refptr<PeerConnectionInterface> pc; |
| + PeerConnectionInterface::RTCConfiguration config; |
| + FakeConstraints constraints; |
| + MockPeerConnectionObserver observer; |
| + |
| + pc = pcf->CreatePeerConnection(config, &constraints, |
| + nullptr, nullptr, &observer); |
| + EXPECT_TRUE(pc.get() != nullptr); |
|
perkj_webrtc
2016/02/11 08:04:06
nit: ASSERT_TRUE - otherwise the test will crash b
nisse-webrtc
2016/02/11 09:16:00
Done. I didn't know, and I've had precisely that p
|
| + EXPECT_TRUE(pcf->create_media_controller_called_); |
| + EXPECT_FALSE(pcf->create_media_controller_config_.enable_dscp); |
| + |
| + // With constraint set to false |
|
perkj_webrtc
2016/02/11 08:04:05
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 false |
|
perkj_webrtc
2016/02/11 08:04:06
true
|
| + PeerConnectionInterface::RTCConfiguration config; |
| + FakeConstraints constraints; |
| + MockPeerConnectionObserver observer; |
| + scoped_refptr<PeerConnectionInterface> pc; |
| + |
| + pc = pcf->CreatePeerConnection(config, &constraints, |
| + nullptr, nullptr, &observer); |
| + EXPECT_TRUE(pc.get() != nullptr); |
|
perkj_webrtc
2016/02/11 08:04:06
same as above
|
| + EXPECT_TRUE(pcf->create_media_controller_called_); |
| + EXPECT_TRUE( |
| + pcf->create_media_controller_config_.enable_cpu_overuse_detection); |
| + |
| + // With constraint set to true |
| + pcf->create_media_controller_called_ = false; |
| + |
| + constraints.AddOptional( |
| + webrtc::MediaConstraintsInterface::kCpuOveruseDetection, false); |
| + |
| + pc = pcf->CreatePeerConnection(config, &constraints, |
| + nullptr, nullptr, &observer); |
| + EXPECT_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); |
| + EXPECT_TRUE(pc.get() != nullptr); |
|
perkj_webrtc
2016/02/11 08:04:06
ASSERT....
|
| + 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 |