blob: 03784d4afcc899bd37be829b6ae46a99bbada6ea [file] [log] [blame]
jbauch5869f502017-06-29 12:31:36 -07001/*
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
11#include "webrtc/config.h"
12
13#include <vector>
14
Edward Lemurc20978e2017-07-06 19:44:34 +020015#include "webrtc/rtc_base/gunit.h"
jbauch5869f502017-06-29 12:31:36 -070016
17using webrtc::RtpExtension;
18
19static const char kExtensionUri1[] = "extension-uri1";
20static const char kExtensionUri2[] = "extension-uri2";
21
22static const RtpExtension kExtension1(kExtensionUri1, 1);
23static const RtpExtension kExtension1Encrypted(kExtensionUri1, 10, true);
24static const RtpExtension kExtension2(kExtensionUri2, 2);
25
26TEST(RtpExtensionTest, FilterDuplicateNonEncrypted) {
27 std::vector<RtpExtension> extensions;
28 std::vector<RtpExtension> filtered;
29
30 extensions.push_back(kExtension1);
31 extensions.push_back(kExtension1Encrypted);
32 filtered = RtpExtension::FilterDuplicateNonEncrypted(extensions);
33 EXPECT_EQ(1u, filtered.size());
34 EXPECT_EQ(std::vector<RtpExtension>{kExtension1Encrypted}, filtered);
35
36 extensions.clear();
37 extensions.push_back(kExtension1Encrypted);
38 extensions.push_back(kExtension1);
39 filtered = RtpExtension::FilterDuplicateNonEncrypted(extensions);
40 EXPECT_EQ(1u, filtered.size());
41 EXPECT_EQ(std::vector<RtpExtension>{kExtension1Encrypted}, filtered);
42
43 extensions.clear();
44 extensions.push_back(kExtension1);
45 extensions.push_back(kExtension2);
46 filtered = RtpExtension::FilterDuplicateNonEncrypted(extensions);
47 EXPECT_EQ(2u, filtered.size());
48 EXPECT_EQ(extensions, filtered);
49}