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 "session_manager/include/hidump_controller.h"
18 #include "session/host/include/scene_session.h"
19 #include "window_manager_hilog.h"
20 #include "wm_single_instance.h"
21
22 using namespace testing;
23 using namespace testing::ext;
24
25 namespace OHOS {
26 namespace Rosen {
27 class HidumpControllerTest : public testing::Test {
28 public:
29 static void SetUpTestCase();
30 static void TearDownTestCase();
31 void SetUp() override;
32 void TearDown() override;
33
34 sptr<SceneSession> GetSceneSession(std::string name);
35 };
36
SetUpTestCase()37 void HidumpControllerTest::SetUpTestCase()
38 {
39 }
40
TearDownTestCase()41 void HidumpControllerTest::TearDownTestCase()
42 {
43 }
44
SetUp()45 void HidumpControllerTest::SetUp()
46 {
47 }
48
TearDown()49 void HidumpControllerTest::TearDown()
50 {
51 }
52
GetSceneSession(std::string name)53 sptr<SceneSession> HidumpControllerTest::GetSceneSession(std::string name)
54 {
55 SessionInfo info;
56 info.abilityName_ = name;
57 info.bundleName_ = name;
58 auto result = sptr<SceneSession>::MakeSptr(info, nullptr);
59 if (result != nullptr) {
60 result->property_ = sptr<WindowSessionProperty>::MakeSptr();
61 if (result->property_ == nullptr) {
62 return nullptr;
63 }
64 }
65
66 return result;
67 }
68
69 namespace {
70 /**
71 * @tc.name: GetAllSessionDumpDetailedInfo
72 * @tc.desc: GetAllSessionDumpDetailedInfo Test
73 * @tc.type: FUNC
74 */
75 HWTEST_F(HidumpControllerTest, GetAllSessionDumpDetailedInfo01, Function | MediumTest | Level2)
76 {
77 std::vector<sptr<SceneSession>> allSession;
78 std::vector<sptr<SceneSession>> backgroundSession;
79 auto sceneSession = GetSceneSession("GetAllSessionDumpDetailedInfo01");
80 ASSERT_NE(sceneSession, nullptr);
81 backgroundSession.push_back(sceneSession);
82
83 std::ostringstream oss;
84 HidumpController::GetInstance().GetAllSessionDumpDetailedInfo(oss, allSession, backgroundSession);
85 std::string result = oss.str();
86 ASSERT_NE(result.size(), 0);
87 }
88
89 /**
90 * @tc.name: GetAllSessionDumpDetailedInfo
91 * @tc.desc: GetAllSessionDumpDetailedInfo Test
92 * @tc.type: FUNC
93 */
94 HWTEST_F(HidumpControllerTest, GetAllSessionDumpDetailedInfo02, Function | MediumTest | Level2)
95 {
96 std::vector<sptr<SceneSession>> allSession;
97 std::vector<sptr<SceneSession>> backgroundSession;
98 auto sceneSession = GetSceneSession("GetAllSessionDumpDetailedInfo02");
99 ASSERT_NE(sceneSession, nullptr);
100 allSession.push_back(sceneSession);
101
102 std::ostringstream oss;
103 HidumpController::GetInstance().GetAllSessionDumpDetailedInfo(oss, allSession, backgroundSession);
104 std::string result = oss.str();
105 ASSERT_NE(result.size(), 0);
106 }
107
108 /**
109 * @tc.name: DumpSceneSessionParamList
110 * @tc.desc: DumpSceneSessionParamList Test
111 * @tc.type: FUNC
112 */
113 HWTEST_F(HidumpControllerTest, DumpSceneSessionParamList, Function | MediumTest | Level2)
114 {
115 std::ostringstream oss;
116 HidumpController::GetInstance().DumpSceneSessionParamList(oss);
117 std::string result = oss.str();
118 ASSERT_NE(result.size(), 0);
119 }
120
121 /**
122 * @tc.name: DumpSceneSessionParam
123 * @tc.desc: DumpSceneSessionParam Test
124 * @tc.type: FUNC
125 */
126 HWTEST_F(HidumpControllerTest, DumpSceneSessionParam01, Function | MediumTest | Level2)
127 {
128 auto sceneSession = GetSceneSession("DumpSceneSessionParam01");
129 ASSERT_NE(sceneSession, nullptr);
130 std::ostringstream oss;
131 HidumpController::GetInstance().DumpSceneSessionParam(oss, sceneSession);
132
133 std::string result = oss.str();
134 ASSERT_NE(result.size(), 0);
135 }
136
137 /**
138 * @tc.name: DumpSceneSessionParam
139 * @tc.desc: DumpSceneSessionParam Test
140 * @tc.type: FUNC
141 */
142 HWTEST_F(HidumpControllerTest, DumpSceneSessionParam02, Function | MediumTest | Level2)
143 {
144 auto sceneSession = GetSceneSession("DumpSceneSessionParam02");
145 ASSERT_NE(sceneSession, nullptr);
146 std::ostringstream oss;
147 HidumpController::GetInstance().DumpSceneSessionParam(oss, sceneSession);
148
149 std::string result = oss.str();
150 ASSERT_NE(result.size(), 0);
151 }
152
153 /**
154 * @tc.name: DumpSessionParamList
155 * @tc.desc: DumpSessionParamList Test
156 * @tc.type: FUNC
157 */
158 HWTEST_F(HidumpControllerTest, DumpSessionParamList, Function | MediumTest | Level2)
159 {
160 std::ostringstream oss;
161 HidumpController::GetInstance().DumpSessionParamList(oss);
162 std::string result = oss.str();
163 ASSERT_NE(result.size(), 0);
164 }
165
166 /**
167 * @tc.name: DumpSessionParam
168 * @tc.desc: DumpSessionParam Test
169 * @tc.type: FUNC
170 */
171 HWTEST_F(HidumpControllerTest, DumpSessionParam, Function | MediumTest | Level2)
172 {
173 auto sceneSession = GetSceneSession("DumpLayoutRectParam");
174 ASSERT_NE(sceneSession, nullptr);
175
176 std::ostringstream oss;
177 HidumpController::GetInstance().DumpSessionParam(oss, sceneSession, sceneSession->property_);
178 std::string result = oss.str();
179 ASSERT_NE(result.size(), 0);
180 }
181
182 /**
183 * @tc.name: DumpLayoutRectParamList
184 * @tc.desc: DumpLayoutRectParamList Test
185 * @tc.type: FUNC
186 */
187 HWTEST_F(HidumpControllerTest, DumpLayoutRectParamList, Function | MediumTest | Level2)
188 {
189 std::ostringstream oss;
190 HidumpController::GetInstance().DumpLayoutRectParamList(oss);
191 std::string result = oss.str();
192 ASSERT_NE(result.size(), 0);
193 }
194
195 /**
196 * @tc.name: DumpLayoutRectParam
197 * @tc.desc: DumpLayoutRectParam Test
198 * @tc.type: FUNC
199 */
200 HWTEST_F(HidumpControllerTest, DumpLayoutRectParam, Function | MediumTest | Level2)
201 {
202 auto sceneSession = GetSceneSession("DumpLayoutRectParam");
203 ASSERT_NE(sceneSession, nullptr);
204
205 std::ostringstream oss;
206 HidumpController::GetInstance().DumpLayoutRectParam(oss, sceneSession, sceneSession->property_);
207 std::string result = oss.str();
208 ASSERT_NE(result.size(), 0);
209 }
210
211 /**
212 * @tc.name: DumpLayoutParamList
213 * @tc.desc: DumpLayoutParamList Test
214 * @tc.type: FUNC
215 */
216 HWTEST_F(HidumpControllerTest, DumpLayoutParamList, Function | MediumTest | Level2)
217 {
218 std::ostringstream oss;
219 HidumpController::GetInstance().DumpLayoutParamList(oss);
220 std::string result = oss.str();
221 ASSERT_NE(result.size(), 0);
222 }
223
224 /**
225 * @tc.name: DumpLayoutParam
226 * @tc.desc: DumpLayoutParam Test
227 * @tc.type: FUNC
228 */
229 HWTEST_F(HidumpControllerTest, DumpLayoutParam, Function | MediumTest | Level2)
230 {
231 auto sceneSession = GetSceneSession("DumpLayoutParam");
232 ASSERT_NE(sceneSession, nullptr);
233
234 std::ostringstream oss;
235 HidumpController::GetInstance().DumpLayoutParam(oss, sceneSession, sceneSession->property_);
236 std::string result = oss.str();
237 ASSERT_NE(result.size(), 0);
238 }
239
240 /**
241 * @tc.name: DumpAbilityParamList
242 * @tc.desc: DumpAbilityParamList Test
243 * @tc.type: FUNC
244 */
245 HWTEST_F(HidumpControllerTest, DumpAbilityParamList, Function | MediumTest | Level2)
246 {
247 std::ostringstream oss;
248 HidumpController::GetInstance().DumpAbilityParamList(oss);
249 std::string result = oss.str();
250 ASSERT_NE(result.size(), 0);
251 }
252
253 /**
254 * @tc.name: DumpAbilityParam
255 * @tc.desc: DumpAbilityParam Test
256 * @tc.type: FUNC
257 */
258 HWTEST_F(HidumpControllerTest, DumpAbilityParam, Function | MediumTest | Level2)
259 {
260 auto sceneSession = GetSceneSession("DumpLayoutParam");
261 ASSERT_NE(sceneSession, nullptr);
262
263 std::ostringstream oss;
264 HidumpController::GetInstance().DumpAbilityParam(oss, sceneSession, sceneSession->property_);
265 std::string result = oss.str();
266 ASSERT_NE(result.size(), 0);
267 }
268
269 /**
270 * @tc.name: DumpKeyboardParamList
271 * @tc.desc: DumpKeyboardParamList Test
272 * @tc.type: FUNC
273 */
274 HWTEST_F(HidumpControllerTest, DumpKeyboardParamList, Function | MediumTest | Level2)
275 {
276 std::ostringstream oss;
277 HidumpController::GetInstance().DumpKeyboardParamList(oss);
278 std::string result = oss.str();
279 ASSERT_NE(result.size(), 0);
280 }
281
282 /**
283 * @tc.name: DumpKeyboardParam
284 * @tc.desc: DumpKeyboardParam Test
285 * @tc.type: FUNC
286 */
287 HWTEST_F(HidumpControllerTest, DumpKeyboardParam, Function | MediumTest | Level2)
288 {
289 auto sceneSession = GetSceneSession("DumpKeyboardParam");
290 ASSERT_NE(sceneSession, nullptr);
291
292 std::ostringstream oss;
293 HidumpController::GetInstance().DumpKeyboardParam(oss, sceneSession, sceneSession->property_);
294 std::string result = oss.str();
295 ASSERT_NE(result.size(), 0);
296 }
297
298 /**
299 * @tc.name: DumpSysconfigParamList
300 * @tc.desc: DumpSysconfigParamList Test
301 * @tc.type: FUNC
302 */
303 HWTEST_F(HidumpControllerTest, DumpSysconfigParamList, Function | MediumTest | Level2)
304 {
305 std::ostringstream oss;
306 HidumpController::GetInstance().DumpSysconfigParamList(oss);
307 std::string result = oss.str();
308 ASSERT_NE(result.size(), 0);
309 }
310
311 /**
312 * @tc.name: DumpSysconfigParam
313 * @tc.desc: DumpSysconfigParam Test
314 * @tc.type: FUNC
315 */
316 HWTEST_F(HidumpControllerTest, DumpSysconfigParam, Function | MediumTest | Level2)
317 {
318 auto sceneSession = GetSceneSession("DumpSysconfigParam");
319 ASSERT_NE(sceneSession, nullptr);
320
321 std::ostringstream oss;
322 HidumpController::GetInstance().DumpSysconfigParam(oss, sceneSession);
323 std::string result = oss.str();
324 ASSERT_NE(result.size(), 0);
325 }
326
327 /**
328 * @tc.name: DumpLifeParamList
329 * @tc.desc: DumpLifeParamList Test
330 * @tc.type: FUNC
331 */
332 HWTEST_F(HidumpControllerTest, DumpLifeParamList, Function | MediumTest | Level2)
333 {
334 std::ostringstream oss;
335 HidumpController::GetInstance().DumpLifeParamList(oss);
336 std::string result = oss.str();
337 ASSERT_NE(result.size(), 0);
338 }
339
340 /**
341 * @tc.name: DumpLifeParam
342 * @tc.desc: DumpLifeParam Test
343 * @tc.type: FUNC
344 */
345 HWTEST_F(HidumpControllerTest, DumpLifeParam, Function | MediumTest | Level2)
346 {
347 auto sceneSession = GetSceneSession("DumpLifeParam");
348 ASSERT_NE(sceneSession, nullptr);
349
350 std::ostringstream oss;
351 HidumpController::GetInstance().DumpLifeParam(oss, sceneSession);
352 std::string result = oss.str();
353 ASSERT_NE(result.size(), 0);
354 }
355
356 /**
357 * @tc.name: DumpDisplayParamList
358 * @tc.desc: DumpDisplayParamList Test
359 * @tc.type: FUNC
360 */
361 HWTEST_F(HidumpControllerTest, DumpDisplayParamList, Function | MediumTest | Level2)
362 {
363 std::ostringstream oss;
364 HidumpController::GetInstance().DumpDisplayParamList(oss);
365 std::string result = oss.str();
366 ASSERT_NE(result.size(), 0);
367 }
368
369 /**
370 * @tc.name: DumpDisplayParam
371 * @tc.desc: DumpDisplayParam Test
372 * @tc.type: FUNC
373 */
374 HWTEST_F(HidumpControllerTest, DumpDisplayParam, Function | MediumTest | Level2)
375 {
376 auto sceneSession = GetSceneSession("DumpDisplayParam");
377 ASSERT_NE(sceneSession, nullptr);
378
379 std::ostringstream oss;
380 HidumpController::GetInstance().DumpDisplayParam(oss, sceneSession, sceneSession->property_);
381 std::string result = oss.str();
382 ASSERT_NE(result.size(), 0);
383 }
384
385 /**
386 * @tc.name: DumpFocusParamList
387 * @tc.desc: DumpFocusParamList Test
388 * @tc.type: FUNC
389 */
390 HWTEST_F(HidumpControllerTest, DumpFocusParamList, Function | MediumTest | Level2)
391 {
392 std::ostringstream oss;
393 HidumpController::GetInstance().DumpFocusParamList(oss);
394 std::string result = oss.str();
395 ASSERT_NE(result.size(), 0);
396 }
397
398 /**
399 * @tc.name: DumpFocusParam
400 * @tc.desc: DumpFocusParam Test
401 * @tc.type: FUNC
402 */
403 HWTEST_F(HidumpControllerTest, DumpFocusParam, Function | MediumTest | Level2)
404 {
405 auto sceneSession = GetSceneSession("DumpFocusParam");
406 ASSERT_NE(sceneSession, nullptr);
407
408 std::ostringstream oss;
409 HidumpController::GetInstance().DumpFocusParam(oss, sceneSession, sceneSession->property_);
410 std::string result = oss.str();
411 ASSERT_NE(result.size(), 0);
412 }
413
414 /**
415 * @tc.name: DumpInputParamList
416 * @tc.desc: DumpInputParamList Test
417 * @tc.type: FUNC
418 */
419 HWTEST_F(HidumpControllerTest, DumpInputParamList, Function | MediumTest | Level2)
420 {
421 std::ostringstream oss;
422 HidumpController::GetInstance().DumpInputParamList(oss);
423 std::string result = oss.str();
424 ASSERT_NE(result.size(), 0);
425 }
426
427 /**
428 * @tc.name: DumpInputParam
429 * @tc.desc: DumpInputParam Test
430 * @tc.type: FUNC
431 */
432 HWTEST_F(HidumpControllerTest, DumpInputParam, Function | MediumTest | Level2)
433 {
434 auto sceneSession = GetSceneSession("DumpInputParam");
435 ASSERT_NE(sceneSession, nullptr);
436
437 std::ostringstream oss;
438 HidumpController::GetInstance().DumpInputParam(oss, sceneSession, sceneSession->property_);
439 std::string result = oss.str();
440 ASSERT_NE(result.size(), 0);
441 }
442
443 /**
444 * @tc.name: DumpLakeParamList
445 * @tc.desc: DumpLakeParamList Test
446 * @tc.type: FUNC
447 */
448 HWTEST_F(HidumpControllerTest, DumpLakeParamList, Function | MediumTest | Level2)
449 {
450 std::ostringstream oss;
451 HidumpController::GetInstance().DumpLakeParamList(oss);
452 std::string result = oss.str();
453 ASSERT_NE(result.size(), 0);
454 }
455
456 /**
457 * @tc.name: DumpLakeParam
458 * @tc.desc: DumpLakeParam Test
459 * @tc.type: FUNC
460 */
461 HWTEST_F(HidumpControllerTest, DumpLakeParam, Function | MediumTest | Level2)
462 {
463 auto sceneSession = GetSceneSession("DumpLakeParam");
464 ASSERT_NE(sceneSession, nullptr);
465
466 std::ostringstream oss;
467 HidumpController::GetInstance().DumpLakeParam(oss, sceneSession);
468 std::string result = oss.str();
469 ASSERT_NE(result.size(), 0);
470 }
471
472 /**
473 * @tc.name: DumpCOMParamList
474 * @tc.desc: DumpCOMParamList Test
475 * @tc.type: FUNC
476 */
477 HWTEST_F(HidumpControllerTest, DumpCOMParamList, Function | MediumTest | Level2)
478 {
479 std::ostringstream oss;
480 HidumpController::GetInstance().DumpCOMParamList(oss);
481 std::string result = oss.str();
482 ASSERT_NE(result.size(), 0);
483 }
484
485 /**
486 * @tc.name: DumpCOMParam
487 * @tc.desc: DumpCOMParam Test
488 * @tc.type: FUNC
489 */
490 HWTEST_F(HidumpControllerTest, DumpCOMParam, Function | MediumTest | Level2)
491 {
492 auto sceneSession = GetSceneSession("DumpCOMParam");
493 ASSERT_NE(sceneSession, nullptr);
494
495 std::ostringstream oss;
496 HidumpController::GetInstance().DumpCOMParam(oss, sceneSession);
497 std::string result = oss.str();
498 ASSERT_NE(result.size(), 0);
499 }
500
501 /**
502 * @tc.name: DumpVisibleParamList
503 * @tc.desc: DumpVisibleParamList Test
504 * @tc.type: FUNC
505 */
506 HWTEST_F(HidumpControllerTest, DumpVisibleParamList, Function | MediumTest | Level2)
507 {
508 std::ostringstream oss;
509 HidumpController::GetInstance().DumpVisibleParamList(oss);
510 std::string result = oss.str();
511 ASSERT_NE(result.size(), 0);
512 }
513
514 /**
515 * @tc.name: DumpVisibleParam
516 * @tc.desc: DumpVisibleParam Test
517 * @tc.type: FUNC
518 */
519 HWTEST_F(HidumpControllerTest, DumpVisibleParam, Function | MediumTest | Level2)
520 {
521 auto sceneSession = GetSceneSession("DumpVisibleParam");
522 ASSERT_NE(sceneSession, nullptr);
523
524 std::ostringstream oss;
525 HidumpController::GetInstance().DumpVisibleParam(oss, sceneSession);
526 std::string result = oss.str();
527 ASSERT_NE(result.size(), 0);
528 }
529 } // namespace
530 } // namespace Rosen
531 } // namespace OHOS