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_MANAGER_DRAG_DROP_MANAGER_TEST_NG_H 17 #define TEST_UNITTEST_CORE_MANAGER_DRAG_DROP_MANAGER_TEST_NG_H 18 #include <optional> 19 20 #include "gtest/gtest.h" 21 22 #define private public 23 #define protected public 24 #include "test/mock/core/common/mock_container.h" 25 #include "test/mock/core/common/mock_interaction_interface.h" 26 #include "test/mock/core/pipeline/mock_pipeline_context.h" 27 28 #include "base/geometry/ng/offset_t.h" 29 #include "base/geometry/ng/rect_t.h" 30 #include "base/geometry/ng/size_t.h" 31 #include "base/image/pixel_map.h" 32 #include "base/memory/ace_type.h" 33 #include "base/memory/referenced.h" 34 #include "base/subwindow/subwindow_manager.h" 35 #include "core/common/interaction/interaction_interface.h" 36 #include "core/components/common/layout/grid_system_manager.h" 37 #include "core/components_ng/base/frame_node.h" 38 #include "core/components_ng/base/geometry_node.h" 39 #include "core/components_ng/base/ui_node.h" 40 #include "core/components_ng/event/event_hub.h" 41 #include "core/components_ng/manager/drag_drop/drag_drop_manager.h" 42 #include "core/components_ng/manager/drag_drop/drag_drop_proxy.h" 43 #include "core/components_ng/pattern/grid/grid_event_hub.h" 44 #include "core/components_ng/pattern/grid/grid_pattern.h" 45 #include "core/components_ng/pattern/list/list_event_hub.h" 46 #include "core/components_ng/pattern/list/list_pattern.h" 47 #include "core/components_ng/pattern/pattern.h" 48 #include "core/components_ng/pattern/text/text_pattern.h" 49 #include "core/components_v2/inspector/inspector_constants.h" 50 #include "core/pipeline/base/render_node.h" 51 #include "core/components_ng/manager/drag_drop/drag_drop_global_controller.h" 52 #include "core/components_ng/manager/drag_drop/drag_drop_spring_loading/drag_drop_spring_loading_detector.h" 53 54 namespace OHOS::Ace::NG { 55 namespace { 56 const std::string ROOT_ETS_TAG("root"); 57 const std::string GRID_TAG("grid"); 58 const std::string LIST_TAG("list"); 59 const std::string NODE_TAG("custom_node"); 60 const std::string NODE_TAG_EX("custom_node_ex"); 61 const std::string NODE_TAG_EX2("custom_node_ex2"); 62 constexpr int32_t GLOBAL_X = 10; 63 constexpr int32_t GLOBAL_Y = 20; 64 const std::string EXTRA_INFO("extra info"); 65 const std::string EXTRA_INFO_2("extra info 2"); 66 const std::string EXTRA_INFO_LEAVE("extra info LEAVE"); 67 const std::string EXTRA_INFO_MOVE("extra info MOVE"); 68 const std::string EXTRA_INFO_ENTER("extra info ENTER"); 69 const std::string ITEM_INFO_LEAVE("item info LEAVE"); 70 const std::string ITEM_INFO_MOVE("item info MOVE"); 71 const std::string ITEM_INFO_ENTER("item info ENTER"); 72 constexpr int32_t INVALID_CURRENT_ID = -1; 73 constexpr int32_t INVALID_PULL_ID = -1; 74 constexpr int32_t CURRENT_PULL_ID = 123; 75 constexpr int32_t NEW_PULL_ID = 456; 76 constexpr int32_t WINDOW_ID = 1; 77 constexpr int32_t PARENT_NODE_ID = 2; 78 constexpr float POINT_X1 = 10.0f; 79 constexpr float POINT_Y1 = 20.0f; 80 constexpr float POINT_X2 = 30.0f; 81 constexpr float POINT_Y2 = 40.0f; 82 // before testing CheckDragDropProxy, DragWindow has created 6 times 83 constexpr int32_t VALID_CURRENT_ID = 6; 84 const OffsetF FRAME_OFFSET(0.0f, 0.0f); 85 const SizeF FRAME_SIZE(GLOBAL_X * 10.0f, GLOBAL_Y * 10.0f); 86 constexpr int32_t DRAGGED_INDEX = 0; 87 const DragType DRAG_TYPE_GRID = DragType::GRID; 88 const DragType DRAG_TYPE_LIST = DragType::LIST; 89 } // namespace 90 91 class DragDropManagerTestNg : public testing::Test { 92 public: 93 static void SetUpTestCase(); 94 static void TearDownTestCase(); 95 }; 96 97 class DragDropManagerTestNgNew : public testing::Test { 98 public: 99 static void SetUpTestCase(); 100 static void TearDownTestCase(); 101 }; 102 103 class DragDropManagerTestNgCoverage : public testing::Test { 104 public: 105 static void SetUpTestCase(); 106 static void TearDownTestCase(); 107 }; 108 109 class DragDropManagerTestNgPlus : public testing::Test { 110 public: 111 static void SetUpTestCase(); 112 static void TearDownTestCase(); 113 }; 114 } // namespace OHOS::Ace::NG 115 116 #endif //TEST_UNITTEST_CORE_MANAGER_DRAG_DROP_MANAGER_TEST_NG_H