From de5b417f04c64473fd65b668228d12cca4add358 Mon Sep 17 00:00:00 2001 From: pwx1285814 Date: Thu, 5 Sep 2024 12:41:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85UT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: pwx1285814 Change-Id: If9aef05d1a596e2cb8ac9e322260b2f74b37632f --- .../src/dscreen_source_handler_test.cpp | 24 +++++-------------- .../src/screen_client_window_adapter_test.cpp | 12 ++++++++++ .../src/screen_data_channel_impl_test.cpp | 16 +++++++++++++ .../src/image_sink_processor_test.cpp | 4 +++- 4 files changed, 37 insertions(+), 19 deletions(-) diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp index ed8856f2..3c5e50ef 100644 --- a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp +++ b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp @@ -357,26 +357,14 @@ HWTEST_F(DScreenSourceHandlerTest, OnRemoteDied_001, TestSize.Level1) { sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + sptr remoteObject1 = nullptr; + wptr remote1(remoteObject1); + DScreenSourceHandler::GetInstance().sourceSvrRecipient_->OnRemoteDied(remote1); - sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID); - wptr remote(remoteObject); - DScreenSourceHandler::GetInstance().sourceSvrRecipient_->OnRemoteDied(remote); + sptr remoteObject2 = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID); + wptr remote2(remoteObject2); + DScreenSourceHandler::GetInstance().sourceSvrRecipient_->OnRemoteDied(remote2); EXPECT_EQ(nullptr, DScreenSourceHandler::GetInstance().dScreenSourceProxy_); } - -/** - * @tc.name: OnRemoteDied_002 - * @tc.desc: Verify the OnRemoteDied function. - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(DScreenSourceHandlerTest, OnRemoteDied_002, TestSize.Level1) -{ - sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - sptr remoteObject = nullptr; - wptr remote(remoteObject); - DScreenSourceHandler::GetInstance().sourceSvrRecipient_->OnRemoteDied(remote); - EXPECT_EQ(remote, remote); -} } // namespace DistributedHardware } // namespace OHOS diff --git a/services/screenclient/test/unittest/src/screen_client_window_adapter_test.cpp b/services/screenclient/test/unittest/src/screen_client_window_adapter_test.cpp index 1f24b82e..e1358778 100644 --- a/services/screenclient/test/unittest/src/screen_client_window_adapter_test.cpp +++ b/services/screenclient/test/unittest/src/screen_client_window_adapter_test.cpp @@ -254,6 +254,10 @@ HWTEST_F(ScreenClientWindowAdapterTest, ScreenClientInputEventListener_OnInputEv std::shared_ptr pointerEvent = nullptr; std::shared_ptr listener = std::make_shared(); EXPECT_FALSE(listener->OnInputEvent(pointerEvent)); + + pointerEvent = MMI::PointerEvent::Create(); + EXPECT_TRUE(pointerEvent != nullptr); + EXPECT_TRUE(listener->OnInputEvent(pointerEvent)); } /** @@ -267,6 +271,10 @@ HWTEST_F(ScreenClientWindowAdapterTest, ScreenClientInputEventListener_OnInputEv std::shared_ptr keyEvent = nullptr; std::shared_ptr listener = std::make_shared(); EXPECT_FALSE(listener->OnInputEvent(keyEvent)); + + keyEvent = MMI::KeyEvent::Create(); + EXPECT_TRUE(keyEvent != nullptr); + EXPECT_TRUE(listener->OnInputEvent(keyEvent)); } /** @@ -280,6 +288,10 @@ HWTEST_F(ScreenClientWindowAdapterTest, ScreenClientInputEventListener_OnInputEv std::shared_ptr axisEvent = nullptr; std::shared_ptr listener = std::make_shared(); EXPECT_FALSE(listener->OnInputEvent(axisEvent)); + + axisEvent = MMI::AxisEvent::Create(); + EXPECT_TRUE(axisEvent != nullptr); + EXPECT_TRUE(listener->OnInputEvent(axisEvent)); } } // DistributedHardware } // OHOS \ No newline at end of file diff --git a/services/screentransport/test/unittest/screendatachannel/src/screen_data_channel_impl_test.cpp b/services/screentransport/test/unittest/screendatachannel/src/screen_data_channel_impl_test.cpp index 7f4d6ab2..109e9c88 100644 --- a/services/screentransport/test/unittest/screendatachannel/src/screen_data_channel_impl_test.cpp +++ b/services/screentransport/test/unittest/screendatachannel/src/screen_data_channel_impl_test.cpp @@ -396,5 +396,21 @@ HWTEST_F(ScreenDataChannelImplTest, JsonToDirtyJson_001, TestSize.Level1) EXPECT_EQ(nullptr, dataChannelImpl_->channelListener_.lock()); } +/** + * @tc.name: SetJpegSessionFlag_001 + * @tc.desc: Verify the SetJpegSessionFlag function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenDataChannelImplTest, SetJpegSessionFlag_001, TestSize.Level1) +{ + bool flag = true; + dataChannelImpl_->SetJpegSessionFlag(flag); + EXPECT_EQ(dataChannelImpl_->jpegSessionFlag_, flag); + + flag = false; + dataChannelImpl_->SetJpegSessionFlag(flag); + EXPECT_EQ(dataChannelImpl_->jpegSessionFlag_, flag); +} } // DistributedHardware } // OHOS \ No newline at end of file diff --git a/services/screentransport/test/unittest/screensinkprocessor/src/image_sink_processor_test.cpp b/services/screentransport/test/unittest/screensinkprocessor/src/image_sink_processor_test.cpp index 85ffa882..1953f648 100644 --- a/services/screentransport/test/unittest/screensinkprocessor/src/image_sink_processor_test.cpp +++ b/services/screentransport/test/unittest/screensinkprocessor/src/image_sink_processor_test.cpp @@ -189,7 +189,9 @@ HWTEST_F(ImageSinkProcessorTest, set_image_surface_test_002, TestSize.Level1) */ HWTEST_F(ImageSinkProcessorTest, processimage_test_001, TestSize.Level1) { - std::shared_ptr data = std::make_shared(DATA_LEN); + std::shared_ptr data = nullptr; + EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, processor_->ProcessImage(data)); + data = std::make_shared(DATA_LEN); EXPECT_EQ(DH_SUCCESS, processor_->ProcessImage(data)); } -- Gitee