1 #include "MockAccessibleNode.h"
2 #include "AccessibleWatcher.h"
7 MockAccessibleNode::MockAccessibleNode(std::shared_ptr<AccessibleNode> parent, std::string text, std::string pkg, std::string role, std::string res, std::string type, std::string style,std::string automationId, Rect<int> boundingBox, int supportingIfaces,int featureProperty)
8 : mParentNode(parent), mChildrenList{}, mActionSet{}
10 printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
11 const auto trickDontRemove = std::shared_ptr<MockAccessibleNode>( this, [](MockAccessibleNode *){} );
13 setProperties(text,pkg,role,res,type,style,automationId, boundingBox, supportingIfaces, featureProperty);
14 auto watcher = AccessibleWatcher::getInstance();
15 watcher->attach(shared_from_this());
18 MockAccessibleNode::~MockAccessibleNode()
20 printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
21 auto watcher = AccessibleWatcher::getInstance();
22 watcher->detach(shared_from_this());
25 int MockAccessibleNode::getChildCount() const
27 return mChildrenList.size();
30 std::shared_ptr<AccessibleNode> MockAccessibleNode::getChildAt(int index) const
32 return mChildrenList.at(index);
34 std::vector<std::shared_ptr<AccessibleNode>> MockAccessibleNode::getChildren() const
39 std::shared_ptr<AccessibleNode> MockAccessibleNode::getParent() const
44 void* MockAccessibleNode::getRawHandler(void) const
46 printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
50 void MockAccessibleNode::setProperties(std::string text,std::string pkg,std::string role,std::string id,std::string type,std::string style,std::string automationId, Rect<int> boundingBox,int supportingIfaces,int featureProperty)
56 mAutomationId = automationId;
59 mBoundingBox = boundingBox;
60 mSupportingIfaces = supportingIfaces;
61 mFeatureProperty = featureProperty;
64 void MockAccessibleNode::refresh()
68 std::vector<std::string> MockAccessibleNode::getActions() const
70 std::vector<std::string> ret{};
71 std::transform(mActionSet.begin(), mActionSet.end(), std::back_inserter(ret), [](auto action){
77 bool MockAccessibleNode::doAction(std::string action)
79 if (mActionSet.find(action) != mActionSet.end()) return true;
83 void MockAccessibleNode::setValue(std::string text)
88 void MockAccessibleNode::setFeatureProperty(int type)
92 setFeatureProperty(NodeFeatureProperties::CHECKED, true);
95 setFeatureProperty(NodeFeatureProperties::CHECKABLE, true);
98 setFeatureProperty(NodeFeatureProperties::ENABLED, true);
101 setFeatureProperty(NodeFeatureProperties::FOCUSABLE, true);
104 setFeatureProperty(NodeFeatureProperties::FOCUSED, true);
107 setFeatureProperty(NodeFeatureProperties::SELECTABLE, true);
110 setFeatureProperty(NodeFeatureProperties::SELECTED, true);
113 setFeatureProperty(NodeFeatureProperties::SHOWING, true);
116 setFeatureProperty(NodeFeatureProperties::VISIBLE, true);
119 setFeatureProperty(NodeFeatureProperties::ACTIVE, true);
122 setFeatureProperty(NodeFeatureProperties::CLICKABLE, true);
126 setFeatureProperty(NodeFeatureProperties::INVALID, true);
131 void MockAccessibleNode::addChild(std::shared_ptr<AccessibleNode> child)
133 mChildrenList.push_back(child);
136 std::shared_ptr<MockAccessibleNode> MockAccessibleNode::addChild(std::string text, std::string pkg, std::string role, std::string res, std::string type, std::string style, std::string automationId, Rect<int> geometry, int ifaces, int properties)
138 auto node = std::make_shared<MockAccessibleNode>(shared_from_this(), text, pkg, role, res, type, style, automationId, geometry, ifaces, properties);
139 this->addChild(node);
143 void MockAccessibleNode::clearChildren(void)
145 mChildrenList.clear();
148 void MockAccessibleNode::addAction(std::string action)
150 mActionSet.insert(action);
153 void MockAccessibleNode::clearActions(void)