• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 RemoveInvisibleWidget() = 0;
32 
33         virtual ~ElementNodeIterator() = default;
34 
35     protected:
36         virtual void WrapperElement(Widget &widget) = 0;
37         int currentIndex_ = -1;
38         int topIndex_ = 0;
39         int lastCurrentIndex_ = -1;
40         std::map<int, int> elementToParentIndexMap_;
41         std::set<int> visitAndVisibleIndexSet_;
42         std::map<int, Rect> elementIndexToRectMap_;
43         std::map<int, std::string> elementIndexToHierarch_;
44     };
45 } // namespace OHOS::uitest
46 
47 #endif