Artem Titov | 0d51052 | 2022-04-19 13:01:03 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2022 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 "api/test/peerconnection_quality_test_fixture.h" |
| 12 | |
| 13 | #include <vector> |
| 14 | |
| 15 | #include "absl/types/optional.h" |
| 16 | #include "rtc_base/gunit.h" |
| 17 | #include "test/gmock.h" |
| 18 | |
| 19 | namespace webrtc { |
| 20 | namespace webrtc_pc_e2e { |
| 21 | namespace { |
| 22 | |
Artem Titov | 7017a13 | 2022-04-20 20:57:56 +0200 | [diff] [blame] | 23 | using VideoResolution = ::webrtc::webrtc_pc_e2e:: |
| 24 | PeerConnectionE2EQualityTestFixture::VideoResolution; |
Artem Titov | 0d51052 | 2022-04-19 13:01:03 +0200 | [diff] [blame] | 25 | using VideoConfig = |
| 26 | ::webrtc::webrtc_pc_e2e::PeerConnectionE2EQualityTestFixture::VideoConfig; |
Artem Titov | 7017a13 | 2022-04-20 20:57:56 +0200 | [diff] [blame] | 27 | using VideoSubscription = ::webrtc::webrtc_pc_e2e:: |
| 28 | PeerConnectionE2EQualityTestFixture::VideoSubscription; |
Artem Titov | 0d51052 | 2022-04-19 13:01:03 +0200 | [diff] [blame] | 29 | |
| 30 | TEST(PclfVideoSubscription, MaxFromSenderSpecEqualIndependentOfOtherFields) { |
Artem Titov | 7017a13 | 2022-04-20 20:57:56 +0200 | [diff] [blame] | 31 | VideoResolution r1(VideoResolution::Spec::kMaxFromSender); |
Artem Titov | 0d51052 | 2022-04-19 13:01:03 +0200 | [diff] [blame] | 32 | r1.set_width(1); |
| 33 | r1.set_height(2); |
| 34 | r1.set_fps(3); |
Artem Titov | 7017a13 | 2022-04-20 20:57:56 +0200 | [diff] [blame] | 35 | VideoResolution r2(VideoResolution::Spec::kMaxFromSender); |
Artem Titov | 0d51052 | 2022-04-19 13:01:03 +0200 | [diff] [blame] | 36 | r1.set_width(4); |
| 37 | r1.set_height(5); |
| 38 | r1.set_fps(6); |
| 39 | EXPECT_EQ(r1, r2); |
| 40 | } |
| 41 | |
| 42 | TEST(PclfVideoSubscription, WhenSpecIsNotSetFieldsAreCompared) { |
Artem Titov | 7017a13 | 2022-04-20 20:57:56 +0200 | [diff] [blame] | 43 | VideoResolution test_resolution(/*width=*/1, /*height=*/2, |
| 44 | /*fps=*/3); |
| 45 | VideoResolution equal_resolution(/*width=*/1, /*height=*/2, |
| 46 | /*fps=*/3); |
| 47 | VideoResolution different_width(/*width=*/10, /*height=*/2, |
| 48 | /*fps=*/3); |
| 49 | VideoResolution different_height(/*width=*/1, /*height=*/20, |
| 50 | /*fps=*/3); |
| 51 | VideoResolution different_fps(/*width=*/1, /*height=*/20, |
| 52 | /*fps=*/30); |
Artem Titov | 0d51052 | 2022-04-19 13:01:03 +0200 | [diff] [blame] | 53 | |
| 54 | EXPECT_EQ(test_resolution, equal_resolution); |
| 55 | EXPECT_NE(test_resolution, different_width); |
| 56 | EXPECT_NE(test_resolution, different_height); |
| 57 | EXPECT_NE(test_resolution, different_fps); |
| 58 | } |
| 59 | |
| 60 | TEST(PclfVideoSubscription, GetMaxResolutionForEmptyReturnsNullopt) { |
Artem Titov | 7017a13 | 2022-04-20 20:57:56 +0200 | [diff] [blame] | 61 | absl::optional<VideoResolution> resolution = |
Artem Titov | 83962d9 | 2022-04-20 19:26:08 +0200 | [diff] [blame] | 62 | VideoSubscription::GetMaxResolution(std::vector<VideoConfig>{}); |
Artem Titov | 0d51052 | 2022-04-19 13:01:03 +0200 | [diff] [blame] | 63 | ASSERT_FALSE(resolution.has_value()); |
| 64 | } |
| 65 | |
| 66 | TEST(PclfVideoSubscription, GetMaxResolutionSelectMaxForEachDimention) { |
| 67 | VideoConfig max_width(/*width=*/1000, /*height=*/1, /*fps=*/1); |
| 68 | VideoConfig max_height(/*width=*/1, /*height=*/100, /*fps=*/1); |
| 69 | VideoConfig max_fps(/*width=*/1, /*height=*/1, /*fps=*/10); |
| 70 | |
Artem Titov | 7017a13 | 2022-04-20 20:57:56 +0200 | [diff] [blame] | 71 | absl::optional<VideoResolution> resolution = |
Artem Titov | 0d51052 | 2022-04-19 13:01:03 +0200 | [diff] [blame] | 72 | VideoSubscription::GetMaxResolution( |
| 73 | std::vector<VideoConfig>{max_width, max_height, max_fps}); |
| 74 | ASSERT_TRUE(resolution.has_value()); |
| 75 | EXPECT_EQ(resolution->width(), static_cast<size_t>(1000)); |
| 76 | EXPECT_EQ(resolution->height(), static_cast<size_t>(100)); |
| 77 | EXPECT_EQ(resolution->fps(), 10); |
| 78 | } |
| 79 | |
| 80 | } // namespace |
| 81 | } // namespace webrtc_pc_e2e |
| 82 | } // namespace webrtc |