• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 "base/json/json_util.h"
19 #include "base/utils/utils.h"
20 #include "core/components/common/layout/constants.h"
21 #include "frameworks/bridge/common/dom/dom_div.h"
22 #include "frameworks/bridge/common/dom/dom_document.h"
23 #include "frameworks/bridge/common/dom/dom_text.h"
24 #include "frameworks/bridge/test/unittest/jsfrontend/dom_node_factory.h"
25 
26 using namespace testing;
27 using namespace testing::ext;
28 
29 namespace OHOS::Ace::Framework {
30 namespace {
31 
32 const double DIV_WIDTH = 200.0;
33 const double DIV_HEIGHT = 100.0;
34 const double DIV_PADDING_TOP = 10.0;
35 const double DIV_PADDING_RIGHT = 30.0;
36 const double DIV_PADDING_BOTTOM = 70.0;
37 const double DIV_PADDING_LEFT = 50.0;
38 const double DIV_MARGIN_TOP = 10.0;
39 const double DIV_MARGIN_RIGHT = 30.0;
40 const double DIV_MARGIN_BOTTOM = 70.0;
41 const double DIV_MARGIN_LEFT = 50.0;
42 const double DIV_BORDER_TOP_WIDTH = 10.0;
43 const double DIV_BORDER_RIGHT_WIDTH = 20.0;
44 const double DIV_BORDER_BOTTOM_WIDTH = 30.0;
45 const double DIV_BORDER_LEFT_WIDTH = 40.0;
46 const double DIV_BOX_SHADOW_H = 50.0;
47 const double DIV_BOX_SHADOW_V = 100.0;
48 const double DIV_BOX_SHADOW_BLUR = 10.0;
49 const double DIV_BOX_SHADOW_SPREAD = 20.0;
50 const std::string DIV_BOX_SHADOW_COLOR = "#ff0000";
51 const std::string DIV_BORDER_TOP_COLOR = "#759432";
52 const std::string DIV_BORDER_RIGHT_COLOR = "#521674";
53 const std::string DIV_BORDER_BOTTOM_COLOR = "#631482";
54 const std::string DIV_BORDER_LEFT_COLOR = "#264798";
55 constexpr int32_t DIV_BORDER_STYLE = 2;
56 const double DIV_BORDER_TOP_LEFT_RADIUS = 10.0;
57 const double DIV_BORDER_TOP_RIGHT_RADIUS = 20.0;
58 const double DIV_BORDER_BOTTOM_RIGHT_RADIUS = 30.0;
59 const double DIV_BORDER_BOTTOM_LEFT_RADIUS = 40.0;
60 const std::string DIV_BACKGROUND_COLOR = "#759432";
61 const std::string DIV_BACKGROUND_IMAGE_SRC = "picture/test2.jpg";
62 const double DIV_BACKGROUND_IMAGE_SIZE = 200.0;
63 const double DIV_BACKGROUND_IMAGE_POSITION_VALUE_X = 100.0;
64 const double DIV_BACKGROUND_IMAGE_POSITION_VALUE_Y = 200.0;
65 constexpr int32_t DIV_BACKGROUND_IMAGE_POSITION_TYPE_X = 1;
66 constexpr int32_t DIV_BACKGROUND_IMAGE_POSITION_TYPE_Y = 1;
67 constexpr int32_t DIV_BACKGROUND_IMAGE_REPEAT = 1;
68 const std::string JSON_DIV_TEST_004 = ""
69                                    "{                                          "
70                                    "    \"tag\": \"div\","
71                                    "    \"commonStyle\": [{                    "
72                                    "        \"borderTopWidth\": \"10px\"       "
73                                    "    },"
74                                    "    {"
75                                    "        \"borderRightWidth\": \"20px\"     "
76                                    "    },"
77                                    "    {"
78                                    "        \"borderBottomWidth\": \"30px\"    "
79                                    "    },"
80                                    "    {"
81                                    "        \"borderLeftWidth\": \"40px\"      "
82                                    "    },"
83                                    "    {"
84                                    "        \"borderStyle\": \"dotted\"         "
85                                    "    },"
86                                    "    {"
87                                    "        \"borderTopColor\": \"#759432\"      "
88                                    "    },"
89                                    "    {"
90                                    "        \"borderRightColor\": \"#521674\"    "
91                                    "    },"
92                                    "    {"
93                                    "        \"borderBottomColor\": \"#631482\"   "
94                                    "    },"
95                                    "    {"
96                                    "        \"borderLeftColor\": \"#264798\"     "
97                                    "    }]"
98                                    "}";
99 
100 } // namespace
101 
102 class DomNodeTest : public testing::Test {
103 public:
104     static void SetUpTestCase();
105     static void TearDownTestCase();
106     void SetUp();
107     void TearDown();
108 };
109 
SetUpTestCase()110 void DomNodeTest::SetUpTestCase() {}
TearDownTestCase()111 void DomNodeTest::TearDownTestCase() {}
SetUp()112 void DomNodeTest::SetUp() {}
TearDown()113 void DomNodeTest::TearDown() {}
114 
115 /**
116  * @tc.name: DomNodeTest001
117  * @tc.desc: Verify that DomNode can be set width and height.
118  * @tc.type: FUNC
119  */
120 HWTEST_F(DomNodeTest, DomNodeTest001, TestSize.Level1)
121 {
122     /**
123      * @tc.steps: step1. construct the json string of DomNode with two attributes:
124      * width, height.
125      */
126     const std::string jsonDivStr = ""
127                                    "{                               "
128                                    "    \"tag\": \"div\","
129                                    "    \"commonStyle\": [{          "
130                                    "        \"width\": \"200px\" "
131                                    "    },"
132                                    "    {"
133                                    "       \"height\": \"100px\"    "
134                                    "    }]"
135                                    "}";
136     /**
137      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its commonStyle.
138      */
139     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
140     auto boxChildComponent = DOMNodeFactory::GetInstance().GetBoxChildComponent(domNodeRoot);
141     double width = boxChildComponent->GetWidthDimension().Value();
142     double height = boxChildComponent->GetHeightDimension().Value();
143 
144     /**
145      * @tc.steps: step3. Verify the DomNode's commonStyle is set correctly.
146      * @tc.expected: step3. width is 200.0, height is 100.0
147      */
148     ASSERT_TRUE(domNodeRoot != nullptr);
149     EXPECT_TRUE(width == DIV_WIDTH);
150     EXPECT_TRUE(height == DIV_HEIGHT);
151 }
152 
153 /**
154  * @tc.name: DomNodeTest002
155  * @tc.desc: Verify that DomNode can be set padding .
156  * @tc.type: FUNC
157  */
158 HWTEST_F(DomNodeTest, DomNodeTest002, TestSize.Level1)
159 {
160     /**
161      * @tc.steps: step1. construct the json string of DomNode with four attributes:
162      * padding-top, padding-right, padding-bottom, padding-left.
163      */
164     const std::string jsonDivStr = ""
165                                    "{                               "
166                                    "    \"tag\": \"div\","
167                                    "    \"commonStyle\": [{                             "
168                                    "        \"paddingTop\": \"10px\" "
169                                    "    },"
170                                    "    {"
171                                    "        \"paddingRight\": \"30px\"    "
172                                    "    },"
173                                    "    {"
174                                    "        \"paddingBottom\": \"70px\"    "
175                                    "    },"
176                                    "    {"
177                                    "        \"paddingLeft\": \"50px\" "
178                                    "    }]"
179                                    "}";
180     /**
181      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its commonStyle.
182      */
183     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
184     auto boxChildComponent = DOMNodeFactory::GetInstance().GetBoxChildComponent(domNodeRoot);
185     double top = static_cast<double>(boxChildComponent->GetPadding().Top().Value());
186     double right = static_cast<double>(boxChildComponent->GetPadding().Right().Value());
187     double bottom = static_cast<double>(boxChildComponent->GetPadding().Bottom().Value());
188     double left = static_cast<double>(boxChildComponent->GetPadding().Left().Value());
189 
190     /**
191      * @tc.steps: step3. Verify the DomNode's commonStyle is set correctly.
192      * @tc.expected: step3. padding-top is 10, padding-right is 10, padding-bottom is 10, padding-left is 10,
193      */
194     ASSERT_TRUE(domNodeRoot != nullptr);
195     EXPECT_TRUE(top == DIV_PADDING_TOP);
196     EXPECT_TRUE(right == DIV_PADDING_RIGHT);
197     EXPECT_TRUE(bottom == DIV_PADDING_BOTTOM);
198     EXPECT_TRUE(left == DIV_PADDING_LEFT);
199 }
200 
201 /**
202  * @tc.name: DomNodeTest003
203  * @tc.desc: Verify that DomNode can be set margin .
204  * @tc.type: FUNC
205  */
206 HWTEST_F(DomNodeTest, DomNodeTest003, TestSize.Level1)
207 {
208     /**
209      * @tc.steps: step1. construct the json string of DomNode with four attributes:
210      * margin-top, margin-right, margin-bottom, margin-left.
211      */
212     const std::string jsonDivStr = ""
213                                    "{                               "
214                                    "    \"tag\": \"div\","
215                                    "    \"commonStyle\": [{                             "
216                                    "        \"marginTop\": \"10px\" "
217                                    "    },"
218                                    "    {"
219                                    "        \"marginRight\": \"30px\"    "
220                                    "    },"
221                                    "    {"
222                                    "        \"marginBottom\": \"70px\"    "
223                                    "    },"
224                                    "    {"
225                                    "        \"marginLeft\": \"50px\" "
226                                    "    }]"
227                                    "}";
228     /**
229      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its commonStyle.
230      */
231     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
232     auto boxChildComponent = DOMNodeFactory::GetInstance().GetBoxChildComponent(domNodeRoot);
233     double top = static_cast<double>(boxChildComponent->GetMargin().Top().Value());
234     double right = static_cast<double>(boxChildComponent->GetMargin().Right().Value());
235     double bottom = static_cast<double>(boxChildComponent->GetMargin().Bottom().Value());
236     double left = static_cast<double>(boxChildComponent->GetMargin().Left().Value());
237 
238     /**
239      * @tc.steps: step3. Verify the DomNode's commonStyle is set correctly.
240      * @tc.expected: step3. margin-top is 10, margin-right is 10, margin-bottom is 10, margin-left is 10,
241      */
242     ASSERT_TRUE(domNodeRoot != nullptr);
243     EXPECT_TRUE(top == DIV_MARGIN_TOP);
244     EXPECT_TRUE(right == DIV_MARGIN_RIGHT);
245     EXPECT_TRUE(bottom == DIV_MARGIN_BOTTOM);
246     EXPECT_TRUE(left == DIV_MARGIN_LEFT);
247 }
248 
249 /**
250  * @tc.name: DomNodeTest004
251  * @tc.desc: Verify that DomNode can be set border.
252  * @tc.type: FUNC
253  */
254 HWTEST_F(DomNodeTest, DomNodeTest004, TestSize.Level1)
255 {
256     /**
257      * @tc.steps: step1. construct the json string of DomNode with border-related attributes:
258      * borderTopWidth, borderRightWidth, borderBottomWidth, borderLeftWidth, borderStyle,
259      * borderTopColor, borderRightColor, borderBottomColor, borderLeftColor.
260      */
261     const std::string& jsonDivStr = JSON_DIV_TEST_004;
262     /**
263      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its border-related common style.
264      */
265     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
266     auto boxChildComponent = DOMNodeFactory::GetInstance().GetBoxChildComponent(domNodeRoot);
267     Border border = boxChildComponent->GetBackDecoration()->GetBorder();
268     BorderEdge borderTopEdge = border.Top();
269     BorderEdge borderRightEdge = border.Right();
270     BorderEdge borderBottomEdge = border.Bottom();
271     BorderEdge borderLeftEdge = border.Left();
272 
273     /**
274      * @tc.steps: step3. Verify the DomNode's bordrt-related common styles can be set correctly.
275      * @tc.expected: step3. borderTopWidth is 10px, borderRightWidth is 20px, borderBottomWidth is 30px,
276      * borderLeftWidth is 40px, borderStyle is dotted, borderTopColor is #759432, borderRightColor is #521674,
277      * borderBottomColor is #631482, borderLeftColor is #264798.
278      */
279     ASSERT_TRUE(domNodeRoot != nullptr);
280     EXPECT_EQ(borderTopEdge.GetWidth().Value(), DIV_BORDER_TOP_WIDTH);
281     EXPECT_EQ(borderRightEdge.GetWidth().Value(), DIV_BORDER_RIGHT_WIDTH);
282     EXPECT_EQ(borderBottomEdge.GetWidth().Value(), DIV_BORDER_BOTTOM_WIDTH);
283     EXPECT_EQ(borderLeftEdge.GetWidth().Value(), DIV_BORDER_LEFT_WIDTH);
284     EXPECT_EQ(borderTopEdge.GetColor(), Color::FromString(DIV_BORDER_TOP_COLOR));
285     EXPECT_EQ(borderRightEdge.GetColor(), Color::FromString(DIV_BORDER_RIGHT_COLOR));
286     EXPECT_EQ(borderBottomEdge.GetColor(), Color::FromString(DIV_BORDER_BOTTOM_COLOR));
287     EXPECT_EQ(borderLeftEdge.GetColor(), Color::FromString(DIV_BORDER_LEFT_COLOR));
288     EXPECT_EQ(static_cast<int32_t>(borderTopEdge.GetBorderStyle()), DIV_BORDER_STYLE);
289     EXPECT_EQ(static_cast<int32_t>(borderRightEdge.GetBorderStyle()), DIV_BORDER_STYLE);
290     EXPECT_EQ(static_cast<int32_t>(borderBottomEdge.GetBorderStyle()), DIV_BORDER_STYLE);
291     EXPECT_EQ(static_cast<int32_t>(borderLeftEdge.GetBorderStyle()), DIV_BORDER_STYLE);
292 }
293 
294 /**
295  * @tc.name: DomNodeTest005
296  * @tc.desc: Verify that DomNode can be set border radius.
297  * @tc.type: FUNC
298  */
299 HWTEST_F(DomNodeTest, DomNodeTest005, TestSize.Level1)
300 {
301     /**
302      * @tc.steps: step1. construct the json string of DomNode with border radius attributes:
303      * borderTopLeftRadius, borderTopRightRadius, borderBottomRightRadius, borderBottomLeftRadius.
304      */
305     const std::string jsonDivStr = ""
306                                    "{                                                 "
307                                    "    \"tag\": \"div\","
308                                    "    \"commonStyle\": [{                           "
309                                    "        \"borderTopLeftRadius\": \"10px\"         "
310                                    "    },"
311                                    "    {"
312                                    "        \"borderTopRightRadius\": \"20px\"        "
313                                    "    },"
314                                    "    {"
315                                    "        \"borderBottomRightRadius\": \"30px\"     "
316                                    "    },"
317                                    "    {"
318                                    "        \"borderBottomLeftRadius\": \"40px\"      "
319                                    "    }]"
320                                    "}";
321     /**
322      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its border radius common style.
323      */
324     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
325     auto boxChildComponent = DOMNodeFactory::GetInstance().GetBoxChildComponent(domNodeRoot);
326     Border border = boxChildComponent->GetBackDecoration()->GetBorder();
327 
328     /**
329      * @tc.steps: step3. Verify the DomNode's bordrt radius common styles can be set correctly.
330      * @tc.expected: step3. borderTopLeftRadius is 10px, borderTopRightRadius is 20px,
331      * borderBottomRightRadius is 30px, borderBottomLeftRadius is 40px.
332      */
333     ASSERT_TRUE(domNodeRoot != nullptr);
334     EXPECT_EQ(border.TopLeftRadius(), Radius(DIV_BORDER_TOP_LEFT_RADIUS));
335     EXPECT_EQ(border.TopRightRadius(), Radius(DIV_BORDER_TOP_RIGHT_RADIUS));
336     EXPECT_EQ(border.BottomRightRadius(), Radius(DIV_BORDER_BOTTOM_RIGHT_RADIUS));
337     EXPECT_EQ(border.BottomLeftRadius(), Radius(DIV_BORDER_BOTTOM_LEFT_RADIUS));
338 }
339 
340 /**
341  * @tc.name: DomNodeTest006
342  * @tc.desc: Verify that DomNode can be set background.
343  * @tc.type: FUNC
344  */
345 HWTEST_F(DomNodeTest, DomNodeTest006, TestSize.Level1)
346 {
347     /**
348      * @tc.steps: step1. construct the json string of DomNode with background-related attributes:
349      * backgroundColor, backgroundImage, backgroundSize, backgroundPosition, backgroundRepeat.
350      */
351     const std::string jsonDivStr = ""
352                                    "{                                                 "
353                                    "    \"tag\": \"div\","
354                                    "    \"commonStyle\": [{                           "
355                                    "        \"backgroundColor\": \"#759432\"         "
356                                    "    },"
357                                    "    {"
358                                    "        \"backgroundImage\": \"picture/test2.jpg\"        "
359                                    "    },"
360                                    "    {"
361                                    "        \"backgroundSize\": \"200px\"     "
362                                    "    },"
363                                    "    {"
364                                    "        \"backgroundPosition\": \"100px 200px\"      "
365                                    "    },"
366                                    "    {"
367                                    "        \"backgroundRepeat\": \"repeat-x\"      "
368                                    "    }]"
369                                    "}";
370     /**
371      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its background-related common style.
372      */
373     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
374     auto boxChildComponent = DOMNodeFactory::GetInstance().GetBoxChildComponent(domNodeRoot);
375     RefPtr<Decoration> decoration = boxChildComponent->GetBackDecoration();
376     RefPtr<BackgroundImage> image = decoration->GetImage();
377     BackgroundImagePosition backgroundImagePosition = image->GetImagePosition();
378 
379     /**
380      * @tc.steps: step3. Verify the DomNode's background-related common styles can be set correctly.
381      * @tc.expected: step3. backgroundColor is #759432, backgroundImage's src is picture/test2.jpg,
382      * backgroundSize is 200px, backgroundPositionValue is 100px 200px, backgroundPositiontype is px,
383      * backgroundRepeat is repeat-x.
384      */
385     ASSERT_TRUE(domNodeRoot != nullptr);
386     EXPECT_EQ(decoration->GetBackgroundColor(), Color::FromString(DIV_BORDER_TOP_COLOR));
387     EXPECT_EQ(image->GetSrc(), DIV_BACKGROUND_IMAGE_SRC);
388     EXPECT_EQ(image->GetImageSize().GetSizeValueX(), DIV_BACKGROUND_IMAGE_SIZE);
389     EXPECT_EQ(backgroundImagePosition.GetSizeValueX(), DIV_BACKGROUND_IMAGE_POSITION_VALUE_X);
390     EXPECT_EQ(backgroundImagePosition.GetSizeValueY(), DIV_BACKGROUND_IMAGE_POSITION_VALUE_Y);
391     EXPECT_EQ(static_cast<int32_t>(backgroundImagePosition.GetSizeTypeX()), DIV_BACKGROUND_IMAGE_POSITION_TYPE_X);
392     EXPECT_EQ(static_cast<int32_t>(backgroundImagePosition.GetSizeTypeY()), DIV_BACKGROUND_IMAGE_POSITION_TYPE_Y);
393     EXPECT_EQ(static_cast<int32_t>(image->GetImageRepeat()), DIV_BACKGROUND_IMAGE_REPEAT);
394 }
395 
396 /**
397  * @tc.name: DomNodeTest007
398  * @tc.desc: Verify that DomNode can be set minWidth/minHeight/maxWidth/maxHeight.
399  * @tc.type: FUNC
400  */
401 HWTEST_F(DomNodeTest, DomNodeTest007, TestSize.Level1)
402 {
403     /**
404      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
405      * flexWeight.
406      */
407     const std::string jsonDivStr = ""
408                                    "{                                                 "
409                                    "    \"tag\": \"div\","
410                                    "    \"commonStyle\": [{                           "
411                                    "        \"flexWeight\": \"1\"                     "
412                                    "    }]"
413                                    "}";
414     /**
415      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its border radius common style.
416      */
417     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
418     ASSERT_TRUE(domNodeRoot != nullptr);
419     auto declaration = domNodeRoot->GetDeclaration();
420     ASSERT_TRUE(declaration != nullptr);
421     double weight = 0.0;
422     auto& flexStyle = static_cast<CommonFlexStyle&>(declaration->GetStyle(StyleTag::COMMON_FLEX_STYLE));
423     if (flexStyle.IsValid()) {
424         weight = flexStyle.flexWeight;
425     }
426 
427     /**
428      * @tc.steps: step3. Verify the DomNode's bordrt radius common styles can be set correctly.
429      * @tc.expected: step3. flexWeight is 1.
430      */
431     EXPECT_EQ(weight, 1);
432 }
433 
434 /**
435  * @tc.name: BoxShadowTest001
436  * @tc.desc: Verify that DomNode can be set box shadow.
437  * @tc.type: FUNC
438  */
439 HWTEST_F(DomNodeTest, BoxShadowTest001, TestSize.Level1)
440 {
441     /**
442      * @tc.steps: step1. construct the json string of DomNode with box shadow offset attributes.
443      */
444     const std::string jsonDivStr = ""
445                                    "{                                                 "
446                                    "    \"tag\": \"div\","
447                                    "    \"commonStyle\": [{                           "
448                                    "        \"boxShadowH\": \"50px\"         "
449                                    "    },"
450                                    "    {"
451                                    "        \"boxShadowV\": \"100px\"        "
452                                    "    }]"
453                                    "}";
454     /**
455      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its box shadow common style.
456      */
457     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
458     auto boxChildComponent = DOMNodeFactory::GetInstance().GetBoxChildComponent(domNodeRoot);
459     RefPtr<Decoration> decoration = boxChildComponent->GetBackDecoration();
460     auto shadow = decoration->GetShadows().front();
461 
462     /**
463      * @tc.steps: step3. Verify the DomNode's box shadow common styles can be set correctly.
464      * @tc.expected: step3. boxShadowH is 50px, boxShadowV is 100px
465      */
466     ASSERT_TRUE(domNodeRoot != nullptr);
467     EXPECT_EQ(shadow.GetOffset().GetX(), DIV_BOX_SHADOW_H);
468     EXPECT_EQ(shadow.GetOffset().GetY(), DIV_BOX_SHADOW_V);
469 }
470 
471 /**
472  * @tc.name: BoxShadowTest002
473  * @tc.desc: Verify that DomNode can be set box shadow.
474  * @tc.type: FUNC
475  */
476 HWTEST_F(DomNodeTest, BoxShadowTest002, TestSize.Level1)
477 {
478     /**
479      * @tc.steps: step1. construct the json string of DomNode with box shadow  attributes.
480      */
481     const std::string jsonDivStr = ""
482                                    "{                                                 "
483                                    "    \"tag\": \"div\","
484                                    "    \"commonStyle\": [{                           "
485                                    "        \"boxShadowH\": \"50px\"         "
486                                    "    },"
487                                    "    {"
488                                    "        \"boxShadowV\": \"100px\"        "
489                                    "    },"
490                                    "    {"
491                                    "        \"boxShadowBlur\": \"10px\"        "
492                                    "    },"
493                                    "    {"
494                                    "        \"boxShadowSpread\": \"20px\"        "
495                                    "    },"
496                                    "    {"
497                                    "        \"boxShadowColor\": \"#ff0000\"        "
498                                    "    }]"
499                                    "}";
500     /**
501      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its box shadow common style.
502      */
503     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
504     auto boxChildComponent = DOMNodeFactory::GetInstance().GetBoxChildComponent(domNodeRoot);
505     RefPtr<Decoration> decoration = boxChildComponent->GetBackDecoration();
506     auto shadow = decoration->GetShadows().front();
507 
508     /**
509      * @tc.steps: step3. Verify the DomNode's box shadow common styles can be set correctly.
510      * @tc.expected: step3. boxShadowH is 50px, boxShadowV is 100px, boxShadowSpread is 20px, boxShadowBlur is 10px
511      */
512     ASSERT_TRUE(domNodeRoot != nullptr);
513     EXPECT_EQ(shadow.GetOffset().GetX(), DIV_BOX_SHADOW_H);
514     EXPECT_EQ(shadow.GetOffset().GetY(), DIV_BOX_SHADOW_V);
515     EXPECT_EQ(shadow.GetSpreadRadius(), DIV_BOX_SHADOW_SPREAD);
516     EXPECT_EQ(shadow.GetBlurRadius(), DIV_BOX_SHADOW_BLUR);
517     EXPECT_EQ(shadow.GetColor(), Color::FromString(DIV_BOX_SHADOW_COLOR));
518 }
519 
520 /*
521  * @tc.name: ClickEffectTest001
522  * @tc.desc: Verify that DomNode can be set click-effect.
523  * @tc.type: FUNC
524  */
525 HWTEST_F(DomNodeTest, ClickEffectTest001, TestSize.Level1)
526 {
527     /**
528      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
529      * click-effect.
530      */
531     const std::string jsonDivStr = ""
532                                    "{                                                 "
533                                    "    \"tag\": \"div\","
534                                    "    \"attr\": [{                           "
535                                    "        \"clickEffect\": \"spring-small\"        "
536                                    "    }]"
537                                    "}";
538     /**
539      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its click-effect.
540      */
541     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
542     ASSERT_TRUE(domNodeRoot != nullptr);
543     auto transformComponent = domNodeRoot->GetTransformComponent();
544     ASSERT_TRUE(transformComponent != nullptr);
545     auto effectType = transformComponent->GetClickSpringEffectType();
546     /**
547      * @tc.steps: step3. Verify the DomNode's click-effect attr can be set correctly.
548      * @tc.expected: step3. effectType is SMALL.
549      */
550     EXPECT_EQ(effectType, ClickSpringEffectType::SMALL);
551 }
552 
553 /*
554  * @tc.name: ClickEffectTest002
555  * @tc.desc: Verify that DomNode can be set click-effect.
556  * @tc.type: FUNC
557  */
558 HWTEST_F(DomNodeTest, ClickEffectTest002, TestSize.Level1)
559 {
560     /**
561      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
562      * click-effect.
563      */
564     const std::string jsonDivStr = ""
565                                    "{                                                 "
566                                    "    \"tag\": \"div\","
567                                    "    \"attr\": [{                           "
568                                    "        \"clickEffect\": \"spring-medium\"        "
569                                    "    }]"
570                                    "}";
571     /**
572      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its click-effect with spring-medium.
573      */
574     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
575     ASSERT_TRUE(domNodeRoot != nullptr);
576     auto transformComponent = domNodeRoot->GetTransformComponent();
577     ASSERT_TRUE(transformComponent != nullptr);
578     auto effectType = transformComponent->GetClickSpringEffectType();
579     /**
580      * @tc.steps: step3. Verify the DomNode's click-effect attr can be set correctly.
581      * @tc.expected: step3. effectType is MEDIUM.
582      */
583     EXPECT_EQ(effectType, ClickSpringEffectType::MEDIUM);
584 }
585 
586 /*
587  * @tc.name: ClickEffectTest003
588  * @tc.desc: Verify that DomNode can be set click-effect.
589  * @tc.type: FUNC
590  */
591 HWTEST_F(DomNodeTest, ClickEffectTest003, TestSize.Level1)
592 {
593     /**
594      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
595      * click-effect.
596      */
597     const std::string jsonDivStr = ""
598                                    "{                                                 "
599                                    "    \"tag\": \"div\","
600                                    "    \"attr\": [{                           "
601                                    "        \"clickEffect\": \"spring-large\"        "
602                                    "    }]"
603                                    "}";
604     /**
605      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its click-effect.
606      */
607     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
608     ASSERT_TRUE(domNodeRoot != nullptr);
609     auto transformComponent = domNodeRoot->GetTransformComponent();
610     ASSERT_TRUE(transformComponent != nullptr);
611     auto effectType = transformComponent->GetClickSpringEffectType();
612     /**
613      * @tc.steps: step3. Verify the DomNode's click-effect attr can be set correctly.
614      * @tc.expected: step3. effectType is LARGE.
615      */
616     EXPECT_EQ(effectType, ClickSpringEffectType::LARGE);
617 }
618 
619 /*
620  * @tc.name: BoxBlurTest001
621  * @tc.desc: Verify that DomNode can be set filter and backdrop-filter.
622  * @tc.type: FUNC
623  */
624 HWTEST_F(DomNodeTest, BoxBlurTest001, TestSize.Level1)
625 {
626     /**
627      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
628      * click-effect.
629      */
630     const std::string jsonDivStr = "{"
631                                    "    \"tag\": \"div\","
632                                    "    \"commonStyle\": ["
633                                    "        {"
634                                    "            \"filter\": \"blur(20px)\""
635                                    "        },"
636                                    "        {"
637                                    "            \"backdropFilter\": \"blur(31px)\""
638                                    "        }"
639                                    "    ]"
640                                    "}";
641     /**
642      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its click-effect.
643      */
644     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
645     ASSERT_TRUE(domNodeRoot != nullptr);
646     auto boxComponent = DOMNodeFactory::GetInstance().GetBoxChildComponent(domNodeRoot);
647     ASSERT_TRUE(boxComponent != nullptr);
648 
649     /**
650      * @tc.steps: step3. Verify the DomNode's filter common styles can be set correctly.
651      * @tc.expected: step3. blurRadius is 20.
652      */
653     auto frontDecoration = boxComponent->GetFrontDecoration();
654     ASSERT_TRUE(frontDecoration != nullptr);
655     EXPECT_EQ(frontDecoration->GetBlurRadius().Value(), 20.0);
656 
657     /**
658      * @tc.steps: step3. Verify the DomNode's backdrop-filter common styles can be set correctly.
659      * @tc.expected: step3. blurRadius is 31.
660      */
661     auto backDecoration = boxComponent->GetBackDecoration();
662     ASSERT_TRUE(backDecoration != nullptr);
663     EXPECT_EQ(backDecoration->GetBlurRadius().Value(), 31.0);
664 }
665 
666 /*
667  * @tc.name: DomeNodeTransitionAnimatioOpitionTest001
668  * @tc.desc: Verify that DomNode can be set transition-effect.
669  * @tc.type: FUNC
670  */
671 HWTEST_F(DomNodeTest, DomeNodeTransitionAnimatioOpitionTest001, TestSize.Level1)
672 {
673     /**
674      * @tc.steps: step1. construct the json string of DomNode with constraint attributes: transition-effect
675      */
676     const std::string jsonDivStr = ""
677                                    "{                                                 "
678                                    "    \"tag\": \"div\","
679                                    "    \"commonStyle\": [{                           "
680                                    "        \"transitionEffect\": \"unfold\" "
681                                    "    }]"
682                                    "}";
683     /**
684      * @tc.steps: step2. call JsonUtil interface, create DomNode and set transition-effect.
685      */
686     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
687     ASSERT_TRUE(domNodeRoot != nullptr);
688     auto transformComponent = domNodeRoot->GetTransformComponent();
689     ASSERT_TRUE(transformComponent != nullptr);
690     auto transitionEffect = transformComponent->GetTransitionEffect();
691     /**
692      * @tc.steps: step3. Verify the DomNode's transition-effect common styles can be set correctly.
693      * @tc.expected: step3. effectType is UNFOLD.
694      */
695     EXPECT_EQ(transitionEffect, TransitionEffect::UNFOLD);
696 }
697 
698 /*
699  * @tc.name: WindowBlurTest001
700  * @tc.desc: Verify that DomNode can be set window-filter.
701  * @tc.type: FUNC
702  */
703 HWTEST_F(DomNodeTest, WindowBlurTest001, TestSize.Level1)
704 {
705     /**
706      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
707      * windowFilter.
708      */
709     const std::string jsonDivStr = "{"
710                                    "    \"tag\": \"div\","
711                                    "    \"commonStyle\": ["
712                                    "        {"
713                                    "            \"windowFilter\": \"blur(50%)\""
714                                    "        }"
715                                    "    ]"
716                                    "}";
717     /**
718      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its window-filter.
719      */
720     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
721     ASSERT_TRUE(domNodeRoot != nullptr);
722     auto boxComponent = DOMNodeFactory::GetInstance().GetBoxChildComponent(domNodeRoot);
723     ASSERT_TRUE(boxComponent != nullptr);
724 
725     /**
726      * @tc.steps: step3. Verify the DomNode's window-filter common styles can be set correctly.
727      * @tc.expected: step3. window blur progress is 0.5.
728      */
729     auto backDecoration = boxComponent->GetBackDecoration();
730     ASSERT_TRUE(backDecoration != nullptr);
731     EXPECT_EQ(backDecoration->GetWindowBlurProgress(), 0.5f);
732 }
733 
734 /*
735  * @tc.name: WindowBlurTest002
736  * @tc.desc: Verify that DomNode can not be set window-filter invalid value.
737  * @tc.type: FUNC
738  */
739 HWTEST_F(DomNodeTest, WindowBlurTest002, TestSize.Level1) {
740     /**
741      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
742      * windowFilter.
743      */
744     const std::string jsonDivStr = "{"
745                                    "    \"tag\": \"div\","
746                                    "    \"commonStyle\": ["
747                                    "        {"
748                                    "            \"windowFilter\": \"blur(150%)\""
749                                    "        }"
750                                    "    ]"
751                                    "}";
752     /**
753      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its window-filter.
754      */
755     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
756     ASSERT_TRUE(domNodeRoot != nullptr);
757     auto boxComponent = DOMNodeFactory::GetInstance().GetBoxChildComponent(domNodeRoot);
758     ASSERT_TRUE(boxComponent != nullptr);
759 
760     /**
761      * @tc.steps: step3. Verify the DomNode's window-filter common styles can not be set correctly.
762      * @tc.expected: step3. window blur progress is 0.0.
763      */
764     auto backDecoration = boxComponent->GetBackDecoration();
765     ASSERT_TRUE(backDecoration != nullptr);
766     EXPECT_EQ(backDecoration->GetWindowBlurProgress(), 0.0f);
767 }
768 
769 /*
770  * @tc.name: WindowBlurTest003
771  * @tc.desc: Verify that DomNode can set window-filter boundary value.
772  * @tc.type: FUNC
773  */
774 HWTEST_F(DomNodeTest, WindowBlurTest003, TestSize.Level1) {
775     /**
776      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
777      * windowFilter.
778      */
779     const std::string jsonDivStr = "{"
780                                    "    \"tag\": \"div\","
781                                    "    \"commonStyle\": ["
782                                    "        {"
783                                    "            \"windowFilter\": \"blur(100%)\""
784                                    "        }"
785                                    "    ]"
786                                    "}";
787     /**
788      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its window-filter.
789      */
790     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
791     ASSERT_TRUE(domNodeRoot != nullptr);
792     auto boxComponent = DOMNodeFactory::GetInstance().GetBoxChildComponent(domNodeRoot);
793     ASSERT_TRUE(boxComponent != nullptr);
794 
795     /**
796      * @tc.steps: step3. Verify the DomNode's window-filter common styles can be set correctly.
797      * @tc.expected: step3. window blur progress is 1.0.
798      */
799     auto backDecoration = boxComponent->GetBackDecoration();
800     ASSERT_TRUE(backDecoration != nullptr);
801     EXPECT_EQ(backDecoration->GetWindowBlurProgress(), 1.0f);
802 }
803 
804 /*
805  * @tc.name: WindowBlurTest004
806  * @tc.desc: Verify that DomNode can not be set window-filter with different unit.
807  * @tc.type: FUNC
808  */
809 HWTEST_F(DomNodeTest, WindowBlurTest004, TestSize.Level1) {
810     /**
811      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
812      * windowFilter.
813      */
814     const std::string jsonDivStr = "{"
815                                    "    \"tag\": \"div\","
816                                    "    \"commonStyle\": ["
817                                    "        {"
818                                    "            \"windowFilter\": \"blur(1px)\""
819                                    "        }"
820                                    "    ]"
821                                    "}";
822     /**
823      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its window-filter.
824      */
825     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
826     ASSERT_TRUE(domNodeRoot != nullptr);
827     auto boxComponent = DOMNodeFactory::GetInstance().GetBoxChildComponent(domNodeRoot);
828     ASSERT_TRUE(boxComponent != nullptr);
829 
830     /**
831      * @tc.steps: step3. Verify the DomNode's window-filter common styles can not be set correctly.
832      * @tc.expected: step3. window blur progress is 0.0.
833      */
834     auto backDecoration = boxComponent->GetBackDecoration();
835     ASSERT_TRUE(backDecoration != nullptr);
836     EXPECT_EQ(backDecoration->GetWindowBlurProgress(), 0.0f);
837 }
838 
839 /*
840  * @tc.name: TransformOriginTest001
841  * @tc.desc: Verify that DomNode can set transform-origin with one value.
842  * @tc.type: FUNC
843  */
844 HWTEST_F(DomNodeTest, TransformOriginTest001, TestSize.Level1)
845 {
846     /**
847      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
848      * windowFilter.
849      */
850     const std::string jsonDivStr = "{"
851                                    "    \"tag\": \"div\","
852                                    "    \"commonStyle\": ["
853                                    "        {"
854                                    "            \"transformOrigin\": \"center\""
855                                    "        }"
856                                    "    ]"
857                                    "}";
858     /**
859      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its transform-origin.
860      */
861     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
862     ASSERT_TRUE(domNodeRoot != nullptr);
863 
864     /**
865      * @tc.steps: step3. Verify the DomNode's transform-origin common styles can be set correctly.
866      * @tc.expected: step3. 50% 50%
867      */
868     auto declaration = domNodeRoot->GetDeclaration();
869     ASSERT_TRUE(declaration != nullptr);
870     auto& animationStyle = static_cast<CommonAnimationStyle&>(declaration->GetStyle(StyleTag::COMMON_ANIMATION_STYLE));
871     ASSERT_TRUE(animationStyle.IsValid());
872     auto originOffsetX = animationStyle.tweenOption.GetTransformOriginX();
873     auto originOffsetY = animationStyle.tweenOption.GetTransformOriginY();
874     ASSERT_TRUE(originOffsetX.Unit() == DimensionUnit::PERCENT);
875     ASSERT_EQ(originOffsetX.Value(), 0.5);
876     ASSERT_TRUE(originOffsetY.Unit() == DimensionUnit::PERCENT);
877     ASSERT_EQ(originOffsetY.Value(), 0.5);
878 }
879 
880 /*
881  * @tc.name: TransformOriginTest002
882  * @tc.desc: Verify that DomNode can set transform-origin with one value.
883  * @tc.type: FUNC
884  */
885 HWTEST_F(DomNodeTest, TransformOriginTest002, TestSize.Level1)
886 {
887     /**
888      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
889      * windowFilter.
890      */
891     const std::string jsonDivStr = "{"
892                                    "    \"tag\": \"div\","
893                                    "    \"commonStyle\": ["
894                                    "        {"
895                                    "            \"transformOrigin\": \"left\""
896                                    "        }"
897                                    "    ]"
898                                    "}";
899     /**
900      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its transform-origin.
901      */
902     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
903     ASSERT_TRUE(domNodeRoot != nullptr);
904 
905     /**
906      * @tc.steps: step3. Verify the DomNode's transform-origin common styles can be set correctly.
907      * @tc.expected: step3. 0% 50%
908      */
909     auto declaration = domNodeRoot->GetDeclaration();
910     ASSERT_TRUE(declaration != nullptr);
911     auto& animationStyle = static_cast<CommonAnimationStyle&>(declaration->GetStyle(StyleTag::COMMON_ANIMATION_STYLE));
912     ASSERT_TRUE(animationStyle.IsValid());
913     auto originOffsetX = animationStyle.tweenOption.GetTransformOriginX();
914     auto originOffsetY = animationStyle.tweenOption.GetTransformOriginY();
915     ASSERT_TRUE(originOffsetX.Unit() == DimensionUnit::PERCENT);
916     ASSERT_EQ(originOffsetX.Value(), 0.0);
917     ASSERT_TRUE(originOffsetY.Unit() == DimensionUnit::PERCENT);
918     ASSERT_EQ(originOffsetY.Value(), 0.5);
919 }
920 
921 /*
922  * @tc.name: TransformOriginTest003
923  * @tc.desc: Verify that DomNode can set transform-origin with one value.
924  * @tc.type: FUNC
925  */
926 HWTEST_F(DomNodeTest, TransformOriginTest003, TestSize.Level1)
927 {
928     /**
929      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
930      * windowFilter.
931      */
932     const std::string jsonDivStr = "{"
933                                    "    \"tag\": \"div\","
934                                    "    \"commonStyle\": ["
935                                    "        {"
936                                    "            \"transformOrigin\": \"bottom\""
937                                    "        }"
938                                    "    ]"
939                                    "}";
940     /**
941      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its transform-origin.
942      */
943     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
944     ASSERT_TRUE(domNodeRoot != nullptr);
945 
946     /**
947      * @tc.steps: step3. Verify the DomNode's transform-origin common styles can be set correctly.
948      * @tc.expected: step3. 50% 100%
949      */
950     auto declaration = domNodeRoot->GetDeclaration();
951     ASSERT_TRUE(declaration != nullptr);
952     auto& animationStyle = static_cast<CommonAnimationStyle&>(declaration->GetStyle(StyleTag::COMMON_ANIMATION_STYLE));
953     ASSERT_TRUE(animationStyle.IsValid());
954     auto originOffsetX = animationStyle.tweenOption.GetTransformOriginX();
955     auto originOffsetY = animationStyle.tweenOption.GetTransformOriginY();
956     ASSERT_TRUE(originOffsetX.Unit() == DimensionUnit::PERCENT);
957     ASSERT_EQ(originOffsetX.Value(), 0.5);
958     ASSERT_TRUE(originOffsetY.Unit() == DimensionUnit::PERCENT);
959     ASSERT_EQ(originOffsetY.Value(), 1.0);
960 }
961 
962 /*
963  * @tc.name: TransformOriginTest004
964  * @tc.desc: Verify that DomNode can set transform-origin with one value.
965  * @tc.type: FUNC
966  */
967 HWTEST_F(DomNodeTest, TransformOriginTest004, TestSize.Level1)
968 {
969     /**
970      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
971      * windowFilter.
972      */
973     const std::string jsonDivStr = "{"
974                                    "    \"tag\": \"div\","
975                                    "    \"commonStyle\": ["
976                                    "        {"
977                                    "            \"transformOrigin\": \"top\""
978                                    "        }"
979                                    "    ]"
980                                    "}";
981     /**
982      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its transform-origin.
983      */
984     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
985     ASSERT_TRUE(domNodeRoot != nullptr);
986 
987     /**
988      * @tc.steps: step3. Verify the DomNode's transform-origin common styles can be set correctly.
989      * @tc.expected: step3. 50% 0%
990      */
991     auto declaration = domNodeRoot->GetDeclaration();
992     ASSERT_TRUE(declaration != nullptr);
993     auto& animationStyle = static_cast<CommonAnimationStyle&>(declaration->GetStyle(StyleTag::COMMON_ANIMATION_STYLE));
994     ASSERT_TRUE(animationStyle.IsValid());
995     auto originOffsetX = animationStyle.tweenOption.GetTransformOriginX();
996     auto originOffsetY = animationStyle.tweenOption.GetTransformOriginY();
997     ASSERT_TRUE(originOffsetX.Unit() == DimensionUnit::PERCENT);
998     ASSERT_EQ(originOffsetX.Value(), 0.5);
999     ASSERT_TRUE(originOffsetY.Unit() == DimensionUnit::PERCENT);
1000     ASSERT_EQ(originOffsetY.Value(), 0.0);
1001 }
1002 
1003 /*
1004  * @tc.name: TransformOriginTest005
1005  * @tc.desc: Verify that DomNode can set transform-origin with one value.
1006  * @tc.type: FUNC
1007  */
1008 HWTEST_F(DomNodeTest, TransformOriginTest005, TestSize.Level1)
1009 {
1010     /**
1011      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
1012      * windowFilter.
1013      */
1014     const std::string jsonDivStr = "{"
1015                                    "    \"tag\": \"div\","
1016                                    "    \"commonStyle\": ["
1017                                    "        {"
1018                                    "            \"transformOrigin\": \"bottom\""
1019                                    "        }"
1020                                    "    ]"
1021                                    "}";
1022     /**
1023      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its transform-origin.
1024      */
1025     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
1026     ASSERT_TRUE(domNodeRoot != nullptr);
1027 
1028     /**
1029      * @tc.steps: step3. Verify the DomNode's transform-origin common styles can be set correctly.
1030      * @tc.expected: step3. 50% 100%
1031      */
1032     auto declaration = domNodeRoot->GetDeclaration();
1033     ASSERT_TRUE(declaration != nullptr);
1034     auto& animationStyle = static_cast<CommonAnimationStyle&>(declaration->GetStyle(StyleTag::COMMON_ANIMATION_STYLE));
1035     ASSERT_TRUE(animationStyle.IsValid());
1036     auto originOffsetX = animationStyle.tweenOption.GetTransformOriginX();
1037     auto originOffsetY = animationStyle.tweenOption.GetTransformOriginY();
1038     ASSERT_TRUE(originOffsetX.Unit() == DimensionUnit::PERCENT);
1039     ASSERT_EQ(originOffsetX.Value(), 0.5);
1040     ASSERT_TRUE(originOffsetY.Unit() == DimensionUnit::PERCENT);
1041     ASSERT_EQ(originOffsetY.Value(), 1.0);
1042 }
1043 
1044 /*
1045  * @tc.name: TransformOriginTest006
1046  * @tc.desc: Verify that DomNode can set transform-origin with one value.
1047  * @tc.type: FUNC
1048  */
1049 HWTEST_F(DomNodeTest, TransformOriginTest006, TestSize.Level1)
1050 {
1051     /**
1052      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
1053      * windowFilter.
1054      */
1055     const std::string jsonDivStr = "{"
1056                                    "    \"tag\": \"div\","
1057                                    "    \"commonStyle\": ["
1058                                    "        {"
1059                                    "            \"transformOrigin\": \"40px\""
1060                                    "        }"
1061                                    "    ]"
1062                                    "}";
1063     /**
1064      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its transform-origin.
1065      */
1066     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
1067     ASSERT_TRUE(domNodeRoot != nullptr);
1068 
1069     /**
1070      * @tc.steps: step3. Verify the DomNode's transform-origin common styles can be set correctly.
1071      * @tc.expected: step3. 40px 50%
1072      */
1073     auto declaration = domNodeRoot->GetDeclaration();
1074     ASSERT_TRUE(declaration != nullptr);
1075     auto& animationStyle = static_cast<CommonAnimationStyle&>(declaration->GetStyle(StyleTag::COMMON_ANIMATION_STYLE));
1076     ASSERT_TRUE(animationStyle.IsValid());
1077     auto originOffsetX = animationStyle.tweenOption.GetTransformOriginX();
1078     auto originOffsetY = animationStyle.tweenOption.GetTransformOriginY();
1079     ASSERT_TRUE(originOffsetX.Unit() == DimensionUnit::PX);
1080     ASSERT_EQ(originOffsetX.Value(), 40);
1081     ASSERT_TRUE(originOffsetY.Unit() == DimensionUnit::PERCENT);
1082     ASSERT_EQ(originOffsetY.Value(), 0.5);
1083 }
1084 
1085 /*
1086  * @tc.name: TransformOriginTest007
1087  * @tc.desc: Verify that DomNode can set transform-origin with one value.
1088  * @tc.type: FUNC
1089  */
1090 HWTEST_F(DomNodeTest, TransformOriginTest007, TestSize.Level1)
1091 {
1092     /**
1093      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
1094      * windowFilter.
1095      */
1096     const std::string jsonDivStr = "{"
1097                                    "    \"tag\": \"div\","
1098                                    "    \"commonStyle\": ["
1099                                    "        {"
1100                                    "            \"transformOrigin\": \"30%\""
1101                                    "        }"
1102                                    "    ]"
1103                                    "}";
1104     /**
1105      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its transform-origin.
1106      */
1107     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
1108     ASSERT_TRUE(domNodeRoot != nullptr);
1109 
1110     /**
1111      * @tc.steps: step3. Verify the DomNode's transform-origin common styles can be set correctly.
1112      * @tc.expected: step3. 30% 50%
1113      */
1114     auto declaration = domNodeRoot->GetDeclaration();
1115     ASSERT_TRUE(declaration != nullptr);
1116     auto& animationStyle = static_cast<CommonAnimationStyle&>(declaration->GetStyle(StyleTag::COMMON_ANIMATION_STYLE));
1117     ASSERT_TRUE(animationStyle.IsValid());
1118     auto originOffsetX = animationStyle.tweenOption.GetTransformOriginX();
1119     auto originOffsetY = animationStyle.tweenOption.GetTransformOriginY();
1120     ASSERT_TRUE(originOffsetX.Unit() == DimensionUnit::PERCENT);
1121     ASSERT_EQ(originOffsetX.Value(), 0.3);
1122     ASSERT_TRUE(originOffsetY.Unit() == DimensionUnit::PERCENT);
1123     ASSERT_EQ(originOffsetY.Value(), 0.5);
1124 }
1125 
1126 /*
1127  * @tc.name: TransformOriginTest008
1128  * @tc.desc: Verify that DomNode can set transform-origin with one value.
1129  * @tc.type: FUNC
1130  */
1131 HWTEST_F(DomNodeTest, TransformOriginTest008, TestSize.Level1)
1132 {
1133     /**
1134      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
1135      * windowFilter.
1136      */
1137     const std::string jsonDivStr = "{"
1138                                    "    \"tag\": \"div\","
1139                                    "    \"commonStyle\": ["
1140                                    "        {"
1141                                    "            \"transformOrigin\": \"0% 0px\""
1142                                    "        }"
1143                                    "    ]"
1144                                    "}";
1145     /**
1146      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its transform-origin.
1147      */
1148     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
1149     ASSERT_TRUE(domNodeRoot != nullptr);
1150 
1151     /**
1152      * @tc.steps: step3. Verify the DomNode's transform-origin common styles can be set correctly.
1153      * @tc.expected: step3. 0% 0px
1154      */
1155     auto declaration = domNodeRoot->GetDeclaration();
1156     ASSERT_TRUE(declaration != nullptr);
1157     auto& animationStyle = static_cast<CommonAnimationStyle&>(declaration->GetStyle(StyleTag::COMMON_ANIMATION_STYLE));
1158     ASSERT_TRUE(animationStyle.IsValid());
1159     auto originOffsetX = animationStyle.tweenOption.GetTransformOriginX();
1160     auto originOffsetY = animationStyle.tweenOption.GetTransformOriginY();
1161     ASSERT_TRUE(originOffsetX.Unit() == DimensionUnit::PERCENT);
1162     ASSERT_EQ(originOffsetX.Value(), 0.0);
1163     ASSERT_TRUE(originOffsetY.Unit() == DimensionUnit::PX);
1164     ASSERT_EQ(originOffsetY.Value(), 0.0);
1165 }
1166 
1167 /*
1168  * @tc.name: TransformOriginTest009
1169  * @tc.desc: Verify that DomNode can set transform-origin with one value.
1170  * @tc.type: FUNC
1171  */
1172 HWTEST_F(DomNodeTest, TransformOriginTest009, TestSize.Level1)
1173 {
1174     /**
1175      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
1176      * windowFilter.
1177      */
1178     const std::string jsonDivStr = "{"
1179                                    "    \"tag\": \"div\","
1180                                    "    \"commonStyle\": ["
1181                                    "        {"
1182                                    "            \"transformOrigin\": \"left 30px\""
1183                                    "        }"
1184                                    "    ]"
1185                                    "}";
1186     /**
1187      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its transform-origin.
1188      */
1189     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
1190     ASSERT_TRUE(domNodeRoot != nullptr);
1191 
1192     /**
1193      * @tc.steps: step3. Verify the DomNode's transform-origin common styles can be set correctly.
1194      * @tc.expected: step3. 0% 30px
1195      */
1196     auto declaration = domNodeRoot->GetDeclaration();
1197     ASSERT_TRUE(declaration != nullptr);
1198     auto& animationStyle = static_cast<CommonAnimationStyle&>(declaration->GetStyle(StyleTag::COMMON_ANIMATION_STYLE));
1199     ASSERT_TRUE(animationStyle.IsValid());
1200     auto originOffsetX = animationStyle.tweenOption.GetTransformOriginX();
1201     auto originOffsetY = animationStyle.tweenOption.GetTransformOriginY();
1202     ASSERT_TRUE(originOffsetX.Unit() == DimensionUnit::PERCENT);
1203     ASSERT_EQ(originOffsetX.Value(), 0.0);
1204     ASSERT_TRUE(originOffsetY.Unit() == DimensionUnit::PX);
1205     ASSERT_EQ(originOffsetY.Value(), 30);
1206 }
1207 
1208 /*
1209  * @tc.name: TransformOriginTest010
1210  * @tc.desc: Verify that DomNode can set transform-origin with one value.
1211  * @tc.type: FUNC
1212  */
1213 HWTEST_F(DomNodeTest, TransformOriginTest010, TestSize.Level1)
1214 {
1215     /**
1216      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
1217      * windowFilter.
1218      */
1219     const std::string jsonDivStr = "{"
1220                                    "    \"tag\": \"div\","
1221                                    "    \"commonStyle\": ["
1222                                    "        {"
1223                                    "            \"transformOrigin\": \"left bottom\""
1224                                    "        }"
1225                                    "    ]"
1226                                    "}";
1227     /**
1228      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its transform-origin.
1229      */
1230     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
1231     ASSERT_TRUE(domNodeRoot != nullptr);
1232 
1233     /**
1234      * @tc.steps: step3. Verify the DomNode's transform-origin common styles can be set correctly.
1235      * @tc.expected: step3. 0% 100%
1236      */
1237     auto declaration = domNodeRoot->GetDeclaration();
1238     ASSERT_TRUE(declaration != nullptr);
1239     auto& animationStyle = static_cast<CommonAnimationStyle&>(declaration->GetStyle(StyleTag::COMMON_ANIMATION_STYLE));
1240     ASSERT_TRUE(animationStyle.IsValid());
1241     auto originOffsetX = animationStyle.tweenOption.GetTransformOriginX();
1242     auto originOffsetY = animationStyle.tweenOption.GetTransformOriginY();
1243     ASSERT_TRUE(originOffsetX.Unit() == DimensionUnit::PERCENT);
1244     ASSERT_EQ(originOffsetX.Value(), 0.0);
1245     ASSERT_TRUE(originOffsetY.Unit() == DimensionUnit::PERCENT);
1246     ASSERT_EQ(originOffsetY.Value(), 1.0);
1247 }
1248 
1249 /*
1250  * @tc.name: TransformOriginTest011
1251  * @tc.desc: Verify that DomNode can set transform-origin with one value.
1252  * @tc.type: FUNC
1253  */
1254 HWTEST_F(DomNodeTest, TransformOriginTest011, TestSize.Level1)
1255 {
1256     /**
1257      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
1258      * windowFilter.
1259      */
1260     const std::string jsonDivStr = "{"
1261                                    "    \"tag\": \"div\","
1262                                    "    \"commonStyle\": ["
1263                                    "        {"
1264                                    "            \"transformOrigin\": \"bottom bottom\""
1265                                    "        }"
1266                                    "    ]"
1267                                    "}";
1268     /**
1269      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its transform-origin.
1270      */
1271     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
1272     ASSERT_TRUE(domNodeRoot != nullptr);
1273 
1274     /**
1275      * @tc.steps: step3. Verify the DomNode's transform-origin common styles can be set correctly.
1276      * @tc.expected: step3. 50% 100%
1277      */
1278     auto declaration = domNodeRoot->GetDeclaration();
1279     ASSERT_TRUE(declaration != nullptr);
1280     auto& animationStyle = static_cast<CommonAnimationStyle&>(declaration->GetStyle(StyleTag::COMMON_ANIMATION_STYLE));
1281     ASSERT_TRUE(animationStyle.IsValid());
1282     auto originOffsetX = animationStyle.tweenOption.GetTransformOriginX();
1283     auto originOffsetY = animationStyle.tweenOption.GetTransformOriginY();
1284     ASSERT_TRUE(originOffsetX.Unit() == DimensionUnit::PERCENT);
1285     ASSERT_EQ(originOffsetX.Value(), 0.5);
1286     ASSERT_TRUE(originOffsetY.Unit() == DimensionUnit::PERCENT);
1287     ASSERT_EQ(originOffsetY.Value(), 1.0);
1288 }
1289 
1290 /*
1291  * @tc.name: MaskImageTest001
1292  * @tc.desc: Verify mask on dom created.
1293  * @tc.type: FUNC
1294  */
1295 HWTEST_F(DomNodeTest, MaskImageTest001, TestSize.Level1)
1296 {
1297     /**
1298      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
1299      * maskImage.
1300      */
1301     const std::string jsonDivStr = R"({"tag":"div","commonStyle":[{"maskImage":"common/mask.svg"}]})";
1302 
1303     /**
1304      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its maskImage.
1305      */
1306     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
1307     ASSERT_TRUE(domNodeRoot != nullptr);
1308 
1309     /**
1310      * @tc.steps: step3. Verify the DomNode's maskImage common styles can be set correctly.
1311      * @tc.expected: step3. Type is svg image.
1312      */
1313     auto boxChild = DOMNodeFactory::GetInstance().GetBoxChildComponent(domNodeRoot);
1314     ASSERT_TRUE(boxChild != nullptr);
1315 
1316     const auto& mask = boxChild->GetMask();
1317     ASSERT_TRUE(mask != nullptr);
1318     ASSERT_TRUE(mask->IsSvgImage());
1319 }
1320 
1321 /*
1322  * @tc.name: MaskImageTest002
1323  * @tc.desc: Verify mask on dom created.
1324  * @tc.type: FUNC
1325  */
1326 HWTEST_F(DomNodeTest, MaskImageTest002, TestSize.Level1)
1327 {
1328     /**
1329      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
1330      * maskImage.
1331      */
1332     const std::string jsonDivStr = R"({"tag":"div","commonStyle":[{"maskImage":"linearGradient"}]})";
1333 
1334     /**
1335      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its maskImage.
1336      */
1337     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
1338     ASSERT_TRUE(domNodeRoot != nullptr);
1339 
1340     /**
1341      * @tc.steps: step3. Verify the DomNode's maskImage common styles can be set correctly.
1342      * @tc.expected: step3. Type is color gradient.
1343      */
1344     auto boxChild = DOMNodeFactory::GetInstance().GetBoxChildComponent(domNodeRoot);
1345     ASSERT_TRUE(boxChild != nullptr);
1346 
1347     const auto& mask = boxChild->GetMask();
1348     ASSERT_TRUE(mask != nullptr);
1349     ASSERT_TRUE(mask->IsColorGradient());
1350 }
1351 
1352 /*
1353  * @tc.name: MaskImageTest003
1354  * @tc.desc: Verify mask on dom created.
1355  * @tc.type: FUNC
1356  */
1357 HWTEST_F(DomNodeTest, MaskImageTest003, TestSize.Level1)
1358 {
1359     /**
1360      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
1361      * maskImage.
1362      */
1363     const std::string jsonDivStr =
1364         R"({"tag":"div","commonStyle":[{"maskImage":"m.svg"},{"maskPosition":"center"},{"maskSize":"cover"}]})";
1365 
1366     /**
1367      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its maskImage.
1368      */
1369     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
1370     ASSERT_TRUE(domNodeRoot != nullptr);
1371 
1372     /**
1373      * @tc.steps: step3. Verify the DomNode's maskImage common styles can be set correctly.
1374      * @tc.expected: step3. Type is svg image. position and size is correctly.
1375      */
1376     auto boxChild = DOMNodeFactory::GetInstance().GetBoxChildComponent(domNodeRoot);
1377     ASSERT_TRUE(boxChild != nullptr);
1378 
1379     const auto& mask = boxChild->GetMask();
1380     ASSERT_TRUE(mask != nullptr);
1381     ASSERT_TRUE(mask->IsSvgImage());
1382 
1383     auto size = mask->GetMaskSize();
1384     ASSERT_EQ(size.GetSizeTypeX(), BackgroundImageSizeType::COVER);
1385 
1386     auto position = mask->GetMaskPosition();
1387     ASSERT_EQ(position.GetSizeTypeX(), BackgroundImagePositionType::PERCENT);
1388     ASSERT_EQ(position.GetSizeTypeY(), BackgroundImagePositionType::PERCENT);
1389     ASSERT_EQ(position.GetSizeValueX(), 50.0f);
1390     ASSERT_EQ(position.GetSizeValueY(), 50.0f);
1391 }
1392 
1393 /*
1394  * @tc.name: MaskImageTest004
1395  * @tc.desc: Verify mask on dom created.
1396  * @tc.type: FUNC
1397  */
1398 HWTEST_F(DomNodeTest, MaskImageTest004, TestSize.Level1)
1399 {
1400     /**
1401      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
1402      * maskImage.
1403      */
1404     const std::string jsonDivStr =
1405         R"({"tag":"div","commonStyle":[{"maskImage":"m.svg"},{"maskPosition":"20%"},{"maskSize":"30%"}]})";
1406 
1407     /**
1408      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its maskImage.
1409      */
1410     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
1411     ASSERT_TRUE(domNodeRoot != nullptr);
1412 
1413     /**
1414      * @tc.steps: step3. Verify the DomNode's maskImage common styles can be set correctly.
1415      * @tc.expected: step3. Type is svg image. position and size is correctly.
1416      */
1417     auto boxChild = DOMNodeFactory::GetInstance().GetBoxChildComponent(domNodeRoot);
1418     ASSERT_TRUE(boxChild != nullptr);
1419 
1420     const auto& mask = boxChild->GetMask();
1421     ASSERT_TRUE(mask != nullptr);
1422     ASSERT_TRUE(mask->IsSvgImage());
1423 
1424     auto position = mask->GetMaskPosition();
1425     ASSERT_EQ(position.GetSizeTypeX(), BackgroundImagePositionType::PERCENT);
1426     ASSERT_EQ(position.GetSizeTypeY(), BackgroundImagePositionType::PERCENT);
1427     ASSERT_EQ(position.GetSizeValueX(), 20.0f);
1428     ASSERT_EQ(position.GetSizeValueY(), 50.0f);
1429 
1430     auto size = mask->GetMaskSize();
1431     ASSERT_EQ(size.GetSizeTypeX(), BackgroundImageSizeType::PERCENT);
1432     ASSERT_EQ(size.GetSizeTypeY(), BackgroundImageSizeType::AUTO);
1433     ASSERT_EQ(size.GetSizeValueX(), 30.0f);
1434     ASSERT_EQ(size.GetSizeValueY(), 0.0f);
1435 }
1436 
1437 /*
1438  * @tc.name: MaskImageTest005
1439  * @tc.desc: Verify mask on dom created.
1440  * @tc.type: FUNC
1441  */
1442 HWTEST_F(DomNodeTest, MaskImageTest005, TestSize.Level1)
1443 {
1444     /**
1445      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
1446      * maskImage.
1447      */
1448     const std::string jsonDivStr =
1449         R"({"tag":"div","commonStyle":[{"maskImage":"m.svg"},{"maskPosition":"30px 20%"},{"maskSize":"30% 50px"}]})";
1450 
1451     /**
1452      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its maskImage.
1453      */
1454     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
1455     ASSERT_TRUE(domNodeRoot != nullptr);
1456 
1457     /**
1458      * @tc.steps: step3. Verify the DomNode's maskImage common styles can be set correctly.
1459      * @tc.expected: step3. Type is svg image. position and size is correctly.
1460      */
1461     auto boxChild = DOMNodeFactory::GetInstance().GetBoxChildComponent(domNodeRoot);
1462     ASSERT_TRUE(boxChild != nullptr);
1463 
1464     const auto& mask = boxChild->GetMask();
1465     ASSERT_TRUE(mask != nullptr);
1466     ASSERT_TRUE(mask->IsSvgImage());
1467 
1468     auto position = mask->GetMaskPosition();
1469     ASSERT_EQ(position.GetSizeTypeX(), BackgroundImagePositionType::PX);
1470     ASSERT_EQ(position.GetSizeTypeY(), BackgroundImagePositionType::PERCENT);
1471     ASSERT_EQ(position.GetSizeValueX(), 30.0f);
1472     ASSERT_EQ(position.GetSizeValueY(), 20.0f);
1473 
1474     auto size = mask->GetMaskSize();
1475     ASSERT_EQ(size.GetSizeTypeX(), BackgroundImageSizeType::PERCENT);
1476     ASSERT_EQ(size.GetSizeTypeY(), BackgroundImageSizeType::LENGTH);
1477     ASSERT_EQ(size.GetSizeValueX(), 30.0f);
1478     ASSERT_EQ(size.GetSizeValueY(), 50.0f);
1479 }
1480 
1481 /*
1482  * @tc.name: MaskImageTest006
1483  * @tc.desc: Verify mask on dom created.
1484  * @tc.type: FUNC
1485  */
1486 HWTEST_F(DomNodeTest, MaskImageTest006, TestSize.Level1)
1487 {
1488     /**
1489      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
1490      * maskImage.
1491      */
1492     const std::string jsonDivStr =
1493         R"({"tag":"div","commonStyle":[{"maskImage":"m.svg"},{"maskPosition":"left top"},{"maskSize":"contain"}]})";
1494 
1495     /**
1496      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its maskImage.
1497      */
1498     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
1499     ASSERT_TRUE(domNodeRoot != nullptr);
1500 
1501     /**
1502      * @tc.steps: step3. Verify the DomNode's maskImage common styles can be set correctly.
1503      * @tc.expected: step3. Type is svg image. position and size is correctly.
1504      */
1505     auto boxChild = DOMNodeFactory::GetInstance().GetBoxChildComponent(domNodeRoot);
1506     ASSERT_TRUE(boxChild != nullptr);
1507 
1508     const auto& mask = boxChild->GetMask();
1509     ASSERT_TRUE(mask != nullptr);
1510     ASSERT_TRUE(mask->IsSvgImage());
1511 
1512     auto position = mask->GetMaskPosition();
1513     ASSERT_EQ(position.GetSizeTypeX(), BackgroundImagePositionType::PERCENT);
1514     ASSERT_EQ(position.GetSizeTypeY(), BackgroundImagePositionType::PERCENT);
1515     ASSERT_EQ(position.GetSizeValueX(), 0.0f);
1516     ASSERT_EQ(position.GetSizeValueY(), 0.0f);
1517 
1518     auto size = mask->GetMaskSize();
1519     ASSERT_EQ(size.GetSizeTypeX(), BackgroundImageSizeType::CONTAIN);
1520 }
1521 
1522 /*
1523  * @tc.name: MaskImageTest007
1524  * @tc.desc: Verify mask on dom created.
1525  * @tc.type: FUNC
1526  */
1527 HWTEST_F(DomNodeTest, MaskImageTest007, TestSize.Level1)
1528 {
1529     /**
1530      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
1531      * maskImage.
1532      */
1533     const std::string jsonDivStr =
1534         R"({"tag":"div","commonStyle":[{"maskImage":"m.svg"},{"maskPosition":"right bottom"},{"maskSize":"auto"}]})";
1535 
1536     /**
1537      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its maskImage.
1538      */
1539     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
1540     ASSERT_TRUE(domNodeRoot != nullptr);
1541 
1542     /**
1543      * @tc.steps: step3. Verify the DomNode's maskImage common styles can be set correctly.
1544      * @tc.expected: step3. Type is svg image. position and size is correctly.
1545      */
1546     auto boxChild = DOMNodeFactory::GetInstance().GetBoxChildComponent(domNodeRoot);
1547     ASSERT_TRUE(boxChild != nullptr);
1548 
1549     const auto& mask = boxChild->GetMask();
1550     ASSERT_TRUE(mask != nullptr);
1551     ASSERT_TRUE(mask->IsSvgImage());
1552 
1553     auto position = mask->GetMaskPosition();
1554     ASSERT_EQ(position.GetSizeTypeX(), BackgroundImagePositionType::PERCENT);
1555     ASSERT_EQ(position.GetSizeTypeY(), BackgroundImagePositionType::PERCENT);
1556     ASSERT_EQ(position.GetSizeValueX(), 100.0f);
1557     ASSERT_EQ(position.GetSizeValueY(), 100.0f);
1558 
1559     auto size = mask->GetMaskSize();
1560     ASSERT_EQ(size.GetSizeTypeX(), BackgroundImageSizeType::AUTO);
1561 }
1562 
1563 /*
1564  * @tc.name: AngleTest001
1565  * @tc.desc: Verify angle with unit deg.
1566  * @tc.type: FUNC
1567  */
1568 HWTEST_F(DomNodeTest, AngleTest001, TestSize.Level1)
1569 {
1570     /**
1571      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
1572      * transform.
1573      */
1574     const std::string jsonDivStr = R"({"tag":"div","commonStyle":[{"transform":"{\"rotate\":\"30deg\"}"}]})";
1575     /**
1576      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its transform.
1577      */
1578     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
1579     ASSERT_TRUE(domNodeRoot != nullptr);
1580 
1581     /**
1582      * @tc.steps: step3. Verify the DomNode's transform common styles can be set correctly.
1583      * @tc.expected: step3. rotateZ 30deg
1584      */
1585 
1586     auto transformComponent = domNodeRoot->GetTransformComponent();
1587     ASSERT_TRUE(transformComponent != nullptr);
1588     const auto& effects = transformComponent->GetTransformEffects();
1589     const auto& operations = effects.GetOperations();
1590     ASSERT_TRUE(operations.size() == 1);
1591     ASSERT_TRUE(operations.front().type_ == TransformOperationType::ROTATE);
1592     ASSERT_TRUE(NearEqual(operations.front().rotateOperation_.angle, 30.0));
1593 }
1594 
1595 /*
1596  * @tc.name: AngleTest002
1597  * @tc.desc: Verify angle with unit grad.
1598  * @tc.type: FUNC
1599  */
1600 HWTEST_F(DomNodeTest, AngleTest002, TestSize.Level1)
1601 {
1602     /**
1603      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
1604      * transform.
1605      */
1606     const std::string jsonDivStr = R"({"tag":"div","commonStyle":[{"transform":"{\"rotate\":\"200grad\"}"}]})";
1607     /**
1608      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its transform.
1609      */
1610     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
1611     ASSERT_TRUE(domNodeRoot != nullptr);
1612 
1613     /**
1614      * @tc.steps: step3. Verify the DomNode's transform common styles can be set correctly.
1615      * @tc.expected: step3. rotateZ 30deg
1616      */
1617 
1618     auto transformComponent = domNodeRoot->GetTransformComponent();
1619     ASSERT_TRUE(transformComponent != nullptr);
1620     const auto& effects = transformComponent->GetTransformEffects();
1621     const auto& operations = effects.GetOperations();
1622     ASSERT_TRUE(operations.size() == 1);
1623     ASSERT_TRUE(operations.front().type_ == TransformOperationType::ROTATE);
1624     ASSERT_TRUE(NearEqual(operations.front().rotateOperation_.angle, 180.0));
1625 }
1626 
1627 /*
1628  * @tc.name: AngleTest003
1629  * @tc.desc: Verify angle with unit rad.
1630  * @tc.type: FUNC
1631  */
1632 HWTEST_F(DomNodeTest, AngleTest003, TestSize.Level1)
1633 {
1634     /**
1635      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
1636      * transform.
1637      */
1638     const std::string jsonDivStr = R"({"tag":"div","commonStyle":[{"transform":"{\"rotate\":\"6.2832rad\"}"}]})";
1639     /**
1640      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its transform.
1641      */
1642     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
1643     ASSERT_TRUE(domNodeRoot != nullptr);
1644 
1645     /**
1646      * @tc.steps: step3. Verify the DomNode's transform common styles can be set correctly.
1647      * @tc.expected: step3. rotateZ 30deg
1648      */
1649 
1650     auto transformComponent = domNodeRoot->GetTransformComponent();
1651     ASSERT_TRUE(transformComponent != nullptr);
1652     const auto& effects = transformComponent->GetTransformEffects();
1653 
1654     const auto& operations = effects.GetOperations();
1655     ASSERT_TRUE(operations.size() == 1);
1656     ASSERT_TRUE(operations.front().type_ == TransformOperationType::ROTATE);
1657     const double epsilon = 0.1;
1658     ASSERT_TRUE(NearEqual(operations.front().rotateOperation_.angle, 360.0, epsilon));
1659 }
1660 
1661 /*
1662  * @tc.name: AngleTest004
1663  * @tc.desc: Verify angle with unit turn.
1664  * @tc.type: FUNC
1665  */
1666 HWTEST_F(DomNodeTest, AngleTest004, TestSize.Level1)
1667 {
1668     /**
1669      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
1670      * transform.
1671      */
1672     const std::string jsonDivStr = R"({"tag":"div","commonStyle":[{"transform":"{\"rotate\":\"0.5turn\"}"}]})";
1673     /**
1674      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its transform.
1675      */
1676     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
1677     ASSERT_TRUE(domNodeRoot != nullptr);
1678 
1679     /**
1680      * @tc.steps: step3. Verify the DomNode's transform common styles can be set correctly.
1681      * @tc.expected: step3. rotateZ 30deg
1682      */
1683 
1684     auto transformComponent = domNodeRoot->GetTransformComponent();
1685     ASSERT_TRUE(transformComponent != nullptr);
1686     const auto& effects = transformComponent->GetTransformEffects();
1687     const auto& operations = effects.GetOperations();
1688     ASSERT_TRUE(operations.size() == 1);
1689     ASSERT_TRUE(operations.front().type_ == TransformOperationType::ROTATE);
1690     const double epsilon = 0.1;
1691     ASSERT_TRUE(NearEqual(operations.front().rotateOperation_.angle, 180.0, epsilon));
1692 }
1693 
1694 /*
1695  * @tc.name: ClipPathTest001
1696  * @tc.desc: Verify clippath with circle shape.
1697  * @tc.type: FUNC
1698  */
1699 HWTEST_F(DomNodeTest, ClipPathTest001, TestSize.Level1)
1700 {
1701     /**
1702      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
1703      * transform.
1704      */
1705     const std::string jsonDivStr = "{"
1706                                    "    \"tag\": \"div\","
1707                                    "    \"commonStyle\": ["
1708                                    "        {"
1709                                    "            \"clipPath\": \"margin-box circle(60% at 50% 50%)\""
1710                                    "        }"
1711                                    "    ]"
1712                                    "}";
1713     /**
1714      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its clip path.
1715      */
1716     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
1717     ASSERT_TRUE(domNodeRoot != nullptr);
1718 
1719     /**
1720      * @tc.steps: step3. Verify the DomNode's clip path common styles can be set correctly.
1721      * @tc.expected: step3. margin-box circle
1722      */
1723 
1724     auto boxChild = DOMNodeFactory::GetInstance().GetBoxChildComponent(domNodeRoot);
1725     ASSERT_TRUE(boxChild != nullptr);
1726     const auto& clippath =  boxChild->GetClipPath();
1727     ASSERT_TRUE(clippath != nullptr);
1728     ASSERT_TRUE(clippath->GetGeometryBoxType() == GeometryBoxType::MARGIN_BOX);
1729     ASSERT_TRUE(clippath->GetBasicShape() != nullptr);
1730     ASSERT_TRUE(clippath->GetBasicShape()->GetBasicShapeType() == BasicShapeType::CIRCLE);
1731     const auto& circle = AceType::DynamicCast<Circle>(clippath->GetBasicShape());
1732     ASSERT_TRUE(NearEqual(circle->GetRadius().Value(), 0.6));
1733     ASSERT_TRUE(NearEqual(circle->GetAxisX().Value(), 0.5));
1734     ASSERT_TRUE(NearEqual(circle->GetAxisX().Value(), 0.5));
1735 }
1736 
1737 /*
1738  * @tc.name: ClipPathTest002
1739  * @tc.desc: Verify clippath with Inset shape.
1740  * @tc.type: FUNC
1741  */
1742 HWTEST_F(DomNodeTest, ClipPathTest002, TestSize.Level1)
1743 {
1744     /**
1745      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
1746      * transform.
1747      */
1748     const std::string jsonDivStr = "{"
1749                                    "    \"tag\": \"div\","
1750                                    "    \"commonStyle\": ["
1751                                    "        {"
1752                                    "            \"clipPath\": \"padding-box inset(30% 10% 90% round 10 25% / 20% 15%)\""
1753                                    "        }"
1754                                    "    ]"
1755                                    "}";
1756     /**
1757      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its clip path.
1758      */
1759     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
1760     ASSERT_TRUE(domNodeRoot != nullptr);
1761 
1762     /**
1763      * @tc.steps: step3. Verify the DomNode's clip path common styles can be set correctly.
1764      * @tc.expected: step3. padding-box inset
1765      */
1766 
1767     auto boxChild = DOMNodeFactory::GetInstance().GetBoxChildComponent(domNodeRoot);
1768     ASSERT_TRUE(boxChild != nullptr);
1769     const auto& clippath =  boxChild->GetClipPath();
1770     ASSERT_TRUE(clippath != nullptr);
1771     ASSERT_TRUE(clippath->GetGeometryBoxType() == GeometryBoxType::PADDING_BOX);
1772     ASSERT_TRUE(clippath->GetBasicShape() != nullptr);
1773     ASSERT_TRUE(clippath->GetBasicShape()->GetBasicShapeType() == BasicShapeType::INSET);
1774     const auto& inset = AceType::DynamicCast<Inset>(clippath->GetBasicShape());
1775     ASSERT_TRUE(NearEqual(inset->GetTop().Value(), 0.3));
1776     ASSERT_TRUE(NearEqual(inset->GetRight().Value(), 0.1));
1777     ASSERT_TRUE(NearEqual(inset->GetBottom().Value(), 0.9));
1778     ASSERT_TRUE(NearEqual(inset->GetLeft().Value(), 0.1));
1779     ASSERT_TRUE(NearEqual(inset->GetTopLeftRadius().GetX().Value(), 10.0));
1780     ASSERT_TRUE(NearEqual(inset->GetTopLeftRadius().GetY().Value(), 0.2));
1781     ASSERT_TRUE(NearEqual(inset->GetTopRightRadius().GetX().Value(), 0.25));
1782     ASSERT_TRUE(NearEqual(inset->GetTopRightRadius().GetY().Value(), 0.15));
1783     ASSERT_TRUE(NearEqual(inset->GetBottomLeftRadius().GetX().Value(), 0.25));
1784     ASSERT_TRUE(NearEqual(inset->GetBottomLeftRadius().GetY().Value(), 0.15));
1785     ASSERT_TRUE(NearEqual(inset->GetBottomRightRadius().GetX().Value(), 10.0));
1786     ASSERT_TRUE(NearEqual(inset->GetBottomRightRadius().GetY().Value(), 0.2));
1787 }
1788 
1789 /*
1790  * @tc.name: ClipPathTest003
1791  * @tc.desc: Verify clippath with ellipse shape.
1792  * @tc.type: FUNC
1793  */
1794 HWTEST_F(DomNodeTest, ClipPathTest003, TestSize.Level1)
1795 {
1796     /**
1797      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
1798      * transform.
1799      */
1800     const std::string jsonDivStr = "{"
1801                                    "    \"tag\": \"div\","
1802                                    "    \"commonStyle\": ["
1803                                    "        {"
1804                                    "            \"clipPath\": \"border-box ellipse(25% 10% at 50% 60%)\""
1805                                    "        }"
1806                                    "    ]"
1807                                    "}";
1808     /**
1809      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its clip path.
1810      */
1811     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
1812     ASSERT_TRUE(domNodeRoot != nullptr);
1813 
1814     /**
1815      * @tc.steps: step3. Verify the DomNode's clip path common styles can be set correctly.
1816      * @tc.expected: step3. border-box ellipse
1817      */
1818     auto boxChild = DOMNodeFactory::GetInstance().GetBoxChildComponent(domNodeRoot);
1819     ASSERT_TRUE(boxChild != nullptr);
1820     const auto& clippath =  boxChild->GetClipPath();
1821     ASSERT_TRUE(clippath != nullptr);
1822     ASSERT_TRUE(clippath->GetGeometryBoxType() == GeometryBoxType::BORDER_BOX);
1823     ASSERT_TRUE(clippath->GetBasicShape() != nullptr);
1824     ASSERT_TRUE(clippath->GetBasicShape()->GetBasicShapeType() == BasicShapeType::ELLIPSE);
1825     const auto& ellipse = AceType::DynamicCast<Ellipse>(clippath->GetBasicShape());
1826     ASSERT_TRUE(NearEqual(ellipse->GetRadiusX().Value(),0.25));
1827     ASSERT_TRUE(NearEqual(ellipse->GetRadiusY().Value(), 0.1));
1828     ASSERT_TRUE(NearEqual(ellipse->GetAxisX().Value(), 0.5));
1829     ASSERT_TRUE(NearEqual(ellipse->GetAxisY().Value(), 0.6));
1830 }
1831 
1832 /*
1833  * @tc.name: ClipPathTest004
1834  * @tc.desc: Verify clippath with polygon shape.
1835  * @tc.type: FUNC
1836  */
1837 HWTEST_F(DomNodeTest, ClipPathTest004, TestSize.Level1)
1838 {
1839     /**
1840      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
1841      * transform.
1842      */
1843     const std::string jsonDivStr = "{"
1844                                    "    \"tag\": \"div\","
1845                                    "    \"commonStyle\": ["
1846                                    "        {"
1847                                    "            \"clipPath\": \"content-box polygon(50% 10, 8% 50%, 50% 100%, 0 50%)\""
1848                                    "        }"
1849                                    "    ]"
1850                                    "}";
1851     /**
1852      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its clip path.
1853      */
1854     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
1855     ASSERT_TRUE(domNodeRoot != nullptr);
1856     /**
1857      * @tc.steps: step3. Verify the DomNode's clip path common styles can be set correctly.
1858      * @tc.expected: step3. content-box polygon
1859      */
1860     auto boxChild = DOMNodeFactory::GetInstance().GetBoxChildComponent(domNodeRoot);
1861     ASSERT_TRUE(boxChild != nullptr);
1862     const auto& clippath =  boxChild->GetClipPath();
1863     ASSERT_TRUE(clippath != nullptr);
1864     ASSERT_TRUE(clippath->GetGeometryBoxType() == GeometryBoxType::CONTENT_BOX);
1865     ASSERT_TRUE(clippath->GetBasicShape() != nullptr);
1866     ASSERT_TRUE(clippath->GetBasicShape()->GetBasicShapeType() == BasicShapeType::POLYGON);
1867     const auto& polygon = AceType::DynamicCast<Polygon>(clippath->GetBasicShape());
1868     const auto& points = polygon->GetPoints();
1869     ASSERT_TRUE(points.size() == 4);
1870     ASSERT_TRUE(NearEqual(points.at(0).first.Value(), 0.5));
1871     ASSERT_TRUE(NearEqual(points.at(0).second.Value(), 10.0));
1872     ASSERT_TRUE(NearEqual(points.at(2).first.Value(), 0.5));
1873     ASSERT_TRUE(NearEqual(points.at(2).second.Value(), 1.0));
1874 }
1875 
1876 /*
1877  * @tc.name: ClipPathTest005
1878  * @tc.desc: Verify clippath with path shape.
1879  * @tc.type: FUNC
1880  */
1881 HWTEST_F(DomNodeTest, ClipPathTest005, TestSize.Level1)
1882 {
1883     /**
1884      * @tc.steps: step1. construct the json string of DomNode with constraint attributes:
1885      * transform.
1886      */
1887     const std::string jsonDivStr = "{"
1888                                    "    \"tag\": \"div\","
1889                                    "    \"commonStyle\": ["
1890                                    "        {"
1891                                    "            \"clipPath\": \"path('M150 20 L75 220 L225 220 Z')\""
1892                                    "        }"
1893                                    "    ]"
1894                                    "}";
1895     /**
1896      * @tc.steps: step2. call JsonUtil interface, create DomNode and set its clip path.
1897      */
1898     auto domNodeRoot = DOMNodeFactory::GetInstance().CreateDOMNodeFromDsl(jsonDivStr);
1899     ASSERT_TRUE(domNodeRoot != nullptr);
1900     /**
1901      * @tc.steps: step3. Verify the DomNode's clip path common styles can be set correctly.
1902      * @tc.expected: step3. border-box path
1903      */
1904     auto boxChild = DOMNodeFactory::GetInstance().GetBoxChildComponent(domNodeRoot);
1905     ASSERT_TRUE(boxChild != nullptr);
1906     const auto& clippath =  boxChild->GetClipPath();
1907     ASSERT_TRUE(clippath != nullptr);
1908     ASSERT_TRUE(clippath->GetGeometryBoxType() == GeometryBoxType::NONE);
1909     ASSERT_TRUE(clippath->GetBasicShape() != nullptr);
1910     ASSERT_TRUE(clippath->GetBasicShape()->GetBasicShapeType() == BasicShapeType::PATH);
1911     const auto& path = AceType::DynamicCast<Path>(clippath->GetBasicShape());
1912     ASSERT_TRUE(path->GetValue() == "M150 20 L75 220 L225 220 Z");
1913 }
1914 
1915 } // namespace OHOS::Ace::Framework
1916