1 /*
2 * Copyright (c) 2022-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 <gtest/gtest.h>
17 #include "audio_system_manager.h"
18
19 using namespace testing::ext;
20 namespace OHOS {
21 namespace AudioStandard {
22 class AudioBalanceUnitTest : public testing::Test {
23 public:
24 static void SetUpTestCase(void);
25 static void TearDownTestCase(void);
26 void SetUp();
27 void TearDown();
28 };
29
SetUpTestCase(void)30 void AudioBalanceUnitTest::SetUpTestCase(void)
31 {
32 // input testsuit setup step,setup invoked before all testcases
33 }
34
TearDownTestCase(void)35 void AudioBalanceUnitTest::TearDownTestCase(void)
36 {
37 // input testsuit teardown step,teardown invoked after all testcases
38 }
39
SetUp(void)40 void AudioBalanceUnitTest::SetUp(void)
41 {
42 // input testcase setup step,setup invoked before each testcases
43 }
44
TearDown(void)45 void AudioBalanceUnitTest::TearDown(void)
46 {
47 // input testcase teardown step,teardown invoked after each testcases
48 }
49
50 /**
51 * @tc.name : Test SetAudioMonoState API
52 * @tc.type : FUNC
53 * @tc.number: SetAudioMonoState_001
54 * @tc.desc : Test SetAudioMonoState interface. Set audio mono state to true
55 */
56 HWTEST(AudioBalanceUnitTest, SetAudioMonoState_001, TestSize.Level1)
57 {
58 bool audioMonoState = true;
59 AudioSystemManager::GetInstance()->SetAudioMonoState(audioMonoState);
60 }
61
62 /**
63 * @tc.name : Test SetAudioMonoState API
64 * @tc.type : FUNC
65 * @tc.number: SetAudioMonoState_002
66 * @tc.desc : Test SetAudioMonoState interface. Set audio mono state to false
67 */
68 HWTEST(AudioBalanceUnitTest, SetAudioMonoState_002, TestSize.Level1)
69 {
70 bool audioMonoState = false;
71 AudioSystemManager::GetInstance()->SetAudioMonoState(audioMonoState);
72 }
73
74 /**
75 * @tc.name : Test SetAudioBalanceValue API
76 * @tc.type : FUNC
77 * @tc.number: SetAudioBalanceValue_001
78 * @tc.desc : Test SetAudioBalanceValue interface. Set audio balance value to -1.0f
79 */
80 HWTEST(AudioBalanceUnitTest, SetAudioBalanceValue_001, TestSize.Level1)
81 {
82 float audioBalanceValue = -1.0f;
83 AudioSystemManager::GetInstance()->SetAudioBalanceValue(audioBalanceValue);
84 }
85
86 /**
87 * @tc.name : Test SetAudioBalanceValue API
88 * @tc.type : FUNC
89 * @tc.number: SetAudioBalanceValue_002
90 * @tc.desc : Test SetAudioBalanceValue interface. Set audio balance value to -0.5f
91 */
92 HWTEST(AudioBalanceUnitTest, SetAudioBalanceValue_002, TestSize.Level1)
93 {
94 float audioBalanceValue = -0.5f;
95 AudioSystemManager::GetInstance()->SetAudioBalanceValue(audioBalanceValue);
96 }
97
98 /**
99 * @tc.name : Test SetAudioBalanceValue API
100 * @tc.type : FUNC
101 * @tc.number: SetAudioBalanceValue_003
102 * @tc.desc : Test SetAudioBalanceValue interface. Set audio balance value to 0.5f
103 */
104 HWTEST(AudioBalanceUnitTest, SetAudioBalanceValue_003, TestSize.Level1)
105 {
106 float audioBalanceValue = 0.5f;
107 AudioSystemManager::GetInstance()->SetAudioBalanceValue(audioBalanceValue);
108 }
109
110 /**
111 * @tc.name : Test SetAudioBalanceValue API
112 * @tc.type : FUNC
113 * @tc.number: SetAudioBalanceValue_004
114 * @tc.desc : Test SetAudioBalanceValue interface. Set audio balance value to 1.0f
115 */
116 HWTEST(AudioBalanceUnitTest, SetAudioBalanceValue_004, TestSize.Level1)
117 {
118 float audioBalanceValue = 1.0f;
119 AudioSystemManager::GetInstance()->SetAudioBalanceValue(audioBalanceValue);
120 }
121
122 /**
123 * @tc.name : Test SetAudioBalanceValue API
124 * @tc.type : FUNC
125 * @tc.number: SetAudioBalanceValue_005
126 * @tc.desc : Test SetAudioBalanceValue interface. Set audio balance value to 0.0f
127 */
128 HWTEST(AudioBalanceUnitTest, SetAudioBalanceValue_005, TestSize.Level1)
129 {
130 float audioBalanceValue = 0.0f;
131 AudioSystemManager::GetInstance()->SetAudioBalanceValue(audioBalanceValue);
132 }
133 } // namespace AudioStandard
134 } // namespace OHOS