• 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 #ifndef ACCESSIBILITY_UI_TEST_ABILITY_IMPL_H
17 #define ACCESSIBILITY_UI_TEST_ABILITY_IMPL_H
18 
19 #include "accessibility_extension_context.h"
20 #include "accessibility_ui_test_ability.h"
21 #include "accessible_ability_client_stub_impl.h"
22 #include "accessible_ability_manager_service_proxy.h"
23 
24 namespace OHOS {
25 namespace Accessibility {
26 class AccessibilityUITestAbilityImpl final : public AccessibilityUITestAbility {
27 public:
28     /**
29      * @brief Construct
30      * @param
31      * @return
32      */
33     AccessibilityUITestAbilityImpl();
34 
35     /**
36      * @brief Destruct
37      * @param
38      * @return
39      */
40     ~AccessibilityUITestAbilityImpl() = default;
41 
42     /**
43      * @brief RegisterListener
44      * @param
45      * @return
46      */
47     virtual bool RegisterListener(const std::shared_ptr<IAccessibleUITestAbilityListener> &listener) override;
48 
49     /**
50      * @brief Connect to AAMS.
51      * @param
52      * @return
53      */
54     virtual bool Connect() override;
55 
56     /**
57      * @brief disconnect to AAMS.
58      * @param
59      * @return
60      */
61     virtual bool Disconnect() override;
62 
63     /**
64      * @brief Obtains elementInfo of focus.
65      * @param focusType The type of focus. It contains FOCUS_TYPE_INPUT and FOCUS_TYPE_ACCESSIBILITY.
66      * @param elementInfo The accessibilityElementInfo of focus.
67      * @return Return true if obtains elementInfo successfully, else return false.
68      */
69     virtual bool GetFocusElementInfo(uint32_t focusType, std::optional<AccessibilityElementInfo> &elementInfo) override;
70 
71     /**
72      * @brief Obtains elementInfo of the accessible root node.
73      * @param elementInfo The elementInfo of the accessible root node.
74      * @return Return true if obtains elementInfo successfully, else return false.
75      */
76     virtual bool GetRootElementInfo(std::optional<AccessibilityElementInfo> &elementInfo) override;
77 
78     /**
79      * @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
80      * @param
81      * @return The information of windows.
82      */
83     virtual std::vector<AccessibilityWindowInfo> GetWindows() override;
84 
85     /**
86      * @brief Executes a specified action.
87      * @param action The action of OHOS::Accessibility::UiTestGlobalAction.
88      * @return Return true if executes action successfully, else return false.
89      */
90     virtual bool ExecuteCommonAction(UiTestGlobalAction action) override;
91 
92     /**
93      * @brief Dispatch the result of simulation gesture.
94      * @param sequence The sequence of gesture.
95      * @param result The result of gesture completion.
96      * @return
97      */
98     virtual void DispatchOnSimulationGestureResult(uint32_t sequence, bool result) override;
99 
100     /**
101      * @brief Set channelId.
102      * @param channelId The id of channel.
103      * @return
104      */
105     virtual void SetChannelId(uint32_t channelId) override;
106 
107 private:
108     sptr<AccessibleAbilityClientStubImpl> stub_ = nullptr;
109     sptr<AccessibleAbilityManagerServiceClientProxy> serviceProxy_ = nullptr;
110     std::shared_ptr<AccessibilityExtensionContext> extensionContext_ = nullptr;
111 };
112 } // namespace Accessibility
113 } // namespace OHOS
114 #endif  // ACCESSIBILITY_UI_TEST_ABILITY_IMPL_H