Index: webrtc/api/peerconnectioninterface_unittest.cc |
diff --git a/webrtc/api/peerconnectioninterface_unittest.cc b/webrtc/api/peerconnectioninterface_unittest.cc |
index 7178ac3b5c216456104e3483896b345f7a58dafa..d9a8656d3af362c50f872fb2e5c47b12faf1afc2 100644 |
--- a/webrtc/api/peerconnectioninterface_unittest.cc |
+++ b/webrtc/api/peerconnectioninterface_unittest.cc |
@@ -2328,6 +2328,131 @@ 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; |
+ 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 |
perkj_webrtc
2016/02/11 12:32:08
nit add . Write complete sentences.
nisse-webrtc
2016/02/11 13:45:08
Done.
|
+ scoped_refptr<PeerConnectionInterface> pc; |
perkj_webrtc
2016/02/11 12:32:07
nit: move to where it is used. ie
scoped_refptr<P
nisse-webrtc
2016/02/11 13:45:08
I did it this way because I wanted both calls
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); |
perkj_webrtc
2016/02/11 12:32:08
ASSERT_TRUE
nisse-webrtc
2016/02/11 13:45:08
Done.
|
+ 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; |
perkj_webrtc
2016/02/11 12:32:07
right - this should actually be 6 tests instead to
nisse-webrtc
2016/02/11 13:45:08
I'll do. I guess we'll need a few iterations more.
|
+ |
+ 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 |