mirror of
https://gitee.com/openharmony/xts_hats
synced 2024-12-04 21:29:07 +00:00
commit
428932984f
@ -277,7 +277,7 @@ HWTEST_F(HdfAudioUtAdapterTest, HdfAudioAdapterGetPortCapabilityInvalid002, Test
|
||||
EXPECT_EQ(HDF_ERR_INVALID_PARAM, adapter_->GetPortCapability(adapter_, &port, nullptr));
|
||||
}
|
||||
|
||||
HWTEST_F(HdfAudioUtAdapterTest, HdfAudioAdapterGetPortCapabilityIsvalid001, TestSize.Level1)
|
||||
HWTEST_F(HdfAudioUtAdapterTest, HdfAudioAdapterGetPortCapabilityInvalid003, TestSize.Level1)
|
||||
{
|
||||
struct AudioPort port = {};
|
||||
struct AudioPortCapability capability = {};
|
||||
@ -288,6 +288,14 @@ HWTEST_F(HdfAudioUtAdapterTest, HdfAudioAdapterGetPortCapabilityIsvalid001, Test
|
||||
ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
|
||||
}
|
||||
|
||||
HWTEST_F(HdfAudioUtAdapterTest, HdfAudioAdapterGetPortCapabilityIsvalid001, TestSize.Level1)
|
||||
{
|
||||
struct AudioPort port = adapterDescs_[0].ports[0];
|
||||
struct AudioPortCapability capability = {};
|
||||
int32_t ret = adapter_->GetPortCapability(adapter_, &port, &capability);
|
||||
ASSERT_TRUE(ret == HDF_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(HdfAudioUtAdapterTest, HdfAudioAdapterSetPassthroughModeNull001, TestSize.Level1)
|
||||
{
|
||||
enum AudioPortPassthroughMode mode = PORT_PASSTHROUGH_LPCM;
|
||||
@ -451,4 +459,57 @@ HWTEST_F(HdfAudioUtAdapterTest, HdfAudioAdapterGetExtraParamsNull002, TestSize.L
|
||||
uint32_t valueLen = AUDIO_ADAPTER_BUF_TEST;
|
||||
EXPECT_NE(HDF_SUCCESS, adapter_->GetExtraParams(nullptr, key, condition, value, valueLen));
|
||||
}
|
||||
HWTEST_F(HdfAudioUtAdapterTest, HdfAudioAdapterGetExtraParamsIsvalid001, TestSize.Level1)
|
||||
{
|
||||
enum AudioExtParamKey key = AUDIO_EXT_PARAM_KEY_NONE;
|
||||
char condition[AUDIO_ADAPTER_BUF_TEST];
|
||||
char value[AUDIO_ADAPTER_BUF_TEST] = "sup_sampling_rates=4800;sup_channels=1;sup_formats=2;";
|
||||
uint32_t valueLen = AUDIO_ADAPTER_BUF_TEST;
|
||||
|
||||
int32_t ret = adapter_->GetExtraParams(adapter_, key, condition, value, valueLen);
|
||||
ASSERT_TRUE(ret == HDF_ERR_NOT_SUPPORT || ret == HDF_FAILURE);
|
||||
}
|
||||
|
||||
HWTEST_F(HdfAudioUtAdapterTest, HdfAudioAdapterUpdateAudioRouteNull001, TestSize.Level1)
|
||||
{
|
||||
struct AudioRoute route = {};
|
||||
int32_t routeHandle = 0;
|
||||
EXPECT_NE(HDF_SUCCESS, adapter_->UpdateAudioRoute(nullptr, &route, &routeHandle));
|
||||
}
|
||||
|
||||
HWTEST_F(HdfAudioUtAdapterTest, HdfAudioAdapterUpdateAudioRouteIsvalid001, TestSize.Level1)
|
||||
{
|
||||
struct AudioRoute route = {};
|
||||
int32_t routeHandle = 0;
|
||||
int32_t ret = adapter_->UpdateAudioRoute(adapter_, &route, &routeHandle);
|
||||
ASSERT_TRUE(ret == HDF_ERR_NOT_SUPPORT || ret == HDF_FAILURE);
|
||||
}
|
||||
|
||||
HWTEST_F(HdfAudioUtAdapterTest, HdfAudioAdapterReleaseAudioRouteNull001, TestSize.Level1)
|
||||
{
|
||||
int32_t routeHandle = 0;
|
||||
EXPECT_NE(HDF_SUCCESS, adapter_->ReleaseAudioRoute(nullptr, routeHandle));
|
||||
}
|
||||
|
||||
HWTEST_F(HdfAudioUtAdapterTest, HdfAudioAdapterReleaseAudioRouteIsvalid001, TestSize.Level1)
|
||||
{
|
||||
int32_t routeHandle = 0;
|
||||
int32_t ret = adapter_->ReleaseAudioRoute(adapter_, routeHandle);
|
||||
ASSERT_TRUE(ret == HDF_ERR_NOT_SUPPORT || ret == HDF_FAILURE);
|
||||
}
|
||||
|
||||
HWTEST_F(HdfAudioUtAdapterTest, HdfAudioAdapterGetVersionNull001, TestSize.Level1)
|
||||
{
|
||||
uint32_t majorVer = 0;
|
||||
uint32_t minorVer = 0;
|
||||
EXPECT_NE(HDF_SUCCESS, adapter_->GetVersion(nullptr, &majorVer, &minorVer));
|
||||
}
|
||||
|
||||
HWTEST_F(HdfAudioUtAdapterTest, HdfAudioAdapterGetVersionIsvalid001, TestSize.Level1)
|
||||
{
|
||||
uint32_t majorVer = 0;
|
||||
uint32_t minorVer = 0;
|
||||
int32_t ret = adapter_->GetVersion(adapter_, &majorVer, &minorVer);
|
||||
ASSERT_TRUE(ret == HDF_ERR_NOT_SUPPORT || ret == HDF_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
@ -216,20 +216,21 @@ HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureFrame001, TestSize.Level1)
|
||||
|
||||
HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureFrameExceptions001, TestSize.Level1)
|
||||
{
|
||||
uint32_t frameLen = (uint64_t)GetCaptureBufferSize();
|
||||
uint64_t requestBytes = frameLen;
|
||||
uint32_t invalidLen = -1;
|
||||
uint64_t requestBytes = invalidLen;
|
||||
ASSERT_NE(capture_->CaptureFrame, nullptr);
|
||||
|
||||
int32_t ret = capture_->Start(capture_);
|
||||
EXPECT_EQ(ret, HDF_SUCCESS);
|
||||
|
||||
int8_t *frame = (int8_t *)calloc(1, frameLen);
|
||||
int8_t *frame = (int8_t *)calloc(1, sizeof(int));
|
||||
EXPECT_NE(nullptr, frame);
|
||||
|
||||
EXPECT_NE(HDF_SUCCESS, capture_->CaptureFrame(nullptr, nullptr, nullptr, nullptr));
|
||||
EXPECT_NE(HDF_SUCCESS, capture_->CaptureFrame(capture_, frame, nullptr, nullptr));
|
||||
EXPECT_NE(HDF_SUCCESS, capture_->CaptureFrame(capture_, frame, &frameLen, nullptr));
|
||||
EXPECT_NE(HDF_SUCCESS, capture_->CaptureFrame(nullptr, frame, &frameLen, &requestBytes));
|
||||
EXPECT_NE(HDF_SUCCESS, capture_->CaptureFrame(capture_, frame, &invalidLen, nullptr));
|
||||
EXPECT_NE(HDF_SUCCESS, capture_->CaptureFrame(nullptr, frame, &invalidLen, &requestBytes));
|
||||
EXPECT_NE(HDF_SUCCESS, capture_->CaptureFrame(capture_, frame, &invalidLen, &requestBytes));
|
||||
|
||||
if (frame != nullptr) {
|
||||
free(frame);
|
||||
@ -317,14 +318,6 @@ HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureStop001, TestSize.Level1)
|
||||
EXPECT_EQ(ret, HDF_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureStopException001, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(capture_->Stop, nullptr);
|
||||
|
||||
int32_t ret = capture_->Stop(capture_);
|
||||
ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureStopException002, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(capture_->Stop, nullptr);
|
||||
@ -654,6 +647,47 @@ HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureGetGainThresholdException002, TestSi
|
||||
EXPECT_NE(ret, HDF_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureSetGain001, TestSize.Level1)
|
||||
{
|
||||
EXPECT_NE(capture_->SetGain, nullptr);
|
||||
|
||||
int32_t ret = capture_->SetGain(capture_, HALF_OF_MAX_VOLUME);
|
||||
ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureSetGainException001, TestSize.Level1)
|
||||
{
|
||||
EXPECT_NE(capture_->SetGain, nullptr);
|
||||
float exceptionGain = -3.0;
|
||||
|
||||
int32_t ret = capture_->SetGain(capture_, exceptionGain);
|
||||
EXPECT_NE(ret, HDF_SUCCESS);
|
||||
|
||||
ret = capture_->SetGain(nullptr, HALF_OF_MAX_VOLUME);
|
||||
EXPECT_NE(ret, HDF_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureGetGain001, TestSize.Level1)
|
||||
{
|
||||
EXPECT_NE(capture_->GetGain, nullptr);
|
||||
float getGain;
|
||||
|
||||
int32_t ret = capture_->GetGain(capture_, &getGain);
|
||||
ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureGetGainException001, TestSize.Level1)
|
||||
{
|
||||
EXPECT_NE(capture_->SetGain, nullptr);
|
||||
float exceptionGain = 2.0;
|
||||
|
||||
int32_t ret = capture_->GetGain(capture_, nullptr);
|
||||
EXPECT_NE(ret, HDF_SUCCESS);
|
||||
|
||||
ret = capture_->GetGain(nullptr, &exceptionGain);
|
||||
EXPECT_NE(ret, HDF_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief here starts the attributes cases
|
||||
*/
|
||||
@ -679,7 +713,7 @@ HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureGetSampleAttributesException001, Tes
|
||||
EXPECT_NE(ret, HDF_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureSetSampleAttributesException001, TestSize.Level1)
|
||||
HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureSetSampleAttributes001, TestSize.Level1)
|
||||
{
|
||||
struct AudioSampleAttributes attrs = {
|
||||
.format = AUDIO_FORMAT_TYPE_PCM_16_BIT,
|
||||
@ -688,7 +722,9 @@ HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureSetSampleAttributesException001, Tes
|
||||
};
|
||||
EXPECT_NE(capture_->SetSampleAttributes, nullptr);
|
||||
|
||||
int32_t ret = capture_->SetSampleAttributes(capture_, nullptr);
|
||||
int32_t ret = capture_->SetSampleAttributes(capture_, &attrs);
|
||||
EXPECT_NE(ret, HDF_SUCCESS);
|
||||
ret = capture_->SetSampleAttributes(capture_, nullptr);
|
||||
EXPECT_NE(ret, HDF_SUCCESS);
|
||||
|
||||
ret = capture_->SetSampleAttributes(nullptr, &attrs);
|
||||
@ -780,4 +816,174 @@ HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureGetExtraParamsException001, TestSize
|
||||
EXPECT_NE(ret, HDF_SUCCESS);
|
||||
}
|
||||
|
||||
/* capture selectsene cases */
|
||||
HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureSelectScene001, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(capture_->SelectScene, nullptr);
|
||||
struct AudioSceneDescriptor sceneDesc = {};
|
||||
sceneDesc.desc.pins = PIN_IN_MIC;
|
||||
sceneDesc.desc.desc = strdup("mic");
|
||||
sceneDesc.scene.id = AUDIO_IN_CALL;
|
||||
|
||||
int32_t ret = capture_->SelectScene(capture_, &sceneDesc);
|
||||
EXPECT_EQ(ret, HDF_SUCCESS);
|
||||
free(sceneDesc.desc.desc);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureSelectSceneException001, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(capture_->SelectScene, nullptr);
|
||||
struct AudioSceneDescriptor sceneDesc = {};
|
||||
sceneDesc.scene.id = AUDIO_IN_CALL;
|
||||
|
||||
int32_t ret = capture_->SelectScene(capture_, nullptr);
|
||||
ASSERT_NE(ret, HDF_SUCCESS);
|
||||
|
||||
ret = capture_->SelectScene(nullptr, &sceneDesc);
|
||||
ASSERT_NE(ret, HDF_SUCCESS);
|
||||
}
|
||||
|
||||
/* capture get version cases */
|
||||
HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureGetVersion001, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(capture_->GetVersion, nullptr);
|
||||
uint32_t majorVer;
|
||||
uint32_t minorVer;
|
||||
ASSERT_EQ(HDF_SUCCESS, capture_->GetVersion(capture_, &majorVer, &minorVer));
|
||||
EXPECT_EQ(IAUDIO_MANAGER_MAJOR_VERSION, majorVer);
|
||||
EXPECT_EQ(IAUDIO_MANAGER_MINOR_VERSION, minorVer);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureGetVersionException001, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(capture_->GetVersion, nullptr);
|
||||
uint32_t majorVer;
|
||||
uint32_t minorVer;
|
||||
EXPECT_EQ(HDF_ERR_INVALID_OBJECT, capture_->GetVersion(nullptr, &majorVer, &minorVer));
|
||||
}
|
||||
|
||||
/* capture support pause and resume cases */
|
||||
HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureIsSupportsPauseAndResume001, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(capture_->GetVersion, nullptr);
|
||||
bool supportPause = false;
|
||||
bool supportResume = false;
|
||||
|
||||
int32_t ret = capture_->IsSupportsPauseAndResume(capture_, &supportPause, &supportResume);
|
||||
ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT || ret == HDF_ERR_INVALID_PARAM);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureIsSupportsPauseAndResumeException001, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(capture_->IsSupportsPauseAndResume, nullptr);
|
||||
bool supportPause = false;
|
||||
bool supportResume = false;
|
||||
|
||||
int32_t ret = capture_->IsSupportsPauseAndResume(nullptr, &supportPause, &supportResume);
|
||||
ASSERT_NE(ret, HDF_SUCCESS);
|
||||
|
||||
ret = capture_->IsSupportsPauseAndResume(capture_, nullptr, &supportResume);
|
||||
ASSERT_NE(ret, HDF_SUCCESS);
|
||||
|
||||
ret = capture_->IsSupportsPauseAndResume(capture_, &supportPause, nullptr);
|
||||
ASSERT_NE(ret, HDF_SUCCESS);
|
||||
}
|
||||
|
||||
/* capture GetFrameBufferSize cases */
|
||||
HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureGetFrameBufferSize001, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(capture_->GetFrameBufferSize, nullptr);
|
||||
uint64_t bufferSize = 0;
|
||||
|
||||
int32_t ret = capture_->GetFrameBufferSize(capture_, &bufferSize);
|
||||
ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT || ret == HDF_ERR_INVALID_PARAM);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureGetFrameBufferSizeException001, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(capture_->GetFrameBufferSize, nullptr);
|
||||
uint64_t bufferSize = 0;
|
||||
|
||||
int32_t ret = capture_->GetFrameBufferSize(nullptr, &bufferSize);
|
||||
ASSERT_NE(ret, HDF_SUCCESS);
|
||||
|
||||
ret = capture_->GetFrameBufferSize(capture_, nullptr);
|
||||
ASSERT_NE(ret, HDF_SUCCESS);
|
||||
}
|
||||
|
||||
/* capture AddAudioEffect cases */
|
||||
HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureAddAudioEffect001, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(capture_->AddAudioEffect, nullptr);
|
||||
uint64_t effectId = 0;
|
||||
|
||||
int32_t ret = capture_->AddAudioEffect(capture_, effectId);
|
||||
ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT || ret == HDF_ERR_INVALID_PARAM);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureAddAudioEffectException001, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(capture_->AddAudioEffect, nullptr);
|
||||
uint64_t effectId = -1;
|
||||
|
||||
int32_t ret = capture_->AddAudioEffect(nullptr, effectId);
|
||||
ASSERT_NE(ret, HDF_SUCCESS);
|
||||
|
||||
ret = capture_->AddAudioEffect(capture_, effectId);
|
||||
ASSERT_NE(ret, HDF_SUCCESS);
|
||||
}
|
||||
|
||||
/* capture RemoveAudioEffect cases */
|
||||
HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureRemoveAudioEffect001, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(capture_->RemoveAudioEffect, nullptr);
|
||||
uint64_t effectId = 0;
|
||||
|
||||
int32_t ret = capture_->RemoveAudioEffect(capture_, effectId);
|
||||
ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT || ret == HDF_ERR_INVALID_PARAM);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureRemoveAudioEffectException001, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(capture_->RemoveAudioEffect, nullptr);
|
||||
uint64_t effectId = -1;
|
||||
|
||||
int32_t ret = capture_->RemoveAudioEffect(nullptr, effectId);
|
||||
ASSERT_NE(ret, HDF_SUCCESS);
|
||||
|
||||
ret = capture_->RemoveAudioEffect(capture_, effectId);
|
||||
ASSERT_NE(ret, HDF_SUCCESS);
|
||||
}
|
||||
|
||||
/* capture CheckSceneCapability cases */
|
||||
HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureCheckSceneCapabilityException001, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(capture_->CheckSceneCapability, nullptr);
|
||||
struct AudioSceneDescriptor sceneDesc = {};
|
||||
sceneDesc.desc.pins = PIN_IN_MIC;
|
||||
sceneDesc.desc.desc = strdup("mic");
|
||||
sceneDesc.scene.id = AUDIO_IN_COMMUNICATION;
|
||||
bool isSupport = false;
|
||||
|
||||
int32_t ret = capture_->CheckSceneCapability(capture_, &sceneDesc, &isSupport);
|
||||
EXPECT_EQ(ret, HDF_SUCCESS);
|
||||
free(sceneDesc.desc.desc);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureCheckSceneCapability001, TestSize.Level1)
|
||||
{
|
||||
ASSERT_NE(capture_->CheckSceneCapability, nullptr);
|
||||
struct AudioSceneDescriptor sceneDesc = {};
|
||||
sceneDesc.scene.id = AUDIO_IN_COMMUNICATION;
|
||||
bool isSupport = false;
|
||||
|
||||
int32_t ret = capture_->CheckSceneCapability(nullptr, &sceneDesc, &isSupport);
|
||||
ASSERT_NE(ret, HDF_SUCCESS);
|
||||
|
||||
ret = capture_->CheckSceneCapability(capture_, nullptr, &isSupport);
|
||||
ASSERT_NE(ret, HDF_SUCCESS);
|
||||
|
||||
ret = capture_->CheckSceneCapability(capture_, &sceneDesc, nullptr);
|
||||
ASSERT_NE(ret, HDF_SUCCESS);
|
||||
}
|
||||
} // end of name space
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
struct AudioDeviceDescriptor devDescRender_ = {};
|
||||
struct AudioSampleAttributes attrsRender_ = {};
|
||||
uint32_t renderId_ = 0;
|
||||
char *devDescriptorName_ = nullptr;
|
||||
uint32_t size_ = MAX_AUDIO_ADAPTER_DESC;
|
||||
virtual void SetUp();
|
||||
virtual void TearDown();
|
||||
@ -102,7 +103,8 @@ void AudioUtRenderTest::InitRenderAttrs(struct AudioSampleAttributes &attrs)
|
||||
void AudioUtRenderTest::InitRenderDevDesc(struct AudioDeviceDescriptor &devDesc)
|
||||
{
|
||||
devDesc.pins = PIN_OUT_SPEAKER;
|
||||
devDesc.desc = strdup("cardname");
|
||||
devDescriptorName_ = strdup("cardname");
|
||||
devDesc.desc = devDescriptorName_;
|
||||
|
||||
ASSERT_NE(desc_, nullptr);
|
||||
ASSERT_NE(desc_->ports, nullptr);
|
||||
@ -112,7 +114,6 @@ void AudioUtRenderTest::InitRenderDevDesc(struct AudioDeviceDescriptor &devDesc)
|
||||
return;
|
||||
}
|
||||
}
|
||||
free(devDesc.desc);
|
||||
}
|
||||
|
||||
void AudioUtRenderTest::FreeAdapterElements(struct AudioAdapterDescriptor *dataBlock, bool freeSelf)
|
||||
@ -166,6 +167,8 @@ void AudioUtRenderTest::SetUp()
|
||||
|
||||
void AudioUtRenderTest::TearDown()
|
||||
{
|
||||
ASSERT_NE(devDescriptorName_, nullptr);
|
||||
free(devDescriptorName_);
|
||||
if (adapter_ != nullptr) {
|
||||
adapter_->DestroyRender(adapter_, renderId_);
|
||||
render_ = nullptr;
|
||||
@ -212,6 +215,12 @@ HWTEST_F(AudioUtRenderTest, RenderStopNull001, TestSize.Level1)
|
||||
EXPECT_EQ(HDF_ERR_INVALID_OBJECT, render_->Stop(nullptr));
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtRenderTest, RenderStopInvalid001, TestSize.Level1)
|
||||
{
|
||||
int32_t ret = render_->Stop(render_);
|
||||
ASSERT_TRUE(ret == HDF_ERR_NOT_SUPPORT || ret == HDF_FAILURE);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtRenderTest, RenderGetFrameSizeNull001, TestSize.Level1)
|
||||
{
|
||||
uint64_t frameSize = 0;
|
||||
@ -316,6 +325,15 @@ HWTEST_F(AudioUtRenderTest, RenderCheckSceneCapabilityNull003, TestSize.Level1)
|
||||
EXPECT_EQ(HDF_ERR_INVALID_PARAM, render_->CheckSceneCapability(render_, &scene, nullptr));
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtRenderTest, RenderCheckSceneCapabilityIsValid001, TestSize.Level1)
|
||||
{
|
||||
struct AudioSceneDescriptor scene;
|
||||
bool supported = false;
|
||||
scene.scene.id = AUDIO_IN_MEDIA;
|
||||
scene.desc = devDescRender_;
|
||||
EXPECT_EQ(HDF_SUCCESS, render_->CheckSceneCapability(render_, &scene, &supported));
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtRenderTest, RenderSelectSceneNull001, TestSize.Level1)
|
||||
{
|
||||
struct AudioSceneDescriptor scene;
|
||||
@ -379,6 +397,8 @@ HWTEST_F(AudioUtRenderTest, RenderGetRenderPositionIsValid001, TestSize.Level1)
|
||||
{
|
||||
uint64_t frames = 0;
|
||||
struct AudioTimeStamp time;
|
||||
time.tvSec = 0;
|
||||
time.tvNSec = 0;
|
||||
int32_t ret = render_->GetRenderPosition(render_, &frames, &time);
|
||||
|
||||
ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_INVALID_PARAM);
|
||||
@ -418,8 +438,9 @@ HWTEST_F(AudioUtRenderTest, RenderGetExtraParamsNull002, TestSize.Level1)
|
||||
HWTEST_F(AudioUtRenderTest, RenderGetExtraParamsIsValid001, TestSize.Level1)
|
||||
{
|
||||
char keyValueList[AUDIO_RENDER_BUF_TEST] = {};
|
||||
uint32_t keyValueListLen = 0;
|
||||
EXPECT_NE(HDF_SUCCESS, render_->GetExtraParams(render_, keyValueList, keyValueListLen));
|
||||
uint32_t keyValueListLen = BUFFER_LENTH;
|
||||
int32_t ret = render_->GetExtraParams(render_, keyValueList, keyValueListLen);
|
||||
ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_INVALID_PARAM);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtRenderTest, RenderTurnStandbyModeNull001, TestSize.Level1)
|
||||
@ -429,10 +450,14 @@ HWTEST_F(AudioUtRenderTest, RenderTurnStandbyModeNull001, TestSize.Level1)
|
||||
|
||||
HWTEST_F(AudioUtRenderTest, RenderTurnStandbyModeIsValid001, TestSize.Level1)
|
||||
{
|
||||
EXPECT_EQ(HDF_SUCCESS, render_->Start(render_));
|
||||
EXPECT_EQ(HDF_SUCCESS, render_->TurnStandbyMode(render_));
|
||||
int32_t ret = render_->Stop(render_);
|
||||
ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = render_->Start(render_);
|
||||
ASSERT_EQ(HDF_SUCCESS, ret);
|
||||
|
||||
ret = render_->TurnStandbyMode(render_);
|
||||
EXPECT_EQ(HDF_SUCCESS, ret);
|
||||
|
||||
ret = render_->Stop(render_);
|
||||
ASSERT_TRUE(ret == HDF_ERR_NOT_SUPPORT || ret == HDF_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtRenderTest, RenderAudioDevDumpNull001, TestSize.Level1)
|
||||
@ -546,6 +571,11 @@ HWTEST_F(AudioUtRenderTest, RenderResumeNull001, TestSize.Level1)
|
||||
EXPECT_EQ(HDF_ERR_INVALID_OBJECT, render_->Resume(nullptr));
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtRenderTest, RenderResumeInvalid001, TestSize.Level1)
|
||||
{
|
||||
EXPECT_EQ(HDF_ERR_NOT_SUPPORT, render_->Resume(render_));
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtRenderTest, RenderPauseResumeIsValid001, TestSize.Level1)
|
||||
{
|
||||
EXPECT_EQ(HDF_SUCCESS, render_->Start(render_));
|
||||
@ -673,4 +703,133 @@ HWTEST_F(AudioUtRenderTest, RenderSetVolumeIsValid001, TestSize.Level1)
|
||||
ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtRenderTest, RenderGetRenderSpeedIsInValid001, TestSize.Level1)
|
||||
{
|
||||
float speed = 0.0;
|
||||
ASSERT_EQ(HDF_SUCCESS, render_->Start(render_));
|
||||
EXPECT_EQ(HDF_ERR_INVALID_OBJECT, render_->GetRenderSpeed(nullptr, &speed));
|
||||
EXPECT_EQ(HDF_ERR_NOT_SUPPORT, render_->GetRenderSpeed(render_, nullptr));
|
||||
EXPECT_EQ(HDF_SUCCESS, render_->Stop(render_));
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtRenderTest, RenderGetRenderSpeedIsValid001, TestSize.Level1)
|
||||
{
|
||||
float speed = 0.0;
|
||||
ASSERT_EQ(HDF_SUCCESS, render_->Start(render_));
|
||||
EXPECT_EQ(HDF_ERR_NOT_SUPPORT, render_->GetRenderSpeed(render_, &speed));
|
||||
EXPECT_EQ(HDF_SUCCESS, render_->Stop(render_));
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtRenderTest, RenderGetChannelModeIsInValid001, TestSize.Level1)
|
||||
{
|
||||
enum AudioChannelMode channelMode = AUDIO_CHANNEL_NORMAL;
|
||||
int32_t ret = render_->GetChannelMode(nullptr, &channelMode);
|
||||
EXPECT_EQ(HDF_ERR_INVALID_OBJECT, ret);
|
||||
|
||||
ret = render_->GetChannelMode(render_, nullptr);
|
||||
ASSERT_TRUE(ret == HDF_ERR_INVALID_PARAM || ret == HDF_ERR_NOT_SUPPORT);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtRenderTest, RenderGetChannelModeIsValid001, TestSize.Level1)
|
||||
{
|
||||
enum AudioChannelMode channelMode = AUDIO_CHANNEL_NORMAL;
|
||||
int32_t ret = render_->GetChannelMode(render_, &channelMode);
|
||||
ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtRenderTest, RenderRegCallbackIsInValid001, TestSize.Level1)
|
||||
{
|
||||
int8_t cookie = 0;
|
||||
struct IAudioCallback *audioCallback = nullptr;
|
||||
EXPECT_EQ(HDF_ERR_INVALID_OBJECT, render_->RegCallback(nullptr, audioCallback, cookie));
|
||||
EXPECT_EQ(HDF_ERR_INVALID_PARAM, render_->RegCallback(render_, nullptr, cookie));
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtRenderTest, RenderRegCallbackIsValid001, TestSize.Level1)
|
||||
{
|
||||
int8_t cookie = 0;
|
||||
struct IAudioCallback *audioCallback = nullptr;
|
||||
int32_t ret = render_->RegCallback(render_, audioCallback, cookie);
|
||||
ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_INVALID_PARAM);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtRenderTest, RenderDrainBufferIsInValid001, TestSize.Level1)
|
||||
{
|
||||
enum AudioDrainNotifyType type = AUDIO_DRAIN_NORMAL_MODE;
|
||||
EXPECT_EQ(HDF_ERR_INVALID_OBJECT, render_->DrainBuffer(nullptr, &type));
|
||||
EXPECT_EQ(HDF_ERR_NOT_SUPPORT, render_->DrainBuffer(render_, nullptr));
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtRenderTest, RenderDrainBufferIsValid001, TestSize.Level1)
|
||||
{
|
||||
enum AudioDrainNotifyType type = AUDIO_DRAIN_NORMAL_MODE;
|
||||
EXPECT_EQ(HDF_ERR_NOT_SUPPORT, render_->DrainBuffer(render_, &type));
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtRenderTest, RenderIsSupportsDrainIsInValid001, TestSize.Level1)
|
||||
{
|
||||
bool support = false;
|
||||
int32_t ret = render_->IsSupportsDrain(nullptr, &support);
|
||||
EXPECT_EQ(HDF_ERR_INVALID_OBJECT, ret);
|
||||
ret = render_->IsSupportsDrain(render_, nullptr);
|
||||
ASSERT_TRUE(ret == HDF_ERR_NOT_SUPPORT || ret == HDF_ERR_INVALID_PARAM);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtRenderTest, RenderIsSupportsDrainIsValid001, TestSize.Level1)
|
||||
{
|
||||
bool support = false;
|
||||
int32_t ret = render_->IsSupportsDrain(render_, &support);
|
||||
ASSERT_TRUE(ret == HDF_ERR_NOT_SUPPORT || ret == HDF_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtRenderTest, RenderAddAudioEffectIsInValid001, TestSize.Level1)
|
||||
{
|
||||
uint64_t effectId = 0;
|
||||
EXPECT_EQ(HDF_ERR_INVALID_OBJECT, render_->AddAudioEffect(nullptr, effectId));
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtRenderTest, RenderRemoveAudioEffectIsInValid001, TestSize.Level1)
|
||||
{
|
||||
uint64_t effectId = 0;
|
||||
EXPECT_EQ(HDF_ERR_INVALID_OBJECT, render_->RemoveAudioEffect(nullptr, effectId));
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtRenderTest, RenderGetFrameBufferSizeIsInValid001, TestSize.Level1)
|
||||
{
|
||||
uint64_t bufferSize = BUFFER_LENTH;
|
||||
int32_t ret = render_->GetFrameBufferSize(nullptr, &bufferSize);
|
||||
EXPECT_EQ(HDF_ERR_INVALID_OBJECT, ret);
|
||||
|
||||
ret = render_->GetFrameBufferSize(render_, nullptr);
|
||||
ASSERT_TRUE(ret == HDF_ERR_NOT_SUPPORT || ret == HDF_ERR_INVALID_PARAM);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtRenderTest, RenderGetFrameBufferSizeIsValid001, TestSize.Level1)
|
||||
{
|
||||
uint64_t bufferSize = BUFFER_LENTH;
|
||||
int32_t ret = render_->GetFrameBufferSize(render_, &bufferSize);
|
||||
ASSERT_TRUE(ret == HDF_ERR_NOT_SUPPORT || ret == HDF_ERR_INVALID_PARAM);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtRenderTest, RenderIsSupportsPauseAndResumeIsInValid001, TestSize.Level1)
|
||||
{
|
||||
bool supportPause = false;
|
||||
bool supportResume = false;
|
||||
int32_t ret = render_->IsSupportsPauseAndResume(nullptr, &supportPause, &supportResume);
|
||||
EXPECT_EQ(HDF_ERR_INVALID_OBJECT, ret);
|
||||
|
||||
ret = render_->IsSupportsPauseAndResume(render_, nullptr, &supportResume);
|
||||
ASSERT_TRUE(ret == HDF_ERR_NOT_SUPPORT || ret == HDF_ERR_INVALID_PARAM);
|
||||
|
||||
ret = render_->IsSupportsPauseAndResume(render_, &supportPause, nullptr);
|
||||
ASSERT_TRUE(ret == HDF_ERR_NOT_SUPPORT || ret == HDF_ERR_INVALID_PARAM);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtRenderTest, RenderIsSupportsPauseAndResumeIsValid001, TestSize.Level1)
|
||||
{
|
||||
bool supportPause = false;
|
||||
bool supportResume = false;
|
||||
int32_t ret = render_->IsSupportsPauseAndResume(render_, &supportPause, &supportResume);
|
||||
ASSERT_TRUE(ret == HDF_ERR_NOT_SUPPORT || ret == HDF_ERR_INVALID_PARAM);
|
||||
}
|
||||
} // end of namespace
|
Loading…
Reference in New Issue
Block a user