1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
media / video / supported_video_decoder_config_unittest.cc [blame]
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/base/supported_video_decoder_config.h"
#include "media/base/test_helpers.h"
#include "media/base/video_codecs.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace media {
class SupportedVideoDecoderConfigTest : public ::testing::Test {
public:
SupportedVideoDecoderConfigTest()
: decoder_config_(
TestVideoConfig::NormalCodecProfile(VideoCodec::kH264,
H264PROFILE_EXTENDED)) {
supported_config_.profile_min = H264PROFILE_MIN;
supported_config_.profile_max = H264PROFILE_MAX;
supported_config_.coded_size_min = gfx::Size(10, 20);
supported_config_.coded_size_max = gfx::Size(10000, 20000);
supported_config_.allow_encrypted = true;
supported_config_.require_encrypted = false;
}
SupportedVideoDecoderConfig supported_config_;
// Decoder config that matches |supported_config_|.
VideoDecoderConfig decoder_config_;
};
TEST_F(SupportedVideoDecoderConfigTest, ConstructionWithArgs) {
SupportedVideoDecoderConfig config2(
supported_config_.profile_min, supported_config_.profile_max,
supported_config_.coded_size_min, supported_config_.coded_size_max,
supported_config_.allow_encrypted, supported_config_.require_encrypted);
EXPECT_EQ(supported_config_.profile_min, config2.profile_min);
EXPECT_EQ(supported_config_.profile_max, config2.profile_max);
EXPECT_EQ(supported_config_.coded_size_min, config2.coded_size_min);
EXPECT_EQ(supported_config_.coded_size_max, config2.coded_size_max);
EXPECT_EQ(supported_config_.allow_encrypted, config2.allow_encrypted);
EXPECT_EQ(supported_config_.require_encrypted, config2.require_encrypted);
}
TEST_F(SupportedVideoDecoderConfigTest, MatchingConfigMatches) {
EXPECT_TRUE(supported_config_.Matches(decoder_config_));
// Since |supported_config_| allows encrypted, this should also succeed.
decoder_config_.SetIsEncrypted(true);
EXPECT_TRUE(supported_config_.Matches(decoder_config_));
}
TEST_F(SupportedVideoDecoderConfigTest, LowerProfileMismatches) {
// Raise |profile_min| above |decoder_config_|.
supported_config_.profile_min = H264PROFILE_HIGH;
EXPECT_FALSE(supported_config_.Matches(decoder_config_));
}
TEST_F(SupportedVideoDecoderConfigTest, HigherProfileMismatches) {
// Lower |profile_max| below |decoder_config_|.
supported_config_.profile_max = H264PROFILE_MAIN;
EXPECT_FALSE(supported_config_.Matches(decoder_config_));
}
TEST_F(SupportedVideoDecoderConfigTest, SmallerMinWidthMismatches) {
supported_config_.coded_size_min =
gfx::Size(decoder_config_.coded_size().width() + 1, 0);
EXPECT_FALSE(supported_config_.Matches(decoder_config_));
}
TEST_F(SupportedVideoDecoderConfigTest, SmallerMinHeightMismatches) {
supported_config_.coded_size_min =
gfx::Size(0, decoder_config_.coded_size().height() + 1);
EXPECT_FALSE(supported_config_.Matches(decoder_config_));
}
TEST_F(SupportedVideoDecoderConfigTest, LargerMaxWidthMismatches) {
supported_config_.coded_size_max =
gfx::Size(decoder_config_.coded_size().width() - 1, 10000);
EXPECT_FALSE(supported_config_.Matches(decoder_config_));
}
TEST_F(SupportedVideoDecoderConfigTest, LargerMaxHeightMismatches) {
supported_config_.coded_size_max =
gfx::Size(10000, decoder_config_.coded_size().height() - 1);
EXPECT_FALSE(supported_config_.Matches(decoder_config_));
}
TEST_F(SupportedVideoDecoderConfigTest, RequiredEncryptionMismatches) {
supported_config_.require_encrypted = true;
EXPECT_FALSE(supported_config_.Matches(decoder_config_));
// The encrypted version should succeed.
decoder_config_.SetIsEncrypted(true);
EXPECT_TRUE(supported_config_.Matches(decoder_config_));
}
TEST_F(SupportedVideoDecoderConfigTest, AllowedEncryptionMismatches) {
supported_config_.allow_encrypted = false;
decoder_config_.SetIsEncrypted(true);
EXPECT_FALSE(supported_config_.Matches(decoder_config_));
}
} // namespace media