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 <gtest/gtest.h>
17 #include "accessibility_account_data.h"
18 #include "accessibility_event_info.h"
19 #include "accessibility_mt_helper.h"
20 #include "accessible_ability_channel_stub.h"
21 #include "accessible_ability_client_proxy.h"
22 #include "accessible_ability_connection.h"
23 #include "accessible_ability_manager_service.h"
24 #include "hilog_wrapper.h"
25 #include "parcel.h"
26
27 namespace OHOS {
28 namespace Accessibility {
AccessibleAbilityClientProxy(const sptr<IRemoteObject> & remoteObj)29 AccessibleAbilityClientProxy::AccessibleAbilityClientProxy(const sptr<IRemoteObject>& remoteObj)
30 : IRemoteProxy<IAccessibleAbilityClient>(remoteObj)
31 {}
32
WriteInterfaceToken(MessageParcel & data)33 bool AccessibleAbilityClientProxy::WriteInterfaceToken(MessageParcel& data)
34 {
35 return true;
36 }
37
Init(const sptr<IAccessibleAbilityChannel> & channel,const int32_t channelId)38 void AccessibleAbilityClientProxy::Init(const sptr<IAccessibleAbilityChannel>& channel, const int32_t channelId)
39 {
40 GTEST_LOG_(INFO) << "AccessibleAbilityClientProxy Init";
41 AccessibilityHelper::GetInstance().SetTestStub(channel);
42 AccessibilityHelper::GetInstance().SetTestChannalId(channelId);
43 }
44
Disconnect(const int32_t channelId)45 void AccessibleAbilityClientProxy::Disconnect(const int32_t channelId)
46 {}
47
OnAccessibilityEvent(const AccessibilityEventInfo & eventInfo)48 void AccessibleAbilityClientProxy::OnAccessibilityEvent(const AccessibilityEventInfo& eventInfo)
49 {
50 GTEST_LOG_(INFO) << "AccessibleAbilityClientProxy OnAccessibilityEvent";
51 int32_t gestureId = static_cast<int32_t>(eventInfo.GetGestureType());
52 if (gestureId != 0) {
53 AccessibilityHelper::GetInstance().SetGestureId(gestureId);
54 }
55 AccessibilityHelper::GetInstance().SetTestWindowId(eventInfo.GetWindowId());
56 AccessibilityHelper::GetInstance().SetTestWindowChangeTypes(eventInfo.GetWindowChangeTypes());
57 AccessibilityHelper::GetInstance().SetTestEventType(int32_t(eventInfo.GetEventType()));
58
59 switch (eventInfo.GetEventType()) {
60 case TYPE_TOUCH_GUIDE_GESTURE_BEGIN:
61 case TYPE_TOUCH_GUIDE_GESTURE_END:
62 case TYPE_TOUCH_GUIDE_BEGIN:
63 case TYPE_TOUCH_GUIDE_END:
64 case TYPE_TOUCH_BEGIN:
65 case TYPE_TOUCH_END:
66 break;
67 default:
68 return;
69 }
70 AccessibilityHelper::GetInstance().PushEventType(eventInfo.GetEventType());
71 }
72
OnKeyPressEvent(const MMI::KeyEvent & keyEvent,const int32_t sequence)73 void AccessibleAbilityClientProxy::OnKeyPressEvent(const MMI::KeyEvent& keyEvent, const int32_t sequence)
74 {
75 MessageParcel data;
76 MessageParcel reply;
77 HILOG_DEBUG();
78 HILOG_DEBUG("start.----------sequence--%{public}d ----------mock Proxy Start ", sequence);
79 AccessibilityHelper::GetInstance().SetTestKeyPressEvent(sequence);
80 HILOG_DEBUG("start.-----------------------------mock Proxy end ");
81 }
82 } // namespace Accessibility
83 } // namespace OHOS