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 OHOS_ROSEN_TEST_COMMON_MOCK_UICONTENT_MOCKER
17 #define OHOS_ROSEN_TEST_COMMON_MOCK_UICONTENT_MOCKER
18 
19 #include "ui_content.h"
20 #include "native_engine/native_value.h"
21 #include "native_engine/native_engine.h"
22 #include <gmock/gmock.h>
23 #include "accessibility_element_info.h"
24 namespace OHOS {
25 namespace Ace {
26 class UIContentMocker : public UIContent {
27 public:
28     MOCK_METHOD3(Initialize, UIContentErrorCode(OHOS::Rosen::Window* window, const std::string& url,
29                  napi_value storage));
30     MOCK_METHOD3(Initialize, UIContentErrorCode(OHOS::Rosen::Window* window,
31                  const std::shared_ptr<std::vector<uint8_t>>& content, napi_value storage));
32     MOCK_METHOD3(InitializeByName, UIContentErrorCode(OHOS::Rosen::Window* window, const std::string& name,
33                  napi_value storage));
34     MOCK_METHOD4(Initialize,
35         void(OHOS::Rosen::Window* window, const std::string& url, napi_value storage, uint32_t focusWindowID));
36     MOCK_METHOD0(Foreground, void());
37     MOCK_METHOD0(Background, void());
38     MOCK_METHOD0(Focus, void());
39     MOCK_METHOD0(UnFocus, void());
40     MOCK_METHOD0(Destroy, void());
41     MOCK_METHOD1(OnNewWant, void(const OHOS::AAFwk::Want& want));
42     MOCK_METHOD4(Restore, UIContentErrorCode(OHOS::Rosen::Window* window, const std::string& contentInfo,
43                  napi_value storage, ContentInfoType type));
44     MOCK_CONST_METHOD1(GetContentInfo, std::string(ContentInfoType type));
45     MOCK_METHOD0(DestroyUIDirector, void());
46     MOCK_METHOD0(ProcessBackPressed, bool());
47     MOCK_METHOD1(ProcessPointerEvent, bool(const std::shared_ptr<OHOS::MMI::PointerEvent>& pointerEvent));
48     MOCK_METHOD2(ProcessKeyEvent, bool(const std::shared_ptr<OHOS::MMI::KeyEvent>& keyEvent, bool isPreIme));
49     MOCK_METHOD1(ProcessAxisEvent, bool(const std::shared_ptr<OHOS::MMI::AxisEvent>& axisEvent));
50     MOCK_METHOD1(ProcessVsyncEvent, bool(uint64_t timeStampNanos));
51     MOCK_METHOD1(UpdateConfiguration, void(const std::shared_ptr<OHOS::AppExecFwk::Configuration>& config));
52     MOCK_METHOD1(UpdateConfigurationSyncForAll, void(const std::shared_ptr<OHOS::AppExecFwk::Configuration>& config));
53     MOCK_METHOD4(UpdateViewportConfig, void(const ViewportConfig& config, OHOS::Rosen::WindowSizeChangeReason reason,
54         const std::shared_ptr<OHOS::Rosen::RSTransaction>& rsTransaction,
55         const std::map<OHOS::Rosen::AvoidAreaType, OHOS::Rosen::AvoidArea>& avoidAreas));
56     MOCK_METHOD2(UpdateWindowMode, void(OHOS::Rosen::WindowMode mode, bool hasDeco));
57     MOCK_METHOD4(HideWindowTitleButton, void(bool hideSplit, bool hideMaximize, bool hideMinimize, bool hideClose));
58     MOCK_METHOD2(UpdateTitleInTargetPos, void(bool isShow, int32_t height));
59     MOCK_METHOD0(GetBackgroundColor, uint32_t());
60     MOCK_METHOD1(SetBackgroundColor, void(uint32_t color));
61     MOCK_METHOD2(DumpInfo, void(const std::vector<std::string>& params, std::vector<std::string>& info));
62     MOCK_METHOD1(SetNextFrameLayoutCallback, void(std::function<void()>&& callback));
63     MOCK_METHOD1(NotifyMemoryLevel, void(int32_t level));
64     MOCK_METHOD1(SetAppWindowTitle, void(const std::string& title));
65     MOCK_METHOD1(SetAppWindowIcon, void(const std::shared_ptr<Media::PixelMap>& pixelMap));
66     MOCK_METHOD3(PreInitializeForm, void(OHOS::Rosen::Window* window, const std::string& url, napi_value storage));
67     MOCK_METHOD0(RunFormPage, void());
68     MOCK_METHOD0(GetFormRootNode, std::shared_ptr<Rosen::RSSurfaceNode>());
69     MOCK_METHOD1(UpdateFormData, void(const std::string& data));
70     MOCK_METHOD1(SetFormWidth, void(const float width));
71     MOCK_METHOD1(SetFormHeight, void(const float height));
72     MOCK_METHOD0(GetFormWidth, float());
73     MOCK_METHOD0(GetFormHeight, float());
74     MOCK_METHOD1(SetActionEventHandler, void(std::function<void(const std::string& action)>&& actionCallback));
75     MOCK_METHOD1(SetErrorEventHandler,
76         void(std::function<void(const std::string& code, const std::string& msg)>&& actionCallback));
77     MOCK_METHOD1(SetIgnoreViewSafeArea, void(bool ignoreViewSafeArea));
78     MOCK_METHOD1(SetIsFocusActive, void(bool isFocusActive));
79     MOCK_METHOD3(CreateModalUIExtension, int32_t(const AAFwk::Want& want,
80         const ModalUIExtensionCallbacks& callbacks, const ModalUIExtensionConfig& config));
81     MOCK_METHOD1(CloseModalUIExtension, void(int32_t sessionId));
82     MOCK_METHOD1(SetParentToken, void(sptr<IRemoteObject> token));
83     MOCK_METHOD0(GetParentToken, sptr<IRemoteObject>());
84 
85     MOCK_METHOD4(
86         SearchElementInfoByAccessibilityId, void(int64_t elementId,
87         int32_t mode, int64_t baseParent, std::list<Accessibility::AccessibilityElementInfo>& output));
88     MOCK_METHOD4(
89         SearchElementInfosByText, void(int64_t elementId, const std::string& text,
90         int64_t baseParent, std::list<Accessibility::AccessibilityElementInfo>& output));
91     MOCK_METHOD4(
92         FindFocusedElementInfo, void(int64_t elementId,
93         int32_t focusType, int64_t baseParent, Accessibility::AccessibilityElementInfo& output));
94     MOCK_METHOD4(
95         FocusMoveSearch, void(int64_t elementId, int32_t direction, int64_t baseParent,
96         Accessibility::AccessibilityElementInfo& output));
97     MOCK_METHOD1(GetAppPaintSize, void(OHOS::Rosen::Rect& drawableRect));
98     MOCK_METHOD2(SetContainerModalTitleVisible, void(bool customTitleSettedShow, bool floatingTitleSettedShow));
99     MOCK_METHOD1(SetContainerModalTitleHeight, void(int height));
100     MOCK_METHOD0(GetContainerModalTitleHeight, int());
101     MOCK_METHOD2(GetContainerModalButtonsRect, bool(OHOS::Rosen::Rect& containerModal, OHOS::Rosen::Rect& buttons));
102     MOCK_METHOD1(SubscribeContainerModalButtonsRectChange,
103         void(std::function<void(OHOS::Rosen::Rect& containerModal, OHOS::Rosen::Rect& buttons)>&& callback));
104     MOCK_METHOD1(UpdateTransform, void(const OHOS::Rosen::Transform& transform));
105     MOCK_METHOD1(SetUIExtensionSubWindow, void(bool isUIExtensionSubWindow));
106     MOCK_METHOD1(SetUIExtensionAbilityProcess, void(bool isUIExtensionAbilityProcess));
107     MOCK_METHOD0(IsUIExtensionSubWindow, bool());
108     MOCK_METHOD0(IsUIExtensionAbilityProcess, bool());
109     MOCK_METHOD4(NotifyExecuteAction, bool(int64_t elementId, const std::map<std::string, std::string>& actionAguments,
110         int32_t action, int64_t baseParent));
111     MOCK_METHOD2(SetForceSplitEnable, void(bool isForceSplit, const std::string& homePage));
112 };
113 } // namespace Ace
114 } // namespace OHOS
115 
116 #endif
117