1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "gtest/gtest.h"
17 
18 #include "effect/color_matrix.h"
19 
20 using namespace testing;
21 using namespace testing::ext;
22 
23 namespace OHOS {
24 namespace Rosen {
25 namespace Drawing {
26 class ColorMatrixTest : public testing::Test {
27 public:
28     static void SetUpTestCase();
29     static void TearDownTestCase();
30     void SetUp() override;
31     void TearDown() override;
32 };
33 
SetUpTestCase()34 void ColorMatrixTest::SetUpTestCase() {}
TearDownTestCase()35 void ColorMatrixTest::TearDownTestCase() {}
SetUp()36 void ColorMatrixTest::SetUp() {}
TearDown()37 void ColorMatrixTest::TearDown() {}
38 
39 /**
40  * @tc.name: CreateAndDestroy001
41  * @tc.desc:
42  * @tc.type: FUNC
43  * @tc.require: AR000GGNV3
44  * @tc.author:
45  */
46 HWTEST_F(ColorMatrixTest, CreateAndDestroy001, TestSize.Level1)
47 {
48     auto colorMatrix = std::make_unique<ColorMatrix>();
49     ASSERT_TRUE(colorMatrix != nullptr);
50     EXPECT_FALSE(nullptr == colorMatrix);
51 }
52 
53 /**
54  * @tc.name: SetIdentity001
55  * @tc.desc:
56  * @tc.type: FUNC
57  * @tc.require: AR000GGNV3
58  * @tc.author:
59  */
60 HWTEST_F(ColorMatrixTest, SetIdentity001, TestSize.Level1)
61 {
62     auto colorMatrix = std::make_unique<ColorMatrix>();
63     ASSERT_TRUE(colorMatrix != nullptr);
64     EXPECT_FALSE(nullptr == colorMatrix);
65     colorMatrix->SetIdentity();
66 }
67 
68 /**
69  * @tc.name: GetterAndSetterOfArray001
70  * @tc.desc:
71  * @tc.type: FUNC
72  * @tc.require: AR000GGNV3
73  * @tc.author:
74  */
75 HWTEST_F(ColorMatrixTest, GetterAndSetterOfArray001, TestSize.Level1)
76 {
77     auto colorMatrix = std::make_unique<ColorMatrix>();
78     ASSERT_TRUE(colorMatrix != nullptr);
79     scalar source[20] = { 0.0f };
80     colorMatrix->SetArray(source);
81     scalar destination[20] = { 121.0f };
82     colorMatrix->GetArray(destination);
83 }
84 
85 /**
86  * @tc.name: GetterAndSetterOfArray002
87  * @tc.desc:
88  * @tc.type: FUNC
89  * @tc.require: AR000GGNV3
90  * @tc.author:
91  */
92 HWTEST_F(ColorMatrixTest, GetterAndSetterOfArray002, TestSize.Level1)
93 {
94     auto colorMatrix = std::make_unique<ColorMatrix>();
95     ASSERT_TRUE(colorMatrix != nullptr);
96     scalar source[ColorMatrix::MATRIX_SIZE] = { 220.0f };
97     colorMatrix->SetArray(source);
98     scalar destination[20] = { 225.5f };
99     colorMatrix->GetArray(destination);
100 }
101 
102 /**
103  * @tc.name: SetConcat001
104  * @tc.desc:
105  * @tc.type: FUNC
106  * @tc.require: AR000GGNV3
107  * @tc.author:
108  */
109 HWTEST_F(ColorMatrixTest, SetConcat001, TestSize.Level1)
110 {
111     auto colorMatrix = std::make_unique<ColorMatrix>();
112     ASSERT_TRUE(colorMatrix != nullptr);
113     ColorMatrix colorMatrix1;
114     ColorMatrix colorMatrix2;
115     colorMatrix->SetConcat(colorMatrix1, colorMatrix2);
116 }
117 
118 /**
119  * @tc.name: PreConcat001
120  * @tc.desc:
121  * @tc.type: FUNC
122  * @tc.require: AR000GGNV3
123  * @tc.author:
124  */
125 HWTEST_F(ColorMatrixTest, PreConcat001, TestSize.Level1)
126 {
127     auto colorMatrix = std::make_unique<ColorMatrix>();
128     ASSERT_TRUE(colorMatrix != nullptr);
129     ColorMatrix colorMatrix1;
130     colorMatrix->PreConcat(colorMatrix1);
131 }
132 
133 /**
134  * @tc.name: PostConcat002
135  * @tc.desc:
136  * @tc.type: FUNC
137  * @tc.require: AR000GGNV3
138  * @tc.author:
139  */
140 HWTEST_F(ColorMatrixTest, PostConcat002, TestSize.Level1)
141 {
142     auto colorMatrix = std::make_unique<ColorMatrix>();
143     ASSERT_TRUE(colorMatrix != nullptr);
144     auto colorMatrix1 = std::make_unique<ColorMatrix>();
145     colorMatrix->PostConcat(*(colorMatrix1.get()));
146 }
147 
148 /**
149  * @tc.name: SetScale001
150  * @tc.desc:
151  * @tc.type: FUNC
152  * @tc.require: AR000GGNV3
153  * @tc.author:
154  */
155 HWTEST_F(ColorMatrixTest, SetScale001, TestSize.Level1)
156 {
157     auto colorMatrix = std::make_unique<ColorMatrix>();
158     ASSERT_TRUE(colorMatrix != nullptr);
159     colorMatrix->SetScale(1.1f, 1.3f, 1.0f, 0.5f);
160 }
161 
162 /**
163  * @tc.name: SetScale002
164  * @tc.desc:
165  * @tc.type: FUNC
166  * @tc.require: AR000GGNV3
167  * @tc.author:
168  */
169 HWTEST_F(ColorMatrixTest, SetScale002, TestSize.Level1)
170 {
171     auto colorMatrix = std::make_unique<ColorMatrix>();
172     ASSERT_TRUE(colorMatrix != nullptr);
173     ColorMatrix colorMatrix1;
174     colorMatrix->SetScale(0.5f, 1.0f, 1.5f, 0.6f);
175 }
176 } // namespace Drawing
177 } // namespace Rosen
178 } // namespace OHOS
179