1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include <memory>
16 
17 #include "gtest/gtest.h"
18 
19 #define protected public
20 #define private public
21 
22 #include "core/components_ng/base/geometry_node.h"
23 
24 using namespace testing;
25 using namespace testing::ext;
26 
27 namespace OHOS::Ace::NG {
28 namespace {
29 const std::array<bool, 4> margin { false, true, false, true };
30 const std::array<bool, 4> content { false, true, true, false };
31 } // namespace
32 class GeometryNodeTestNg : public testing::Test {
33 public:
SetUpTestCase()34     static void SetUpTestCase() {}
TearDownTestCase()35     static void TearDownTestCase() {}
36 };
37 
38 /**
39  * @tc.name: GeometryNodeTestNg001
40  * @tc.desc: Test geometry node method
41  * @tc.type: FUNC
42  */
43 HWTEST_F(GeometryNodeTestNg, GeometryNodeTestNg001, TestSize.Level1)
44 {
45     /**
46      * @tc.steps: step1. geometry node clone
47      * @tc.expected: step1. margin size
48      */
49     for (int i = 0; i < 4; ++i) {
50         auto geometryNode = AceType::MakeRefPtr<GeometryNode>();
51         if (margin[i]) {
52             geometryNode->margin_ = std::make_unique<MarginPropertyF>();
53         }
54         if (content[i]) {
55             geometryNode->content_ = std::make_unique<GeometryProperty>();
56         }
57         auto cloneNode = geometryNode->Clone();
58         EXPECT_NE(cloneNode, nullptr);
59         if (margin[i]) {
60             EXPECT_EQ(geometryNode->margin_->Size(), cloneNode->margin_->Size());
61         }
62     }
63 }
64 } // namespace OHOS::Ace::NG