From 5df370e62bb2058fcb0681418a9c0c4dee3eec37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E8=8E=B9wuying?= Date: Mon, 14 Jul 2025 08:25:13 +0000 Subject: [PATCH 1/4] =?UTF-8?q?LPP=5FUT=E8=A6=86=E7=9B=96=E6=8F=90?= =?UTF-8?q?=E5=8D=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴莹wuying --- .../lpp_engine_manager_unit_test/BUILD.gn | 97 ++++++++++++++++ .../lpp_engine_manager_unit_test.cpp | 84 ++++++++++++++ .../lpp_engine_manager_unit_test.h | 43 +++++++ .../mock/i_lpp_audio_streamer.h | 26 +++++ .../mock/i_lpp_video_streamer.h | 26 +++++ .../BUILD.gn | 107 ++++++++++++++++++ .../lpp_sync_manager_adapter_unit_test.cpp | 73 ++++++++++++ .../lpp_sync_manager_adapter_unit_test.h | 41 +++++++ .../lpp_video_dec_adapter_unit_test.cpp | 47 +++++++- 9 files changed, 543 insertions(+), 1 deletion(-) create mode 100644 test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/BUILD.gn create mode 100644 test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/lpp_engine_manager_unit_test.cpp create mode 100644 test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/lpp_engine_manager_unit_test.h create mode 100644 test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/mock/i_lpp_audio_streamer.h create mode 100644 test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/mock/i_lpp_video_streamer.h create mode 100644 test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/BUILD.gn create mode 100644 test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/lpp_sync_manager_adapter_unit_test.cpp create mode 100644 test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/lpp_sync_manager_adapter_unit_test.h diff --git a/test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/BUILD.gn b/test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/BUILD.gn new file mode 100644 index 000000000..d8adb23f3 --- /dev/null +++ b/test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/BUILD.gn @@ -0,0 +1,97 @@ +# Copyright (c) 2025 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. + +import("//build/test.gni") +import("//foundation/multimedia/player_framework/config.gni") + +module_output_path = "player_framework/lpp_unit_test" + +config("lpp_engine_manager_unit_test_config") { + visibility = [ ":*" ] + + cflags = [ + "-O2", + "-fPIC", + "-Wall", + "-fexceptions", + "-fno-rtti", + "-Wno-unused-but-set-variable", + "-Wno-format", + "-Dprivate=public", + "-Dprotected=public", + ] + cflags_cc = cflags + include_dirs = [ + "./mock/", + "$MEDIA_PLAYER_ROOT_DIR/services/engine/histreamer/lpp/lpp_audio_streamer", + "$MEDIA_PLAYER_ROOT_DIR/services/engine/histreamer/lpp/lpp_engine_manager", + "$MEDIA_PLAYER_ROOT_DIR/services/utils/include", + "$MEDIA_PLAYER_ROOT_DIR/interfaces/inner_api/native", + "$MEDIA_PLAYER_ROOT_DIR/services/engine/histreamer/lpp/lpp_engine_manager" + + ] + defines = [] + + defines += player_framework_defines +} + +ohos_unittest("lpp_engine_manager_unit_test") { + module_out_path = module_output_path + stack_protector_ret = true + + sources = [] + + if (player_framework_support_lowpower_av_sink) { + sources += [ + "$MEDIA_PLAYER_ROOT_DIR/services/engine/histreamer/lpp/lpp_engine_manager/i_lpp_engine_manager.cpp", + "lpp_engine_manager_unit_test.cpp", + ] + } + + configs = [ + ":lpp_engine_manager_unit_test_config", + "$MEDIA_PLAYER_ROOT_DIR/services/dfx:media_service_log_dfx_public_config", + "$MEDIA_PLAYER_ROOT_DIR/services/utils:media_service_utils_public_config", + ] + + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + debug = true + } + + external_deps = [ + "av_codec:av_codec_client", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "googletest:gmock_main", + "hicollie:libhicollie", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "hitrace:libhitracechain", + "init:libbegetutil", + "ipc:ipc_single", + "media_foundation:media_foundation", + "safwk:system_ability_fwk", + ] + + deps = [ + "$MEDIA_PLAYER_ROOT_DIR/services/dfx:media_service_log_dfx", + "$MEDIA_PLAYER_ROOT_DIR/services/utils:media_service_utils", + ] +} \ No newline at end of file diff --git a/test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/lpp_engine_manager_unit_test.cpp b/test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/lpp_engine_manager_unit_test.cpp new file mode 100644 index 000000000..f61d4d6ff --- /dev/null +++ b/test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/lpp_engine_manager_unit_test.cpp @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2025 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 "gtest/gtest.h" +#include "lpp_engine_manager_unit_test.h" + +using namespace std; +using namespace testing; +using namespace testing::ext; +namespace OHOS { +namespace Media { +void LppEngineManagerUnitTest::SetUpTestCase(void) +{ +} + +void LppEngineManagerUnitTest::TearDownTestCase(void) +{ +} + +void LppEngineManagerUnitTest::SetUp(void) +{ + lppEngineManager_ = std::make_shared(); +} + +void LppEngineManagerUnitTest::TearDown(void) +{ + lppEngineManager_ = nullptr; +} + +/** +* @tc.name : Test GetLppVideoInstance API +* @tc.number : GetLppVideoInstance_001 +* @tc.desc : Test GetLppVideoInstance interface +*/ +HWTEST_F(LppEngineManagerUnitTest, GetLppVideoInstance_001, TestSize.Level0) +{ + string videoStreamName = "video1"; + auto instance = std::make_shared(); + lppEngineManager_->lppVideoStreamerMap_[videoStreamName] = instance; + std::shared_ptr ret = lppEngineManager_->GetLppVideoInstance(videoStreamName); + EXPECT_NE(ret, nullptr); + lppEngineManager_->lppVideoStreamerMap_.clear(); + ret = lppEngineManager_->GetLppVideoInstance(videoStreamName); + EXPECT_EQ(ret, nullptr); +} + + +/** +* @tc.name : Test GetLppAudioInstance API +* @tc.number : GetLppAudioInstance_001 +* @tc.desc : Test GetLppAudioInstance interface +*/ +HWTEST_F(LppEngineManagerUnitTest, GetLppAudioInstance_001, TestSize.Level0) +{ + string audioStreamName = "audio1"; + auto instance = std::make_shared(); + lppEngineManager_->lppAudioStreamerMap_[audioStreamName] = instance; + std::shared_ptr ret = lppEngineManager_->GetLppAudioInstance(audioStreamName); + EXPECT_NE(ret, nullptr); + lppEngineManager_->lppAudioStreamerMap_.clear(); + ret = lppEngineManager_->GetLppAudioInstance(audioStreamName); + EXPECT_EQ(ret, nullptr); +} + +} // namespace Media +} // namespace OHOS + + + + + diff --git a/test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/lpp_engine_manager_unit_test.h b/test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/lpp_engine_manager_unit_test.h new file mode 100644 index 000000000..9512085a7 --- /dev/null +++ b/test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/lpp_engine_manager_unit_test.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2025 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. + */ +#ifndef LPP_ENGINE_MANAGER_UNIT_TEST_H +#define LPP_ENGINE_MANAGER_UNIT_TEST_H + + +#include "gtest/gtest.h" +#include "i_lpp_engine_manager.h" + + + + +namespace OHOS { +namespace Media { + +class LppEngineManagerUnitTest : public testing::Test { +public: + // SetUpTestCase: Called before all test cases + static void SetUpTestCase(void); + // TearDownTestCase: Called after all test case + static void TearDownTestCase(void); + // SetUp: Called before each test cases + void SetUp(void); + // TearDown: Called after each test cases + void TearDown(void); +protected: + std::shared_ptr lppEngineManager_ {nullptr}; +}; +} // namespace Media +} // namespace OHOS +#endif diff --git a/test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/mock/i_lpp_audio_streamer.h b/test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/mock/i_lpp_audio_streamer.h new file mode 100644 index 000000000..cf5d69dcf --- /dev/null +++ b/test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/mock/i_lpp_audio_streamer.h @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2025 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. + */ +#ifndef I_LPP_AUDIO_STREAME_RENGINE_H +#define I_LPP_AUDIO_STREAME_RENGINE_H +namespace OHOS { +namespace Media { + +class ILppAudioStreamerEngine { +public: + ILppAudioStreamerEngine() = default; +}; +} // namespace Media +} // namespace OHOS +#endif \ No newline at end of file diff --git a/test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/mock/i_lpp_video_streamer.h b/test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/mock/i_lpp_video_streamer.h new file mode 100644 index 000000000..304e0ee84 --- /dev/null +++ b/test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/mock/i_lpp_video_streamer.h @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2025 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. + */ +#ifndef I_LPP_VIDEO_STREAME_RENGINE_H +#define I_LPP_VIDEO_STREAME_RENGINE_H +namespace OHOS { +namespace Media { + +class ILppVideoStreamerEngine { +public: + ILppVideoStreamerEngine() = default; +}; +} // namespace Media +} // namespace OHOS +#endif \ No newline at end of file diff --git a/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/BUILD.gn b/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/BUILD.gn new file mode 100644 index 000000000..169a20b56 --- /dev/null +++ b/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/BUILD.gn @@ -0,0 +1,107 @@ +# Copyright (c) 2025 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. + +import("//build/test.gni") +import("//foundation/multimedia/player_framework/config.gni") + +module_output_path = "player_framework/lpp_unit_test" + +config("lpp_sync_manager_adapter_unit_test_config") { + visibility = [ ":*" ] + + cflags = [ + "-O2", + "-fPIC", + "-Wall", + "-fexceptions", + "-fno-rtti", + "-Wno-unused-but-set-variable", + "-Wno-format", + "-Dprivate=public", + "-Dprotected=public", + ] + cflags_cc = cflags + include_dirs = [ + "$MEDIA_PLAYER_ROOT_DIR/services/engine/histreamer/lpp/lpp_sync_manager", + "$MEDIA_PLAYER_ROOT_DIR/services/utils/include", + "$MEDIA_PLAYER_ROOT_DIR/interfaces/inner_api/native", + "$MEDIA_PLAYER_ROOT_DIR/services/services/engine_intf", + ] + defines = [] + + defines += player_framework_defines +} + +ohos_unittest("lpp_sync_manager_adapter_unit_test") { + module_out_path = module_output_path + stack_protector_ret = true + + sources = [] + + if (player_framework_support_lowpower_av_sink) { + sources += [ + "$MEDIA_PLAYER_ROOT_DIR/services/engine/histreamer/lpp/lpp_engine_manager/i_lpp_engine_manager.cpp", + "lpp_sync_manager_adapter_unit_test.cpp", + ] + } + + configs = [ + ":lpp_sync_manager_adapter_unit_test_config", + "$MEDIA_PLAYER_ROOT_DIR/services/dfx:media_service_log_dfx_public_config", + "$MEDIA_PLAYER_ROOT_DIR/services/utils:media_service_utils_public_config", + ] + + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + debug = true + } + + external_deps = [ + "av_codec:av_codec_client", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "googletest:gmock_main", + "hicollie:libhicollie", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "hitrace:libhitracechain", + "init:libbegetutil", + "ipc:ipc_single", + "media_foundation:media_foundation", + "safwk:system_ability_fwk", + ] + if (player_framework_support_lowpower_av_sink) { + external_deps += [ + "drivers_interface_lpplayer:liblow_power_player_proxy_1.0", + "hdf_core:libhdi", + ] + } + deps = [ + "$MEDIA_PLAYER_ROOT_DIR/services/dfx:media_service_log_dfx", + "$MEDIA_PLAYER_ROOT_DIR/services/utils:media_service_utils", + ] + if (player_framework_support_lowpower_av_sink) { + deps += [ + "$MEDIA_PLAYER_ROOT_DIR/services/engine/histreamer/lpp/lpp_audio_streamer:media_engine_histreamer_lpp_audio_streamer", + "$MEDIA_PLAYER_ROOT_DIR/services/engine/histreamer/lpp/lpp_engine_manager:media_engine_histreamer_lpp_engine_manager", + "$MEDIA_PLAYER_ROOT_DIR/services/engine/histreamer/lpp/lpp_sync_manager:media_engine_histreamer_lpp_sync_manager", + "$MEDIA_PLAYER_ROOT_DIR/services/engine/histreamer/lpp/lpp_video_streamer:media_engine_histreamer_lpp_video_streamer", + ] + } +} \ No newline at end of file diff --git a/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/lpp_sync_manager_adapter_unit_test.cpp b/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/lpp_sync_manager_adapter_unit_test.cpp new file mode 100644 index 000000000..ae481396c --- /dev/null +++ b/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/lpp_sync_manager_adapter_unit_test.cpp @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2025 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 "gtest/gtest.h" +#include "lpp_sync_manager_adapter_unit_test.h" +#include "media_lpp_errors.h" + +using namespace std; +using namespace testing; +using namespace testing::ext; +namespace OHOS { +namespace Media { +using namespace OHOS::HDI::Base; +void LppSyncManagerAdapterUnitTest::SetUpTestCase(void) +{ +} + +void LppSyncManagerAdapterUnitTest::TearDownTestCase(void) +{ +} + +void LppSyncManagerAdapterUnitTest::SetUp(void) +{ + lppSyncManagerAdapter_ = std::make_shared(); +} + +void LppSyncManagerAdapterUnitTest::TearDown(void) +{ + lppSyncManagerAdapter_ = nullptr; +} + +/** +* @tc.name : Test OnError API +* @tc.number : OnError_001 +* @tc.desc : Test OnError interface +*/ +HWTEST_F(LppSyncManagerAdapterUnitTest, OnError_001, TestSize.Level0) +{ + int32_t errorCode = HDF_ERR_OK; + string str = ""; + lppSyncManagerAdapter_->OnError(errorCode, str); +} + +/** +* @tc.name : Test BindOutputBuffers API +* @tc.number : BindOutputBuffers_001 +* @tc.desc : Test BindOutputBuffers interface +*/ +HWTEST_F(LppSyncManagerAdapterUnitTest, BindOutputBuffers_001, TestSize.Level0) +{ + std::map> bufferMap; + bufferMap[0] = nullptr; + lppSyncManagerAdapter_ ->BindOutputBuffers(bufferMap); +} + +} // namespace Media +} // namespace OHOS + + + diff --git a/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/lpp_sync_manager_adapter_unit_test.h b/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/lpp_sync_manager_adapter_unit_test.h new file mode 100644 index 000000000..f53693ed2 --- /dev/null +++ b/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/lpp_sync_manager_adapter_unit_test.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2025 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. + */ +#ifndef LPP_SYNC_MANAGER_ADAPTER_UNIT_TEST_H +#define LPP_SYNC_MANAGER_ADAPTER_UNIT_TEST_H + + +#include "gtest/gtest.h" +#include "lpp_sync_manager_adapter.h" + + +namespace OHOS { +namespace Media { + +class LppSyncManagerAdapterUnitTest : public testing::Test { +public: + // SetUpTestCase: Called before all test cases + static void SetUpTestCase(void); + // TearDownTestCase: Called after all test case + static void TearDownTestCase(void); + // SetUp: Called before each test cases + void SetUp(void); + // TearDown: Called after each test cases + void TearDown(void); +protected: + std::shared_ptr lppSyncManagerAdapter_ {nullptr}; +}; +} // namespace Media +} // namespace OHOS +#endif diff --git a/test/unittest/lpp_unit_test/module/lpp_video_dec_adapter_unit_test/lpp_video_dec_adapter_unit_test.cpp b/test/unittest/lpp_unit_test/module/lpp_video_dec_adapter_unit_test/lpp_video_dec_adapter_unit_test.cpp index fe33cb52e..fec1003d6 100644 --- a/test/unittest/lpp_unit_test/module/lpp_video_dec_adapter_unit_test/lpp_video_dec_adapter_unit_test.cpp +++ b/test/unittest/lpp_unit_test/module/lpp_video_dec_adapter_unit_test/lpp_video_dec_adapter_unit_test.cpp @@ -216,5 +216,50 @@ HWTEST_F(LppVideoDecAdapterUnitTest, OnInputBufferAvailable_002, TestSize.Level1 videoDecAdapter_->OnInputBufferAvailable(index, buffer); EXPECT_EQ(videoDecAdapter_->bufferVector_.size(), 0); } + +/** +* @tc.name : Test Flush API +* @tc.number : Flush_001 +* @tc.desc : Test Flush interface +* @tc.require : issueI5NZAQ +*/ +HWTEST_F(LppVideoDecAdapterUnitTest, Flush_001, TestSize.Level1) +{ + ASSERT_NE(nullptr, videoDecAdapter_); + ASSERT_NE(nullptr, videoDecoder_); + ASSERT_NE(nullptr, inputBufferQueueConsumer_); + videoDecAdapter_->videoDecoder_ = videoDecoder_; + videoDecAdapter_->inputBufferQueueConsumer_ = inputBufferQueueConsumer_; + auto buffer = std::make_shared(); + std::vector> bufferVector_; + bufferVector_.push_back(buffer); + videoDecAdapter_->bufferVector_ = bufferVector_; + EXPECT_CALL(*inputBufferQueueConsumer_, DetachBuffer(buffer)).Times(1); + EXPECT_CALL(*inputBufferQueueConsumer_, SetQueueSize(0)).Times(1); + int32_t res = videoDecAdapter_->Flush(); + EXPECT_EQ(res, MSERR_OK); +} + +/** +* @tc.name : Test Flush API +* @tc.number : Flush_002 +* @tc.desc : Test Flush interface +* @tc.require : issueI5NZAQ +*/ +HWTEST_F(LppVideoDecAdapterUnitTest, Flush_002, TestSize.Level1) +{ + ASSERT_NE(nullptr, videoDecAdapter_); + ASSERT_NE(nullptr, videoDecoder_); + videoDecAdapter_->videoDecoder_ = videoDecoder_; + videoDecAdapter_->inputBufferQueueConsumer_ = nullptr; + auto buffer = std::make_shared(); + std::vector> bufferVector_; + bufferVector_.push_back(buffer); + videoDecAdapter_->bufferVector_ = bufferVector_; + EXPECT_CALL(*inputBufferQueueConsumer_, DetachBuffer(buffer)).Times(0); + EXPECT_CALL(*inputBufferQueueConsumer_, SetQueueSize(0)).Times(0); + int32_t res = videoDecAdapter_->Flush(); + EXPECT_EQ(res, MSERR_OK); +} } // namespace Media -} // namespace OHOS \ No newline at end of file +} // namespace OHOS -- Gitee From 6ab90ae138adb3c82c65aecb92bdfac2d3c2b379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E8=8E=B9wuying?= Date: Mon, 14 Jul 2025 09:15:15 +0000 Subject: [PATCH 2/4] LPP_UT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴莹wuying --- .../lpp_engine_manager_unit_test.cpp | 9 +-------- .../lpp_engine_manager_unit_test.h | 6 +----- .../lpp_sync_manager_adapter_unit_test.cpp | 7 ++----- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/lpp_engine_manager_unit_test.cpp b/test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/lpp_engine_manager_unit_test.cpp index f61d4d6ff..5463bc570 100644 --- a/test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/lpp_engine_manager_unit_test.cpp +++ b/test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/lpp_engine_manager_unit_test.cpp @@ -13,7 +13,6 @@ * limitations under the License. */ - #include "gtest/gtest.h" #include "lpp_engine_manager_unit_test.h" @@ -57,7 +56,6 @@ HWTEST_F(LppEngineManagerUnitTest, GetLppVideoInstance_001, TestSize.Level0) EXPECT_EQ(ret, nullptr); } - /** * @tc.name : Test GetLppAudioInstance API * @tc.number : GetLppAudioInstance_001 @@ -76,9 +74,4 @@ HWTEST_F(LppEngineManagerUnitTest, GetLppAudioInstance_001, TestSize.Level0) } } // namespace Media -} // namespace OHOS - - - - - +} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/lpp_engine_manager_unit_test.h b/test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/lpp_engine_manager_unit_test.h index 9512085a7..440b6d922 100644 --- a/test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/lpp_engine_manager_unit_test.h +++ b/test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/lpp_engine_manager_unit_test.h @@ -15,13 +15,9 @@ #ifndef LPP_ENGINE_MANAGER_UNIT_TEST_H #define LPP_ENGINE_MANAGER_UNIT_TEST_H - #include "gtest/gtest.h" #include "i_lpp_engine_manager.h" - - - namespace OHOS { namespace Media { @@ -40,4 +36,4 @@ protected: }; } // namespace Media } // namespace OHOS -#endif +#endif \ No newline at end of file diff --git a/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/lpp_sync_manager_adapter_unit_test.cpp b/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/lpp_sync_manager_adapter_unit_test.cpp index ae481396c..4d901b84a 100644 --- a/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/lpp_sync_manager_adapter_unit_test.cpp +++ b/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/lpp_sync_manager_adapter_unit_test.cpp @@ -51,7 +51,7 @@ HWTEST_F(LppSyncManagerAdapterUnitTest, OnError_001, TestSize.Level0) { int32_t errorCode = HDF_ERR_OK; string str = ""; - lppSyncManagerAdapter_->OnError(errorCode, str); + lppSyncManagerAdapter_->OnError(errorCode, str); } /** @@ -67,7 +67,4 @@ HWTEST_F(LppSyncManagerAdapterUnitTest, BindOutputBuffers_001, TestSize.Level0) } } // namespace Media -} // namespace OHOS - - - +} // namespace OHOS \ No newline at end of file -- Gitee From 69580d238d18cfab6550ffe8d902a0199c91e725 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E8=8E=B9wuying?= Date: Wed, 16 Jul 2025 07:23:38 +0000 Subject: [PATCH 3/4] LPP_0716 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴莹wuying --- .../lpp_video_dec_adapter_unit_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unittest/lpp_unit_test/module/lpp_video_dec_adapter_unit_test/lpp_video_dec_adapter_unit_test.cpp b/test/unittest/lpp_unit_test/module/lpp_video_dec_adapter_unit_test/lpp_video_dec_adapter_unit_test.cpp index fec1003d6..fde8b1691 100644 --- a/test/unittest/lpp_unit_test/module/lpp_video_dec_adapter_unit_test/lpp_video_dec_adapter_unit_test.cpp +++ b/test/unittest/lpp_unit_test/module/lpp_video_dec_adapter_unit_test/lpp_video_dec_adapter_unit_test.cpp @@ -262,4 +262,4 @@ HWTEST_F(LppVideoDecAdapterUnitTest, Flush_002, TestSize.Level1) EXPECT_EQ(res, MSERR_OK); } } // namespace Media -} // namespace OHOS +} // namespace OHOS \ No newline at end of file -- Gitee From 5618a39891dc6d2b0ee48a44b2b789110055eb52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E8=8E=B9wuying?= Date: Wed, 16 Jul 2025 08:04:00 +0000 Subject: [PATCH 4/4] LPP_UT_0716 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴莹wuying --- .../BUILD.gn | 1 + .../lpp_sync_manager_adapter_unit_test.cpp | 9 ++++- .../lpp_sync_manager_adapter_unit_test.h | 4 +- .../mock/mock_event_receiver.h | 38 +++++++++++++++++++ 4 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/mock/mock_event_receiver.h diff --git a/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/BUILD.gn b/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/BUILD.gn index 169a20b56..3a927c41c 100644 --- a/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/BUILD.gn +++ b/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/BUILD.gn @@ -32,6 +32,7 @@ config("lpp_sync_manager_adapter_unit_test_config") { ] cflags_cc = cflags include_dirs = [ + "./mock/", "$MEDIA_PLAYER_ROOT_DIR/services/engine/histreamer/lpp/lpp_sync_manager", "$MEDIA_PLAYER_ROOT_DIR/services/utils/include", "$MEDIA_PLAYER_ROOT_DIR/interfaces/inner_api/native", diff --git a/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/lpp_sync_manager_adapter_unit_test.cpp b/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/lpp_sync_manager_adapter_unit_test.cpp index 4d901b84a..ba40a287b 100644 --- a/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/lpp_sync_manager_adapter_unit_test.cpp +++ b/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/lpp_sync_manager_adapter_unit_test.cpp @@ -18,6 +18,7 @@ #include "lpp_sync_manager_adapter_unit_test.h" #include "media_lpp_errors.h" + using namespace std; using namespace testing; using namespace testing::ext; @@ -35,6 +36,7 @@ void LppSyncManagerAdapterUnitTest::TearDownTestCase(void) void LppSyncManagerAdapterUnitTest::SetUp(void) { lppSyncManagerAdapter_ = std::make_shared(); + mockEventReceiver_ = std::make_shared(); } void LppSyncManagerAdapterUnitTest::TearDown(void) @@ -51,7 +53,9 @@ HWTEST_F(LppSyncManagerAdapterUnitTest, OnError_001, TestSize.Level0) { int32_t errorCode = HDF_ERR_OK; string str = ""; - lppSyncManagerAdapter_->OnError(errorCode, str); + EXPECT_CALL(*mockEventReceiver_ , OnEvent(_)).Times(0); + lppSyncManagerAdapter_->eventReceiver_ = mockEventReceiver_; + lppSyncManagerAdapter_->OnError(errorCode, str); } /** @@ -63,7 +67,8 @@ HWTEST_F(LppSyncManagerAdapterUnitTest, BindOutputBuffers_001, TestSize.Level0) { std::map> bufferMap; bufferMap[0] = nullptr; - lppSyncManagerAdapter_ ->BindOutputBuffers(bufferMap); + int32_t res = lppSyncManagerAdapter_->BindOutputBuffers(bufferMap); + EXPECT_NE(res, MSERR_OK); } } // namespace Media diff --git a/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/lpp_sync_manager_adapter_unit_test.h b/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/lpp_sync_manager_adapter_unit_test.h index f53693ed2..43a93a1b4 100644 --- a/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/lpp_sync_manager_adapter_unit_test.h +++ b/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/lpp_sync_manager_adapter_unit_test.h @@ -18,6 +18,7 @@ #include "gtest/gtest.h" #include "lpp_sync_manager_adapter.h" +#include "mock_event_receiver.h" namespace OHOS { @@ -35,7 +36,8 @@ public: void TearDown(void); protected: std::shared_ptr lppSyncManagerAdapter_ {nullptr}; + std::shared_ptr mockEventReceiver_ {nullptr}; }; } // namespace Media } // namespace OHOS -#endif +#endif \ No newline at end of file diff --git a/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/mock/mock_event_receiver.h b/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/mock/mock_event_receiver.h new file mode 100644 index 000000000..63cd050c0 --- /dev/null +++ b/test/unittest/lpp_unit_test/engine/lpp_sync_manager_adapter_unit_test/mock/mock_event_receiver.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023-2025 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. + */ +#ifndef MOCK_EVENT_RECEIVER_H +#define MOCK_EVENT_RECEIVER_H + +#include +#include +#include "pipeline/pipeline.h" + +namespace OHOS { +namespace Media { +namespace Pipeline { + +using namespace testing; + +class MockEventReceiver : public EventReceiver { +public: + MOCK_METHOD(void, OnEvent, (const Event& event), ()); + MOCK_METHOD(void, OnDfxEvent, (const DfxEvent& event), ()); + MOCK_METHOD(void, NotifyRelease, (), ()); + MOCK_METHOD(void, OnMemoryUsageEvent, (const DfxEvent& event), ()); +}; +} // namespace Pipeline +} // namespace Media +} // namespace OHOS +#endif \ No newline at end of file -- Gitee