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