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