2 * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #include "Accessible.h"
25 #include "UiSelector.h"
27 #include "PartialMatch.h"
40 * @brief Class that traverses the object tree and finds an object that match the given condition.
45 * @brief Comparer constructor with device, selector, early return flag.
47 * @param[in] device @UiDevice
48 * @param[in] selector @UiSelector
49 * @param[in] earlyReturn flag for early return
53 Comparer(const std::shared_ptr<UiDevice>& device, const std::shared_ptr<UiSelector>& selector,
54 const bool &earlyReturn);
57 * @brief Comparer destructor.
65 * @brief find object from device.
66 * it finds focused window then start to find object as it root.
68 * @param[in] device @UiDevice
69 * @param[in] selector @UiSelector
70 * @param[in] root @AccessibleNode root object(focused window on current state)
72 * @return AccessibleNode if found, else nullptr
76 static std::shared_ptr<AccessibleNode> findObject(const std::shared_ptr<UiDevice>& device,
77 const std::shared_ptr<UiSelector>& selector,
78 const std::shared_ptr<AccessibleNode>& root);
81 * @brief find object from device.
82 * it finds focused window then start to find object as it root.
83 * Finds all objects to the end of tree.
85 * @param[in] ret vector where found objects stored
86 * @param[in] device @UiDevice
87 * @param[in] selector @UiSelector
88 * @param[in] root @AccessibleNode root object(focused window on current state)
89 * @param[in] earlyReturn find all object or not (default = false)
94 static void findObjects(std::vector<std::shared_ptr<AccessibleNode>> &ret,
95 const std::shared_ptr<UiDevice>& device, const std::shared_ptr<UiSelector>& selector,
96 const std::shared_ptr<AccessibleNode>& root, bool earlyReturn = false);
102 * @brief Starts find object from root.
104 * @param[in] ret vector where found objects stored
105 * @param[in] root @AccessibleNode
109 void findObjects(std::vector<std::shared_ptr<AccessibleNode>> &ret,
110 const std::shared_ptr<AccessibleNode>& root);
115 * @brief It updates all partialMatches and traverse tree till given depth to find objects
117 * @param[in] ret vector where found objects stored
118 * @param[in] root @AccessibleNode
119 * @param[in] index node index
120 * @param[in] depth tree depth
121 * @param[in] partialMatches @PartialMatch list
126 std::vector<std::shared_ptr<AccessibleNode>> &ret,
127 const std::shared_ptr<AccessibleNode>& root, const int &index, const int &depth,
128 std::list<std::shared_ptr<PartialMatch>> &partialMatches);
131 const std::shared_ptr<UiDevice>& mDevice;
132 const std::shared_ptr<UiSelector>& mSelector;