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 0000000000000000000000000000000000000000..d8adb23f3ceddd56547dbdc51ffd256ee4fc3923 --- /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 0000000000000000000000000000000000000000..b02e6c55801e553475cd4f82733df1f0c9e8518d --- /dev/null +++ b/test/unittest/lpp_unit_test/engine/lpp_engine_manager_unit_test/lpp_engine_manager_unit_test.cpp @@ -0,0 +1,79 @@ +/* + * 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 \ 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 new file mode 100644 index 0000000000000000000000000000000000000000..9512085a72acb0cfd1cdffb04345ec2d3cdab165 --- /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 0000000000000000000000000000000000000000..cf5d69dcf70410f5776344c7f6232b124eb2477e --- /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 0000000000000000000000000000000000000000..304e0ee845be4580cb289986e902d4b761fe7911 --- /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