From 914658dfd043f06938cc4c23687980e92a0b34e3 Mon Sep 17 00:00:00 2001 From: chen0088 Date: Wed, 28 Aug 2024 17:25:53 +0800 Subject: [PATCH] add ut Signed-off-by: chen0088 --- ...distributed_camera_source_service_test.cpp | 5 ++ .../unittest/common/pipeline_node/BUILD.gn | 2 + .../abstract_data_process_test.cpp | 70 +++++++++++++++++++ .../pipeline_node/property_carrier_test.cpp | 68 ++++++++++++++++++ 4 files changed, 145 insertions(+) create mode 100644 services/data_process/test/unittest/common/pipeline_node/abstract_data_process_test.cpp create mode 100644 services/data_process/test/unittest/common/pipeline_node/property_carrier_test.cpp diff --git a/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/distributed_camera_source_service_test.cpp b/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/distributed_camera_source_service_test.cpp index 9d55180a..57403d98 100644 --- a/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/distributed_camera_source_service_test.cpp +++ b/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/distributed_camera_source_service_test.cpp @@ -46,6 +46,7 @@ namespace { const std::string TEST_DEVICE_ID = "bb536a637105409e904d4da83790a4a7"; const std::string TEST_CAMERA_DH_ID_0 = "camera_0"; const std::string TEST_REQID = "bb536a637105409e904d4da83790a4a7"; +const int32_t TEST_SOURCE_SERVICE = 200000; } void DistributedCameraSourceServiceTest::SetUpTestCase(void) @@ -178,6 +179,7 @@ HWTEST_F(DistributedCameraSourceServiceTest, dcamera_source_service_test_006, Te testSrcService_->listener_ = std::make_shared(); int32_t ret = testSrcService_->InitSource(params, callbackProxy); EXPECT_EQ(DCAMERA_OK, ret); + usleep(TEST_SOURCE_SERVICE); } /** @@ -193,6 +195,7 @@ HWTEST_F(DistributedCameraSourceServiceTest, dcamera_source_service_test_007, Te int32_t ret = testSrcService_->ReleaseSource(); EXPECT_EQ(DCAMERA_BAD_VALUE, ret); + usleep(TEST_SOURCE_SERVICE); } /** @@ -208,6 +211,7 @@ HWTEST_F(DistributedCameraSourceServiceTest, dcamera_source_service_test_008, Te int32_t ret = testSrcService_->LoadDCameraHDF(); EXPECT_EQ(DCAMERA_OK, ret); + usleep(TEST_SOURCE_SERVICE); } /** @@ -225,6 +229,7 @@ HWTEST_F(DistributedCameraSourceServiceTest, dcamera_source_service_test_009, Te EXPECT_EQ(DCAMERA_OK, ret); ret = testSrcService_->UnLoadCameraHDF(); EXPECT_EQ(DCAMERA_OK, ret); + usleep(TEST_SOURCE_SERVICE); } } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/services/data_process/test/unittest/common/pipeline_node/BUILD.gn b/services/data_process/test/unittest/common/pipeline_node/BUILD.gn index fa69c43b..3b99e709 100644 --- a/services/data_process/test/unittest/common/pipeline_node/BUILD.gn +++ b/services/data_process/test/unittest/common/pipeline_node/BUILD.gn @@ -41,9 +41,11 @@ ohos_unittest("DCameraDataProcessPipelineNodeTest") { module_out_path = module_out_path sources = [ + "abstract_data_process_test.cpp", "decode_data_process_test.cpp", "encode_data_process_test.cpp", "fps_controller_process_test.cpp", + "property_carrier_test.cpp", "scale_convert_process_test.cpp", ] diff --git a/services/data_process/test/unittest/common/pipeline_node/abstract_data_process_test.cpp b/services/data_process/test/unittest/common/pipeline_node/abstract_data_process_test.cpp new file mode 100644 index 00000000..04588486 --- /dev/null +++ b/services/data_process/test/unittest/common/pipeline_node/abstract_data_process_test.cpp @@ -0,0 +1,70 @@ +/* + * 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 "abstract_data_process.h" +#include "distributed_camera_errno.h" +#include "encode_data_process.h" + +using namespace testing::ext; + +namespace OHOS { +namespace DistributedHardware { +class AbstractDataProcessTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + + std::shared_ptr testAbstractDataProcess_; +}; + +void AbstractDataProcessTest::SetUpTestCase(void) +{ +} + +void AbstractDataProcessTest::TearDownTestCase(void) +{ +} + +void AbstractDataProcessTest::SetUp(void) +{ + std::shared_ptr sinkPipeline = std::make_shared(); + testAbstractDataProcess_ = std::make_shared(sinkPipeline); +} + +void AbstractDataProcessTest::TearDown(void) +{ + testAbstractDataProcess_ = nullptr; +} + +/** + * @tc.name: abstract_data_process_test_001 + * @tc.desc: Verify SetNextNode. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(AbstractDataProcessTest, abstract_data_process_test_001, TestSize.Level1) +{ + EXPECT_EQ(false, testAbstractDataProcess_ == nullptr); + + std::shared_ptr nextDataProcess = nullptr; + int32_t ret = testAbstractDataProcess_->SetNextNode(nextDataProcess); + EXPECT_EQ(ret, DCAMERA_BAD_VALUE); +} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/data_process/test/unittest/common/pipeline_node/property_carrier_test.cpp b/services/data_process/test/unittest/common/pipeline_node/property_carrier_test.cpp new file mode 100644 index 00000000..4c8b2b67 --- /dev/null +++ b/services/data_process/test/unittest/common/pipeline_node/property_carrier_test.cpp @@ -0,0 +1,68 @@ +/* + * 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 "property_carrier.h" +#include "distributed_camera_errno.h" + +using namespace testing::ext; + +namespace OHOS { +namespace DistributedHardware { +class PropertyCarrierTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + + std::shared_ptr testPropertyCarrier_; +}; + +void PropertyCarrierTest::SetUpTestCase(void) +{ +} + +void PropertyCarrierTest::TearDownTestCase(void) +{ +} + +void PropertyCarrierTest::SetUp(void) +{ + testPropertyCarrier_ = std::make_shared(); +} + +void PropertyCarrierTest::TearDown(void) +{ + testPropertyCarrier_ = nullptr; +} + +/** + * @tc.name: property_carrier_test_001 + * @tc.desc: Verify CarrySurfaceProperty. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(PropertyCarrierTest, property_carrier_test_001, TestSize.Level1) +{ + EXPECT_EQ(false, testPropertyCarrier_ == nullptr); + + sptr surface = nullptr; + int32_t ret = testPropertyCarrier_->CarrySurfaceProperty(surface); + EXPECT_EQ(ret, DCAMERA_BAD_VALUE); +} +} // namespace DistributedHardware +} // namespace OHOS -- Gitee