Chromium Code Reviews| 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_EQ(false, configuration.disable_ipv6); | |
| 38 constraints.SetMandatory(MediaConstraintsInterface::kEnableIPv6, "false"); | |
| 39 CopyConstraintsIntoRtcConfiguration(&constraints, &configuration); | |
| 40 EXPECT_EQ(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 // Setting with an empty configuration will overwrite optional<> fields, | |
| 49 // but leave other fields alone. | |
|
nisse-webrtc
2016/03/03 12:09:39
I don't understand the logic. If no constraint rel
hta-webrtc
2016/03/03 12:32:38
It came out when I wrote the unittest... when I ad
| |
| 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_FALSE(configuration.enable_dtls_srtp); | |
| 56 EXPECT_EQ(34, configuration.audio_jitter_buffer_max_packets); | |
| 57 } | |
| 58 | |
| 59 } // namespace | |
| 60 | |
| 61 } // namespace webrtc | |
| OLD | NEW |