1 /* 2 * Copyright (c) 2023 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 ELEMENT_NODE_ITERATOR_H 17 #define ELEMENT_NODE_ITERATOR_H 18 19 #include "ui_model.h" 20 21 namespace OHOS::uitest { 22 class ElementNodeIterator { 23 public: 24 ElementNodeIterator() = default; 25 virtual bool DFSNextWithInTarget(Widget &widget) = 0; 26 virtual bool DFSNext(Widget &widget, uint32_t windowId) = 0; 27 virtual bool IsVisitFinish() const = 0; 28 virtual void RestoreNodeIndexByAnchor() = 0; 29 virtual void ResetNodeIndexToAnchor() = 0; 30 virtual void ClearDFSNext() = 0; 31 virtual void GetParentContainerBounds(Rect &dockerRect) = 0; 32 virtual void CheckAndUpdateContainerRectMap() = 0; 33 virtual void RemoveInvisibleWidget() = 0; 34 35 virtual ~ElementNodeIterator() = default; 36 37 protected: 38 virtual void WrapperElement(Widget &widget) = 0; 39 int currentIndex_ = -1; 40 int topIndex_ = 0; 41 int lastCurrentIndex_ = -1; 42 std::map<int, int> elementToParentIndexMap_; 43 std::set<int> visitAndVisibleIndexSet_; 44 std::map<int, Rect> elementIndexToRectMap_; 45 std::map<int, std::string> elementIndexToHierarch_; 46 }; 47 } // namespace OHOS::uitest 48 49 #endif