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 MOCK_KEYBOARD_SESSION_H 17 #define MOCK_KEYBOARD_SESSION_H 18 19 #include "session/host/include/keyboard_session.h" 20 #include "interfaces/include/ws_common.h" 21 #include "session/container/include/zidl/session_stage_interface.h" 22 #include "session/host/include/session.h" 23 #include <gmock/gmock.h> 24 25 namespace OHOS { 26 namespace Rosen { 27 class KeyboardSessionMocker : public KeyboardSession { 28 public: KeyboardSessionMocker(const SessionInfo & info,const sptr<SpecificSessionCallback> & specificCallback,const sptr<KeyboardSessionCallback> & keyboardCallback)29 KeyboardSessionMocker(const SessionInfo& info, const sptr<SpecificSessionCallback>& specificCallback, 30 const sptr<KeyboardSessionCallback>& keyboardCallback) 31 : KeyboardSession(info, specificCallback, keyboardCallback) {} ~KeyboardSessionMocker()32 ~KeyboardSessionMocker() {} 33 GetSceneSession(uint32_t persistentId)34 sptr<SceneSession> GetSceneSession(uint32_t persistentId) 35 { 36 return callingSession_; 37 }; 38 sptr<SceneSession> callingSession_; 39 }; 40 41 using UpdateSessionRectCallBack = std::function<void(const WSRect& rect, SizeChangeReason reason)>; 42 class KSSceneSessionMocker : public SceneSession { 43 public: KSSceneSessionMocker(const SessionInfo & info,const sptr<SpecificSessionCallback> & specificCallback)44 KSSceneSessionMocker(const SessionInfo& info, const sptr<SpecificSessionCallback>& specificCallback) 45 : SceneSession(info, specificCallback) {} ~KSSceneSessionMocker()46 ~KSSceneSessionMocker() {} 47 48 WSError UpdateSessionRect(const WSRect& rect, SizeChangeReason reason, bool isGlobal = false, 49 bool isFromMoveToGlobal = false, const MoveConfiguration& moveConfiguration = {}, 50 const RectAnimationConfig& rectAnimationConfig = {}) override 51 { 52 updateRectCallback_(rect, reason); 53 return WSError::WS_OK; 54 }; 55 GetStatusBarHeight()56 int32_t GetStatusBarHeight() override 57 { 58 constexpr int32_t statusBarHeight = 128; 59 return statusBarHeight; 60 } 61 62 UpdateSessionRectCallBack updateRectCallback_ = [](const WSRect& rect, SizeChangeReason reason) {}; 63 }; 64 } // namespace Rosen 65 } // namespace OHOS 66 #endif 67