From 6bf0cb879b5bdc7afa163ade1802acbb55713706 Mon Sep 17 00:00:00 2001 From: zhaona45 Date: Wed, 28 May 2025 18:22:20 +0800 Subject: [PATCH] Modify invalid case Signed-off-by: zhaona45 Change-Id: I6d0516f84bc9f937aea353a1dd06f9975d602b2c --- .../unittest/imagecodec/image_codec_test.cpp | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/frameworks/innerkitsimpl/test/unittest/imagecodec/image_codec_test.cpp b/frameworks/innerkitsimpl/test/unittest/imagecodec/image_codec_test.cpp index b9e79ac06..eb1093ab4 100644 --- a/frameworks/innerkitsimpl/test/unittest/imagecodec/image_codec_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/imagecodec/image_codec_test.cpp @@ -266,13 +266,16 @@ HWTEST_F(ImageCodecTest, OnMsgReceivedTest001, TestSize.Level1) std::shared_ptr bundle = std::make_shared(); info.param = bundle; startingState.OnMsgReceived(info); - EXPECT_EQ(info.type, ImageCodec::MsgWhat::GET_INPUT_FORMAT); + bool result = startingState.codec_->deferredQueue_.size() != 0; + EXPECT_TRUE(result); info.type = ImageCodec::MsgWhat::START; startingState.OnMsgReceived(info); - EXPECT_EQ(info.type, ImageCodec::MsgWhat::START); + result = startingState.codec_->m_replies.find(info.id) == startingState.codec_->m_replies.end(); + EXPECT_TRUE(result); info.type = ImageCodec::MsgWhat::CHECK_IF_STUCK; startingState.OnMsgReceived(info); - EXPECT_EQ(info.type, ImageCodec::MsgWhat::CHECK_IF_STUCK); + int32_t generation; + EXPECT_FALSE(info.param->GetValue("generation", generation)); GTEST_LOG_(INFO) << "ImageCodecTest: OnMsgReceivedTest001 end"; } @@ -293,7 +296,8 @@ HWTEST_F(ImageCodecTest, OnMsgReceivedTest002, TestSize.Level1) info.type = ImageCodec::MsgWhat::START; info.id = 0; runningState.OnMsgReceived(info); - EXPECT_EQ(info.id, 0); + bool result = runningState.codec_->m_replies.find(info.id) == runningState.codec_->m_replies.end(); + EXPECT_TRUE(result); GTEST_LOG_(INFO) << "ImageCodecTest: OnMsgReceivedTest002 end"; } @@ -315,19 +319,20 @@ HWTEST_F(ImageCodecTest, OnMsgReceivedTest003, TestSize.Level1) info.type = ImageCodec::MsgWhat::START; outputPortChangedState.OnShutDown(info); outputPortChangedState.OnMsgReceived(info); - EXPECT_EQ(info.type, ImageCodec::MsgWhat::START); + bool result = outputPortChangedState.codec_->deferredQueue_.size() != 0; + EXPECT_TRUE(result); info.type = ImageCodec::MsgWhat::QUEUE_INPUT_BUFFER; outputPortChangedState.OnMsgReceived(info); - EXPECT_EQ(info.type, ImageCodec::MsgWhat::QUEUE_INPUT_BUFFER); info.type = ImageCodec::MsgWhat::RELEASE_OUTPUT_BUFFER; outputPortChangedState.OnMsgReceived(info); - EXPECT_EQ(info.type, ImageCodec::MsgWhat::RELEASE_OUTPUT_BUFFER); + result = outputPortChangedState.codec_->m_replies.find(info.id) == outputPortChangedState.codec_->m_replies.end(); + EXPECT_TRUE(result); info.type = ImageCodec::MsgWhat::FORCE_SHUTDOWN; outputPortChangedState.OnMsgReceived(info); - EXPECT_EQ(info.type, ImageCodec::MsgWhat::FORCE_SHUTDOWN); + EXPECT_FALSE(outputPortChangedState.codec_->isShutDownFromRunning_); info.type = ImageCodec::MsgWhat::CHECK_IF_STUCK; outputPortChangedState.OnMsgReceived(info); - EXPECT_EQ(info.type, ImageCodec::MsgWhat::CHECK_IF_STUCK); + EXPECT_FALSE(outputPortChangedState.codec_->hasFatalError_); GTEST_LOG_(INFO) << "ImageCodecTest: OnMsgReceivedTest003 end"; } @@ -347,7 +352,9 @@ HWTEST_F(ImageCodecTest, OnMsgReceivedTest004, TestSize.Level1) std::shared_ptr bundle = std::make_shared(); info.param = bundle; stoppingState.OnMsgReceived(info); - EXPECT_EQ(info.type, ImageCodec::MsgWhat::CHECK_IF_STUCK); + int32_t generation; + (void)info.param->GetValue("generation", generation); + EXPECT_NE(generation, stoppingState.codec_->stateGeneration_); GTEST_LOG_(INFO) << "ImageCodecTest: OnMsgReceivedTest004 end"; } -- Gitee