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 MOCK_ACCESSIBILITY_ELEMENT_OPERATOR_PROXY_H 17 #define MOCK_ACCESSIBILITY_ELEMENT_OPERATOR_PROXY_H 18 19 #include "accessibility_ipc_interface_code.h" 20 #include "iaccessibility_element_operator.h" 21 #include "iremote_proxy.h" 22 23 namespace OHOS { 24 namespace Accessibility { 25 /* 26 * The class define the interface for UI to implement. 27 * It triggered by ABMS when AA to request the accessibility information. 28 */ 29 class MockAccessibilityElementOperatorProxy : public IRemoteProxy<IAccessibilityElementOperator> { 30 public: 31 /** 32 * @brief construct function 33 * @param object The object of IPC 34 */ 35 explicit MockAccessibilityElementOperatorProxy(const sptr<IRemoteObject>& object); 36 37 /** 38 * @brief destruct function 39 */ 40 virtual ~MockAccessibilityElementOperatorProxy() = default; 41 42 /** 43 * @brief Make the node information by accessibility ID and set the result by callback. 44 * @param elementId: The unique id of the component ID. 45 * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only. 46 * @param callback To transfer the node info to ASAC and it defined by ASAC. 47 * @param mode PREFETCH_PREDECESSORS: Need to make the parent node info also. 48 * PREFETCH_SIBLINGS: Need to make the sister/brothers node info also. 49 * PREFETCH_CHILDREN: Need to make the child node info also. 50 * otherwise: Make the node information by elementId only. 51 * @sysCap Accessibility 52 */ 53 RetError SearchElementInfoByAccessibilityId(const int64_t elementId, const int32_t requestId, 54 const sptr<IAccessibilityElementOperatorCallback>& callback, const int32_t mode, bool isFilter) override; 55 56 /** 57 * @brief Make the node information by window ID and set the result by callback. 58 * @param window: The window id. 59 * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only. 60 * @param callback To transfer the node info to ASAC and it defined by ASAC. 61 * @param mode PREFETCH_PREDECESSORS: Need to make the parent node info also. 62 * PREFETCH_SIBLINGS: Need to make the sister/brothers node info also. 63 * PREFETCH_CHILDREN: Need to make the child node info also. 64 * otherwise: Make the node information by elementId only. 65 * @sysCap Accessibility 66 */ 67 void SearchDefaultFocusedByWindowId(const int32_t windowId, const int32_t requestId, 68 const sptr<IAccessibilityElementOperatorCallback>& callback, const int32_t mode, bool isFilter) override; 69 70 /** 71 * @brief Make the child node information by accessibility ID and filtered by text and set the result by callback. 72 * @param elementId: The unique id of the component ID. 73 * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only. 74 * @param callback To transfer the node info to ASAC and it defined by ASAC. 75 * @param text Filter for the child components to matched with the text 76 */ 77 void SearchElementInfosByText(const int64_t elementId, const std::string& text, const int32_t requestId, 78 const sptr<IAccessibilityElementOperatorCallback>& callback) override; 79 80 /** 81 * @brief Make the node information of the component focused by the focus type specified. 82 * @param elementId: The unique id of the component ID. 83 * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only. 84 * @param callback To transfer the node info to ASAC and it defined by ASAC. 85 * @param focusType FOCUS_TYPE_ACCESSIBILITY: accessibility focus 86 * FOCUS_TYPE_INPUT: text input focus 87 */ 88 void FindFocusedElementInfo(const int64_t elementId, const int32_t focusType, const int32_t requestId, 89 const sptr<IAccessibilityElementOperatorCallback>& callback) override; 90 91 /** 92 * @brief Make the node info by current focus move direction. 93 * @param elementId: The unique id of the component ID. 94 * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only. 95 * @param callback To transfer the node info to ASAC and it defined by ASAC. 96 * @param direction Refer to AccessibilityElementInfo.FocusMoveDirection(UP/DOWN/LEFT/RIGHT/FORWARD/BACKWARD) 97 */ 98 void FocusMoveSearch(const int64_t elementId, const int32_t direction, const int32_t requestId, 99 const sptr<IAccessibilityElementOperatorCallback>& callback) override; 100 101 /** 102 * @brief To return the result of perform action. 103 * @param elementId: The unique id of the component ID. 104 * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only. 105 * @param callback To transfer the node info to ASAC and it defined by ASAC. 106 * @param action Refer to [AccessibilityElementInfo.ActionType] 107 * @param actionArguments The parameter for action type. such as: 108 * action: ACCESSIBILITY_ACTION_NEXT_HTML_ITEM, 109 * actionArguments(ACTION_ARGU_HTML_ELEMENT,HtmlItemType) 110 * action: ACCESSIBILITY_ACTION_PREVIOUS_HTML_ITEM, 111 * actionArguments(ACTION_ARGU_HTML_ELEMENT,HtmlItemType) 112 * action: ACCESSIBILITY_ACTION_NEXT_TEXT, 113 * actionArguments(ACTION_ARGU_MOVE_UNIT,MOVE_UNIT_XXX) 114 * action: ACCESSIBILITY_ACTION_PREVIOUS_TEXT, 115 * actionArguments(ACTION_ARGU_MOVE_UNIT,MOVE_UNIT_XXX) 116 * action: ACCESSIBILITY_ACTION_SET_SELECTION, 117 * actionArguments({ACTION_ARGU_SELECT_TEXT_START,"1"(start location)}, 118 * {ACTION_ARGU_SELECT_TEXT_END,"10"(end location)}) 119 * action: ACCESSIBILITY_ACTION_SET_TEXT, 120 * actionArguments(ACTION_ARGU_SET_TEXT,"the text of setted") 121 */ 122 void ExecuteAction(const int64_t elementId, const int32_t action, 123 const std::map<std::string, std::string> &actionArguments, int32_t requestId, 124 const sptr<IAccessibilityElementOperatorCallback>& callback) override; 125 126 /** 127 * @brief To return the result of cursor position. 128 * @param elementId: The unique id of the component ID. 129 * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only. 130 * @param callback To transfer the node info to ASAC and it defined by ASAC. 131 **/ 132 void GetCursorPosition(const int64_t elementId, int32_t requestId, 133 const sptr<IAccessibilityElementOperatorCallback>& callback) override; 134 135 /** 136 * @brief Search element information by specific property. 137 * @param elementId: The unique id of the component ID. 138 * @param param The specific property parameters. 139 * @param requestId Matched the request and response. It needn't cared by ACE, transfer it by callback only. 140 * @param callback To transfer the node info to ASAC and it defined by ASAC. 141 */ 142 void SearchElementInfoBySpecificProperty(const int64_t elementId, 143 const SpecificPropertyParam& param, const int32_t requestId, 144 const sptr<IAccessibilityElementOperatorCallback>& callback) override; 145 146 /** 147 * @brief The function is called while accessibility System check the id of window is not equal 148 * to the id of active window when sendAccessibility. 149 */ 150 void ClearFocus() override; 151 152 /** 153 * @brief the low layer is notified by the function called while accessibility system execute 154 * the function of executeAction from AS to check the all low windows cared the outside event. 155 * Example: PopupWindow receive the OUTSIDE_EVENT to close itself. 156 */ 157 void OutsideTouch() override; 158 159 /** 160 * @brief To return the result of elementId, treeId, childWindowId. 161 * @param elementId: The element Id. 162 * @param treeId: The tree Id. 163 * @param childWindowId The childwindow Id. 164 */ 165 void SetChildTreeIdAndWinId(const int64_t elementId, const int32_t treeId, const int32_t childWindowId) override; 166 167 /** 168 * @brief To return the result of treeId 169 * @param treeId: The tree Id. 170 */ 171 void SetBelongTreeId(const int32_t treeId) override; 172 173 /** 174 * @brief To return the result of parentWindowId 175 * @param parentWindowId: The parentWindow Id. 176 */ 177 void SetParentWindowId(const int32_t parentWindowId) override; 178 179 int64_t testElementId_ = -1; 180 int32_t testClearFocus_ = -1; 181 int32_t testOutsideTouch_ = -1; 182 183 int64_t testChannelElementId_ = -1; 184 int32_t testChannelRequestId_ = -1; 185 int32_t testChannelMode_ = -1; 186 std::string testText_ = ""; 187 int32_t testFocusType_ = 0; 188 int32_t testDirection_ = 0; 189 int32_t testAction_ = 0; 190 int32_t testTreeId_ = -1; 191 int32_t testChildWindowId_ = -1; 192 int32_t testParentWindowId_ = -1; 193 std::map<std::string, std::string> testActionArguments_; 194 195 bool isFilter_ = false; 196 197 private: 198 /** 199 * @brief Write the descriptor of IPC. 200 * @param data It is include the descriptor of IPC. 201 * @return true: Write the descriptor successfully; otherwise is not. 202 */ 203 bool WriteInterfaceToken(MessageParcel& data); 204 205 /** 206 * @brief Send the command data from proxy to stub in IPC mechanism. 207 * @param code The code matched the function called. 208 * @param data Serializable data 209 * @param reply The response of IPC 210 * @param option The option parameter of IPC,such as: async,sync 211 * @return true: Write the descriptor successfully; otherwise is not. 212 */ 213 bool SendTransactCmd( 214 AccessibilityInterfaceCode code, MessageParcel& data, MessageParcel& reply, MessageOption& option); 215 static inline BrokerDelegator<MockAccessibilityElementOperatorProxy> delegator; 216 }; 217 } // namespace Accessibility 218 } // namespace OHOS 219 #endif // MOCK_ACCESSIBILITY_ELEMENT_OPERATOR_PROXY_H