• 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 #include "window.h"
17 #include "MockGlobalResult.h"
18 
19 namespace OHOS {
20 namespace Rosen {
21 class MockWindow : public Window {
22 public:
RegisterSystemBarEnableListener(const sptr<IWindowSystemBarEnableListener> & listener)23     WMError RegisterSystemBarEnableListener(const sptr<IWindowSystemBarEnableListener>& listener) override
24     {
25         return WMError::WM_OK;
26     }
UnRegisterSystemBarEnableListener(const sptr<IWindowSystemBarEnableListener> & listener)27     WMError UnRegisterSystemBarEnableListener(const sptr<IWindowSystemBarEnableListener>& listener) override
28     {
29         return WMError::WM_OK;
30     }
SetContentInfoCallback(const ContentInfoCallback & callback)31     void SetContentInfoCallback(const ContentInfoCallback& callback) override
32     {
33         contentInfoCallback = callback;
34         g_setContentInfoCallback = true;
35     }
CreateSurfaceNode(const std::string name,const SendRenderDataCallback & callback)36     void CreateSurfaceNode(const std::string name, const SendRenderDataCallback& callback) override
37     {
38         g_createSurfaceNode = true;
39     }
SetViewportConfig(const Ace::ViewportConfig & config)40     void SetViewportConfig(const Ace::ViewportConfig& config) override {}
ConsumeKeyEvent(const std::shared_ptr<MMI::KeyEvent> & inputEvent)41     void ConsumeKeyEvent(const std::shared_ptr<MMI::KeyEvent>& inputEvent) override {}
ConsumePointerEvent(const std::shared_ptr<MMI::PointerEvent> & inputEvent)42     void ConsumePointerEvent(const std::shared_ptr<MMI::PointerEvent>& inputEvent) override {}
UpdateAvoidArea(const sptr<AvoidArea> & avoidArea,AvoidAreaType type)43     void UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type) override
44     {
45         g_updateAvoidArea = true;
46     }
GetSystemBarPropertyByType(WindowType type) const47     SystemBarProperty GetSystemBarPropertyByType(WindowType type) const override
48     {
49         g_getSystemBarPropertyByType = true;
50         return property;
51     }
52 private:
53     SystemBarProperty property;
54     ContentInfoCallback contentInfoCallback;
55 };
56 
Create(const std::string & windowName,sptr<WindowOption> & option,const std::shared_ptr<OHOS::AbilityRuntime::Context> & context,WMError & errCode)57 sptr<Window> Window::Create(const std::string& windowName, sptr<WindowOption>& option,
58     const std::shared_ptr<OHOS::AbilityRuntime::Context>& context, WMError& errCode)
59 {
60     sptr<MockWindow> windowImpl = new(std::nothrow) MockWindow();
61     return windowImpl;
62 }
63 }
64 }