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