1 /*
2  * Copyright (c) 2024 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 "avsession_log.h"
18 #include "session_listener_proxy.h"
19 
20 using namespace OHOS::AVSession;
21 
22 class SessionListenerProxyTest : public testing::Test {
23 public:
24     static void SetUpTestCase(void);
25     static void TearDownTestCase(void);
26     void SetUp();
27     void TearDown();
28 
29     std::shared_ptr<SessionListenerProxy> sessionListenerProxy;
30 };
31 
SetUpTestCase()32 void SessionListenerProxyTest::SetUpTestCase()
33 {
34 }
35 
TearDownTestCase()36 void SessionListenerProxyTest::TearDownTestCase()
37 {
38 }
39 
SetUp()40 void SessionListenerProxyTest::SetUp()
41 {
42     OHOS::sptr<IRemoteObject> iRemoteObject;
43     sessionListenerProxy = std::make_shared<SessionListenerProxy>(iRemoteObject);
44 }
45 
TearDown()46 void SessionListenerProxyTest::TearDown()
47 {
48 }
49 
50 /**
51  * @tc.name: OnSessionCreate001
52  * @tc.desc: Test OnSessionCreate
53  * @tc.type: FUNC
54  */
55 static HWTEST_F(SessionListenerProxyTest, OnSessionCreate001, testing::ext::TestSize.Level1)
56 {
57     SLOGI("OnSessionCreate001, start");
58     AVSessionDescriptor descriptor;
59     sessionListenerProxy->OnSessionCreate(descriptor);
60     SLOGI("OnSessionCreate001, end");
61 }
62 
63 /**
64  * @tc.name: OnSessionRelease001
65  * @tc.desc: Test OnSessionRelease
66  * @tc.type: FUNC
67  */
68 static HWTEST_F(SessionListenerProxyTest, OnSessionRelease001, testing::ext::TestSize.Level1)
69 {
70     SLOGI("OnSessionRelease001, start");
71     AVSessionDescriptor descriptor;
72     sessionListenerProxy->OnSessionRelease(descriptor);
73     SLOGI("OnSessionRelease001, end");
74 }
75 
76 /**
77  * @tc.name: OnTopSessionChange001
78  * @tc.desc: Test OnTopSessionChange
79  * @tc.type: FUNC
80  */
81 static HWTEST_F(SessionListenerProxyTest, OnTopSessionChange001, testing::ext::TestSize.Level1)
82 {
83     SLOGI("OnTopSessionChange001, start");
84     AVSessionDescriptor descriptor;
85     sessionListenerProxy->OnTopSessionChange(descriptor);
86     SLOGI("OnTopSessionChange001, end");
87 }
88 
89 /**
90  * @tc.name: OnAudioSessionChecked001
91  * @tc.desc: Test OnAudioSessionChecked
92  * @tc.type: FUNC
93  */
94 static HWTEST_F(SessionListenerProxyTest, OnAudioSessionChecked001, testing::ext::TestSize.Level1)
95 {
96     SLOGI("OnAudioSessionChecked001, start");
97     int32_t uid = 0;
98     sessionListenerProxy->OnAudioSessionChecked(uid);
99     SLOGI("OnAudioSessionChecked001, end");
100 }
101 
102 /**
103  * @tc.name: OnDeviceAvailable001
104  * @tc.desc: Test OnDeviceAvailable
105  * @tc.type: FUNC
106  */
107 static HWTEST_F(SessionListenerProxyTest, OnDeviceAvailable001, testing::ext::TestSize.Level1)
108 {
109     SLOGI("OnDeviceAvailable001, start");
110     OutputDeviceInfo castOutputDeviceInfo;
111     sessionListenerProxy->OnDeviceAvailable(castOutputDeviceInfo);
112     SLOGI("OnDeviceAvailable001, end");
113 }
114 
115 /**
116  * @tc.name: OnDeviceOffline001
117  * @tc.desc: Test OnDeviceOffline
118  * @tc.type: FUNC
119  */
120 static HWTEST_F(SessionListenerProxyTest, OnDeviceOffline001, testing::ext::TestSize.Level1)
121 {
122     SLOGI("OnDeviceOffline001, start");
123     std::string deviceId = "deviceId";
124     sessionListenerProxy->OnDeviceOffline(deviceId);
125     SLOGI("OnDeviceOffline001, end");
126 }
127