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"
24 #include "ISearchable.h"
25 #include "UiSelector.h"
36 * @brief This class keep object's descendant tree.
38 class Node : public std::enable_shared_from_this<Node> {
40 Node(std::shared_ptr<UiObject> node, std::vector<std::shared_ptr<Node>> children)
41 :mNode{node}, mChildren{children}{}
43 std::shared_ptr<UiObject> mNode;
44 std::vector<std::shared_ptr<Node>> mChildren;
52 * @brief A UiObject is a representation of a actual object in view.
53 * As a class that abstracts the actual object, it has the information of the object
54 * such as object's properties, states, geometry information.
55 * also user can send and receive event via this class.
57 class UiObject : public ISearchable , public std::enable_shared_from_this<UiObject> {
60 * @brief UiObject constructor with device, selector, node pointer.
64 UiObject(const std::shared_ptr<UiDevice> device, const std::shared_ptr<UiSelector> selector,
65 const AccessibleNode *node);
68 * @brief UiObject constructor with device, selector, node.
72 UiObject(const std::shared_ptr<UiDevice> device, const std::shared_ptr<UiSelector> selector,
73 std::shared_ptr<AccessibleNode> node);
76 * @brief UiObject constructor with object source.
80 UiObject(UiObject &&src);
83 * @brief UiObject constructor. (default constructor)
90 * @brief UiObject destructor.
97 * @brief Gets selector.
99 * @return UiSelector pointer
103 std::shared_ptr<UiSelector> getSelector();
106 * @brief Checks that there is object that satisfied with the selector condition in the object tree.
108 * @param[in] selector @UiSelector
110 * @return true if object exist, otherwise false
114 bool hasObject(const std::shared_ptr<UiSelector> selector) const override;
117 * @brief Finds that object that satisfied with the selector condition in the object tree.
119 * @param[in] selector @UiSelector
121 * @return Found UiObject pointer
125 std::shared_ptr<UiObject> findObject(
126 const std::shared_ptr<UiSelector> selector) const override;
129 * @brief Finds that objects that satisfied with the selector condition in the object tree.
131 * @param[in] selector @UiSelector
133 * @return the list of found UiObject pointer vector
137 std::vector<std::shared_ptr<UiObject>> findObjects(
138 const std::shared_ptr<UiSelector> selector) const override;
144 const std::function<bool(const ISearchable *)> condition) const;
149 std::shared_ptr<UiObject> waitFor(
150 const std::function<std::shared_ptr<UiObject>(const ISearchable *)>
156 bool waitFor(const std::function<bool(const UiObject *)> condition) const;
160 * @brief Gets object's parent.
162 * @return UiObject pointer
166 UiObject *getParent() const;
169 * @brief Gets object's child count.
171 * @return number of child
175 int getChildCount() const;
178 * @brief Gets object's children.
180 * @return UiObject pointer vector
184 std::vector<std::shared_ptr<UiObject>> getChildren() const;
187 * @brief Gets object's child at specific index.
189 * @return UiObject pointer
193 std::shared_ptr<UiObject> getChildAt(int index) const;
196 * @brief Gets object's Descendant tree .
198 * @return Node pointer vector
202 std::shared_ptr<Node> getDescendant();
205 * @brief Gets object's package name.
211 std::string getApplicationPackage() const;
214 * @brief Gets object's Id.
220 std::string getId() const;
223 * @brief Gets object's automation Id.
229 std::string getAutomationId() const;
232 * @brief Gets object's type.
238 std::string getElementType() const;
241 * @brief Gets object's style.
247 std::string getElementStyle() const;
250 * @brief Gets object's text.
256 std::string getText() const;
259 * @brief Gets object's role.
265 std::string getRole() const;
268 * @brief Sets object's text.
270 * @param[in] text string
272 * @return true if success else false
276 bool setText(std::string text);
279 * @brief Gets object's geometry of the screen.
285 const Rect<int> getScreenBoundingBox() const;
288 * @brief Gets object's geometry of the window.
294 const Rect<int> getWindowBoundingBox() const;
297 * @brief Gets object's checkable property.
299 * @return true if checkable else false
303 bool isCheckable() const;
306 * @brief Gets object's checked property.
308 * @return true if checked else false
312 bool isChecked() const;
315 * @brief Gets object's clickable property.
317 * @return true if clickable else false
321 bool isClickable() const;
324 * @brief Gets object's enabled property. (to get object enabled. disabled state)
326 * @return true if enabled else false
330 bool isEnabled() const;
333 * @brief Gets object's focusable property.
335 * @return true if focusable else false
339 bool isFocusable() const;
342 * @brief Gets object's focused property.
344 * @return true if focused else false
348 bool isFocused() const;
351 * @brief Gets object's longclickable property.
353 * @return true if longclickable else false
357 bool isLongClickable() const;
360 * @brief Gets object's scrollable property.
362 * @return true if scrollable else false
366 bool isScrollable() const;
369 * @brief Gets object's selectable property.
371 * @return true if selectable else false
375 bool isSelectable() const;
378 * @brief Gets object's selected property.
380 * @return true if selected else false
384 bool isSelected() const;
387 * @brief Gets object's visible property.
389 * @return true if visible else false
393 bool isVisible() const;
396 * @brief Gets object's showing property.
398 * @return true if showing else false
402 bool isShowing() const;
405 * @brief Gets object's active property.
407 * @return true if active else false
411 bool isActive() const;
414 * @brief Performs a click action on object.
421 * @brief Performs a long click action on object.
423 * @param[in] durationMs total time to maintain down action (default = 500ms)
427 void longClick(const unsigned int durationMs = LOGNCLICK_INTERVAL) const;
432 bool DoAtspiActivate() const;
435 * @brief Updates object's role name information from atspi server.
439 void updateRoleName() const;
442 * @brief Updates object's Id information from atspi server.
446 void updateUniqueId() const;
449 * @brief Updates object's name information from atspi server.
453 void updateName() const;
456 * @brief Updates object's application name information from atspi server.
460 void updateApplication() const;
463 * @brief Updates object's attributes information from atspi server.
467 void updateAttributes() const;
470 * @brief Updates object's states information from atspi server.
474 void updateStates() const;
477 * @brief Updates object's geometry information from atspi server.
481 void updateExtents() const;
484 * @brief Updates object's XPath information.
488 void updateXPath() const;
491 * @brief Sets focus to object.
495 bool setFocus() const;
498 * @brief Updates object's information from atspi server.
502 void refresh() const;
505 * @brief Checks object is valid or not.
507 * @return true if valid else false
511 bool isValid() const;
514 * @brief Gets object's AccessibleNode class
516 * @return AccessibleNode pointer
520 std::shared_ptr<AccessibleNode> getAccessibleNode() const;
523 std::shared_ptr<UiDevice> mDevice;
524 std::shared_ptr<UiSelector> mSelector;
525 std::shared_ptr<AccessibleNode> mNode;
526 const Waiter *mWaiter;
527 static const unsigned int LOGNCLICK_INTERVAL = 500;