• 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 <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     AccessibilityHelper::GetInstance().SetTestWindowId(eventInfo.GetWindowId());
52     AccessibilityHelper::GetInstance().SetTestWindowChangeTypes(eventInfo.GetWindowChangeTypes());
53     AccessibilityHelper::GetInstance().SetTestEventType(int32_t(eventInfo.GetEventType()));
54     AccessibilityHelper::GetInstance().SetGestureId(int32_t(eventInfo.GetGestureType()));
55 
56     switch (eventInfo.GetEventType()) {
57         case TYPE_TOUCH_GUIDE_GESTURE_BEGIN:
58         case TYPE_TOUCH_GUIDE_GESTURE_END:
59         case TYPE_TOUCH_GUIDE_BEGIN:
60         case TYPE_TOUCH_GUIDE_END:
61         case TYPE_TOUCH_BEGIN:
62         case TYPE_TOUCH_END:
63             break;
64         default:
65             return;
66     }
67     AccessibilityHelper::GetInstance().PushEventType(eventInfo.GetEventType());
68 }
69 
OnKeyPressEvent(const MMI::KeyEvent & keyEvent,const int32_t sequence)70 void AccessibleAbilityClientProxy::OnKeyPressEvent(const MMI::KeyEvent& keyEvent, const int32_t sequence)
71 {
72     MessageParcel data;
73     MessageParcel reply;
74     HILOG_DEBUG();
75     HILOG_DEBUG("start.----------sequence--%{public}d ----------mock Proxy Start ", sequence);
76     AccessibilityHelper::GetInstance().SetTestKeyPressEvent(sequence);
77     HILOG_DEBUG("start.-----------------------------mock Proxy end ");
78 }
79 } // namespace Accessibility
80 } // namespace OHOS