• 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 MOCK_ACCESSIBILITY_ABILITY_MANAGER_SERVICE_CLIENT_STUB_H
17 #define MOCK_ACCESSIBILITY_ABILITY_MANAGER_SERVICE_CLIENT_STUB_H
18 
19 #include <map>
20 #include "i_accessible_ability_manager_service.h"
21 #include "accessibility_config_impl.h"
22 #include "iremote_stub.h"
23 
24 namespace OHOS {
25 namespace Accessibility {
26 /*
27  * The class define the interface to call ABMS API.
28  */
29 class MockAccessibleAbilityManagerServiceStub : public IRemoteStub<IAccessibleAbilityManagerService> {
30 public:
31     MockAccessibleAbilityManagerServiceStub();
32 
33     virtual ~MockAccessibleAbilityManagerServiceStub();
34 
35     int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
36 
37     RetError SendEvent(const AccessibilityEventInfo &uiEvent, const int32_t flag) override;
38 
39     uint32_t RegisterStateObserver(const sptr<IAccessibleAbilityManagerStateObserver> &callback) override;
40 
41     uint32_t RegisterCaptionObserver(const sptr<IAccessibleAbilityManagerCaptionObserver> &callback) override;
42 
43     void RegisterEnableAbilityListsObserver(
44         const sptr<IAccessibilityEnableAbilityListsObserver> &observer) override;
45 
46     RetError GetAbilityList(const uint32_t abilityTypes, const int32_t stateType,
47         std::vector<AccessibilityAbilityInfo> &infos) override;
48 
49     RetError RegisterElementOperator(const int32_t windowId,
50         const sptr<IAccessibilityElementOperator> &operation, bool isApp) override;
51 
52     RetError RegisterElementOperator(Registration parameter,
53         const sptr<IAccessibilityElementOperator> &operation, bool isApp) override;
54 
55     RetError DeregisterElementOperator(const int32_t windowId) override;
56 
57     RetError DeregisterElementOperator(const int32_t windowId, const int32_t treeId) override;
58 
59     RetError GetCaptionProperty(AccessibilityConfig::CaptionProperty &caption) override;
60     RetError SetCaptionProperty(const AccessibilityConfig::CaptionProperty &caption) override;
61     RetError SetCaptionState(const bool state) override;
62 
63     bool GetEnabledState() override;
64     RetError GetCaptionState(bool &state) override;
65     bool GetTouchGuideState() override;
66     bool GetGestureState() override;
67     bool GetKeyEventObserverState() override;
68     bool GetScreenReaderState() override;
69 
70     RetError EnableAbility(const std::string &name, const uint32_t capabilities) override;
71     RetError GetEnabledAbilities(std::vector<std::string> &enabledAbilities) override;
72 
73     RetError DisableAbility(const std::string &name) override;
74     int32_t GetActiveWindow() override;
75 
76     RetError EnableUITestAbility(const sptr<IRemoteObject> &obj) override;
77     RetError DisableUITestAbility() override;
78 
79     RetError SetScreenMagnificationState(const bool state) override;
80     RetError SetShortKeyState(const bool state) override;
81     RetError SetMouseKeyState(const bool state) override;
82     RetError SetMouseAutoClick(const int32_t time) override;
83     RetError SetShortkeyTarget(const std::string &name) override;
84     RetError SetShortkeyMultiTarget(const std::vector<std::string> &name) override;
85     RetError SetHighContrastTextState(const bool state) override;
86     RetError SetInvertColorState(const bool state) override;
87     RetError SetAnimationOffState(const bool state) override;
88     RetError SetAudioMonoState(const bool state) override;
89     RetError SetDaltonizationState(const bool state) override;
90     RetError SetDaltonizationColorFilter(const uint32_t filter) override;
91     RetError SetContentTimeout(const uint32_t time) override;
92     RetError SetBrightnessDiscount(const float discount) override;
93     RetError SetAudioBalance(const float balance) override;
94     RetError SetClickResponseTime(const uint32_t time) override;
95     RetError SetIgnoreRepeatClickState(const bool state) override;
96     RetError SetIgnoreRepeatClickTime(const uint32_t time) override;
97 
98     RetError GetScreenMagnificationState(bool &state) override;
99     RetError GetShortKeyState(bool &state) override;
100     RetError GetMouseKeyState(bool &state) override;
101     RetError GetMouseAutoClick(int32_t &time) override;
102     RetError GetShortkeyTarget(std::string &name) override;
103     RetError GetShortkeyMultiTarget(std::vector<std::string> &name) override;
104     RetError GetHighContrastTextState(bool &state) override;
105     RetError GetInvertColorState(bool &state) override;
106     RetError GetAnimationOffState(bool &state) override;
107     RetError GetAudioMonoState(bool &state) override;
108     RetError GetDaltonizationState(bool &state) override;
109     RetError GetDaltonizationColorFilter(uint32_t &type) override;
110     RetError GetContentTimeout(uint32_t &timer) override;
111     RetError GetBrightnessDiscount(float &brightness) override;
112     RetError GetAudioBalance(float &balance) override;
113     RetError GetClickResponseTime(uint32_t &time) override;
114     RetError GetIgnoreRepeatClickState(bool &state) override;
115     RetError GetIgnoreRepeatClickTime(uint32_t &time) override;
116     void GetAllConfigs(AccessibilityConfigData &configData) override;
117     uint32_t RegisterConfigObserver(const sptr<IAccessibleAbilityManagerConfigObserver> &callback) override;
118     void GetRealWindowAndElementId(int32_t& windowId, int64_t& elementId) override;
119     void GetSceneBoardInnerWinId(int32_t windowId, int64_t elementId, int32_t& innerWid) override;
120     RetError GetFocusedWindowId(int32_t &focusedWindowId) override;
121     void RemoveRequestId(int32_t requestId) override;
122     int64_t GetRootParentId(int32_t windowId, int32_t treeId) override;
123     RetError GetAllTreeId(int32_t windowId, std::vector<int32_t> &treeIds) override;
124 
125 private:
126     std::shared_ptr<AppExecFwk::EventRunner> runner_;
127     std::shared_ptr<AppExecFwk::EventHandler> handler_;
128     sptr<IAccessibleAbilityManagerConfigObserver> observer_ = nullptr;
129     sptr<IAccessibleAbilityManagerCaptionObserver> captionObserver_ = nullptr;
130     sptr<IAccessibilityEnableAbilityListsObserver> abilityObserver_ = nullptr;
131 
132     bool shortkey_ = false;
133     bool highContrastText_ = false;
134     bool screenMagnifier_ = false;
135     bool invertColor_ = false;
136     bool captionState_ = false;
137     bool animationOff_ = false;
138     bool audioMono_ = false;
139     bool mouseKey_ = false;
140     bool daltonizationState_ = false;
141     int32_t mouseAutoClick_ = 0;
142     uint32_t contentTimeout_ = 0;
143     uint32_t daltonizationColorFilter_ = 0;
144     float audioBalance_ = 0.0;
145     float brightnessDiscount_ = 0.0;
146     std::string shortkeyTarget_ = "";
147     std::vector<std::string> shortkeyMultiTarget_ {};
148     uint32_t clickResponseTime_ = 0;
149     bool ignoreRepeatClickState_ = false;
150     uint32_t ignoreRepeatClickTime_ = 0;
151     AccessibilityConfig::CaptionProperty captionProperty_ = {};
152 };
153 } // namespace Accessibility
154 } // namespace OHOS
155 #endif