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_IMPL_H 17 #define ELEMENT_NODE_ITERATOR_IMPL_H 18 19 #include "ui_model.h" 20 #include "element_node_iterator.h" 21 #include "accessibility_ui_test_ability.h" 22 #include "accessibility_element_info.h" 23 24 namespace OHOS::uitest { 25 class ElementNodeIteratorImpl : public ElementNodeIterator { 26 public: 27 explicit ElementNodeIteratorImpl(const std::vector<OHOS::Accessibility::AccessibilityElementInfo> &elements); 28 ElementNodeIteratorImpl(); 29 ~ElementNodeIteratorImpl() override; 30 bool DFSNextWithInTarget(Widget &widget) override; 31 bool DFSNext(Widget &widget, uint32_t windowId) override; 32 bool IsVisitFinish() const override; 33 void RestoreNodeIndexByAnchor() override; 34 void ResetNodeIndexToAnchor() override; 35 void ClearDFSNext() override; 36 void GetParentContainerBounds(Rect &dockerRect) override; 37 void CheckAndUpdateContainerRectMap() override; 38 void RemoveInvisibleWidget() override; 39 static std::string GenerateNodeHashCode(const OHOS::Accessibility::AccessibilityElementInfo &element); 40 41 protected: 42 void WrapperElement(Widget &widget) override; 43 44 private: 45 bool VisitNodeByChildAndBrother(Widget &widget); 46 bool VisitChildren(Widget& widget); 47 bool VisitBrother(Widget &widget, int parentIndex, int tempCurrentIndex); 48 void WrapperNodeAttrToVec(Widget &widget, const OHOS::Accessibility::AccessibilityElementInfo &element); 49 void WrapperNodeActionAttrToVec(Widget &widget, const OHOS::Accessibility::AccessibilityElementInfo &element); 50 std::vector<OHOS::Accessibility::AccessibilityElementInfo> elementInfoLists_; 51 }; 52 } // namespace OHOS::uitest 53 54 #endif