1 /*
2  *  Copyright (c) 2020 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 "media/base/media_engine.h"
12 
13 #include "test/gmock.h"
14 
15 using ::testing::ElementsAre;
16 using ::testing::Field;
17 using ::testing::Return;
18 using ::testing::StrEq;
19 using ::webrtc::RtpExtension;
20 using ::webrtc::RtpHeaderExtensionCapability;
21 using ::webrtc::RtpTransceiverDirection;
22 
23 namespace cricket {
24 namespace {
25 
26 class MockRtpHeaderExtensionQueryInterface
27     : public RtpHeaderExtensionQueryInterface {
28  public:
29   MOCK_METHOD(std::vector<RtpHeaderExtensionCapability>,
30               GetRtpHeaderExtensions,
31               (),
32               (const, override));
33 };
34 
35 }  // namespace
36 
TEST(MediaEngineTest,ReturnsNotStoppedHeaderExtensions)37 TEST(MediaEngineTest, ReturnsNotStoppedHeaderExtensions) {
38   MockRtpHeaderExtensionQueryInterface mock;
39   std::vector<RtpHeaderExtensionCapability> extensions(
40       {RtpHeaderExtensionCapability("uri1", 1,
41                                     RtpTransceiverDirection::kInactive),
42        RtpHeaderExtensionCapability("uri2", 2,
43                                     RtpTransceiverDirection::kSendRecv),
44        RtpHeaderExtensionCapability("uri3", 3,
45                                     RtpTransceiverDirection::kStopped),
46        RtpHeaderExtensionCapability("uri4", 4,
47                                     RtpTransceiverDirection::kSendOnly),
48        RtpHeaderExtensionCapability("uri5", 5,
49                                     RtpTransceiverDirection::kRecvOnly)});
50   EXPECT_CALL(mock, GetRtpHeaderExtensions).WillOnce(Return(extensions));
51   EXPECT_THAT(GetDefaultEnabledRtpHeaderExtensions(mock),
52               ElementsAre(Field(&RtpExtension::uri, StrEq("uri1")),
53                           Field(&RtpExtension::uri, StrEq("uri2")),
54                           Field(&RtpExtension::uri, StrEq("uri4")),
55                           Field(&RtpExtension::uri, StrEq("uri5"))));
56 }
57 
58 }  // namespace cricket
59