From b81777c1b98c08e65a7226373da9f8a3a5c58770 Mon Sep 17 00:00:00 2001 From: w30042960 Date: Wed, 16 Oct 2024 17:10:56 +0800 Subject: [PATCH] add code Signed-off-by: w30042960 --- .../test/unittest/av_receiver_engine/BUILD.gn | 3 +- .../av_receiver_engine_provider/BUILD.gn | 3 +- .../test/unittest/av_sender_engine/BUILD.gn | 3 +- .../av_sender_engine_provider/BUILD.gn | 3 +- .../av_transport_input_filter_test/BUILD.gn | 4 +- .../av_transport_input_filter_test.cpp | 133 +++++------------ .../av_transport_output_filter_test/BUILD.gn | 4 +- .../av_transport_output_filter_test.cpp | 92 +++--------- .../dsoftbus_input/dsoftbus_input_plugin.cpp | 8 +- .../dsoftbus_output_plugin.cpp | 4 +- .../include/output_controller_listener.h | 6 +- .../include/time_statistician.h | 6 +- .../output_control/src/output_controller.cpp | 8 +- .../src/output_controller_listener.cpp | 6 +- .../av_trans_input/daudio_input_test/BUILD.gn | 6 +- .../dscreen_input_test/BUILD.gn | 6 +- .../dsoftbus_input_audio_test/BUILD.gn | 6 +- .../dsoftbus_input_test/BUILD.gn | 6 +- .../daudio_output_test/BUILD.gn | 6 +- .../dscreen_output_test/BUILD.gn | 6 +- .../dsoftbus_output_audio_test/BUILD.gn | 6 +- .../dsoftbus_output_test/BUILD.gn | 6 +- .../output_control_test/BUILD.gn | 6 +- .../av_trans_engine/plugin/test/core/BUILD.gn | 2 +- .../src/histreamer_ability_querier.cpp | 2 +- .../test/unittest/common/BUILD.gn | 2 - .../include/histreamer_ability_querier_test.h | 5 +- .../src/histreamer_ability_querier_test.cpp | 139 +++++------------- av_transport/common/include/av_trans_log.h | 3 +- 29 files changed, 146 insertions(+), 344 deletions(-) diff --git a/av_transport/av_trans_engine/av_receiver/test/unittest/av_receiver_engine/BUILD.gn b/av_transport/av_trans_engine/av_receiver/test/unittest/av_receiver_engine/BUILD.gn index 7ffca7d0..8fade15e 100644 --- a/av_transport/av_trans_engine/av_receiver/test/unittest/av_receiver_engine/BUILD.gn +++ b/av_transport/av_trans_engine/av_receiver/test/unittest/av_receiver_engine/BUILD.gn @@ -29,7 +29,6 @@ config("module_private_config") { "${filters_path}/av_transport_output", "${engine_path}/av_receiver/test/unittest/av_receiver_engine/include", "${interface_path}", - "${media_standard_path}/interfaces/inner_api/native", "${plugin_path}/core", "${plugin_path}/interface", ] @@ -58,7 +57,6 @@ ohos_unittest("AvReceiverEngineTest") { "${engine_path}/av_receiver:distributed_av_receiver", "${filters_path}:avtrans_input_filter", "${filters_path}:avtrans_output_filter", - "//third_party/googletest:gtest_rtti", ] defines = [ @@ -86,6 +84,7 @@ ohos_unittest("AvReceiverEngineTest") { "cJSON:cjson", "c_utils:utils", "dsoftbus:softbus_client", + "googletest:gtest", "graphic_2d:libgraphic_utils", "graphic_surface:surface", "hilog:libhilog", diff --git a/av_transport/av_trans_engine/av_receiver/test/unittest/av_receiver_engine_provider/BUILD.gn b/av_transport/av_trans_engine/av_receiver/test/unittest/av_receiver_engine_provider/BUILD.gn index 6f04395a..d029012d 100644 --- a/av_transport/av_trans_engine/av_receiver/test/unittest/av_receiver_engine_provider/BUILD.gn +++ b/av_transport/av_trans_engine/av_receiver/test/unittest/av_receiver_engine_provider/BUILD.gn @@ -29,7 +29,6 @@ config("module_private_config") { "${filters_path}/av_transport_output", "${engine_path}/av_receiver/test/unittest/av_receiver_engine_provider/include", "${interface_path}", - "${media_standard_path}/interfaces/inner_api/native", "${plugin_path}/core", "${plugin_path}/interface", ] @@ -58,7 +57,6 @@ ohos_unittest("AvReceiverEngineProviderTest") { "${engine_path}/av_receiver:distributed_av_receiver", "${filters_path}:avtrans_input_filter", "${filters_path}:avtrans_output_filter", - "//third_party/googletest:gtest_rtti", ] defines = [ @@ -86,6 +84,7 @@ ohos_unittest("AvReceiverEngineProviderTest") { "cJSON:cjson", "c_utils:utils", "dsoftbus:softbus_client", + "googletest:gtest", "graphic_2d:libgraphic_utils", "graphic_surface:surface", "hilog:libhilog", diff --git a/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine/BUILD.gn b/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine/BUILD.gn index f5f087ad..76e8ae18 100644 --- a/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine/BUILD.gn +++ b/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine/BUILD.gn @@ -29,7 +29,6 @@ config("module_private_config") { "${filters_path}/av_transport_output", "${engine_path}/av_sender/test/unittest/av_sender_engine/include", "${interface_path}", - "${media_standard_path}/interfaces/inner_api/native", "${plugin_path}/core", "${plugin_path}/interface", ] @@ -57,7 +56,6 @@ ohos_unittest("AvSenderEngineTest") { "${engine_path}/av_sender:distributed_av_sender", "${filters_path}:avtrans_input_filter", "${filters_path}:avtrans_output_filter", - "//third_party/googletest:gtest", ] defines = [ @@ -87,6 +85,7 @@ ohos_unittest("AvSenderEngineTest") { "cJSON:cjson", "c_utils:utils", "dsoftbus:softbus_client", + "googletest:gtest", "graphic_2d:libgraphic_utils", "graphic_surface:surface", "hilog:libhilog", diff --git a/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine_provider/BUILD.gn b/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine_provider/BUILD.gn index 764876f2..f6af26f8 100644 --- a/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine_provider/BUILD.gn +++ b/av_transport/av_trans_engine/av_sender/test/unittest/av_sender_engine_provider/BUILD.gn @@ -29,7 +29,6 @@ config("module_private_config") { "${filters_path}/av_transport_output", "${engine_path}/av_sender/test/unittest/av_sender_engine_provider/include", "${interface_path}", - "${media_standard_path}/interfaces/inner_api/native", "${plugin_path}/core", "${plugin_path}/interface", ] @@ -58,7 +57,6 @@ ohos_unittest("AvSenderEngineProviderTest") { "${engine_path}/av_sender:distributed_av_sender", "${filters_path}:avtrans_input_filter", "${filters_path}:avtrans_output_filter", - "//third_party/googletest:gtest", ] defines = [ @@ -88,6 +86,7 @@ ohos_unittest("AvSenderEngineProviderTest") { "cJSON:cjson", "c_utils:utils", "dsoftbus:softbus_client", + "googletest:gtest", "graphic_2d:libgraphic_utils", "graphic_surface:surface", "hilog:libhilog", diff --git a/av_transport/av_trans_engine/filters/test/av_transport_input_filter_test/BUILD.gn b/av_transport/av_trans_engine/filters/test/av_transport_input_filter_test/BUILD.gn index 2f8d7df8..c51059e9 100644 --- a/av_transport/av_trans_engine/filters/test/av_transport_input_filter_test/BUILD.gn +++ b/av_transport/av_trans_engine/filters/test/av_transport_input_filter_test/BUILD.gn @@ -54,8 +54,6 @@ ohos_unittest("AvTransportInputFilterTest") { deps = [ "${engine_path}/filters:avtrans_input_filter", "${plugin_path}/plugins/av_trans_input/dsoftbus_input:plugin_AVTransDsoftbusInput", - "//third_party/googletest:gtest", - "//third_party/libevdev:libevdev", ] if (histreamer_compile_part) { @@ -72,7 +70,9 @@ ohos_unittest("AvTransportInputFilterTest") { "cJSON:cjson", "c_utils:utils", "dsoftbus:softbus_client", + "googletest:gtest", "hilog:libhilog", + "libevdev:libevdev", ] } diff --git a/av_transport/av_trans_engine/filters/test/av_transport_input_filter_test/av_transport_input_filter_test.cpp b/av_transport/av_trans_engine/filters/test/av_transport_input_filter_test/av_transport_input_filter_test.cpp index cfe13c5c..3b1f42f1 100644 --- a/av_transport/av_trans_engine/filters/test/av_transport_input_filter_test/av_transport_input_filter_test.cpp +++ b/av_transport/av_trans_engine/filters/test/av_transport_input_filter_test/av_transport_input_filter_test.cpp @@ -52,9 +52,7 @@ HWTEST_F(AvTransportInputFilterTest, SetParameter_001, testing::ext::TestSize.Le FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); int32_t key = -1; Any value = VideoBitStreamFormat::ANNEXB; - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); ErrorCode ret = avInputTest_->SetParameter(key, value); EXPECT_EQ(ErrorCode::ERROR_INVALID_PARAMETER_VALUE, ret); } @@ -65,9 +63,7 @@ HWTEST_F(AvTransportInputFilterTest, SetParameter_002, testing::ext::TestSize.Le FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); int32_t key = static_cast(Plugin::Tag::MIME); Any value = MEDIA_MIME_VIDEO_H264; - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); ErrorCode ret = avInputTest_->SetParameter(key, value); EXPECT_EQ(ErrorCode::SUCCESS, ret); @@ -81,9 +77,7 @@ HWTEST_F(AvTransportInputFilterTest, GetParameter_001, testing::ext::TestSize.Le { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); int32_t key = -1; Any value = VideoBitStreamFormat::ANNEXB; ErrorCode ret = avInputTest_->GetParameter(key, value); @@ -94,9 +88,7 @@ HWTEST_F(AvTransportInputFilterTest, GetParameter_002, testing::ext::TestSize.Le { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); int32_t key = static_cast(Plugin::Tag::MIME); Any value = VideoBitStreamFormat::ANNEXB; ErrorCode ret = avInputTest_->GetParameter(key, value); @@ -107,9 +99,7 @@ HWTEST_F(AvTransportInputFilterTest, Prepare_001, testing::ext::TestSize.Level1) { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); ErrorCode ret = avInputTest_->Prepare(); EXPECT_EQ(ErrorCode::ERROR_INVALID_STATE, ret); } @@ -118,9 +108,7 @@ HWTEST_F(AvTransportInputFilterTest, Prepare_002, testing::ext::TestSize.Level1) { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); avInputTest_->state_ = FilterState::INITIALIZED; ErrorCode ret = avInputTest_->Prepare(); EXPECT_EQ(ErrorCode::ERROR_INVALID_PARAMETER_VALUE, ret); @@ -130,9 +118,7 @@ HWTEST_F(AvTransportInputFilterTest, Start_001, testing::ext::TestSize.Level1) { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); ErrorCode ret = avInputTest_->Start(); EXPECT_EQ(ErrorCode::ERROR_INVALID_STATE, ret); @@ -149,9 +135,7 @@ HWTEST_F(AvTransportInputFilterTest, Start_002, testing::ext::TestSize.Level1) { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); avInputTest_->state_ = FilterState::READY; avInputTest_->plugin_ = PluginManager::Instance().CreateGenericPlugin("AVTransDaudioInputPlugin"); @@ -163,9 +147,7 @@ HWTEST_F(AvTransportInputFilterTest, Stop_001, testing::ext::TestSize.Level1) { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); ErrorCode ret = avInputTest_->Stop(); EXPECT_EQ(ErrorCode::ERROR_NULL_POINTER, ret); avInputTest_->plugin_ = @@ -184,9 +166,7 @@ HWTEST_F(AvTransportInputFilterTest, Stop_002, testing::ext::TestSize.Level1) { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); avInputTest_->state_ = FilterState::RUNNING; avInputTest_->plugin_ = PluginManager::Instance().CreateGenericPlugin("AVTransDaudioInputPlugin"); @@ -198,9 +178,7 @@ HWTEST_F(AvTransportInputFilterTest, Pause_001, testing::ext::TestSize.Level1) { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); ErrorCode ret = avInputTest_->Pause(); EXPECT_EQ(ErrorCode::ERROR_INVALID_STATE, ret); @@ -213,9 +191,7 @@ HWTEST_F(AvTransportInputFilterTest, Pause_002, testing::ext::TestSize.Level1) { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); avInputTest_->state_ = FilterState::READY; ErrorCode ret = avInputTest_->Pause(); EXPECT_EQ(ErrorCode::ERROR_NULL_POINTER, ret); @@ -229,9 +205,7 @@ HWTEST_F(AvTransportInputFilterTest, Pause_003, testing::ext::TestSize.Level1) { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); avInputTest_->state_ = FilterState::RUNNING; avInputTest_->plugin_ = PluginManager::Instance().CreateGenericPlugin("AVTransDaudioInputPlugin"); @@ -243,9 +217,7 @@ HWTEST_F(AvTransportInputFilterTest, Resume_001, testing::ext::TestSize.Level1) { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); ErrorCode ret = avInputTest_->Resume(); EXPECT_EQ(ErrorCode::ERROR_NULL_POINTER, ret); } @@ -254,9 +226,7 @@ HWTEST_F(AvTransportInputFilterTest, Resume_002, testing::ext::TestSize.Level1) { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); avInputTest_->plugin_ = PluginManager::Instance().CreateGenericPlugin("AVTransDaudioInputPlugin"); ErrorCode ret = avInputTest_->Resume(); @@ -267,9 +237,7 @@ HWTEST_F(AvTransportInputFilterTest, FindPlugin_001, testing::ext::TestSize.Leve { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); ErrorCode ret = avInputTest_->FindPlugin(); EXPECT_EQ(ErrorCode::ERROR_INVALID_PARAMETER_VALUE, ret); @@ -289,9 +257,7 @@ HWTEST_F(AvTransportInputFilterTest, DoNegotiate_001, testing::ext::TestSize.Lev { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); CapabilitySet outCaps; bool ret = avInputTest_->DoNegotiate(outCaps); EXPECT_EQ(false, ret); @@ -306,9 +272,7 @@ HWTEST_F(AvTransportInputFilterTest, CreatePlugin_001, testing::ext::TestSize.Le { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); std::shared_ptr selectedInfo = nullptr; ErrorCode ret = avInputTest_->CreatePlugin(selectedInfo); EXPECT_EQ(ErrorCode::ERROR_INVALID_PARAMETER_VALUE, ret); @@ -323,9 +287,7 @@ HWTEST_F(AvTransportInputFilterTest, CreatePlugin_002, testing::ext::TestSize.Le { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); std::shared_ptr selectedInfo = std::make_shared(); avInputTest_->plugin_ = nullptr; selectedInfo->name = "name"; @@ -336,9 +298,7 @@ HWTEST_F(AvTransportInputFilterTest, CreatePlugin_002, testing::ext::TestSize.Le ret = avInputTest_->CreatePlugin(selectedInfo); EXPECT_EQ(ErrorCode::SUCCESS, ret); - if (avInputTest_->pluginInfo_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_->pluginInfo_ != nullptr); avInputTest_->pluginInfo_->name = "name"; avInputTest_->CreatePlugin(selectedInfo); EXPECT_EQ(ErrorCode::SUCCESS, ret); @@ -354,6 +314,7 @@ HWTEST_F(AvTransportInputFilterTest, ConfigMeta_001, testing::ext::TestSize.Leve if (avInputTest_ == nullptr) { return; } + ASSERT_TRUE(avInputTest_ != nullptr); Plugin::Meta meta; ErrorCode ret = avInputTest_->ConfigMeta(meta); EXPECT_EQ(ErrorCode::ERROR_NOT_EXISTED, ret); @@ -374,9 +335,7 @@ HWTEST_F(AvTransportInputFilterTest, ConfigVideoMeta_001, testing::ext::TestSize { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); Plugin::Meta meta; ErrorCode ret = avInputTest_->ConfigVideoMeta(meta); EXPECT_EQ(ErrorCode::SUCCESS, ret); @@ -417,9 +376,7 @@ HWTEST_F(AvTransportInputFilterTest, TransAudioChannelLayout_001, testing::ext:: { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); int layoutPtr = 3; OHOS::Media::Plugin::AudioChannelLayout ret = avInputTest_->TransAudioChannelLayout(layoutPtr); EXPECT_EQ(OHOS::Media::Plugin::AudioChannelLayout::UNKNOWN, ret); @@ -433,9 +390,7 @@ HWTEST_F(AvTransportInputFilterTest, TransAudioSampleFormat_001, testing::ext::T { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); int layoutPtr = 5; OHOS::Media::Plugin::AudioSampleFormat ret = avInputTest_->TransAudioSampleFormat(layoutPtr); EXPECT_EQ(OHOS::Media::Plugin::AudioSampleFormat::NONE, ret); @@ -449,9 +404,7 @@ HWTEST_F(AvTransportInputFilterTest, ConfigAudioMeta_001, testing::ext::TestSize { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); Plugin::Meta meta; int32_t key = static_cast(Plugin::Tag::AUDIO_CHANNELS); uint32_t value = 100; @@ -493,9 +446,7 @@ HWTEST_F(AvTransportInputFilterTest, ConfigAudioMeta_001, testing::ext::TestSize HWTEST_F(AvTransportInputFilterTest, ConfigDownStream_001, testing::ext::TestSize.Level1) { auto avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); Plugin::Meta meta; ErrorCode ret = avInputTest_->ConfigDownStream(meta); EXPECT_EQ(ErrorCode::ERROR_INVALID_PARAMETER_VALUE, ret); @@ -505,9 +456,7 @@ HWTEST_F(AvTransportInputFilterTest, InitPlugin_001, testing::ext::TestSize.Leve { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); avInputTest_->plugin_ = nullptr; ErrorCode ret = avInputTest_->InitPlugin(); EXPECT_EQ(ErrorCode::ERROR_INVALID_PARAMETER_VALUE, ret); @@ -522,9 +471,7 @@ HWTEST_F(AvTransportInputFilterTest, ConfigPlugin_001, testing::ext::TestSize.Le { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); ErrorCode ret = avInputTest_->ConfigPlugin(); EXPECT_EQ(ErrorCode::ERROR_NULL_POINTER, ret); @@ -538,9 +485,7 @@ HWTEST_F(AvTransportInputFilterTest, SetPluginParams_001, testing::ext::TestSize { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); ErrorCode ret = avInputTest_->SetPluginParams(); EXPECT_EQ(ErrorCode::ERROR_NULL_POINTER, ret); } @@ -548,9 +493,7 @@ HWTEST_F(AvTransportInputFilterTest, SetPluginParams_001, testing::ext::TestSize HWTEST_F(AvTransportInputFilterTest, SetPluginParams_002, testing::ext::TestSize.Level1) { auto avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); avInputTest_->plugin_ = PluginManager::Instance().CreateGenericPlugin("AVTransDaudioInputPlugin"); avInputTest_->paramsMap_.clear(); @@ -578,9 +521,7 @@ HWTEST_F(AvTransportInputFilterTest, PreparePlugin_001, testing::ext::TestSize.L { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); ErrorCode ret = avInputTest_->PreparePlugin(); EXPECT_EQ(ErrorCode::ERROR_NULL_POINTER, ret); @@ -594,9 +535,7 @@ HWTEST_F(AvTransportInputFilterTest, PushData_001, testing::ext::TestSize.Level1 { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); std::string inPort; AVBufferPtr buffer; int64_t offset = 0; @@ -608,9 +547,7 @@ HWTEST_F(AvTransportInputFilterTest, SetEventCallBack_001, testing::ext::TestSiz { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); avInputTest_->plugin_ = nullptr; ErrorCode ret = avInputTest_->SetEventCallBack(); EXPECT_EQ(ErrorCode::ERROR_NULL_POINTER, ret); @@ -625,9 +562,7 @@ HWTEST_F(AvTransportInputFilterTest, SetDataCallBack_001, testing::ext::TestSize { std::shared_ptr avInputTest_ = FilterFactory::Instance().CreateFilterWithType(AVINPUT_NAME, FILTERNAME); - if (avInputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avInputTest_ != nullptr); std::shared_ptr buffer = nullptr; avInputTest_->OnDataCallback(buffer); avInputTest_->plugin_ = nullptr; diff --git a/av_transport/av_trans_engine/filters/test/av_transport_output_filter_test/BUILD.gn b/av_transport/av_trans_engine/filters/test/av_transport_output_filter_test/BUILD.gn index 0dd71bd7..2639173e 100644 --- a/av_transport/av_trans_engine/filters/test/av_transport_output_filter_test/BUILD.gn +++ b/av_transport/av_trans_engine/filters/test/av_transport_output_filter_test/BUILD.gn @@ -54,8 +54,6 @@ ohos_unittest("AvTransportOutputFilterTest") { deps = [ "${engine_path}/filters:avtrans_output_filter", "${plugin_path}/plugins/av_trans_output/dsoftbus_output_audio:plugin_AVTransDsoftbusOutputAudio", - "//third_party/googletest:gtest", - "//third_party/libevdev:libevdev", ] if (histreamer_compile_part) { @@ -72,7 +70,9 @@ ohos_unittest("AvTransportOutputFilterTest") { "cJSON:cjson", "c_utils:utils", "dsoftbus:softbus_client", + "googletest:gtest", "hilog:libhilog", + "libevdev:libevdev", ] } diff --git a/av_transport/av_trans_engine/filters/test/av_transport_output_filter_test/av_transport_output_filter_test.cpp b/av_transport/av_trans_engine/filters/test/av_transport_output_filter_test/av_transport_output_filter_test.cpp index 42c61f9e..44257ad4 100644 --- a/av_transport/av_trans_engine/filters/test/av_transport_output_filter_test/av_transport_output_filter_test.cpp +++ b/av_transport/av_trans_engine/filters/test/av_transport_output_filter_test/av_transport_output_filter_test.cpp @@ -49,18 +49,14 @@ HWTEST_F(AvTransportOutputFilterTest, SetParameter_001, testing::ext::TestSize.L { int32_t key = -1; Any value = VideoBitStreamFormat::ANNEXB; - if (avOutputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avOutputTest_ != nullptr); ErrorCode ret = avOutputTest_->SetParameter(key, value); EXPECT_EQ(ErrorCode::ERROR_INVALID_PARAMETER_VALUE, ret); } HWTEST_F(AvTransportOutputFilterTest, SetParameter_002, testing::ext::TestSize.Level1) { - if (avOutputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avOutputTest_ != nullptr); int32_t key = static_cast(Plugin::Tag::MIME); Any value = MEDIA_MIME_AUDIO_RAW; ErrorCode ret = avOutputTest_->SetParameter(key, value); @@ -74,9 +70,7 @@ HWTEST_F(AvTransportOutputFilterTest, SetParameter_002, testing::ext::TestSize.L HWTEST_F(AvTransportOutputFilterTest, GetParameter_001, testing::ext::TestSize.Level1) { - if (avOutputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avOutputTest_ != nullptr); int32_t key = -1; Any value = VideoBitStreamFormat::ANNEXB; ErrorCode ret = avOutputTest_->GetParameter(key, value); @@ -85,9 +79,7 @@ HWTEST_F(AvTransportOutputFilterTest, GetParameter_001, testing::ext::TestSize.L HWTEST_F(AvTransportOutputFilterTest, GetParameter_002, testing::ext::TestSize.Level1) { - if (avOutputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avOutputTest_ != nullptr); int32_t key = static_cast(Plugin::Tag::MIME); Any value = VideoBitStreamFormat::ANNEXB; ErrorCode ret = avOutputTest_->GetParameter(key, value); @@ -96,18 +88,14 @@ HWTEST_F(AvTransportOutputFilterTest, GetParameter_002, testing::ext::TestSize.L HWTEST_F(AvTransportOutputFilterTest, Prepare_001, testing::ext::TestSize.Level1) { - if (avOutputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avOutputTest_ != nullptr); ErrorCode ret = avOutputTest_->Prepare(); EXPECT_EQ(ErrorCode::ERROR_INVALID_STATE, ret); } HWTEST_F(AvTransportOutputFilterTest, Prepare_002, testing::ext::TestSize.Level1) { - if (avOutputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avOutputTest_ != nullptr); avOutputTest_->state_ = FilterState::INITIALIZED; ErrorCode ret = avOutputTest_->Prepare(); EXPECT_EQ(ErrorCode::ERROR_INVALID_PARAMETER_VALUE, ret); @@ -115,9 +103,7 @@ HWTEST_F(AvTransportOutputFilterTest, Prepare_002, testing::ext::TestSize.Level1 HWTEST_F(AvTransportOutputFilterTest, Start_001, testing::ext::TestSize.Level1) { - if (avOutputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avOutputTest_ != nullptr); ErrorCode ret = avOutputTest_->Start(); EXPECT_EQ(ErrorCode::ERROR_INVALID_STATE, ret); @@ -132,9 +118,7 @@ HWTEST_F(AvTransportOutputFilterTest, Start_001, testing::ext::TestSize.Level1) HWTEST_F(AvTransportOutputFilterTest, Start_002, testing::ext::TestSize.Level1) { - if (avOutputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avOutputTest_ != nullptr); avOutputTest_->plugin_ = PluginManager::Instance().CreateGenericPlugin("AVTransDaudioOutputPlugin"); avOutputTest_->state_ = FilterState::READY; @@ -144,9 +128,7 @@ HWTEST_F(AvTransportOutputFilterTest, Start_002, testing::ext::TestSize.Level1) HWTEST_F(AvTransportOutputFilterTest, Stop_001, testing::ext::TestSize.Level1) { - if (avOutputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avOutputTest_ != nullptr); avOutputTest_->plugin_ = nullptr; ErrorCode ret = avOutputTest_->Stop(); EXPECT_EQ(ErrorCode::ERROR_NULL_POINTER, ret); @@ -159,9 +141,7 @@ HWTEST_F(AvTransportOutputFilterTest, Stop_001, testing::ext::TestSize.Level1) HWTEST_F(AvTransportOutputFilterTest, Stop_002, testing::ext::TestSize.Level1) { - if (avOutputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avOutputTest_ != nullptr); avOutputTest_->state_ = FilterState::RUNNING; avOutputTest_->plugin_ = PluginManager::Instance().CreateGenericPlugin("AVTransDaudioOutputPlugin"); @@ -171,18 +151,14 @@ HWTEST_F(AvTransportOutputFilterTest, Stop_002, testing::ext::TestSize.Level1) HWTEST_F(AvTransportOutputFilterTest, FindPlugin_001, testing::ext::TestSize.Level1) { - if (avOutputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avOutputTest_ != nullptr); ErrorCode ret = avOutputTest_->FindPlugin(); EXPECT_EQ(ErrorCode::ERROR_INVALID_PARAMETER_VALUE, ret); } HWTEST_F(AvTransportOutputFilterTest, FindPlugin_002, testing::ext::TestSize.Level1) { - if (avOutputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avOutputTest_ != nullptr); int32_t key = static_cast(Plugin::Tag::MIME); Any value = 100; avOutputTest_->plugin_ = @@ -199,9 +175,7 @@ HWTEST_F(AvTransportOutputFilterTest, FindPlugin_002, testing::ext::TestSize.Lev HWTEST_F(AvTransportOutputFilterTest, Negotiate_001, testing::ext::TestSize.Level1) { - if (avOutputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avOutputTest_ != nullptr); std::string inPort = "inPort_test"; std::shared_ptr upstreamCap; Plugin::Capability negotiatedCap; @@ -218,9 +192,7 @@ HWTEST_F(AvTransportOutputFilterTest, Negotiate_001, testing::ext::TestSize.Leve HWTEST_F(AvTransportOutputFilterTest, CreatePlugin_001, testing::ext::TestSize.Level1) { - if (avOutputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avOutputTest_ != nullptr); std::shared_ptr selectedInfo = nullptr; ErrorCode ret = avOutputTest_->CreatePlugin(selectedInfo); EXPECT_EQ(ErrorCode::ERROR_INVALID_PARAMETER_VALUE, ret); @@ -260,9 +232,7 @@ HWTEST_F(AvTransportOutputFilterTest, CreatePlugin_001, testing::ext::TestSize.L HWTEST_F(AvTransportOutputFilterTest, CreatePlugin_002, testing::ext::TestSize.Level1) { - if (avOutputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avOutputTest_ != nullptr); std::shared_ptr selectedInfo = PluginManager::Instance().GetPluginInfo( PluginType::GENERIC_PLUGIN, ""); ErrorCode ret = avOutputTest_->CreatePlugin(selectedInfo); @@ -271,9 +241,7 @@ HWTEST_F(AvTransportOutputFilterTest, CreatePlugin_002, testing::ext::TestSize.L HWTEST_F(AvTransportOutputFilterTest, InitPlugin_001, testing::ext::TestSize.Level1) { - if (avOutputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avOutputTest_ != nullptr); avOutputTest_->plugin_ = nullptr; ErrorCode ret = avOutputTest_->InitPlugin(); EXPECT_EQ(ErrorCode::ERROR_INVALID_PARAMETER_VALUE, ret); @@ -286,9 +254,7 @@ HWTEST_F(AvTransportOutputFilterTest, InitPlugin_001, testing::ext::TestSize.Lev HWTEST_F(AvTransportOutputFilterTest, ConfigPlugin_001, testing::ext::TestSize.Level1) { - if (avOutputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avOutputTest_ != nullptr); ErrorCode ret = avOutputTest_->ConfigPlugin(); EXPECT_EQ(ErrorCode::ERROR_NULL_POINTER, ret); @@ -300,9 +266,7 @@ HWTEST_F(AvTransportOutputFilterTest, ConfigPlugin_001, testing::ext::TestSize.L HWTEST_F(AvTransportOutputFilterTest, PreparePlugin_001, testing::ext::TestSize.Level1) { - if (avOutputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avOutputTest_ != nullptr); avOutputTest_->plugin_ = nullptr; ErrorCode ret = avOutputTest_->PreparePlugin(); EXPECT_EQ(ErrorCode::ERROR_INVALID_PARAMETER_TYPE, ret); @@ -310,9 +274,7 @@ HWTEST_F(AvTransportOutputFilterTest, PreparePlugin_001, testing::ext::TestSize. HWTEST_F(AvTransportOutputFilterTest, PreparePlugin_002, testing::ext::TestSize.Level1) { - if (avOutputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avOutputTest_ != nullptr); ErrorCode ret = avOutputTest_->PreparePlugin(); EXPECT_EQ(ErrorCode::ERROR_INVALID_PARAMETER_TYPE, ret); @@ -324,9 +286,7 @@ HWTEST_F(AvTransportOutputFilterTest, PreparePlugin_002, testing::ext::TestSize. HWTEST_F(AvTransportOutputFilterTest, PushData_001, testing::ext::TestSize.Level1) { - if (avOutputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avOutputTest_ != nullptr); std::string inPort; AVBufferPtr buffer; int64_t offset = 0; @@ -351,9 +311,7 @@ HWTEST_F(AvTransportOutputFilterTest, PushData_001, testing::ext::TestSize.Level HWTEST_F(AvTransportOutputFilterTest, SetPluginParams_001, testing::ext::TestSize.Level1) { - if (avOutputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avOutputTest_ != nullptr); avOutputTest_->plugin_ = nullptr; ErrorCode ret = avOutputTest_->SetPluginParams(); EXPECT_EQ(ErrorCode::ERROR_NULL_POINTER, ret); @@ -402,9 +360,7 @@ HWTEST_F(AvTransportOutputFilterTest, SetPluginParams_001, testing::ext::TestSiz HWTEST_F(AvTransportOutputFilterTest, SetEventCallBack_001, testing::ext::TestSize.Level1) { - if (avOutputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avOutputTest_ != nullptr); avOutputTest_->plugin_ = PluginManager::Instance().CreateGenericPlugin("AVTransDaudioOutputPlugin"); ErrorCode ret = avOutputTest_->SetEventCallBack(); @@ -417,9 +373,7 @@ HWTEST_F(AvTransportOutputFilterTest, SetEventCallBack_001, testing::ext::TestSi HWTEST_F(AvTransportOutputFilterTest, SetDataCallBack_001, testing::ext::TestSize.Level1) { - if (avOutputTest_ == nullptr) { - return; - } + ASSERT_TRUE(avOutputTest_ != nullptr); avOutputTest_->plugin_ = PluginManager::Instance().CreateGenericPlugin("AVTransDaudioOutputPlugin"); std::shared_ptr buffer = nullptr; diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.cpp index dd79765d..3e97848c 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 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 @@ -298,7 +298,7 @@ std::shared_ptr DsoftbusInputPlugin::CreateBuffer(uint32_t metaType, return buffer; } cJSON *paramItem = cJSON_GetObjectItem(resMsg, AVT_DATA_PARAM.c_str()); - if (paramItem == NULL) { + if (paramItem == NULL || !cJSON_IsString(paramItem)) { return nullptr; } auto meta = std::make_shared(); @@ -323,11 +323,11 @@ void DsoftbusInputPlugin::DataEnqueue(std::shared_ptr &buffer) AVTRANS_LOGE("buffer is nullptr."); return; } - if (GetReDumpFlag() == true) { + if (GetReDumpFlag()) { std::remove(SCREEN_FILE_NAME_BEFOREENCODING.c_str()); SetReDumpFlagFalse(); } - if (GetDumpFlag() == true) { + if (GetDumpFlag()) { auto bufferData = buffer->GetMemory(); if (bufferData != nullptr) { DumpBufferToFile(SCREEN_FILE_NAME_BEFOREENCODING, diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.cpp index 996b1800..a7767818 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.cpp @@ -254,11 +254,11 @@ Status DsoftbusOutputPlugin::PushData(const std::string &inPort, std::shared_ptr AVTRANS_LOGE("Buffer is nullptr."); return Status::ERROR_NULL_POINTER; } - if (GetReDumpFlag() == true) { + if (GetReDumpFlag()) { std::remove(SCREEN_FILE_NAME_AFTERCODING.c_str()); SetReDumpFlagFalse(); } - if (GetDumpFlag() == true) { + if (GetDumpFlag()) { auto bufferData = buffer->GetMemory(); if (bufferData != nullptr) { DumpBufferToFile(SCREEN_FILE_NAME_AFTERCODING, diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/include/output_controller_listener.h b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/include/output_controller_listener.h index babab494..1f05f509 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/include/output_controller_listener.h +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/include/output_controller_listener.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 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 @@ -15,9 +15,11 @@ #ifndef OHOS_OUTPUT_CONTROLLER_LISTENER_H #define OHOS_OUTPUT_CONTROLLER_LISTENER_H + +#include + #include "controllable_output.h" #include "plugin_buffer.h" -#include namespace OHOS { namespace DistributedHardware { diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/include/time_statistician.h b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/include/time_statistician.h index b8715626..2b045a35 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/include/time_statistician.h +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/include/time_statistician.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 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 @@ -16,8 +16,10 @@ #ifndef OHOS_TIME_STATISTICIAN_H #define OHOS_TIME_STATISTICIAN_H -#include "plugin_buffer.h" #include + +#include "plugin_buffer.h" + namespace OHOS { namespace DistributedHardware { using namespace OHOS::Media; diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/src/output_controller.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/src/output_controller.cpp index 258c004a..d5dc265f 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/src/output_controller.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/src/output_controller.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 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 @@ -13,9 +13,11 @@ * limitations under the License. */ -#include -#include #include "output_controller.h" + +#include +#include + #include "av_trans_constants.h" #include "av_trans_errno.h" diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/src/output_controller_listener.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/src/output_controller_listener.cpp index 348b5116..962e8904 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/src/output_controller_listener.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/src/output_controller_listener.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 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 @@ -12,8 +12,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "av_trans_log.h" + #include "output_controller_listener.h" + +#include "av_trans_log.h" #include "output_controller_constants.h" namespace OHOS { 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/av_trans_input/daudio_input_test/BUILD.gn index 25253491..6775faad 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/av_trans_input/daudio_input_test/BUILD.gn @@ -45,10 +45,7 @@ ohos_unittest("DaudioInputPluginTest") { ] cflags_cc = cflags - deps = [ - "${plugin_path}/plugins/av_trans_input/daudio_input:plugin_AVTransDaudioInput", - "//third_party/googletest:gtest", - ] + deps = [ "${plugin_path}/plugins/av_trans_input/daudio_input:plugin_AVTransDaudioInput" ] if (histreamer_compile_part) { external_deps = [ @@ -63,6 +60,7 @@ ohos_unittest("DaudioInputPluginTest") { "c_utils:utils", "dsoftbus:softbus_client", "eventhandler:libeventhandler", + "googletest:gtest", "hilog:libhilog", "kv_store:distributeddata_inner", "safwk:system_ability_fwk", 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/av_trans_input/dscreen_input_test/BUILD.gn index fb11cae5..693c7864 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/av_trans_input/dscreen_input_test/BUILD.gn @@ -34,10 +34,7 @@ ohos_unittest("DscreenInputTest") { "dscreen_input_test.cpp", ] - deps = [ - "${plugin_path}/plugins/av_trans_input/dscreen_input:plugin_AVTransDscreenInput", - "//third_party/googletest:gtest", - ] + deps = [ "${plugin_path}/plugins/av_trans_input/dscreen_input:plugin_AVTransDscreenInput" ] if (histreamer_compile_part) { external_deps = [ @@ -51,6 +48,7 @@ ohos_unittest("DscreenInputTest") { "cJSON:cjson", "c_utils:utils", "eventhandler:libeventhandler", + "googletest:gtest", "hilog:libhilog", "kv_store:distributeddata_inner", "safwk:system_ability_fwk", 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/av_trans_input/dsoftbus_input_audio_test/BUILD.gn index 61185d69..41663e3e 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/av_trans_input/dsoftbus_input_audio_test/BUILD.gn @@ -33,10 +33,7 @@ ohos_unittest("DsoftbusInputAudioPluginTest") { "dsoftbus_input_audio_plugin_test.cpp", ] - deps = [ - "${plugin_path}/plugins/av_trans_input/dsoftbus_input_audio:plugin_AVTransDsoftbusInputAudio", - "//third_party/googletest:gtest", - ] + deps = [ "${plugin_path}/plugins/av_trans_input/dsoftbus_input_audio:plugin_AVTransDsoftbusInputAudio" ] if (histreamer_compile_part) { external_deps = [ @@ -51,6 +48,7 @@ ohos_unittest("DsoftbusInputAudioPluginTest") { "cJSON:cjson", "c_utils:utils", "dsoftbus:softbus_client", + "googletest:gtest", "hilog:libhilog", ] 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/av_trans_input/dsoftbus_input_test/BUILD.gn index 0f2bbd1f..82786f20 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/av_trans_input/dsoftbus_input_test/BUILD.gn @@ -33,10 +33,7 @@ ohos_unittest("DsoftbusInputPluginTest") { "dsoftbus_input_plugin_test.cpp", ] - deps = [ - "${plugin_path}/plugins/av_trans_input/dsoftbus_input:plugin_AVTransDsoftbusInput", - "//third_party/googletest:gtest", - ] + deps = [ "${plugin_path}/plugins/av_trans_input/dsoftbus_input:plugin_AVTransDsoftbusInput" ] if (histreamer_compile_part) { external_deps = [ @@ -51,6 +48,7 @@ ohos_unittest("DsoftbusInputPluginTest") { "cJSON:cjson", "c_utils:utils", "dsoftbus:softbus_client", + "googletest:gtest", "hilog:libhilog", ] 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/av_trans_output/daudio_output_test/BUILD.gn index 9393ea87..07221238 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/av_trans_output/daudio_output_test/BUILD.gn @@ -42,10 +42,7 @@ ohos_unittest("DaudioOutputPluginTest") { ] cflags_cc = cflags - deps = [ - "${plugin_path}/plugins/av_trans_output/daudio_output:plugin_AVTransDaudioOutput", - "//third_party/googletest:gtest", - ] + deps = [ "${plugin_path}/plugins/av_trans_output/daudio_output:plugin_AVTransDaudioOutput" ] if (histreamer_compile_part) { external_deps = [ @@ -61,6 +58,7 @@ ohos_unittest("DaudioOutputPluginTest") { "c_utils:utils", "eventhandler:libeventhandler", "ffmpeg:libohosffmpeg", + "googletest:gtest", "hilog:libhilog", "kv_store:distributeddata_inner", "safwk:system_ability_fwk", 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/av_trans_output/dscreen_output_test/BUILD.gn index 4f03b290..db00d463 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/av_trans_output/dscreen_output_test/BUILD.gn @@ -43,10 +43,7 @@ ohos_unittest("DscreenOutputPluginTest") { ] cflags_cc = cflags - deps = [ - "${plugin_path}/plugins/av_trans_output/dscreen_output:plugin_AVTransDscreenOutput", - "//third_party/googletest:gtest", - ] + deps = [ "${plugin_path}/plugins/av_trans_output/dscreen_output:plugin_AVTransDscreenOutput" ] if (histreamer_compile_part) { external_deps = [ @@ -61,6 +58,7 @@ ohos_unittest("DscreenOutputPluginTest") { "cJSON:cjson", "c_utils:utils", "eventhandler:libeventhandler", + "googletest:gtest", "hilog:libhilog", "kv_store:distributeddata_inner", "safwk:system_ability_fwk", 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/av_trans_output/dsoftbus_output_audio_test/BUILD.gn index 811adb76..5d32e517 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/av_trans_output/dsoftbus_output_audio_test/BUILD.gn @@ -42,10 +42,7 @@ ohos_unittest("DsoftbusOutputAudioPluginTest") { ] cflags_cc = cflags - deps = [ - "${plugin_path}/plugins/av_trans_output/dsoftbus_output_audio:plugin_AVTransDsoftbusOutputAudio", - "//third_party/googletest:gtest", - ] + deps = [ "${plugin_path}/plugins/av_trans_output/dsoftbus_output_audio:plugin_AVTransDsoftbusOutputAudio" ] if (histreamer_compile_part) { external_deps = [ @@ -60,6 +57,7 @@ ohos_unittest("DsoftbusOutputAudioPluginTest") { "cJSON:cjson", "c_utils:utils", "dsoftbus:softbus_client", + "googletest:gtest", "hilog:libhilog", ] 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/av_trans_output/dsoftbus_output_test/BUILD.gn index 273206de..713ab2e2 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/av_trans_output/dsoftbus_output_test/BUILD.gn @@ -42,10 +42,7 @@ ohos_unittest("DsoftbusOutputPluginTest") { ] cflags_cc = cflags - deps = [ - "${plugin_path}/plugins/av_trans_output/dsoftbus_output:plugin_AVTransDsoftbusOutput", - "//third_party/googletest:gtest", - ] + deps = [ "${plugin_path}/plugins/av_trans_output/dsoftbus_output:plugin_AVTransDsoftbusOutput" ] if (histreamer_compile_part) { external_deps = [ @@ -60,6 +57,7 @@ ohos_unittest("DsoftbusOutputPluginTest") { "cJSON:cjson", "c_utils:utils", "dsoftbus:softbus_client", + "googletest:gtest", "hilog:libhilog", ] diff --git a/av_transport/av_trans_engine/plugin/test/av_trans_output/output_control_test/BUILD.gn b/av_transport/av_trans_engine/plugin/test/av_trans_output/output_control_test/BUILD.gn index c65eb72e..e3d5c6a4 100644 --- a/av_transport/av_trans_engine/plugin/test/av_trans_output/output_control_test/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/test/av_trans_output/output_control_test/BUILD.gn @@ -43,10 +43,7 @@ ohos_unittest("OutputControllerTest") { ] cflags_cc = cflags - deps = [ - "${plugin_path}/plugins/av_trans_output/dscreen_output:plugin_AVTransDscreenOutput", - "//third_party/googletest:gtest", - ] + deps = [ "${plugin_path}/plugins/av_trans_output/dscreen_output:plugin_AVTransDscreenOutput" ] if (histreamer_compile_part) { external_deps = [ @@ -61,6 +58,7 @@ ohos_unittest("OutputControllerTest") { "cJSON:cjson", "c_utils:utils", "dsoftbus:softbus_client", + "googletest:gtest", "hilog:libhilog", ] diff --git a/av_transport/av_trans_engine/plugin/test/core/BUILD.gn b/av_transport/av_trans_engine/plugin/test/core/BUILD.gn index e31e02a9..2bf37670 100644 --- a/av_transport/av_trans_engine/plugin/test/core/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/test/core/BUILD.gn @@ -48,7 +48,6 @@ ohos_unittest("AvTransInputOutputTest") { deps = [ "${filters_path}:avtrans_input_filter", "${filters_path}:avtrans_output_filter", - "//third_party/googletest:gtest", ] if (histreamer_compile_part) { @@ -66,6 +65,7 @@ ohos_unittest("AvTransInputOutputTest") { "c_utils:utils", "dsoftbus:softbus_client", "eventhandler:libeventhandler", + "googletest:gtest", "hilog:libhilog", "kv_store:distributeddata_inner", "safwk:system_ability_fwk", diff --git a/av_transport/av_trans_handler/histreamer_ability_querier/src/histreamer_ability_querier.cpp b/av_transport/av_trans_handler/histreamer_ability_querier/src/histreamer_ability_querier.cpp index 2c746e14..eb560382 100644 --- a/av_transport/av_trans_handler/histreamer_ability_querier/src/histreamer_ability_querier.cpp +++ b/av_transport/av_trans_handler/histreamer_ability_querier/src/histreamer_ability_querier.cpp @@ -970,7 +970,7 @@ template void FromJson(const std::string &key, const cJSON *jsonObject, std::vector &objs) { cJSON *objJson = cJSON_GetObjectItemCaseSensitive(jsonObject, key.c_str()); - if (objJson == nullptr) { + if (objJson == nullptr || !cJSON_IsArray(objJson)) { AVTRANS_LOGE("JSONObject key invalid, key: %{public}s", key.c_str()); return; } diff --git a/av_transport/av_trans_handler/histreamer_ability_querier/test/unittest/common/BUILD.gn b/av_transport/av_trans_handler/histreamer_ability_querier/test/unittest/common/BUILD.gn index 078c0594..8edebefc 100644 --- a/av_transport/av_trans_handler/histreamer_ability_querier/test/unittest/common/BUILD.gn +++ b/av_transport/av_trans_handler/histreamer_ability_querier/test/unittest/common/BUILD.gn @@ -27,7 +27,6 @@ config("module_private_config") { "${engine_path}/av_receiver/include", "${interface_path}", "${common_path}/include", - "${media_standard_path}/interfaces/inner_api/native", ] } @@ -40,7 +39,6 @@ ohos_unittest("HistreamerAbilityQuerierTest") { deps = [ "${handler_path}/histreamer_ability_querier:histreamer_ability_querier", - "//third_party/googletest:gtest_main", ] if (histreamer_compile_part) { diff --git a/av_transport/av_trans_handler/histreamer_ability_querier/test/unittest/common/include/histreamer_ability_querier_test.h b/av_transport/av_trans_handler/histreamer_ability_querier/test/unittest/common/include/histreamer_ability_querier_test.h index f65d492b..35aa1723 100644 --- a/av_transport/av_trans_handler/histreamer_ability_querier/test/unittest/common/include/histreamer_ability_querier_test.h +++ b/av_transport/av_trans_handler/histreamer_ability_querier/test/unittest/common/include/histreamer_ability_querier_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 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 @@ -16,9 +16,10 @@ #ifndef OHOS_DISTRIBUTED_HARDWARE_HISTREAMER_ABILITY_QUERIER_TEST_H #define OHOS_DISTRIBUTED_HARDWARE_HISTREAMER_ABILITY_QUERIER_TEST_H -#include "cJSON.h" #include +#include "cJSON.h" + namespace OHOS { namespace DistributedHardware { class HistreamerAbilityQuerierTest : public testing::Test { diff --git a/av_transport/av_trans_handler/histreamer_ability_querier/test/unittest/common/src/histreamer_ability_querier_test.cpp b/av_transport/av_trans_handler/histreamer_ability_querier/test/unittest/common/src/histreamer_ability_querier_test.cpp index 60a3fc57..2c859f1e 100644 --- a/av_transport/av_trans_handler/histreamer_ability_querier/test/unittest/common/src/histreamer_ability_querier_test.cpp +++ b/av_transport/av_trans_handler/histreamer_ability_querier/test/unittest/common/src/histreamer_ability_querier_test.cpp @@ -210,17 +210,13 @@ HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_008, Test HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_009, TestSize.Level0) { cJSON *jsonObject = cJSON_CreateObject(); - if (jsonObject == nullptr) { - return; - } + ASSERT_TRUE(jsonObject != nullptr); cJSON_AddStringToObject(jsonObject, KEY.c_str(), TEST_STR.c_str()); EXPECT_TRUE(IsString(jsonObject, KEY)); cJSON_Delete(jsonObject); cJSON *jsonObject2 = cJSON_CreateObject(); - if (jsonObject2 == nullptr) { - return; - } + ASSERT_TRUE(jsonObject2 != nullptr); cJSON_AddNumberToObject(jsonObject2, KEY.c_str(), 1); EXPECT_FALSE(IsString(jsonObject2, KEY)); cJSON_Delete(jsonObject2); @@ -235,9 +231,7 @@ HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_009, Test HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_010, TestSize.Level0) { cJSON *jsonObject = cJSON_CreateObject(); - if (jsonObject == nullptr) { - return; - } + ASSERT_TRUE(jsonObject != nullptr); const uint8_t num_s = 1; cJSON_AddNumberToObject(jsonObject, KEY.c_str(), num_s); EXPECT_TRUE(IsUInt8(jsonObject, KEY)); @@ -257,9 +251,7 @@ HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_010, Test HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_011, TestSize.Level0) { cJSON *jsonObject = cJSON_CreateObject(); - if (jsonObject == nullptr) { - return; - } + ASSERT_TRUE(jsonObject != nullptr); const uint32_t num_s = 1; cJSON_AddNumberToObject(jsonObject, KEY.c_str(), num_s); EXPECT_TRUE(IsUInt32(jsonObject, KEY)); @@ -279,9 +271,7 @@ HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_011, Test HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_012, TestSize.Level0) { cJSON *jsonObject = cJSON_CreateObject(); - if (jsonObject == nullptr) { - return; - } + ASSERT_TRUE(jsonObject != nullptr); AudioEncoderIn audioEncoderIn; cJSON_AddNumberToObject(jsonObject, MIME.c_str(), UINT16_ONE); FromJson(jsonObject, audioEncoderIn); @@ -298,9 +288,7 @@ HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_012, Test HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_013, TestSize.Level0) { cJSON *jsonObject = cJSON_CreateObject(); - if (jsonObject == nullptr) { - return; - } + ASSERT_TRUE(jsonObject != nullptr); AudioEncoderOut audioEncoderOut; cJSON_AddNumberToObject(jsonObject, MIME.c_str(), UINT16_ONE); FromJson(jsonObject, audioEncoderOut); @@ -336,19 +324,14 @@ HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_014, Test AudioEncoder audioEncoder; ToJson(jsonObject, audioEncoder); jsonObject = cJSON_CreateObject(); - if (jsonObject == nullptr) { - return; - } + ASSERT_TRUE(jsonObject != nullptr); cJSON_AddNumberToObject(jsonObject, NAME.c_str(), UINT16_ONE); FromJson(jsonObject, audioEncoder); EXPECT_TRUE(audioEncoder.name.empty()); cJSON_Delete(jsonObject); cJSON *jsonObject2 = cJSON_CreateObject(); - if (jsonObject2 == nullptr) { - return; - } - + ASSERT_TRUE(jsonObject2 != nullptr); cJSON_AddStringToObject(jsonObject2, NAME.c_str(), AUDIO_ENCODER_NAME.c_str()); FromJson(jsonObject2, audioEncoder); EXPECT_EQ(AUDIO_ENCODER_NAME, audioEncoder.name); @@ -376,19 +359,14 @@ HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_015, Test AudioDecoderIn audioDecoderIn; ToJson(jsonObject, audioDecoderIn); jsonObject = cJSON_CreateObject(); - if (jsonObject == nullptr) { - return; - } + ASSERT_TRUE(jsonObject != nullptr); cJSON_AddNumberToObject(jsonObject, MIME.c_str(), UINT16_ONE); FromJson(jsonObject, audioDecoderIn); EXPECT_TRUE(audioDecoderIn.mime.empty()); cJSON_Delete(jsonObject); cJSON *jsonObject2 = cJSON_CreateObject(); - if (jsonObject2 == nullptr) { - return; - } - + ASSERT_TRUE(jsonObject2 != nullptr); cJSON_AddStringToObject(jsonObject2, MIME.c_str(), AUDIO_DECODERIN_MIME.c_str()); FromJson(jsonObject2, audioDecoderIn); EXPECT_EQ(AUDIO_DECODERIN_MIME, audioDecoderIn.mime); @@ -408,19 +386,14 @@ HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_016, Test AudioDecoderOut audioDecoderOut; ToJson(jsonObject, audioDecoderOut); jsonObject = cJSON_CreateObject(); - if (jsonObject == nullptr) { - return; - } + ASSERT_TRUE(jsonObject != nullptr); cJSON_AddNumberToObject(jsonObject, MIME.c_str(), UINT16_ONE); FromJson(jsonObject, audioDecoderOut); EXPECT_TRUE(audioDecoderOut.mime.empty()); cJSON_Delete(jsonObject); cJSON *jsonObject2 = cJSON_CreateObject(); - if (jsonObject2 == nullptr) { - return; - } - + ASSERT_TRUE(jsonObject2 != nullptr); cJSON_AddStringToObject(jsonObject2, MIME.c_str(), AUDIO_DECODEROUT_MIME.c_str()); FromJson(jsonObject2, audioDecoderOut); EXPECT_EQ(AUDIO_DECODEROUT_MIME, audioDecoderOut.mime); @@ -440,19 +413,14 @@ HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_017, Test AudioDecoder audioDecoder; ToJson(jsonObject, audioDecoder); jsonObject = cJSON_CreateObject(); - if (jsonObject == nullptr) { - return; - } + ASSERT_TRUE(jsonObject != nullptr); cJSON_AddNumberToObject(jsonObject, NAME.c_str(), UINT16_ONE); FromJson(jsonObject, audioDecoder); EXPECT_TRUE(audioDecoder.name.empty()); cJSON_Delete(jsonObject); cJSON *jsonObject2 = cJSON_CreateObject(); - if (jsonObject2 == nullptr) { - return; - } - + ASSERT_TRUE(jsonObject2 != nullptr); cJSON_AddStringToObject(jsonObject2, NAME.c_str(), AUDIO_DECODER_NAME.c_str()); FromJson(jsonObject2, audioDecoder); EXPECT_EQ(AUDIO_DECODER_NAME, audioDecoder.name); @@ -485,19 +453,14 @@ HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_018, Test ToJson(jsonObject, videoEncoderIn); FromJson(jsonObject, videoEncoderIn); jsonObject = cJSON_CreateObject(); - if (jsonObject == nullptr) { - return; - } + ASSERT_TRUE(jsonObject != nullptr); cJSON_AddNumberToObject(jsonObject, MIME.c_str(), UINT16_ONE); FromJson(jsonObject, videoEncoderIn); EXPECT_TRUE(videoEncoderIn.mime.empty()); cJSON_Delete(jsonObject); cJSON *jsonObject2 = cJSON_CreateObject(); - if (jsonObject2 == nullptr) { - return; - } - + ASSERT_TRUE(jsonObject2 != nullptr); cJSON_AddStringToObject(jsonObject2, MIME.c_str(), VIDEO_ENCODERIN_MIME.c_str()); FromJson(jsonObject2, videoEncoderIn); EXPECT_EQ(VIDEO_ENCODERIN_MIME, videoEncoderIn.mime); @@ -518,9 +481,7 @@ HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_019, Test ToJson(jsonObject, videoEncoderOut); FromJson(jsonObject, videoEncoderOut); jsonObject = cJSON_CreateObject(); - if (jsonObject == nullptr) { - return; - } + ASSERT_TRUE(jsonObject != nullptr); cJSON_AddNumberToObject(jsonObject, MIME.c_str(), UINT16_ONE); FromJson(jsonObject, videoEncoderOut); EXPECT_TRUE(videoEncoderOut.mime.empty()); @@ -540,19 +501,14 @@ HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_020, Test ToJson(jsonObject, videoEncoder); FromJson(jsonObject, videoEncoder); jsonObject = cJSON_CreateObject(); - if (jsonObject == nullptr) { - return; - } + ASSERT_TRUE(jsonObject != nullptr); cJSON_AddNumberToObject(jsonObject, NAME.c_str(), UINT16_ONE); FromJson(jsonObject, videoEncoder); EXPECT_TRUE(videoEncoder.name.empty()); cJSON_Delete(jsonObject); cJSON *jsonObject2 = cJSON_CreateObject(); - if (jsonObject2 == nullptr) { - return; - } - + ASSERT_TRUE(jsonObject2 != nullptr); cJSON_AddStringToObject(jsonObject2, NAME.c_str(), VIDEO_ENCODER_NAME.c_str()); FromJson(jsonObject2, videoEncoder); EXPECT_EQ(VIDEO_ENCODER_NAME, videoEncoder.name); @@ -580,9 +536,7 @@ HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_020, Test HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_021, TestSize.Level0) { cJSON *jsonObject = cJSON_CreateObject(); - if (jsonObject == nullptr) { - return; - } + ASSERT_TRUE(jsonObject != nullptr); VideoDecoderIn videoDecoderIn; cJSON_AddNumberToObject(jsonObject, MIME.c_str(), UINT16_ONE); FromJson(jsonObject, videoDecoderIn); @@ -590,10 +544,7 @@ HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_021, Test cJSON_Delete(jsonObject); cJSON *jsonObject2 = cJSON_CreateObject(); - if (jsonObject2 == nullptr) { - return; - } - + ASSERT_TRUE(jsonObject2 != nullptr); cJSON_AddStringToObject(jsonObject2, MIME.c_str(), VIDEO_DECODERIN_MIME.c_str()); FromJson(jsonObject2, videoDecoderIn); EXPECT_EQ(VIDEO_DECODERIN_MIME, videoDecoderIn.mime); @@ -610,9 +561,7 @@ HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_021, Test HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_022, TestSize.Level0) { cJSON *jsonObject = cJSON_CreateObject(); - if (jsonObject == nullptr) { - return; - } + ASSERT_TRUE(jsonObject != nullptr); VideoDecoderOut videoDecoderOut; cJSON_AddNumberToObject(jsonObject, MIME.c_str(), UINT16_ONE); FromJson(jsonObject, videoDecoderOut); @@ -620,10 +569,7 @@ HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_022, Test cJSON_Delete(jsonObject); cJSON *jsonObject2 = cJSON_CreateObject(); - if (jsonObject2 == nullptr) { - return; - } - + ASSERT_TRUE(jsonObject2 != nullptr); cJSON_AddStringToObject(jsonObject2, MIME.c_str(), VIDEO_DECODEROUT_MIME.c_str()); FromJson(jsonObject2, videoDecoderOut); EXPECT_EQ(VIDEO_DECODEROUT_MIME, videoDecoderOut.mime); @@ -640,9 +586,7 @@ HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_022, Test HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_023, TestSize.Level0) { cJSON *jsonObject = cJSON_CreateObject(); - if (jsonObject == nullptr) { - return; - } + ASSERT_TRUE(jsonObject != nullptr); VideoDecoder videoDecoder; cJSON_AddNumberToObject(jsonObject, NAME.c_str(), UINT16_ONE); FromJson(jsonObject, videoDecoder); @@ -650,10 +594,7 @@ HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_023, Test cJSON_Delete(jsonObject); cJSON *jsonObject2 = cJSON_CreateObject(); - if (jsonObject2 == nullptr) { - return; - } - + ASSERT_TRUE(jsonObject2 != nullptr); cJSON_AddStringToObject(jsonObject2, NAME.c_str(), VIDEO_DECODER_NAME.c_str()); FromJson(jsonObject2, videoDecoder); EXPECT_EQ(VIDEO_DECODER_NAME, videoDecoder.name); @@ -687,9 +628,7 @@ HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_024, Test ToJson(jsonObject, audioEncoderIn); jsonObject = cJSON_CreateObject(); - if (jsonObject == nullptr) { - return; - } + ASSERT_TRUE(jsonObject != nullptr); cJSON_AddStringToObject(jsonObject, MIME.c_str(), "MIME"); cJSON *sampleRateJson = cJSON_CreateArray(); if (sampleRateJson == nullptr) { @@ -702,22 +641,18 @@ HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_024, Test cJSON_Delete(jsonObject); cJSON *jsonObject2 = cJSON_CreateObject(); - if (jsonObject2 == nullptr) { - return; - } + ASSERT_TRUE(jsonObject2 != nullptr); cJSON_AddNumberToObject(jsonObject2, MIME.c_str(), 1); FromJson(jsonObject2, audioEncoderIn); cJSON_Delete(jsonObject2); cJSON *jsonObject3 = cJSON_CreateObject(); - if (jsonObject3 == nullptr) { - return; - } + ASSERT_TRUE(jsonObject3 != nullptr); cJSON_AddStringToObject(jsonObject3, MIME.c_str(), "MIME"); cJSON *sampleRateJson1 = cJSON_CreateObject(); if (sampleRateJson1 == nullptr) { cJSON_Delete(jsonObject3); - return; + ASSERT_TRUE(sampleRateJson1 != nullptr); } cJSON_AddItemToArray(sampleRateJson1, cJSON_CreateNumber(1)); cJSON_AddItemToObject(jsonObject3, SAMPLE_RATE.c_str(), sampleRateJson1); @@ -738,9 +673,7 @@ HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_025, Test ToJson(jsonObject, audioEncoderOut); jsonObject = cJSON_CreateObject(); - if (jsonObject == nullptr) { - return; - } + ASSERT_TRUE(jsonObject != nullptr); cJSON_AddStringToObject(jsonObject, MIME.c_str(), "MIME"); cJSON_AddNumberToObject(jsonObject, AD_MPEG_VER.c_str(), 1); cJSON_AddNumberToObject(jsonObject, AUDIO_AAC_PROFILE.c_str(), 2); @@ -749,18 +682,14 @@ HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_025, Test cJSON_Delete(jsonObject); cJSON *jsonObject2 = cJSON_CreateObject(); - if (jsonObject2 == nullptr) { - return; - } + ASSERT_TRUE(jsonObject2 != nullptr); cJSON_AddStringToObject(jsonObject2, MIME.c_str(), "MIME"); cJSON_AddStringToObject(jsonObject2, AD_MPEG_VER.c_str(), "VER"); FromJson(jsonObject2, audioEncoderOut); cJSON_Delete(jsonObject2); cJSON *jsonObject3 = cJSON_CreateObject(); - if (jsonObject3 == nullptr) { - return; - } + ASSERT_TRUE(jsonObject3 != nullptr); cJSON_AddStringToObject(jsonObject3, MIME.c_str(), "MIME"); cJSON_AddNumberToObject(jsonObject3, AD_MPEG_VER.c_str(), 1); cJSON_AddStringToObject(jsonObject3, AUDIO_AAC_PROFILE.c_str(), "PROFILE"); @@ -769,9 +698,7 @@ HWTEST_F(HistreamerAbilityQuerierTest, histreamer_ability_querier_test_025, Test cJSON *jsonObject4 = cJSON_CreateObject(); - if (jsonObject4 == nullptr) { - return; - } + ASSERT_TRUE(jsonObject4 != nullptr); cJSON_AddStringToObject(jsonObject4, MIME.c_str(), "MIME"); cJSON_AddNumberToObject(jsonObject4, AD_MPEG_VER.c_str(), 1); cJSON_AddNumberToObject(jsonObject4, AUDIO_AAC_PROFILE.c_str(), 2); diff --git a/av_transport/common/include/av_trans_log.h b/av_transport/common/include/av_trans_log.h index 0453a410..afb6c2c8 100644 --- a/av_transport/common/include/av_trans_log.h +++ b/av_transport/common/include/av_trans_log.h @@ -17,10 +17,11 @@ #define OHOS_AV_TRANSPORT_LOG_H #include -#include "hilog/log.h" #include #include +#include "hilog/log.h" + namespace OHOS { namespace DistributedHardware { #undef LOG_TAG -- Gitee