webrtc/pc/rtpmediautils_unittest.cc
Steve Anton 22da89f502 Implement legacy offer_to_receive options for Unified Plan
This implements the WebRTC specification for handling
the legacy offer options offer_to_receive_audio and
offer_to_receive_video. They are not implemented for CreateAnswer.

With Unified Plan semantics, clients should switch to the
RtpTransceiver API for ensuring the correct media sections are
offered.

Bug: webrtc:7600
Change-Id: I6ced00b86b165a352bd0ca3d64b48fadcfd12235
Reviewed-on: https://webrtc-review.googlesource.com/41341
Reviewed-by: Peter Thatcher <pthatcher@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21784}
2018-01-27 02:20:29 +00:00

96 lines
3.3 KiB
C++

/*
* Copyright 2017 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include <tuple>
#include "pc/rtpmediautils.h"
#include "test/gtest.h"
namespace webrtc {
using ::testing::Bool;
using ::testing::Combine;
using ::testing::Values;
using ::testing::ValuesIn;
RtpTransceiverDirection kAllDirections[] = {
RtpTransceiverDirection::kSendRecv, RtpTransceiverDirection::kSendOnly,
RtpTransceiverDirection::kRecvOnly, RtpTransceiverDirection::kInactive};
class EnumerateAllDirectionsTest
: public ::testing::TestWithParam<RtpTransceiverDirection> {};
// Test that converting the direction to send/recv and back again results in the
// same direction.
TEST_P(EnumerateAllDirectionsTest, TestIdentity) {
RtpTransceiverDirection direction = GetParam();
bool send = RtpTransceiverDirectionHasSend(direction);
bool recv = RtpTransceiverDirectionHasRecv(direction);
EXPECT_EQ(direction, RtpTransceiverDirectionFromSendRecv(send, recv));
}
// Test that reversing the direction is equivalent to swapping send/recv.
TEST_P(EnumerateAllDirectionsTest, TestReversedSwapped) {
RtpTransceiverDirection direction = GetParam();
bool send = RtpTransceiverDirectionHasSend(direction);
bool recv = RtpTransceiverDirectionHasRecv(direction);
EXPECT_EQ(RtpTransceiverDirectionFromSendRecv(recv, send),
RtpTransceiverDirectionReversed(direction));
}
// Test that reversing the direction twice results in the same direction.
TEST_P(EnumerateAllDirectionsTest, TestReversedIdentity) {
RtpTransceiverDirection direction = GetParam();
EXPECT_EQ(direction, RtpTransceiverDirectionReversed(
RtpTransceiverDirectionReversed(direction)));
}
INSTANTIATE_TEST_CASE_P(RtpTransceiverDirectionTest,
EnumerateAllDirectionsTest,
ValuesIn(kAllDirections));
class EnumerateAllDirectionsAndBool
: public ::testing::TestWithParam<
std::tuple<RtpTransceiverDirection, bool>> {};
TEST_P(EnumerateAllDirectionsAndBool, TestWithSendSet) {
RtpTransceiverDirection direction = std::get<0>(GetParam());
bool send = std::get<1>(GetParam());
RtpTransceiverDirection result =
RtpTransceiverDirectionWithSendSet(direction, send);
EXPECT_EQ(send, RtpTransceiverDirectionHasSend(result));
EXPECT_EQ(RtpTransceiverDirectionHasRecv(direction),
RtpTransceiverDirectionHasRecv(result));
}
TEST_P(EnumerateAllDirectionsAndBool, TestWithRecvSet) {
RtpTransceiverDirection direction = std::get<0>(GetParam());
bool recv = std::get<1>(GetParam());
RtpTransceiverDirection result =
RtpTransceiverDirectionWithRecvSet(direction, recv);
EXPECT_EQ(RtpTransceiverDirectionHasSend(direction),
RtpTransceiverDirectionHasSend(result));
EXPECT_EQ(recv, RtpTransceiverDirectionHasRecv(result));
}
INSTANTIATE_TEST_CASE_P(RtpTransceiverDirectionTest,
EnumerateAllDirectionsAndBool,
Combine(ValuesIn(kAllDirections), Bool()));
} // namespace webrtc