• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "mock_accessibility_element_operator_proxy.h"
17 #include <cstdio>
18 #include <gtest/gtest.h>
19 #include "hilog_wrapper.h"
20 #include "iremote_object.h"
21 #include "ipc_types.h"
22 
23 namespace OHOS {
24 namespace Accessibility {
MockAccessibilityElementOperatorProxy(const sptr<IRemoteObject> & object)25 MockAccessibilityElementOperatorProxy::MockAccessibilityElementOperatorProxy(const sptr<IRemoteObject>& object)
26     : IRemoteProxy<IAccessibilityElementOperator>(object)
27 {
28     GTEST_LOG_(INFO) << "MockAccessibilityElementOperatorProxy";
29 }
30 
WriteInterfaceToken(MessageParcel & data)31 bool MockAccessibilityElementOperatorProxy::WriteInterfaceToken(MessageParcel& data)
32 {
33     return true;
34 }
35 
SearchElementInfoByAccessibilityId(const int64_t elementId,const int32_t requestId,const sptr<IAccessibilityElementOperatorCallback> & callback,const int32_t mode)36 void MockAccessibilityElementOperatorProxy::SearchElementInfoByAccessibilityId(const int64_t elementId,
37     const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback>& callback, const int32_t mode)
38 {
39     GTEST_LOG_(INFO) << "MockAccessibilityElementOperatorProxy SearchElementInfoByAccessibilityId";
40     testElementId_ = elementId;
41     testChannelElementId_ = elementId;
42     testChannelRequestId_ = requestId;
43     testChannelMode_ = mode;
44     return;
45 }
46 
SearchElementInfosByText(const int64_t elementId,const std::string & text,const int32_t requestId,const sptr<IAccessibilityElementOperatorCallback> & callback)47 void MockAccessibilityElementOperatorProxy::SearchElementInfosByText(const int64_t elementId, const std::string& text,
48     const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback>& callback)
49 {
50     GTEST_LOG_(INFO) << "MockAccessibilityElementOperatorProxy SearchElementInfosByText";
51     testElementId_ = elementId;
52     testChannelElementId_ = elementId;
53     testText_ = text;
54     testChannelRequestId_ = requestId;
55     return;
56 }
57 
FindFocusedElementInfo(const int64_t elementId,const int32_t focusType,const int32_t requestId,const sptr<IAccessibilityElementOperatorCallback> & callback)58 void MockAccessibilityElementOperatorProxy::FindFocusedElementInfo(const int64_t elementId, const int32_t focusType,
59     const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback>& callback)
60 {
61     GTEST_LOG_(INFO) << "MockAccessibilityElementOperatorProxy FindFocusedElementInfo";
62     testElementId_ = elementId;
63     testChannelElementId_ = elementId;
64     testFocusType_ = focusType;
65     testChannelRequestId_ = requestId;
66     return;
67 }
68 
FocusMoveSearch(const int64_t elementId,const int32_t direction,const int32_t requestId,const sptr<IAccessibilityElementOperatorCallback> & callback)69 void MockAccessibilityElementOperatorProxy::FocusMoveSearch(const int64_t elementId, const int32_t direction,
70     const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback>& callback)
71 {
72     GTEST_LOG_(INFO) << "MockAccessibilityElementOperatorProxy FocusMoveSearch";
73     testElementId_ = elementId;
74     testChannelElementId_ = elementId;
75     testDirection_ = direction;
76     testChannelRequestId_ = requestId;
77     return;
78 }
79 
ExecuteAction(const int64_t elementId,const int32_t action,const std::map<std::string,std::string> & actionArguments,const int32_t requestId,const sptr<IAccessibilityElementOperatorCallback> & callback)80 void MockAccessibilityElementOperatorProxy::ExecuteAction(const int64_t elementId, const int32_t action,
81     const std::map<std::string, std::string> &actionArguments, const int32_t requestId,
82     const sptr<IAccessibilityElementOperatorCallback>& callback)
83 {
84     GTEST_LOG_(INFO) << "MockAccessibilityElementOperatorProxy ExecuteAction";
85     testElementId_ = elementId;
86     testChannelElementId_ = elementId;
87     testActionArguments_ = actionArguments;
88     testChannelRequestId_ = requestId;
89     testAction_ = action;
90     return;
91 }
92 
ClearFocus()93 void MockAccessibilityElementOperatorProxy::ClearFocus()
94 {
95     GTEST_LOG_(INFO) << "MockAccessibilityElementOperatorProxy ClearFocus";
96     testClearFocus_ = 1;
97     return;
98 }
99 
OutsideTouch()100 void MockAccessibilityElementOperatorProxy::OutsideTouch()
101 {
102     GTEST_LOG_(INFO) << "MockAccessibilityElementOperatorProxy OutsideTouch";
103     testOutsideTouch_ = 1;
104     return;
105 }
106 } // namespace Accessibility
107 } // namespace OHOS