From 2f6ebf783956770e62d6775f7829e1310e458889 Mon Sep 17 00:00:00 2001 From: wangh Date: Mon, 30 Oct 2023 20:06:19 +0800 Subject: [PATCH] add test for disable snapshot or mirror Signed-off-by: wangh --- .../unittest/display_manager_adapter_test.cpp | 31 +++++++++++++++ .../screen_session_manager_stub_test.cpp | 39 +++++++++++++++++++ .../unittest/screen_session_manager_test.cpp | 21 ++++++++++ 3 files changed, 91 insertions(+) diff --git a/dm/test/unittest/display_manager_adapter_test.cpp b/dm/test/unittest/display_manager_adapter_test.cpp index 43539c860f..4479c72717 100644 --- a/dm/test/unittest/display_manager_adapter_test.cpp +++ b/dm/test/unittest/display_manager_adapter_test.cpp @@ -229,6 +229,37 @@ HWTEST_F(DisplayManagerAdapterTest, Clear01, Function | SmallTest | Level2) SingletonContainer::Get().Clear(); ASSERT_FALSE(SingletonContainer::Get().isProxyValid_); } + +/** + * @tc.name: DisableDisplaySnapshot + * @tc.desc: DisableDisplaySnapshot test + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerAdapterTest, DisableDisplaySnapshot, Function | SmallTest | Level2) +{ + DMError ret = SingletonContainer::Get().DisableDisplaySnapshot(false); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_EQ(DMError::DM_OK, ret); + } else { + ASSERT_NE(DMError::DM_OK, ret); + } +} + +/** + * @tc.name: DisableMirror + * @tc.desc: DisableMirror test + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerAdapterTest, DisableMirror, Function | SmallTest | Level2) +{ + DMError ret = SingletonContainer::Get().DisableMirror(false); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_EQ(DMError::DM_OK, ret); + } else { + ASSERT_NE(DMError::DM_OK, ret); + } +} + } } } \ No newline at end of file diff --git a/window_scene/test/unittest/screen_session_manager_stub_test.cpp b/window_scene/test/unittest/screen_session_manager_stub_test.cpp index 62db41275a..5470e4bfdc 100644 --- a/window_scene/test/unittest/screen_session_manager_stub_test.cpp +++ b/window_scene/test/unittest/screen_session_manager_stub_test.cpp @@ -748,6 +748,45 @@ HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest30, Function | SmallTest | int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + +/** + * @tc.name: OnRemoteRequest31 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest31, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); + data.WriteBool(false); + uint32_t code = static_cast( + IDisplayManager::DisplayManagerMessage::TRANS_ID_DISABLE_DISPLAY_SNAPSHOT); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} + +/** + * @tc.name: OnRemoteRequest32 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest32, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); + data.WriteBool(false); + uint32_t code = static_cast( + IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_DISABLE_MIRROR); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} + } } } \ No newline at end of file diff --git a/window_scene/test/unittest/screen_session_manager_test.cpp b/window_scene/test/unittest/screen_session_manager_test.cpp index 1e3e7786df..fb13b74058 100644 --- a/window_scene/test/unittest/screen_session_manager_test.cpp +++ b/window_scene/test/unittest/screen_session_manager_test.cpp @@ -811,6 +811,27 @@ HWTEST_F(ScreenSessionManagerTest, MakeUniqueScreen, Function | SmallTest | Leve screenIds.clear(); ASSERT_EQ(DMError::DM_ERROR_INVALID_PARAM, ssm_->MakeUniqueScreen(screenIds)); } + +/** + * @tc.name: DisableDisplaySnapshot + * @tc.desc: DisableDisplaySnapshot test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, DisableDisplaySnapshot, Function | SmallTest | Level3) +{ + ASSERT_EQ(DMError::DM_OK, ssm_->DisableDisplaySnapshot(false)); +} + +/** + * @tc.name: DisableMirror + * @tc.desc: DisableMirror test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, DisableMirror, Function | SmallTest | Level3) +{ + ASSERT_EQ(DMError::DM_OK, ssm_->DisableMirror(false)); +} + } } // namespace Rosen } // namespace OHOS -- Gitee