1 /* 2 * Copyright (C) 2021 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_ACCESSIBLE_ABILITY_MANAGER_SERVICE_H 17 #define MOCK_ACCESSIBLE_ABILITY_MANAGER_SERVICE_H 18 19 #include <gmock/gmock.h> 20 #include "accessible_ability_manager_service.h" 21 22 namespace OHOS { 23 namespace Accessibility { 24 class MockAccessibleAbilityManagerService : public AccessibleAbilityManagerService { 25 DECLARE_DELAYED_SINGLETON(MockAccessibleAbilityManagerService) 26 DECLEAR_SYSTEM_ABILITY(MockAccessibleAbilityManagerService) 27 public: 28 MOCK_METHOD0(OnStart, void()); 29 MOCK_METHOD0(OnStop, void()); 30 MOCK_METHOD1(SendEvent, RetError(const AccessibilityEventInfo& uiEvent)); 31 MOCK_METHOD2(RegisterStateCallback, 32 uint32_t(const sptr<AccessibleAbilityManagerServiceStub>& callback, const int32_t accountId)); 33 MOCK_METHOD2(RegisterCaptionPropertyCallback, 34 uint32_t(const sptr<IAccessibleAbilityManagerCaptionObserver>& callback, const int32_t accountId)); 35 MOCK_METHOD3(GetAbilityList, RetError(const uint32_t abilityTypes, const int32_t stateType, 36 std::vector<AccessibilityAbilityInfo> &infos)); 37 MOCK_METHOD2(RegisterElementOperator, 38 RetError(const int32_t windowId, const sptr<IAccessibilityElementOperator>& operation)); 39 MOCK_METHOD1(DeregisterElementOperator, RetError(const int32_t windowId)); 40 MOCK_METHOD1(GetCaptionProperty, RetError(AccessibilityConfig::CaptionProperty& caption)); 41 MOCK_METHOD1(SetCaptionProperty, RetError(const AccessibilityConfig::CaptionProperty& caption)); 42 MOCK_METHOD1(SetCaptionState, RetError(const bool state)); 43 MOCK_METHOD1(SetEnabled, bool(const bool state)); 44 MOCK_METHOD1(SetTouchEventInjector, void(const sptr<TouchEventInjector>& touchEventInjector)); 45 GetTouchEventInjector()46 inline sptr<TouchEventInjector> GetTouchEventInjector() 47 { 48 return nullptr; 49 } 50 GetKeyEventFilter()51 inline sptr<KeyEventFilter> GetKeyEventFilter() 52 { 53 return nullptr; 54 } 55 56 MOCK_METHOD1(SetKeyEventFilter, void(const sptr<KeyEventFilter>& keyEventFilter)); 57 MOCK_METHOD5(NotifyDisplayResizeStateChanged, 58 void(int32_t displayId, Rect& rect, float scale, float centerX, float centerY)); 59 GetCurrentAccountId()60 inline int32_t GetCurrentAccountId() 61 { 62 return 0; 63 } 64 65 std::shared_ptr<AppExecFwk::EventRunner> runner_; 66 std::shared_ptr<AAMSEventHandler> handler_; GetMainHandler()67 inline std::shared_ptr<AAMSEventHandler>& GetMainHandler() 68 { 69 return handler_; 70 } 71 GetMainRunner()72 inline std::shared_ptr<AppExecFwk::EventRunner>& GetMainRunner() 73 { 74 return runner_; 75 } 76 77 MOCK_METHOD0(GetCurrentAccountData, sptr<AccessibilityAccountData>()); 78 MOCK_METHOD0(GetBundleMgrProxy, sptr<AppExecFwk::IBundleMgr>()); 79 MOCK_METHOD1(AddedUser, void(int32_t accountId)); 80 MOCK_METHOD1(RemovedUser, void(int32_t accountId)); 81 MOCK_METHOD1(SwitchedUser, void(int32_t accountId)); 82 MOCK_METHOD1(PackageChanged, void(const std::string& bundleName)); 83 MOCK_METHOD1(PackageRemoved, void(const std::string& bundleName)); 84 MOCK_METHOD1(PackageAdd, void(const std::string& bundleName)); 85 MOCK_METHOD0(UpdateAccessibilityManagerService, void()); 86 MOCK_METHOD0(GetEnabledState, bool()); 87 MOCK_METHOD1(GetCaptionState, RetError(bool &state)); 88 MOCK_METHOD0(GetTouchGuideState, bool()); 89 MOCK_METHOD0(GetGestureState, bool()); 90 MOCK_METHOD0(GetKeyEventObserverState, bool()); 91 MOCK_METHOD1(SetTouchGuideState, bool(const bool state)); 92 MOCK_METHOD1(SetGestureState, bool(const bool state)); 93 MOCK_METHOD1(SetKeyEventObserverState, bool(const bool state)); 94 MOCK_METHOD1(SetEnabledObj, bool(std::map<std::string, AppExecFwk::ElementName> it)); 95 MOCK_METHOD1(GetEnabledAbilities, RetError(std::vector<std::string> &enabledAbilities)); 96 MOCK_METHOD0(GetActiveWindow, int32_t()); 97 }; 98 } // namespace Accessibility 99 } // namespace OHOS 100 #endif // MOCK_ACCESSIBLE_ABILITY_MANAGER_SERVICE_H