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 RemoveInvisibleWidget() override; 37 static std::string GenerateNodeHashCode(const OHOS::Accessibility::AccessibilityElementInfo &element); 38 39 protected: 40 void WrapperElement(Widget &widget) override; 41 42 private: 43 bool VisitNodeByChildAndBrother(Widget &widget); 44 bool VisitChildren(Widget& widget); 45 bool VisitBrother(Widget &widget, int parentIndex, int tempCurrentIndex); 46 void WrapperNodeAttrToVec(Widget &widget, const OHOS::Accessibility::AccessibilityElementInfo &element); 47 void WrapperNodeActionAttrToVec(Widget &widget, const OHOS::Accessibility::AccessibilityElementInfo &element); 48 std::vector<OHOS::Accessibility::AccessibilityElementInfo> elementInfoLists_; 49 }; 50 } // namespace OHOS::uitest 51 52 #endif