diff --git a/frameworks/native/lpp_audio_streamer/test/unittest/BUILD.gn b/frameworks/native/lpp_audio_streamer/test/unittest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..ed4bff8b8cd2ee0e3ce0c34d17d0f709c03d5c55 --- /dev/null +++ b/frameworks/native/lpp_audio_streamer/test/unittest/BUILD.gn @@ -0,0 +1,51 @@ +# 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_audio_streamer" + +ohos_unittest("lpp_audio_streamer_unit_test") { + module_out_path = module_output_path + include_dirs = [ + "./include", + "$MEDIA_PLAYER_ROOT_DIR/interfaces/inner_api/native", + "$MEDIA_PLAYER_ROOT_DIR/frameworks/native/lpp_audio_streamer", + "$MEDIA_PLAYER_ROOT_DIR/test/unittest/common/include", + ] + + cflags = [ + "-Wall", + "-Werror", + "-Wno-deprecated-declarations", + ] + + if (player_framework_support_lowpower_av_sink) { + sources = [ + "src/lpp_audio_streamer_unit_test.cpp", + ] + } + + deps = [ "$MEDIA_PLAYER_ROOT_DIR/interfaces/inner_api/native:media_client" ] + + external_deps = [ + "av_codec:av_codec_client", + "c_utils:utils", + "hilog:libhilog", + "media_foundation:media_foundation", + ] + + resource_config_file = + "$MEDIA_PLAYER_ROOT_DIR/test/unittest/resources/ohos_test.xml" +} \ No newline at end of file diff --git a/frameworks/native/lpp_audio_streamer/test/unittest/include/lpp_audio_streamer_unit_test.h b/frameworks/native/lpp_audio_streamer/test/unittest/include/lpp_audio_streamer_unit_test.h new file mode 100644 index 0000000000000000000000000000000000000000..566d7f13bd51af47b67c521927e1fe553444bc80 --- /dev/null +++ b/frameworks/native/lpp_audio_streamer/test/unittest/include/lpp_audio_streamer_unit_test.h @@ -0,0 +1,33 @@ +/* + * 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_AUDIO_STREAMER_UNIT_TEST_H +#define LPP_AUDIO_STREAMER_UNIT_TEST_H + +#include +#include "lpp_audio_streamer.h" + +namespace OHOS { +namespace Media { +class AudioStreamerUnitTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; +} // namespace Media +} // namespace OHOS +#endif // LPP_AUDIO_STREAMER_UNIT_TEST_H diff --git a/frameworks/native/lpp_audio_streamer/test/unittest/src/lpp_audio_streamer_unit_test.cpp b/frameworks/native/lpp_audio_streamer/test/unittest/src/lpp_audio_streamer_unit_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fe18582cd9fa2689d9ae9c8db20ce05bcd47cf8c --- /dev/null +++ b/frameworks/native/lpp_audio_streamer/test/unittest/src/lpp_audio_streamer_unit_test.cpp @@ -0,0 +1,53 @@ +/* + * 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 +#include +#include "lpp_audio_streamer_unit_test.h" + +namespace OHOS { +namespace Media { +using namespace std; +using namespace testing::ext; + +void AudioStreamerUnitTest::SetUpTestCase(void) +{} + +void AudioStreamerUnitTest::TearDownTestCase(void) +{} + +void AudioStreamerUnitTest::SetUp(void) +{} + +void AudioStreamerUnitTest::TearDown(void) +{} + +/** + * @tc.name : AudioCreateByMime + * @tc.number: AudioCreateByMime + * @tc.desc : FUNC + */ +HWTEST_F(AudioStreamerUnitTest, AudioCreateByMime, TestSize.Level1) +{ + std::string invalidMime = "video/avc"; + std::shared_ptr invalidAudioPlayer = AudioStreamerFactory::CreateByMime(invalidMime); + EXPECT_EQ(invalidAudioPlayer, nullptr); + + std::string validMime = "audio/mp4a-latm"; + std::shared_ptr validAudioPlayer = AudioStreamerFactory::CreateByMime(validMime); + EXPECT_NE(validAudioPlayer, nullptr); +} +} // namespace Media +} // namespace OHOS \ No newline at end of file diff --git a/frameworks/native/lpp_video_streamer/test/unittest/BUILD.gn b/frameworks/native/lpp_video_streamer/test/unittest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..3f37c186ebf7139469dc09dab7d22d7e8fac25ab --- /dev/null +++ b/frameworks/native/lpp_video_streamer/test/unittest/BUILD.gn @@ -0,0 +1,51 @@ +# 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_video_streamer" + +ohos_unittest("lpp_video_streamer_unit_test") { + module_out_path = module_output_path + include_dirs = [ + "./include", + "$MEDIA_PLAYER_ROOT_DIR/interfaces/inner_api/native", + "$MEDIA_PLAYER_ROOT_DIR/frameworks/native/lpp_video_streamer", + "$MEDIA_PLAYER_ROOT_DIR/test/unittest/common/include", + ] + + cflags = [ + "-Wall", + "-Werror", + "-Wno-deprecated-declarations", + ] + + if (player_framework_support_lowpower_av_sink) { + sources = [ + "src/lpp_video_streamer_unit_test.cpp", + ] + } + + deps = [ "$MEDIA_PLAYER_ROOT_DIR/interfaces/inner_api/native:media_client" ] + + external_deps = [ + "av_codec:av_codec_client", + "c_utils:utils", + "hilog:libhilog", + "media_foundation:media_foundation" + ] + + resource_config_file = + "$MEDIA_PLAYER_ROOT_DIR/test/unittest/resources/ohos_test.xml" +} \ No newline at end of file diff --git a/frameworks/native/lpp_video_streamer/test/unittest/include/lpp_video_streamer_unit_test.h b/frameworks/native/lpp_video_streamer/test/unittest/include/lpp_video_streamer_unit_test.h new file mode 100644 index 0000000000000000000000000000000000000000..55d2b2f508ac5d93078801f51f213ca021c63d5a --- /dev/null +++ b/frameworks/native/lpp_video_streamer/test/unittest/include/lpp_video_streamer_unit_test.h @@ -0,0 +1,33 @@ +/* + * 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_VIDEO_STREAMER_UNIT_TEST_H +#define LPP_VIDEO_STREAMER_UNIT_TEST_H + +#include +#include "lpp_video_streamer.h" + +namespace OHOS { +namespace Media { +class VideoStreamerUnitTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; +} // namespace Media +} // namespace OHOS +#endif // LPP_VIDEO_STREAMER_UNIT_TEST_H diff --git a/frameworks/native/lpp_video_streamer/test/unittest/src/lpp_video_streamer_unit_test.cpp b/frameworks/native/lpp_video_streamer/test/unittest/src/lpp_video_streamer_unit_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b2e103389d8f3444ff3bee2109538720f5074383 --- /dev/null +++ b/frameworks/native/lpp_video_streamer/test/unittest/src/lpp_video_streamer_unit_test.cpp @@ -0,0 +1,53 @@ +/* + * 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 +#include +#include "lpp_video_streamer_unit_test.h" + +namespace OHOS { +namespace Media { +using namespace std; +using namespace testing::ext; + +void VideoStreamerUnitTest::SetUpTestCase(void) +{} + +void VideoStreamerUnitTest::TearDownTestCase(void) +{} + +void VideoStreamerUnitTest::SetUp(void) +{} + +void VideoStreamerUnitTest::TearDown(void) +{} + +/** + * @tc.name : VideoCreateByMime + * @tc.number: VideoCreateByMime + * @tc.desc : FUNC + */ +HWTEST_F(VideoStreamerUnitTest, VideoCreateByMime, TestSize.Level1) +{ + std::string invalidMime = "invalid"; + std::shared_ptr invalidVideoPlayer = VideoStreamerFactory::CreateByMime(invalidMime); + EXPECT_EQ(invalidVideoPlayer, nullptr); + + std::string validMime = "video/avc"; + std::shared_ptr validVideoPlayer = VideoStreamerFactory::CreateByMime(validMime); + EXPECT_NE(validVideoPlayer, nullptr); +} +} // namespace Media +} // namespace OHOS \ No newline at end of file diff --git a/interfaces/inner_api/native/lpp_audio_streamer.h b/interfaces/inner_api/native/lpp_audio_streamer.h index ba4e46b23eb58778dda1df1ec3b2d8c242747844..8c49294d4f800a7e64453145f9d7df1b5a271c18 100644 --- a/interfaces/inner_api/native/lpp_audio_streamer.h +++ b/interfaces/inner_api/native/lpp_audio_streamer.h @@ -96,17 +96,12 @@ public: class __attribute__((visibility("default"))) AudioStreamerFactory { public: #ifdef UNSUPPORT_LPP_AUDIO_STRAMER - static std::shared_ptr CreatePlayer() - { - return nullptr; - } static std::shared_ptr CreateByMime(const std::string &mime) { (void)mime; return nullptr; } #else - static std::shared_ptr CreatePlayer(); static std::shared_ptr CreateByMime(const std::string &mime); #endif private: diff --git a/interfaces/inner_api/native/lpp_video_streamer.h b/interfaces/inner_api/native/lpp_video_streamer.h index e3de3855826ffc46f6e31903920660cf3b654c96..d29cd78a0af5d0f8d9b75b916ae9a0f3c6b6a586 100644 --- a/interfaces/inner_api/native/lpp_video_streamer.h +++ b/interfaces/inner_api/native/lpp_video_streamer.h @@ -108,17 +108,12 @@ public: class __attribute__((visibility("default"))) VideoStreamerFactory { public: #ifdef UNSUPPORT_LPP_AUDIO_STRAMER - static std::shared_ptr CreatePlayer() - { - return nullptr; - } static std::shared_ptr CreateByMime(const std::string &mime) { (void)mime; return nullptr; } #else - static std::shared_ptr CreatePlayer(); static std::shared_ptr CreateByMime(const std::string &mime); #endif private: diff --git a/interfaces/inner_api/native/player_framework.versionscript b/interfaces/inner_api/native/player_framework.versionscript index 392a8c8ba49b0c7caa4dad34bfab42b5a31a8228..e6a712c866d3aebed1fa12727f91cfe4334bf52d 100644 --- a/interfaces/inner_api/native/player_framework.versionscript +++ b/interfaces/inner_api/native/player_framework.versionscript @@ -27,9 +27,7 @@ *OHOS::Media::ScreenCaptureFactory::CreateScreenCapture*; *OHOS::Media::ScreenCaptureFactory::CreateScreenCaptureMonitor*; *OHOS::Media::ScreenCaptureControllerFactory::CreateScreenCaptureController*; - *OHOS::Media::AudioStreamerFactory::CreatePlayer*; *OHOS::Media::AudioStreamerFactory::CreateByMime*; - *OHOS::Media::VideoStreamerFactory::CreatePlayer*; *OHOS::Media::VideoStreamerFactory::CreateByMime*; *OHOS::Media::Format::*; *OHOS::Media::VideoCaps::*; diff --git a/test/BUILD.gn b/test/BUILD.gn index 2a6620eccb420ea30fcf034d644c6f1ee8fee802..c2dbf2e65556c7c9a9298f2ddbc99afbb1e0dcbb 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -27,6 +27,8 @@ group("media_unit_test") { "../frameworks/native/system_sound_manager/unittest/sound_manager_test:system_sound_manager_unit_test", "../frameworks/native/system_sound_manager/unittest/tone_player_test:system_tone_player_unit_test", "../frameworks/native/transcoder/test/unittest:transcoder_unit_test", + "../frameworks/native/lpp_audio_streamer/test/unittest:lpp_audio_streamer_unit_test", + "../frameworks/native/lpp_video_streamer/test/unittest:lpp_video_streamer_unit_test", "../frameworks/native/video_editor/test/unittest:video_editor_unit_test", "unittest/audio_background_adapter_test:audio_background_adapter_unit_test", "unittest/audio_haptic_test:audio_haptic_player_impl_unit_test",