1 /*
2 * Copyright (c) 2023 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 "audio_errors.h"
17 #include "audio_input_thread_unit_test.h"
18
19 using namespace testing::ext;
20
21 namespace OHOS {
22 namespace AudioStandard {
23
SetUpTestCase(void)24 void AudioInputThreadUnitTest::SetUpTestCase(void) {}
TearDownTestCase(void)25 void AudioInputThreadUnitTest::TearDownTestCase(void) {}
SetUp(void)26 void AudioInputThreadUnitTest::SetUp(void) {}
TearDown(void)27 void AudioInputThreadUnitTest::TearDown(void) {}
28
29 /**
30 * @tc.name : Test AudioInputThread.
31 * @tc.number: AudioRecoveryDeviceUnitTest_001.
32 * @tc.desc : Test AudioAnalogHeadsetDeviceCheck.
33 */
34 HWTEST_F(AudioInputThreadUnitTest, AudioInputThreadUnitTest_001, TestSize.Level1)
35 {
36 input_event evt;
37 evt.code = SW_HEADPHONE_INSERT;
38 auto audioInputThread = std::make_shared<AudioInputThread>();
39 auto result = audioInputThread->AudioAnalogHeadsetDeviceCheck(evt);
40 EXPECT_EQ(result, SUCCESS);
41
42 evt.code = SW_MICROPHONE_INSERT;
43 result = audioInputThread->AudioAnalogHeadsetDeviceCheck(evt);
44 EXPECT_EQ(result, SUCCESS);
45
46 evt.code = SW_LINEOUT_INSERT;
47 result = audioInputThread->AudioAnalogHeadsetDeviceCheck(evt);
48 EXPECT_EQ(result, SUCCESS);
49
50 evt.code = SW_LINEIN_INSERT;
51 result = audioInputThread->AudioAnalogHeadsetDeviceCheck(evt);
52 EXPECT_EQ(result, ERROR);
53 }
54
55 /**
56 * @tc.name : Test AudioInputThread.
57 * @tc.number: AudioRecoveryDeviceUnitTest_002.
58 * @tc.desc : Test AudioPnpInputPollAndRead.
59 */
60 HWTEST_F(AudioInputThreadUnitTest, AudioInputThreadUnitTest_002, TestSize.Level1)
61 {
62 auto audioInputThread = std::make_shared<AudioInputThread>();
63 auto result = audioInputThread->AudioPnpInputOpen();
64 EXPECT_EQ(result, SUCCESS);
65 }
66 } // namespace AudioStandard
67 } // namespace OHOS