1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <gtest/gtest.h>
17 #include "hdi_service_common.h"
18 
19 using namespace std;
20 using namespace testing::ext;
21 using namespace OHOS::Audio;
22 
23 namespace {
24 const int BUFFER_SIZE_LITTLE = 0;
25 const uint64_t FILESIZE = 1024;
26 
27 class AudioIdlHdiCaptureTest : public testing::Test {
28 public:
29     static void SetUpTestCase(void);
30     static void TearDownTestCase(void);
31     void SetUp();
32     void TearDown();
33     struct IAudioAdapter *adapter = nullptr;
34     struct IAudioCapture *capture = nullptr;
35     static TestAudioManager *manager;
36     uint32_t captureId_ = 0;
37 };
38 
39 TestAudioManager *AudioIdlHdiCaptureTest::manager = nullptr;
40 using THREAD_FUNC = void *(*)(void *);
41 
SetUpTestCase(void)42 void AudioIdlHdiCaptureTest::SetUpTestCase(void)
43 {
44     manager = IAudioManagerGet(IS_STUB);
45     ASSERT_NE(nullptr, manager);
46 }
47 
TearDownTestCase(void)48 void AudioIdlHdiCaptureTest::TearDownTestCase(void)
49 {
50     if (manager != nullptr) {
51         (void)IAudioManagerRelease(manager, IS_STUB);
52     }
53 }
54 
SetUp(void)55 void AudioIdlHdiCaptureTest::SetUp(void)
56 {
57     ASSERT_NE(nullptr, manager);
58     int32_t ret = AudioCreateCapture(manager, PIN_IN_MIC, ADAPTER_NAME, &adapter, &capture, &captureId_);
59     ASSERT_EQ(HDF_SUCCESS, ret);
60 }
61 
TearDown(void)62 void AudioIdlHdiCaptureTest::TearDown(void)
63 {
64     int32_t ret = ReleaseCaptureSource(manager, adapter, capture, captureId_);
65     ASSERT_EQ(HDF_SUCCESS, ret);
66 }
67 
68 /**
69 * @tc.name  AudioCaptureFrame_001
70 * @tc.desc  test AudioCaptureCaptureFrame interface,Returns 0 if the input data is read successfully
71 * @tc.type: FUNC
72 */
73 HWTEST_F(AudioIdlHdiCaptureTest, AudioCaptureFrame_001, TestSize.Level1)
74 {
75     int32_t ret;
76     uint32_t replyBytes = 0;
77     uint64_t requestBytes = 0;
78     uint32_t bufferSize = 0;
79     ASSERT_NE(nullptr, capture);
80     ret = GetCaptureBufferSize(capture, bufferSize);
81     EXPECT_EQ(HDF_SUCCESS, ret);
82     replyBytes = bufferSize;
83     requestBytes = bufferSize;
84     ret = capture->Start(capture);
85     EXPECT_EQ(HDF_SUCCESS, ret);
86     int8_t *frame = (int8_t *)calloc(1, bufferSize);
87     EXPECT_NE(nullptr, frame);
88     ret = capture->CaptureFrame(capture, frame, &replyBytes, &requestBytes);
89     EXPECT_EQ(HDF_SUCCESS, ret);
90     capture->Stop(capture);
91 
92     if (frame != nullptr) {
93         free(frame);
94         frame = nullptr;
95     }
96 }
97 /**
98 * @tc.name  AudioCaptureFrameNull_002
99 * @tc.desc  test AudioCaptureCaptureFrame interface,Returns -3 if the incoming parameter frame is nullptr
100 * @tc.type: FUNC
101 */
102 HWTEST_F(AudioIdlHdiCaptureTest, AudioCaptureFrameNull_002, TestSize.Level1)
103 {
104     int32_t ret;
105     uint32_t replyBytes = 0;
106     uint64_t requestBytes = 0;
107     int8_t *frame = nullptr;
108     uint32_t bufferSize = 0;
109     ASSERT_NE(nullptr, capture);
110     ret = GetCaptureBufferSize(capture, bufferSize);
111     EXPECT_EQ(HDF_SUCCESS, ret);
112     replyBytes = bufferSize;
113     requestBytes = bufferSize;
114     ret = capture->Start(capture);
115     EXPECT_EQ(HDF_SUCCESS, ret);
116     ret = capture->CaptureFrame(capture, frame, &replyBytes, &requestBytes);
117     EXPECT_EQ(HDF_ERR_INVALID_PARAM, ret);
118     capture->Stop(capture);
119 }
120 #ifdef AUDIO_ADM_PASSTHROUGH
121 /**
122 * @tc.name  AudioCaptureFrameNull_003
123 * @tc.desc  test AudioCaptureCaptureFrame interface,Returns -3 if the incoming parameter replyBytes is nullptr
124 * @tc.type: FUNC
125 */
126 HWTEST_F(AudioIdlHdiCaptureTest, AudioCaptureFrameNull_003, TestSize.Level1)
127 {
128     int32_t ret;
129     uint64_t requestBytes = 0;
130     uint32_t *replyBytes = nullptr;
131     uint32_t bufferSize = 0;
132     ASSERT_NE(nullptr, capture);
133     ret = GetCaptureBufferSize(capture, bufferSize);
134     EXPECT_EQ(HDF_SUCCESS, ret);
135     requestBytes = bufferSize;
136     ret = capture->Start(capture);
137     EXPECT_EQ(HDF_SUCCESS, ret);
138     int8_t *frame = (int8_t *)calloc(1, bufferSize);
139     EXPECT_NE(nullptr, frame);
140     ret = capture->CaptureFrame(capture, frame, replyBytes, &requestBytes);
141     EXPECT_EQ(HDF_ERR_INVALID_PARAM, ret);
142 
143     capture->Stop(capture);
144 
145     if (frame != nullptr) {
146         free(frame);
147         frame = nullptr;
148     }
149 }
150 #endif
151 /**
152 * @tc.name  AudioCaptureFrameNull_004
153 * @tc.desc  test AudioCaptureCaptureFrame interface,Returns -3/-4 if the incoming parameter capture is nullptr
154 * @tc.type: FUNC
155 */
156 HWTEST_F(AudioIdlHdiCaptureTest, AudioCaptureFrameNull_004, TestSize.Level1)
157 {
158     int32_t ret;
159     uint64_t requestBytes = 0;
160     uint32_t replyBytes = 0;
161     struct IAudioCapture *captureNull = nullptr;
162     uint32_t bufferSize = 0;
163     ASSERT_NE(nullptr, capture);
164     ret = GetCaptureBufferSize(capture, bufferSize);
165     EXPECT_EQ(HDF_SUCCESS, ret);
166     replyBytes = bufferSize;
167     requestBytes = bufferSize;
168     ret = capture->Start(capture);
169     EXPECT_EQ(HDF_SUCCESS, ret);
170     int8_t *frame = (int8_t *)calloc(1, bufferSize);
171     EXPECT_NE(nullptr, frame);
172     ret = capture->CaptureFrame(captureNull, frame, &replyBytes, &requestBytes);
173     ASSERT_TRUE(ret == HDF_ERR_INVALID_PARAM || ret == HDF_ERR_INVALID_OBJECT);
174 
175     capture->Stop(capture);
176 
177     if (frame != nullptr) {
178         free(frame);
179         frame = nullptr;
180     }
181 }
182 /**
183 * @tc.name  AudioCaptureFrame_005
184 * @tc.desc  Test AudioCaptureFrame interface,Returns -3 if without calling interface capturestart
185 * @tc.type: FUNC
186 */
187 HWTEST_F(AudioIdlHdiCaptureTest, AudioCaptureFrame_005, TestSize.Level1)
188 {
189     int32_t ret;
190     uint64_t requestBytes = 0;
191     uint32_t replyBytes = 0;
192     uint32_t bufferSize = 0;
193     ASSERT_NE(nullptr, capture);
194     ret = GetCaptureBufferSize(capture, bufferSize);
195     EXPECT_EQ(HDF_SUCCESS, ret);
196     replyBytes = bufferSize;
197     requestBytes = bufferSize;
198     int8_t *frame = (int8_t *)calloc(1, bufferSize);
199     EXPECT_NE(nullptr, frame);
200     ret = capture->CaptureFrame(capture, frame, &replyBytes, &requestBytes);
201     ASSERT_TRUE(ret == HDF_ERR_INVALID_PARAM || ret == HDF_SUCCESS);
202 
203     if (frame != nullptr) {
204         free(frame);
205         frame = nullptr;
206     }
207 }
208 /**
209     less than interface requirements
210 * @tc.name  AudioCaptureFrame_006
211 * @tc.desc  test AudioCaptureCaptureFrame interface,Returns -1 if the incoming parameter
212     requestBytes less than interface requirements
213 * @tc.type: FUNC
214 */
215 HWTEST_F(AudioIdlHdiCaptureTest, AudioCaptureFrame_006, TestSize.Level1)
216 {
217     int32_t ret;
218     uint64_t requestBytes = BUFFER_SIZE_LITTLE;
219     uint32_t replyBytes = 0;
220 
221     uint32_t bufferSize = 0;
222     ASSERT_NE(nullptr, capture);
223     ret = GetCaptureBufferSize(capture, bufferSize);
224     EXPECT_EQ(HDF_SUCCESS, ret);
225     replyBytes = bufferSize;
226     ret = capture->Start(capture);
227     EXPECT_EQ(HDF_SUCCESS, ret);
228     int8_t *frame = (int8_t *)calloc(1, bufferSize);
229     EXPECT_NE(nullptr, frame);
230     ret = capture->CaptureFrame(capture, frame, &replyBytes, &requestBytes);
231     EXPECT_EQ(HDF_SUCCESS, ret);
232 
233     capture->Stop(capture);
234 
235     if (frame != nullptr) {
236         free(frame);
237         frame = nullptr;
238     }
239 }
240 /**
241 * @tc.name  AudioCaptureGetCapturePosition_001
242 * @tc.desc  Test AudioCaptureGetCapturePosition interface,Returns 0 if get CapturePosition during playing.
243 * @tc.type: FUNC
244 */
245 HWTEST_F(AudioIdlHdiCaptureTest, AudioCaptureGetCapturePosition_001, TestSize.Level1)
246 {
247     int32_t ret;
248     uint64_t frames = 0;
249     int64_t timeExp = 0;
250     struct AudioTimeStamp time = {.tvSec = 0, .tvNSec = 0};
251     ASSERT_NE(nullptr, capture);
252     struct PrepareAudioPara audiopara = {
253         .capture = capture, .portType = PORT_IN, .adapterName = ADAPTER_NAME.c_str(), .pins = PIN_IN_MIC,
254         .path = AUDIO_CAPTURE_FILE.c_str(), .fileSize = FILESIZE
255     };
256 
257     ret = pthread_create(&audiopara.tids, NULL, (THREAD_FUNC)RecordAudio, &audiopara);
258     ASSERT_EQ(HDF_SUCCESS, ret);
259     sleep(1);
260     if (audiopara.capture != nullptr) {
261         ret = audiopara.capture->GetCapturePosition(audiopara.capture, &frames, &time);
262         if (ret == HDF_SUCCESS) {
263             EXPECT_GT((time.tvSec) * SECTONSEC + (time.tvNSec), timeExp);
264             EXPECT_GT(frames, INITIAL_VALUE);
265         }
266     }
267 
268     ret = ThreadRelease(audiopara);
269     ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
270 }
271 /**
272 * @tc.name  AudioCaptureGetCapturePosition_002
273 * @tc.desc   Test GetCapturePosition interface,Returns 0 if get Position after Pause and resume during playing
274 * @tc.type: FUNC
275 */
276 HWTEST_F(AudioIdlHdiCaptureTest, AudioCaptureGetCapturePosition_002, TestSize.Level1)
277 {
278     int32_t ret;
279     int64_t timeExp = 0;
280     uint64_t frames = 0;
281     struct AudioTimeStamp timeCount = {.tvSec = 0, .tvNSec = 0};
282     ASSERT_NE(nullptr, capture);
283     struct PrepareAudioPara audiopara = {
284         .capture = capture, .portType = PORT_IN, .adapterName = ADAPTER_NAME.c_str(), .pins = PIN_IN_MIC,
285         .path = AUDIO_CAPTURE_FILE.c_str(), .fileSize = FILESIZE
286     };
287 
288     ret = pthread_create(&audiopara.tids, NULL, (THREAD_FUNC)RecordAudio, &audiopara);
289     ASSERT_EQ(HDF_SUCCESS, ret);
290     sleep(1);
291     if (audiopara.capture != nullptr) {
292         ret = audiopara.capture->Pause(audiopara.capture);
293         ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
294         ret = audiopara.capture->GetCapturePosition(audiopara.capture, &frames, &timeCount);
295         ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
296         if (ret == HDF_SUCCESS) {
297             EXPECT_GT((timeCount.tvSec) * SECTONSEC + (timeCount.tvNSec), timeExp);
298             EXPECT_GT(frames, INITIAL_VALUE);
299         }
300 
301         ret = audiopara.capture->Resume(audiopara.capture);
302         ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
303         ret = audiopara.capture->GetCapturePosition(audiopara.capture, &frames, &timeCount);
304         ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
305         if (ret == HDF_SUCCESS) {
306             EXPECT_GT((timeCount.tvSec) * SECTONSEC + (timeCount.tvNSec), timeExp);
307             EXPECT_GT(frames, INITIAL_VALUE);
308         }
309     }
310 
311     ret = ThreadRelease(audiopara);
312     ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
313 }
314 /**
315 * @tc.name  AudioCaptureGetCapturePosition_003
316 * @tc.desc  Test GetCapturePosition interface,Returns 0 if get CapturePosition after stop during playing
317 * @tc.type: FUNC
318 */
319 HWTEST_F(AudioIdlHdiCaptureTest, AudioCaptureGetCapturePosition_003, TestSize.Level1)
320 {
321     int32_t ret;
322     uint64_t frames = 0;
323     struct AudioTimeStamp time = {.tvSec = 0, .tvNSec = 0};
324     int64_t timeExp = 0;
325     ASSERT_NE(nullptr, capture);
326     ret = AudioCaptureStartAndOneFrame(capture);
327     ASSERT_EQ(HDF_SUCCESS, ret);
328     ret = capture->Stop(capture);
329     EXPECT_EQ(HDF_SUCCESS, ret);
330     ret = capture->GetCapturePosition(capture, &frames, &time);
331     if (ret == HDF_SUCCESS) {
332         EXPECT_GT((time.tvSec) * SECTONSEC + (time.tvNSec), timeExp);
333         EXPECT_GT(frames, INITIAL_VALUE);
334     }
335 }
336 /**
337 * @tc.name  AudioCaptureGetCapturePosition_004
338 * @tc.desc  Test GetCapturePosition interface, return 0 if get CapturePosition after the object is created
339 * @tc.type: FUNC
340 */
341 HWTEST_F(AudioIdlHdiCaptureTest, AudioCaptureGetCapturePosition_004, TestSize.Level1)
342 {
343     int32_t ret;
344     uint64_t frames = 0;
345     struct AudioTimeStamp time = {.tvSec = 0, .tvNSec = 0};
346     int64_t timeExp = 0;
347     ASSERT_NE(nullptr, capture);
348     ret = capture->GetCapturePosition(capture, &frames, &time);
349     ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
350     EXPECT_EQ((time.tvSec) * SECTONSEC + (time.tvNSec), timeExp);
351 }
352 /**
353 * @tc.name  AudioCaptureGetCapturePositionNull_005
354 * @tc.desc  Test GetCapturePosition interface, return -3/-4 if setting the parameter Capture is nullptr
355 * @tc.type: FUNC
356 */
357 HWTEST_F(AudioIdlHdiCaptureTest, AudioCaptureGetCapturePositionNull_005, TestSize.Level1)
358 {
359     int32_t ret;
360     struct IAudioCapture *captureNull = nullptr;
361     uint64_t frames = 0;
362     struct AudioTimeStamp time = {};
363     ASSERT_NE(nullptr, capture);
364     ret = AudioCaptureStartAndOneFrame(capture);
365     ASSERT_EQ(HDF_SUCCESS, ret);
366     ret = capture->GetCapturePosition(captureNull, &frames, &time);
367     ASSERT_TRUE(ret == HDF_ERR_INVALID_PARAM || ret == HDF_ERR_INVALID_OBJECT);
368     capture->Stop(capture);
369 }
370 /**
371 * @tc.name  AudioCaptureGetCapturePositionNull_006
372 * @tc.desc  Test GetCapturePosition interface, return -3 if setting the parameter frames is nullptr
373 * @tc.type: FUNC
374 */
375 HWTEST_F(AudioIdlHdiCaptureTest, AudioCaptureGetCapturePositionNull_006, TestSize.Level1)
376 {
377     int32_t ret;
378     uint64_t *framesNull = nullptr;
379     struct AudioTimeStamp time = {.tvSec = 0, .tvNSec = 0};
380     ASSERT_NE(nullptr, capture);
381     ret = AudioCaptureStartAndOneFrame(capture);
382     ASSERT_EQ(HDF_SUCCESS, ret);
383     ret = capture->GetCapturePosition(capture, framesNull, &time);
384     ASSERT_TRUE(ret == HDF_ERR_INVALID_PARAM || ret == HDF_ERR_NOT_SUPPORT);
385     capture->Stop(capture);
386 }
387 /**
388 * @tc.name  AudioCaptureGetCapturePositionNull_007
389 * @tc.desc  Test GetCapturePosition interface, return -3 if setting the parameter time is nullptr
390 * @tc.type: FUNC
391 */
392 HWTEST_F(AudioIdlHdiCaptureTest, AudioCaptureGetCapturePositionNull_007, TestSize.Level1)
393 {
394     int32_t ret;
395     uint64_t frames = 0;
396     struct AudioTimeStamp *timeNull = nullptr;
397     ASSERT_NE(nullptr, capture);
398     ret = AudioCaptureStartAndOneFrame(capture);
399     ASSERT_EQ(HDF_SUCCESS, ret);
400     ret = capture->GetCapturePosition(capture, &frames, timeNull);
401     ASSERT_TRUE(ret == HDF_ERR_INVALID_PARAM || ret == HDF_ERR_NOT_SUPPORT);
402     capture->Stop(capture);
403 }
404 /**
405 * @tc.name  AudioCaptureGetCapturePosition_008
406 * @tc.desc  Test GetCapturePosition interface, return 0 if the GetCapturePosition was called twice
407 * @tc.type: FUNC
408 */
409 HWTEST_F(AudioIdlHdiCaptureTest, AudioCaptureGetCapturePosition_008, TestSize.Level1)
410 {
411     int32_t ret;
412     uint64_t frames = 0;
413     struct AudioTimeStamp time = {.tvSec = 0, .tvNSec = 0};
414     struct AudioTimeStamp timeSec = {.tvSec = 0, .tvNSec = 0};
415     int64_t timeExp = 0;
416     ASSERT_NE(nullptr, capture);
417     ret = AudioCaptureStartAndOneFrame(capture);
418     ASSERT_EQ(HDF_SUCCESS, ret);
419     ret = capture->GetCapturePosition(capture, &frames, &time);
420     ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
421     if (ret == HDF_SUCCESS) {
422         EXPECT_GT((time.tvSec) * SECTONSEC + (time.tvNSec), timeExp);
423         EXPECT_GT(frames, INITIAL_VALUE);
424     }
425     ret = capture->GetCapturePosition(capture, &frames, &timeSec);
426     ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
427     if (ret == HDF_SUCCESS) {
428         EXPECT_GT((time.tvSec) * SECTONSEC + (time.tvNSec), timeExp);
429         EXPECT_GT(frames, INITIAL_VALUE);
430     }
431     capture->Stop(capture);
432 }
433 
434 /**
435 * @tc.name  AudioCaptureReqMmapBufferNull_006
436 * @tc.desc  Test ReqMmapBuffer interface,return -3/-4 if call ReqMmapBuffer interface unsuccessful when setting the
437             incoming parameter handle is nullptr
438 * @tc.type: FUNC
439 */
440 HWTEST_F(AudioIdlHdiCaptureTest, AudioCaptureReqMmapBufferNull_006, TestSize.Level1)
441 {
442     int32_t ret;
443     bool isRender = false;
444     int32_t reqSize = 0;
445     struct AudioMmapBufferDescriptor desc = {};
446     struct IAudioCapture *captureNull = nullptr;
447     ASSERT_NE(nullptr, capture);
448     ret = InitMmapDesc(AUDIO_LOW_LATENCY_CAPTURE_FILE, desc, reqSize, isRender);
449     EXPECT_EQ(HDF_SUCCESS, ret);
450     ret = capture->Start(capture);
451     EXPECT_EQ(HDF_SUCCESS, ret);
452     ret = capture->ReqMmapBuffer(captureNull, reqSize, &desc);
453     ASSERT_TRUE(ret == HDF_ERR_INVALID_PARAM || ret == HDF_ERR_INVALID_OBJECT);
454     capture->Stop(capture);
455 }
456 
457 /**
458 * @tc.name  AudioCaptureGetMmapPositionNull_003
459 * @tc.desc  Test GetMmapPosition interface,return -3 if Error in incoming parameter.
460 * @tc.type: FUNC
461 */
462 HWTEST_F(AudioIdlHdiCaptureTest, AudioCaptureGetMmapPositionNull_003, TestSize.Level1)
463 {
464     int32_t ret;
465     uint64_t *frames = nullptr;
466     ASSERT_NE(nullptr, capture);
467     struct PrepareAudioPara audiopara = {
468         .capture = capture, .portType = PORT_IN, .adapterName = ADAPTER_NAME.c_str(), .pins = PIN_IN_MIC,
469         .path = AUDIO_LOW_LATENCY_CAPTURE_FILE.c_str()
470     };
471 
472     ret = audiopara.capture->GetMmapPosition(audiopara.capture, frames, &(audiopara.time));
473     ASSERT_TRUE(ret == HDF_ERR_INVALID_PARAM || ret == HDF_ERR_NOT_SUPPORT);
474 }
475 /**
476 * @tc.name  AudioCaptureGetMmapPositionNull_004
477 * @tc.desc  Test GetMmapPosition interface,return -3 if Error in incoming parameter.
478 * @tc.type: FUNC
479 */
480 HWTEST_F(AudioIdlHdiCaptureTest, AudioCaptureGetMmapPositionNull_004, TestSize.Level1)
481 {
482     int32_t ret;
483     uint64_t frames = 0;
484     struct AudioTimeStamp *time = nullptr;
485     ASSERT_NE(nullptr, capture);
486     struct PrepareAudioPara audiopara = {
487         .capture = capture, .portType = PORT_IN, .adapterName = ADAPTER_NAME.c_str(), .pins = PIN_IN_MIC,
488         .path = AUDIO_LOW_LATENCY_CAPTURE_FILE.c_str()
489     };
490 
491     ret = audiopara.capture->GetMmapPosition(audiopara.capture, &frames, time);
492     ASSERT_TRUE(ret == HDF_ERR_INVALID_PARAM || ret == HDF_ERR_NOT_SUPPORT);
493 }
494 /**
495 * @tc.name  AudioCaptureGetMmapPositionNull_005
496 * @tc.desc  Test GetMmapPosition interface,return -3/-4 if Error in incoming parameter.
497 * @tc.type: FUNC
498 */
499 HWTEST_F(AudioIdlHdiCaptureTest, AudioCaptureGetMmapPositionNull_005, TestSize.Level1)
500 {
501     int32_t ret;
502     uint64_t frames = 0;
503     struct IAudioCapture *captureNull = nullptr;
504     ASSERT_NE(nullptr, capture);
505     struct PrepareAudioPara audiopara = {
506         .capture = capture, .portType = PORT_IN, .adapterName = ADAPTER_NAME.c_str(), .pins = PIN_IN_MIC,
507         .path = AUDIO_LOW_LATENCY_CAPTURE_FILE.c_str()
508     };
509 
510     ret = audiopara.capture->GetMmapPosition(captureNull, &frames, &(audiopara.time));
511     ASSERT_TRUE(ret == HDF_ERR_INVALID_PARAM || ret == HDF_ERR_INVALID_OBJECT);
512 }
513 }
514