1 /* 2 * Copyright (c) 2022 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 TEST_WUKONG_COMPONENT_TREE_H 17 #define TEST_WUKONG_COMPONENT_TREE_H 18 19 #include <map> 20 21 #include "accessibility_element_info.h" 22 #include "wukong_define.h" 23 #include "wukong_tree.h" 24 25 namespace OHOS { 26 namespace WuKong { 27 class ComponentTree : public WuKongTree { 28 public: ComponentTree()29 ComponentTree() : WuKongTree(), expectedInputCount_(0) 30 { 31 type_.clear(); 32 inputTypeCountMap_.clear(); 33 } ~ComponentTree()34 virtual ~ComponentTree() 35 { 36 } 37 GetType()38 const std::string& GetType() 39 { 40 return type_; 41 } 42 IsVisible()43 bool IsVisible() 44 { 45 return isVisible_; 46 } 47 GetPosition()48 OHOS::Accessibility::Rect GetPosition() 49 { 50 return rect_; 51 } 52 53 private: 54 friend class TreeManager; 55 virtual bool SetNodeId() override; 56 virtual bool RecursUpdateInfo(const std::shared_ptr<ComponentTree>& source); AddTypeInputCount(uint32_t type)57 void AddTypeInputCount(uint32_t type) 58 { 59 auto it = inputTypeCountMap_.find(type); 60 if (it != inputTypeCountMap_.end()) { 61 it->second++; 62 } else { 63 inputTypeCountMap_[type] = 1; 64 } 65 } 66 OHOS::Accessibility::Rect rect_ {}; 67 bool isVisible_ = false; 68 std::string type_; 69 uint32_t expectedInputCount_; 70 std::map<uint32_t, uint32_t> inputTypeCountMap_; 71 }; 72 } // namespace WuKong 73 } // namespace OHOS 74 #endif // TEST_WUKONG_COMPONENT_TREE_H 75