1 /*
2  * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 <cstdint>
17 #include <functional>
18 #include <optional>
19 #include <string>
20 #include <tuple>
21 #include <vector>
22 
23 #include "gtest/gtest.h"
24 
25 #include "base/geometry/ng/size_t.h"
26 #include "base/geometry/size.h"
27 #include "core/components_ng/property/calc_length.h"
28 #include "core/components_ng/property/layout_constraint.h"
29 #include "core/components_ng/property/measure_property.h"
30 
31 using namespace testing;
32 using namespace testing::ext;
33 
34 namespace OHOS::Ace::NG {
35 class LayoutConstraintTestNg : public testing::Test {
36 public:
SetUpTestSuite()37     static void SetUpTestSuite() {};
TearDownTestSuite()38     static void TearDownTestSuite() {};
39 };
40 
41 /**
42  * @tc.name: LayoutConstraintTestNg001
43  * @tc.desc: Test ApplyAspectRatio.
44  * @tc.type: FUNC
45  */
46 HWTEST_F(LayoutConstraintTestNg, LayoutConstraintTestNg001, TestSize.Level1)
47 {
48     LayoutConstraintF layoutConstraint;
49     layoutConstraint.parentIdealSize = OptionalSizeF(768, 1024);
50     layoutConstraint.selfIdealSize = OptionalSizeF(480, 960);
51 
52     auto calcSize = std::make_optional<CalcSize>();
53     /**
54      * @tc.steps: step1 call ApplyAspectRatio and set ratio < 0.
55      * @tc.expected: the set value do not change.
56      */
57     float ratio = -1.0;
58     layoutConstraint.ApplyAspectRatio(ratio, calcSize);
59     EXPECT_EQ(layoutConstraint.parentIdealSize.Width().value(), 768.0);
60 
61     /**
62      * @tc.steps: step2 call ApplyAspectRatio, set ratio = 1 and useDefinedWidth.
63      * @tc.expected: the selfIdealSize.Width() = selfIdealSize.Height() * 1.
64      */
65     ratio = 1.0;
66     std::string widthStr = "768px";
67     CalcLength width = CalcLength::FromString(widthStr);
68     std::string heightStr = "1024px";
69     CalcLength height = CalcLength::FromString(heightStr);
70     calcSize = std::make_optional<CalcSize>(width, height);
71     layoutConstraint.ApplyAspectRatio(ratio, calcSize);
72     EXPECT_EQ(layoutConstraint.selfIdealSize.Width(), layoutConstraint.selfIdealSize.Height());
73 
74     /**
75      * @tc.steps: step3 call ApplyAspectRatio, set ratio = 2 and not useDefinedWidth
76                     and selfIdealSize.Width().
77      * @tc.expected: the selfIdealSize.Width() = selfIdealSize.Height() * 2.
78      */
79     ratio = 2.0;
80     width = CalcLength();
81     heightStr = "1024px";
82     height = CalcLength::FromString(heightStr);
83     calcSize = std::make_optional<CalcSize>(width, height);
84     layoutConstraint.ApplyAspectRatio(ratio, calcSize);
85     EXPECT_EQ(layoutConstraint.selfIdealSize.Width().value(), layoutConstraint.selfIdealSize.Height().value() * 2);
86 
87     /**
88      * @tc.steps: step4 call ApplyAspectRatio, set ratio = 4 and not useDefinedWidth
89                     and selfIdealSize.Height().
90      * @tc.expected: the selfIdealSize.Width() = selfIdealSize.Height() * 4.
91      */
92     ratio = 4.0;
93     widthStr = "768px";
94     width = CalcLength::FromString(widthStr);
95     height = CalcLength();
96     calcSize = std::make_optional<CalcSize>(width, height);
97     layoutConstraint.ApplyAspectRatio(ratio, calcSize);
98     EXPECT_EQ(layoutConstraint.selfIdealSize.Width().value(), layoutConstraint.selfIdealSize.Height().value() * 4);
99 
100     /**
101      * @tc.steps: step5 call ApplyAspectRatio, set ratio = 4 and not useDefinedWidth
102                     and selfIdealSize is null and maxHeight and maxWidth is inf.
103      * @tc.expected: the set value do not change.
104      */
105     calcSize = std::nullopt;
106     layoutConstraint.ApplyAspectRatio(ratio, calcSize);
107     EXPECT_EQ(layoutConstraint.parentIdealSize.Width().value(), 768.0);
108 
109     /**
110      * @tc.steps: step6 call ApplyAspectRatio, set ratio = 4 and not useDefinedWidth
111                     and selfIdealSize is null and maxHeight and maxWidth is 1024.
112      * @tc.expected: the set value do not change.
113      */
114     SizeT<float> size(1024, 2048);
115     layoutConstraint.UpdateMaxSizeWithCheck(size);
116     layoutConstraint.ApplyAspectRatio(ratio, calcSize);
117     EXPECT_EQ(layoutConstraint.parentIdealSize.Width().value(), layoutConstraint.parentIdealSize.Height().value() * 4);
118 
119     /**
120      * @tc.steps: step7 call ApplyAspectRatio, set ratio = 1, useDefinedWidth and useDefinedWidth.value() = false.
121      * @tc.expected: the selfIdealSize.Width() = selfIdealSize.Height() * 1.
122      */
123     ratio = 1.0;
124     heightStr = "1024px";
125     height = CalcLength::FromString(heightStr);
126     calcSize = std::make_optional<CalcSize>(std::nullopt, height);
127     layoutConstraint.ApplyAspectRatio(ratio, calcSize);
128     EXPECT_EQ(layoutConstraint.selfIdealSize.Width(), layoutConstraint.selfIdealSize.Height());
129 
130     /**
131      * @tc.steps: step8 call ApplyAspectRatio, set ratio = 1, useDefinedWidth NULL.
132      * @tc.expected: the selfIdealSize.Width() = selfIdealSize.Height() * 2.
133      */
134     ratio = 2.0;
135     calcSize = std::nullopt;
136     std::optional<float> selfIdeaWidth = std::nullopt;
137     auto selfIdeaHeight = std::make_optional<float>(960);
138     layoutConstraint.selfIdealSize = OptionalSizeF(selfIdeaWidth, selfIdeaHeight);
139     layoutConstraint.ApplyAspectRatio(ratio, calcSize);
140     EXPECT_EQ(layoutConstraint.selfIdealSize.Width().value(), layoutConstraint.selfIdealSize.Height().value() * 2);
141 
142     /**
143      * @tc.steps: step8 call ApplyAspectRatio, set ratio = 1, useDefinedWidth NULL.
144      * @tc.expected: the selfIdealSize.Width() = selfIdealSize.Height() * 4.
145      */
146     ratio = 4.0;
147     calcSize = std::nullopt;
148     selfIdeaWidth = std::nullopt;
149     selfIdeaHeight = std::nullopt;
150     layoutConstraint.selfIdealSize = OptionalSizeF(selfIdeaWidth, selfIdeaHeight);
151     layoutConstraint.ApplyAspectRatio(ratio, calcSize);
152     EXPECT_EQ(layoutConstraint.minSize.Width(), 0);
153 
154     /**
155      * @tc.steps: step8 call ApplyAspectRatio, set ratio = 1, useDefinedWidth NULL.
156      * @tc.expected: the selfIdealSize.Width() = selfIdealSize.Height() * 1.
157      */
158     ratio = 1.0;
159     calcSize = std::nullopt;
160     selfIdeaWidth = std::nullopt;
161     selfIdeaHeight = std::nullopt;
162     layoutConstraint.selfIdealSize = OptionalSizeF(selfIdeaWidth, selfIdeaHeight);
163     layoutConstraint.minSize = SizeT<float>(1, 2);
164     layoutConstraint.maxSize = SizeT<float>(100, 200);
165     layoutConstraint.ApplyAspectRatio(ratio, calcSize);
166     EXPECT_EQ(layoutConstraint.minSize.Width(), layoutConstraint.minSize.Height());
167 }
168 
169 /**
170  * @tc.name: LayoutConstraintTestNg002
171  * @tc.desc: Test ApplyAspectRatioToParentIdealSize.
172  * @tc.type: FUNC
173  */
174 HWTEST_F(LayoutConstraintTestNg, LayoutConstraintTestNg002, TestSize.Level1)
175 {
176     LayoutConstraintF layoutConstraint;
177     layoutConstraint.parentIdealSize = OptionalSizeF(768, 1024);
178     layoutConstraint.selfIdealSize = OptionalSizeF(480, 960);
179 
180     /**
181      * @tc.steps: step1 call ApplyAspectRatioToParentIdealSize and set ratio < 0 and useWidth false.
182      * @tc.expected: the set value do not change.
183      */
184     bool useWidth = false;
185     float ratio = -1;
186     layoutConstraint.ApplyAspectRatioToParentIdealSize(useWidth, ratio);
187     EXPECT_EQ(layoutConstraint.parentIdealSize.Width().value(), 768.0);
188 
189     /**
190      * @tc.steps: step2 call ApplyAspectRatioToParentIdealSize and set ratio = 1 and useWidth true.
191      * @tc.expected: parentIdealSize.Width() == layoutConstraint.parentIdealSize.Height().
192      */
193     ratio = 1;
194     useWidth = true;
195     layoutConstraint.ApplyAspectRatioToParentIdealSize(useWidth, ratio);
196     EXPECT_EQ(layoutConstraint.parentIdealSize.Width().value(), layoutConstraint.parentIdealSize.Height().value());
197 
198     /**
199      * @tc.steps: step3 call ApplyAspectRatioToParentIdealSize and set ratio = 2 and useWidth false.
200      * @tc.expected: parentIdealSize.Width() == layoutConstraint.parentIdealSize.Height() * 2.
201      */
202     ratio = 2;
203     useWidth = false;
204     layoutConstraint.ApplyAspectRatioToParentIdealSize(useWidth, ratio);
205     EXPECT_EQ(layoutConstraint.parentIdealSize.Width().value(), layoutConstraint.parentIdealSize.Height().value() * 2);
206 
207     /**
208      * @tc.steps: step4 call ApplyAspectRatioToParentIdealSize and set ratio = 2 and useWidth false.
209      * @tc.expected: the set value do not change.
210      */
211     ratio = 4;
212     useWidth = false;
213     layoutConstraint.parentIdealSize = OptionalSizeF();
214     layoutConstraint.parentIdealSize.SetWidth(768);
215     layoutConstraint.ApplyAspectRatioToParentIdealSize(useWidth, ratio);
216     EXPECT_EQ(layoutConstraint.parentIdealSize.Width().value(), 768.0);
217 }
218 
219 /**
220  * @tc.name: LayoutConstraintTestNg003
221  * @tc.desc: Test ApplyAspectRatioByMaxSize.
222  * @tc.type: FUNC
223  */
224 HWTEST_F(LayoutConstraintTestNg, LayoutConstraintTestNg003, TestSize.Level1)
225 {
226     LayoutConstraintF layoutConstraint;
227     layoutConstraint.parentIdealSize = OptionalSizeF(768, 1024);
228     layoutConstraint.selfIdealSize = OptionalSizeF(480, 960);
229     layoutConstraint.minSize.SetWidth(2);
230     layoutConstraint.minSize.SetHeight(3);
231     layoutConstraint.maxSize.SetWidth(2048);
232     layoutConstraint.maxSize.SetHeight(4096);
233 
234     /**
235      * @tc.steps: step1 call ApplyAspectRatioByMaxSize and set ratio < 0 and useDefinedWidth false.
236      * @tc.expected: the set value do not change.
237      */
238     auto useDefinedWidth = std::make_optional<bool>(false);
239     float ratio = -1;
240     layoutConstraint.ApplyAspectRatioByMaxSize(ratio, useDefinedWidth);
241     EXPECT_EQ(layoutConstraint.parentIdealSize.Width().value(), 768.0);
242 
243     /**
244      * @tc.steps: step2 call ApplyAspectRatioByMaxSize and set ratio = 1 and useDefinedWidth true.
245      * @tc.expected: the set value do not change.
246      */
247     ratio = 1;
248     useDefinedWidth = std::make_optional<bool>(true);
249     layoutConstraint.ApplyAspectRatioByMaxSize(ratio, useDefinedWidth);
250     EXPECT_EQ(layoutConstraint.minSize.Width(), layoutConstraint.minSize.Height());
251 
252     /**
253      * @tc.steps: step3 call ApplyAspectRatioByMaxSize and set ratio = 2 and useDefinedWidth false.
254      * @tc.expected: minSize.Width() == minSize.Height() * 2.
255      */
256     ratio = 2;
257     useDefinedWidth = std::make_optional<bool>(false);
258     layoutConstraint.ApplyAspectRatioByMaxSize(ratio, useDefinedWidth);
259     EXPECT_EQ(layoutConstraint.minSize.Width(), layoutConstraint.minSize.Height() * 2);
260 
261     /**
262      * @tc.steps: step4 call ApplyAspectRatioByMaxSize and set ratio = 2 and useDefinedWidth is null.
263      * @tc.expected: minSize.Width() == minSize.Height() * 4.
264      */
265     ratio = 4;
266     useDefinedWidth = std::nullopt;
267     layoutConstraint.ApplyAspectRatioByMaxSize(ratio, useDefinedWidth);
268     EXPECT_EQ(layoutConstraint.minSize.Width(), layoutConstraint.minSize.Height() * 4);
269 }
270 
271 /**
272  * @tc.name: LayoutConstraintTestNg004
273  * @tc.desc: Test ApplyAspectRatioByMaxSize.
274  * @tc.type: FUNC
275  */
276 HWTEST_F(LayoutConstraintTestNg, LayoutConstraintTestNg004, TestSize.Level1)
277 {
278     LayoutConstraintF layoutConstraint;
279     layoutConstraint.parentIdealSize = OptionalSizeF(768, 1024);
280 
281     /**
282      * @tc.steps: step1 call ApplyAspectRatioByMaxSize and set ratio < 0 and useDefinedWidth false.
283      * @tc.expected: the set value do not change.
284      */
285     float ratio = -1;
286     bool useDefinedWidth = false;
287     layoutConstraint.ApplyAspectRatioWithCalcSize(ratio, useDefinedWidth);
288     EXPECT_EQ(layoutConstraint.parentIdealSize.Width().value(), 768.0);
289 }
290 
291 /**
292  * @tc.name: LayoutConstraintTestNg005
293  * @tc.desc: Test ApplyAspectRatioWithoutCalcSize.
294  * @tc.type: FUNC
295  */
296 HWTEST_F(LayoutConstraintTestNg, LayoutConstraintTestNg005, TestSize.Level1)
297 {
298     LayoutConstraintF layoutConstraint;
299     layoutConstraint.parentIdealSize = OptionalSizeF(768, 1024);
300     layoutConstraint.selfIdealSize = OptionalSizeF(480, 960);
301 
302     /**
303      * @tc.steps: step1 call ApplyAspectRatioWithoutCalcSize and set ratio < 0 and useDefinedWidth false.
304      * @tc.expected: the set value do not change.
305      */
306     float ratio = -1;
307     layoutConstraint.ApplyAspectRatioWithoutCalcSize(ratio);
308     EXPECT_EQ(layoutConstraint.parentIdealSize.Width().value(), 768.0);
309 
310     /**
311      * @tc.steps: step1 call ApplyAspectRatioWithoutCalcSize and set ratio = 1 and
312                   maxSize.Width() < maxSize.Height().
313      * @tc.expected: the minSize.Width() == minSize.Height().
314      */
315     ratio = 1;
316     layoutConstraint.maxSize.SetWidth(2048);
317     layoutConstraint.maxSize.SetHeight(4096);
318     layoutConstraint.ApplyAspectRatioWithoutCalcSize(ratio);
319     EXPECT_EQ(layoutConstraint.minSize.Width(), layoutConstraint.minSize.Height());
320 
321     /**
322      * @tc.steps: step1 call ApplyAspectRatioWithoutCalcSize and set ratio = 1 and
323                   maxSize.Width() > maxSize.Height().
324      * @tc.expected: the minSize.Width() == minSize.Height().
325      */
326     ratio = 2;
327     layoutConstraint.maxSize.SetWidth(4096);
328     layoutConstraint.maxSize.SetHeight(2048);
329     layoutConstraint.ApplyAspectRatioWithoutCalcSize(ratio);
330     EXPECT_EQ(layoutConstraint.minSize.Width(), layoutConstraint.minSize.Height() * 2);
331 }
332 
333 /**
334  * @tc.name: LayoutConstraintTestNg006
335  * @tc.desc: Test ApplyAspectRatio.
336  * @tc.type: FUNC
337  */
338 HWTEST_F(LayoutConstraintTestNg, LayoutConstraintTestNg006, TestSize.Level1)
339 {
340     LayoutConstraintF layoutConstraint;
341     layoutConstraint.parentIdealSize = OptionalSizeF(768, 1024);
342 
343     auto calcSize = std::make_optional<CalcSize>();
344     /**
345      * @tc.steps: step1 call ApplyAspectRatio and set ratio > 0 and calcSize not has width and height.
346      * @tc.expected: the set value do not change.
347      */
348     float ratio = 1.0;
349     layoutConstraint.ApplyAspectRatio(ratio, calcSize);
350     EXPECT_EQ(layoutConstraint.parentIdealSize.Width().value(), 768.0);
351 
352     /**
353      * @tc.steps: step2 call ApplyAspectRatio, set ratio = 1 and useDefinedWidth.
354      * @tc.expected: set Height failure, height not change.
355      */
356     std::string widthStr = "768px";
357     CalcLength width = CalcLength::FromString(widthStr);
358     std::string heightStr = "1024px";
359     CalcLength height = CalcLength::FromString(heightStr);
360     calcSize = std::make_optional<CalcSize>(width, height);
361     layoutConstraint.selfIdealSize.SetHeight(960);
362     layoutConstraint.ApplyAspectRatio(ratio, calcSize);
363     EXPECT_EQ(layoutConstraint.selfIdealSize.Height(), 960.0);
364 
365     /**
366      * @tc.steps: step3 call ApplyAspectRatio, set ratio = 2 and not useDefinedWidth
367                     and selfIdealSize.Width().
368      * @tc.expected: the selfIdealSize.Width() = selfIdealSize.Height() * 2.
369      */
370     ratio = 2.0;
371     width = CalcLength();
372     heightStr = "1024px";
373     height = CalcLength::FromString(heightStr);
374     calcSize.value().Reset();
375     calcSize->SetHeight(height);
376     layoutConstraint.ApplyAspectRatio(ratio, calcSize);
377     EXPECT_EQ(layoutConstraint.selfIdealSize.Width().value(), layoutConstraint.selfIdealSize.Height().value() * 2);
378 
379     /**
380      * @tc.steps: step4 call ApplyAspectRatio, set minSize and set maxSize
381      * @tc.expected: minSize and maxSize is neaer Infinity.
382      */
383     layoutConstraint.minSize = { Infinity<float>() / 2, Infinity<float>() / 2 };
384     layoutConstraint.maxSize = { Infinity<float>() / 2, Infinity<float>() / 2 };
385     layoutConstraint.ApplyAspectRatio(ratio, calcSize);
386     EXPECT_EQ(layoutConstraint.maxSize.Width(), Infinity<float>());
387     EXPECT_EQ(layoutConstraint.minSize.Width(), Infinity<float>());
388 }
389 
390 /**
391  * @tc.name: LayoutConstraintTestNg007
392  * @tc.desc: Test ApplyAspectRatioToParentIdealSize.
393  * @tc.type: FUNC
394  */
395 HWTEST_F(LayoutConstraintTestNg, LayoutConstraintTestNg007, TestSize.Level1)
396 {
397     LayoutConstraintF layoutConstraint;
398     layoutConstraint.parentIdealSize = OptionalSizeF(0, 1024);
399     layoutConstraint.selfIdealSize = OptionalSizeF(480, 960);
400 
401     /**
402      * @tc.steps: step1 call ApplyAspectRatioToParentIdealSize and set ratio > 0 and useWidth false
403      * and parentIdealSize width false.
404      * @tc.expected: width changed successfully
405      */
406     bool useWidth = false;
407     float ratio = 2;
408     layoutConstraint.ApplyAspectRatioToParentIdealSize(useWidth, ratio);
409     EXPECT_EQ(layoutConstraint.parentIdealSize.Width().value(), 2048);
410 
411     /**
412      * @tc.steps: step2 call ApplyAspectRatioToParentIdealSize and set ratio > 0 and useWidth true
413      * and parentIdealSize width false.
414      * @tc.expected: width changed successfully
415      */
416     ratio = 1;
417     useWidth = true;
418     layoutConstraint.parentIdealSize.Reset();
419     layoutConstraint.parentIdealSize.SetHeight(1024);
420     layoutConstraint.ApplyAspectRatioToParentIdealSize(useWidth, ratio);
421     EXPECT_EQ(layoutConstraint.parentIdealSize.Width().value(), 1024);
422 }
423 
424 /**
425  * @tc.name: LayoutConstraintTestNg008
426  * @tc.desc: Test ApplyAspectRatioWithoutCalcSize.
427  * @tc.type: FUNC
428  */
429 HWTEST_F(LayoutConstraintTestNg, LayoutConstraintTestNg008, TestSize.Level1)
430 {
431     LayoutConstraintF layoutConstraint;
432     layoutConstraint.parentIdealSize = OptionalSizeF(768, 1024);
433     layoutConstraint.selfIdealSize = OptionalSizeF(480, 960);
434 
435     /**
436      * @tc.steps: step1 call ApplyAspectRatioWithoutCalcSize and set ratio < 0 and greaterThanApiTen true.
437      * @tc.expected: the set value do not change.
438      */
439     float ratio = -1;
440     layoutConstraint.ApplyAspectRatioWithoutCalcSize(ratio, true);
441     EXPECT_EQ(layoutConstraint.parentIdealSize.Width().value(), 768.0);
442 
443     /**
444      * @tc.steps: step2 call ApplyAspectRatioWithoutCalcSize and set ratio = 2 reaterThanApiTen true.
445      * @tc.expected: minSize,maxSize,percentRef height all set success
446      */
447     ratio = 2;
448     layoutConstraint.percentReference = { 0, 1025 };
449     layoutConstraint.maxSize.SetWidth(2048);
450     layoutConstraint.maxSize.SetHeight(4096);
451     layoutConstraint.minSize.SetWidth(1);
452     layoutConstraint.minSize.SetHeight(2);
453     layoutConstraint.ApplyAspectRatioWithoutCalcSize(ratio, true);
454     EXPECT_EQ(layoutConstraint.minSize.Height(), 0.5f);
455     EXPECT_EQ(layoutConstraint.maxSize.Height(), 1024);
456     EXPECT_EQ(layoutConstraint.percentReference.Height(), 0);
457 
458     /**
459      * @tc.steps: step3 call ApplyAspectRatioWithoutCalcSize and set ratio = 2 reaterThanApiTen true.
460      * @tc.expected: minSize,maxSize,percentRef width all set success
461      */
462     ratio = 2;
463     layoutConstraint.maxSize.SetWidth(4096);
464     layoutConstraint.maxSize.SetHeight(2048);
465     layoutConstraint.minSize.SetWidth(1);
466     layoutConstraint.minSize.SetHeight(2);
467     layoutConstraint.percentReference = { 8193, 0 };
468     layoutConstraint.ApplyAspectRatioWithoutCalcSize(ratio, true);
469     EXPECT_EQ(layoutConstraint.minSize.Width(), 4);
470     EXPECT_EQ(layoutConstraint.maxSize.Width(), 4096);
471     EXPECT_EQ(layoutConstraint.percentReference.Width(), 0);
472 
473     /**
474      * @tc.steps: step4 call ApplyAspectRatioWithoutCalcSize and set ratio = 2 reaterThanApiTen true.
475      * @tc.expected: minSize,maxSize,percentRef all set fail
476      */
477     layoutConstraint.percentReference = { 0, 0 };
478     layoutConstraint.ApplyAspectRatioWithoutCalcSize(ratio, true);
479     EXPECT_EQ(layoutConstraint.percentReference.Width(), 0);
480     EXPECT_EQ(layoutConstraint.percentReference.Height(), 0);
481 }
482 
483 /**
484  * @tc.name: LayoutConstraintTestNg009
485  * @tc.desc: Test ApplyAspectRatioWithoutCalcSize.
486  * @tc.type: FUNC
487  */
488 HWTEST_F(LayoutConstraintTestNg, LayoutConstraintTestNg009, TestSize.Level1)
489 {
490     LayoutConstraintF layoutConstraint;
491     layoutConstraint.parentIdealSize = OptionalSizeF(768, 1024);
492     layoutConstraint.selfIdealSize = OptionalSizeF(480, 960);
493 
494     /**
495      * @tc.steps: step1 call Reset.
496      * @tc.expected: Reset Success.
497      */
498     layoutConstraint.Reset();
499     EXPECT_EQ(layoutConstraint.minSize.Width(), 0);
500     EXPECT_EQ(layoutConstraint.minSize.Height(), 0);
501 }
502 } // namespace OHOS::Ace::NG