1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #include "DecoderBenchmark.h"
7
8 #include "gmock/gmock.h"
9 #include "gtest/gtest-printers.h"
10 #include "gtest/gtest.h"
11
12 using ::testing::Return;
13 using namespace mozilla;
14
TEST(DecoderBenchmark,CreateKey)15 TEST(DecoderBenchmark, CreateKey)
16 {
17 DecoderBenchmarkInfo info{NS_LITERAL_CSTRING("video/av1"), 1, 1, 1, 8};
18 EXPECT_EQ(KeyUtil::CreateKey(info),
19 NS_LITERAL_CSTRING("ResolutionLevel0-FrameRateLevel0-8bit"))
20 << "Min level";
21
22 DecoderBenchmarkInfo info1{NS_LITERAL_CSTRING("video/av1"), 5000, 5000, 100,
23 8};
24 EXPECT_EQ(KeyUtil::CreateKey(info1),
25 NS_LITERAL_CSTRING("ResolutionLevel7-FrameRateLevel4-8bit"))
26 << "Max level";
27
28 DecoderBenchmarkInfo info2{NS_LITERAL_CSTRING("video/av1"), 854, 480, 30, 8};
29 EXPECT_EQ(KeyUtil::CreateKey(info2),
30 NS_LITERAL_CSTRING("ResolutionLevel3-FrameRateLevel2-8bit"))
31 << "On the top of 4th resolution level";
32
33 DecoderBenchmarkInfo info3{NS_LITERAL_CSTRING("video/av1"), 1270, 710, 24, 8};
34 EXPECT_EQ(KeyUtil::CreateKey(info3),
35 NS_LITERAL_CSTRING("ResolutionLevel4-FrameRateLevel1-8bit"))
36 << "Closer to 5th resolution level - bellow";
37
38 DecoderBenchmarkInfo info4{NS_LITERAL_CSTRING("video/av1"), 1290, 730, 24, 8};
39 EXPECT_EQ(KeyUtil::CreateKey(info4),
40 NS_LITERAL_CSTRING("ResolutionLevel4-FrameRateLevel1-8bit"))
41 << "Closer to 5th resolution level - above";
42
43 DecoderBenchmarkInfo info5{NS_LITERAL_CSTRING("video/av1"), 854, 480, 20, 8};
44 EXPECT_EQ(KeyUtil::CreateKey(info5),
45 NS_LITERAL_CSTRING("ResolutionLevel3-FrameRateLevel1-8bit"))
46 << "Closer to 2nd frame rate level - bellow";
47
48 DecoderBenchmarkInfo info6{NS_LITERAL_CSTRING("video/av1"), 854, 480, 26, 8};
49 EXPECT_EQ(KeyUtil::CreateKey(info6),
50 NS_LITERAL_CSTRING("ResolutionLevel3-FrameRateLevel1-8bit"))
51 << "Closer to 2nd frame rate level - above";
52
53 DecoderBenchmarkInfo info7{NS_LITERAL_CSTRING("video/av1"), 1280, 720, 24,
54 10};
55 EXPECT_EQ(KeyUtil::CreateKey(info7),
56 NS_LITERAL_CSTRING("ResolutionLevel4-FrameRateLevel1-non8bit"))
57 << "Bit depth 10 bits";
58
59 DecoderBenchmarkInfo info8{NS_LITERAL_CSTRING("video/av1"), 1280, 720, 24,
60 12};
61 EXPECT_EQ(KeyUtil::CreateKey(info8),
62 NS_LITERAL_CSTRING("ResolutionLevel4-FrameRateLevel1-non8bit"))
63 << "Bit depth 12 bits";
64
65 DecoderBenchmarkInfo info9{NS_LITERAL_CSTRING("video/av1"), 1280, 720, 24,
66 16};
67 EXPECT_EQ(KeyUtil::CreateKey(info9),
68 NS_LITERAL_CSTRING("ResolutionLevel4-FrameRateLevel1-non8bit"))
69 << "Bit depth 16 bits";
70 }
71