• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef TEST_UNITTEST_CORE_EVENT_FOCUS_API_TEST_H
17 #define TEST_UNITTEST_CORE_EVENT_FOCUS_API_TEST_H
18 #include <cstddef>
19 #include <cstdint>
20 
21 #include "gtest/gtest.h"
22 #include "test/mock/core/common/mock_theme_manager.h"
23 #include "test/mock/core/pipeline/mock_pipeline_context.h"
24 #include "test/unittest/core/event/focus_core/focus_test_base.h"
25 
26 #include "base/geometry/ng/offset_t.h"
27 #include "base/geometry/ng/size_t.h"
28 #include "base/memory/ace_type.h"
29 #include "base/memory/referenced.h"
30 #include "core/components/theme/app_theme.h"
31 #include "core/components_ng/base/frame_node.h"
32 #include "core/components_ng/event/focus_hub.h"
33 #include "core/components_ng/event/touch_event.h"
34 #include "core/components_ng/manager/focus/focus_view.h"
35 #include "core/components_ng/pattern/linear_layout/linear_layout_pattern.h"
36 #include "core/components_ng/pattern/pattern.h"
37 #include "core/components_v2/inspector/inspector_constants.h"
38 #include "core/event/key_event.h"
39 #include "core/pipeline_ng/pipeline_context.h"
40 
41 namespace OHOS::Ace::NG {
42 struct FocusAreaNodeOffset {
43     float nodeAx;
44     float nodeAy;
45     float nodeBx;
46     float nodeBy;
47     float nodeCx;
48     float nodeDx;
49     float nodeCy;
50     float nodeDy;
51 };
52 struct FocusAreaTestCase {
53     bool isFocusable;
54     bool isFocusBrotherNode;
55     FocusStep StepMethod;
56     FocusAreaNodeOffset nodeOffset;
FocusAreaTestCaseFocusAreaTestCase57     FocusAreaTestCase(bool isFocusable, bool isFocusBrotherNode, FocusStep StepMethod, FocusAreaNodeOffset nodeOffset)
58         : isFocusable(isFocusable), isFocusBrotherNode(isFocusBrotherNode), StepMethod(StepMethod),
59           nodeOffset { nodeOffset.nodeAx, nodeOffset.nodeAy, nodeOffset.nodeBx, nodeOffset.nodeBy, nodeOffset.nodeCx,
60               nodeOffset.nodeCy, nodeOffset.nodeDx, nodeOffset.nodeDy }
61     {}
62 };
63 
64 class FocusAreaTestNG : public FocusTestBaseNg, public testing::Test {
65 public:
66     static void SetUpTestSuite();
67     static void TearDownTestSuite();
68     static RefPtr<FrameNode> CreatNode(float nodex, float nodey);
69     RefPtr<FrameNode> CreatRootNode();
70     void InitFocusareaTest();
71 };
72 
73 } // namespace OHOS::Ace::NG
74 
75 #endif // TEST_UNITTEST_CORE_EVENT_FOCUS_WINDOW_TEST_H