/* * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef SELECT_STRATEGY_H #define SELECT_STRATEGY_H #include "ui_model.h" #include "element_node_iterator.h" namespace OHOS::uitest { enum class StrategyEnum { PLAIN, WITH_IN, IS_AFTER, IS_BEFORE, COMPLEX, }; struct StrategyBuildParam { std::vector myselfMatcher; std::vector> afterAnchorMatcherVec; std::vector> beforeAnchorMatcherVec; std::vector> withInAnchorMatcherVec; }; class SelectStrategy { public: SelectStrategy() = default; static unique_ptr BuildSelectStrategy(const StrategyBuildParam &buildParam, bool isWantMulti); virtual void SetAndCalcSelectWindowRect(const Rect &windowBounds, const std::vector &windowBoundsVec); virtual std::string Describe() const; virtual void RegisterAnchorMatch(const WidgetMatchModel &matchModel); virtual void RegisterMyselfMatch(const WidgetMatchModel &matchModel); virtual void SetWantMulti(bool isWantMulti); virtual StrategyEnum GetStrategyType() const = 0; virtual void LocateNode(const Window &window, ElementNodeIterator &elementNodeRef, vector &visitWidgets, vector &targetWidgets, bool isSkipInvisible = true) = 0; virtual ~SelectStrategy(); protected: virtual void RefreshWidgetBounds(Widget &widget); virtual void CalcWidgetVisibleBounds(Widget &widget); std::vector anchorMatch_; std::vector myselfMatch_; bool wantMulti_ = false; Rect windowBounds_{0, 0, 0, 0}; std::vector overplayWindowBoundsVec_; std::map clipers_; }; } // namespace OHOS::uitest #endif