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 <iostream>
17 #include "audio_group_handle_unit_test.h"
18
19 using namespace testing::ext;
20
21 namespace OHOS {
22 namespace AudioStandard {
23
SetUpTestCase(void)24 void AudioGroupHandleUnitTest::SetUpTestCase(void) {}
TearDownTestCase(void)25 void AudioGroupHandleUnitTest::TearDownTestCase(void) {}
SetUp(void)26 void AudioGroupHandleUnitTest::SetUp(void) {}
TearDown(void)27 void AudioGroupHandleUnitTest::TearDown(void) {}
28
29 /**
30 * @tc.name : Test CheckId.
31 * @tc.number: AudioGroupHandleUnitTest_001
32 * @tc.desc : Test CheckId.
33 */
34 HWTEST(AudioGroupHandleUnitTest, AudioGroupHandleUnitTest_001, TestSize.Level4)
35 {
36 AudioGroupHandle audioGroupHandleTest = AudioGroupHandle::GetInstance();
37 GroupType type = GroupType::VOLUME_TYPE;
38 audioGroupHandleTest.currentVolumeId_ = MAX_ID;
39 audioGroupHandleTest.currentInterruptId_ = MAX_ID;
40
41 audioGroupHandleTest.CheckId(type);
42 EXPECT_EQ(0, audioGroupHandleTest.currentVolumeId_);
43 EXPECT_EQ(MAX_ID, audioGroupHandleTest.currentInterruptId_);
44 }
45
46 /**
47 * @tc.name : Test CheckId.
48 * @tc.number: AudioGroupHandleUnitTest_002
49 * @tc.desc : Test CheckId.
50 */
51 HWTEST(AudioGroupHandleUnitTest, AudioGroupHandleUnitTest_002, TestSize.Level4)
52 {
53 AudioGroupHandle audioGroupHandleTest = AudioGroupHandle::GetInstance();
54 GroupType type = GroupType::INTERRUPT_TYPE;
55 audioGroupHandleTest.currentVolumeId_ = 1;
56 audioGroupHandleTest.currentInterruptId_ = MAX_ID;
57
58 audioGroupHandleTest.CheckId(type);
59 EXPECT_EQ(1, audioGroupHandleTest.currentVolumeId_);
60 EXPECT_EQ(0, audioGroupHandleTest.currentInterruptId_);
61 }
62
63 /**
64 * @tc.name : Test CheckId.
65 * @tc.number: AudioGroupHandleUnitTest_003
66 * @tc.desc : Test CheckId.
67 */
68 HWTEST(AudioGroupHandleUnitTest, AudioGroupHandleUnitTest_003, TestSize.Level4)
69 {
70 AudioGroupHandle audioGroupHandleTest = AudioGroupHandle::GetInstance();
71 GroupType type = GroupType::INTERRUPT_TYPE;
72 audioGroupHandleTest.currentVolumeId_ = 1;
73 audioGroupHandleTest.currentInterruptId_ = 1;
74
75 audioGroupHandleTest.CheckId(type);
76 EXPECT_EQ(1, audioGroupHandleTest.currentVolumeId_);
77 EXPECT_EQ(1, audioGroupHandleTest.currentInterruptId_);
78 }
79 } // namespace AudioStandard
80 } // namespace OHOS
81