diff --git a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/dcamera_sink_handler_test.cpp b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/dcamera_sink_handler_test.cpp index 883c26123850c5d46a967630b89db19bb4570936..cdec29242af56486a6ff2e4b532ddfd7213933a1 100644 --- a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/dcamera_sink_handler_test.cpp +++ b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/dcamera_sink_handler_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 @@ -198,5 +198,82 @@ HWTEST_F(DCameraSinkHandlerTest, dcamera_sink_handler_test_006, TestSize.Level1) int32_t ret = DCameraSinkHandler::GetInstance().ReleaseSink(); EXPECT_EQ(DCAMERA_OK, ret); } + +/** + * @tc.name: dcamera_sink_handler_test_007 + * @tc.desc: Verify the function. + * @tc.type: FUNC + * @tc.require: issue + */ +HWTEST_F(DCameraSinkHandlerTest, dcamera_sink_handler_test_007, TestSize.Level1) +{ + int32_t ret = DCameraSinkHandler::GetInstance().ReleaseSink(); + EXPECT_EQ(DCAMERA_BAD_VALUE, ret); +} + +/** + * @tc.name: dcamera_sink_handler_test_008 + * @tc.desc: Verify the function. + * @tc.type: FUNC + * @tc.require: issue + */ +HWTEST_F(DCameraSinkHandlerTest, dcamera_sink_handler_test_008, TestSize.Level1) +{ + std::shared_ptr listener; + int32_t ret = DCameraSinkHandler::GetInstance().RegisterPrivacyResources(listener); + EXPECT_EQ(DCAMERA_OK, ret); +} + +/** + * @tc.name: dcamera_sink_handler_test_009 + * @tc.desc: Verify the function. + * @tc.type: FUNC + * @tc.require: issue + */ +HWTEST_F(DCameraSinkHandlerTest, dcamera_sink_handler_test_009, TestSize.Level1) +{ + std::string networkId = "test009"; + int32_t ret = DCameraSinkHandler::GetInstance().PauseDistributedHardware(networkId); + EXPECT_EQ(DCAMERA_BAD_VALUE, ret); + + ret = DCameraSinkHandler::GetInstance().ResumeDistributedHardware(networkId); + EXPECT_EQ(DCAMERA_BAD_VALUE, ret); + + ret = DCameraSinkHandler::GetInstance().StopDistributedHardware(networkId); + EXPECT_EQ(DCAMERA_BAD_VALUE, ret); +} + +/** + * @tc.name: dcamera_sink_handler_test_010 + * @tc.desc: Verify the function. + * @tc.type: FUNC + * @tc.require: issue + */ +HWTEST_F(DCameraSinkHandlerTest, dcamera_sink_handler_test_010, TestSize.Level1) +{ + std::string params = "test010"; + int32_t systemAbilityId = 4804; + sptr samgr = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + sptr remoteObject = samgr->GetSystemAbility(systemAbilityId); + sptr loadCallback(new DCameraSinkLoadCallback(params)); + loadCallback->OnLoadSystemAbilitySuccess(systemAbilityId, remoteObject); + + remoteObject = nullptr; + loadCallback->OnLoadSystemAbilitySuccess(systemAbilityId, remoteObject); + systemAbilityId = 1; + loadCallback->OnLoadSystemAbilitySuccess(systemAbilityId, remoteObject); + int32_t ret = DCameraSinkHandler::GetInstance().InitSink(params); + EXPECT_EQ(DCAMERA_OK, ret); + + ret = DCameraSinkHandler::GetInstance().PauseDistributedHardware(params); + EXPECT_EQ(DCAMERA_BAD_VALUE, ret); + + ret = DCameraSinkHandler::GetInstance().ResumeDistributedHardware(params); + EXPECT_EQ(DCAMERA_BAD_VALUE, ret); + + ret = DCameraSinkHandler::GetInstance().StopDistributedHardware(params); + EXPECT_EQ(DCAMERA_BAD_VALUE, ret); +} } } \ No newline at end of file diff --git a/services/cameraservice/cameraoperator/client/test/unittest/common/cameraoperator/dcamera_client_test.cpp b/services/cameraservice/cameraoperator/client/test/unittest/common/cameraoperator/dcamera_client_test.cpp index 8e94ae3084a14006d7b09d697e3cc2c1cf076e56..fe8ddc19a769987fd05573bec2e632264e7f42da 100644 --- a/services/cameraservice/cameraoperator/client/test/unittest/common/cameraoperator/dcamera_client_test.cpp +++ b/services/cameraservice/cameraoperator/client/test/unittest/common/cameraoperator/dcamera_client_test.cpp @@ -370,6 +370,12 @@ HWTEST_F(DCameraClientTest, dcamera_client_test_004, TestSize.Level1) ret = client_->StartCapture(captureInfos, pSurface); EXPECT_EQ(DCAMERA_OK, ret); + ret = client_->PauseCapture(); + EXPECT_EQ(DCAMERA_OK, ret); + + ret = client_->ResumeCapture(); + EXPECT_EQ(DCAMERA_OK, ret); + auto metaData = std::make_shared(ENTRY_CAPACITY, DATA_CAPACITY); std::string abilityString = Camera::MetadataUtils::EncodeToString(metaData); std::vector> settings; @@ -667,5 +673,21 @@ HWTEST_F(DCameraClientTest, dcamera_client_test_015, TestSize.Level1) int32_t ret = client_->StartCaptureInner(info); EXPECT_EQ(DCAMERA_BAD_VALUE, ret); } + +/** + * @tc.name: dcamera_client_test_016 + * @tc.desc: Verify PauseCapture ResumeCapture + * @tc.type: FUNC + * @tc.require: AR000GK6ML + */ +HWTEST_F(DCameraClientTest, dcamera_client_test_016, TestSize.Level1) +{ + DHLOGI("DCameraClientTest dcamera_client_test_016: test PauseCapture"); + int32_t ret = client_->PauseCapture(); + EXPECT_EQ(DCAMERA_BAD_VALUE, ret); + + ret = client_->ResumeCapture(); + EXPECT_EQ(DCAMERA_BAD_VALUE, ret); +} } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/BUILD.gn b/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/BUILD.gn index 9e531fecc27636ee4103dc783b172366e3e12cbd..76b2d5a9303f620c21f338d91e2ca3da61bc179b 100644 --- a/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/BUILD.gn +++ b/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/BUILD.gn @@ -60,6 +60,7 @@ ohos_unittest("DistributedCameraSinkServiceTest") { module_out_path = module_out_path sources = [ + "dcamera_sink_callback_proxy_test.cpp", "dcamera_sink_hidumper_test.cpp", "distributed_camera_sink_service_test.cpp", "distributed_camera_sink_stub_test.cpp", diff --git a/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/dcamera_sink_callback_proxy_test.cpp b/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/dcamera_sink_callback_proxy_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c5ed0ccfbfec23322bdd0f96cdef34c7b94c69c5 --- /dev/null +++ b/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/dcamera_sink_callback_proxy_test.cpp @@ -0,0 +1,82 @@ +/* + * 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_proxy.h" +#include "distributed_camera_errno.h" +#include "distributed_camera_constants.h" +#include "distributed_camera_sink_proxy.h" +#include "distributed_hardware_log.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" + +using namespace testing::ext; + +namespace OHOS { +namespace DistributedHardware { +class DcameraSinkCallbackProxyTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; + +void DcameraSinkCallbackProxyTest::SetUpTestCase(void) +{ + DHLOGI("DcameraSinkCallbackProxyTest::SetUpTestCase"); +} + +void DcameraSinkCallbackProxyTest::TearDownTestCase(void) +{ + DHLOGI("DcameraSinkCallbackProxyTest::TearDownTestCase"); +} + +void DcameraSinkCallbackProxyTest::SetUp(void) +{ + DHLOGI("DcameraSinkCallbackProxyTest::SetUp"); +} + +void DcameraSinkCallbackProxyTest::TearDown(void) +{ + DHLOGI("DcameraSinkCallbackProxyTest::TearDown"); +} + +/** + * @tc.name: dcamera_sink_callback_proxy_test_001 + * @tc.desc: Verify the OnNotifyResourceInfo function. + * @tc.type: FUNC + * @tc.require: issue + */ +HWTEST_F(DcameraSinkCallbackProxyTest, dcamera_sink_callback_proxy_test_001, TestSize.Level1) +{ + DHLOGI("DcameraSinkCallbackProxyTest::dcamera_sink_callback_proxy_test_001"); + sptr samgr = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID); + sptr callbackProxy(new DCameraSinkCallbackProxy(remoteObject)); + EXPECT_EQ(false, callbackProxy == nullptr); + + ResourceEventType type = ResourceEventType::EVENT_TYPE_QUERY_RESOURCE; + const std::string subtype = ""; + const std::string networkId = ""; + bool isSensitive = 0; + bool isSameAccout = 0; + int32_t ret = callbackProxy->OnNotifyResourceInfo(type, subtype, networkId, isSensitive, isSameAccout); + EXPECT_EQ(DCAMERA_OK, ret); +} +} // namespace DistributedHardware +} // namespace OHOS \ No newline at end of file diff --git a/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/distributed_camera_sink_stub_test.cpp b/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/distributed_camera_sink_stub_test.cpp index 7a32020decfe4f73edec655ec33be7d4c978a014..6f935d22bf1a882213234eef5e439e8e9e50441c 100644 --- a/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/distributed_camera_sink_stub_test.cpp +++ b/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/distributed_camera_sink_stub_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 @@ -228,5 +228,53 @@ HWTEST_F(DcameraSinkStubTest, dcamera_sink_stub_test_009, TestSize.Level1) int32_t ret = sinkProxy.CloseChannel(dhId); EXPECT_EQ(DCAMERA_OK, ret); } + +/** + * @tc.name: dcamera_sink_stub_test_010 + * @tc.desc: Verify the PauseDistributedHardware function. + * @tc.type: FUNC + * @tc.require: issue + */ +HWTEST_F(DcameraSinkStubTest, dcamera_sink_stub_test_010, TestSize.Level1) +{ + DHLOGI("dcamera_sink_stub_test_010"); + sptr sinkStubPtr(new MockDistributedCameraSinkStub()); + DistributedCameraSinkProxy sinkProxy(sinkStubPtr); + std::string networkId = "test10"; + int32_t ret = sinkProxy.PauseDistributedHardware(networkId); + EXPECT_EQ(DCAMERA_OK, ret); +} + +/** + * @tc.name: dcamera_sink_stub_test_011 + * @tc.desc: Verify the ResumeDistributedHardware function. + * @tc.type: FUNC + * @tc.require: issue + */ +HWTEST_F(DcameraSinkStubTest, dcamera_sink_stub_test_011, TestSize.Level1) +{ + DHLOGI("dcamera_sink_stub_test_011"); + sptr sinkStubPtr(new MockDistributedCameraSinkStub()); + DistributedCameraSinkProxy sinkProxy(sinkStubPtr); + std::string networkId = "test11"; + int32_t ret = sinkProxy.ResumeDistributedHardware(networkId); + EXPECT_EQ(DCAMERA_OK, ret); +} + +/** + * @tc.name: dcamera_sink_stub_test_012 + * @tc.desc: Verify the StopDistributedHardware function. + * @tc.type: FUNC + * @tc.require: issue + */ +HWTEST_F(DcameraSinkStubTest, dcamera_sink_stub_test_012, TestSize.Level1) +{ + DHLOGI("dcamera_sink_stub_test_012"); + sptr sinkStubPtr(new MockDistributedCameraSinkStub()); + DistributedCameraSinkProxy sinkProxy(sinkStubPtr); + std::string networkId = "test12"; + int32_t ret = sinkProxy.StopDistributedHardware(networkId); + EXPECT_EQ(DCAMERA_OK, ret); +} } // namespace DistributedHardware } // namespace OHOS \ 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 f594e3a234984dfbeb5a17ba0a84ffbb076a4c71..934598831a5b34da243da2b924d51a48f9cd546b 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 @@ -457,5 +457,67 @@ HWTEST_F(EncodeDataProcessTest, encode_data_process_test_014, TestSize.Level1) testEncodeDataProcess_->OnOutputBufferAvailable(index, info, flag, buffer); EXPECT_EQ(rc, DCAMERA_OK); } + +/** + * @tc.name: encode_data_process_test_015 + * @tc.desc: Verify encode data process GetProperty. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(EncodeDataProcessTest, encode_data_process_test_015, TestSize.Level1) +{ + EXPECT_EQ(false, testEncodeDataProcess_ == nullptr); + + std::string propertyName = "propertyName"; + PropertyCarrier propertyCarrier; + int32_t rc = testEncodeDataProcess_->GetProperty(propertyName, propertyCarrier); + EXPECT_EQ(rc, DCAMERA_OK); +} + +/** + * @tc.name: encode_data_process_test_016 + * @tc.desc: Verify encode data process GetProperty. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(EncodeDataProcessTest, encode_data_process_test_016, 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); + + std::string propertyName = "surface"; + PropertyCarrier propertyCarrier; + rc = testEncodeDataProcess_->GetProperty(propertyName, propertyCarrier); + EXPECT_EQ(rc, DCAMERA_OK); +} + +/** + * @tc.name: encode_data_process_test_017 + * @tc.desc: Verify encode data process GetProperty. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(EncodeDataProcessTest, encode_data_process_test_017, TestSize.Level1) +{ + EXPECT_EQ(false, testEncodeDataProcess_ == nullptr); + + std::string propertyName = "surface"; + PropertyCarrier propertyCarrier; + int32_t rc = testEncodeDataProcess_->GetProperty(propertyName, propertyCarrier); + EXPECT_EQ(rc, DCAMERA_BAD_VALUE); +} } // namespace DistributedHardware } // namespace OHOS