From 324c3d11c8aad36e9e1ad615b2825ad911d8fe49 Mon Sep 17 00:00:00 2001 From: chen0088 Date: Thu, 10 Nov 2022 09:23:02 +0800 Subject: [PATCH] fix:add unittest Signed-off-by: chen0088 --- services/data_process/test/unittest/BUILD.gn | 5 +- .../unittest/common/pipeline_node/BUILD.gn | 80 ++++++ .../color_format_process_test.cpp | 248 +++++++++++++++++ .../decode_data_process_test.cpp | 243 ++++++++++++++++ .../encode_data_process_test.cpp | 242 ++++++++++++++++ .../fps_controller_process_test.cpp | 230 +++++++++++++++ .../scale_convert_process_test.cpp | 263 ++++++++++++++++++ 7 files changed, 1310 insertions(+), 1 deletion(-) create mode 100644 services/data_process/test/unittest/common/pipeline_node/BUILD.gn create mode 100644 services/data_process/test/unittest/common/pipeline_node/color_format_process_test.cpp create mode 100644 services/data_process/test/unittest/common/pipeline_node/decode_data_process_test.cpp create mode 100644 services/data_process/test/unittest/common/pipeline_node/encode_data_process_test.cpp create mode 100644 services/data_process/test/unittest/common/pipeline_node/fps_controller_process_test.cpp create mode 100644 services/data_process/test/unittest/common/pipeline_node/scale_convert_process_test.cpp diff --git a/services/data_process/test/unittest/BUILD.gn b/services/data_process/test/unittest/BUILD.gn index 3a36afb5..06910b09 100644 --- a/services/data_process/test/unittest/BUILD.gn +++ b/services/data_process/test/unittest/BUILD.gn @@ -13,5 +13,8 @@ group("data_process_test") { testonly = true - deps = [ "common/pipeline:dcamera_pipeline_test" ] + deps = [ + "common/pipeline:dcamera_pipeline_test", + "common/pipeline_node:dcamera_pipeline_node_test", + ] } diff --git a/services/data_process/test/unittest/common/pipeline_node/BUILD.gn b/services/data_process/test/unittest/common/pipeline_node/BUILD.gn new file mode 100644 index 00000000..f0b90959 --- /dev/null +++ b/services/data_process/test/unittest/common/pipeline_node/BUILD.gn @@ -0,0 +1,80 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributed_camera/distributedcamera.gni") + +module_out_path = "distributed_camera/dcamera_data_process_test" + +config("module_private_config") { + visibility = [ ":*" ] + include_dirs = [ + "${services_path}/data_process/include/interfaces", + "${services_path}/data_process/include/eventbus", + "${services_path}/data_process/include/pipeline", + "${services_path}/data_process/include/utils", + "${services_path}/data_process/include/pipeline_node/multimedia_codec/decoder", + "${services_path}/data_process/include/pipeline_node/multimedia_codec/encoder", + "${services_path}/data_process/include/pipeline_node/colorspace_conversion", + "${services_path}/data_process/include/pipeline_node/fpscontroller", + "${services_path}/data_process/include/pipeline_node/scale_conversion", + "${services_path}/cameraservice/sinkservice/include/distributedcameramgr", + "${common_path}/include/constants", + "${common_path}/include/utils", + "${innerkits_path}/native_cpp/camera_source/include", + "//commonlibrary/c_utils/base/include", + "${fwk_common_path}/utils/include", + "${fwk_utils_path}/include/eventbus", + "//third_party/ffmpeg/", + ] +} + +ohos_unittest("DCameraDataProcessPipelineNodeTest") { + module_out_path = module_out_path + + sources = [ + "color_format_process_test.cpp", + "decode_data_process_test.cpp", + "encode_data_process_test.cpp", + "fps_controller_process_test.cpp", + "scale_convert_process_test.cpp", + ] + + configs = [ ":module_private_config" ] + + deps = [ + "${common_path}:distributed_camera_utils", + "${services_path}/data_process:distributed_camera_data_process", + "//foundation/graphic/graphic_2d/frameworks/surface:surface", + "//third_party/ffmpeg:libohosffmpeg", + ] + + external_deps = [ + "c_utils:utils", + "eventhandler:libeventhandler", + "hitrace_native:hitrace_meter", + "multimedia_player_framework:media_client", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"DCameraDataProcessPipelineNodeTest\"", + "LOG_DOMAIN=0xD004100", + ] +} + +group("dcamera_pipeline_node_test") { + testonly = true + deps = [ ":DCameraDataProcessPipelineNodeTest" ] +} diff --git a/services/data_process/test/unittest/common/pipeline_node/color_format_process_test.cpp b/services/data_process/test/unittest/common/pipeline_node/color_format_process_test.cpp new file mode 100644 index 00000000..d7cb2383 --- /dev/null +++ b/services/data_process/test/unittest/common/pipeline_node/color_format_process_test.cpp @@ -0,0 +1,248 @@ +/* + * Copyright (c) 2022 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 + +#define private public +#include "color_format_process.h" +#undef private +#include "distributed_camera_constants.h" +#include "distributed_camera_errno.h" + +using namespace testing::ext; + +namespace OHOS { +namespace DistributedHardware { +class ColorFormatProcessTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + + std::shared_ptr testColorFmtProcess_; +}; + +namespace { +const int32_t TEST_WIDTH = 1920; +const int32_t TEST_HEIGTH = 1080; +const int32_t TEST_WIDTH2 = 640; +const int32_t TEST_HEIGTH2 = 480; +} + +void ColorFormatProcessTest::SetUpTestCase(void) +{ +} + +void ColorFormatProcessTest::TearDownTestCase(void) +{ +} + +void ColorFormatProcessTest::SetUp(void) +{ + std::shared_ptr sourcePipeline = std::make_shared(); + std::weak_ptr callbackPipelineSource(sourcePipeline); + testColorFmtProcess_ = std::make_shared(callbackPipelineSource); +} + +void ColorFormatProcessTest::TearDown(void) +{ + testColorFmtProcess_ = nullptr; +} + +/** + * @tc.name: color_format_process_test_001 + * @tc.desc: Verify color format process InitNode normal. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ColorFormatProcessTest, color_format_process_test_001, TestSize.Level1) +{ + EXPECT_EQ(false, testColorFmtProcess_ == nullptr); + + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H264, + Videoformat::NV21, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams procConfig; + int32_t rc = testColorFmtProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_OK); +} + +/** + * @tc.name: color_format_process_test_002 + * @tc.desc: Verify color format process InitNode abnormal. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ColorFormatProcessTest, color_format_process_test_002, TestSize.Level1) +{ + EXPECT_EQ(false, testColorFmtProcess_ == nullptr); + + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H264, + Videoformat::NV21, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH2, + TEST_HEIGTH2); + VideoConfigParams procConfig; + int32_t rc = testColorFmtProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_BAD_TYPE); +} + +/** + * @tc.name: color_format_process_test_003 + * @tc.desc: Verify color format process ProcessData inputBuffers is empty. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ColorFormatProcessTest, color_format_process_test_003, TestSize.Level1) +{ + EXPECT_EQ(false, testColorFmtProcess_ == nullptr); + + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H264, + Videoformat::NV21, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams procConfig; + int32_t rc = testColorFmtProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_OK); + + std::vector> inputBuffers; + rc = testColorFmtProcess_->ProcessData(inputBuffers); + EXPECT_EQ(rc, DCAMERA_BAD_VALUE); +} + +/** + * @tc.name: color_format_process_test_004 + * @tc.desc: Verify color format process ProcessData inputBuffers[0] is nullptr. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ColorFormatProcessTest, color_format_process_test_004, TestSize.Level1) +{ + EXPECT_EQ(false, testColorFmtProcess_ == nullptr); + + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H264, + Videoformat::NV21, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams procConfig; + int32_t rc = testColorFmtProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_OK); + + std::vector> inputBuffers; + std::shared_ptr db; + inputBuffers.push_back(db); + rc = testColorFmtProcess_->ProcessData(inputBuffers); + EXPECT_EQ(rc, DCAMERA_BAD_VALUE); +} + +/** + * @tc.name: color_format_process_test_005 + * @tc.desc: Verify color format process ProcessData find timeStamp failed. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ColorFormatProcessTest, color_format_process_test_005, TestSize.Level1) +{ + EXPECT_EQ(false, testColorFmtProcess_ == nullptr); + + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H264, + Videoformat::NV21, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams procConfig; + int32_t rc = testColorFmtProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_OK); + + size_t capacity = 100; + std::vector> inputBuffers; + std::shared_ptr db = std::make_shared(capacity); + inputBuffers.push_back(db); + rc = testColorFmtProcess_->ProcessData(inputBuffers); + EXPECT_EQ(rc, DCAMERA_BAD_VALUE); +} + +/** + * @tc.name: color_format_process_test_006 + * @tc.desc: Verify color format process ProcessData normal. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ColorFormatProcessTest, color_format_process_test_006, TestSize.Level1) +{ + EXPECT_EQ(false, testColorFmtProcess_ == nullptr); + + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H264, + Videoformat::NV21, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams procConfig; + int32_t rc = testColorFmtProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_OK); + + size_t capacity = 3200000; + int64_t timeStamp = 10; + std::vector> inputBuffers; + std::shared_ptr db = std::make_shared(capacity); + db->SetInt64("timeUs", timeStamp); + db->SetInt32("Videoformat", static_cast(Videoformat::NV12)); + db->SetInt32("alignedWidth", TEST_WIDTH); + db->SetInt32("alignedHeight", TEST_HEIGTH); + db->SetInt32("width", TEST_WIDTH); + db->SetInt32("height", TEST_HEIGTH); + inputBuffers.push_back(db); + std::shared_ptr sourcePipeline = std::make_shared(); + testColorFmtProcess_->callbackPipelineSource_ = sourcePipeline; + rc = testColorFmtProcess_->ProcessData(inputBuffers); + EXPECT_EQ(rc, DCAMERA_OK); +} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/data_process/test/unittest/common/pipeline_node/decode_data_process_test.cpp b/services/data_process/test/unittest/common/pipeline_node/decode_data_process_test.cpp new file mode 100644 index 00000000..5abbcae8 --- /dev/null +++ b/services/data_process/test/unittest/common/pipeline_node/decode_data_process_test.cpp @@ -0,0 +1,243 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "decode_data_process.h" +#include "distributed_camera_constants.h" +#include "distributed_camera_errno.h" + +using namespace testing::ext; + +namespace OHOS { +namespace DistributedHardware { +class DecodeDataProcessTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + + std::shared_ptr testDecodeDataProcess_; +}; + +namespace { +const int32_t TEST_WIDTH = 1920; +const int32_t TEST_HEIGTH = 1080; +const int32_t TEST_WIDTH2 = 640; +const int32_t TEST_HEIGTH2 = 480; +} + +void DecodeDataProcessTest::SetUpTestCase(void) +{ +} + +void DecodeDataProcessTest::TearDownTestCase(void) +{ +} + +void DecodeDataProcessTest::SetUp(void) +{ + std::shared_ptr sourcePipeline = std::make_shared(); + std::shared_ptr eventBusPipeline = std::make_shared("TestDecodeHandler"); + testDecodeDataProcess_ = std::make_shared(eventBusPipeline, sourcePipeline); +} + +void DecodeDataProcessTest::TearDown(void) +{ + testDecodeDataProcess_ = nullptr; +} + +/** + * @tc.name: decode_data_process_test_001 + * @tc.desc: Verify decode data process InitNode IsInDecoderRange false. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DecodeDataProcessTest, decode_data_process_test_001, TestSize.Level1) +{ + EXPECT_EQ(false, testDecodeDataProcess_ == nullptr); + + int32_t frameRate = 50; + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + frameRate, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H264, + Videoformat::NV21, + frameRate, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams procConfig; + int32_t rc = testDecodeDataProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_OK); +} + +/** + * @tc.name: decode_data_process_test_002 + * @tc.desc: Verify decode data process InitNode IsConvertible false. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DecodeDataProcessTest, decode_data_process_test_002, TestSize.Level1) +{ + EXPECT_EQ(false, testDecodeDataProcess_ == nullptr); + + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H265, + Videoformat::NV21, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH2, + TEST_HEIGTH2); + VideoConfigParams procConfig; + int32_t rc = testDecodeDataProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_BAD_TYPE); +} + +/** + * @tc.name: decode_data_process_test_003 + * @tc.desc: Verify decode data process InitNode normal. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DecodeDataProcessTest, decode_data_process_test_003, TestSize.Level1) +{ + EXPECT_EQ(false, testDecodeDataProcess_ == nullptr); + + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H264, + Videoformat::NV21, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH2, + TEST_HEIGTH2); + VideoConfigParams procConfig; + int32_t rc = testDecodeDataProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_OK); +} + +/** + * @tc.name: decode_data_process_test_004 + * @tc.desc: Verify decode data process InitNode normal. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DecodeDataProcessTest, decode_data_process_test_004, TestSize.Level1) +{ + EXPECT_EQ(false, testDecodeDataProcess_ == nullptr); + + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::NO_CODEC, + Videoformat::NV21, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH2, + TEST_HEIGTH2); + VideoConfigParams procConfig; + int32_t rc = testDecodeDataProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_OK); +} + +/** + * @tc.name: decode_data_process_test_005 + * @tc.desc: Verify decode data process ProcessData inputBuffers is nullptr. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DecodeDataProcessTest, decode_data_process_test_005, TestSize.Level1) +{ + EXPECT_EQ(false, testDecodeDataProcess_ == nullptr); + + std::vector> inputBuffers; + int32_t rc = testDecodeDataProcess_->ProcessData(inputBuffers); + EXPECT_EQ(rc, DCAMERA_BAD_VALUE); +} + +/** + * @tc.name: decode_data_process_test_006 + * @tc.desc: Verify decode data process ProcessData codetype equality. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DecodeDataProcessTest, decode_data_process_test_006, TestSize.Level1) +{ + EXPECT_EQ(false, testDecodeDataProcess_ == nullptr); + + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H264, + Videoformat::NV21, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams procConfig; + int32_t rc = testDecodeDataProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_OK); + + size_t capacity = 100; + std::vector> inputBuffers; + std::shared_ptr db = std::make_shared(capacity); + inputBuffers.push_back(db); + rc = testDecodeDataProcess_->ProcessData(inputBuffers); + EXPECT_EQ(rc, DCAMERA_BAD_VALUE); +} + +/** + * @tc.name: decode_data_process_test_007 + * @tc.desc: Verify decode data process ProcessData normal. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DecodeDataProcessTest, decode_data_process_test_007, TestSize.Level1) +{ + EXPECT_EQ(false, testDecodeDataProcess_ == nullptr); + + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::NO_CODEC, + Videoformat::NV21, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams procConfig; + int32_t rc = testDecodeDataProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_OK); + + size_t capacity = 100; + std::vector> inputBuffers; + std::shared_ptr db = std::make_shared(capacity); + inputBuffers.push_back(db); + rc = testDecodeDataProcess_->ProcessData(inputBuffers); + EXPECT_EQ(rc, DCAMERA_OK); +} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/data_process/test/unittest/common/pipeline_node/encode_data_process_test.cpp b/services/data_process/test/unittest/common/pipeline_node/encode_data_process_test.cpp new file mode 100644 index 00000000..d54332da --- /dev/null +++ b/services/data_process/test/unittest/common/pipeline_node/encode_data_process_test.cpp @@ -0,0 +1,242 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "encode_data_process.h" +#include "distributed_camera_constants.h" +#include "distributed_camera_errno.h" + +using namespace testing::ext; + +namespace OHOS { +namespace DistributedHardware { +class EncodeDataProcessTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + + std::shared_ptr testEncodeDataProcess_; +}; + +namespace { +const int32_t TEST_WIDTH = 1920; +const int32_t TEST_HEIGTH = 1080; +const int32_t TEST_WIDTH2 = 640; +const int32_t TEST_HEIGTH2 = 480; +} + +void EncodeDataProcessTest::SetUpTestCase(void) +{ +} + +void EncodeDataProcessTest::TearDownTestCase(void) +{ +} + +void EncodeDataProcessTest::SetUp(void) +{ + std::shared_ptr sinkPipeline = std::make_shared(); + testEncodeDataProcess_ = std::make_shared(sinkPipeline); +} + +void EncodeDataProcessTest::TearDown(void) +{ + testEncodeDataProcess_ = nullptr; +} + +/** + * @tc.name: encode_data_process_test_001 + * @tc.desc: Verify encode data process InitNode IsInEncoderRange false. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(EncodeDataProcessTest, encode_data_process_test_001, TestSize.Level1) +{ + EXPECT_EQ(false, testEncodeDataProcess_ == nullptr); + + int32_t frameRate = 50; + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + frameRate, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H264, + Videoformat::NV21, + frameRate, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams procConfig; + int32_t rc = testEncodeDataProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_OK); +} + +/** + * @tc.name: encode_data_process_test_002 + * @tc.desc: Verify encode data process InitNode IsConvertible false. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(EncodeDataProcessTest, encode_data_process_test_002, TestSize.Level1) +{ + EXPECT_EQ(false, testEncodeDataProcess_ == nullptr); + + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H265, + Videoformat::NV21, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH2, + TEST_HEIGTH2); + VideoConfigParams procConfig; + int32_t rc = testEncodeDataProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_BAD_TYPE); +} + +/** + * @tc.name: encode_data_process_test_003 + * @tc.desc: Verify encode data process InitNode normal. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(EncodeDataProcessTest, encode_data_process_test_003, TestSize.Level1) +{ + EXPECT_EQ(false, testEncodeDataProcess_ == nullptr); + + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H264, + Videoformat::NV21, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH2, + TEST_HEIGTH2); + VideoConfigParams procConfig; + int32_t rc = testEncodeDataProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_OK); +} + +/** + * @tc.name: encode_data_process_test_004 + * @tc.desc: Verify encode data process InitNode normal. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(EncodeDataProcessTest, encode_data_process_test_004, TestSize.Level1) +{ + EXPECT_EQ(false, testEncodeDataProcess_ == nullptr); + + VideoConfigParams srcParams(VideoCodecType::NO_CODEC, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H264, + Videoformat::NV21, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH2, + TEST_HEIGTH2); + VideoConfigParams procConfig; + int32_t rc = testEncodeDataProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_OK); +} + +/** + * @tc.name: encode_data_process_test_005 + * @tc.desc: Verify encode data process ProcessData inputBuffers is nullptr. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(EncodeDataProcessTest, encode_data_process_test_005, TestSize.Level1) +{ + EXPECT_EQ(false, testEncodeDataProcess_ == nullptr); + + std::vector> inputBuffers; + int32_t rc = testEncodeDataProcess_->ProcessData(inputBuffers); + EXPECT_EQ(rc, DCAMERA_BAD_VALUE); +} + +/** + * @tc.name: encode_data_process_test_006 + * @tc.desc: Verify encode data process ProcessData codetype equality. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(EncodeDataProcessTest, encode_data_process_test_006, TestSize.Level1) +{ + EXPECT_EQ(false, testEncodeDataProcess_ == nullptr); + + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H264, + Videoformat::NV21, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams procConfig; + int32_t rc = testEncodeDataProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_OK); + + size_t capacity = 100; + std::vector> inputBuffers; + std::shared_ptr db = std::make_shared(capacity); + inputBuffers.push_back(db); + rc = testEncodeDataProcess_->ProcessData(inputBuffers); + EXPECT_EQ(rc, DCAMERA_BAD_VALUE); +} + +/** + * @tc.name: encode_data_process_test_007 + * @tc.desc: Verify encode data process ProcessData normal. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(EncodeDataProcessTest, encode_data_process_test_007, TestSize.Level1) +{ + EXPECT_EQ(false, testEncodeDataProcess_ == nullptr); + + VideoConfigParams srcParams(VideoCodecType::NO_CODEC, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H264, + Videoformat::NV21, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams procConfig; + int32_t rc = testEncodeDataProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_OK); + + size_t capacity = 100; + std::vector> inputBuffers; + std::shared_ptr db = std::make_shared(capacity); + inputBuffers.push_back(db); + rc = testEncodeDataProcess_->ProcessData(inputBuffers); + EXPECT_EQ(rc, DCAMERA_OK); +} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/data_process/test/unittest/common/pipeline_node/fps_controller_process_test.cpp b/services/data_process/test/unittest/common/pipeline_node/fps_controller_process_test.cpp new file mode 100644 index 00000000..0cf28a9b --- /dev/null +++ b/services/data_process/test/unittest/common/pipeline_node/fps_controller_process_test.cpp @@ -0,0 +1,230 @@ +/* + * Copyright (c) 2022 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 + +#define private public +#include "fps_controller_process.h" +#undef private +#include "distributed_camera_constants.h" +#include "distributed_camera_errno.h" + +using namespace testing::ext; + +namespace OHOS { +namespace DistributedHardware { +class FpsControllerProcessTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + + std::shared_ptr testFpsControllerProcess_; +}; + +namespace { +const int32_t TEST_WIDTH = 1920; +const int32_t TEST_HEIGTH = 1080; +const int32_t TEST_WIDTH2 = 640; +const int32_t TEST_HEIGTH2 = 480; +} + +void FpsControllerProcessTest::SetUpTestCase(void) +{ +} + +void FpsControllerProcessTest::TearDownTestCase(void) +{ +} + +void FpsControllerProcessTest::SetUp(void) +{ + std::shared_ptr sourcePipeline = std::make_shared(); + std::weak_ptr callbackPipelineSource(sourcePipeline); + testFpsControllerProcess_ = std::make_shared(callbackPipelineSource); +} + +void FpsControllerProcessTest::TearDown(void) +{ + testFpsControllerProcess_ = nullptr; +} + +/** + * @tc.name: fps_controller_process_test_001 + * @tc.desc: Verify fps controller process InitNode normal. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(FpsControllerProcessTest, fps_controller_process_test_001, TestSize.Level1) +{ + EXPECT_EQ(false, testFpsControllerProcess_ == nullptr); + + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H264, + Videoformat::NV21, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams procConfig; + int32_t rc = testFpsControllerProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_OK); +} + +/** + * @tc.name: fps_controller_process_test_002 + * @tc.desc: Verify fps controller process InitNode abnormal. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(FpsControllerProcessTest, fps_controller_process_test_002, TestSize.Level1) +{ + EXPECT_EQ(false, testFpsControllerProcess_ == nullptr); + + int32_t frameRate = 50; + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H264, + Videoformat::NV21, + frameRate, + TEST_WIDTH2, + TEST_HEIGTH2); + VideoConfigParams procConfig; + int32_t rc = testFpsControllerProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_BAD_TYPE); +} + +/** + * @tc.name: fps_controller_process_test_003 + * @tc.desc: Verify fps controller process ProcessData inputBuffers is empty. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(FpsControllerProcessTest, fps_controller_process_test_003, TestSize.Level1) +{ + EXPECT_EQ(false, testFpsControllerProcess_ == nullptr); + + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H264, + Videoformat::NV21, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams procConfig; + int32_t rc = testFpsControllerProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_OK); + + std::vector> inputBuffers; + rc = testFpsControllerProcess_->ProcessData(inputBuffers); + EXPECT_EQ(rc, DCAMERA_BAD_TYPE); +} + +/** + * @tc.name: fps_controller_process_test_004 + * @tc.desc: Verify fps controller process ProcessData isFpsControllerProcess_ false. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(FpsControllerProcessTest, fps_controller_process_test_004, TestSize.Level1) +{ + EXPECT_EQ(false, testFpsControllerProcess_ == nullptr); + + std::vector> inputBuffers; + std::shared_ptr db; + inputBuffers.push_back(db); + int32_t rc = testFpsControllerProcess_->ProcessData(inputBuffers); + EXPECT_EQ(rc, DCAMERA_DISABLE_PROCESS); +} + +/** + * @tc.name: fps_controller_process_test_005 + * @tc.desc: Verify fps controller process ProcessData find timeStamp failed. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(FpsControllerProcessTest, fps_controller_process_test_005, TestSize.Level1) +{ + EXPECT_EQ(false, testFpsControllerProcess_ == nullptr); + + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H264, + Videoformat::NV21, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams procConfig; + int32_t rc = testFpsControllerProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_OK); + + size_t capacity = 100; + std::vector> inputBuffers; + std::shared_ptr db = std::make_shared(capacity); + inputBuffers.push_back(db); + rc = testFpsControllerProcess_->ProcessData(inputBuffers); + EXPECT_EQ(rc, DCAMERA_BAD_TYPE); +} + +/** + * @tc.name: fps_controller_process_test_006 + * @tc.desc: Verify fps controller process ProcessData normal. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(FpsControllerProcessTest, fps_controller_process_test_006, TestSize.Level1) +{ + EXPECT_EQ(false, testFpsControllerProcess_ == nullptr); + + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H264, + Videoformat::NV21, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams procConfig; + int32_t rc = testFpsControllerProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_OK); + + size_t capacity = 100; + int64_t timeStamp = 10; + std::vector> inputBuffers; + std::shared_ptr db = std::make_shared(capacity); + db->SetInt64("timeUs", timeStamp); + inputBuffers.push_back(db); + std::shared_ptr sourcePipeline = std::make_shared(); + testFpsControllerProcess_->callbackPipelineSource_ = sourcePipeline; + rc = testFpsControllerProcess_->ProcessData(inputBuffers); + EXPECT_EQ(rc, DCAMERA_OK); +} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/data_process/test/unittest/common/pipeline_node/scale_convert_process_test.cpp b/services/data_process/test/unittest/common/pipeline_node/scale_convert_process_test.cpp new file mode 100644 index 00000000..bbbe1aec --- /dev/null +++ b/services/data_process/test/unittest/common/pipeline_node/scale_convert_process_test.cpp @@ -0,0 +1,263 @@ +/* + * Copyright (c) 2022 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 + +#define private public +#include "scale_convert_process.h" +#undef private +#include "distributed_camera_constants.h" +#include "distributed_camera_errno.h" + +using namespace testing::ext; + +namespace OHOS { +namespace DistributedHardware { +class ScaleConvertProcessTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + + std::shared_ptr testScaleConvertProcess_; +}; + +namespace { +const int32_t TEST_WIDTH = 1920; +const int32_t TEST_HEIGTH = 1080; +const int32_t TEST_WIDTH2 = 640; +const int32_t TEST_HEIGTH2 = 480; +} + +void ScaleConvertProcessTest::SetUpTestCase(void) +{ +} + +void ScaleConvertProcessTest::TearDownTestCase(void) +{ +} + +void ScaleConvertProcessTest::SetUp(void) +{ + std::shared_ptr sourcePipeline = std::make_shared(); + testScaleConvertProcess_ = std::make_shared(sourcePipeline); +} + +void ScaleConvertProcessTest::TearDown(void) +{ + testScaleConvertProcess_ = nullptr; +} + +/** + * @tc.name: scale_convert_process_test_001 + * @tc.desc: Verify scale convert process InitNode IsConvertible true. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScaleConvertProcessTest, scale_convert_process_test_001, TestSize.Level1) +{ + EXPECT_EQ(false, testScaleConvertProcess_ == nullptr); + + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H264, + Videoformat::NV21, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams procConfig; + int32_t rc = testScaleConvertProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_OK); +} + +/** + * @tc.name: scale_convert_process_test_002 + * @tc.desc: Verify scale convert process InitNode IsConvertible false. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScaleConvertProcessTest, scale_convert_process_test_002, TestSize.Level1) +{ + EXPECT_EQ(false, testScaleConvertProcess_ == nullptr); + + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H264, + Videoformat::NV21, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH2, + TEST_HEIGTH2); + VideoConfigParams procConfig; + int32_t rc = testScaleConvertProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_OK); +} + +/** + * @tc.name: scale_convert_process_test_003 + * @tc.desc: Verify scale convert process ProcessData isScaleConvert_ false. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScaleConvertProcessTest, scale_convert_process_test_003, TestSize.Level1) +{ + EXPECT_EQ(false, testScaleConvertProcess_ == nullptr); + + std::vector> inputBuffers; + int32_t rc = testScaleConvertProcess_->ProcessData(inputBuffers); + EXPECT_EQ(rc, DCAMERA_DISABLE_PROCESS); +} + +/** + * @tc.name: scale_convert_process_test_004 + * @tc.desc: Verify scale convert process ProcessData inputBuffers is empty. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScaleConvertProcessTest, scale_convert_process_test_004, TestSize.Level1) +{ + EXPECT_EQ(false, testScaleConvertProcess_ == nullptr); + + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H264, + Videoformat::NV21, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams procConfig; + int32_t rc = testScaleConvertProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_OK); + + std::vector> inputBuffers; + rc = testScaleConvertProcess_->ProcessData(inputBuffers); + EXPECT_EQ(rc, DCAMERA_BAD_VALUE); +} + +/** + * @tc.name: scale_convert_process_test_005 + * @tc.desc: Verify scale convert process ProcessData IsConvertible false. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScaleConvertProcessTest, scale_convert_process_test_005, TestSize.Level1) +{ + EXPECT_EQ(false, testScaleConvertProcess_ == nullptr); + + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H264, + Videoformat::NV21, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams procConfig; + int32_t rc = testScaleConvertProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_OK); + + size_t capacity = 100; + std::vector> inputBuffers; + std::shared_ptr db = std::make_shared(capacity); + inputBuffers.push_back(db); + rc = testScaleConvertProcess_->ProcessData(inputBuffers); + EXPECT_EQ(rc, DCAMERA_BAD_VALUE); +} + +/** + * @tc.name: scale_convert_process_test_006 + * @tc.desc: Verify scale convert process ProcessData IsConvertible true find timeStamp fail. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScaleConvertProcessTest, scale_convert_process_test_006, TestSize.Level1) +{ + EXPECT_EQ(false, testScaleConvertProcess_ == nullptr); + + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H264, + Videoformat::NV21, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH2, + TEST_HEIGTH2); + VideoConfigParams procConfig; + int32_t rc = testScaleConvertProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_OK); + + size_t capacity = 100; + std::vector> inputBuffers; + std::shared_ptr db = std::make_shared(capacity); + inputBuffers.push_back(db); + rc = testScaleConvertProcess_->ProcessData(inputBuffers); + EXPECT_EQ(rc, DCAMERA_BAD_VALUE); +} + +/** + * @tc.name: scale_convert_process_test_007 + * @tc.desc: Verify scale convert process ProcessData normal. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScaleConvertProcessTest, scale_convert_process_test_007, TestSize.Level1) +{ + EXPECT_EQ(false, testScaleConvertProcess_ == nullptr); + + VideoConfigParams srcParams(VideoCodecType::CODEC_H264, + Videoformat::NV12, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH, + TEST_HEIGTH); + VideoConfigParams destParams(VideoCodecType::CODEC_H264, + Videoformat::NV21, + DCAMERA_PRODUCER_FPS_DEFAULT, + TEST_WIDTH2, + TEST_HEIGTH2); + VideoConfigParams procConfig; + int32_t rc = testScaleConvertProcess_->InitNode(srcParams, destParams, procConfig); + EXPECT_EQ(rc, DCAMERA_OK); + + size_t capacity = 3200000; + int64_t timeStamp = 10; + std::vector> inputBuffers; + std::shared_ptr db = std::make_shared(capacity); + db->SetInt64("timeUs", timeStamp); + db->SetInt32("Videoformat", static_cast(Videoformat::NV12)); + db->SetInt32("alignedWidth", TEST_WIDTH); + db->SetInt32("alignedHeight", TEST_HEIGTH); + db->SetInt32("width", TEST_WIDTH); + db->SetInt32("height", TEST_HEIGTH); + inputBuffers.push_back(db); + std::shared_ptr sourcePipeline = std::make_shared(); + testScaleConvertProcess_->callbackPipelineSource_ = sourcePipeline; + rc = testScaleConvertProcess_->ProcessData(inputBuffers); + EXPECT_EQ(rc, DCAMERA_OK); +} +} // namespace DistributedHardware +} // namespace OHOS -- Gitee