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_TESTER_IMPL_H 17 #define OHOS_ACE_COMPONENT_TEST_TESTER_IMPL_H 18 19 #include <memory> 20 #include <vector> 21 22 #include "component_test/core/action.h" 23 #include "component_test/core/component_test_component_impl.h" 24 #include "component_test/core/component_test_matcher_impl.h" 25 26 namespace OHOS::Ace::ComponentTest { 27 enum UiDirection : uint8_t { 28 TO_LEFT, 29 TO_RIGHT, 30 TO_UP, 31 TO_DOWN, 32 }; 33 34 class ACE_FORCE_EXPORT ComponentTestTesterImpl final { 35 public: 36 ComponentTestTesterImpl() = default; 37 ~ComponentTestTesterImpl() = default; 38 39 ComponentTestComponentImpl* FindComponentImpl(const ComponentTestMatcherImpl& matcher, ErrInfo& errInfo) const; 40 std::unique_ptr<std::vector<ComponentTestComponentImpl*>> FindComponentsImpl( 41 const ComponentTestMatcherImpl& matcher, ErrInfo& errInfo) const; 42 void AssertComponentExistImpl(const ComponentTestMatcherImpl& matcher, ErrInfo& errInfo) const; 43 ComponentTestComponentImpl* ScrollUntilExistImpl(const ComponentTestMatcherImpl& matcher, ErrInfo& errInfo) const; 44 void TriggerKeyImpl(OHOS::MMI::KeyCode keyCode, ErrInfo& errInfo) const; 45 void TriggerCombineKeysImpl(const std::vector<OHOS::MMI::KeyCode>& keyCodes, ErrInfo& errInfo) const; 46 void TapImpl(float x, float y, ErrInfo& errInfo) const; 47 void DoubleTapImpl(float x, float y, ErrInfo& errInfo) const; 48 void PressImpl(float x, float y, ErrInfo& errInfo, uint32_t duration = PRESS_HOLD_MS) const; 49 void ScrollImpl(float deltaX, float deltaY, ErrInfo& errInfo) const; 50 void DragImpl(float startX, float startY, float endX, float endY, uint32_t speed, ErrInfo& errInfo) const; 51 void FlingImpl( 52 const NG::PointF& from, const NG::PointF& to, uint32_t stepLen, uint32_t speed, ErrInfo& errInfo) const; 53 void FlingImpl(UiDirection direction, uint32_t speed, ErrInfo& errInfo) const; 54 55 private: 56 void GenericClick(float x, float y, const TouchType touchType, uint32_t duration = PRESS_HOLD_MS) const; 57 }; 58 59 } // namespace OHOS::Ace::ComponentTest 60 61 #endif // OHOS_NAPI_ACE_COMPONENT_TEST_TESTER_IMPL_H 62