jbauch | 5869f50 | 2017-06-29 12:31:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 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 | |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 11 | #include <utility> |
jbauch | 5869f50 | 2017-06-29 12:31:36 -0700 | [diff] [blame] | 12 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 13 | #include "api/rtpparameters.h" |
| 14 | #include "test/gtest.h" |
jbauch | 5869f50 | 2017-06-29 12:31:36 -0700 | [diff] [blame] | 15 | |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 16 | namespace webrtc { |
jbauch | 5869f50 | 2017-06-29 12:31:36 -0700 | [diff] [blame] | 17 | |
| 18 | using webrtc::RtpExtension; |
| 19 | |
| 20 | static const char kExtensionUri1[] = "extension-uri1"; |
| 21 | static const char kExtensionUri2[] = "extension-uri2"; |
| 22 | |
| 23 | static const RtpExtension kExtension1(kExtensionUri1, 1); |
| 24 | static const RtpExtension kExtension1Encrypted(kExtensionUri1, 10, true); |
| 25 | static const RtpExtension kExtension2(kExtensionUri2, 2); |
| 26 | |
| 27 | TEST(RtpExtensionTest, FilterDuplicateNonEncrypted) { |
| 28 | std::vector<RtpExtension> extensions; |
| 29 | std::vector<RtpExtension> filtered; |
| 30 | |
| 31 | extensions.push_back(kExtension1); |
| 32 | extensions.push_back(kExtension1Encrypted); |
| 33 | filtered = RtpExtension::FilterDuplicateNonEncrypted(extensions); |
| 34 | EXPECT_EQ(1u, filtered.size()); |
| 35 | EXPECT_EQ(std::vector<RtpExtension>{kExtension1Encrypted}, filtered); |
| 36 | |
| 37 | extensions.clear(); |
| 38 | extensions.push_back(kExtension1Encrypted); |
| 39 | extensions.push_back(kExtension1); |
| 40 | filtered = RtpExtension::FilterDuplicateNonEncrypted(extensions); |
| 41 | EXPECT_EQ(1u, filtered.size()); |
| 42 | EXPECT_EQ(std::vector<RtpExtension>{kExtension1Encrypted}, filtered); |
| 43 | |
| 44 | extensions.clear(); |
| 45 | extensions.push_back(kExtension1); |
| 46 | extensions.push_back(kExtension2); |
| 47 | filtered = RtpExtension::FilterDuplicateNonEncrypted(extensions); |
| 48 | EXPECT_EQ(2u, filtered.size()); |
| 49 | EXPECT_EQ(extensions, filtered); |
| 50 | } |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 51 | } // namespace webrtc |