diff --git a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/BUILD.gn b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/BUILD.gn index 9e5e51abdf0a045698ab73effcacddb6f1c72995..58183597269d6d980272dc969a68c722eec94ba8 100644 --- a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/BUILD.gn @@ -34,6 +34,7 @@ ohos_unittest("DCameraSinkHandlerTest") { module_out_path = module_out_path sources = [ + "callback/dcamera_sink_callback_test.cpp", "dcamera_sink_handler_ipc_test.cpp", "dcamera_sink_handler_test.cpp", ] diff --git a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/callback/dcamera_sink_callback_test.cpp b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/callback/dcamera_sink_callback_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..33cb3bf4e2ea82b365aeeb79b88bd0389e22e276 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/callback/dcamera_sink_callback_test.cpp @@ -0,0 +1,109 @@ +/* + * Copyright (c) 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 + * + * 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 "dcamera_sink_callback.h" + +#include "anonymous_string.h" +#include "distributed_camera_errno.h" +#include "distributed_hardware_log.h" + +using namespace testing::ext; + +namespace OHOS { +namespace DistributedHardware { +class DCameraSinkCallbackTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + + std::shared_ptr sinkCallback_; +}; + +class PrivacyResourcesListenerTest : public PrivacyResourcesListener { +public: + PrivacyResourcesListenerTest() = default; + virtual ~PrivacyResourcesListenerTest() = default; + + int32_t OnPrivaceResourceMessage(const ResourceEventType &type, const std::string &subType, + const std::string &networkId, bool &isSensitive, bool &isSameAccout) + { + return 0; + } +}; + +void DCameraSinkCallbackTest::SetUpTestCase(void) +{ + DHLOGI("enter"); +} + +void DCameraSinkCallbackTest::TearDownTestCase(void) +{ + DHLOGI("enter"); +} + +void DCameraSinkCallbackTest::SetUp(void) +{ + DHLOGI("enter"); + sinkCallback_ = std::make_shared(); +} + +void DCameraSinkCallbackTest::TearDown(void) +{ + DHLOGI("enter"); + sinkCallback_ = nullptr; +} + +/** + * @tc.name: dcamera_sink_callback_test_001 + * @tc.desc: Verify the OnNotifyRegResult function. + * @tc.type: FUNC + * @tc.require: issue + */ +HWTEST_F(DCameraSinkCallbackTest, dcamera_sink_callback_test_001, TestSize.Level1) +{ + DHLOGI("DCameraSinkCallbackTest dcamera_sink_callback_test_001."); + EXPECT_EQ(false, sinkCallback_ == nullptr); + + int32_t ret = DCAMERA_OK; + std::shared_ptr callback = std::make_shared(); + sinkCallback_->PushPrivacyResCallback(callback); + EXPECT_EQ(DCAMERA_OK, ret); +} + +/** + * @tc.name: dcamera_sink_callback_test_002 + * @tc.desc: Verify the OnNotifyRegResult function. + * @tc.type: FUNC + * @tc.require: issue + */ +HWTEST_F(DCameraSinkCallbackTest, dcamera_sink_callback_test_002, TestSize.Level1) +{ + DHLOGI("DCameraSinkCallbackTest dcamera_sink_callback_test_002."); + EXPECT_EQ(false, sinkCallback_ == nullptr); + + ResourceEventType type = ResourceEventType::EVENT_TYPE_QUERY_RESOURCE; + const std::string subType = "camera"; + const std::string networkId = "networkId"; + bool isSensitive = false; + bool isSameAccout = false; + int32_t ret = sinkCallback_->OnNotifyResourceInfo(type, subType, networkId, isSensitive, isSameAccout); + EXPECT_EQ(DCAMERA_OK, ret); +} +} +} \ No newline at end of file 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 index 6742e64c2a86bea0e35ad8fedcfea9f9c8426b87..f594e3a234984dfbeb5a17ba0a84ffbb076a4c71 100644 --- 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2022-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 @@ -241,7 +241,7 @@ HWTEST_F(EncodeDataProcessTest, encode_data_process_test_007, TestSize.Level1) DCAMERA_PRODUCER_FPS_DEFAULT, TEST_WIDTH, TEST_HEIGTH); - VideoConfigParams destParams(VideoCodecType::CODEC_H264, + VideoConfigParams destParams(VideoCodecType::CODEC_H265, Videoformat::NV21, DCAMERA_PRODUCER_FPS_DEFAULT, TEST_WIDTH, @@ -250,11 +250,7 @@ HWTEST_F(EncodeDataProcessTest, encode_data_process_test_007, TestSize.Level1) 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); + rc = testEncodeDataProcess_->InitEncoderMetadataFormat(); EXPECT_EQ(rc, DCAMERA_OK); } @@ -333,7 +329,7 @@ HWTEST_F(EncodeDataProcessTest, encode_data_process_test_010, TestSize.Level1) EXPECT_EQ(false, testEncodeDataProcess_ == nullptr); VideoConfigParams srcParams(VideoCodecType::NO_CODEC, - Videoformat::RGBA_8888, + Videoformat::YUVI420, DCAMERA_PRODUCER_FPS_DEFAULT, TEST_WIDTH, TEST_HEIGTH); @@ -346,14 +342,7 @@ HWTEST_F(EncodeDataProcessTest, encode_data_process_test_010, TestSize.Level1) 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); - - rc = testEncodeDataProcess_->FeedEncoderInputBuffer(db); + rc = testEncodeDataProcess_->InitEncoderMetadataFormat(); EXPECT_EQ(rc, DCAMERA_OK); } @@ -367,38 +356,6 @@ HWTEST_F(EncodeDataProcessTest, encode_data_process_test_011, TestSize.Level1) { EXPECT_EQ(false, testEncodeDataProcess_ == nullptr); - VideoConfigParams srcParams(VideoCodecType::NO_CODEC, - Videoformat::YUVI420, - 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); -} - -/** - * @tc.name: encode_data_process_test_012 - * @tc.desc: Verify encode data process ProcessData. - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(EncodeDataProcessTest, encode_data_process_test_012, TestSize.Level1) -{ - EXPECT_EQ(false, testEncodeDataProcess_ == nullptr); - VideoConfigParams srcParams(VideoCodecType::NO_CODEC, Videoformat::NV21, DCAMERA_PRODUCER_FPS_DEFAULT, @@ -413,21 +370,17 @@ HWTEST_F(EncodeDataProcessTest, encode_data_process_test_012, TestSize.Level1) 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); + rc = testEncodeDataProcess_->InitEncoderMetadataFormat(); EXPECT_EQ(rc, DCAMERA_OK); } /** - * @tc.name: encode_data_process_test_013 + * @tc.name: encode_data_process_test_012 * @tc.desc: Verify encode data process GetEncoderOutputBuffer. * @tc.type: FUNC * @tc.require: Issue Number */ -HWTEST_F(EncodeDataProcessTest, encode_data_process_test_013, TestSize.Level1) +HWTEST_F(EncodeDataProcessTest, encode_data_process_test_012, TestSize.Level1) { EXPECT_EQ(false, testEncodeDataProcess_ == nullptr); @@ -445,12 +398,12 @@ HWTEST_F(EncodeDataProcessTest, encode_data_process_test_013, TestSize.Level1) } /** - * @tc.name: encode_data_process_test_014 + * @tc.name: encode_data_process_test_013 * @tc.desc: Verify encode data process EncodeDone. * @tc.type: FUNC * @tc.require: Issue Number */ -HWTEST_F(EncodeDataProcessTest, encode_data_process_test_014, TestSize.Level1) +HWTEST_F(EncodeDataProcessTest, encode_data_process_test_013, TestSize.Level1) { EXPECT_EQ(false, testEncodeDataProcess_ == nullptr); @@ -460,12 +413,12 @@ HWTEST_F(EncodeDataProcessTest, encode_data_process_test_014, TestSize.Level1) } /** - * @tc.name: encode_data_process_test_015 + * @tc.name: encode_data_process_test_014 * @tc.desc: Verify encode data process ProcessData codetype equality. * @tc.type: FUNC * @tc.require: Issue Number */ -HWTEST_F(EncodeDataProcessTest, encode_data_process_test_015, TestSize.Level1) +HWTEST_F(EncodeDataProcessTest, encode_data_process_test_014, TestSize.Level1) { EXPECT_EQ(false, testEncodeDataProcess_ == nullptr); 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 index a84919034863d03d07fd12487260dc7211a21427..7d360ba6e32975995d89fb6a2323fbefd048d1b5 100644 --- 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 @@ -20,6 +20,7 @@ #undef private #include "distributed_camera_constants.h" #include "distributed_camera_errno.h" +#include "distributed_hardware_log.h" using namespace testing::ext; @@ -407,6 +408,8 @@ const int32_t TEST_WIDTH = 1920; const int32_t TEST_HEIGTH = 1080; const int32_t TEST_WIDTH2 = 640; const int32_t TEST_HEIGTH2 = 480; +const int32_t TEST_ALIGNEDWIDTH = 1920; +const int32_t TEST_ALIGNEDHEIGTH = 1088; VideoConfigParams SRC_PARAMS1(VideoCodecType::CODEC_H264, Videoformat::NV12, @@ -434,6 +437,7 @@ VideoConfigParams PROC_CONFIG; */ HWTEST_F(ScaleConvertProcessTest, scale_convert_process_test_018, TestSize.Level1) { + DHLOGI("ScaleConvertProcessTest scale_convert_process_test_018."); int32_t rc = testScaleConvertProcess_->InitNode(SRC_PARAMS1, DEST_PARAMS1, PROC_CONFIG); EXPECT_EQ(rc, DCAMERA_OK); } @@ -446,6 +450,7 @@ HWTEST_F(ScaleConvertProcessTest, scale_convert_process_test_018, TestSize.Level */ HWTEST_F(ScaleConvertProcessTest, scale_convert_process_test_019, TestSize.Level1) { + DHLOGI("ScaleConvertProcessTest scale_convert_process_test_019."); std::vector> inputBuffers; int32_t rc = testScaleConvertProcess_->ProcessData(inputBuffers); EXPECT_EQ(rc, DCAMERA_DISABLE_PROCESS); @@ -459,6 +464,7 @@ HWTEST_F(ScaleConvertProcessTest, scale_convert_process_test_019, TestSize.Level */ HWTEST_F(ScaleConvertProcessTest, scale_convert_process_test_020, TestSize.Level1) { + DHLOGI("ScaleConvertProcessTest scale_convert_process_test_020."); ImageUnitInfo srcImgInfo {Videoformat::YUVI420, 0, 0, 0, 0, 0, 0, nullptr}; std::shared_ptr imgBuf = nullptr; int32_t rc = testScaleConvertProcess_->GetImageUnitInfo(srcImgInfo, imgBuf); @@ -482,6 +488,7 @@ HWTEST_F(ScaleConvertProcessTest, scale_convert_process_test_020, TestSize.Level */ HWTEST_F(ScaleConvertProcessTest, scale_convert_process_test_021, TestSize.Level1) { + DHLOGI("ScaleConvertProcessTest scale_convert_process_test_021."); ImageUnitInfo srcImgInfo {Videoformat::YUVI420, 0, 0, 0, 0, 0, 0, nullptr}; size_t capacity = 100; std::shared_ptr imgBuf = std::make_shared(capacity); @@ -505,6 +512,7 @@ HWTEST_F(ScaleConvertProcessTest, scale_convert_process_test_021, TestSize.Level */ HWTEST_F(ScaleConvertProcessTest, scale_convert_process_test_022, TestSize.Level1) { + DHLOGI("ScaleConvertProcessTest scale_convert_process_test_022."); ImageUnitInfo srcImgInfo {Videoformat::NV12, TEST_WIDTH, TEST_HEIGTH, 0, 0, 0, 0, nullptr}; ImageUnitInfo dstImgInfo {Videoformat::NV12, TEST_WIDTH, TEST_HEIGTH, 0, 0, 0, 0, nullptr}; @@ -526,6 +534,7 @@ HWTEST_F(ScaleConvertProcessTest, scale_convert_process_test_022, TestSize.Level */ HWTEST_F(ScaleConvertProcessTest, scale_convert_process_test_023, TestSize.Level1) { + DHLOGI("ScaleConvertProcessTest scale_convert_process_test_023."); ImageUnitInfo srcImgInfo {Videoformat::YUVI420, 0, 0, 0, 0, 0, 0, nullptr}; size_t capacity = 100; std::shared_ptr imgBuf = std::make_shared(capacity); @@ -539,6 +548,97 @@ HWTEST_F(ScaleConvertProcessTest, scale_convert_process_test_023, TestSize.Level int32_t rc = testScaleConvertProcess_->GetImageUnitInfo(srcImgInfo, imgBuf); EXPECT_EQ(rc, DCAMERA_NOT_FOUND); } + +/** + * @tc.name: scale_convert_process_test_024 + * @tc.desc: Verify scale convert process InitNode IsConvertible true. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScaleConvertProcessTest, scale_convert_process_test_024, TestSize.Level1) +{ + DHLOGI("ScaleConvertProcessTest scale_convert_process_test_024."); + int32_t rc = testScaleConvertProcess_->InitNode(SRC_PARAMS1, DEST_PARAMS1, PROC_CONFIG); + EXPECT_EQ(rc, DCAMERA_OK); + + std::vector> inputBuffers; + rc = testScaleConvertProcess_->ProcessData(inputBuffers); + EXPECT_EQ(rc, DCAMERA_BAD_VALUE); +} + +/** + * @tc.name: scale_convert_process_test_025 + * @tc.desc: Verify scale convert process InitNode IsConvertible true. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScaleConvertProcessTest, scale_convert_process_test_025, TestSize.Level1) +{ + DHLOGI("ScaleConvertProcessTest scale_convert_process_test_025."); + int32_t rc = testScaleConvertProcess_->InitNode(SRC_PARAMS1, DEST_PARAMS1, PROC_CONFIG); + 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_026 + * @tc.desc: Verify scale convert process InitNode IsConvertible true. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScaleConvertProcessTest, scale_convert_process_test_026, TestSize.Level1) +{ + DHLOGI("ScaleConvertProcessTest scale_convert_process_test_026."); + int32_t rc = testScaleConvertProcess_->InitNode(SRC_PARAMS1, DEST_PARAMS2, PROC_CONFIG); + 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::YUVI420)); + db->SetInt32("alignedWidth", TEST_ALIGNEDWIDTH); + db->SetInt32("alignedHeight", TEST_ALIGNEDHEIGTH); + 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); +} + +/** + * @tc.name: scale_convert_process_test_027 + * @tc.desc: Verify scale convert process InitNode IsConvertible true. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScaleConvertProcessTest, scale_convert_process_test_027, TestSize.Level1) +{ + DHLOGI("ScaleConvertProcessTest scale_convert_process_test_027."); + int32_t rc = testScaleConvertProcess_->InitNode(SRC_PARAMS1, DEST_PARAMS2, PROC_CONFIG); + EXPECT_EQ(rc, DCAMERA_OK); + + size_t capacity = 3200000; + std::vector> inputBuffers; + std::shared_ptr db = std::make_shared(capacity); + db->SetInt32("Videoformat", static_cast(Videoformat::YUVI420)); + 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_BAD_VALUE); +} #endif } // namespace DistributedHardware } // namespace OHOS