• 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_H
17 #define ACCESSIBILITY_UI_TEST_ABILITY_H
18 
19 #include <memory>
20 #include "accessibility_element_info.h"
21 #include "accessibility_window_info.h"
22 #include "accessibility_ui_test_ability_listener.h"
23 
24 namespace OHOS {
25 namespace Accessibility {
26 enum UiTestGlobalAction : uint32_t {
27     UI_GLOBAL_ACTION_INVALID = 0x0000,
28     UI_GLOBAL_ACTION_BACK = 0x0001,
29     UI_GLOBAL_ACTION_HOME = 0x0002,
30     UI_GLOBAL_ACTION_RECENT = 0x0003,
31     UI_GLOBAL_ACTION_NOTIFICATION = 0x0004,
32     UI_GLOBAL_ACTION_POP_UP_POWER_DIALOG = 0x0006,
33     UI_GLOBAL_ACTION_DIVIDE_SCREEN = 0x0007,
34     UI_GLOBAL_ACTION_LOCK_SCREEN = 0x0008,
35     UI_GLOBAL_ACTION_CAPTURE_SCREEN = 0x0009
36 };
37 
38 class AccessibilityUITestAbility {
39 public:
40     /**
41      * @brief Destruct
42      * @param
43      * @return
44      */
45     virtual ~AccessibilityUITestAbility() = default;
46 
47     /**
48      * @brief Gets an instance of AccessibleAbility.
49      * @param
50      * @return Return an instance of AccessibleAbility.
51      */
52     static std::shared_ptr<AccessibilityUITestAbility> GetInstance();
53 
54     /**
55      * @brief RegisterListener
56      * @param
57      * @return
58      */
59     virtual bool RegisterListener(const std::shared_ptr<IAccessibleUITestAbilityListener> &listener) = 0;
60 
61     /**
62      * @brief Connect to AAMS.
63      * @param
64      * @return
65      */
66     virtual bool Connect() = 0;
67 
68     /**
69      * @brief disconnect to AAMS.
70      * @param
71      * @return
72      */
73     virtual bool Disconnect() = 0;
74 
75     /**
76      * @brief Obtains elementInfo of focus.
77      * @param focusType The type of focus. It contains FOCUS_TYPE_INPUT and FOCUS_TYPE_ACCESSIBILITY.
78      * @param elementInfo The accessibilityElementInfo of focus.
79      * @return Return true if obtains elementInfo successfully, else return false.
80      */
81     virtual bool GetFocusElementInfo(uint32_t focusType, std::optional<AccessibilityElementInfo> &elementInfo) = 0;
82 
83     /**
84      * @brief Obtains elementInfo of the accessible root node.
85      * @param elementInfo The elementInfo of the accessible root node.
86      * @return Return true if obtains elementInfo successfully, else return false.
87      */
88     virtual bool GetRootElementInfo(std::optional<AccessibilityElementInfo> &elementInfo) = 0;
89 
90     /**
91      * @brief Obtains the list of interactive windows on the device, in the layers they are visible to users.
92      * @param
93      * @return The information of windows.
94      */
95     virtual std::vector<AccessibilityWindowInfo> GetWindows() = 0;
96 
97     /**
98      * @brief Executes a specified action.
99      * @param action The action of OHOS::Accessibility::UiTestGlobalAction.
100      * @return Return true if executes action successfully, else return false.
101      */
102     virtual bool ExecuteCommonAction(UiTestGlobalAction action) = 0;
103 
104     /**
105      * @brief Dispatch the result of simulation gesture.
106      * @param sequence The sequence of gesture.
107      * @param result The result of gesture completion.
108      * @return
109      */
110     virtual void DispatchOnSimulationGestureResult(uint32_t sequence, bool result) = 0;
111 
112     /**
113      * @brief Set channelId.
114      * @param channelId The id of channel.
115      * @return
116      */
117     virtual void SetChannelId(uint32_t channelId) = 0;
118 };
119 } // namespace Accessibility
120 } // namespace OHOS
121 #endif // ACCESSIBILITY_UI_TEST_ABILITY_H