• 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() {}
TearDownTestCase()41 void DotMatrixShaderParamsTest::TearDownTestCase() {}
SetUp()42 void DotMatrixShaderParamsTest::SetUp() {}
TearDown()43 void DotMatrixShaderParamsTest::TearDown() {}
44 
45 /**
46  * @tc.name: RotateEffectParamsMarshalling001
47  * @tc.desc: Verify function GetDescription
48  * @tc.type:FUNC
49  */
50 HWTEST_F(DotMatrixShaderParamsTest, RotateEffectParamsMarshalling001, TestSize.Level1)
51 {
52     RotateEffectParams params;
53     Parcel parcel;
54     EXPECT_TRUE(params.Marshalling(parcel));
55     params.effectColors_.resize(bigSize_);
56     EXPECT_FALSE(params.Marshalling(parcel));
57 }
58 
59 /**
60  * @tc.name: RotateEffectParamsUnmarshalling001
61  * @tc.desc: Verify function GetDescription
62  * @tc.type:FUNC
63  */
64 HWTEST_F(DotMatrixShaderParamsTest, RotateEffectParamsUnmarshalling001, TestSize.Level1)
65 {
66     RotateEffectParams params;
67     Parcel parcel;
68     EXPECT_FALSE(params.Unmarshalling(parcel));
69 
70     parcel.WriteUint32(0);
71     parcel.WriteUint32(0);
72     EXPECT_TRUE(params.Unmarshalling(parcel));
73 
74     Parcel parcel2;
75     parcel2.WriteUint32(1);
76     parcel2.WriteUint32(1);
77     EXPECT_FALSE(params.Unmarshalling(parcel2));
78 
79     Parcel parcel3;
80     parcel3.WriteUint32(0);
81     parcel3.WriteUint32(bigSize_);
82     EXPECT_FALSE(params.Unmarshalling(parcel3));
83 }
84 
85 /**
86  * @tc.name: RotateEffectParamsUnmarshalling002
87  * @tc.desc: Verify function GetDescription
88  * @tc.type:FUNC
89  */
90 HWTEST_F(DotMatrixShaderParamsTest, RotateEffectParamsUnmarshalling002, TestSize.Level1)
91 {
92     RotateEffectParams params1{DotMatrixDirection::TOP, colorVector_};
93     Parcel parcel;
94     EXPECT_TRUE(params1.Marshalling(parcel));
95     RotateEffectParams params2;
96     EXPECT_TRUE(params2.Unmarshalling(parcel));
97     EXPECT_EQ(params1.pathDirection_, params2.pathDirection_);
98     EXPECT_EQ(params1.effectColors_, params2.effectColors_);
99 }
100 
101 /**
102  * @tc.name: RippleEffectParamsMarshalling001
103  * @tc.desc: Verify function GetDescription
104  * @tc.type:FUNC
105  */
106 HWTEST_F(DotMatrixShaderParamsTest, RippleEffectParamsMarshalling001, TestSize.Level1)
107 {
108     RippleEffectParams params;
109     Parcel parcel;
110     EXPECT_TRUE(params.Marshalling(parcel));
111     params.effectColors_.resize(bigSize_);
112     EXPECT_FALSE(params.Marshalling(parcel));
113 
114     params = RippleEffectParams();
115     params.colorFractions_.resize(bigSize_);
116     EXPECT_FALSE(params.Marshalling(parcel));
117 
118     params = RippleEffectParams();
119     params.startPoints_.resize(bigSize_);
120     EXPECT_FALSE(params.Marshalling(parcel));
121 }
122 
123 /**
124  * @tc.name: RippleEffectParamsUnMarshalling001
125  * @tc.desc: Verify function GetDescription
126  * @tc.type:FUNC
127  */
128 HWTEST_F(DotMatrixShaderParamsTest, RippleEffectParamsUnMarshalling001, TestSize.Level1)
129 {
130     RippleEffectParams params;
131     Parcel parcel;
132     EXPECT_FALSE(params.Unmarshalling(parcel));
133 
134     parcel.WriteUint32(0);
135     parcel.WriteUint32(0);
136     parcel.WriteUint32(0);
137     parcel.WriteFloat(0.f);
138     parcel.WriteBool(false);
139     EXPECT_TRUE(params.Unmarshalling(parcel));
140 
141     Parcel parcel2;
142     parcel2.WriteUint32(bigSize_);
143     parcel2.WriteUint32(1);
144     EXPECT_FALSE(params.Unmarshalling(parcel2));
145 
146     Parcel parcel3;
147     parcel3.WriteUint32(0);
148     parcel3.WriteUint32(bigSize_);
149     EXPECT_FALSE(params.Unmarshalling(parcel3));
150 }
151 
152 /**
153  * @tc.name: DotMatrixNormalParamsMarshalling001
154  * @tc.desc: Verify function GetDescription
155  * @tc.type:FUNC
156  */
157 HWTEST_F(DotMatrixShaderParamsTest, DotMatrixNormalParamsMarshalling001, TestSize.Level1)
158 {
159     DotMatrixNormalParams params;
160     Parcel parcel;
161     EXPECT_TRUE(params.Marshalling(parcel));
162 }
163 
164 /**
165  * @tc.name: DotMatrixNormalParamsUnMarshalling001
166  * @tc.desc: Verify function GetDescription
167  * @tc.type:FUNC
168  */
169 HWTEST_F(DotMatrixShaderParamsTest, DotMatrixNormalParamsUnMarshalling001, TestSize.Level1)
170 {
171     DotMatrixNormalParams params;
172     Parcel parcel;
173     ASSERT_FALSE(params.Unmarshalling(parcel));
174     parcel.WriteUint32(0);
175     parcel.WriteFloat(0.f);
176     parcel.WriteFloat(0.f);
177     parcel.WriteUint32(0);
178     EXPECT_TRUE(params.Unmarshalling(parcel));
179 }
180 
181 /**
182  * @tc.name: DotMatrixShaderParamsMarshalling001
183  * @tc.desc: Verify function GetDescription
184  * @tc.type:FUNC
185  */
186 HWTEST_F(DotMatrixShaderParamsTest, DotMatrixShaderParamsMarshalling001, TestSize.Level1)
187 {
188     DotMatrixShaderParams params;
189     Parcel parcel;
190     EXPECT_TRUE(params.Marshalling(parcel));
191 }
192 
193 /**
194  * @tc.name: DotMatrixShaderParamsUnMarshalling001
195  * @tc.desc: Verify function GetDescription
196  * @tc.type:FUNC
197  */
198 HWTEST_F(DotMatrixShaderParamsTest, DotMatrixShaderParamsUnMarshalling001, TestSize.Level1)
199 {
200     DotMatrixShaderParams params1;
201     Parcel parcel;
202     EXPECT_TRUE(params1.Marshalling(parcel));
203     DotMatrixShaderParams params2;
204     EXPECT_TRUE(params2.Unmarshalling(parcel));
205 }
206 
207 } // namespace GraphicsEffectEngine
208 } // namespace OHOS