diff --git a/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine/include/av_sender_engine_test.h b/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine/include/av_sender_engine_test.h index 6cdca1e1cc2231ebbf502f7f43c9b721a73d0e1c..7f4519ee06b16fc2f314dd9166d94e71ad80f9f8 100644 --- a/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine/include/av_sender_engine_test.h +++ b/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine/include/av_sender_engine_test.h @@ -27,6 +27,7 @@ #include "av_trans_types.h" #include "av_trans_utils.h" #include "i_av_sender_engine.h" +#include "i_av_sender_engine_callback.h" #include "softbus_channel_adapter.h" #include "distributed_hardware_fwk_kit.h" #include "av_trans_control_center_callback.h" @@ -56,6 +57,21 @@ public: void SetUp() override; void TearDown() override; }; +class SenderEngineCallback : public IAVSenderEngineCallback { +public: + SenderEngineCallback() = default; + ~SenderEngineCallback() override = default; + int32_t OnSenderEvent(const AVTransEvent &event) override + { + (void) event; + return DH_AVT_SUCCESS; + } + int32_t OnMessageReceived(const std::shared_ptr &message) override + { + (void) message; + return DH_AVT_SUCCESS; + } +}; } // namespace DistributedHardware } // namespace OHOS diff --git a/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine/src/av_sender_engine_test.cpp b/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine/src/av_sender_engine_test.cpp index 7edd3151fd4e0eb1fc0fb674825a0127a67856f3..1e0096340ce38675658f7a7c42f59e95bbc633f8 100644 --- a/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine/src/av_sender_engine_test.cpp +++ b/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine/src/av_sender_engine_test.cpp @@ -17,6 +17,7 @@ #include "pipeline/factory/filter_factory.h" #include "plugin_video_tags.h" +#include "distributed_hardware_fwk_kit.h" using namespace testing::ext; using namespace OHOS::DistributedHardware; @@ -48,6 +49,8 @@ HWTEST_F(AvSenderEngineTest, Initialize_001, testing::ext::TestSize.Level1) std::string peerDevId = "pEid"; auto sender = std::make_shared(ownerName, peerDevId); sender->initialized_ = true; + std::string value = MIME_VIDEO_H264; + sender->SetVideoCodecType(value); int32_t ret = sender->Initialize(); EXPECT_EQ(DH_AVT_SUCCESS, ret); } @@ -58,6 +61,8 @@ HWTEST_F(AvSenderEngineTest, Initialize_002, testing::ext::TestSize.Level1) std::string peerDevId = "pEid"; auto sender = std::make_shared(ownerName, peerDevId); sender->avInput_ = nullptr; + std::string value = MIME_VIDEO_H265; + sender->SetVideoCodecType(value); int32_t ret = sender->Initialize(); EXPECT_EQ(ERR_DH_AVT_INIT_FAILED, ret); } @@ -68,10 +73,35 @@ HWTEST_F(AvSenderEngineTest, Initialize_003, testing::ext::TestSize.Level1) std::string peerDevId = "pEid"; auto sender = std::make_shared(ownerName, peerDevId); sender->sessionName_ = ""; + sender->SetEnginePause(ownerName); + sender->pipeline_ = nullptr; + sender->SetEnginePause(ownerName); int32_t ret = sender->Initialize(); EXPECT_EQ(ERR_DH_AVT_INIT_FAILED, ret); } +HWTEST_F(AvSenderEngineTest, InitPipeline_001, testing::ext::TestSize.Level1) +{ + std::string ownerName = "001"; + std::string peerDevId = "pEid"; + auto sender = std::make_shared(ownerName, peerDevId); + sender->ownerName_ = ""; + sender->SetEngineResume(ownerName); + sender->pipeline_ = nullptr; + sender->SetEngineResume(ownerName); + int32_t ret = sender->InitPipeline(); + EXPECT_EQ(ERR_DH_AVT_NULL_POINTER, ret); +} + +HWTEST_F(AvSenderEngineTest, InitPipeline_002, testing::ext::TestSize.Level1) +{ + std::string peerDevId = "pEid"; + auto sender = std::make_shared(OWNER_NAME_D_MIC, peerDevId); + sender->ownerName_ = ""; + int32_t ret = sender->InitPipeline(); + EXPECT_EQ(ERR_DH_AVT_NULL_POINTER, ret); +} + HWTEST_F(AvSenderEngineTest, CreateControlChannel_001, testing::ext::TestSize.Level1) { std::string ownerName = "001"; @@ -125,6 +155,19 @@ HWTEST_F(AvSenderEngineTest, Start_002, testing::ext::TestSize.Level1) EXPECT_EQ(DH_AVT_SUCCESS, ret); } +HWTEST_F(AvSenderEngineTest, Start_003, testing::ext::TestSize.Level1) +{ + std::string ownerName = "001"; + std::string peerDevId = "pEid"; + auto sender = std::make_shared(ownerName, peerDevId); + sender->currentState_ = StateId::CH_CREATED; + sender->pipeline_ = std::make_shared(); + sender->dhfwkKit_ = std::make_shared(); + int32_t ret = sender->Start(); + sender->Stop(); + EXPECT_EQ(ERR_DH_AVT_CREATE_CHANNEL_FAILED, ret); +} + HWTEST_F(AvSenderEngineTest, Stop_001, testing::ext::TestSize.Level1) { std::string ownerName = "001"; @@ -296,12 +339,104 @@ HWTEST_F(AvSenderEngineTest, PreparePipeline_004, testing::ext::TestSize.Level1) HWTEST_F(AvSenderEngineTest, SendMessage_001, testing::ext::TestSize.Level1) { - std::string ownerName = "001"; + std::string ownerName = OWNER_NAME_D_MIC; std::string peerDevId = "pEid"; - std::string configParam = "value"; auto sender = std::make_shared(ownerName, peerDevId); + EventType type = EventType::EVENT_ADD_STREAM; + sender->NotifyStreamChange(type); int32_t ret = sender->SendMessage(nullptr); EXPECT_EQ(ERR_DH_AVT_INVALID_PARAM, ret); } + +HWTEST_F(AvSenderEngineTest, SendMessage_002, testing::ext::TestSize.Level1) +{ + std::string ownerName = OWNER_NAME_D_SPEAKER; + std::string peerDevId = "pEid"; + auto sender = std::make_shared(ownerName, peerDevId); + EventType type = EventType::EVENT_ADD_STREAM; + sender->NotifyStreamChange(type); + std::shared_ptr message = std::make_shared(); + int32_t ret = sender->SendMessage(message); + EXPECT_EQ(ERR_DH_AVT_INVALID_PARAM, ret); +} + +HWTEST_F(AvSenderEngineTest, RegisterSenderCallback_001, testing::ext::TestSize.Level1) +{ + std::string ownerName = OWNER_NAME_D_SCREEN; + std::string peerDevId = "pEid"; + auto sender = std::make_shared(ownerName, peerDevId); + EventType type = EventType::EVENT_ADD_STREAM; + sender->NotifyStreamChange(type); + std::shared_ptr callback = std::make_shared(); + int32_t ret = sender->RegisterSenderCallback(callback); + EXPECT_EQ(DH_AVT_SUCCESS, ret); +} + +HWTEST_F(AvSenderEngineTest, RegisterSenderCallback_002, testing::ext::TestSize.Level1) +{ + std::string ownerName = OWNER_NAME_D_CAMERA; + std::string peerDevId = "pEid"; + auto sender = std::make_shared(ownerName, peerDevId); + EventType type = EventType::EVENT_ADD_STREAM; + sender->NotifyStreamChange(type); + std::shared_ptr callback = nullptr; + int32_t ret = sender->RegisterSenderCallback(callback); + EXPECT_EQ(ERR_DH_AVT_INVALID_PARAM, ret); +} + +HWTEST_F(AvSenderEngineTest, OnChannelEvent_001, testing::ext::TestSize.Level1) +{ + std::string ownerName = OWNER_NAME_D_CAMERA; + std::string peerDevId = "pEid"; + auto sender = std::make_shared(ownerName, peerDevId); + sender->senderCallback_ = nullptr; + AVTransEvent transEvent; + transEvent.content = "content"; + transEvent.type = EventType::EVENT_CHANNEL_OPENED; + sender->OnChannelEvent(transEvent); + + sender->senderCallback_ = std::make_shared(); + sender->OnChannelEvent(transEvent); + Event event; + event.type = OHOS::Media::EventType::EVENT_PLUGIN_EVENT; + sender->OnEvent(event); + + EXPECT_EQ(StateId::CH_CREATED, sender->currentState_); +} + +HWTEST_F(AvSenderEngineTest, OnChannelEvent_002, testing::ext::TestSize.Level1) +{ + std::string ownerName = OWNER_NAME_D_CAMERA; + std::string peerDevId = "pEid"; + auto sender = std::make_shared(ownerName, peerDevId); + AVTransEvent transEvent; + transEvent.content = "content"; + transEvent.type = EventType::EVENT_CHANNEL_OPEN_FAIL; + sender->senderCallback_ = std::make_shared(); + sender->OnChannelEvent(transEvent); + Event event; + event.type = OHOS::Media::EventType::EVENT_PLUGIN_EVENT; + sender->OnEvent(event); + + EXPECT_EQ(StateId::INITIALIZED, sender->currentState_); +} + +HWTEST_F(AvSenderEngineTest, OnChannelEvent_003, testing::ext::TestSize.Level1) +{ + std::string ownerName = OWNER_NAME_D_CAMERA; + std::string peerDevId = "pEid"; + auto sender = std::make_shared(ownerName, peerDevId); + AVTransEvent event; + event.content = "content"; + event.type = EventType::EVENT_CHANNEL_CLOSED; + sender->senderCallback_ = std::make_shared(); + sender->currentState_ = StateId::CH_CREATED; + sender->OnChannelEvent(event); + + event.type = EventType::EVENT_DATA_RECEIVED; + sender->OnChannelEvent(event); + + EXPECT_EQ(StateId::INITIALIZED, sender->currentState_); +} } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine_provider/src/av_sender_engine_provider_test.cpp b/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine_provider/src/av_sender_engine_provider_test.cpp index 0db2c6d6c262954ffe6c5279db90685920e668a4..04d7bc0da451fc303a68061de5d0c219a1fc725c 100644 --- a/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine_provider/src/av_sender_engine_provider_test.cpp +++ b/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine_provider/src/av_sender_engine_provider_test.cpp @@ -76,9 +76,13 @@ HWTEST_F(AvSenderEngineProviderTest, GetAVSenderEngineList_002, testing::ext::Te HWTEST_F(AvSenderEngineProviderTest, RegisterProviderCallback_001, testing::ext::TestSize.Level1) { std::string ownerName = "ownerName"; + std::string peerDevId = "peerDevId"; auto avSendProTest_ = std::make_shared(ownerName); std::shared_ptr callback = nullptr; int32_t ret = avSendProTest_->RegisterProviderCallback(callback); + AVTransEvent event = {EventType::EVENT_ADD_STREAM, ownerName, peerDevId}; + avSendProTest_->providerCallback_ = nullptr; + avSendProTest_->OnChannelEvent(event); EXPECT_EQ(DH_AVT_SUCCESS, ret); } } // namespace DistributedHardware diff --git a/av_transport/av_trans_engine/plugin/test/BUILD.gn b/av_transport/av_trans_engine/plugin/test/unittest/BUILD.gn similarity index 49% rename from av_transport/av_trans_engine/plugin/test/BUILD.gn rename to av_transport/av_trans_engine/plugin/test/unittest/BUILD.gn index 0f3fc96faebdffdea142eb70710663b87e683c22..50456f18d48d9b691218f20b82471b313162343c 100644 --- a/av_transport/av_trans_engine/plugin/test/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/test/unittest/BUILD.gn @@ -15,13 +15,14 @@ group("plugin_test") { testonly = true deps = [ - "av_trans_input/daudio_input_test:daudio_input_unittest", - "av_trans_input/dscreen_input_test:dscreen_input_unittest", - "av_trans_input/dsoftbus_input_audio_test:dsoftbus_input_audio_unittest", - "av_trans_input/dsoftbus_input_test:dsoftbus_input_unittest", - "av_trans_output/daudio_output_test:daudio_output_unittest", - "av_trans_output/dscreen_output_test:dscreen_output_unittest", - "av_trans_output/dsoftbus_output_audio_test:dsoftbus_output_audio_unittest", - "av_trans_output/dsoftbus_output_test:dsoftbus_output_unittest", + "core:avtrans_input_output_unittest", + "plugins/av_trans_input/daudio_input_test:daudio_input_unittest", + "plugins/av_trans_input/dscreen_input_test:dscreen_input_unittest", + "plugins/av_trans_input/dsoftbus_input_audio_test:dsoftbus_input_audio_unittest", + "plugins/av_trans_input/dsoftbus_input_test:dsoftbus_input_unittest", + "plugins/av_trans_output/daudio_output_test:daudio_output_unittest", + "plugins/av_trans_output/dscreen_output_test:dscreen_output_unittest", + "plugins/av_trans_output/dsoftbus_output_audio_test:dsoftbus_output_audio_unittest", + "plugins/av_trans_output/dsoftbus_output_test:dsoftbus_output_unittest", ] } diff --git a/av_transport/av_trans_engine/plugin/test/unittest/core/BUILD.gn b/av_transport/av_trans_engine/plugin/test/unittest/core/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..070e97b9b6af153a0bfe6d968b93765ffc554f49 --- /dev/null +++ b/av_transport/av_trans_engine/plugin/test/unittest/core/BUILD.gn @@ -0,0 +1,70 @@ +# Copyright (c) 2023 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("../../../../../distributed_av_transport.gni") + +module_out_path = "distributed_hardware_fwk/avtrans_input_output_unittest" + +ohos_unittest("AvTransInputOutputTest") { + module_out_path = module_out_path + + include_dirs = [ + "//third_party/ffmpeg", + "//third_party/json/include", + "${plugin_path}/core", + "${plugin_path}/interface", + "${common_path}/include", + ] + + sources = [ + "avtrans_input_test.cpp", + "avtrans_output_test.cpp", + ] + + cflags = [ + "-O2", + "-fPIC", + "-Wall", + "-frtti", + "-fexceptions", + "-Dprivate = public", + ] + cflags_cc = cflags + + deps = [ "//third_party/googletest:gtest" ] + + external_deps = [ + "bounds_checking_function:libsec_shared", + "c_utils:utils", + "eventhandler:libeventhandler", + "hilog:libhilog", + "histreamer:histreamer_base", + "histreamer:histreamer_codec_filters", + "histreamer:histreamer_ffmpeg_convert", + "histreamer:histreamer_plugin_base", + "kv_store:distributeddata_inner", + "safwk:system_ability_fwk", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"avtrans_input_output_test\"", + "LOG_DOMAIN=0xD004100", + ] +} + +group("avtrans_input_output_unittest") { + testonly = true + deps = [ ":AvTransInputOutputTest" ] +} diff --git a/av_transport/av_trans_engine/plugin/test/unittest/core/avtrans_input_test.cpp b/av_transport/av_trans_engine/plugin/test/unittest/core/avtrans_input_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d4b6cecdaafe44639f1c9fdba230d04dd580ac00 --- /dev/null +++ b/av_transport/av_trans_engine/plugin/test/unittest/core/avtrans_input_test.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2023 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 "avtrans_input_test.h" + +namespace OHOS { +namespace DistributedHardware { +void AvTransInputTest::SetUpTestCase() {} + +void AvTransInputTest::TearDownTestCase() {} + +void AvTransInputTest::SetUp() +{ + uint32_t pkgVer = 2; + uint32_t apiVer = 2; + std::shared_ptr plugin = std::make_shared(); + input_ = std::make_shared(pkgVer, apiVer, plugin); +} + +void AvTransInputTest::TearDown() {} + +HWTEST_F(AvTransInputTest, Pause_001, TestSize.Level0) +{ + Status ret = input_->Pause(); + EXPECT_EQ(Status::OK, ret); +} + +HWTEST_F(AvTransInputTest, Resume_001, TestSize.Level0) +{ + Status ret = input_->Resume(); + EXPECT_EQ(Status::OK, ret); +} + +HWTEST_F(AvTransInputTest, PushData_001, TestSize.Level0) +{ + std::string inPort = "inPort"; + std::shared_ptr buffer = nullptr; + int32_t offset = 0; + Status ret = input_->PushData(inPort, buffer, offset); + EXPECT_EQ(Status::OK, ret); +} + +HWTEST_F(AvTransInputTest, SetDataCallback_001, TestSize.Level0) +{ + std::function)> callback = nullptr; + Status ret = input_->SetDataCallback(callback); + EXPECT_EQ(Status::OK, ret); +} +} // namespace DistributedHardware +} // namespace OHOS \ No newline at end of file diff --git a/av_transport/av_trans_engine/plugin/test/unittest/core/avtrans_input_test.h b/av_transport/av_trans_engine/plugin/test/unittest/core/avtrans_input_test.h new file mode 100644 index 0000000000000000000000000000000000000000..fe707063fad9b2a43f129f7199aa3d6dfc8f76f7 --- /dev/null +++ b/av_transport/av_trans_engine/plugin/test/unittest/core/avtrans_input_test.h @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2023 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 OHOS_DISTRIBUTED_HARDWARE_AVTRANS_INPUT_TEST_H +#define OHOS_DISTRIBUTED_HARDWARE_AVTRANS_INPUT_TEST_H + +#include "gtest/gtest.h" + +#include "avtrans_input.h" + +#include "av_sync_utils.h" +#include "av_trans_buffer.h" +#include "av_trans_constants.h" +#include "av_trans_log.h" +#include "av_trans_meta.h" +#include "av_trans_types.h" +#include "av_trans_utils.h" +#include "avtrans_input_plugin.h" +#include "nlohmann/json.hpp" +#include "plugin_manager.h" +#include "plugin_types.h" + +namespace OHOS { +namespace DistributedHardware { +using namespace testing::ext; +using namespace std; +class AvTransInputTest : public testing::Test { +public: + AvTransInputTest() {} + ~AvTransInputTest() {} + + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + std::shared_ptr input_ = nullptr; +}; +class AvTransInputPluginTest : public AvTransInputPlugin { +public: + AvTransInputPluginTest() = default; + ~AvTransInputPluginTest() = default; + OHOS::Media::Plugin::Status Pause() override + { + return Status::OK; + } + OHOS::Media::Plugin::Status Resume() override + { + return Status::OK; + } + OHOS::Media::Plugin::Status PushData(const std::string& inPort, std::shared_ptr buffer, + int32_t offset) override + { + (void) inPort; + (void) buffer; + (void) offset; + return Status::OK; + } + OHOS::Media::Plugin::Status SetDataCallback( + std::function)> callback) override + { + (void) callback; + return Status::OK; + } +}; +} // namespace DistributedHardware +} // namespace OHOS +#endif // OHOS_DISTRIBUTED_HARDWARE_AVTRANS_INPUT_TEST_H \ No newline at end of file diff --git a/av_transport/av_trans_engine/plugin/test/unittest/core/avtrans_output_test.cpp b/av_transport/av_trans_engine/plugin/test/unittest/core/avtrans_output_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..39749bf6231c1d32fa1891e3e5de127728aa3096 --- /dev/null +++ b/av_transport/av_trans_engine/plugin/test/unittest/core/avtrans_output_test.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 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 "avtrans_output_test.h" + +namespace OHOS { +namespace DistributedHardware { + +void AvTransOutputTest::SetUpTestCase() {} + +void AvTransOutputTest::TearDownTestCase() {} + +void AvTransOutputTest::SetUp() +{ + uint32_t pkgVer = 2; + uint32_t apiVer = 2; + std::shared_ptr plugin = std::make_shared(); + transOutput_ = std::make_shared(pkgVer, apiVer, plugin); +} + +void AvTransOutputTest::TearDown() {} + +HWTEST_F(AvTransOutputTest, PushData_001, TestSize.Level0) +{ + std::string inPort = "inPort"; + std::shared_ptr buffer = nullptr; + int32_t offset = 0; + Status ret = transOutput_->PushData(inPort, buffer, offset); + EXPECT_EQ(Status::OK, ret); +} + +HWTEST_F(AvTransOutputTest, SetDataCallback_001, TestSize.Level0) +{ + std::function)> callback = nullptr; + Status ret = transOutput_->SetDataCallback(callback); + EXPECT_EQ(Status::OK, ret); +} +} // namespace DistributedHardware +} // namespace OHOS \ No newline at end of file diff --git a/av_transport/av_trans_engine/plugin/test/unittest/core/avtrans_output_test.h b/av_transport/av_trans_engine/plugin/test/unittest/core/avtrans_output_test.h new file mode 100644 index 0000000000000000000000000000000000000000..9fdbfa288db048dbeca5a058b97c3f8bb79c06aa --- /dev/null +++ b/av_transport/av_trans_engine/plugin/test/unittest/core/avtrans_output_test.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2023 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 OHOS_DISTRIBUTED_HARDWARE_AVTRANS_OUTPUT_TEST_H +#define OHOS_DISTRIBUTED_HARDWARE_AVTRANS_OUTPUT_TEST_H + +#include "gtest/gtest.h" + +#include "avtrans_output.h" + +#include "av_sync_utils.h" +#include "av_trans_buffer.h" +#include "av_trans_constants.h" +#include "av_trans_meta.h" +#include "av_trans_types.h" +#include "av_trans_utils.h" +#include "avtrans_output_plugin.h" +#include "nlohmann/json.hpp" +#include "plugin_manager.h" +#include "plugin_types.h" + +namespace OHOS { +namespace DistributedHardware { +using namespace testing::ext; +using namespace std; +class AvTransOutputTest : public testing::Test { +public: + AvTransOutputTest() {} + ~AvTransOutputTest() {} + + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + std::shared_ptr transOutput = nullptr; +}; +class AvTransOutputPluginTest : public AvTransOutputPlugin { +public: + AvTransOutputPluginTest() = default; + ~AvTransOutputPluginTest() = default; + OHOS::Media::Plugin::Status PushData(const std::string& inPort, std::shared_ptr buffer, + int32_t offset) override + { + (void) inPort; + (void) buffer; + (void) offset; + return Status::OK; + } + OHOS::Media::Plugin::Status SetDataCallback( + std::function)> callback) override + { + (void) callback; + return Status::OK; + } +}; +} // namespace DistributedHardware +} // namespace OHOS +#endif // OHOS_DISTRIBUTED_HARDWARE_AVTRANS_OUTPUT_TEST_H \ No newline at end of file diff --git a/av_transport/av_trans_engine/plugin/test/av_trans_input/daudio_input_test/BUILD.gn b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/daudio_input_test/BUILD.gn similarity index 97% rename from av_transport/av_trans_engine/plugin/test/av_trans_input/daudio_input_test/BUILD.gn rename to av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/daudio_input_test/BUILD.gn index 0e7bd934bb407edcec69452a33724857da4988a5..034c922b2572371d746f09d5fdfc1e17a599616d 100644 --- a/av_transport/av_trans_engine/plugin/test/av_trans_input/daudio_input_test/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/daudio_input_test/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. import("//build/test.gni") -import("../../../../../distributed_av_transport.gni") +import("../../../../../../../distributed_av_transport.gni") module_out_path = "distributed_hardware_fwk/daudio_input_test" diff --git a/av_transport/av_trans_engine/plugin/test/av_trans_input/daudio_input_test/daudio_input_test.cpp b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/daudio_input_test/daudio_input_test.cpp similarity index 100% rename from av_transport/av_trans_engine/plugin/test/av_trans_input/daudio_input_test/daudio_input_test.cpp rename to av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/daudio_input_test/daudio_input_test.cpp diff --git a/av_transport/av_trans_engine/plugin/test/av_trans_input/daudio_input_test/daudio_input_test.h b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/daudio_input_test/daudio_input_test.h similarity index 100% rename from av_transport/av_trans_engine/plugin/test/av_trans_input/daudio_input_test/daudio_input_test.h rename to av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/daudio_input_test/daudio_input_test.h diff --git a/av_transport/av_trans_engine/plugin/test/av_trans_input/dscreen_input_test/BUILD.gn b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/dscreen_input_test/BUILD.gn similarity index 97% rename from av_transport/av_trans_engine/plugin/test/av_trans_input/dscreen_input_test/BUILD.gn rename to av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/dscreen_input_test/BUILD.gn index 19bd514074f0176bd370c1de4cac8d851580bd4f..9ce1dbe25dec23a797338d1f9427ea7c9e528e3f 100644 --- a/av_transport/av_trans_engine/plugin/test/av_trans_input/dscreen_input_test/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/dscreen_input_test/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. import("//build/test.gni") -import("../../../../../distributed_av_transport.gni") +import("../../../../../../../distributed_av_transport.gni") module_out_path = "distributed_hardware_fwk/dscreen_input_test" diff --git a/av_transport/av_trans_engine/plugin/test/av_trans_input/dscreen_input_test/dscreen_input_test.cpp b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/dscreen_input_test/dscreen_input_test.cpp similarity index 100% rename from av_transport/av_trans_engine/plugin/test/av_trans_input/dscreen_input_test/dscreen_input_test.cpp rename to av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/dscreen_input_test/dscreen_input_test.cpp diff --git a/av_transport/av_trans_engine/plugin/test/av_trans_input/dscreen_input_test/dscreen_input_test.h b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/dscreen_input_test/dscreen_input_test.h similarity index 100% rename from av_transport/av_trans_engine/plugin/test/av_trans_input/dscreen_input_test/dscreen_input_test.h rename to av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/dscreen_input_test/dscreen_input_test.h diff --git a/av_transport/av_trans_engine/plugin/test/av_trans_input/dsoftbus_input_audio_test/BUILD.gn b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/dsoftbus_input_audio_test/BUILD.gn similarity index 97% rename from av_transport/av_trans_engine/plugin/test/av_trans_input/dsoftbus_input_audio_test/BUILD.gn rename to av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/dsoftbus_input_audio_test/BUILD.gn index 7aae125d0123f0705cf4b4788d06a2ceadf30ba9..165e6eff93a0c30a3a6cf8ed76169eeed70eb967 100644 --- a/av_transport/av_trans_engine/plugin/test/av_trans_input/dsoftbus_input_audio_test/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/dsoftbus_input_audio_test/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. import("//build/test.gni") -import("../../../../../distributed_av_transport.gni") +import("../../../../../../../distributed_av_transport.gni") module_out_path = "distributed_hardware_fwk/dsoftbus_input_audio_plugin_test" diff --git a/av_transport/av_trans_engine/plugin/test/av_trans_input/dsoftbus_input_audio_test/dsoftbus_input_audio_plugin_test.cpp b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/dsoftbus_input_audio_test/dsoftbus_input_audio_plugin_test.cpp similarity index 100% rename from av_transport/av_trans_engine/plugin/test/av_trans_input/dsoftbus_input_audio_test/dsoftbus_input_audio_plugin_test.cpp rename to av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/dsoftbus_input_audio_test/dsoftbus_input_audio_plugin_test.cpp diff --git a/av_transport/av_trans_engine/plugin/test/av_trans_input/dsoftbus_input_audio_test/dsoftbus_input_audio_plugin_test.h b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/dsoftbus_input_audio_test/dsoftbus_input_audio_plugin_test.h similarity index 100% rename from av_transport/av_trans_engine/plugin/test/av_trans_input/dsoftbus_input_audio_test/dsoftbus_input_audio_plugin_test.h rename to av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/dsoftbus_input_audio_test/dsoftbus_input_audio_plugin_test.h diff --git a/av_transport/av_trans_engine/plugin/test/av_trans_input/dsoftbus_input_test/BUILD.gn b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/dsoftbus_input_test/BUILD.gn similarity index 97% rename from av_transport/av_trans_engine/plugin/test/av_trans_input/dsoftbus_input_test/BUILD.gn rename to av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/dsoftbus_input_test/BUILD.gn index b986fd15b5a23b39f6046435435e0edc12e0f5bf..7f43975b190dc51b23f5e513abf047d981aae148 100644 --- a/av_transport/av_trans_engine/plugin/test/av_trans_input/dsoftbus_input_test/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/dsoftbus_input_test/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. import("//build/test.gni") -import("../../../../../distributed_av_transport.gni") +import("../../../../../../../distributed_av_transport.gni") module_out_path = "distributed_hardware_fwk/dsoftbus_input_test" diff --git a/av_transport/av_trans_engine/plugin/test/av_trans_input/dsoftbus_input_test/dsoftbus_input_plugin_test.cpp b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/dsoftbus_input_test/dsoftbus_input_plugin_test.cpp similarity index 100% rename from av_transport/av_trans_engine/plugin/test/av_trans_input/dsoftbus_input_test/dsoftbus_input_plugin_test.cpp rename to av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/dsoftbus_input_test/dsoftbus_input_plugin_test.cpp diff --git a/av_transport/av_trans_engine/plugin/test/av_trans_input/dsoftbus_input_test/dsoftbus_input_plugin_test.h b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/dsoftbus_input_test/dsoftbus_input_plugin_test.h similarity index 100% rename from av_transport/av_trans_engine/plugin/test/av_trans_input/dsoftbus_input_test/dsoftbus_input_plugin_test.h rename to av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_input/dsoftbus_input_test/dsoftbus_input_plugin_test.h diff --git a/av_transport/av_trans_engine/plugin/test/av_trans_output/daudio_output_test/BUILD.gn b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/daudio_output_test/BUILD.gn similarity index 97% rename from av_transport/av_trans_engine/plugin/test/av_trans_output/daudio_output_test/BUILD.gn rename to av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/daudio_output_test/BUILD.gn index ee8db27218b557c0e76a00563478172a8f804433..1dd2bd716fc951c4410eefe55e2eee8021504cee 100644 --- a/av_transport/av_trans_engine/plugin/test/av_trans_output/daudio_output_test/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/daudio_output_test/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. import("//build/test.gni") -import("../../../../../distributed_av_transport.gni") +import("../../../../../../../distributed_av_transport.gni") module_out_path = "distributed_hardware_fwk/daudio_output_test" diff --git a/av_transport/av_trans_engine/plugin/test/av_trans_output/daudio_output_test/daudio_output_test.cpp b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/daudio_output_test/daudio_output_test.cpp similarity index 100% rename from av_transport/av_trans_engine/plugin/test/av_trans_output/daudio_output_test/daudio_output_test.cpp rename to av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/daudio_output_test/daudio_output_test.cpp diff --git a/av_transport/av_trans_engine/plugin/test/av_trans_output/daudio_output_test/daudio_output_test.h b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/daudio_output_test/daudio_output_test.h similarity index 100% rename from av_transport/av_trans_engine/plugin/test/av_trans_output/daudio_output_test/daudio_output_test.h rename to av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/daudio_output_test/daudio_output_test.h diff --git a/av_transport/av_trans_engine/plugin/test/av_trans_output/dscreen_output_test/BUILD.gn b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/dscreen_output_test/BUILD.gn similarity index 97% rename from av_transport/av_trans_engine/plugin/test/av_trans_output/dscreen_output_test/BUILD.gn rename to av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/dscreen_output_test/BUILD.gn index 84c4948c8a0bb092a0b2f6e3b9d537063a4389fb..a1c698e29cc95d3a118dbd11a99295fdf5d15be6 100644 --- a/av_transport/av_trans_engine/plugin/test/av_trans_output/dscreen_output_test/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/dscreen_output_test/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. import("//build/test.gni") -import("../../../../../distributed_av_transport.gni") +import("../../../../../../../distributed_av_transport.gni") module_out_path = "distributed_hardware_fwk/dscreen_output_test" diff --git a/av_transport/av_trans_engine/plugin/test/av_trans_output/dscreen_output_test/dscreen_output_test.cpp b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/dscreen_output_test/dscreen_output_test.cpp similarity index 100% rename from av_transport/av_trans_engine/plugin/test/av_trans_output/dscreen_output_test/dscreen_output_test.cpp rename to av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/dscreen_output_test/dscreen_output_test.cpp diff --git a/av_transport/av_trans_engine/plugin/test/av_trans_output/dscreen_output_test/dscreen_output_test.h b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/dscreen_output_test/dscreen_output_test.h similarity index 100% rename from av_transport/av_trans_engine/plugin/test/av_trans_output/dscreen_output_test/dscreen_output_test.h rename to av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/dscreen_output_test/dscreen_output_test.h diff --git a/av_transport/av_trans_engine/plugin/test/av_trans_output/dsoftbus_output_audio_test/BUILD.gn b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/dsoftbus_output_audio_test/BUILD.gn similarity index 97% rename from av_transport/av_trans_engine/plugin/test/av_trans_output/dsoftbus_output_audio_test/BUILD.gn rename to av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/dsoftbus_output_audio_test/BUILD.gn index 6d3aad0fb20b44356dc73e731eff56baaa3e4468..805cee81fa6d1e9b578be1f36f73a4ed57fab648 100644 --- a/av_transport/av_trans_engine/plugin/test/av_trans_output/dsoftbus_output_audio_test/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/dsoftbus_output_audio_test/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. import("//build/test.gni") -import("../../../../../distributed_av_transport.gni") +import("../../../../../../../distributed_av_transport.gni") module_out_path = "distributed_hardware_fwk/dsoftbus_output_audio_test" diff --git a/av_transport/av_trans_engine/plugin/test/av_trans_output/dsoftbus_output_audio_test/dsoftbus_output_audio_plugin_test.cpp b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/dsoftbus_output_audio_test/dsoftbus_output_audio_plugin_test.cpp similarity index 100% rename from av_transport/av_trans_engine/plugin/test/av_trans_output/dsoftbus_output_audio_test/dsoftbus_output_audio_plugin_test.cpp rename to av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/dsoftbus_output_audio_test/dsoftbus_output_audio_plugin_test.cpp diff --git a/av_transport/av_trans_engine/plugin/test/av_trans_output/dsoftbus_output_audio_test/dsoftbus_output_audio_plugin_test.h b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/dsoftbus_output_audio_test/dsoftbus_output_audio_plugin_test.h similarity index 100% rename from av_transport/av_trans_engine/plugin/test/av_trans_output/dsoftbus_output_audio_test/dsoftbus_output_audio_plugin_test.h rename to av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/dsoftbus_output_audio_test/dsoftbus_output_audio_plugin_test.h diff --git a/av_transport/av_trans_engine/plugin/test/av_trans_output/dsoftbus_output_test/BUILD.gn b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/dsoftbus_output_test/BUILD.gn similarity index 97% rename from av_transport/av_trans_engine/plugin/test/av_trans_output/dsoftbus_output_test/BUILD.gn rename to av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/dsoftbus_output_test/BUILD.gn index d5f0bbc9229262a91877be7fe6d943c9f9754b87..dbfa26e80b6459927a1199da8bcf03246178940a 100644 --- a/av_transport/av_trans_engine/plugin/test/av_trans_output/dsoftbus_output_test/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/dsoftbus_output_test/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. import("//build/test.gni") -import("../../../../../distributed_av_transport.gni") +import("../../../../../../../distributed_av_transport.gni") module_out_path = "distributed_hardware_fwk/dsoftbus_output_test" diff --git a/av_transport/av_trans_engine/plugin/test/av_trans_output/dsoftbus_output_test/dsoftbus_output_plugin_test.cpp b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/dsoftbus_output_test/dsoftbus_output_plugin_test.cpp similarity index 100% rename from av_transport/av_trans_engine/plugin/test/av_trans_output/dsoftbus_output_test/dsoftbus_output_plugin_test.cpp rename to av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/dsoftbus_output_test/dsoftbus_output_plugin_test.cpp diff --git a/av_transport/av_trans_engine/plugin/test/av_trans_output/dsoftbus_output_test/dsoftbus_output_plugin_test.h b/av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/dsoftbus_output_test/dsoftbus_output_plugin_test.h similarity index 100% rename from av_transport/av_trans_engine/plugin/test/av_trans_output/dsoftbus_output_test/dsoftbus_output_plugin_test.h rename to av_transport/av_trans_engine/plugin/test/unittest/plugins/av_trans_output/dsoftbus_output_test/dsoftbus_output_plugin_test.h diff --git a/bundle.json b/bundle.json index d4b2a75ba570d90f0d41a0bc362fe2092b694389..6db08a6e7c098025af967571d108c46070431093 100644 --- a/bundle.json +++ b/bundle.json @@ -119,7 +119,7 @@ "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/av_trans_engine/filters/test:filter_test", "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/av_trans_engine/av_receiver/test/unittest:receiver_test", "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/av_trans_engine/av_sender/test/unittest:sender_test", - "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/av_trans_engine/plugin/test:plugin_test" + "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/av_trans_engine/plugin/test/unittest:plugin_test" ] } }