blob: d72f35be07853eaabdf41879b418e78114bf3681 [file] [log] [blame]
Steve Anton1d03a752017-11-27 14:30:09 -08001/*
2 * Copyright 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 "pc/rtpmediautils.h"
12#include "test/gtest.h"
13
14namespace webrtc {
15
16using ::testing::Values;
17
18class EnumerateAllDirectionsTest
19 : public ::testing::Test,
20 public ::testing::WithParamInterface<RtpTransceiverDirection> {};
21
22// Test that converting the direction to send/recv and back again results in the
23// same direction.
24TEST_P(EnumerateAllDirectionsTest, TestIdentity) {
25 RtpTransceiverDirection direction = GetParam();
26
27 bool send = RtpTransceiverDirectionHasSend(direction);
28 bool recv = RtpTransceiverDirectionHasRecv(direction);
29
30 EXPECT_EQ(direction, RtpTransceiverDirectionFromSendRecv(send, recv));
31}
32
33// Test that reversing the direction is equivalent to swapping send/recv.
34TEST_P(EnumerateAllDirectionsTest, TestReversedSwapped) {
35 RtpTransceiverDirection direction = GetParam();
36
37 bool send = RtpTransceiverDirectionHasSend(direction);
38 bool recv = RtpTransceiverDirectionHasRecv(direction);
39
40 EXPECT_EQ(RtpTransceiverDirectionFromSendRecv(recv, send),
41 RtpTransceiverDirectionReversed(direction));
42}
43
44// Test that reversing the direction twice results in the same direction.
45TEST_P(EnumerateAllDirectionsTest, TestReversedIdentity) {
46 RtpTransceiverDirection direction = GetParam();
47
48 EXPECT_EQ(direction, RtpTransceiverDirectionReversed(
49 RtpTransceiverDirectionReversed(direction)));
50}
51
52INSTANTIATE_TEST_CASE_P(RtpTransceiverDirectionTest,
53 EnumerateAllDirectionsTest,
54 Values(RtpTransceiverDirection::kSendRecv,
55 RtpTransceiverDirection::kSendOnly,
56 RtpTransceiverDirection::kRecvOnly,
57 RtpTransceiverDirection::kInactive));
58
59} // namespace webrtc