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 <gmock/gmock.h>
17 #include <gtest/gtest.h>
18 #include <sys/mman.h>
19
20 #include "daudio_capture_internal.h"
21 #include "audio_capture.h"
22 #include "daudio_errorcode.h"
23 #include "daudio_log.h"
24
25 #define HDF_LOG_TAG HDF_AUDIO_UT
26
27 using namespace std;
28 using namespace testing::ext;
29 namespace OHOS {
30 namespace DistributedHardware {
31 class AudioCaptureTest : public testing::Test {
32 public:
33 static void SetUpTestCase();
34 static void TearDownTestCase();
35 };
36
SetUpTestCase()37 void AudioCaptureTest::SetUpTestCase()
38 {
39 }
40
TearDownTestCase()41 void AudioCaptureTest::TearDownTestCase()
42 {
43 }
44
45 /**
46 * @tc.name: GetCapturePositionInternal
47 * @tc.desc: Verify the abnormal branch of the GetCapturePositionInternal, when param is null.
48 * @tc.type: FUNC
49 * @tc.require: AR000H0E6H
50 */
51 HWTEST_F(AudioCaptureTest, GetCapturePositionInternal_001, TestSize.Level1)
52 {
53 struct AudioCaptureContext captureContext;
54 struct AudioCapture *capture = nullptr;
55 uint64_t *frames = nullptr;
56 struct ::AudioTimeStamp *time = nullptr;
57 int32_t ret = captureContext.instance_.GetCapturePosition(capture, frames, time);
58 EXPECT_EQ(ERR_DH_AUDIO_HDI_INVALID_PARAM, ret);
59 }
60
61 /**
62 * @tc.name: CaptureFrameInternal
63 * @tc.desc: Verify the abnormal branch of the CaptureFrameInternal, when param is null.
64 * @tc.type: FUNC
65 * @tc.require: AR000H0E6H
66 */
67 HWTEST_F(AudioCaptureTest, CaptureFrameInternal_001, TestSize.Level1)
68 {
69 struct AudioCaptureContext captureContext;
70 struct AudioCapture *capture = nullptr;
71 void *frame = nullptr;
72 uint64_t requestBytes = 0;
73 uint64_t *replyBytes = nullptr;
74 int32_t ret = captureContext.instance_.CaptureFrame(capture, frame, requestBytes, replyBytes);
75 EXPECT_EQ(ERR_DH_AUDIO_HDI_INVALID_PARAM, ret);
76 }
77 } // DistributedHardware
78 } // OHOS