• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2020 The Chromium Authors. All Rights Reserved.
3  *
4  * This software is provided 'as-is', without any express or implied
5  * warranty.  In no event will the authors be held liable for any damages
6  * arising from the use of this software.
7  *
8  * Permission is granted to anyone to use this software for any purpose,
9  * including commercial applications, and to alter it and redistribute it
10  * freely, subject to the following restrictions:
11  *
12  * 1. The origin of this software must not be misrepresented; you must not
13  *    claim that you wrote the original software. If you use this software
14  *    in a product, an acknowledgment in the product documentation would be
15  *    appreciated but is not required.
16  * 2. Altered source versions must be plainly marked as such, and must not be
17  *    misrepresented as being the original software.
18  * 3. This notice may not be removed or altered from any source distribution.
19  */
20 
21 #include <gtest/gtest.h>
22 
23 extern "C" int testBmp(int yuv, int noyuvpad, int autoalloc);
24 extern "C" int testThreeByte444(int yuv, int noyuvpad, int autoalloc);
25 extern "C" int testFourByte444(int yuv, int noyuvpad, int autoalloc);
26 extern "C" int testThreeByte422(int yuv, int noyuvpad, int autoalloc);
27 extern "C" int testFourByte422(int yuv, int noyuvpad, int autoalloc);
28 extern "C" int testThreeByte420(int yuv, int noyuvpad, int autoalloc);
29 extern "C" int testFourByte420(int yuv, int noyuvpad, int autoalloc);
30 extern "C" int testThreeByte440(int yuv, int noyuvpad, int autoalloc);
31 extern "C" int testFourByte440(int yuv, int noyuvpad, int autoalloc);
32 extern "C" int testThreeByte411(int yuv, int noyuvpad, int autoalloc);
33 extern "C" int testFourByte411(int yuv, int noyuvpad, int autoalloc);
34 extern "C" int testOnlyGray(int yuv, int noyuvpad, int autoalloc);
35 extern "C" int testThreeByteGray(int yuv, int noyuvpad, int autoalloc);
36 extern "C" int testFourByteGray(int yuv, int noyuvpad, int autoalloc);
37 extern "C" int testBufSize(int yuv, int noyuvpad, int autoalloc);
38 extern "C" int testYUVOnlyRGB444(int noyuvpad, int autoalloc);
39 extern "C" int testYUVOnlyRGB422(int noyuvpad, int autoalloc);
40 extern "C" int testYUVOnlyRGB420(int noyuvpad, int autoalloc);
41 extern "C" int testYUVOnlyRGB440(int noyuvpad, int autoalloc);
42 extern "C" int testYUVOnlyRGB411(int noyuvpad, int autoalloc);
43 extern "C" int testYUVOnlyRGBGray(int noyuvpad, int autoalloc);
44 extern "C" int testYUVOnlyGrayGray(int noyuvpad, int autoalloc);
45 
46 const int YUV = 1;
47 const int NO_YUV = 0;
48 const int NO_YUV_PAD = 1;
49 const int YUV_PAD = 0;
50 const int AUTO_ALLOC = 1;
51 const int NO_AUTO_ALLOC = 0;
52 
53 class TJUnitTest : public
54   ::testing::TestWithParam<std::tuple<int, int, int>> {};
55 
TEST_P(TJUnitTest,BMP)56 TEST_P(TJUnitTest, BMP) {
57   EXPECT_EQ(testBmp(std::get<0>(GetParam()),
58                     std::get<1>(GetParam()),
59                     std::get<2>(GetParam())), 0);
60 }
61 
TEST_P(TJUnitTest,ThreeByte444)62 TEST_P(TJUnitTest, ThreeByte444) {
63   EXPECT_EQ(testThreeByte444(std::get<0>(GetParam()),
64                              std::get<1>(GetParam()),
65                              std::get<2>(GetParam())), 0);
66 }
67 
TEST_P(TJUnitTest,FourByte444)68 TEST_P(TJUnitTest, FourByte444) {
69   EXPECT_EQ(testFourByte444(std::get<0>(GetParam()),
70                             std::get<1>(GetParam()),
71                             std::get<2>(GetParam())), 0);
72 }
73 
TEST_P(TJUnitTest,ThreeByte422)74 TEST_P(TJUnitTest, ThreeByte422) {
75   EXPECT_EQ(testThreeByte422(std::get<0>(GetParam()),
76                              std::get<1>(GetParam()),
77                              std::get<2>(GetParam())), 0);
78 }
79 
TEST_P(TJUnitTest,FourByte422)80 TEST_P(TJUnitTest, FourByte422) {
81   EXPECT_EQ(testFourByte422(std::get<0>(GetParam()),
82                             std::get<1>(GetParam()),
83                             std::get<2>(GetParam())), 0);
84 }
85 
TEST_P(TJUnitTest,ThreeByte420)86 TEST_P(TJUnitTest, ThreeByte420) {
87   EXPECT_EQ(testThreeByte420(std::get<0>(GetParam()),
88                              std::get<1>(GetParam()),
89                              std::get<2>(GetParam())), 0);
90 }
91 
TEST_P(TJUnitTest,FourByte420)92 TEST_P(TJUnitTest, FourByte420) {
93   EXPECT_EQ(testFourByte420(std::get<0>(GetParam()),
94                             std::get<1>(GetParam()),
95                             std::get<2>(GetParam())), 0);
96 }
97 
TEST_P(TJUnitTest,ThreeByte440)98 TEST_P(TJUnitTest, ThreeByte440) {
99   EXPECT_EQ(testThreeByte440(std::get<0>(GetParam()),
100                              std::get<1>(GetParam()),
101                              std::get<2>(GetParam())), 0);
102 }
103 
TEST_P(TJUnitTest,FourByte440)104 TEST_P(TJUnitTest, FourByte440) {
105   EXPECT_EQ(testFourByte440(std::get<0>(GetParam()),
106                             std::get<1>(GetParam()),
107                             std::get<2>(GetParam())), 0);
108 }
109 
TEST_P(TJUnitTest,ThreeByte411)110 TEST_P(TJUnitTest, ThreeByte411) {
111   EXPECT_EQ(testThreeByte411(std::get<0>(GetParam()),
112                              std::get<1>(GetParam()),
113                              std::get<2>(GetParam())), 0);
114 }
115 
TEST_P(TJUnitTest,FourByte411)116 TEST_P(TJUnitTest, FourByte411) {
117   EXPECT_EQ(testFourByte411(std::get<0>(GetParam()),
118                             std::get<1>(GetParam()),
119                             std::get<2>(GetParam())), 0);
120 }
121 
TEST_P(TJUnitTest,OnlyGray)122 TEST_P(TJUnitTest, OnlyGray) {
123   EXPECT_EQ(testOnlyGray(std::get<0>(GetParam()),
124                          std::get<1>(GetParam()),
125                          std::get<2>(GetParam())), 0);
126 }
127 
TEST_P(TJUnitTest,ThreeByteGray)128 TEST_P(TJUnitTest, ThreeByteGray) {
129   EXPECT_EQ(testThreeByteGray(std::get<0>(GetParam()),
130                               std::get<1>(GetParam()),
131                               std::get<2>(GetParam())), 0);
132 }
133 
TEST_P(TJUnitTest,FourByteGray)134 TEST_P(TJUnitTest, FourByteGray) {
135   EXPECT_EQ(testFourByteGray(std::get<0>(GetParam()),
136                              std::get<1>(GetParam()),
137                              std::get<2>(GetParam())), 0);
138 }
139 
TEST_P(TJUnitTest,BufSize)140 TEST_P(TJUnitTest, BufSize) {
141   EXPECT_EQ(testBufSize(std::get<0>(GetParam()),
142                         std::get<1>(GetParam()),
143                         std::get<2>(GetParam())), 0);
144 }
145 
146 INSTANTIATE_TEST_SUITE_P(
147         TJUnitTests,
148         TJUnitTest,
149         ::testing::Values(std::make_tuple(NO_YUV, YUV_PAD, NO_AUTO_ALLOC),
150                           std::make_tuple(NO_YUV, YUV_PAD, AUTO_ALLOC),
151                           std::make_tuple(NO_YUV, NO_YUV_PAD, NO_AUTO_ALLOC),
152                           std::make_tuple(NO_YUV, NO_YUV_PAD, AUTO_ALLOC),
153                           std::make_tuple(YUV, YUV_PAD, NO_AUTO_ALLOC),
154                           std::make_tuple(YUV, YUV_PAD, AUTO_ALLOC),
155                           std::make_tuple(YUV, NO_YUV_PAD, NO_AUTO_ALLOC),
156                           std::make_tuple(YUV, NO_YUV_PAD, AUTO_ALLOC)));
157 
158 class TJUnitTestYUV : public ::testing::TestWithParam<std::tuple<int, int>> {};
159 
TEST_P(TJUnitTestYUV,YUVOnlyRGB444)160 TEST_P(TJUnitTestYUV, YUVOnlyRGB444) {
161   EXPECT_EQ(testYUVOnlyRGB444(std::get<0>(GetParam()),
162                               std::get<1>(GetParam())), 0);
163 }
164 
TEST_P(TJUnitTestYUV,YUVOnlyRGB422)165 TEST_P(TJUnitTestYUV, YUVOnlyRGB422) {
166   EXPECT_EQ(testYUVOnlyRGB422(std::get<0>(GetParam()),
167                               std::get<1>(GetParam())), 0);
168 }
169 
TEST_P(TJUnitTestYUV,YUVOnlyRGB420)170 TEST_P(TJUnitTestYUV, YUVOnlyRGB420) {
171   EXPECT_EQ(testYUVOnlyRGB420(std::get<0>(GetParam()),
172                               std::get<1>(GetParam())), 0);
173 }
174 
TEST_P(TJUnitTestYUV,YUVOnlyRGB440)175 TEST_P(TJUnitTestYUV, YUVOnlyRGB440) {
176   EXPECT_EQ(testYUVOnlyRGB440(std::get<0>(GetParam()),
177                               std::get<1>(GetParam())), 0);
178 }
179 
TEST_P(TJUnitTestYUV,YUVOnlyRGB411)180 TEST_P(TJUnitTestYUV, YUVOnlyRGB411) {
181   EXPECT_EQ(testYUVOnlyRGB411(std::get<0>(GetParam()),
182                               std::get<1>(GetParam())), 0);
183 }
184 
TEST_P(TJUnitTestYUV,YUVOnlyRGBGray)185 TEST_P(TJUnitTestYUV, YUVOnlyRGBGray) {
186   EXPECT_EQ(testYUVOnlyRGBGray(std::get<0>(GetParam()),
187                                std::get<1>(GetParam())), 0);
188 }
189 
TEST_P(TJUnitTestYUV,YUVOnlyGrayGray)190 TEST_P(TJUnitTestYUV, YUVOnlyGrayGray) {
191   EXPECT_EQ(testYUVOnlyGrayGray(std::get<0>(GetParam()),
192                                 std::get<1>(GetParam())), 0);
193 }
194 
195 INSTANTIATE_TEST_SUITE_P(
196         TJUnitTestsYUV,
197         TJUnitTestYUV,
198         ::testing::Values(std::make_tuple(YUV_PAD, NO_AUTO_ALLOC),
199                           std::make_tuple(YUV_PAD, AUTO_ALLOC),
200                           std::make_tuple(NO_YUV_PAD, NO_AUTO_ALLOC),
201                           std::make_tuple(NO_YUV_PAD, AUTO_ALLOC)));
202