From 5cce0b7608f10a923d62fe855788c554a721e691 Mon Sep 17 00:00:00 2001 From: w30042960 Date: Wed, 24 May 2023 09:54:21 +0800 Subject: [PATCH] modify UT Signed-off-by: w30042960 --- .../src/audio_render_interface_impl_test.cpp | 2 - .../audio_adapter_internal_test.cpp | 46 ------------------- .../audio_capture_internal_test.cpp | 38 --------------- .../audio_render_internal_test.cpp | 17 ------- 4 files changed, 103 deletions(-) diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_interface/src/audio_render_interface_impl_test.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_interface/src/audio_render_interface_impl_test.cpp index 6074d047..72161307 100644 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_interface/src/audio_render_interface_impl_test.cpp +++ b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_interface/src/audio_render_interface_impl_test.cpp @@ -84,8 +84,6 @@ HWTEST_F(AudioRenderInterfaceImplTest, RenderFrame_002, TestSize.Level1) audioRenderInterfaceImpl_->renderStatus_ = RENDER_STATUS_START; audioRenderInterfaceImpl_->audioExtCallback_ = nullptr; EXPECT_EQ(HDF_FAILURE, audioRenderInterfaceImpl_->RenderFrame(frame, replyBytes)); - audioRenderInterfaceImpl_->audioExtCallback_ = new MockIDAudioCallback(); - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->RenderFrame(frame, replyBytes)); } /** diff --git a/services/hdfaudioclient/test/unittest/audio_adapter_internal/audio_adapter_internal_test.cpp b/services/hdfaudioclient/test/unittest/audio_adapter_internal/audio_adapter_internal_test.cpp index ff843310..a1f167a0 100644 --- a/services/hdfaudioclient/test/unittest/audio_adapter_internal/audio_adapter_internal_test.cpp +++ b/services/hdfaudioclient/test/unittest/audio_adapter_internal/audio_adapter_internal_test.cpp @@ -94,29 +94,6 @@ HWTEST_F(AudioAdapterTest, CreateRenderInternal_001, TestSize.Level1) EXPECT_EQ(ERR_DH_AUDIO_HDI_INVALID_PARAM, ret); } -/** -* @tc.name: CreateRenderInternal -* @tc.desc: Verify the abnormal branch of the CreateRenderInternal, when param is null. -* @tc.type: FUNC -* @tc.require: AR000H0E6H -*/ -HWTEST_F(AudioAdapterTest, CreateRenderInternal_002, TestSize.Level1) -{ - auto adapterContext1 = std::make_unique(); - const struct ::AudioDeviceDescriptor *desc = new ::AudioDeviceDescriptor; - const struct ::AudioSampleAttributes *attrs = new ::AudioSampleAttributes; - struct AudioRender *render = new AudioRender; - int32_t ret = adapterContext1->instance_.CreateRender(&adapterContext1->instance_, desc, attrs, &render); - EXPECT_EQ(ERR_DH_AUDIO_HDI_NULLPTR, ret); - auto adapterContext = std::make_unique(); - adapterContext->proxy_ = new MockIAudioAdapter(); - adapterContext->adapterName_ = "adapterName"; - EXPECT_EQ(DH_SUCCESS, adapterContext->instance_.CreateRender(&adapterContext->instance_, desc, attrs, &render)); - delete desc; - delete attrs; - delete render; -} - /** * @tc.name: DestroyRenderInternal * @tc.desc: Verify the abnormal branch of the DestroyRenderInternal, when param is null. @@ -168,29 +145,6 @@ HWTEST_F(AudioAdapterTest, CreateCaptureInternal_001, TestSize.Level1) EXPECT_EQ(ERR_DH_AUDIO_HDI_INVALID_PARAM, ret); } -/** -* @tc.name: CreateCaptureInternal -* @tc.desc: Verify the abnormal branch of the CreateCaptureInternal, when param is null. -* @tc.type: FUNC -* @tc.require: AR000H0E6H -*/ -HWTEST_F(AudioAdapterTest, CreateCaptureInternal_002, TestSize.Level1) -{ - const struct ::AudioDeviceDescriptor *desc = new ::AudioDeviceDescriptor; - const struct ::AudioSampleAttributes *attrs = new ::AudioSampleAttributes; - auto adapterContext1 = std::make_unique(); - struct AudioCapture *capture = new AudioCapture; - int32_t ret = adapterContext1->instance_.CreateCapture(&adapterContext1->instance_, desc, attrs, &capture); - EXPECT_EQ(ERR_DH_AUDIO_HDI_NULLPTR, ret); - auto adapterContext = std::make_unique(); - adapterContext->proxy_ = new MockIAudioAdapter(); - adapterContext->adapterName_ = "adapterName"; - EXPECT_EQ(DH_SUCCESS, adapterContext->instance_.CreateCapture(&adapterContext->instance_, desc, attrs, &capture)); - delete desc; - delete attrs; - delete capture; -} - /** * @tc.name: DestroyCaptureInternal * @tc.desc: Verify the abnormal branch of the DestroyCaptureInternal, when param is null. diff --git a/services/hdfaudioclient/test/unittest/audio_capture_internal/audio_capture_internal_test.cpp b/services/hdfaudioclient/test/unittest/audio_capture_internal/audio_capture_internal_test.cpp index 4c4680c4..636ebbc2 100644 --- a/services/hdfaudioclient/test/unittest/audio_capture_internal/audio_capture_internal_test.cpp +++ b/services/hdfaudioclient/test/unittest/audio_capture_internal/audio_capture_internal_test.cpp @@ -58,24 +58,6 @@ HWTEST_F(AudioCaptureTest, GetCapturePositionInternal_001, TestSize.Level1) EXPECT_EQ(ERR_DH_AUDIO_HDI_INVALID_PARAM, ret); } -/** -* @tc.name: GetCapturePositionInternal -* @tc.desc: Verify the abnormal branch of the GetCapturePositionInternal, when param is null. -* @tc.type: FUNC -* @tc.require: AR000H0E6H -*/ -HWTEST_F(AudioCaptureTest, GetCapturePositionInternal_002, TestSize.Level1) -{ - struct AudioCaptureContext captureContext; - struct AudioCapture *capture = new AudioCapture; - uint64_t *frames = new uint64_t; - struct ::AudioTimeStamp *time = new ::AudioTimeStamp; - int32_t ret = captureContext.instance_.GetCapturePosition(capture, frames, time); - delete capture; - delete time; - EXPECT_EQ(ERR_DH_AUDIO_HDI_NULLPTR, ret); -} - /** * @tc.name: CaptureFrameInternal * @tc.desc: Verify the abnormal branch of the CaptureFrameInternal, when param is null. @@ -92,25 +74,5 @@ HWTEST_F(AudioCaptureTest, CaptureFrameInternal_001, TestSize.Level1) int32_t ret = captureContext.instance_.CaptureFrame(capture, frame, requestBytes, replyBytes); EXPECT_EQ(ERR_DH_AUDIO_HDI_INVALID_PARAM, ret); } - -/** -* @tc.name: CaptureFrameInternal -* @tc.desc: Verify the abnormal branch of the CaptureFrameInternal, when param is null. -* @tc.type: FUNC -* @tc.require: AR000H0E6H -*/ -HWTEST_F(AudioCaptureTest, CaptureFrameInternal_002, TestSize.Level1) -{ - struct AudioCaptureContext captureContext; - struct AudioCapture *capture = new AudioCapture; - char p = 'c'; - void *frame = &p; - uint64_t requestBytes = 1; - uint64_t *replyBytes = new uint64_t; - int32_t ret = captureContext.instance_.CaptureFrame(capture, frame, requestBytes, replyBytes); - delete capture; - delete replyBytes; - EXPECT_EQ(ERR_DH_AUDIO_HDI_NULLPTR, ret); -} } // DistributedHardware } // OHOS \ No newline at end of file diff --git a/services/hdfaudioclient/test/unittest/audio_render_internal/audio_render_internal_test.cpp b/services/hdfaudioclient/test/unittest/audio_render_internal/audio_render_internal_test.cpp index 55d84d53..648f3f15 100644 --- a/services/hdfaudioclient/test/unittest/audio_render_internal/audio_render_internal_test.cpp +++ b/services/hdfaudioclient/test/unittest/audio_render_internal/audio_render_internal_test.cpp @@ -57,23 +57,6 @@ HWTEST_F(AudioRenderTest, GetLatencyInternal_001, TestSize.Level1) EXPECT_EQ(ERR_DH_AUDIO_HDI_INVALID_PARAM, ret); } -/** -* @tc.name: GetLatencyInternal -* @tc.desc: Verify the abnormal branch of the GetLatencyInternal, when param is null. -* @tc.type: FUNC -* @tc.require: AR000H0E6H -*/ -HWTEST_F(AudioRenderTest, GetLatencyInternal_002, TestSize.Level1) -{ - struct AudioRenderContext renderContext; - struct AudioRender *render = new AudioRender; - uint32_t *ms = new uint32_t; - int32_t ret = renderContext.instance_.GetLatency(render, ms); - delete render; - delete ms; - EXPECT_EQ(ERR_DH_AUDIO_HDI_NULLPTR, ret); -} - /** * @tc.name: RenderFrameInternal * @tc.desc: Verify the abnormal branch of the RenderFrameInternal, when param is null. -- Gitee