• 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 "daudio_radar.h"
17 #include "daudio_errorcode.h"
18 #include "daudio_log.h"
19 #include "gtest/gtest.h"
20 
21 #undef DH_LOG_TAG
22 #define DH_LOG_TAG "DAudioRadarTest"
23 
24 using namespace testing;
25 using namespace testing::ext;
26 
27 namespace OHOS {
28 namespace DistributedHardware {
29 
30 class DaudioRadarTest : public testing::Test {
31 public:
32     static void SetUpTestCase(void);
33     static void TearDownTestCase(void);
34     void SetUp();
35     void TearDown();
36 };
37 
SetUpTestCase(void)38 void DaudioRadarTest::SetUpTestCase(void)
39 {
40     DHLOGI("enter");
41 }
42 
TearDownTestCase(void)43 void DaudioRadarTest::TearDownTestCase(void)
44 {
45     DHLOGI("enter");
46 }
47 
SetUp(void)48 void DaudioRadarTest::SetUp(void)
49 {
50     DHLOGI("enter");
51 }
52 
TearDown(void)53 void DaudioRadarTest::TearDown(void)
54 {
55     DHLOGI("enter");
56 }
57 
58 /**
59  * @tc.name: ReportDaudioInit_001
60  * @tc.desc: check ReportDaudioInit
61  * @tc.type: FUNC
62  */
63 HWTEST_F(DaudioRadarTest, ReportDaudioInit_001, TestSize.Level1)
64 {
65     DHLOGI("DaudioRadarTest ReportDaudioInit_001 begin");
66     bool ret = DaudioRadar::GetInstance().ReportDaudioInit(FUNC, AudioInit::SERVICE_INIT,
67         BizState::BIZ_STATE_START, DH_SUCCESS);
68     EXPECT_EQ(ret, true);
69     DHLOGI("DaudioRadarTest ReportDaudioInit_001 end");
70 }
71 
72 /**
73  * @tc.name: ReportDaudioInit_002
74  * @tc.desc: check ReportDaudioInit
75  * @tc.type: FUNC
76  */
77 HWTEST_F(DaudioRadarTest, ReportDaudioInit_002, TestSize.Level1)
78 {
79     DHLOGI("DaudioRadarTest ReportDaudioInit_002 begin");
80     bool ret = DaudioRadar::GetInstance().ReportDaudioInit(FUNC, AudioInit::SERVICE_INIT,
81         BizState::BIZ_STATE_START, ERR_DH_AUDIO_FAILED);
82     EXPECT_EQ(ret, true);
83     DHLOGI("DaudioRadarTest ReportDaudioInit_002 end");
84 }
85 
86 /**
87  * @tc.name: ReportDaudioInitProgress_001
88  * @tc.desc: check ReportDaudioInitProgress
89  * @tc.type: FUNC
90  */
91 HWTEST_F(DaudioRadarTest, ReportDaudioInitProgress_001, TestSize.Level1)
92 {
93     DHLOGI("DaudioRadarTest ReportDaudioInitProgress_001 begin");
94     bool ret = DaudioRadar::GetInstance().ReportDaudioInitProgress(FUNC, AudioInit::SERVICE_INIT, DH_SUCCESS);
95     EXPECT_EQ(ret, true);
96     DHLOGI("DaudioRadarTest ReportDaudioInitProgress_001 end");
97 }
98 
99 /**
100  * @tc.name: ReportDaudioInitProgress_002
101  * @tc.desc: check ReportDaudioInitProgress
102  * @tc.type: FUNC
103  */
104 HWTEST_F(DaudioRadarTest, ReportDaudioInitProgress_002, TestSize.Level1)
105 {
106     DHLOGI("DaudioRadarTest ReportDaudioInitProgress_002 begin");
107     bool ret = DaudioRadar::GetInstance().ReportDaudioInitProgress(FUNC, AudioInit::SERVICE_INIT,
108         ERR_DH_AUDIO_FAILED);
109     EXPECT_EQ(ret, true);
110     DHLOGI("DaudioRadarTest ReportDaudioInitProgress_002 end");
111 }
112 
113 /**
114  * @tc.name: ReportSpeakerOpen_001
115  * @tc.desc: check ReportSpeakerOpen
116  * @tc.type: FUNC
117  */
118 HWTEST_F(DaudioRadarTest, ReportSpeakerOpen_001, TestSize.Level1)
119 {
120     DHLOGI("DaudioRadarTest ReportSpeakerOpen_001 begin");
121     bool ret = DaudioRadar::GetInstance().ReportSpeakerOpen(FUNC, SpeakerOpen::CREATE_STREAM,
122         BizState::BIZ_STATE_START, DH_SUCCESS);
123     EXPECT_EQ(ret, true);
124     DHLOGI("DaudioRadarTest ReportSpeakerOpen_001 end");
125 }
126 
127 /**
128  * @tc.name: ReportSpeakerOpen_002
129  * @tc.desc: check ReportSpeakerOpen
130  * @tc.type: FUNC
131  */
132 HWTEST_F(DaudioRadarTest, ReportSpeakerOpen_002, TestSize.Level1)
133 {
134     DHLOGI("DaudioRadarTest ReportSpeakerOpen_002 begin");
135     bool ret = DaudioRadar::GetInstance().ReportSpeakerOpen(FUNC, SpeakerOpen::CREATE_STREAM,
136         BizState::BIZ_STATE_START, ERR_DH_AUDIO_FAILED);
137     EXPECT_EQ(ret, true);
138     DHLOGI("DaudioRadarTest ReportSpeakerOpen_002 end");
139 }
140 
141 /**
142  * @tc.name: ReportSpeakerOpenProgress_001
143  * @tc.desc: check ReportSpeakerOpenProgress
144  * @tc.type: FUNC
145  */
146 HWTEST_F(DaudioRadarTest, ReportSpeakerOpenProgress_001, TestSize.Level1)
147 {
148     DHLOGI("DaudioRadarTest ReportSpeakerOpenProgress_001 begin");
149     bool ret = DaudioRadar::GetInstance().ReportSpeakerOpenProgress(FUNC, SpeakerOpen::CREATE_STREAM, DH_SUCCESS);
150     EXPECT_EQ(ret, true);
151     DHLOGI("DaudioRadarTest ReportSpeakerOpenProgress_001 end");
152 }
153 
154 /**
155  * @tc.name: ReportSpeakerOpenProgress_002
156  * @tc.desc: check ReportSpeakerOpenProgress
157  * @tc.type: FUNC
158  */
159 HWTEST_F(DaudioRadarTest, ReportSpeakerOpenProgress_002, TestSize.Level1)
160 {
161     DHLOGI("DaudioRadarTest ReportSpeakerOpenProgress_002 begin");
162     bool ret = DaudioRadar::GetInstance().ReportSpeakerOpenProgress(FUNC, SpeakerOpen::CREATE_STREAM,
163         ERR_DH_AUDIO_FAILED);
164     EXPECT_EQ(ret, true);
165     DHLOGI("DaudioRadarTest ReportSpeakerOpenProgress_002 end");
166 }
167 
168 /**
169  * @tc.name: ReportSpeakerClose_001
170  * @tc.desc: check ReportSpeakerClose
171  * @tc.type: FUNC
172  */
173 HWTEST_F(DaudioRadarTest, ReportSpeakerClose_001, TestSize.Level1)
174 {
175     DHLOGI("DaudioRadarTest ReportSpeakerClose_001 begin");
176     bool ret = DaudioRadar::GetInstance().ReportSpeakerClose(FUNC, SpeakerClose::DESTROY_STREAM,
177         BizState::BIZ_STATE_START, DH_SUCCESS);
178     EXPECT_EQ(ret, true);
179     DHLOGI("DaudioRadarTest ReportSpeakerClose_001 end");
180 }
181 
182 /**
183  * @tc.name: ReportSpeakerClose_002
184  * @tc.desc: check ReportSpeakerClose
185  * @tc.type: FUNC
186  */
187 HWTEST_F(DaudioRadarTest, ReportSpeakerClose_002, TestSize.Level1)
188 {
189     DHLOGI("DaudioRadarTest ReportSpeakerClose_002 begin");
190     bool ret = DaudioRadar::GetInstance().ReportSpeakerClose(FUNC, SpeakerClose::DESTROY_STREAM,
191         BizState::BIZ_STATE_START, ERR_DH_AUDIO_FAILED);
192     EXPECT_EQ(ret, true);
193     DHLOGI("DaudioRadarTest ReportSpeakerClose_002 end");
194 }
195 
196 /**
197  * @tc.name: ReportSpeakerCloseProgress_001
198  * @tc.desc: check ReportSpeakerCloseProgress
199  * @tc.type: FUNC
200  */
201 HWTEST_F(DaudioRadarTest, ReportSpeakerCloseProgress_001, TestSize.Level1)
202 {
203     DHLOGI("DaudioRadarTest ReportSpeakerCloseProgress_001 begin");
204     bool ret = DaudioRadar::GetInstance().ReportSpeakerCloseProgress(FUNC, SpeakerClose::DESTROY_STREAM, DH_SUCCESS);
205     EXPECT_EQ(ret, true);
206     DHLOGI("DaudioRadarTest ReportSpeakerCloseProgress_001 end");
207 }
208 
209 /**
210  * @tc.name: ReportSpeakerCloseProgress_002
211  * @tc.desc: check ReportSpeakerCloseProgress
212  * @tc.type: FUNC
213  */
214 HWTEST_F(DaudioRadarTest, ReportSpeakerCloseProgress_002, TestSize.Level1)
215 {
216     DHLOGI("DaudioRadarTest ReportSpeakerCloseProgress_002 begin");
217     bool ret = DaudioRadar::GetInstance().ReportSpeakerCloseProgress(FUNC, SpeakerClose::DESTROY_STREAM,
218         ERR_DH_AUDIO_FAILED);
219     EXPECT_EQ(ret, true);
220     DHLOGI("DaudioRadarTest ReportSpeakerCloseProgress_002 end");
221 }
222 
223 /**
224  * @tc.name: ReportMicOpen_001
225  * @tc.desc: check ReportMicOpen
226  * @tc.type: FUNC
227  */
228 HWTEST_F(DaudioRadarTest, ReportMicOpen_001, TestSize.Level1)
229 {
230     DHLOGI("DaudioRadarTest ReportMicOpen_001 begin");
231     bool ret = DaudioRadar::GetInstance().ReportMicOpen(FUNC, MicOpen::CREATE_STREAM,
232         BizState::BIZ_STATE_START, DH_SUCCESS);
233     EXPECT_EQ(ret, true);
234     DHLOGI("DaudioRadarTest ReportMicOpen_001 end");
235 }
236 
237 /**
238  * @tc.name: ReportMicOpen_002
239  * @tc.desc: check ReportMicOpen
240  * @tc.type: FUNC
241  */
242 HWTEST_F(DaudioRadarTest, ReportMicOpen_002, TestSize.Level1)
243 {
244     DHLOGI("DaudioRadarTest ReportMicOpen_002 begin");
245     bool ret = DaudioRadar::GetInstance().ReportMicOpen(FUNC, MicOpen::CREATE_STREAM,
246         BizState::BIZ_STATE_START, ERR_DH_AUDIO_FAILED);
247     EXPECT_EQ(ret, true);
248     DHLOGI("DaudioRadarTest ReportMicOpen_002 end");
249 }
250 
251 /**
252  * @tc.name: ReportMicOpenProgress_001
253  * @tc.desc: check ReportMicOpenProgress
254  * @tc.type: FUNC
255  */
256 HWTEST_F(DaudioRadarTest, ReportMicOpenProgress_001, TestSize.Level1)
257 {
258     DHLOGI("DaudioRadarTest ReportMicOpenProgress_001 begin");
259     bool ret = DaudioRadar::GetInstance().ReportMicOpenProgress(FUNC, MicOpen::CREATE_STREAM,
260         DH_SUCCESS);
261     EXPECT_EQ(ret, true);
262     DHLOGI("DaudioRadarTest ReportMicOpenProgress_001 end");
263 }
264 
265 /**
266  * @tc.name: ReportMicOpenProgress_002
267  * @tc.desc: check ReportMicOpenProgress
268  * @tc.type: FUNC
269  */
270 HWTEST_F(DaudioRadarTest, ReportMicOpenProgress_002, TestSize.Level1)
271 {
272     DHLOGI("DaudioRadarTest ReportMicOpenProgress_002 begin");
273     bool ret = DaudioRadar::GetInstance().ReportMicOpenProgress(FUNC, MicOpen::CREATE_STREAM,
274         ERR_DH_AUDIO_FAILED);
275     EXPECT_EQ(ret, true);
276     DHLOGI("DaudioRadarTest ReportMicOpenProgress_002 end");
277 }
278 
279 /**
280  * @tc.name: ReportMicClose_001
281  * @tc.desc: check ReportMicClose
282  * @tc.type: FUNC
283  */
284 HWTEST_F(DaudioRadarTest, ReportMicClose_001, TestSize.Level1)
285 {
286     DHLOGI("DaudioRadarTest ReportMicClose_001 begin");
287     bool ret = DaudioRadar::GetInstance().ReportMicClose(FUNC, MicClose::DESTROY_STREAM,
288         BizState::BIZ_STATE_START, DH_SUCCESS);
289     EXPECT_EQ(ret, true);
290     DHLOGI("DaudioRadarTest ReportMicClose_001 end");
291 }
292 
293 /**
294  * @tc.name: ReportMicClose_002
295  * @tc.desc: check ReportMicClose
296  * @tc.type: FUNC
297  */
298 HWTEST_F(DaudioRadarTest, ReportMicClose_002, TestSize.Level1)
299 {
300     DHLOGI("DaudioRadarTest ReportMicClose_002 begin");
301     bool ret = DaudioRadar::GetInstance().ReportMicClose(FUNC, MicClose::DESTROY_STREAM,
302         BizState::BIZ_STATE_START, ERR_DH_AUDIO_FAILED);
303     EXPECT_EQ(ret, true);
304     DHLOGI("DaudioRadarTest ReportMicClose_002 end");
305 }
306 
307 /**
308  * @tc.name: ReportMicCloseProgress_001
309  * @tc.desc: check ReportMicCloseProgress
310  * @tc.type: FUNC
311  */
312 HWTEST_F(DaudioRadarTest, ReportMicCloseProgress_001, TestSize.Level1)
313 {
314     DHLOGI("DaudioRadarTest ReportMicCloseProgress_001 begin");
315     bool ret = DaudioRadar::GetInstance().ReportMicCloseProgress(FUNC, MicClose::DESTROY_STREAM,
316         DH_SUCCESS);
317     EXPECT_EQ(ret, true);
318     DHLOGI("DaudioRadarTest ReportMicCloseProgress_001 end");
319 }
320 
321 /**
322  * @tc.name: ReportMicCloseProgress_002
323  * @tc.desc: check ReportMicCloseProgress
324  * @tc.type: FUNC
325  */
326 HWTEST_F(DaudioRadarTest, ReportMicCloseProgress_002, TestSize.Level1)
327 {
328     DHLOGI("DaudioRadarTest ReportMicCloseProgress_002 begin");
329     bool ret = DaudioRadar::GetInstance().ReportMicCloseProgress(FUNC, MicClose::DESTROY_STREAM,
330         ERR_DH_AUDIO_FAILED);
331     EXPECT_EQ(ret, true);
332     DHLOGI("DaudioRadarTest ReportMicCloseProgress_002 end");
333 }
334 
335 /**
336  * @tc.name: ReportDaudioUnInit_001
337  * @tc.desc: check ReportDaudioUnInit
338  * @tc.type: FUNC
339  */
340 HWTEST_F(DaudioRadarTest, ReportDaudioUnInit_001, TestSize.Level1)
341 {
342     DHLOGI("DaudioRadarTest ReportDaudioUnInit_001 begin");
343     bool ret = DaudioRadar::GetInstance().ReportDaudioUnInit(FUNC, AudioUnInit::UNREGISTER,
344         BizState::BIZ_STATE_START, DH_SUCCESS);
345     EXPECT_EQ(ret, true);
346     DHLOGI("DaudioRadarTest ReportDaudioUnInit_001 end");
347 }
348 
349 /**
350  * @tc.name: ReportDaudioUnInit_002
351  * @tc.desc: check ReportDaudioUnInit
352  * @tc.type: FUNC
353  */
354 HWTEST_F(DaudioRadarTest, ReportDaudioUnInit_002, TestSize.Level1)
355 {
356     DHLOGI("DaudioRadarTest ReportDaudioUnInit_002 begin");
357     bool ret = DaudioRadar::GetInstance().ReportDaudioUnInit(FUNC, AudioUnInit::UNREGISTER,
358         BizState::BIZ_STATE_START, ERR_DH_AUDIO_FAILED);
359     EXPECT_EQ(ret, true);
360     DHLOGI("DaudioRadarTest ReportDaudioUnInit_002 end");
361 }
362 
363 /**
364  * @tc.name: ReportDaudioUnInitProgress_001
365  * @tc.desc: check ReportDaudioUnInitProgress
366  * @tc.type: FUNC
367  */
368 HWTEST_F(DaudioRadarTest, ReportDaudioUnInitProgress_001, TestSize.Level1)
369 {
370     DHLOGI("DaudioRadarTest ReportDaudioUnInitProgress_001 begin");
371     bool ret = DaudioRadar::GetInstance().ReportDaudioUnInitProgress(FUNC, AudioUnInit::UNREGISTER,
372         DH_SUCCESS);
373     EXPECT_EQ(ret, true);
374     DHLOGI("DaudioRadarTest ReportDaudioUnInitProgress_001 end");
375 }
376 
377 /**
378  * @tc.name: ReportDaudioUnInitProgress_002
379  * @tc.desc: check ReportDaudioUnInitProgress
380  * @tc.type: FUNC
381  */
382 HWTEST_F(DaudioRadarTest, ReportDaudioUnInitProgress_002, TestSize.Level1)
383 {
384     DHLOGI("DaudioRadarTest ReportDaudioUnInitProgress_002 begin");
385     bool ret = DaudioRadar::GetInstance().ReportDaudioUnInitProgress(FUNC, AudioUnInit::UNREGISTER,
386         ERR_DH_AUDIO_FAILED);
387     EXPECT_EQ(ret, true);
388     DHLOGI("DaudioRadarTest ReportDaudioUnInitProgress_002 end");
389 }
390 }
391 }