• 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) 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 DeregisterElementOperator(const int32_t windowId) override;
53 
54     RetError GetCaptionProperty(AccessibilityConfig::CaptionProperty &caption) override;
55     RetError SetCaptionProperty(const AccessibilityConfig::CaptionProperty &caption) override;
56     RetError SetCaptionState(const bool state) override;
57 
58     bool GetEnabledState() override;
59     RetError GetCaptionState(bool &state) override;
60     bool GetTouchGuideState() override;
61     bool GetGestureState() override;
62     bool GetKeyEventObserverState() override;
63 
64     RetError EnableAbility(const std::string &name, const uint32_t capabilities) override;
65     RetError GetEnabledAbilities(std::vector<std::string> &enabledAbilities) override;
66 
67     RetError DisableAbility(const std::string &name) override;
68     int32_t GetActiveWindow() override;
69 
70     RetError EnableUITestAbility(const sptr<IRemoteObject> &obj) override;
71     RetError DisableUITestAbility() override;
72 
73     RetError SetScreenMagnificationState(const bool state) override;
74     RetError SetShortKeyState(const bool state) override;
75     RetError SetMouseKeyState(const bool state) override;
76     RetError SetMouseAutoClick(const int32_t time) override;
77     RetError SetShortkeyTarget(const std::string &name) override;
78     RetError SetShortkeyMultiTarget(const std::vector<std::string> &name) override;
79     RetError SetHighContrastTextState(const bool state) override;
80     RetError SetInvertColorState(const bool state) override;
81     RetError SetAnimationOffState(const bool state) override;
82     RetError SetAudioMonoState(const bool state) override;
83     RetError SetDaltonizationState(const bool state) override;
84     RetError SetDaltonizationColorFilter(const uint32_t filter) override;
85     RetError SetContentTimeout(const uint32_t time) override;
86     RetError SetBrightnessDiscount(const float discount) override;
87     RetError SetAudioBalance(const float balance) override;
88     RetError SetClickResponseTime(const uint32_t time) override;
89     RetError SetIgnoreRepeatClickState(const bool state) override;
90     RetError SetIgnoreRepeatClickTime(const uint32_t time) override;
91 
92     RetError GetScreenMagnificationState(bool &state) override;
93     RetError GetShortKeyState(bool &state) override;
94     RetError GetMouseKeyState(bool &state) override;
95     RetError GetMouseAutoClick(int32_t &time) override;
96     RetError GetShortkeyTarget(std::string &name) override;
97     RetError GetShortkeyMultiTarget(std::vector<std::string> &name) override;
98     RetError GetHighContrastTextState(bool &state) override;
99     RetError GetInvertColorState(bool &state) override;
100     RetError GetAnimationOffState(bool &state) override;
101     RetError GetAudioMonoState(bool &state) override;
102     RetError GetDaltonizationState(bool &state) override;
103     RetError GetDaltonizationColorFilter(uint32_t &type) override;
104     RetError GetContentTimeout(uint32_t &timer) override;
105     RetError GetBrightnessDiscount(float &brightness) override;
106     RetError GetAudioBalance(float &balance) override;
107     RetError GetClickResponseTime(uint32_t &time) override;
108     RetError GetIgnoreRepeatClickState(bool &state) override;
109     RetError GetIgnoreRepeatClickTime(uint32_t &time) override;
110     void GetAllConfigs(AccessibilityConfigData &configData) override;
111     uint32_t RegisterConfigObserver(const sptr<IAccessibleAbilityManagerConfigObserver> &callback) override;
112     void GetRealWindowAndElementId(int32_t& windowId, int64_t& elementId) override;
113     void GetSceneBoardInnerWinId(int32_t windowId, int64_t elementId, int32_t& innerWid) override;
114     RetError GetFocusedWindowId(int32_t &focusedWindowId) override;
115 
116 private:
117     std::shared_ptr<AppExecFwk::EventRunner> runner_;
118     std::shared_ptr<AppExecFwk::EventHandler> handler_;
119     sptr<IAccessibleAbilityManagerConfigObserver> observer_ = nullptr;
120     sptr<IAccessibleAbilityManagerCaptionObserver> captionObserver_ = nullptr;
121     sptr<IAccessibilityEnableAbilityListsObserver> abilityObserver_ = nullptr;
122 
123     bool shortkey_ = false;
124     bool highContrastText_ = false;
125     bool screenMagnifier_ = false;
126     bool invertColor_ = false;
127     bool captionState_ = false;
128     bool animationOff_ = false;
129     bool audioMono_ = false;
130     bool mouseKey_ = false;
131     bool daltonizationState_ = false;
132     int32_t mouseAutoClick_ = 0;
133     uint32_t contentTimeout_ = 0;
134     uint32_t daltonizationColorFilter_ = 0;
135     float audioBalance_ = 0.0;
136     float brightnessDiscount_ = 0.0;
137     std::string shortkeyTarget_ = "";
138     std::vector<std::string> shortkeyMultiTarget_ {};
139     uint32_t clickResponseTime_ = 0;
140     bool ignoreRepeatClickState_ = false;
141     uint32_t ignoreRepeatClickTime_ = 0;
142     AccessibilityConfig::CaptionProperty captionProperty_ = {};
143 };
144 } // namespace Accessibility
145 } // namespace OHOS
146 #endif