/* * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "session_proxy.h" #include "iremote_object_mocker.h" #include #include "accessibility_event_info.h" #include "ws_common.h" #include "mock_message_parcel.h" #include "pointer_event.h" #include "ui/rs_canvas_node.h" #include "transaction/rs_transaction.h" #include "window_manager_hilog.h" // using namespace FRAME_TRACE; using namespace testing; using namespace testing::ext; namespace { std::string logMsg; void MyLogCallback(const LogType type, const LogLevel level, const unsigned int domain, const char* tag, const char* msg) { logMsg = msg; } } namespace OHOS { namespace Rosen { class SessionProxyTest : public testing::Test { public: SessionProxyTest() {} ~SessionProxyTest() {} }; namespace { /** * @tc.name: OnSessionEvent * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, OnSessionEvent, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: OnSessionEvent start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); SessionEvent event = SessionEvent::EVENT_MAXIMIZE; WSError res = sProxy->OnSessionEvent(event); ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: OnSessionEvent end"; } /** * @tc.name: UpdateSessionRect * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, UpdateSessionRect, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: UpdateSessionRect start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); WSRect rect{ .posX_ = 1, .posY_ = 1, .width_ = 100, .height_ = 100 }; SizeChangeReason reason = SizeChangeReason::RECOVER; WSError res = sProxy->UpdateSessionRect(rect, reason); ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: UpdateSessionRect end"; } /** * @tc.name: Restore * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, OnRestoreMainWindow, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: OnRestoreMainWindow start"; auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); auto sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); WSError res = sProxy->OnRestoreMainWindow(); ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: OnRestoreMainWindow end"; } /** * @tc.name: RaiseToAppTop * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, RaiseToAppTop, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: RaiseToAppTop start"; sptr remoteMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(remoteMocker); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); WSError res = sProxy->RaiseToAppTop(); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); sptr tempProxy = sptr::MakeSptr(nullptr); res = tempProxy->RaiseToAppTop(); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); remoteMocker->SetRequestResult(ERR_INVALID_DATA); res = sProxy->RaiseToAppTop(); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); remoteMocker->SetRequestResult(ERR_NONE); res = sProxy->RaiseToAppTop(); ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: RaiseToAppTop end"; } /** * @tc.name: RaiseAboveTarget * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, RaiseAboveTarget, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: RaiseAboveTarget start"; sptr remoteMocker = sptr::MakeSptr(); sptr proxy = sptr::MakeSptr(remoteMocker); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); int32_t subWindowId = 0; WSError res = proxy->RaiseAboveTarget(subWindowId); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); sptr tempProxy = sptr::MakeSptr(nullptr); res = tempProxy->RaiseAboveTarget(subWindowId); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); remoteMocker->SetRequestResult(ERR_INVALID_DATA); res = proxy->RaiseAboveTarget(subWindowId); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); remoteMocker->SetRequestResult(ERR_NONE); res = proxy->RaiseAboveTarget(subWindowId); ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: RaiseAboveTarget end"; } /** * @tc.name: OnNeedAvoid * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, OnNeedAvoid, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: OnNeedAvoid start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); bool status = false; WSError res = sProxy->OnNeedAvoid(status); ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: OnNeedAvoid end"; } /** * @tc.name: RequestSessionBack * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, RequestSessionBack, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: RequestSessionBack start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); bool needMoveToBackground = true; WSError res = sProxy->RequestSessionBack(needMoveToBackground); ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: RequestSessionBack end"; } /** * @tc.name: MarkProcessed * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, MarkProcessed, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: MarkProcessed start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); int32_t eventId = 0; WSError res = sProxy->MarkProcessed(eventId); ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: MarkProcessed end"; } /** * @tc.name: SetGlobalMaximizeMode * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, SetGlobalMaximizeMode, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: SetGlobalMaximizeMode start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); MaximizeMode mode = MaximizeMode::MODE_AVOID_SYSTEM_BAR; WSError res = sProxy->SetGlobalMaximizeMode(mode); ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: SetGlobalMaximizeMode end"; } /** * @tc.name: GetGlobalMaximizeMode * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, GetGlobalMaximizeMode, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: GetGlobalMaximizeMode start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); MaximizeMode mode = MaximizeMode::MODE_AVOID_SYSTEM_BAR; WSError res = sProxy->GetGlobalMaximizeMode(mode); ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: GetGlobalMaximizeMode end"; } /** * @tc.name: SetAspectRatio * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, SetAspectRatio, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: SetAspectRatio start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); float ratio = 10; WSError res = sProxy->SetAspectRatio(ratio); ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: SetAspectRatio end"; } /** * @tc.name: UpdateWindowSceneAfterCustomAnimation * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, UpdateWindowSceneAfterCustomAnimation, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: UpdateWindowSceneAfterCustomAnimation start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); bool isAdd = false; WSError res = sProxy->UpdateWindowSceneAfterCustomAnimation(isAdd); ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: UpdateWindowSceneAfterCustomAnimation end"; } /** * @tc.name: SetSystemWindowEnableDrag * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, SetSystemWindowEnableDrag, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: SetSystemWindowEnableDrag start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); bool enableDrag = false; WMError res = sProxy->SetSystemWindowEnableDrag(enableDrag); ASSERT_EQ(res, WMError::WM_OK); GTEST_LOG_(INFO) << "SessionProxyTest: SetSystemWindowEnableDrag end"; } /** * @tc.name: TransferAbilityResult * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, TransferAbilityResult, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: TransferAbilityResult start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); uint32_t resultCode = 0; AAFwk::Want want; WSError res = sProxy->TransferAbilityResult(resultCode, want); ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: TransferAbilityResult end"; } /** * @tc.name: NotifyExtensionDied * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, NotifyExtensionDied, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: NotifyExtensionDied start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); sProxy->NotifyExtensionDied(); GTEST_LOG_(INFO) << "SessionProxyTest: NotifyExtensionDied end"; } /** * @tc.name: NotifyExtensionTimeout * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, NotifyExtensionTimeout, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: NotifyExtensionTimeout start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); sProxy->NotifyExtensionTimeout(2); GTEST_LOG_(INFO) << "SessionProxyTest: NotifyExtensionTimeout end"; } /** * @tc.name: UpdateWindowAnimationFlag * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, UpdateWindowAnimationFlag, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: UpdateWindowAnimationFlag start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); bool needDefaultAnimationFlag = false; WSError res = sProxy->UpdateWindowAnimationFlag(needDefaultAnimationFlag); ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: UpdateWindowAnimationFlag end"; } /** * @tc.name: TransferAccessibilityEvent * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, TransferAccessibilityEvent, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: TransferAccessibilityEvent start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); Accessibility::AccessibilityEventInfo info; int64_t uiExtensionIdLevel = 0; WSError res = sProxy->TransferAccessibilityEvent(info, uiExtensionIdLevel); ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: TransferAccessibilityEvent end"; } /** * @tc.name: OnTitleAndDockHoverShowChange * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, OnTitleAndDockHoverShowChange, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: OnTitleAndDockHoverShowChange start"; auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); auto sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); bool isTitleHoverShown = true; bool isDockHoverShown = true; WSError res = sProxy->OnTitleAndDockHoverShowChange(isTitleHoverShown, isDockHoverShown); EXPECT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: OnTitleAndDockHoverShowChange end"; } /** * @tc.name: UpdatePiPControlStatus * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, UpdatePiPControlStatus, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: UpdatePiPControlStatus start"; auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); auto sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); auto controlType = WsPiPControlType::VIDEO_PLAY_PAUSE; auto status = WsPiPControlStatus::PLAY; WSError res = sProxy->UpdatePiPControlStatus(controlType, status); ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: UpdatePiPControlStatus end"; } /** * @tc.name: SetAutoStartPiP * @tc.desc: sessionStub sessionStubTest * @tc.type: FUNC * @tc.require: #I6JLSI */ HWTEST_F(SessionProxyTest, SetAutoStartPiP, TestSize.Level1) { GTEST_LOG_(INFO) << "SetAutoStartPiP: SetAutoStartPiP start"; auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); auto sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); bool isAutoStartValid = true; uint32_t priority = 0; uint32_t width = 0; uint32_t height = 0; ASSERT_EQ(WSError::WS_OK, sProxy->SetAutoStartPiP(isAutoStartValid, priority, width, height)); GTEST_LOG_(INFO) << "SetAutoStartPiP: SetAutoStartPiP end"; } /** * @tc.name: UpdatePiPTemplateInfo * @tc.desc: sessionStub sessionStubTest * @tc.type: FUNC * @tc.require: #I6JLSI */ HWTEST_F(SessionProxyTest, UpdatePiPTemplateInfo, Function | SmallTest | Level2) { GTEST_LOG_(INFO) << "UpdatePiPTemplateInfo: UpdatePiPTemplateInfo start"; auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); auto sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); PiPTemplateInfo templateInfo; ASSERT_EQ(WSError::WS_OK, sProxy->UpdatePiPTemplateInfo(templateInfo)); GTEST_LOG_(INFO) << "UpdatePiPTemplateInfo: UpdatePiPTemplateInfo end"; } /** * @tc.name: SetWindowAnchorInfo * @tc.desc: sessionStub sessionStubTest * @tc.type: FUNC * @tc.require: #I6JLSI */ HWTEST_F(SessionProxyTest, SetWindowAnchorInfo, Function | SmallTest | Level2) { GTEST_LOG_(INFO) << "SetWindowAnchorInfo: SetWindowAnchorInfo start"; sptr remoteMocker = sptr::MakeSptr(); auto sProxy = sptr::MakeSptr(remoteMocker); ASSERT_NE(sProxy, nullptr); WindowAnchorInfo anchorInfo; WSError res = sProxy->SetWindowAnchorInfo(anchorInfo); ASSERT_EQ(res, WSError::WS_OK); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); res = sProxy->SetWindowAnchorInfo(anchorInfo); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); MockMessageParcel::SetWriteParcelableErrorFlag(true); res = sProxy->SetWindowAnchorInfo(anchorInfo); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); MockMessageParcel::SetWriteParcelableErrorFlag(false); sptr tempProxy = sptr::MakeSptr(nullptr); res = tempProxy->SetWindowAnchorInfo(anchorInfo); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); remoteMocker->SetRequestResult(ERR_INVALID_DATA); res = sProxy->SetWindowAnchorInfo(anchorInfo); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); remoteMocker->SetRequestResult(ERR_NONE); MockMessageParcel::SetReadInt32ErrorFlag(true); res = sProxy->SetWindowAnchorInfo(anchorInfo); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); MockMessageParcel::SetReadInt32ErrorFlag(false); MockMessageParcel::ClearAllErrorFlag(); GTEST_LOG_(INFO) << "SetWindowAnchorInfo: SetWindowAnchorInfo end"; } /** * @tc.name: SetWindowTransitionAnimation * @tc.desc: sessionStub sessionStubTest * @tc.type: FUNC * @tc.require: #I6JLSI */ HWTEST_F(SessionProxyTest, SetWindowTransitionAnimation, Function | SmallTest | Level2) { GTEST_LOG_(INFO) << "SetWindowTransitionAnimation: SetWindowTransitionAnimation start"; auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); auto sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); TransitionAnimation animation; WSError res = sProxy->SetWindowTransitionAnimation(WindowTransitionType::DESTROY, animation); ASSERT_EQ(res, WSError::WS_OK); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); res = sProxy->SetWindowTransitionAnimation(WindowTransitionType::DESTROY, animation); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); MockMessageParcel::SetWriteUint32ErrorFlag(true); res = sProxy->SetWindowTransitionAnimation(WindowTransitionType::DESTROY, animation); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); MockMessageParcel::SetWriteUint32ErrorFlag(false); MockMessageParcel::SetWriteParcelableErrorFlag(true); res = sProxy->SetWindowTransitionAnimation(WindowTransitionType::DESTROY, animation); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); MockMessageParcel::SetWriteParcelableErrorFlag(false); MockMessageParcel::SetReadInt32ErrorFlag(true); res = sProxy->SetWindowTransitionAnimation(WindowTransitionType::DESTROY, animation); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); MockMessageParcel::SetReadInt32ErrorFlag(false); MockMessageParcel::ClearAllErrorFlag(); GTEST_LOG_(INFO) << "SetWindowTransitionAnimation: SetWindowTransitionAnimation end"; } /** * @tc.name: GetGlobalScaledRect * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, GetGlobalScaledRect, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: GetGlobalScaledRect start"; Rect rect; sptr remoteMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(remoteMocker); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); WMError res = sProxy->GetGlobalScaledRect(rect); ASSERT_EQ(res, WMError::WM_ERROR_IPC_FAILED); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); sptr tempProxy = sptr::MakeSptr(nullptr); res = tempProxy->GetGlobalScaledRect(rect); ASSERT_EQ(res, WMError::WM_ERROR_IPC_FAILED); remoteMocker->SetRequestResult(ERR_INVALID_DATA); res = sProxy->GetGlobalScaledRect(rect); ASSERT_EQ(res, WMError::WM_ERROR_IPC_FAILED); remoteMocker->SetRequestResult(ERR_NONE); MockMessageParcel::SetReadInt32ErrorFlag(true); MockMessageParcel::SetReadUint32ErrorFlag(true); res = sProxy->GetGlobalScaledRect(rect); ASSERT_EQ(res, WMError::WM_ERROR_IPC_FAILED); MockMessageParcel::ClearAllErrorFlag(); res = sProxy->GetGlobalScaledRect(rect); ASSERT_EQ(res, WMError::WM_OK); GTEST_LOG_(INFO) << "SessionProxyTest: GetGlobalScaledRect end"; } /** * @tc.name: GetStatusBarHeight * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, GetStatusBarHeight, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: GetStatusBarHeight start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); int32_t res = sProxy->GetStatusBarHeight(); ASSERT_EQ(res, 0); GTEST_LOG_(INFO) << "SessionProxyTest: GetStatusBarHeight end"; } /** * @tc.name: SetDialogSessionBackGestureEnabled * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, SetDialogSessionBackGestureEnabled, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: SetDialogSessionBackGestureEnabled start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); WSError res = sProxy->SetDialogSessionBackGestureEnabled(true); ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: SetDialogSessionBackGestureEnabled end"; } /** * @tc.name: GetAppForceLandscapeConfig * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, GetAppForceLandscapeConfig, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: GetAppForceLandscapeConfig start"; auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); auto sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); AppForceLandscapeConfig config = {}; auto res = sProxy->GetAppForceLandscapeConfig(config); ASSERT_EQ(res, WMError::WM_OK); GTEST_LOG_(INFO) << "SessionProxyTest: GetAppForceLandscapeConfig end"; } /** * @tc.name: NotifyExtensionEventAsync * @tc.desc: NotifyExtensionEventAsync test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, NotifyExtensionEventAsync, TestSize.Level1) { auto sProxy = sptr::MakeSptr(nullptr); ASSERT_NE(sProxy, nullptr); sProxy->NotifyExtensionEventAsync(0); auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); sProxy->NotifyExtensionEventAsync(0); MockMessageParcel::SetWriteUint32ErrorFlag(true); sProxy->NotifyExtensionEventAsync(0); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); sProxy->NotifyExtensionEventAsync(0); MockMessageParcel::ClearAllErrorFlag(); } /** * @tc.name: RequestFocus * @tc.desc: RequestFocus Test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, RequestFocus, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: RequestFocus start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); auto sProxy = sptr::MakeSptr(iRemoteObjectMocker); WSError res = sProxy->RequestFocus(true); ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: RequestFocus end"; } /** * @tc.name: UpdateClientRect01 * @tc.desc: UpdateClientRect test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, UpdateClientRect01, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: UpdateClientRect01 start"; auto sProxy = sptr::MakeSptr(nullptr); WSRect rect = { 200, 200, 200, 200 }; ASSERT_EQ(sProxy->UpdateClientRect(rect), WSError::WS_ERROR_IPC_FAILED); auto iRemoteObjectMocker = sptr::MakeSptr(); sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_EQ(sProxy->UpdateClientRect(rect), WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: UpdateClientRect01 start"; } /** * @tc.name: TransferExtensionData * @tc.desc: TransferExtensionData test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, TransferExtensionData, TestSize.Level1) { auto sProxy = sptr::MakeSptr(nullptr); ASSERT_NE(sProxy, nullptr); AAFwk::WantParams wantParams; auto res = sProxy->TransferExtensionData(wantParams); ASSERT_EQ(res, IPC_PROXY_ERR); auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); res = sProxy->TransferExtensionData(wantParams); ASSERT_EQ(res, ERR_NONE); MockMessageParcel::SetWriteParcelableErrorFlag(true); res = sProxy->TransferExtensionData(wantParams); ASSERT_EQ(res, IPC_PROXY_ERR); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); res = sProxy->TransferExtensionData(wantParams); ASSERT_EQ(res, IPC_PROXY_ERR); MockMessageParcel::ClearAllErrorFlag(); } /** * @tc.name: NotifyAsyncOn * @tc.desc: NotifyAsyncOn test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, NotifyAsyncOn, TestSize.Level1) { auto sProxy = sptr::MakeSptr(nullptr); ASSERT_NE(sProxy, nullptr); sProxy->NotifyAsyncOn(); auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); sProxy->NotifyAsyncOn(); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); sProxy->NotifyAsyncOn(); MockMessageParcel::ClearAllErrorFlag(); } /** * @tc.name: OnSetWindowRectAutoSave * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, OnSetWindowRectAutoSave, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: OnSetWindowRectAutoSave start"; auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); auto sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); WSError res = sProxy->OnSetWindowRectAutoSave(true, false); ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: OnSetWindowRectAutoSave end"; } /** * @tc.name: NotifyMainModalTypeChange * @tc.desc: NotifyMainModalTypeChange test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, NotifyMainModalTypeChange, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: NotifyMainModalTypeChange start"; auto sProxy = sptr::MakeSptr(nullptr); ASSERT_EQ(sProxy->NotifyMainModalTypeChange(true), WSError::WS_ERROR_IPC_FAILED); auto iRemoteObjectMocker = sptr::MakeSptr(); sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_EQ(sProxy->NotifyMainModalTypeChange(true), WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: NotifyMainModalTypeChange end"; } /** * @tc.name: Foreground * @tc.desc: Foreground test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, Foreground, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: Foreground start"; sptr sProxy = sptr::MakeSptr(nullptr); ASSERT_NE(sProxy, nullptr); sptr property = sptr::MakeSptr(); ASSERT_NE(property, nullptr); bool isFromClient = true; std::string identityToken = "foregroundTest"; WSError ret = sProxy->Foreground(property, isFromClient, identityToken); ASSERT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); GTEST_LOG_(INFO) << "SessionProxyTest: Foreground end"; } /** * @tc.name: Foreground02 * @tc.desc: Foreground test property is nullptr * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, Foreground02, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: Foreground02 start"; sptr sProxy = sptr::MakeSptr(nullptr); ASSERT_NE(sProxy, nullptr); bool isFromClient = true; std::string identityToken = "foregroundTest"; WSError ret = sProxy->Foreground(nullptr, isFromClient, identityToken); ASSERT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); GTEST_LOG_(INFO) << "SessionProxyTest: Foreground02 end"; } /** * @tc.name: Foreground03 * @tc.desc: Foreground test isFromClient is false * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, Foreground03, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: Foreground03 start"; sptr sProxy = sptr::MakeSptr(nullptr); ASSERT_NE(sProxy, nullptr); sptr property = sptr::MakeSptr(); ASSERT_NE(property, nullptr); bool isFromClient = false; std::string identityToken = "foregroundTest"; WSError ret = sProxy->Foreground(property, isFromClient, identityToken); ASSERT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); GTEST_LOG_(INFO) << "SessionProxyTest: Foreground03 end"; } /** * @tc.name: Background * @tc.desc: Background test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, Background, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: Background start"; sptr sProxy = sptr::MakeSptr(nullptr); ASSERT_NE(sProxy, nullptr); bool isFromClient = true; std::string identityToken = "backgroundTest"; WSError ret = sProxy->Background(isFromClient, identityToken); ASSERT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); GTEST_LOG_(INFO) << "SessionProxyTest: Background end"; } /** * @tc.name: Background02 * @tc.desc: Background test isFromClient is false * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, Background02, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: Background02 start"; sptr sProxy = sptr::MakeSptr(nullptr); ASSERT_NE(sProxy, nullptr); bool isFromClient = false; std::string identityToken = "backgroundTest"; WSError ret = sProxy->Background(isFromClient, identityToken); ASSERT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); GTEST_LOG_(INFO) << "SessionProxyTest: Background02 end"; } /** * @tc.name: Show * @tc.desc: Show Test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, Show, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: Show start"; sptr sProxy = sptr::MakeSptr(nullptr); ASSERT_NE(sProxy, nullptr); sptr property = sptr::MakeSptr(); WSError ret = sProxy->Show(property); ASSERT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); // property is nullptr ret = sProxy->Show(nullptr); ASSERT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); GTEST_LOG_(INFO) << "SessionProxyTest: Show end"; } /** * @tc.name: Hide * @tc.desc: Hide Test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, Hide, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: Hide start"; sptr sProxy = sptr::MakeSptr(nullptr); ASSERT_NE(sProxy, nullptr); WSError ret = sProxy->Hide(); ASSERT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); GTEST_LOG_(INFO) << "SessionProxyTest: Hide end"; } /** * @tc.name: Disconnect * @tc.desc: Disconnect Test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, Disconnect, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: Disconnect start"; sptr sProxy = sptr::MakeSptr(nullptr); ASSERT_NE(sProxy, nullptr); bool isFromClient = true; std::string identityToken = "disconnectTest"; WSError ret = sProxy->Disconnect(isFromClient, identityToken); ASSERT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); // isFromClient is false isFromClient = false; ret = sProxy->Disconnect(isFromClient, identityToken); ASSERT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); GTEST_LOG_(INFO) << "SessionProxyTest: Disconnect end"; } /** * @tc.name: DrawingCompleted * @tc.desc: DrawingCompleted Test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, DrawingCompleted, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: DrawingCompleted start"; sptr sProxy = sptr::MakeSptr(nullptr); ASSERT_NE(sProxy, nullptr); WSError ret = sProxy->DrawingCompleted(); ASSERT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); GTEST_LOG_(INFO) << "SessionProxyTest: DrawingCompleted end"; } /** * @tc.name: NotifySupportWindowModesChange * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, NotifySupportWindowModesChange, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: NotifySupportWindowModesChange start"; auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); auto sProxy = sptr::MakeSptr(iRemoteObjectMocker); std::vector supportedWindowModes = { AppExecFwk::SupportWindowMode::FULLSCREEN, AppExecFwk::SupportWindowMode::SPLIT, AppExecFwk::SupportWindowMode::FLOATING }; WSError res = sProxy->NotifySupportWindowModesChange(supportedWindowModes); ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: NotifySupportWindowModesChange end"; } /** * @tc.name: GetIsMidScene * @tc.desc: GetIsMidScene * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, GetIsMidScene, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: GetIsMidScene start"; sptr sProxy = sptr::MakeSptr(nullptr); bool isMidScene = false; WSError res = sProxy->GetIsMidScene(isMidScene); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); GTEST_LOG_(INFO) << "SessionProxyTest: GetIsMidScene end"; } /** * @tc.name: ChangeSessionVisibilityWithStatusBar * @tc.desc: ChangeSessionVisibilityWithStatusBar test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, ChangeSessionVisibilityWithStatusBar, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: ChangeSessionVisibilityWithStatusBar start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); bool visible = true; sptr abilitySessionInfo = sptr::MakeSptr(); WSError res = sProxy->ChangeSessionVisibilityWithStatusBar(abilitySessionInfo, visible); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); sProxy = sptr::MakeSptr(nullptr); res = sProxy->ChangeSessionVisibilityWithStatusBar(abilitySessionInfo, visible); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); abilitySessionInfo = nullptr; res = sProxy->ChangeSessionVisibilityWithStatusBar(abilitySessionInfo, visible); ASSERT_EQ(res, WSError::WS_ERROR_INVALID_SESSION); GTEST_LOG_(INFO) << "SessionProxyTest: ChangeSessionVisibilityWithStatusBar end"; } /** * @tc.name: SyncSessionEvent * @tc.desc: SyncSessionEvent test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, SyncSessionEvent, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: SyncSessionEvent start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); SessionEvent event = SessionEvent::EVENT_MAXIMIZE; WSError res = sProxy->SyncSessionEvent(event); ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: SyncSessionEvent end"; } /** * @tc.name: OnLayoutFullScreenChange * @tc.desc: OnLayoutFullScreenChange test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, OnLayoutFullScreenChange, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: OnLayoutFullScreenChange start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); bool isLayoutFullScreen = true; WSError res = sProxy->OnLayoutFullScreenChange(isLayoutFullScreen); ASSERT_EQ(res, WSError::WS_OK); sProxy = sptr::MakeSptr(nullptr); res = sProxy->OnLayoutFullScreenChange(isLayoutFullScreen); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); GTEST_LOG_(INFO) << "SessionProxyTest: OnLayoutFullScreenChange end"; } /** * @tc.name: OnDefaultDensityEnabled * @tc.desc: OnDefaultDensityEnabled test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, OnDefaultDensityEnabled, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: OnDefaultDensityEnabled start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); bool isDefaultDensityEnabled = true; WSError res = sProxy->OnDefaultDensityEnabled(isDefaultDensityEnabled); ASSERT_EQ(res, WSError::WS_OK); sProxy = sptr::MakeSptr(nullptr); res = sProxy->OnDefaultDensityEnabled(isDefaultDensityEnabled); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); GTEST_LOG_(INFO) << "SessionProxyTest: OnDefaultDensityEnabled end"; } /** * @tc.name: NotifyFrameLayoutFinishFromApp * @tc.desc: NotifyFrameLayoutFinishFromApp test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, NotifyFrameLayoutFinishFromApp, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: NotifyFrameLayoutFinishFromApp start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); bool notifyListener = true; WSRect rect = { 200, 200, 200, 200 }; WSError res = sProxy->NotifyFrameLayoutFinishFromApp(notifyListener, rect); ASSERT_EQ(res, WSError::WS_OK); sProxy = sptr::MakeSptr(nullptr); res = sProxy->NotifyFrameLayoutFinishFromApp(notifyListener, rect); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); GTEST_LOG_(INFO) << "SessionProxyTest: NotifyFrameLayoutFinishFromApp end"; } /** * @tc.name: NotifySnapshotUpdate * @tc.desc: NotifySnapshotUpdate test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, NotifySnapshotUpdate, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: NotifySnapshotUpdate start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); WMError res = sProxy->NotifySnapshotUpdate(); EXPECT_EQ(res, WMError::WM_OK); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); res = sProxy->NotifySnapshotUpdate(); EXPECT_EQ(res, WMError::WM_ERROR_IPC_FAILED); MockMessageParcel::ClearAllErrorFlag(); sProxy = sptr::MakeSptr(nullptr); res = sProxy->NotifySnapshotUpdate(); EXPECT_EQ(res, WMError::WM_ERROR_IPC_FAILED); GTEST_LOG_(INFO) << "SessionProxyTest: NotifySnapshotUpdate end"; } /** * @tc.name: RaiseAppMainWindowToTop * @tc.desc: RaiseAppMainWindowToTop test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, RaiseAppMainWindowToTop, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: RaiseAppMainWindowToTop start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); WSError res = sProxy->RaiseAppMainWindowToTop(); ASSERT_EQ(res, WSError::WS_OK); sProxy = sptr::MakeSptr(nullptr); res = sProxy->RaiseAppMainWindowToTop(); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); GTEST_LOG_(INFO) << "SessionProxyTest: RaiseAppMainWindowToTop end"; } /** * @tc.name: GetAllAvoidAreas * @tc.desc: GetAllAvoidAreas test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, GetAllAvoidAreas, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: GetAllAvoidAreas start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); std::map avoidAreas; WSError res = sProxy->GetAllAvoidAreas(avoidAreas); ASSERT_EQ(res, WSError::WS_OK); sProxy = sptr::MakeSptr(nullptr); res = sProxy->GetAllAvoidAreas(avoidAreas); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); GTEST_LOG_(INFO) << "SessionProxyTest: GetAllAvoidAreas end"; } /** * @tc.name: SetLandscapeMultiWindow * @tc.desc: SetLandscapeMultiWindow test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, SetLandscapeMultiWindow, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: SetLandscapeMultiWindow start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); bool isLandscapeMultiWindow = true; WSError res = sProxy->SetLandscapeMultiWindow(isLandscapeMultiWindow); ASSERT_EQ(res, WSError::WS_OK); sProxy = sptr::MakeSptr(nullptr); res = sProxy->SetLandscapeMultiWindow(isLandscapeMultiWindow); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); GTEST_LOG_(INFO) << "SessionProxyTest: SetLandscapeMultiWindow end"; } /** * @tc.name: NotifySyncOn * @tc.desc: NotifySyncOn test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, NotifySyncOn, TestSize.Level1) { auto sProxy = sptr::MakeSptr(nullptr); ASSERT_NE(sProxy, nullptr); sProxy->NotifySyncOn(); auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); sProxy->NotifySyncOn(); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); sProxy->NotifySyncOn(); MockMessageParcel::ClearAllErrorFlag(); } /** * @tc.name: TriggerBindModalUIExtension * @tc.desc: TriggerBindModalUIExtension test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, TriggerBindModalUIExtension, TestSize.Level1) { auto sProxy = sptr::MakeSptr(nullptr); ASSERT_NE(sProxy, nullptr); sProxy->TriggerBindModalUIExtension(); auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); sProxy->TriggerBindModalUIExtension(); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); sProxy->TriggerBindModalUIExtension(); MockMessageParcel::ClearAllErrorFlag(); } /** * @tc.name: NotifyPiPWindowPrepareClose * @tc.desc: NotifyPiPWindowPrepareClose test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, NotifyPiPWindowPrepareClose, TestSize.Level1) { auto sProxy = sptr::MakeSptr(nullptr); ASSERT_NE(sProxy, nullptr); sProxy->NotifyPiPWindowPrepareClose(); auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); sProxy->NotifyPiPWindowPrepareClose(); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); sProxy->NotifyPiPWindowPrepareClose(); MockMessageParcel::ClearAllErrorFlag(); } /** * @tc.name: UpdatePiPRect * @tc.desc: UpdatePiPRect test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, UpdatePiPRect, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: UpdatePiPRect start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); Rect rect = { 200, 200, 200, 200 }; SizeChangeReason reason = SizeChangeReason::UNDEFINED; WSError res = sProxy->UpdatePiPRect(rect, reason); ASSERT_EQ(res, WSError::WS_OK); sProxy = sptr::MakeSptr(nullptr); res = sProxy->UpdatePiPRect(rect, reason); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); GTEST_LOG_(INFO) << "SessionProxyTest: UpdatePiPRect end"; } /** * @tc.name: SetSessionLabelAndIcon * @tc.desc: SetSessionLabelAndIcon * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, SetSessionLabelAndIcon, TestSize.Level1) { std::string label = "SetSessionLabelAndIcon"; std::shared_ptr icon = std::make_shared(); sptr sProxy = sptr::MakeSptr(nullptr); ASSERT_EQ(WSError::WS_ERROR_IPC_FAILED, sProxy->SetSessionLabelAndIcon(label, icon)); } /** * @tc.name: UpdateFlag * @tc.desc: UpdateFlag * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, UpdateFlag, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: UpdateFlag start"; auto iRemoteObjectMocker = sptr::MakeSptr(); auto sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); std::string flag = "test"; WSError res = sProxy->UpdateFlag(flag); ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: UpdateFlag end"; } /** * @tc.name: ProcessPointDownSession * @tc.desc: ProcessPointDownSession test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, ProcessPointDownSession, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: ProcessPointDownSession start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); int32_t posX = 50; int32_t posY = 50; WSError res = sProxy->ProcessPointDownSession(posX, posY); ASSERT_EQ(res, WSError::WS_OK); sProxy = sptr::MakeSptr(nullptr); res = sProxy->ProcessPointDownSession(posX, posY); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); GTEST_LOG_(INFO) << "SessionProxyTest: ProcessPointDownSession end"; } /** * @tc.name: SendPointEventForMoveDrag * @tc.desc: SendPointEventForMoveDrag test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, SendPointEventForMoveDrag, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: SendPointEventForMoveDrag start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); bool isExecuteDelayRaise = true; WSError res = sProxy->SendPointEventForMoveDrag(pointerEvent, isExecuteDelayRaise); ASSERT_EQ(res, WSError::WS_OK); sProxy = sptr::MakeSptr(nullptr); res = sProxy->SendPointEventForMoveDrag(pointerEvent, isExecuteDelayRaise); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); GTEST_LOG_(INFO) << "SessionProxyTest: SendPointEventForMoveDrag end"; } /** * @tc.name: IsStartMoving * @tc.desc: IsStartMoving test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, IsStartMoving, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: IsStartMoving start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); bool res = sProxy->IsStartMoving(); ASSERT_EQ(res, false); sProxy = sptr::MakeSptr(nullptr); res = sProxy->IsStartMoving(); ASSERT_EQ(res, false); GTEST_LOG_(INFO) << "SessionProxyTest: IsStartMoving end"; } /** * @tc.name: UpdateRectChangeListenerRegistered * @tc.desc: UpdateRectChangeListenerRegistered test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, UpdateRectChangeListenerRegistered, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: UpdateRectChangeListenerRegistered start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); bool isRegister = true; WSError res = sProxy->UpdateRectChangeListenerRegistered(isRegister); ASSERT_EQ(res, WSError::WS_OK); sProxy = sptr::MakeSptr(nullptr); res = sProxy->UpdateRectChangeListenerRegistered(isRegister); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); GTEST_LOG_(INFO) << "SessionProxyTest: UpdateRectChangeListenerRegistered end"; } /** * @tc.name: SendExtensionData * @tc.desc: SendExtensionData test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, SendExtensionData, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: SendExtensionData start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); MessageParcel data; MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); WSError res = sProxy->SendExtensionData(data, reply, option); ASSERT_EQ(res, WSError::WS_OK); sProxy = sptr::MakeSptr(nullptr); res = sProxy->SendExtensionData(data, reply, option); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); GTEST_LOG_(INFO) << "SessionProxyTest: SendExtensionData end"; } /** * @tc.name: SetGestureBackEnabled * @tc.desc: SetGestureBackEnabled test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, SetGestureBackEnabled, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: SetGestureBackEnabled start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); bool isEnabled = true; WMError res = sProxy->SetGestureBackEnabled(isEnabled); ASSERT_EQ(res, WMError::WM_OK); sProxy = sptr::MakeSptr(nullptr); res = sProxy->SetGestureBackEnabled(isEnabled); ASSERT_EQ(res, WMError::WM_ERROR_IPC_FAILED); GTEST_LOG_(INFO) << "SessionProxyTest: SetGestureBackEnabled end"; } /** * @tc.name: NotifySubModalTypeChange * @tc.desc: NotifySubModalTypeChange test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, NotifySubModalTypeChange, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: NotifySubModalTypeChange start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); SubWindowModalType subWindowModalType = SubWindowModalType::TYPE_APPLICATION_MODALITY; WSError res = sProxy->NotifySubModalTypeChange(subWindowModalType); ASSERT_EQ(res, WSError::WS_OK); sProxy = sptr::MakeSptr(nullptr); res = sProxy->NotifySubModalTypeChange(subWindowModalType); ASSERT_EQ(res, WSError::WS_ERROR_IPC_FAILED); GTEST_LOG_(INFO) << "SessionProxyTest: NotifySubModalTypeChange end"; } /** * @tc.name: GetCrossAxisState * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, GetCrossAxisState, TestSize.Level1) { auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); auto sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); CrossAxisState state = CrossAxisState::STATE_CROSS; WSError res = sProxy->GetCrossAxisState(state); ASSERT_EQ(res, WSError::WS_OK); } /** * @tc.name: OnContainerModalEvent * @tc.desc: OnContainerModalEvent Test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, OnContainerModalEvent, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: OnContainerModalEvent start"; auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); auto sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); WSError res = sProxy->OnContainerModalEvent("name", "value"); ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: OnContainerModalEvent end"; } /** * @tc.name: GetWaterfallMode * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, GetWaterfallMode, TestSize.Level1) { auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); auto sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); bool isWaterfallMode = false; WSError res = sProxy->GetWaterfallMode(isWaterfallMode); ASSERT_EQ(res, WSError::WS_OK); } /** * @tc.name: NotifyFollowParentMultiScreenPolicy * @tc.desc: NotifyFollowParentMultiScreenPolicy test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, NotifyFollowParentMultiScreenPolicy, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: NotifyFollowParentMultiScreenPolicy start"; auto sProxy = sptr::MakeSptr(nullptr); ASSERT_EQ(sProxy->NotifyFollowParentMultiScreenPolicy(true), WSError::WS_ERROR_IPC_FAILED); auto iRemoteObjectMocker = sptr::MakeSptr(); sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_EQ(sProxy->NotifyFollowParentMultiScreenPolicy(true), WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: NotifyFollowParentMultiScreenPolicy end"; } /** * @tc.name: UpdateRotationChangeRegistered * @tc.desc: UpdateRotationChangeRegistered test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, UpdateRotationChangeRegistered, Function | SmallTest | Level2) { GTEST_LOG_(INFO) << "SessionProxyTest: UpdateRotationChangeRegistered start"; auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); auto sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); WSError res = sProxy->UpdateRotationChangeRegistered(0, false); ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: UpdateRotationChangeRegistered start"; } /** * @tc.name: UpdateScreenshotAppEventRegistered * @tc.desc: UpdateScreenshotAppEventRegistered test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, UpdateScreenshotAppEventRegistered, Function | SmallTest | Level2) { MockMessageParcel::ClearAllErrorFlag(); auto sProxy = sptr::MakeSptr(nullptr); ASSERT_NE(sProxy, nullptr); auto ret = sProxy->UpdateScreenshotAppEventRegistered(0, true); EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); ret = sProxy->UpdateScreenshotAppEventRegistered(0, true); EXPECT_EQ(ret, WMError::WM_OK); MockMessageParcel::SetReadInt32ErrorFlag(true); ret = sProxy->UpdateScreenshotAppEventRegistered(0, true); EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); MockMessageParcel::SetWriteBoolErrorFlag(true); ret = sProxy->UpdateScreenshotAppEventRegistered(0, true); EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); MockMessageParcel::SetWriteInt32ErrorFlag(true); ret = sProxy->UpdateScreenshotAppEventRegistered(0, true); EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); ret = sProxy->UpdateScreenshotAppEventRegistered(0, true); EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); MockMessageParcel::ClearAllErrorFlag(); } /** * @tc.name: UpdateAcrossDisplaysChangeRegistered * @tc.desc: UpdateAcrossDisplaysChangeRegistered test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, UpdateAcrossDisplaysChangeRegistered, Function | SmallTest | Level2) { MockMessageParcel::ClearAllErrorFlag(); auto sProxy = sptr::MakeSptr(nullptr); ASSERT_NE(sProxy, nullptr); auto ret = sProxy->UpdateAcrossDisplaysChangeRegistered(true); EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); sptr remoteMocker = sptr::MakeSptr(); sProxy = sptr::MakeSptr(remoteMocker); ASSERT_NE(sProxy, nullptr); ret = sProxy->UpdateAcrossDisplaysChangeRegistered(true); EXPECT_EQ(ret, WMError::WM_OK); MockMessageParcel::SetReadInt32ErrorFlag(true); ret = sProxy->UpdateAcrossDisplaysChangeRegistered(true); EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); remoteMocker->SetRequestResult(ERR_INVALID_DATA); ret = sProxy->UpdateAcrossDisplaysChangeRegistered(true); EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); remoteMocker->SetRequestResult(ERR_NONE); MockMessageParcel::SetWriteBoolErrorFlag(true); ret = sProxy->UpdateAcrossDisplaysChangeRegistered(true); EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); ret = sProxy->UpdateAcrossDisplaysChangeRegistered(true); EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); MockMessageParcel::ClearAllErrorFlag(); } /** * @tc.name: UpdateAcrossDisplaysChangeRegistered * @tc.desc: UpdateAcrossDisplaysChangeRegistered test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, IsMainWindowFullScreenAcrossDisplays, Function | SmallTest | Level2) { bool isAcrossDisplays = false; MockMessageParcel::ClearAllErrorFlag(); auto sProxy = sptr::MakeSptr(nullptr); ASSERT_NE(sProxy, nullptr); auto ret = sProxy->IsMainWindowFullScreenAcrossDisplays(isAcrossDisplays); EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); sptr remoteMocker = sptr::MakeSptr(); sProxy = sptr::MakeSptr(remoteMocker); ASSERT_NE(sProxy, nullptr); ret = sProxy->IsMainWindowFullScreenAcrossDisplays(isAcrossDisplays); EXPECT_EQ(ret, WMError::WM_OK); MockMessageParcel::SetReadInt32ErrorFlag(true); ret = sProxy->IsMainWindowFullScreenAcrossDisplays(isAcrossDisplays); EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); remoteMocker->SetRequestResult(ERR_INVALID_DATA); ret = sProxy->IsMainWindowFullScreenAcrossDisplays(isAcrossDisplays); EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); remoteMocker->SetRequestResult(ERR_NONE); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); ret = sProxy->IsMainWindowFullScreenAcrossDisplays(isAcrossDisplays); EXPECT_EQ(ret, WMError::WM_ERROR_IPC_FAILED); MockMessageParcel::ClearAllErrorFlag(); } /** * @tc.name: GetTargetOrientationConfigInfo * @tc.desc: GetTargetOrientationConfigInfo test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, GetTargetOrientationConfigInfo, Function | SmallTest | Level2) { auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); auto sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); std::map properties; Rosen::SystemBarProperty statusBarProperty; properties[Rosen::WindowType::WINDOW_TYPE_STATUS_BAR] = statusBarProperty; WSError res = sProxy->GetTargetOrientationConfigInfo(Orientation::USER_ROTATION_PORTRAIT, properties); ASSERT_EQ(res, WSError::WS_OK); } /** * @tc.name: KeyFrameAnimateEnd * @tc.desc: KeyFrameAnimateEnd test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, KeyFrameAnimateEnd, Function | SmallTest | Level2) { auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); auto sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); ASSERT_EQ(sProxy->KeyFrameAnimateEnd(), WSError::WS_OK); } /** * @tc.name: UpdateKeyFrameCloneNode * @tc.desc: UpdateKeyFrameCloneNode test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, UpdateKeyFrameCloneNode, Function | SmallTest | Level2) { auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); auto sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); auto rsCanvasNode = RSCanvasNode::Create(); ASSERT_NE(rsCanvasNode, nullptr); auto rsTransaction = std::make_shared(); ASSERT_NE(rsTransaction, nullptr); ASSERT_EQ(sProxy->UpdateKeyFrameCloneNode(rsCanvasNode, rsTransaction), WSError::WS_OK); } /** * @tc.name: GetIsHighlighted * @tc.desc: GetIsHighlighted test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, GetIsHighlighted, Function | SmallTest | Level2) { auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); auto sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); bool isHighlighted = false; ASSERT_EQ(sProxy->GetIsHighlighted(isHighlighted), WSError::WS_OK); } /** * @tc.name: SetSubWindowSource * @tc.desc: SetSubWindowSource test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, SetSubWindowSource, Function | SmallTest | Level2) { sptr remoteMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(remoteMocker); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); auto res = sProxy->SetSubWindowSource(SubWindowSource::SUB_WINDOW_SOURCE_UNKNOWN); EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); sptr tempProxy = sptr::MakeSptr(nullptr); res = tempProxy->SetSubWindowSource(SubWindowSource::SUB_WINDOW_SOURCE_UNKNOWN); EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); remoteMocker->SetRequestResult(1); res = sProxy->SetSubWindowSource(SubWindowSource::SUB_WINDOW_SOURCE_UNKNOWN); EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); remoteMocker->SetRequestResult(0); SubWindowSource source = SubWindowSource::SUB_WINDOW_SOURCE_UNKNOWN; EXPECT_EQ(sProxy->SetSubWindowSource(source), WSError::WS_OK); } /** * @tc.name: StartMovingWithCoordinate * @tc.desc: StartMovingWithCoordinate test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, StartMovingWithCoordinate, TestSize.Level2) { sptr remoteMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(remoteMocker); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); WSError res = sProxy->StartMovingWithCoordinate(0, 0, 0, 0, 0); EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); sptr tempProxy = sptr::MakeSptr(nullptr); res = tempProxy->StartMovingWithCoordinate(0, 0, 0, 0, 0); EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); remoteMocker->SetRequestResult(ERR_INVALID_DATA); res = sProxy->StartMovingWithCoordinate(0, 0, 0, 0, 0); EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); remoteMocker->SetRequestResult(ERR_NONE); MockMessageParcel::SetReadInt32ErrorFlag(true); res = sProxy->StartMovingWithCoordinate(0, 0, 0, 0, 0); EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); MockMessageParcel::SetReadInt32ErrorFlag(false); MockMessageParcel::SetWriteUint64ErrorFlag(true); res = sProxy->StartMovingWithCoordinate(0, 0, 0, 0, 0); EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); MockMessageParcel::SetWriteUint64ErrorFlag(false); MockMessageParcel::ClearAllErrorFlag(); res = sProxy->StartMovingWithCoordinate(-1, 0, 0, 0, 0); EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); res = sProxy->StartMovingWithCoordinate(0, -1, 0, 0, 0); EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); res = sProxy->StartMovingWithCoordinate(0, 0, -1, 0, 0); EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); res = sProxy->StartMovingWithCoordinate(0, 0, 0, -1, 0); EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); res = sProxy->StartMovingWithCoordinate(0, 0, 0, 0, 0); EXPECT_EQ(res, WSError::WS_OK); } /** * @tc.name: SetFrameRectForPartialZoomIn * @tc.desc: SetFrameRectForPartialZoomIn test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, SetFrameRectForPartialZoomIn, Function | SmallTest | Level2) { sptr remoteMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(remoteMocker); Rect frameRect; WSError res = sProxy->SetFrameRectForPartialZoomIn(frameRect); EXPECT_EQ(res, WSError::WS_OK); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); res = sProxy->SetFrameRectForPartialZoomIn(frameRect); EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); MockMessageParcel::SetWriteInt32ErrorFlag(true); res = sProxy->SetFrameRectForPartialZoomIn(frameRect); EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); MockMessageParcel::SetWriteInt32ErrorFlag(false); MockMessageParcel::SetWriteUint32ErrorFlag(true); res = sProxy->SetFrameRectForPartialZoomIn(frameRect); EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); MockMessageParcel::SetWriteUint32ErrorFlag(false); MockMessageParcel::SetReadInt32ErrorFlag(true); res = sProxy->SetFrameRectForPartialZoomIn(frameRect); EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); MockMessageParcel::SetReadInt32ErrorFlag(false); remoteMocker->SetRequestResult(ERR_INVALID_DATA); res = sProxy->SetFrameRectForPartialZoomIn(frameRect); EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); remoteMocker->SetRequestResult(ERR_NONE); MockMessageParcel::ClearAllErrorFlag(); } /** * @tc.name: SetFrameRectForPartialZoomIn01 * @tc.desc: SetFrameRectForPartialZoomIn test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, SetFrameRectForPartialZoomIn01, Function | SmallTest | Level2) { Rect frameRect; auto sProxy = sptr::MakeSptr(nullptr); WSError res = sProxy->SetFrameRectForPartialZoomIn(frameRect); EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); } /** * @tc.name: ChangeKeyboardEffectOption01 * @tc.desc: ChangeKeyboardEffectOption test * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, ChangeKeyboardEffectOption01, Function | SmallTest | Level2) { KeyboardEffectOption effectOption; auto sProxy = sptr::MakeSptr(nullptr); WSError res = sProxy->ChangeKeyboardEffectOption(effectOption); EXPECT_EQ(res, WSError::WS_ERROR_IPC_FAILED); } /** * @tc.name: UpdateFloatingBall * @tc.desc: UpdateFloatingBall * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, UpdateFloatingBall, Function | SmallTest | Level2) { auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); auto sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); FloatingBallTemplateInfo fbTemplateInfo; MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); WMError res = sProxy->UpdateFloatingBall(fbTemplateInfo); ASSERT_EQ(res, WMError::WM_ERROR_IPC_FAILED); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); res = sProxy->UpdateFloatingBall(fbTemplateInfo); ASSERT_EQ(res, WMError::WM_OK); MockMessageParcel::SetWriteParcelableErrorFlag(true); ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sProxy->UpdateFloatingBall(fbTemplateInfo)); MockMessageParcel::SetWriteParcelableErrorFlag(false); sProxy = sptr::MakeSptr(nullptr); ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sProxy->UpdateFloatingBall(fbTemplateInfo)); iRemoteObjectMocker->sendRequestResult_ = 1; sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sProxy->UpdateFloatingBall(fbTemplateInfo)); } /** * @tc.name: RestoreFbMainWindow * @tc.desc: RestoreFbMainWindow * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, RestoreFbMainWindow, Function | SmallTest | Level2) { auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); auto want = std::make_shared(); ASSERT_NE(want, nullptr); auto sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sProxy->RestoreFbMainWindow(want)); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); MockMessageParcel::SetWriteParcelableErrorFlag(true); ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sProxy->RestoreFbMainWindow(want)); MockMessageParcel::SetWriteParcelableErrorFlag(false); WMError res = sProxy->RestoreFbMainWindow(want); ASSERT_EQ(res, WMError::WM_OK); sProxy = sptr::MakeSptr(nullptr); ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sProxy->RestoreFbMainWindow(want)); iRemoteObjectMocker->sendRequestResult_ = 1; sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sProxy->RestoreFbMainWindow(want)); } /** * @tc.name: GetFloatingBallWindowId * @tc.desc: GetFloatingBallWindowId * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, GetFloatingBallWindowId, Function | SmallTest | Level2) { auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); auto sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); uint32_t windowId = 0; MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sProxy->GetFloatingBallWindowId(windowId)); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); WMError res = sProxy->GetFloatingBallWindowId(windowId); ASSERT_EQ(res, WMError::WM_OK); sProxy = sptr::MakeSptr(nullptr); ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sProxy->GetFloatingBallWindowId(windowId)); iRemoteObjectMocker->sendRequestResult_ = 1; sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sProxy->GetFloatingBallWindowId(windowId)); } /** * @tc.name: NotifyFloatingBallPrepareClose * @tc.desc: NotifyFloatingBallPrepareClose * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, NotifyFloatingBallPrepareClose, Function | SmallTest | Level2) { auto iRemoteObjectMocker = sptr::MakeSptr(); ASSERT_NE(iRemoteObjectMocker, nullptr); auto sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); sProxy->NotifyFloatingBallPrepareClose(); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); sProxy->NotifyFloatingBallPrepareClose(); sProxy = sptr::MakeSptr(nullptr); sProxy->NotifyFloatingBallPrepareClose(); iRemoteObjectMocker->sendRequestResult_ = 1; sProxy = sptr::MakeSptr(iRemoteObjectMocker); sProxy->NotifyFloatingBallPrepareClose(); } /** * @tc.name: TestUpdateGlobalDisplayRectFromClient * @tc.desc: Test UpdateGlobalDisplayRectFromClient behavior in various IPC scenarios * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, TestUpdateGlobalDisplayRectFromClient, Function | SmallTest | Level1) { auto mockRemote = sptr::MakeSptr(); auto sessionProxy = sptr::MakeSptr(mockRemote); WSRect rect { 10, 20, 200, 100 }; SizeChangeReason reason = SizeChangeReason::UNDEFINED; // Case 1: Failed to write interface token MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); EXPECT_EQ(WSError::WS_ERROR_IPC_FAILED, sessionProxy->UpdateGlobalDisplayRectFromClient(rect, reason)); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); // Case 2: Failed to write rect MockMessageParcel::SetWriteInt32ErrorFlag(true); EXPECT_EQ(WSError::WS_ERROR_IPC_FAILED, sessionProxy->UpdateGlobalDisplayRectFromClient(rect, reason)); MockMessageParcel::SetWriteInt32ErrorFlag(false); // Case 3: Failed to write reason MockMessageParcel::SetWriteUint32ErrorFlag(true); EXPECT_EQ(WSError::WS_ERROR_IPC_FAILED, sessionProxy->UpdateGlobalDisplayRectFromClient(rect, reason)); MockMessageParcel::SetWriteUint32ErrorFlag(false); // Case 4: remote is nullptr sptr nullProxy = sptr::MakeSptr(nullptr); EXPECT_EQ(WSError::WS_ERROR_IPC_FAILED, nullProxy->UpdateGlobalDisplayRectFromClient(rect, reason)); // Case 5: Failed to send request mockRemote->sendRequestResult_ = ERR_TRANSACTION_FAILED; sptr failProxy = sptr::MakeSptr(mockRemote); EXPECT_EQ(WSError::WS_ERROR_IPC_FAILED, failProxy->UpdateGlobalDisplayRectFromClient(rect, reason)); // Case 6: Success mockRemote->sendRequestResult_ = ERR_NONE; sptr okProxy = sptr::MakeSptr(mockRemote); EXPECT_EQ(WSError::WS_OK, okProxy->UpdateGlobalDisplayRectFromClient(rect, reason)); } /** * @tc.name: GetAppHookWindowInfoFromServer * @tc.desc: normal function * @tc.type: FUNC */ HWTEST_F(SessionProxyTest, GetAppHookWindowInfoFromServer, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyTest: GetAppHookWindowInfoFromServer start"; auto mockRemote = sptr::MakeSptr(); auto sProxy = sptr::MakeSptr(mockRemote); MockMessageParcel::ClearAllErrorFlag(); HookWindowInfo hookWindowInfo; // Case 1: Failed to write interface token MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); EXPECT_EQ(WMError::WM_ERROR_IPC_FAILED, sProxy->GetAppHookWindowInfoFromServer(hookWindowInfo)); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); // Case 2: remote is nullptr sptr nullProxy = sptr::MakeSptr(nullptr); EXPECT_EQ(WMError::WM_ERROR_IPC_FAILED, nullProxy->GetAppHookWindowInfoFromServer(hookWindowInfo)); // Case 3: Failed to send request mockRemote->SetRequestResult(ERR_TRANSACTION_FAILED); sptr failSendRequestProxy = sptr::MakeSptr(mockRemote); EXPECT_EQ(WMError::WM_ERROR_IPC_FAILED, failSendRequestProxy->GetAppHookWindowInfoFromServer(hookWindowInfo)); mockRemote->SetRequestResult(ERR_NONE); // Case 4: Failed to read replyInfo and ret MockMessageParcel::SetReadBoolErrorFlag(true); MockMessageParcel::SetReadInt32ErrorFlag(true); EXPECT_EQ(WMError::WM_ERROR_IPC_FAILED, sProxy->GetAppHookWindowInfoFromServer(hookWindowInfo)); MockMessageParcel::SetReadBoolErrorFlag(false); MockMessageParcel::SetReadInt32ErrorFlag(false); // Case 5: Success sptr okProxy = sptr::MakeSptr(mockRemote); EXPECT_EQ(WMError::WM_OK, okProxy->GetAppHookWindowInfoFromServer(hookWindowInfo)); MockMessageParcel::ClearAllErrorFlag(); GTEST_LOG_(INFO) << "SessionProxyTest: GetAppHookWindowInfoFromServer end"; } } // namespace } // namespace Rosen } // namespace OHOS