OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. |
| 3 * |
| 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 |
| 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ |
| 10 |
| 11 #include "webrtc/api/mediaconstraintsinterface.h" |
| 12 |
| 13 #include "webrtc/api/test/fakeconstraints.h" |
| 14 #include "webrtc/base/gunit.h" |
| 15 |
| 16 namespace webrtc { |
| 17 |
| 18 namespace { |
| 19 |
| 20 bool Matches(const PeerConnectionInterface::RTCConfiguration& a, |
| 21 const PeerConnectionInterface::RTCConfiguration& b) { |
| 22 return a.audio_jitter_buffer_max_packets == |
| 23 b.audio_jitter_buffer_max_packets && |
| 24 a.disable_prerenderer_smoothing == b.disable_prerenderer_smoothing; |
| 25 } |
| 26 |
| 27 TEST(MediaConstraintsInterface, CopyConstraintsIntoRtcConfiguration) { |
| 28 FakeConstraints constraints; |
| 29 PeerConnectionInterface::RTCConfiguration old_configuration; |
| 30 PeerConnectionInterface::RTCConfiguration configuration; |
| 31 |
| 32 CopyConstraintsIntoRtcConfiguration(&constraints, &configuration); |
| 33 EXPECT_TRUE(Matches(old_configuration, configuration)); |
| 34 |
| 35 constraints.SetMandatory(MediaConstraintsInterface::kEnableIPv6, "true"); |
| 36 CopyConstraintsIntoRtcConfiguration(&constraints, &configuration); |
| 37 EXPECT_FALSE(configuration.disable_ipv6); |
| 38 constraints.SetMandatory(MediaConstraintsInterface::kEnableIPv6, "false"); |
| 39 CopyConstraintsIntoRtcConfiguration(&constraints, &configuration); |
| 40 EXPECT_TRUE(configuration.disable_ipv6); |
| 41 |
| 42 constraints.SetMandatory(MediaConstraintsInterface::kScreencastMinBitrate, |
| 43 27); |
| 44 CopyConstraintsIntoRtcConfiguration(&constraints, &configuration); |
| 45 EXPECT_TRUE(configuration.screencast_min_bitrate); |
| 46 EXPECT_EQ(27, *(configuration.screencast_min_bitrate)); |
| 47 |
| 48 // An empty set of constraints will not overwrite |
| 49 // values that are already present. |
| 50 constraints = FakeConstraints(); |
| 51 configuration = old_configuration; |
| 52 configuration.enable_dtls_srtp = rtc::Optional<bool>(true); |
| 53 configuration.audio_jitter_buffer_max_packets = 34; |
| 54 CopyConstraintsIntoRtcConfiguration(&constraints, &configuration); |
| 55 EXPECT_EQ(34, configuration.audio_jitter_buffer_max_packets); |
| 56 ASSERT_TRUE(configuration.enable_dtls_srtp); |
| 57 EXPECT_TRUE(*(configuration.enable_dtls_srtp)); |
| 58 } |
| 59 |
| 60 } // namespace |
| 61 |
| 62 } // namespace webrtc |
OLD | NEW |