libaurum: apply smart pointer wider and extract impl out
[platform/core/uifw/aurum.git] / libaurum / src / Impl / Accessibility / MockAccessibleNode.cc
1 #include "MockAccessibleNode.h"
2
3 #include <algorithm>
4
5 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, Rect<int> boundingBox, int supportingIfaces,int featureProperty)
6 : mParentNode(parent), mChildrenList{}, mActionSet{}
7 {
8     printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
9     setProperties(text,pkg,role,res,type,style,boundingBox, supportingIfaces, featureProperty);
10 }
11
12 MockAccessibleNode::~MockAccessibleNode()
13 {
14     printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
15 }
16
17 int MockAccessibleNode::getChildCount() const
18 {
19     printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
20     return mChildrenList.size();
21 }
22
23 std::shared_ptr<AccessibleNode> MockAccessibleNode::getChildAt(int index) const
24 {
25     printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
26     return mChildrenList.at(index);
27 }
28 std::vector<std::shared_ptr<AccessibleNode>> MockAccessibleNode::getChildren() const
29 {
30     printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
31     return mChildrenList;
32 }
33
34 std::shared_ptr<AccessibleNode> MockAccessibleNode::getParent() const
35 {
36     printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
37     return mParentNode;
38 }
39
40 void* MockAccessibleNode::getRawHandler(void) const
41 {
42     printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
43     return (void*)0;
44 }
45
46 void MockAccessibleNode::setProperties(std::string text,std::string pkg,std::string role,std::string res,std::string type,std::string style,Rect<int> boundingBox,int supportingIfaces,int featureProperty)
47 {
48     mText = text;
49     mPkg = pkg;
50     mRole = role;
51     mRes = res;
52     mType = type;
53     mStyle = style;
54     mBoundingBox = boundingBox;
55     mSupportingIfaces = supportingIfaces;
56     mFeatureProperty = featureProperty;
57 }
58
59 void MockAccessibleNode::refresh()
60 {
61     printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
62 }
63
64 std::vector<std::string> MockAccessibleNode::getActions() const
65 {
66     printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
67     std::vector<std::string> ret{};
68     std::transform(mActionSet.begin(), mActionSet.end(), std::back_inserter(ret), [](auto action){
69         return action;
70     });
71     return ret;
72 }
73
74 bool MockAccessibleNode::doAction(std::string action)
75 {
76     printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
77     if (mActionSet.find(action) != mActionSet.end()) return true;
78     return false;
79 }
80
81 void MockAccessibleNode::setValue(std::string text)
82 {
83     printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
84     mText = text;
85 }
86
87 void MockAccessibleNode::setFeatureProperty(int type)
88 {
89     printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
90     switch(type) {
91         case 1:
92             setFeatureProperty(NodeFeatureProperties::CHECKED, true);
93             break;
94         case 2:
95             setFeatureProperty(NodeFeatureProperties::CHECKABLE, true);
96             break;
97         case 3:
98             setFeatureProperty(NodeFeatureProperties::ENABLED, true);
99             break;
100         case 4:
101             setFeatureProperty(NodeFeatureProperties::FOCUSABLE, true);
102             break;
103         case 5:
104             setFeatureProperty(NodeFeatureProperties::FOCUSED, true);
105             break;
106         case 6:
107             setFeatureProperty(NodeFeatureProperties::SELECTABLE, true);
108             break;
109         case 7:
110             setFeatureProperty(NodeFeatureProperties::SELECTED, true);
111             break;
112         case 8:
113             setFeatureProperty(NodeFeatureProperties::SHOWING, true);
114             break;
115         case 9:
116             setFeatureProperty(NodeFeatureProperties::VISIBLE, true);
117             break;
118         case 10:
119             setFeatureProperty(NodeFeatureProperties::ACTIVE, true);
120             break;
121         case 11:
122             setFeatureProperty(NodeFeatureProperties::CLICKABLE, true);
123             break;
124         case 12:
125         case 13:
126             setFeatureProperty(NodeFeatureProperties::INVALID, true);
127             break;
128     }
129 }
130
131 void MockAccessibleNode::addChild(std::shared_ptr<AccessibleNode> child)
132 {
133     mChildrenList.push_back(child);
134 }
135
136 void MockAccessibleNode::clearChildren(void)
137 {
138     mChildrenList.clear();
139 }
140
141 void MockAccessibleNode::addAction(std::string action)
142 {
143     mActionSet.insert(action);
144 }
145
146 void MockAccessibleNode::clearActions(void)
147 {
148     mActionSet.clear();
149 }