• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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_recovery_device_unit_test.h"
17 
18 using namespace testing::ext;
19 
20 namespace OHOS {
21 namespace AudioStandard {
22 
SetUpTestCase(void)23 void AudioRecoveryDeviceUnitTest::SetUpTestCase(void) {}
TearDownTestCase(void)24 void AudioRecoveryDeviceUnitTest::TearDownTestCase(void) {}
SetUp(void)25 void AudioRecoveryDeviceUnitTest::SetUp(void) {}
TearDown(void)26 void AudioRecoveryDeviceUnitTest::TearDown(void) {}
27 
28 /**
29 * @tc.name  : Test AudioRecoveryDevice.
30 * @tc.number: AudioRecoveryDeviceUnitTest_001.
31 * @tc.desc  : Test RecoveryPreferredDevices.
32 */
33 HWTEST_F(AudioRecoveryDeviceUnitTest, AudioRecoveryDeviceUnitTest_001, TestSize.Level1)
34 {
35     auto audioRecoveryDevice = std::make_shared<AudioRecoveryDevice>();
36     audioRecoveryDevice->RecoveryPreferredDevices();
37     EXPECT_NE(audioRecoveryDevice, nullptr);
38 }
39 
40 /**
41 * @tc.name  : Test AudioRecoveryDevice.
42 * @tc.number: AudioRecoveryDeviceUnitTest_002.
43 * @tc.desc  : Test RecoverExcludedOutputDevices.
44 */
45 HWTEST_F(AudioRecoveryDeviceUnitTest, AudioRecoveryDeviceUnitTest_002, TestSize.Level1)
46 {
47     auto audioRecoveryDevice = std::make_shared<AudioRecoveryDevice>();
48     audioRecoveryDevice->RecoverExcludedOutputDevices();
49     EXPECT_NE(audioRecoveryDevice, nullptr);
50 }
51 
52 /**
53 * @tc.name  : Test AudioRecoveryDevice.
54 * @tc.number: AudioRecoveryDeviceUnitTest_003.
55 * @tc.desc  : Test HandleExcludedOutputDevicesRecovery.
56 */
57 HWTEST_F(AudioRecoveryDeviceUnitTest, AudioRecoveryDeviceUnitTest_003, TestSize.Level1)
58 {
59     auto audioRecoveryDevice = std::make_shared<AudioRecoveryDevice>();
60     std::vector<std::shared_ptr<Media::MediaMonitor::MonitorDeviceInfo>> excludedDevices;
61     auto mediaMonitor = std::make_shared<Media::MediaMonitor::MonitorDeviceInfo>();
62     excludedDevices.push_back(mediaMonitor);
63     auto result = audioRecoveryDevice->HandleExcludedOutputDevicesRecovery(AudioDeviceUsage::ALL_CALL_DEVICES,
64         excludedDevices);
65     EXPECT_EQ(result, ERROR);
66 }
67 } // namespace AudioStandard
68 } // namespace OHOS