• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 FOUNDATION_ACE_INTERFACE_INNERKITS_ACE_TEST_MOCK_MOCK_UICONTENT_H
17 #define FOUNDATION_ACE_INTERFACE_INNERKITS_ACE_TEST_MOCK_MOCK_UICONTENT_H
18 
19 #include "gmock/gmock.h"
20 
21 #include "accessibility_element_info.h"
22 #include "ui_content.h"
23 
24 namespace OHOS {
25 namespace Ace {
26 class MockUIContent : public UIContent {
27 public:
28     MockUIContent() = default;
29     ~MockUIContent() override = default;
30     MOCK_METHOD3(Initialize, UIContentErrorCode(OHOS::Rosen::Window *window, const std::string &url,
31         napi_value storage));
32     MOCK_METHOD3(Initialize, UIContentErrorCode(OHOS::Rosen::Window *window,
33         const std::shared_ptr<std::vector<uint8_t>> &content, napi_value storage));
34     MOCK_METHOD3(InitializeByName, UIContentErrorCode(OHOS::Rosen::Window *window,
35         const std::string &name, napi_value storage));
36     MOCK_METHOD4(Initialize,
37         void(OHOS::Rosen::Window *window, const std::string &url, napi_value storage, uint32_t focusWindowID));
38     MOCK_METHOD0(Foreground, void());
39     MOCK_METHOD0(Background, void());
40     MOCK_METHOD0(Focus, void());
41     MOCK_METHOD0(UnFocus, void());
42     MOCK_METHOD0(Destroy, void());
43     MOCK_METHOD1(OnNewWant, void(const OHOS::AAFwk::Want &want));
44     MOCK_METHOD4(Restore, UIContentErrorCode(OHOS::Rosen::Window *window, const std::string &contentInfo,
45         napi_value storage, ContentInfoType type));
46     MOCK_CONST_METHOD1(GetContentInfo, std::string(ContentInfoType type));
47     MOCK_METHOD0(DestroyUIDirector, void());
48     MOCK_METHOD0(ProcessBackPressed, bool());
49     MOCK_METHOD1(ProcessPointerEvent, bool(const std::shared_ptr<OHOS::MMI::PointerEvent> &pointerEvent));
50     MOCK_METHOD2(ProcessPointerEventWithCallback,
51         bool(const std::shared_ptr<OHOS::MMI::PointerEvent> &pointerEvent, const std::function<void()> &callback));
52     MOCK_METHOD2(ProcessKeyEvent, bool(const std::shared_ptr<OHOS::MMI::KeyEvent> &keyEvent, bool isPreIme));
53     MOCK_METHOD1(ProcessAxisEvent, bool(const std::shared_ptr<OHOS::MMI::AxisEvent> &axisEvent));
54     MOCK_METHOD1(ProcessVsyncEvent, bool(uint64_t timeStampNanos));
55     MOCK_METHOD1(UpdateConfiguration, void(const std::shared_ptr<OHOS::AppExecFwk::Configuration> &config));
56     MOCK_METHOD2(UpdateWindowMode, void(OHOS::Rosen::WindowMode mode, bool hasDeco));
57     MOCK_METHOD2(UpdateTitleInTargetPos, void(bool isShow, int32_t height));
58     MOCK_METHOD2(UpdateDecorVisible, void(bool visible, bool hasDeco));
59     MOCK_METHOD4(HideWindowTitleButton, void(bool hideSplit, bool hideMaximize, bool hideMinimize, bool hideClose));
60     MOCK_METHOD1(SetIgnoreViewSafeArea, void(bool ignoreViewSafeArea));
61     MOCK_METHOD0(GetBackgroundColor, uint32_t());
62     MOCK_METHOD1(SetBackgroundColor, void(uint32_t color));
63     MOCK_METHOD2(SetWindowContainerColor, void(uint32_t activeColor, uint32_t inactiveColor));
64     MOCK_METHOD2(DumpInfo, void(const std::vector<std::string> &params, std::vector<std::string> &info));
65     MOCK_METHOD1(SetNextFrameLayoutCallback, void(std::function<void()> &&callback));
66     MOCK_METHOD1(NotifyMemoryLevel, void(int32_t level));
67     MOCK_METHOD1(SetAppWindowTitle, void(const std::string &title));
68     MOCK_METHOD1(SetAppWindowIcon, void(const std::shared_ptr<Media::PixelMap> &pixelMap));
69     MOCK_METHOD3(PreInitializeForm, void(OHOS::Rosen::Window *window, const std::string &url, napi_value storage));
70     MOCK_METHOD0(RunFormPage, void());
71     MOCK_METHOD0(GetFormRootNode, std::shared_ptr<Rosen::RSSurfaceNode>());
72     MOCK_METHOD1(UpdateFormData, void(const std::string &data));
73     MOCK_METHOD1(
74         UpdateFormSharedImage, void(const std::map<std::string, sptr<OHOS::AppExecFwk::FormAshmem>> &imageDataMap));
75     MOCK_METHOD1(SetFormWidth, void(const float width));
76     MOCK_METHOD1(SetFormHeight, void(const float height));
77     MOCK_METHOD0(GetFormWidth, float());
78     MOCK_METHOD0(GetFormHeight, float());
79     MOCK_METHOD4(OnFormSurfaceChange, void(float width, float height, OHOS::Rosen::WindowSizeChangeReason reason,
80         const std::shared_ptr<OHOS::Rosen::RSTransaction> &rsTransaction));
81     MOCK_METHOD1(SetActionEventHandler, void(std::function<void(const std::string &action)> &&actionCallback));
82     MOCK_METHOD1(SetFormLinkInfoUpdateHandler, void(std::function<void(const std::vector<std::string>&)> &&callback));
83     MOCK_METHOD1(SetErrorEventHandler,
84         void(std::function<void(const std::string &code, const std::string &msg)> &&actionCallback));
85     MOCK_METHOD1(ReloadForm, void(const std::string &url));
86     MOCK_METHOD1(SetIsFocusActive, void(bool isFocusActive));
87 
88     MOCK_METHOD3(CreateModalUIExtension, int32_t(const AAFwk::Want &want,
89         const ModalUIExtensionCallbacks &callbacks, const ModalUIExtensionConfig &config));
90     MOCK_METHOD1(CloseModalUIExtension, void(int32_t sessionId));
91     MOCK_METHOD1(SetParentToken, void(sptr<IRemoteObject> token));
92     MOCK_METHOD0(GetParentToken, sptr<IRemoteObject>());
93 
94     MOCK_METHOD2(SetContainerModalTitleVisible, void(bool customTitleSettedShow, bool floatingTitleSettedShow));
95     MOCK_METHOD1(SetContainerModalTitleHeight, void(int height));
96     MOCK_METHOD0(GetContainerModalTitleHeight, int());
97     MOCK_METHOD2(GetContainerModalButtonsRect, bool(Rosen::Rect &containerModal, Rosen::Rect &buttons));
98     MOCK_METHOD1(SubscribeContainerModalButtonsRectChange, void(
99         std::function<void(Rosen::Rect &containerModal, Rosen::Rect &buttons)> &&callback));
100     MOCK_METHOD0(GetFormSerializedGesture, SerializedGesture());
101     MOCK_METHOD4(SetForceSplitEnable, void(bool isForceSplit, const std::string& homePage,
102         bool isRouter, bool ignoreOrientation));
103     MOCK_METHOD2(UpdateConfiguration, void(const std::shared_ptr<OHOS::AppExecFwk::Configuration>& config,
104         const std::shared_ptr<Global::Resource::ResourceManager>& resourceManager));
105 
106 #ifndef PREVIEW
107     MOCK_METHOD4(
108         SearchElementInfoByAccessibilityId, void(int64_t elementId,
109         int32_t mode, int64_t baseParent, std::list<Accessibility::AccessibilityElementInfo> &output));
110     MOCK_METHOD4(
111         SearchElementInfosByText, void(int64_t elementId,
112         const std::string &text, int64_t baseParent, std::list<Accessibility::AccessibilityElementInfo> &output));
113     MOCK_METHOD4(
114         FindFocusedElementInfo, void(int64_t elementId,
115         int32_t focusType, int64_t baseParent, Accessibility::AccessibilityElementInfo &output));
116     MOCK_METHOD4(
117         FocusMoveSearch, void(int64_t elementId, int32_t direction,
118         int64_t baseParent, Accessibility::AccessibilityElementInfo &output));
119 #endif
120     MOCK_METHOD1(GetAppPaintSize, void(OHOS::Rosen::Rect&));
121     MOCK_METHOD3(CreateCustomPopupUIExtension, int32_t(const AAFwk::Want &want,
122         const ModalUIExtensionCallbacks &callbacks, const CustomPopupUIExtensionConfig &config));
123     MOCK_METHOD1(DestroyCustomPopupUIExtension, void(int32_t nodeId));
124     MOCK_METHOD1(UpdateTransform, void(const OHOS::Rosen::Transform &transform));
125     MOCK_METHOD2(UpdateSizeOfPopupUIExtension, void(int32_t nodeId, std::optional<PopupSize> &targetSize));
126 };
127 
Create(OHOS::AbilityRuntime::Context *,NativeEngine *)128 std::unique_ptr<Ace::UIContent> UIContent::Create(OHOS::AbilityRuntime::Context *, NativeEngine *)
129 {
130     return std::make_unique<Ace::MockUIContent>();
131 }
132 } // namespace Ace
133 } // namespace OHOS
134 
135 #endif // FOUNDATION_ACE_INTERFACE_INNERKITS_ACE_TEST_MOCK_MOCK_UICONTENT_H
136