From 3b8edceb9705d86837aa5ffdcf3235a744fe21fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A6=E5=9B=BD=E5=BA=86?= Date: Sat, 11 May 2024 15:04:50 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20f8a3dde=20from=20https://gitee.com/wei-?= =?UTF-8?q?guoqing/distributedhardware=5Fdistributed=5Fcamera=5Fbd/pulls/5?= =?UTF-8?q?75=20=E8=A1=A5=E5=85=85UT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 韦国庆 --- common/test/unittest/common/utils/BUILD.gn | 9 +++++++- .../common/utils/dcamera_utils_tools_test.cpp | 23 +++++++++++++++++++ ...mera_stream_data_process_producer_test.cpp | 2 +- .../pipeline/dcamera_pipeline_sink_test.cpp | 10 ++++---- 4 files changed, 37 insertions(+), 7 deletions(-) diff --git a/common/test/unittest/common/utils/BUILD.gn b/common/test/unittest/common/utils/BUILD.gn index 0ac844ee..e3c2b780 100644 --- a/common/test/unittest/common/utils/BUILD.gn +++ b/common/test/unittest/common/utils/BUILD.gn @@ -42,11 +42,17 @@ ohos_unittest("CommonUtilsTest") { configs = [ ":module_private_config" ] - deps = [ "${common_path}:distributed_camera_utils" ] + deps = [ + "${common_path}:distributed_camera_utils", + "//third_party/googletest:gmock", + "//third_party/googletest:gtest_main", + ] cflags = [ "-fPIC", "-Wall", + "-Dprivate=public", + "-Dprotected=public", ] external_deps = [ @@ -66,6 +72,7 @@ ohos_unittest("CommonUtilsTest") { "HI_LOG_ENABLE", "DH_LOG_TAG=\"CommonUtilsTest\"", "LOG_DOMAIN=0xD004150", + "DCAMERA_MMAP_RESERVE", ] cflags_cc = cflags } diff --git a/common/test/unittest/common/utils/dcamera_utils_tools_test.cpp b/common/test/unittest/common/utils/dcamera_utils_tools_test.cpp index 8eaabf4e..324ff4bf 100644 --- a/common/test/unittest/common/utils/dcamera_utils_tools_test.cpp +++ b/common/test/unittest/common/utils/dcamera_utils_tools_test.cpp @@ -198,5 +198,28 @@ HWTEST_F(DcameraUtilsToolsTest, IsOverDumpSize_001, TestSize.Level1) DumpBufferToFile(fileName, str, size); IsUnderDumpMaxSize(fileName); } + +/** + * @tc.name: IsUnderDumpMaxSize_001 + * @tc.desc: Verify the IsUnderDumpMaxSize. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DcameraUtilsToolsTest, IsUnderDumpMaxSize_001, TestSize.Level1) +{ + std::string longFileName(PATH_MAX + 1, 'a'); + EXPECT_EQ(IsUnderDumpMaxSize(longFileName), DCAMERA_INIT_ERR); +} + +/** + * @tc.name: IsUnderDumpMaxSize_002 + * @tc.desc: Verify the IsUnderDumpMaxSize. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DcameraUtilsToolsTest, IsUnderDumpMaxSize_002, TestSize.Level1) +{ + EXPECT_EQ(IsUnderDumpMaxSize("/nonexistent/file"), DCAMERA_INIT_ERR); +} } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/dcamera_stream_data_process_producer_test.cpp b/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/dcamera_stream_data_process_producer_test.cpp index 8c3ed636..f332817d 100644 --- a/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/dcamera_stream_data_process_producer_test.cpp +++ b/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/dcamera_stream_data_process_producer_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 diff --git a/services/data_process/test/unittest/common/pipeline/dcamera_pipeline_sink_test.cpp b/services/data_process/test/unittest/common/pipeline/dcamera_pipeline_sink_test.cpp index 9cf7cee2..887914bb 100644 --- a/services/data_process/test/unittest/common/pipeline/dcamera_pipeline_sink_test.cpp +++ b/services/data_process/test/unittest/common/pipeline/dcamera_pipeline_sink_test.cpp @@ -84,7 +84,7 @@ HWTEST_F(DCameraPipelineSinkTest, dcamera_pipeline_sink_test_001, TestSize.Level TEST_WIDTH, TEST_HEIGTH); int32_t rc = testSinkPipeline_->CreateDataProcessPipeline(PipelineType::VIDEO, srcParams, destParams, listener); - EXPECT_EQ(rc, DCAMERA_INIT_ERR); + EXPECT_EQ(rc, DCAMERA_OK); usleep(SLEEP_TIME); } @@ -110,14 +110,14 @@ HWTEST_F(DCameraPipelineSinkTest, dcamera_pipeline_sink_test_002, TestSize.Level TEST_WIDTH, TEST_HEIGTH); int32_t rc = testSinkPipeline_->CreateDataProcessPipeline(PipelineType::VIDEO, srcParams, destParams, listener); - EXPECT_EQ(rc, DCAMERA_INIT_ERR); + EXPECT_EQ(rc, DCAMERA_OK); size_t capacity = 100; std::vector> buffers; std::shared_ptr db = std::make_shared(capacity); buffers.push_back(db); rc = testSinkPipeline_->ProcessData(buffers); - EXPECT_EQ(rc, DCAMERA_INIT_ERR); + EXPECT_EQ(rc, DCAMERA_OK); usleep(SLEEP_TIME); } @@ -171,11 +171,11 @@ HWTEST_F(DCameraPipelineSinkTest, dcamera_pipeline_sink_test_004, TestSize.Level TEST_WIDTH, TEST_HEIGTH); int32_t rc = testSinkPipeline_->CreateDataProcessPipeline(PipelineType::VIDEO, srcParams, destParams, listener); - EXPECT_EQ(rc, DCAMERA_INIT_ERR); + EXPECT_EQ(rc, DCAMERA_OK); std::vector> buffers; rc = testSinkPipeline_->ProcessData(buffers); - EXPECT_EQ(rc, DCAMERA_INIT_ERR); + EXPECT_EQ(rc, DCAMERA_BAD_VALUE); usleep(SLEEP_TIME); } -- Gitee