Files
platform-external-webrtc/call/adaptation/video_source_restrictions_unittest.cc
Henrik Boström 722fa4d509 [Adaptation] Misc tests for processor, input provider and restrictions.
This CL adds miscellaneous unit tests for the
ResourceAdaptationProcessor, the VideoSourceRestrictions comparators and
the VideoStreamInputStateProvider.

Bug: webrtc:11172
Change-Id: If95f69644aaf2b43e3b19d5729bedef0b438c77b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174101
Reviewed-by: Evan Shrubsole <eshr@google.com>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31147}
2020-04-29 15:59:14 +00:00

74 lines
3.2 KiB
C++

/*
* Copyright (c) 2020 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 "call/adaptation/video_source_restrictions.h"
#include "test/gtest.h"
namespace webrtc {
namespace {
VideoSourceRestrictions RestrictionsFromMaxPixelsPerFrame(
size_t max_pixels_per_frame) {
return VideoSourceRestrictions(max_pixels_per_frame, absl::nullopt,
absl::nullopt);
}
VideoSourceRestrictions RestrictionsFromMaxFrameRate(double max_frame_rate) {
return VideoSourceRestrictions(absl::nullopt, absl::nullopt, max_frame_rate);
}
} // namespace
TEST(VideoSourceRestrictionsTest, DidIncreaseResolution) {
// smaller restrictions -> larger restrictions
EXPECT_TRUE(DidIncreaseResolution(RestrictionsFromMaxPixelsPerFrame(10),
RestrictionsFromMaxPixelsPerFrame(11)));
// unrestricted -> restricted
EXPECT_FALSE(DidIncreaseResolution(VideoSourceRestrictions(),
RestrictionsFromMaxPixelsPerFrame(10)));
// restricted -> unrestricted
EXPECT_TRUE(DidIncreaseResolution(RestrictionsFromMaxPixelsPerFrame(10),
VideoSourceRestrictions()));
// restricted -> equally restricted
EXPECT_FALSE(DidIncreaseResolution(RestrictionsFromMaxPixelsPerFrame(10),
RestrictionsFromMaxPixelsPerFrame(10)));
// unrestricted -> unrestricted
EXPECT_FALSE(DidIncreaseResolution(VideoSourceRestrictions(),
VideoSourceRestrictions()));
// larger restrictions -> smaller restrictions
EXPECT_FALSE(DidIncreaseResolution(RestrictionsFromMaxPixelsPerFrame(10),
RestrictionsFromMaxPixelsPerFrame(9)));
}
TEST(VideoSourceRestrictionsTest, DidDecreaseFrameRate) {
// samller restrictions -> larger restrictions
EXPECT_FALSE(DidDecreaseFrameRate(RestrictionsFromMaxFrameRate(10),
RestrictionsFromMaxFrameRate(11)));
// unrestricted -> restricted
EXPECT_TRUE(DidDecreaseFrameRate(VideoSourceRestrictions(),
RestrictionsFromMaxFrameRate(10)));
// restricted -> unrestricted
EXPECT_FALSE(DidDecreaseFrameRate(RestrictionsFromMaxFrameRate(10),
VideoSourceRestrictions()));
// restricted -> equally restricted
EXPECT_FALSE(DidDecreaseFrameRate(RestrictionsFromMaxFrameRate(10),
RestrictionsFromMaxFrameRate(10)));
// unrestricted -> unrestricted
EXPECT_FALSE(DidDecreaseFrameRate(VideoSourceRestrictions(),
VideoSourceRestrictions()));
// larger restrictions -> samller restrictions
EXPECT_TRUE(DidDecreaseFrameRate(RestrictionsFromMaxFrameRate(10),
RestrictionsFromMaxFrameRate(9)));
}
} // namespace webrtc