• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 "ext/gex_dot_matrix_shader_params.h"
19 
20 using namespace testing;
21 using namespace testing::ext;
22 
23 namespace OHOS {
24 namespace GraphicsEffectEngine {
25 
26 using namespace Rosen;
27 
28 class DotMatrixShaderParamsTest : public testing::Test {
29 public:
30     static void SetUpTestCase();
31     static void TearDownTestCase();
32     void SetUp() override;
33     void TearDown() override;
34 
35     uint32_t bigSize_ = 1000;
36     std::vector<Drawing::Color> colorVector_ {Drawing::Color::COLOR_BLACK, Drawing::Color::COLOR_DKGRAY};
37     std::vector<Drawing::Point> pointVector_ {{0., 0.}, {1., 1.}};
38 };
39 
SetUpTestCase()40 void DotMatrixShaderParamsTest::SetUpTestCase() {}
41 
TearDownTestCase()42 void DotMatrixShaderParamsTest::TearDownTestCase() {}
43 
SetUp()44 void DotMatrixShaderParamsTest::SetUp() {}
45 
TearDown()46 void DotMatrixShaderParamsTest::TearDown() {}
47 
48 /**
49  * @tc.name: RotateEffectParamsMarshalling_001
50  * @tc.desc: Verify function RotateEffectParamsMarshalling
51  * @tc.type:FUNC
52  */
53 HWTEST_F(DotMatrixShaderParamsTest, RotateEffectParamsMarshalling_001, TestSize.Level1)
54 {
55     RotateEffectParams params;
56     Parcel parcel;
57     EXPECT_TRUE(params.Marshalling(parcel));
58     params.effectColors_.resize(bigSize_);
59     EXPECT_FALSE(params.Marshalling(parcel));
60 }
61 
62 /**
63  * @tc.name: RotateEffectParamsUnmarshalling_001
64  * @tc.desc: Verify function RotateEffectParamsUnmarshalling
65  * @tc.type:FUNC
66  */
67 HWTEST_F(DotMatrixShaderParamsTest, RotateEffectParamsUnmarshalling_001, TestSize.Level1)
68 {
69     RotateEffectParams params;
70     Parcel parcel;
71     EXPECT_FALSE(params.Unmarshalling(parcel));
72 
73     parcel.WriteUint32(0);
74     parcel.WriteUint32(0);
75     EXPECT_TRUE(params.Unmarshalling(parcel));
76 
77     Parcel parcel2;
78     parcel2.WriteUint32(1);
79     parcel2.WriteUint32(1);
80     EXPECT_FALSE(params.Unmarshalling(parcel2));
81 
82     Parcel parcel3;
83     parcel3.WriteUint32(0);
84     parcel3.WriteUint32(bigSize_);
85     EXPECT_FALSE(params.Unmarshalling(parcel3));
86 }
87 
88 /**
89  * @tc.name: RotateEffectParamsUnmarshalling_002
90  * @tc.desc: Verify function RotateEffectParamsUnmarshalling
91  * @tc.type:FUNC
92  */
93 HWTEST_F(DotMatrixShaderParamsTest, RotateEffectParamsUnmarshalling_002, TestSize.Level1)
94 {
95     RotateEffectParams params1{DotMatrixDirection::TOP, colorVector_};
96     Parcel parcel;
97     EXPECT_TRUE(params1.Marshalling(parcel));
98     RotateEffectParams params2;
99     EXPECT_TRUE(params2.Unmarshalling(parcel));
100     EXPECT_EQ(params1.pathDirection_, params2.pathDirection_);
101     EXPECT_EQ(params1.effectColors_, params2.effectColors_);
102 }
103 
104 /**
105  * @tc.name: RippleEffectParamsMarshalling_001
106  * @tc.desc: Verify function RippleEffectParamsMarshalling
107  * @tc.type:FUNC
108  */
109 HWTEST_F(DotMatrixShaderParamsTest, RippleEffectParamsMarshalling_001, TestSize.Level1)
110 {
111     RippleEffectParams params;
112     Parcel parcel;
113     EXPECT_TRUE(params.Marshalling(parcel));
114     params.effectColors_.resize(bigSize_);
115     EXPECT_FALSE(params.Marshalling(parcel));
116 
117     params = RippleEffectParams();
118     params.colorFractions_.resize(bigSize_);
119     EXPECT_FALSE(params.Marshalling(parcel));
120 
121     params = RippleEffectParams();
122     params.startPoints_.resize(bigSize_);
123     EXPECT_FALSE(params.Marshalling(parcel));
124 }
125 
126 /**
127  * @tc.name: RippleEffectParamsUnMarshalling_001
128  * @tc.desc: Verify function RippleEffectParamsUnMarshalling
129  * @tc.type:FUNC
130  */
131 HWTEST_F(DotMatrixShaderParamsTest, RippleEffectParamsUnMarshalling_001, TestSize.Level1)
132 {
133     RippleEffectParams params;
134     Parcel parcel;
135     EXPECT_FALSE(params.Unmarshalling(parcel));
136 
137     parcel.WriteUint32(0);
138     parcel.WriteUint32(0);
139     parcel.WriteUint32(0);
140     parcel.WriteFloat(0.f);
141     parcel.WriteBool(false);
142     EXPECT_TRUE(params.Unmarshalling(parcel));
143 
144     Parcel parcel2;
145     parcel2.WriteUint32(bigSize_);
146     parcel2.WriteUint32(1);
147     EXPECT_FALSE(params.Unmarshalling(parcel2));
148 
149     Parcel parcel3;
150     parcel3.WriteUint32(0);
151     parcel3.WriteUint32(bigSize_);
152     EXPECT_FALSE(params.Unmarshalling(parcel3));
153 }
154 
155 /**
156  * @tc.name: DotMatrixNormalParamsMarshalling_001
157  * @tc.desc: Verify function DotMatrixNormalParamsMarshalling
158  * @tc.type:FUNC
159  */
160 HWTEST_F(DotMatrixShaderParamsTest, DotMatrixNormalParamsMarshalling_001, TestSize.Level1)
161 {
162     DotMatrixNormalParams params;
163     Parcel parcel;
164     EXPECT_TRUE(params.Marshalling(parcel));
165 }
166 
167 /**
168  * @tc.name: DotMatrixNormalParamsUnMarshalling_001
169  * @tc.desc: Verify function DotMatrixNormalParamsUnMarshalling
170  * @tc.type:FUNC
171  */
172 HWTEST_F(DotMatrixShaderParamsTest, DotMatrixNormalParamsUnMarshalling_001, TestSize.Level1)
173 {
174     DotMatrixNormalParams params;
175     Parcel parcel;
176     ASSERT_FALSE(params.Unmarshalling(parcel));
177     parcel.WriteUint32(0);
178     parcel.WriteFloat(0.f);
179     parcel.WriteFloat(0.f);
180     parcel.WriteUint32(0);
181     EXPECT_TRUE(params.Unmarshalling(parcel));
182 }
183 
184 /**
185  * @tc.name: DotMatrixShaderParamsMarshalling_001
186  * @tc.desc: Verify function DotMatrixShaderParamsMarshalling
187  * @tc.type:FUNC
188  */
189 HWTEST_F(DotMatrixShaderParamsTest, DotMatrixShaderParamsMarshalling_001, TestSize.Level1)
190 {
191     DotMatrixShaderParams params;
192     Parcel parcel;
193     EXPECT_TRUE(params.Marshalling(parcel));
194 }
195 
196 /**
197  * @tc.name: DotMatrixShaderParamsUnMarshalling_001
198  * @tc.desc: Verify function DotMatrixShaderParamsUnMarshalling
199  * @tc.type:FUNC
200  */
201 HWTEST_F(DotMatrixShaderParamsTest, DotMatrixShaderParamsUnMarshalling_001, TestSize.Level1)
202 {
203     DotMatrixShaderParams params1;
204     Parcel parcel;
205     EXPECT_TRUE(params1.Marshalling(parcel));
206     DotMatrixShaderParams params2;
207     EXPECT_TRUE(params2.Unmarshalling(parcel));
208 }
209 
210 } // namespace GraphicsEffectEngine
211 } // namespace OHOS