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 19namespace OHOS { 20namespace Rosen { 21class MockWindow : public Window { 22public: 23 WMError RegisterSystemBarEnableListener(const sptr<IWindowSystemBarEnableListener>& listener) override 24 { 25 return WMError::WM_OK; 26 } 27 WMError UnRegisterSystemBarEnableListener(const sptr<IWindowSystemBarEnableListener>& listener) override 28 { 29 return WMError::WM_OK; 30 } 31 void SetContentInfoCallback(const ContentInfoCallback& callback) override 32 { 33 contentInfoCallback = callback; 34 g_setContentInfoCallback = true; 35 } 36 void CreateSurfaceNode(const std::string name, const SendRenderDataCallback& callback) override 37 { 38 g_createSurfaceNode = true; 39 } 40 void SetViewportConfig(const Ace::ViewportConfig& config) override {} 41 void ConsumeKeyEvent(const std::shared_ptr<MMI::KeyEvent>& inputEvent) override {} 42 void ConsumePointerEvent(const std::shared_ptr<MMI::PointerEvent>& inputEvent) override {} 43 void UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type) override 44 { 45 g_updateAvoidArea = true; 46 } 47 SystemBarProperty GetSystemBarPropertyByType(WindowType type) const override 48 { 49 g_getSystemBarPropertyByType = true; 50 return property; 51 } 52private: 53 SystemBarProperty property; 54 ContentInfoCallback contentInfoCallback; 55}; 56 57sptr<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}