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 OHOS_ACE_COMPONENT_TEST_COMPONENT_IMPL_H 17 #define OHOS_ACE_COMPONENT_TEST_COMPONENT_IMPL_H 18 19 #include <vector> 20 21 #include "component_test/core/action.h" 22 23 #include "base/geometry/ng/rect_t.h" 24 #include "core/components_ng/base/ui_node.h" 25 #include "core/components_ng/pattern/pattern.h" 26 #include "core/pipeline_ng/pipeline_context.h" 27 28 namespace OHOS::Ace::ComponentTest { 29 30 class ACE_FORCE_EXPORT ComponentTestComponentImpl final { 31 public: 32 ComponentTestComponentImpl() = default; 33 ~ComponentTestComponentImpl() = default; 34 35 void TapImpl(ErrInfo& errInfo) const; 36 void DoubleTapImpl(ErrInfo& errInfo) const; 37 void PressImpl(ErrInfo& errInfo, uint32_t duration = PRESS_HOLD_MS) const; 38 void PinchOutImpl(float scale, ErrInfo& errInfo) const; 39 void PinchInImpl(float scale, ErrInfo& errInfo) const; 40 void InputTextImpl(std::string text, ErrInfo& errInfo) const; 41 void ClearTextImpl(ErrInfo& errInfo) const; 42 void ScrollToTopImplAsync(uint32_t speed, std::function<void(ErrInfo errInfo)>&& callback) const; 43 void ScrollToBottomImplAsync(uint32_t speed, std::function<void(ErrInfo errInfo)>&& callback) const; 44 std::string GetIdImpl(ErrInfo& errInfo) const; 45 std::string GetTextImpl(ErrInfo& errInfo) const; 46 std::string GetTypeImpl(ErrInfo& errInfo) const; 47 bool IsClickableImpl(ErrInfo& errInfo) const; 48 bool IsLongPressableImpl(ErrInfo& errInfo) const; 49 bool IsScrollableImpl(ErrInfo& errInfo) const; 50 bool IsEnabledImpl(ErrInfo& errInfo) const; 51 bool IsFocusedImpl(ErrInfo& errInfo) const; 52 bool IsSelectedImpl(ErrInfo& errInfo) const; 53 bool IsCheckedImpl(ErrInfo& errInfo) const; 54 bool IsCheckableImpl(ErrInfo& errInfo) const; 55 std::string GetInspectorInfoImpl(ErrInfo& errInfo) const; 56 std::string GetInspectorTreeImpl(ErrInfo& errInfo) const; 57 int32_t GetChildCountImpl(ErrInfo& errInfo) const; 58 NG::RectF GetBoundsImpl(ErrInfo& errInfo) const; 59 void SetUiNode(const RefPtr<NG::UINode> uiNode); 60 void SetEffective(); 61 62 private: 63 RefPtr<NG::UINode> uiNode_ = nullptr; 64 NG::RectF effective_ = {}; 65 void GetContextInfo(const RefPtr<NG::PipelineContext>& context, std::unique_ptr<JsonValue>& jsonRoot) const; 66 void ScrollToBorderAsync(uint32_t speed, bool toTop, std::function<void(ErrInfo errInfo)>&& callback) const; 67 void GetFrameNodeChildren( 68 const RefPtr<NG::UINode>& uiNode, std::vector<RefPtr<NG::UINode>>& children, int32_t pageId) const; 69 std::string GetChildrenInspectorInfo( 70 std::vector<RefPtr<NG::UINode>> children, int32_t pageId, std::unique_ptr<JsonValue> jsonNode) const; 71 void GetInspectorChildren( 72 const RefPtr<NG::UINode>& parent, std::unique_ptr<JsonValue>& jsonNodeArray, int pageId) const; 73 void GetSpanInspector( 74 const RefPtr<NG::UINode>& parent, std::unique_ptr<JsonValue>& jsonNodeArray, int pageId) const; 75 bool GenericClick(const TouchType touchType, uint32_t duration = PRESS_HOLD_MS) const; 76 RefPtr<NG::FrameNode> GetFrameNode() const; 77 }; 78 79 } // namespace OHOS::Ace::ComponentTest 80 81 #endif // OHOS_NAPI_ACE_COMPONENT_TEST_COMPONENT_IMPL_H 82