1 /*
2  * Copyright (c) 2024 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 #ifndef TEST_UNITTEST_CORE_BASE_FRAME_NODE_TEST_NG_H
17 #define TEST_UNITTEST_CORE_BASE_FRAME_NODE_TEST_NG_H
18 #include "gtest/gtest.h"
19 
20 #define protected public
21 #define private public
22 #include "test/mock/core/pipeline/mock_pipeline_context.h"
23 #include "test/mock/core/render/mock_render_context.h"
24 
25 #include "core/components_ng/base/frame_node.h"
26 #include "core/components_ng/pattern/linear_layout/linear_layout_pattern.h"
27 
28 namespace OHOS::Ace::NG {
29 namespace {
30 const RefPtr<FrameNode> FRAME_NODE_PARENT =
31     FrameNode::CreateFrameNode("parent", 0, AceType::MakeRefPtr<Pattern>(), true);
32 const RefPtr<FrameNode> FRAME_NODE = FrameNode::CreateFrameNode("one", 1, AceType::MakeRefPtr<Pattern>());
33 const RefPtr<FrameNode> FRAME_NODE2 = FrameNode::CreateFrameNode("two", 2, AceType::MakeRefPtr<Pattern>());
34 const RefPtr<FrameNode> FRAME_NODE3 =
35     FrameNode::CreateFrameNode("three", 3, AceType::MakeRefPtr<LinearLayoutPattern>(false));
36 const RefPtr<FrameNode> FRAME_NODE_WEB_ETS_TAG =
37     FrameNode::CreateFrameNode(V2::WEB_ETS_TAG, 5, AceType::MakeRefPtr<LinearLayoutPattern>(false));
38 std::string srcimages = "";
39 
40 const std::string NAME = "propertyName";
41 float value = 1.0;
42 const std::function<void(float)> onCallbackEvent = [](float) {};
43 
44 const float CONTAINER_WIDTH = 600.0f;
45 const float CONTAINER_HEIGHT = 1000.0f;
46 const SizeF CONTAINER_SIZE(CONTAINER_WIDTH, CONTAINER_HEIGHT);
47 
48 const float CONTAINER_WIDTH_HUGE = 1260.0f;
49 const SizeF CONTAINER_SIZE_HUGE(CONTAINER_WIDTH_HUGE, CONTAINER_HEIGHT);
50 
51 const float CONTAINER_WIDTH_SMALL = 10.0f;
52 const SizeF CONTAINER_SIZE_SMALL(CONTAINER_WIDTH_SMALL, CONTAINER_HEIGHT);
53 
54 const float CONTAINER_WIDTH_ZERO = 0.0f;
55 const SizeF CONTAINER_SIZE_ZERO(CONTAINER_WIDTH_ZERO, CONTAINER_WIDTH_ZERO);
56 
57 const OffsetF OFFSETF { 1.0, 1.0 };
58 const float DEFAULT_X = 10;
59 const float DEFAULT_Y = 10;
60 
61 constexpr uint64_t TIMESTAMP_1 = 100;
62 constexpr uint64_t TIMESTAMP_2 = 101;
63 constexpr uint64_t TIMESTAMP_3 = 102;
64 constexpr uint64_t TIMESTAMP_4 = 103;
65 
66 const InspectorFilter filter;
67 } // namespace
68 class FrameNodeTestNg : public testing::Test {
69 public:
70     static void SetUpTestSuite();
71     static void TearDownTestSuite();
72 };
73 
74 class TestNode : public UINode {
75     DECLARE_ACE_TYPE(TestNode, UINode);
76 
77 public:
CreateTestNode(int32_t nodeId)78     static RefPtr<TestNode> CreateTestNode(int32_t nodeId)
79     {
80         auto node = MakeRefPtr<TestNode>(nodeId);
81         return node;
82     }
83 
IsAtomicNode()84     bool IsAtomicNode() const override
85     {
86         return true;
87     }
88 
TestNode(int32_t nodeId)89     explicit TestNode(int32_t nodeId) : UINode("TestNode", nodeId) {}
90     ~TestNode() override = default;
91 };
92 } // namespace OHOS::Ace::NG
93 
94 #endif // TEST_UNITTEST_CORE_BASE_FRAME_NODE_TEST_NG_H