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 "../include/privacy_priority_router_unit_test.h"
17 #include "audio_errors.h"
18 #include "audio_policy_log.h"
19
20 #include <thread>
21 #include <memory>
22 #include <vector>
23 using namespace testing::ext;
24
25 namespace OHOS {
26 namespace AudioStandard {
27
SetUpTestCase(void)28 void PrivacyPriorityRouterUnitTest::SetUpTestCase(void) {}
TearDownTestCase(void)29 void PrivacyPriorityRouterUnitTest::TearDownTestCase(void) {}
SetUp(void)30 void PrivacyPriorityRouterUnitTest::SetUp(void) {}
TearDown(void)31 void PrivacyPriorityRouterUnitTest::TearDown(void) {}
32
33 /**
34 * @tc.name : Test PrivacyPriorityRouter.
35 * @tc.number: PrivacyPriorityRouter_001
36 * @tc.desc : Test NeedLatestConnectWithDefaultDevices interface.
37 */
38 HWTEST(PrivacyPriorityRouterUnitTest, PrivacyPriorityRouter_001, TestSize.Level1)
39 {
40 PrivacyPriorityRouter router;
41
42 EXPECT_TRUE(router.NeedLatestConnectWithDefaultDevices(DEVICE_TYPE_WIRED_HEADSET));
43 EXPECT_TRUE(router.NeedLatestConnectWithDefaultDevices(DEVICE_TYPE_WIRED_HEADPHONES));
44 EXPECT_TRUE(router.NeedLatestConnectWithDefaultDevices(DEVICE_TYPE_BLUETOOTH_SCO));
45 EXPECT_TRUE(router.NeedLatestConnectWithDefaultDevices(DEVICE_TYPE_USB_HEADSET));
46 EXPECT_TRUE(router.NeedLatestConnectWithDefaultDevices(DEVICE_TYPE_BLUETOOTH_A2DP));
47 EXPECT_TRUE(router.NeedLatestConnectWithDefaultDevices(DEVICE_TYPE_USB_ARM_HEADSET));
48 EXPECT_FALSE(router.NeedLatestConnectWithDefaultDevices(DEVICE_TYPE_NONE));
49 }
50
51 /**
52 * @tc.name : Test PrivacyPriorityRouter.
53 * @tc.number: PrivacyPriorityRouter_002
54 * @tc.desc : Test GetRingRenderDevices interface.
55 */
56 HWTEST(PrivacyPriorityRouterUnitTest, PrivacyPriorityRouter_002, TestSize.Level1)
57 {
58 PrivacyPriorityRouter router;
59
60 EXPECT_EQ(1, router.GetRingRenderDevices(STREAM_USAGE_VOICE_RINGTONE, 1).size());
61 EXPECT_EQ(1, router.GetRingRenderDevices(STREAM_USAGE_RINGTONE, 1).size());
62 EXPECT_EQ(1, router.GetRingRenderDevices(STREAM_USAGE_ALARM, 1).size());
63 }
64 } // namespace AudioStandard
65 } // namespace OHOS
66