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_ut_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> & object)29 AccessibleAbilityClientProxy::AccessibleAbilityClientProxy(const sptr<IRemoteObject>& object)
30     : IRemoteProxy<IAccessibleAbilityClient>(object)
31 {
32 }
33 
WriteInterfaceToken(MessageParcel & data)34 bool AccessibleAbilityClientProxy::WriteInterfaceToken(MessageParcel& data)
35 {
36     (void)data;
37     return true;
38 }
39 
Init(const sptr<IAccessibleAbilityChannel> & channel,const int32_t channelId)40 void AccessibleAbilityClientProxy::Init(const sptr<IAccessibleAbilityChannel>& channel, const int32_t channelId)
41 {
42     (void)channel;
43     AccessibilityAbilityHelper::GetInstance().SetTestChannelId(channelId);
44 }
45 
Disconnect(const int32_t channelId)46 void AccessibleAbilityClientProxy::Disconnect(const int32_t channelId)
47 {
48     AccessibilityAbilityHelper::GetInstance().SetTestChannelId(channelId);
49 }
50 
OnAccessibilityEvent(const AccessibilityEventInfo & eventInfo)51 void AccessibleAbilityClientProxy::OnAccessibilityEvent(const AccessibilityEventInfo& eventInfo)
52 {
53     GTEST_LOG_(INFO) << "TouchGuider_Unittest_OnTouchEvent OnAccessibilityEvent";
54     AccessibilityAbilityHelper::GetInstance().SetTestEventType(int(eventInfo.GetEventType()));
55     AccessibilityAbilityHelper::GetInstance().SetGestureId(int(eventInfo.GetGestureType()));
56 
57     AccessibilityAbilityHelper::GetInstance().SetEventTypeVector(eventInfo.GetEventType());
58     GTEST_LOG_(INFO) << "AccessibleAbilityClientProxy::OnAccessibilityEvent eventType="
59                      << (int32_t)eventInfo.GetEventType();
60 }
61 
OnKeyPressEvent(const MMI::KeyEvent & keyEvent,const int32_t sequence)62 void AccessibleAbilityClientProxy::OnKeyPressEvent(const MMI::KeyEvent& keyEvent, const int32_t sequence)
63 {
64     (void)keyEvent;
65     MessageParcel data;
66     MessageParcel reply;
67     HILOG_DEBUG();
68     HILOG_DEBUG("start.-----sequence--%{public}d ----------mock Proxy Start ", sequence);
69     AccessibilityAbilityHelper::GetInstance().SetTestKeyPressEvent(sequence);
70     HILOG_DEBUG("start.-----------------------------mock Proxy end ");
71 }
72 } // namespace Accessibility
73 } // namespace OHOS