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 <regex>
18 #include <bundle_mgr_interface.h>
19 #include <bundlemgr/launcher_service.h>
20 #include "interfaces/include/ws_common.h"
21 #include "session_manager/include/scene_session_manager.h"
22 #include "session_info.h"
23 #include "session/host/include/scene_session.h"
24 #include "session/host/include/main_session.h"
25 #include "window_manager_agent.h"
26 #include "session_manager.h"
27 #include "zidl/window_manager_agent_interface.h"
28 #include "mock/mock_session_stage.h"
29 #include "mock/mock_window_event_channel.h"
30 #include "context.h"
31
32 using namespace testing;
33 using namespace testing::ext;
34
35 namespace OHOS {
36 namespace Rosen {
37 namespace {
38 const std::string EMPTY_DEVICE_ID = "";
39 constexpr int WAIT_SLEEP_TIME = 1;
40 using ConfigItem = WindowSceneConfig::ConfigItem;
ReadConfig(const std::string & xmlStr)41 ConfigItem ReadConfig(const std::string& xmlStr)
42 {
43 ConfigItem config;
44 xmlDocPtr docPtr = xmlParseMemory(xmlStr.c_str(), xmlStr.length() + 1);
45 if (docPtr == nullptr) {
46 return config;
47 }
48
49 xmlNodePtr rootPtr = xmlDocGetRootElement(docPtr);
50 if (rootPtr == nullptr || rootPtr->name == nullptr ||
51 xmlStrcmp(rootPtr->name, reinterpret_cast<const xmlChar*>("Configs"))) {
52 xmlFreeDoc(docPtr);
53 return config;
54 }
55
56 std::map<std::string, ConfigItem> configMap;
57 config.SetValue(configMap);
58 WindowSceneConfig::ReadConfig(rootPtr, *config.mapValue_);
59 xmlFreeDoc(docPtr);
60 return config;
61 }
62 }
63 class SceneSessionManagerTest2 : public testing::Test {
64 public:
65 static void SetUpTestCase();
66 static void TearDownTestCase();
67 void SetUp() override;
68 void TearDown() override;
69
70 static bool gestureNavigationEnabled_;
71 static ProcessGestureNavigationEnabledChangeFunc callbackFunc_;
72 static sptr<SceneSessionManager> ssm_;
73
74 private:
75 static constexpr uint32_t WAIT_SYNC_IN_NS = 200000;
76 };
77
78 sptr<SceneSessionManager> SceneSessionManagerTest2::ssm_ = nullptr;
79
80 bool SceneSessionManagerTest2::gestureNavigationEnabled_ = true;
81 ProcessGestureNavigationEnabledChangeFunc SceneSessionManagerTest2::callbackFunc_ = [](bool enable,
__anon3ade16ce0202(bool enable, const std::string& bundleName, GestureBackType type) 82 const std::string& bundleName, GestureBackType type) {
83 gestureNavigationEnabled_ = enable;
84 };
85
WindowChangedFuncTest(int32_t persistentId,WindowUpdateType type)86 void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type)
87 {
88 }
89
ProcessStatusBarEnabledChangeFuncTest(bool enable)90 void ProcessStatusBarEnabledChangeFuncTest(bool enable)
91 {
92 }
93
DumpRootSceneElementInfoFuncTest(const std::vector<std::string> & params,std::vector<std::string> & infos)94 void DumpRootSceneElementInfoFuncTest(const std::vector<std::string>& params, std::vector<std::string>& infos)
95 {
96 }
97
SetUpTestCase()98 void SceneSessionManagerTest2::SetUpTestCase()
99 {
100 ssm_ = &SceneSessionManager::GetInstance();
101 }
102
TearDownTestCase()103 void SceneSessionManagerTest2::TearDownTestCase()
104 {
105 ssm_ = nullptr;
106 }
107
SetUp()108 void SceneSessionManagerTest2::SetUp()
109 {
110 }
111
TearDown()112 void SceneSessionManagerTest2::TearDown()
113 {
114 usleep(WAIT_SYNC_IN_NS);
115 }
116
117 namespace {
118 /**
119 * @tc.name: SetGestureNavigaionEnabled
120 * @tc.desc: SceneSessionManager set gesture navigation enabled
121 * @tc.type: FUNC
122 */
123 HWTEST_F(SceneSessionManagerTest2, SetGestureNavigaionEnabled, Function | SmallTest | Level3)
124 {
125 ASSERT_NE(callbackFunc_, nullptr);
126
127 WMError result00 = ssm_->SetGestureNavigaionEnabled(true);
128 ASSERT_EQ(result00, WMError::WM_OK);
129
130 ssm_->SetGestureNavigationEnabledChangeListener(callbackFunc_);
131 WMError result01 = ssm_->SetGestureNavigaionEnabled(true);
132 ASSERT_EQ(result01, WMError::WM_OK);
133 sleep(WAIT_SLEEP_TIME);
134 ASSERT_EQ(gestureNavigationEnabled_, true);
135
136 WMError result02 = ssm_->SetGestureNavigaionEnabled(false);
137 ASSERT_EQ(result02, WMError::WM_OK);
138 sleep(WAIT_SLEEP_TIME);
139 ASSERT_EQ(gestureNavigationEnabled_, false);
140
141 ssm_->SetGestureNavigationEnabledChangeListener(nullptr);
142 WMError result03 = ssm_->SetGestureNavigaionEnabled(true);
143 ASSERT_EQ(result03, WMError::WM_OK);
144 }
145
146 /**
147 * @tc.name: RegisterWindowManagerAgent
148 * @tc.desc: SceneSesionManager rigister window manager agent
149 * @tc.type: FUNC
150 */
151 HWTEST_F(SceneSessionManagerTest2, RegisterWindowManagerAgent, Function | SmallTest | Level3)
152 {
153 sptr<IWindowManagerAgent> windowManagerAgent = new WindowManagerAgent();
154 WindowManagerAgentType type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS;
155
156 ASSERT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, ssm_->RegisterWindowManagerAgent(type, windowManagerAgent));
157 ASSERT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, ssm_->UnregisterWindowManagerAgent(
158 type, windowManagerAgent));
159 }
160
161 /**
162 * @tc.name: ConfigWindowSizeLimits01
163 * @tc.desc: call ConfigWindowSizeLimits and check the systemConfig_.
164 * @tc.type: FUNC
165 */
166 HWTEST_F(SceneSessionManagerTest2, ConfigWindowSizeLimits01, Function | SmallTest | Level3)
167 {
168 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
169 "<Configs>"
170 "<mainWindowSizeLimits>"
171 "<miniWidth>10</miniWidth>"
172 "<miniHeight>20</miniHeight>"
173 "</mainWindowSizeLimits>"
174 "<subWindowSizeLimits>"
175 "<miniWidth>30</miniWidth>"
176 "<miniHeight>40</miniHeight>"
177 "</subWindowSizeLimits>"
178 "</Configs>";
179 WindowSceneConfig::config_ = ReadConfig(xmlStr);
180 ssm_->ConfigWindowSizeLimits();
181 ASSERT_EQ(ssm_->systemConfig_.miniWidthOfMainWindow_, static_cast<uint32_t>(10));
182 ASSERT_EQ(ssm_->systemConfig_.miniHeightOfMainWindow_, static_cast<uint32_t>(20));
183 ASSERT_EQ(ssm_->systemConfig_.miniWidthOfSubWindow_, static_cast<uint32_t>(30));
184 ASSERT_EQ(ssm_->systemConfig_.miniHeightOfSubWindow_, static_cast<uint32_t>(40));
185 }
186
187 /**
188 * @tc.name: ConfigWindowEffect01
189 * @tc.desc: call ConfigWindowEffect all success focused
190 * @tc.type: FUNC
191 */
192 HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect01, Function | SmallTest | Level3)
193 {
194 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
195 "<Configs>"
196 "<windowEffect>"
197 "<appWindows>"
198 "<cornerRadius>"
199 "<fullScreen>off</fullScreen>"
200 "<split>off</split>"
201 "<float>off</float>"
202 "</cornerRadius>"
203 "<shadow>"
204 "<focused>"
205 "<elevation>0</elevation>"
206 "<color>#000000</color>"
207 "<offsetX>1</offsetX>"
208 "<offsetY>1</offsetY>"
209 "<alpha>0</alpha>"
210 "<radius>0.5</radius>"
211 "</focused>"
212 "</shadow>"
213 "</appWindows>"
214 "</windowEffect>"
215 "</Configs>";
216 WindowSceneConfig::config_ = ReadConfig(xmlStr);
217 ssm_->ConfigWindowSceneXml();
218 ASSERT_EQ(ssm_->appWindowSceneConfig_.focusedShadow_.alpha_, 0);
219 ASSERT_EQ(ssm_->appWindowSceneConfig_.focusedShadow_.offsetX_, 1);
220 ASSERT_EQ(ssm_->appWindowSceneConfig_.focusedShadow_.offsetY_, 1);
221 ASSERT_EQ(ssm_->appWindowSceneConfig_.focusedShadow_.radius_, 0.5);
222 }
223
224 /**
225 * @tc.name: ConfigWindowEffect02
226 * @tc.desc: call ConfigWindowEffect
227 * @tc.type: FUNC
228 */
229 HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect02, Function | SmallTest | Level3)
230 {
231 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
232 "<Configs>"
233 "<windowEffect>"
234 "<appWindows>"
235 "<cornerRadius>"
236 "<fullScreen>off</fullScreen>"
237 "<split>off</split>"
238 "</cornerRadius>"
239 "<shadow>"
240 "<focused>"
241 "<elevation>0</elevation>"
242 "<alpha>0</alpha>"
243 "</focused>"
244 "<unfocused>"
245 "<elevation>0</elevation>"
246 "</unfocused>"
247 "</shadow>"
248 "</appWindows>"
249 "</windowEffect>"
250 "</Configs>";
251 WindowSceneConfig::config_ = ReadConfig(xmlStr);
252 ssm_->ConfigWindowSceneXml();
253 ASSERT_EQ(ssm_->appWindowSceneConfig_.focusedShadow_.alpha_, 0);
254 }
255
256 /**
257 * @tc.name: ConfigWindowEffect03
258 * @tc.desc: call ConfigWindowEffect ConfigAppWindowShadow unfocused
259 * @tc.type: FUNC
260 */
261 HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect03, Function | SmallTest | Level3)
262 {
263 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
264 "<Configs>"
265 "<windowEffect>"
266 "<appWindows>"
267 "<shadow>"
268 "<unfocused>"
269 "<elevation>0</elevation>"
270 "<color>#000000</color>"
271 "<offsetX>1</offsetX>"
272 "<offsetY>1</offsetY>"
273 "<alpha>0</alpha>"
274 "<radius>0.5</radius>"
275 "</unfocused>"
276 "</shadow>"
277 "</appWindows>"
278 "</windowEffect>"
279 "</Configs>";
280 WindowSceneConfig::config_ = ReadConfig(xmlStr);
281 ssm_->ConfigWindowSceneXml();
282 ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.alpha_, 0);
283 ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetX_, 1);
284 ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetY_, 1);
285 ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.radius_, 0.5);
286 }
287
288 /**
289 * @tc.name: ConfigWindowEffect04
290 * @tc.desc: call ConfigWindowEffect all
291 * @tc.type: FUNC
292 */
293 HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect04, Function | SmallTest | Level3)
294 {
295 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
296 "<Configs>"
297 "<windowEffect>"
298 "<appWindows>"
299 "<cornerRadius>"
300 "<fullScreen>off</fullScreen>"
301 "<split>off</split>"
302 "<float>off</float>"
303 "</cornerRadius>"
304 "<shadow>"
305 "<focused>"
306 "<elevation>0</elevation>"
307 "<color>#000000</color>"
308 "<offsetX>1</offsetX>"
309 "<offsetY>1</offsetY>"
310 "<alpha>0</alpha>"
311 "<radius>0.5</radius>"
312 "</focused>"
313 "<unfocused>"
314 "<elevation>0</elevation>"
315 "<color>#000000</color>"
316 "<offsetX>1</offsetX>"
317 "<offsetY>1</offsetY>"
318 "<alpha>0</alpha>"
319 "<radius>0.5</radius>"
320 "</unfocused>"
321 "</shadow>"
322 "</appWindows>"
323 "</windowEffect>"
324 "</Configs>";
325 WindowSceneConfig::config_ = ReadConfig(xmlStr);
326 ssm_->ConfigWindowSceneXml();
327 ASSERT_EQ(ssm_->appWindowSceneConfig_.focusedShadow_.alpha_, 0);
328 ASSERT_EQ(ssm_->appWindowSceneConfig_.focusedShadow_.offsetX_, 1);
329 ASSERT_EQ(ssm_->appWindowSceneConfig_.focusedShadow_.offsetY_, 1);
330 ASSERT_EQ(ssm_->appWindowSceneConfig_.focusedShadow_.radius_, 0.5);
331 ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.alpha_, 0);
332 ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetX_, 1);
333 ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetY_, 1);
334 ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.radius_, 0.5);
335 }
336
337 /**
338 * @tc.name: ConfigWindowEffect05
339 * @tc.desc: call ConfigWindowEffect all offsetX.size is not 1
340 * @tc.type: FUNC
341 */
342 HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect05, Function | SmallTest | Level3)
343 {
344 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
345 "<Configs>"
346 "<windowEffect>"
347 "<appWindows>"
348 "<shadow>"
349 "<focused>"
350 "<elevation>0</elevation>"
351 "<offsetX>1</offsetX>"
352 "<offsetX>2</offsetX>"
353 "</focused>"
354 "<unfocused>"
355 "<elevation>0</elevation>"
356 "<color>#000000</color>"
357 "<offsetX>1</offsetX>"
358 "<offsetY>1</offsetY>"
359 "<alpha>0</alpha>"
360 "<radius>0.5</radius>"
361 "</unfocused>"
362 "</shadow>"
363 "</appWindows>"
364 "</windowEffect>"
365 "</Configs>";
366 WindowSceneConfig::config_ = ReadConfig(xmlStr);
367 ssm_->ConfigWindowSceneXml();
368 ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.alpha_, 0);
369 ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetX_, 1);
370 ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetY_, 1);
371 ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.radius_, 0.5);
372 }
373
374 /**
375 * @tc.name: ConfigWindowEffect06
376 * @tc.desc: call ConfigWindowEffect offsetY.size is not 1
377 * @tc.type: FUNC
378 */
379 HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect06, Function | SmallTest | Level3)
380 {
381 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
382 "<Configs>"
383 "<windowEffect>"
384 "<appWindows>"
385 "<shadow>"
386 "<focused>"
387 "<elevation>0</elevation>"
388 "<offsetY>1</offsetY>"
389 "<offsetY>2</offsetY>"
390 "</focused>"
391 "<unfocused>"
392 "<elevation>0</elevation>"
393 "<color>#000000</color>"
394 "<offsetX>1</offsetX>"
395 "<offsetY>1</offsetY>"
396 "<alpha>0</alpha>"
397 "<radius>0.5</radius>"
398 "</unfocused>"
399 "</shadow>"
400 "</appWindows>"
401 "</windowEffect>"
402 "</Configs>";
403 WindowSceneConfig::config_ = ReadConfig(xmlStr);
404 ssm_->ConfigWindowSceneXml();
405 ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.alpha_, 0);
406 ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetX_, 1);
407 ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetY_, 1);
408 ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.radius_, 0.5);
409 }
410
411 /**
412 * @tc.name: ConfigWindowEffect07
413 * @tc.desc: call ConfigWindowEffect alpha.size is not 1
414 * @tc.type: FUNC
415 */
416 HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect07, Function | SmallTest | Level3)
417 {
418 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
419 "<Configs>"
420 "<windowEffect>"
421 "<appWindows>"
422 "<shadow>"
423 "<focused>"
424 "<elevation>0</elevation>"
425 "<alpha>1</alpha>"
426 "<alpha>2</alpha>"
427 "</focused>"
428 "<unfocused>"
429 "<elevation>0</elevation>"
430 "<color>#000000</color>"
431 "<offsetX>1</offsetX>"
432 "<offsetY>1</offsetY>"
433 "<alpha>0</alpha>"
434 "<radius>0.5</radius>"
435 "</unfocused>"
436 "</shadow>"
437 "</appWindows>"
438 "</windowEffect>"
439 "</Configs>";
440 WindowSceneConfig::config_ = ReadConfig(xmlStr);
441 ssm_->ConfigWindowSceneXml();
442 ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.alpha_, 0);
443 ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetX_, 1);
444 ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetY_, 1);
445 ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.radius_, 0.5);
446 }
447
448 /**
449 * @tc.name: ConfigWindowEffect08
450 * @tc.desc: call ConfigWindowEffect radius.size is not 1
451 * @tc.type: FUNC
452 */
453 HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect08, Function | SmallTest | Level3)
454 {
455 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
456 "<Configs>"
457 "<windowEffect>"
458 "<appWindows>"
459 "<shadow>"
460 "<focused>"
461 "<elevation>0</elevation>"
462 "<radius>1</radius>"
463 "<radius>2</radius>"
464 "</focused>"
465 "<unfocused>"
466 "<elevation>0</elevation>"
467 "<color>#000000</color>"
468 "<offsetX>1</offsetX>"
469 "<offsetY>1</offsetY>"
470 "<alpha>0</alpha>"
471 "<radius>0.5</radius>"
472 "</unfocused>"
473 "</shadow>"
474 "</appWindows>"
475 "</windowEffect>"
476 "</Configs>";
477 WindowSceneConfig::config_ = ReadConfig(xmlStr);
478 ssm_->ConfigWindowSceneXml();
479 ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.alpha_, 0);
480 ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetX_, 1);
481 ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetY_, 1);
482 ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.radius_, 0.5);
483 }
484
485 /**
486 * @tc.name: ConfigDecor
487 * @tc.desc: call ConfigDecor fullscreen
488 * @tc.type: FUNC
489 */
490 HWTEST_F(SceneSessionManagerTest2, ConfigDecor01, Function | SmallTest | Level3)
491 {
492 std::string xmlStr1 = "<?xml version='1.0' encoding=\"utf-8\"?>"
493 "<Configs>"
494 "<decor enable=\"111\">"
495 "<supportedMode>fullscreen</supportedMode>"
496 "</decor>"
497 "</Configs>";
498 WindowSceneConfig::config_ = ReadConfig(xmlStr1);
499 ssm_->ConfigWindowSceneXml();
500
501 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
502 "<Configs>"
503 "<decor enable=\"true\">"
504 "<supportedMode>fullscreen</supportedMode>"
505 "</decor>"
506 "</Configs>";
507 WindowSceneConfig::config_ = ReadConfig(xmlStr);
508 ssm_->ConfigWindowSceneXml();
509 ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_,
510 static_cast<uint32_t>(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN));
511 }
512
513 /**
514 * @tc.name: ConfigDecor
515 * @tc.desc: call ConfigDecor
516 * @tc.type: FUNC
517 */
518 HWTEST_F(SceneSessionManagerTest2, ConfigDecor02, Function | SmallTest | Level3)
519 {
520 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
521 "<Configs>"
522 "<decor enable=\"true\">"
523 "</decor>"
524 "</Configs>";
525 WindowSceneConfig::config_ = ReadConfig(xmlStr);
526 ssm_->ConfigWindowSceneXml();
527 ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_,
528 WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN);
529 }
530
531 /**
532 * @tc.name: ConfigDecor
533 * @tc.desc: call ConfigDecor floating
534 * @tc.type: FUNC
535 */
536 HWTEST_F(SceneSessionManagerTest2, ConfigDecor03, Function | SmallTest | Level3)
537 {
538 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
539 "<Configs>"
540 "<decor enable=\"true\">"
541 "<supportedMode>floating</supportedMode>"
542 "</decor>"
543 "</Configs>";
544 WindowSceneConfig::config_ = ReadConfig(xmlStr);
545 ssm_->ConfigWindowSceneXml();
546 ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_,
547 WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING);
548 }
549
550 /**
551 * @tc.name: ConfigDecor
552 * @tc.desc: call ConfigDecor pip
553 * @tc.type: FUNC
554 */
555 HWTEST_F(SceneSessionManagerTest2, ConfigDecor04, Function | SmallTest | Level3)
556 {
557 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
558 "<Configs>"
559 "<decor enable=\"true\">"
560 "<supportedMode>pip</supportedMode>"
561 "</decor>"
562 "</Configs>";
563 WindowSceneConfig::config_ = ReadConfig(xmlStr);
564 ssm_->ConfigWindowSceneXml();
565 ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_,
566 WindowModeSupport::WINDOW_MODE_SUPPORT_PIP);
567 }
568
569 /**
570 * @tc.name: ConfigDecor
571 * @tc.desc: call ConfigDecor split
572 * @tc.type: FUNC
573 */
574 HWTEST_F(SceneSessionManagerTest2, ConfigDecor05, Function | SmallTest | Level3)
575 {
576 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
577 "<Configs>"
578 "<decor enable=\"true\">"
579 "<supportedMode>split</supportedMode>"
580 "</decor>"
581 "</Configs>";
582 WindowSceneConfig::config_ = ReadConfig(xmlStr);
583 ssm_->ConfigWindowSceneXml();
584 ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_,
585 WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY |
586 WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY);
587 }
588
589 /**
590 * @tc.name: ConfigDecor
591 * @tc.desc: call ConfigDecor default
592 * @tc.type: FUNC
593 */
594 HWTEST_F(SceneSessionManagerTest2, ConfigDecor06, Function | SmallTest | Level3)
595 {
596 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
597 "<Configs>"
598 "<decor enable=\"true\">"
599 "<supportedMode>111</supportedMode>"
600 "</decor>"
601 "</Configs>";
602 WindowSceneConfig::config_ = ReadConfig(xmlStr);
603 ssm_->ConfigWindowSceneXml();
604 ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_,
605 WINDOW_MODE_SUPPORT_ALL);
606 }
607
608 /**
609 * @tc.name: ConfigWindowSceneXml01
610 * @tc.desc: call defaultWindowMode
611 * @tc.type: FUNC
612 */
613 HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml01, Function | SmallTest | Level3)
614 {
615 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
616 "<Configs>"
617 "<defaultWindowMode>10</defaultWindowMode>"
618 "</Configs>";
619 WindowSceneConfig::config_ = ReadConfig(xmlStr);
620 ssm_->ConfigWindowSceneXml();
621
622 std::string xmlStr1 = "<?xml version='1.0' encoding=\"utf-8\"?>"
623 "<Configs>"
624 "<defaultWindowMode>102</defaultWindowMode>"
625 "</Configs>";
626 WindowSceneConfig::config_ = ReadConfig(xmlStr1);
627 ssm_->ConfigWindowSceneXml();
628 ASSERT_EQ(ssm_->systemConfig_.defaultWindowMode_,
629 static_cast<WindowMode>(static_cast<uint32_t>(102)));
630 }
631 /**
632 * @tc.name: ConfigWindowSceneXml02
633 * @tc.desc: call defaultWindowMode
634 * @tc.type: FUNC
635 */
636 HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml02, Function | SmallTest | Level3)
637 {
638 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
639 "<Configs>"
640 "<defaultWindowMode>1 1</defaultWindowMode>"
641 "<uiType>phone</uiType>"
642 "<backgroundScreenLock enable=\"true\"></backgroundScreenLock>"
643 "<rotationMode>windowRotation</rotationMode>"
644 "<supportTypeFloatWindow enable=\"true\"></supportTypeFloatWindow>"
645 "</Configs>";
646 WindowSceneConfig::config_ = ReadConfig(xmlStr);
647 ssm_->ConfigWindowSceneXml();
648
649 std::string xmlStr1 = "<?xml version='1.0' encoding=\"utf-8\"?>"
650 "<Configs>"
651 "<defaultWindowMode>1</defaultWindowMode>"
652 "</Configs>";
653 WindowSceneConfig::config_ = ReadConfig(xmlStr1);
654 ssm_->ConfigWindowSceneXml();
655 ASSERT_EQ(ssm_->systemConfig_.defaultWindowMode_,
656 static_cast<WindowMode>(static_cast<uint32_t>(1)));
657 }
658
659 /**
660 * @tc.name: ConfigWindowSceneXml03
661 * @tc.desc: call defaultMaximizeMode
662 * @tc.type: FUNC
663 */
664 HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml03, Function | SmallTest | Level3)
665 {
666 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
667 "<Configs>"
668 "<defaultMaximizeMode>1 1</defaultMaximizeMode>"
669 "</Configs>";
670 WindowSceneConfig::config_ = ReadConfig(xmlStr);
671 ssm_->ConfigWindowSceneXml();
672
673 std::string xmlStr1 = "<?xml version='1.0' encoding=\"utf-8\"?>"
674 "<Configs>"
675 "<defaultMaximizeMode>1</defaultMaximizeMode>"
676 "</Configs>";
677 WindowSceneConfig::config_ = ReadConfig(xmlStr1);
678 ssm_->ConfigWindowSceneXml();
679 ASSERT_EQ(SceneSession::maximizeMode_,
680 static_cast<MaximizeMode>(static_cast<uint32_t>(1)));
681 }
682
683 /**
684 * @tc.name: ConfigWindowSceneXml04
685 * @tc.desc: call defaultMaximizeMode
686 * @tc.type: FUNC
687 */
688 HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml04, Function | SmallTest | Level3)
689 {
690 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
691 "<Configs>"
692 "<defaultMaximizeMode>111</defaultMaximizeMode>"
693 "</Configs>";
694 WindowSceneConfig::config_ = ReadConfig(xmlStr);
695 ssm_->ConfigWindowSceneXml();
696
697 std::string xmlStr1 = "<?xml version='1.0' encoding=\"utf-8\"?>"
698 "<Configs>"
699 "<defaultMaximizeMode>0</defaultMaximizeMode>"
700 "</Configs>";
701 WindowSceneConfig::config_ = ReadConfig(xmlStr1);
702 ssm_->ConfigWindowSceneXml();
703 ASSERT_EQ(SceneSession::maximizeMode_,
704 static_cast<MaximizeMode>(static_cast<uint32_t>(0)));
705 }
706
707 /**
708 * @tc.name: ConfigWindowSceneXml05
709 * @tc.desc: call maxFloatingWindowSize
710 * @tc.type: FUNC
711 */
712 HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml05, Function | SmallTest | Level3)
713 {
714 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
715 "<Configs>"
716 "<maxFloatingWindowSize>1</maxFloatingWindowSize>"
717 "</Configs>";
718 WindowSceneConfig::config_ = ReadConfig(xmlStr);
719 ssm_->ConfigWindowSceneXml();
720
721 std::string xmlStr1 = "<?xml version='1.0' encoding=\"utf-8\"?>"
722 "<Configs>"
723 "<maxFloatingWindowSize>1</maxFloatingWindowSize>"
724 "</Configs>";
725 WindowSceneConfig::config_ = ReadConfig(xmlStr1);
726 ssm_->ConfigWindowSceneXml();
727 ASSERT_EQ(ssm_->systemConfig_.maxFloatingWindowSize_,
728 static_cast<uint32_t>(1));
729 }
730
731 /**
732 * @tc.name: ConfigWindowSceneXml06
733 * @tc.desc: call uiType
734 * @tc.type: FUNC
735 */
736 HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml06, Function | SmallTest | Level3)
737 {
738 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
739 "<Configs>"
740 "<uiType>ut</uiType>"
741 "</Configs>";
742 WindowSceneConfig::config_ = ReadConfig(xmlStr);
743 ssm_->ConfigWindowSceneXml();
744 ASSERT_EQ(ssm_->appWindowSceneConfig_.uiType_, "ut");
745 }
746
747 /**
748 * @tc.name: ConfigWindowSceneXml07
749 * @tc.desc: call backgroundScreenLock
750 * @tc.type: FUNC
751 */
752 HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml07, Function | SmallTest | Level3)
753 {
754 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
755 "<Configs>"
756 "<backgroundScreenLock enable=\"true\"></backgroundScreenLock>"
757 "</Configs>";
758 WindowSceneConfig::config_ = ReadConfig(xmlStr);
759 ssm_->ConfigWindowSceneXml();
760 ASSERT_EQ(ssm_->appWindowSceneConfig_.backgroundScreenLock_, true);
761 }
762
763 /**
764 * @tc.name: ConfigWindowSceneXml08
765 * @tc.desc: call rotationMode
766 * @tc.type: FUNC
767 */
768 HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml08, Function | SmallTest | Level3)
769 {
770 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
771 "<Configs>"
772 "<rotationMode>rotation</rotationMode>"
773 "</Configs>";
774 WindowSceneConfig::config_ = ReadConfig(xmlStr);
775 ssm_->ConfigWindowSceneXml();
776 ASSERT_EQ(ssm_->appWindowSceneConfig_.rotationMode_, "rotation");
777 }
778
779 /**
780 * @tc.name: ConfigKeyboardAnimation01
781 * @tc.desc: call ConfigKeyboardAnimation default
782 * @tc.type: FUNC
783 */
784 HWTEST_F(SceneSessionManagerTest2, ConfigKeyboardAnimation01, Function | SmallTest | Level3)
785 {
786 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
787 "<Configs>"
788 "<keyboardAnimation>"
789 "<animationIn>"
790 "<timing>"
791 "<duration>abv</duration>"
792 "<curve name=\"cubic\">0.2 0.0 0.2 1.0</curve>"
793 "</timing>"
794 "</animationIn>"
795 "<animationOut>"
796 "<timing>"
797 "<duration>abv</duration>"
798 "<curve name=\"cubic\">0.2 0.0 0.2 1.0</curve>"
799 "</timing>"
800 "</animationOut>"
801 "</keyboardAnimation>"
802 "</Configs>";
803 WindowSceneConfig::config_ = ReadConfig(xmlStr);
804 ssm_->ConfigWindowSceneXml();
805
806 std::string xmlStr1 = "<?xml version='1.0' encoding=\"utf-8\"?>"
807 "<Configs>"
808 "<keyboardAnimation>"
809 "<animationIn>"
810 "<timing>"
811 "<duration>500</duration>"
812 "<curve name=\"cubic\">0.2 0.0 0.2 1.0</curve>"
813 "</timing>"
814 "</animationIn>"
815 "<animationOut>"
816 "<timing>"
817 "<duration>300</duration>"
818 "<curve name=\"cubic\">0.2 0.0 0.2 1.0</curve>"
819 "</timing>"
820 "</animationOut>"
821 "</keyboardAnimation>"
822 "</Configs>";
823 WindowSceneConfig::config_ = ReadConfig(xmlStr1);
824 ssm_->ConfigWindowSceneXml();
825 ASSERT_EQ(ssm_->systemConfig_.animationIn_.duration_, static_cast<uint32_t>(500));
826 ASSERT_EQ(ssm_->systemConfig_.animationOut_.duration_, static_cast<uint32_t>(300));
827 }
828
829 /**
830 * @tc.name: ConfigKeyboardAnimation02
831 * @tc.desc: call ConfigKeyboardAnimation default
832 * @tc.type: FUNC
833 */
834 HWTEST_F(SceneSessionManagerTest2, ConfigKeyboardAnimation02, Function | SmallTest | Level3)
835 {
836 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
837 "<Configs>"
838 "<keyboardAnimation>"
839 "<animationIn>"
840 "<timing>"
841 "<duration>500</duration>"
842 "<duration>600</duration>"
843 "</timing>"
844 "</animationIn>"
845 "<animationOut>"
846 "<timing>"
847 "<duration>300</duration>"
848 "</timing>"
849 "</animationOut>"
850 "</keyboardAnimation>"
851 "</Configs>";
852 WindowSceneConfig::config_ = ReadConfig(xmlStr);
853 ssm_->ConfigWindowSceneXml();
854 ASSERT_EQ(ssm_->systemConfig_.animationOut_.duration_, static_cast<uint32_t>(300));
855 }
856
857 /**
858 * @tc.name: ConfigKeyboardAnimation03
859 * @tc.desc: call ConfigKeyboardAnimation default
860 * @tc.type: FUNC
861 */
862 HWTEST_F(SceneSessionManagerTest2, ConfigKeyboardAnimation03, Function | SmallTest | Level3)
863 {
864 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
865 "<Configs>"
866 "<keyboardAnimation>"
867 "<animationIn>"
868 "<timing>"
869 "<duration>500</duration>"
870 "</timing>"
871 "</animationIn>"
872 "<animationOut>"
873 "<timing>"
874 "<duration>300</duration>"
875 "<duration>400</duration>"
876 "</timing>"
877 "</animationOut>"
878 "</keyboardAnimation>"
879 "</Configs>";
880 WindowSceneConfig::config_ = ReadConfig(xmlStr);
881 ssm_->ConfigWindowSceneXml();
882 ASSERT_EQ(ssm_->systemConfig_.animationIn_.duration_, static_cast<uint32_t>(500));
883 }
884
885 /**
886 * @tc.name: ConfigKeyboardAnimation04
887 * @tc.desc: call ConfigKeyboardAnimation default
888 * @tc.type: FUNC
889 */
890 HWTEST_F(SceneSessionManagerTest2, ConfigKeyboardAnimation04, Function | SmallTest | Level3)
891 {
892 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
893 "<Configs>"
894 "<keyboardAnimation>"
895 "<animationIn>"
896 "<timing>"
897 "<duration>500</duration>"
898 "</timing>"
899 "</animationIn>"
900 "</keyboardAnimation>"
901 "</Configs>";
902 WindowSceneConfig::config_ = ReadConfig(xmlStr);
903 ssm_->ConfigWindowSceneXml();
904 ASSERT_EQ(ssm_->systemConfig_.animationIn_.duration_, static_cast<uint32_t>(500));
905 }
906
907 /**
908 * @tc.name: ConfigWindowAnimation01
909 * @tc.desc: call ConfigWindowAnimation default
910 * @tc.type: FUNC
911 */
912 HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation01, Function | SmallTest | Level3)
913 {
914 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
915 "<Configs>"
916 "<windowAnimation>"
917 "<timing>"
918 "<duration>350</duration>"
919 "<curve name=\"easeOut\"></curve>"
920 "</timing>"
921 "<scale>0.7 0.7</scale>"
922 "<rotation>0 0 1 0</rotation>"
923 "<translate>0 0</translate>"
924 "<opacity>0</opacity>"
925 "</windowAnimation>"
926 "</Configs>";
927 WindowSceneConfig::config_ = ReadConfig(xmlStr);
928 ssm_->ConfigWindowSceneXml();
929 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.duration_, 350);
930 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.scaleX_, static_cast<float>(0.7));
931 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.scaleY_, static_cast<float>(0.7));
932 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.rotationX_, 0);
933 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.rotationY_, 0);
934 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.rotationZ_, 1);
935 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.angle_, 0);
936 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.translateX_, 0);
937 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.translateY_, 0);
938 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.opacity_, 0);
939 }
940
941 /**
942 * @tc.name: ConfigWindowAnimation02
943 * @tc.desc: call ConfigWindowAnimation no change
944 * @tc.type: FUNC
945 */
946 HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation02, Function | SmallTest | Level3)
947 {
948 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
949 "<Configs>"
950 "<windowAnimation>"
951 "<timing>"
952 "<duration>350</duration>"
953 "<curve name=\"easeOut\"></curve>"
954 "</timing>"
955 "</windowAnimation>"
956 "</Configs>";
957 WindowSceneConfig::config_ = ReadConfig(xmlStr);
958 ssm_->ConfigWindowSceneXml();
959 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.duration_, 350);
960 }
961
962 /**
963 * @tc.name: ConfigWindowAnimation03
964 * @tc.desc: call ConfigWindowAnimation no timing
965 * @tc.type: FUNC
966 */
967 HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation03, Function | SmallTest | Level3)
968 {
969 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
970 "<Configs>"
971 "<windowAnimation>"
972 "<timing>"
973 "</timing>"
974 "<scale>0.7 0.7</scale>"
975 "<rotation>0 0 1 0</rotation>"
976 "<translate>0 0</translate>"
977 "<opacity>0</opacity>"
978 "</windowAnimation>"
979 "</Configs>";
980 WindowSceneConfig::config_ = ReadConfig(xmlStr);
981 ssm_->ConfigWindowSceneXml();
982 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.scaleX_, static_cast<float>(0.7));
983 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.scaleY_, static_cast<float>(0.7));
984 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.rotationX_, 0);
985 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.rotationY_, 0);
986 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.rotationZ_, 1);
987 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.angle_, 0);
988 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.translateX_, 0);
989 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.translateY_, 0);
990 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.opacity_, 0);
991 }
992
993 /**
994 * @tc.name: ConfigWindowAnimation04
995 * @tc.desc: call ConfigWindowAnimation default timing is not int
996 * @tc.type: FUNC
997 */
998 HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation04, Function | SmallTest | Level3)
999 {
1000 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
1001 "<Configs>"
1002 "<windowAnimation>"
1003 "<timing>"
1004 "<duration>aaa</duration>"
1005 "<curve></curve>"
1006 "</timing>"
1007 "<scale>0.7 0.7</scale>"
1008 "<rotation>0 0 1 0</rotation>"
1009 "<translate>0 0</translate>"
1010 "<opacity>0</opacity>"
1011 "</windowAnimation>"
1012 "</Configs>";
1013 WindowSceneConfig::config_ = ReadConfig(xmlStr);
1014 ssm_->ConfigWindowSceneXml();
1015 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.scaleX_, static_cast<float>(0.7));
1016 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.scaleY_, static_cast<float>(0.7));
1017 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.rotationX_, 0);
1018 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.rotationY_, 0);
1019 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.rotationZ_, 1);
1020 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.angle_, 0);
1021 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.translateX_, 0);
1022 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.translateY_, 0);
1023 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.opacity_, 0);
1024 }
1025
1026 /**
1027 * @tc.name: ConfigWindowAnimation05
1028 * @tc.desc: call ConfigWindowAnimation default timing is error size
1029 * @tc.type: FUNC
1030 */
1031 HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation05, Function | SmallTest | Level3)
1032 {
1033 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
1034 "<Configs>"
1035 "<windowAnimation>"
1036 "<timing>"
1037 "<duration>350 350</duration>"
1038 "<curve></curve>"
1039 "</timing>"
1040 "<scale>0.7 0.7</scale>"
1041 "<rotation>0 0 1 0</rotation>"
1042 "<translate>0 0</translate>"
1043 "<opacity>0</opacity>"
1044 "</windowAnimation>"
1045 "</Configs>";
1046 WindowSceneConfig::config_ = ReadConfig(xmlStr);
1047 ssm_->ConfigWindowSceneXml();
1048 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.scaleX_, static_cast<float>(0.7));
1049 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.scaleY_, static_cast<float>(0.7));
1050 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.rotationX_, 0);
1051 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.rotationY_, 0);
1052 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.rotationZ_, 1);
1053 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.angle_, 0);
1054 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.translateX_, 0);
1055 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.translateY_, 0);
1056 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.opacity_, 0);
1057 }
1058
1059 /**
1060 * @tc.name: ConfigWindowAnimation06
1061 * @tc.desc: call ConfigWindowAnimation default change is not int
1062 * @tc.type: FUNC
1063 */
1064 HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation06, Function | SmallTest | Level3)
1065 {
1066 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
1067 "<Configs>"
1068 "<windowAnimation>"
1069 "<timing>"
1070 "<duration>350</duration>"
1071 "<curve name=\"easeOut\"></curve>"
1072 "</timing>"
1073 "<scale>a a</scale>"
1074 "<rotation>a a a a</rotation>"
1075 "<translate>a a</translate>"
1076 "<opacity>a</opacity>"
1077 "</windowAnimation>"
1078 "</Configs>";
1079 WindowSceneConfig::config_ = ReadConfig(xmlStr);
1080 ssm_->ConfigWindowSceneXml();
1081 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.duration_, 350);
1082 }
1083
1084 /**
1085 * @tc.name: ConfigWindowAnimation07
1086 * @tc.desc: call ConfigWindowAnimation default change error size
1087 * @tc.type: FUNC
1088 */
1089 HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation07, Function | SmallTest | Level3)
1090 {
1091 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
1092 "<Configs>"
1093 "<windowAnimation>"
1094 "<timing>"
1095 "<duration>350</duration>"
1096 "<curve name=\"easeOut\"></curve>"
1097 "</timing>"
1098 "<scale>0.7 0.7 0.7</scale>"
1099 "<rotation>0 0 1 0 1</rotation>"
1100 "<translate>0 0 1</translate>"
1101 "<opacity>0 1</opacity>"
1102 "</windowAnimation>"
1103 "</Configs>";
1104 WindowSceneConfig::config_ = ReadConfig(xmlStr);
1105 ssm_->ConfigWindowSceneXml();
1106 ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.duration_, 350);
1107 }
1108
1109 /**
1110 * @tc.name: ConfigStartingWindowAnimation01
1111 * @tc.desc: call ConfigStartingWindowAnimation default
1112 * @tc.type: FUNC
1113 */
1114 HWTEST_F(SceneSessionManagerTest2, ConfigStartingWindowAnimation01, Function | SmallTest | Level3)
1115 {
1116 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
1117 "<Configs>"
1118 "<startWindowTransitionAnimation enable=\"false\">"
1119 "<timing>"
1120 "<duration>200</duration>"
1121 "<curve name=\"linear\"></curve>"
1122 "</timing>"
1123 "<opacityStart>1</opacityStart>"
1124 "<opacityEnd>0</opacityEnd>"
1125 "</startWindowTransitionAnimation>"
1126 "</Configs>";
1127 WindowSceneConfig::config_ = ReadConfig(xmlStr);
1128 ssm_->ConfigWindowSceneXml();
1129 ASSERT_EQ(ssm_->appWindowSceneConfig_.startingWindowAnimationConfig_.enabled_, false);
1130 ASSERT_EQ(ssm_->appWindowSceneConfig_.startingWindowAnimationConfig_.duration_, 200);
1131 ASSERT_EQ(ssm_->appWindowSceneConfig_.startingWindowAnimationConfig_.opacityStart_, 1);
1132 ASSERT_EQ(ssm_->appWindowSceneConfig_.startingWindowAnimationConfig_.opacityEnd_, 0);
1133 }
1134
1135 /**
1136 * @tc.name: ConfigStartingWindowAnimation02
1137 * @tc.desc: call ConfigStartingWindowAnimation default
1138 * @tc.type: FUNC
1139 */
1140 HWTEST_F(SceneSessionManagerTest2, ConfigStartingWindowAnimation02, Function | SmallTest | Level3)
1141 {
1142 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
1143 "<Configs>"
1144 "<startWindowTransitionAnimation enable=\"aaa\">"
1145 "<timing>"
1146 "<duration>200</duration>"
1147 "<curve name=\"linear\"></curve>"
1148 "</timing>"
1149 "<opacityStart>1</opacityStart>"
1150 "<opacityEnd>0</opacityEnd>"
1151 "</startWindowTransitionAnimation>"
1152 "</Configs>";
1153 WindowSceneConfig::config_ = ReadConfig(xmlStr);
1154 ssm_->ConfigWindowSceneXml();
1155 ASSERT_EQ(ssm_->appWindowSceneConfig_.startingWindowAnimationConfig_.duration_, 200);
1156 ASSERT_EQ(ssm_->appWindowSceneConfig_.startingWindowAnimationConfig_.opacityStart_, 1);
1157 ASSERT_EQ(ssm_->appWindowSceneConfig_.startingWindowAnimationConfig_.opacityEnd_, 0);
1158 }
1159
1160 /**
1161 * @tc.name: ConfigStartingWindowAnimation03
1162 * @tc.desc: call ConfigStartingWindowAnimation default
1163 * @tc.type: FUNC
1164 */
1165 HWTEST_F(SceneSessionManagerTest2, ConfigStartingWindowAnimation03, Function | SmallTest | Level3)
1166 {
1167 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
1168 "<Configs>"
1169 "<startWindowTransitionAnimation enable=\"false\">"
1170 "<timing>"
1171 "<duration>aaa</duration>"
1172 "<curve name=\"linear\"></curve>"
1173 "</timing>"
1174 "<opacityStart>aaa</opacityStart>"
1175 "<opacityEnd>aaa</opacityEnd>"
1176 "</startWindowTransitionAnimation>"
1177 "</Configs>";
1178 WindowSceneConfig::config_ = ReadConfig(xmlStr);
1179 ssm_->ConfigWindowSceneXml();
1180 ASSERT_EQ(ssm_->appWindowSceneConfig_.startingWindowAnimationConfig_.enabled_, false);
1181 }
1182
1183 /**
1184 * @tc.name: ConfigStartingWindowAnimation04
1185 * @tc.desc: call ConfigStartingWindowAnimation default
1186 * @tc.type: FUNC
1187 */
1188 HWTEST_F(SceneSessionManagerTest2, ConfigStartingWindowAnimation04, Function | SmallTest | Level3)
1189 {
1190 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
1191 "<Configs>"
1192 "<startWindowTransitionAnimation enable=\"false\">"
1193 "<timing>"
1194 "<duration>200 200</duration>"
1195 "<curve name=\"linear\"></curve>"
1196 "</timing>"
1197 "<opacityStart>1 1</opacityStart>"
1198 "<opacityEnd>0 1</opacityEnd>"
1199 "</startWindowTransitionAnimation>"
1200 "</Configs>";
1201 WindowSceneConfig::config_ = ReadConfig(xmlStr);
1202 ssm_->ConfigWindowSceneXml();
1203 ASSERT_EQ(ssm_->appWindowSceneConfig_.startingWindowAnimationConfig_.enabled_, false);
1204 }
1205
1206 /**
1207 * @tc.name: ConfigStartingWindowAnimation05
1208 * @tc.desc: call ConfigStartingWindowAnimation default
1209 * @tc.type: FUNC
1210 */
1211 HWTEST_F(SceneSessionManagerTest2, ConfigStartingWindowAnimation05, Function | SmallTest | Level3)
1212 {
1213 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
1214 "<Configs>"
1215 "<startWindowTransitionAnimation enable=\"false\">"
1216 "<timing>"
1217 "<duration>aaa aaa</duration>"
1218 "<curve name=\"linear\"></curve>"
1219 "</timing>"
1220 "<opacityStart>a a</opacityStart>"
1221 "<opacityEnd>a a</opacityEnd>"
1222 "</startWindowTransitionAnimation>"
1223 "</Configs>";
1224 WindowSceneConfig::config_ = ReadConfig(xmlStr);
1225 ssm_->ConfigWindowSceneXml();
1226 ASSERT_EQ(ssm_->appWindowSceneConfig_.startingWindowAnimationConfig_.enabled_, false);
1227 }
1228
1229 /**
1230 * @tc.name: ConfigSnapshotScale01
1231 * @tc.desc: call ConfigSnapshotScale and check the snapshotScale_.
1232 * @tc.type: FUNC
1233 */
1234 HWTEST_F(SceneSessionManagerTest2, ConfigSnapshotScale01, Function | SmallTest | Level3)
1235 {
1236 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
1237 "<Configs>"
1238 "<snapshotScale>0.7</snapshotScale>"
1239 "</Configs>";
1240 WindowSceneConfig::config_ = ReadConfig(xmlStr);
1241 ssm_->ConfigSnapshotScale();
1242 ASSERT_EQ(ssm_->snapshotScale_, static_cast<float>(0.7));
1243 }
1244
1245 /**
1246 * @tc.name: ConfigSnapshotScale02
1247 * @tc.desc: call ConfigSnapshotScale and check the snapshotScale_.
1248 * @tc.type: FUNC
1249 */
1250 HWTEST_F(SceneSessionManagerTest2, ConfigSnapshotScale02, Function | SmallTest | Level3)
1251 {
1252 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
1253 "<Configs>"
1254 "<snapshotScale>0.7 0.7</snapshotScale>"
1255 "</Configs>";
1256 WindowSceneConfig::config_ = ReadConfig(xmlStr);
1257 ssm_->ConfigSnapshotScale();
1258 ASSERT_EQ(ssm_->snapshotScale_, 0.7f);
1259 }
1260
1261 /**
1262 * @tc.name: ConfigSnapshotScale03
1263 * @tc.desc: call ConfigSnapshotScale and check the snapshotScale_.
1264 * @tc.type: FUNC
1265 */
1266 HWTEST_F(SceneSessionManagerTest2, ConfigSnapshotScale03, Function | SmallTest | Level3)
1267 {
1268 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
1269 "<Configs>"
1270 "<snapshotScale>aaa</snapshotScale>"
1271 "</Configs>";
1272 WindowSceneConfig::config_ = ReadConfig(xmlStr);
1273 ssm_->ConfigSnapshotScale();
1274 ASSERT_EQ(ssm_->snapshotScale_, 0.7f);
1275 }
1276
1277 /**
1278 * @tc.name: ConfigSnapshotScale04
1279 * @tc.desc: call ConfigSnapshotScale and check the snapshotScale_.
1280 * @tc.type: FUNC
1281 */
1282 HWTEST_F(SceneSessionManagerTest2, ConfigSnapshotScale04, Function | SmallTest | Level3)
1283 {
1284 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
1285 "<Configs>"
1286 "<snapshotScale>-0.1</snapshotScale>"
1287 "</Configs>";
1288 WindowSceneConfig::config_ = ReadConfig(xmlStr);
1289 ssm_->ConfigSnapshotScale();
1290 ASSERT_EQ(ssm_->snapshotScale_, 0.7f);
1291 }
1292
1293 /**
1294 * @tc.name: ConfigSnapshotScale05
1295 * @tc.desc: call ConfigSnapshotScale and check the snapshotScale_.
1296 * @tc.type: FUNC
1297 */
1298 HWTEST_F(SceneSessionManagerTest2, ConfigSnapshotScale05, Function | SmallTest | Level3)
1299 {
1300 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
1301 "<Configs>"
1302 "<snapshotScale>1.5</snapshotScale>"
1303 "</Configs>";
1304 WindowSceneConfig::config_ = ReadConfig(xmlStr);
1305 ssm_->ConfigSnapshotScale();
1306 ASSERT_EQ(ssm_->snapshotScale_, 0.7f);
1307 }
1308
1309 /**
1310 * @tc.name: ConfigSystemUIStatusBar01
1311 * @tc.desc: call ConfigSystemUIStatusBar default.
1312 * @tc.type: FUNC
1313 */
1314 HWTEST_F(SceneSessionManagerTest2, ConfigSystemUIStatusBar01, Function | SmallTest | Level3)
1315 {
1316 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
1317 "<Configs>"
1318 "<systemUIStatusBar>"
1319 "<showInLandscapeMode>1</showInLandscapeMode>"
1320 "<immersiveStatusBarBgColor>#4c000000</immersiveStatusBarBgColor>"
1321 "<immersiveStatusBarContentColor>#ffffee</immersiveStatusBarContentColor>"
1322 "</systemUIStatusBar>"
1323 "</Configs>";
1324 WindowSceneConfig::config_ = ReadConfig(xmlStr);
1325 SceneSessionManager* sceneSessionManager = new SceneSessionManager();
1326 sceneSessionManager->ConfigWindowSceneXml();
1327 ASSERT_EQ(sceneSessionManager->appWindowSceneConfig_.systemUIStatusBarConfig_.showInLandscapeMode_, 1);
1328 ASSERT_STREQ(sceneSessionManager->appWindowSceneConfig_.systemUIStatusBarConfig_.immersiveStatusBarBgColor_.c_str(),
1329 "#4c000000");
1330 ASSERT_STREQ(sceneSessionManager->appWindowSceneConfig_.systemUIStatusBarConfig_.
1331 immersiveStatusBarContentColor_.c_str(), "#ffffee");
1332 delete sceneSessionManager;
1333 }
1334
1335 /**
1336 * @tc.name: DumpSessionAll
1337 * @tc.desc: ScreenSesionManager dump all session info
1338 * @tc.type: FUNC
1339 */
1340 HWTEST_F(SceneSessionManagerTest2, DumpSessionAll, Function | SmallTest | Level3)
1341 {
1342 SessionInfo sessionInfo;
1343 sessionInfo.bundleName_ = "SceneSessionManagerTest2";
1344 sessionInfo.abilityName_ = "DumpSessionAll";
1345 sptr<WindowSessionProperty> windowSessionProperty = new WindowSessionProperty();
1346 sptr<SceneSession> sceneSession = ssm_->RequestSceneSession(sessionInfo, windowSessionProperty);
1347 ASSERT_EQ(nullptr, sceneSession);
1348 std::vector<std::string> infos;
1349 WSError result = ssm_->DumpSessionAll(infos);
1350 ASSERT_EQ(WSError::WS_OK, result);
1351 ASSERT_FALSE(infos.empty());
1352 }
1353
1354 /**
1355 * @tc.name: DumpSessionWithId
1356 * @tc.desc: ScreenSesionManager dump session with id
1357 * @tc.type: FUNC
1358 */
1359 HWTEST_F(SceneSessionManagerTest2, DumpSessionWithId, Function | SmallTest | Level3)
1360 {
1361 SessionInfo sessionInfo;
1362 sessionInfo.bundleName_ = "SceneSessionManagerTest2";
1363 sessionInfo.abilityName_ = "DumpSessionWithId";
1364 sptr<WindowSessionProperty> windowSessionProperty = new WindowSessionProperty();
1365 sptr<SceneSession> sceneSession = ssm_->RequestSceneSession(sessionInfo, windowSessionProperty);
1366 ASSERT_EQ(nullptr, sceneSession);
1367 std::vector<std::string> infos;
1368 WSError result = ssm_->DumpSessionWithId(windowSessionProperty->GetPersistentId(), infos);
1369 ASSERT_EQ(WSError::WS_OK, result);
1370 ASSERT_FALSE(infos.empty());
1371 }
1372
1373 /**
1374 * @tc.name: Init
1375 * @tc.desc: SceneSesionManager init
1376 * @tc.type: FUNC
1377 */
1378 HWTEST_F(SceneSessionManagerTest2, Init, Function | SmallTest | Level3)
1379 {
1380 int ret = 0;
1381 ssm_->Init();
1382 ssm_->RegisterAppListener();
1383 ASSERT_EQ(ret, 0);
1384 }
1385
1386 /**
1387 * @tc.name: LoadWindowSceneXml
1388 * @tc.desc: SceneSesionManager load window scene xml
1389 * @tc.type: FUNC
1390 */
1391 HWTEST_F(SceneSessionManagerTest2, LoadWindowSceneXml, Function | SmallTest | Level3)
1392 {
1393 int ret = 0;
1394 ssm_->LoadWindowSceneXml();
1395 ssm_->ConfigWindowSceneXml();
1396 ssm_->SetEnableInputEvent(true);
1397 ssm_->SetEnableInputEvent(false);
1398 ASSERT_EQ(ssm_->IsInputEventEnabled(), false);
1399 ASSERT_EQ(ret, 0);
1400 }
1401
1402 /**
1403 * @tc.name: UpdateRecoveredSessionInfo
1404 * @tc.desc: SceneSessionManager load window scene xml
1405 * @tc.type: FUNC
1406 */
1407 HWTEST_F(SceneSessionManagerTest2, UpdateRecoveredSessionInfo, Function | SmallTest | Level3)
1408 {
1409 int ret = 0;
1410 std::vector<int32_t> recoveredPersistentIds;
1411 ssm_->UpdateRecoveredSessionInfo(recoveredPersistentIds);
1412 recoveredPersistentIds.push_back(0);
1413 ssm_->UpdateRecoveredSessionInfo(recoveredPersistentIds);
1414 SessionInfo info;
1415 info.abilityName_ = "test1";
1416 info.bundleName_ = "test2";
1417 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1418 if (sceneSession == nullptr) {
1419 return;
1420 }
1421 ssm_->sceneSessionMap_.insert({0, sceneSession});
1422 ssm_->UpdateRecoveredSessionInfo(recoveredPersistentIds);
1423 ssm_->sceneSessionMap_.erase(0);
1424 ASSERT_EQ(ret, 0);
1425 }
1426
1427 /**
1428 * @tc.name: ConfigWindowSceneXml
1429 * @tc.desc: SceneSesionManager config window scene xml run
1430 * @tc.type: FUNC
1431 */
1432 HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml, Function | SmallTest | Level3)
1433 {
1434 int ret = 0;
1435 ssm_->ConfigWindowSceneXml();
1436 ASSERT_EQ(ret, 0);
1437 }
1438
1439 /**
1440 * @tc.name: SetSessionContinueState
1441 * @tc.desc: SceneSesionManager set session continue state
1442 * @tc.type: FUNC
1443 */
1444 HWTEST_F(SceneSessionManagerTest2, SetSessionContinueState, Function | SmallTest | Level3)
1445 {
1446 MessageParcel *data = new MessageParcel();
1447 sptr <IRemoteObject> token = data->ReadRemoteObject();
1448 auto continueState = static_cast<ContinueState>(data->ReadInt32());
1449 WSError result02 = ssm_->SetSessionContinueState(nullptr, continueState);
1450 WSError result01 = ssm_->SetSessionContinueState(token, continueState);
1451 ASSERT_EQ(result02, WSError::WS_ERROR_INVALID_PARAM);
1452 ASSERT_EQ(result01, WSError::WS_ERROR_INVALID_PARAM);
1453 delete data;
1454 }
1455
1456 /**
1457 * @tc.name: SetSessionContinueState002
1458 * @tc.desc: SceneSesionManager set session continue state
1459 * @tc.type: FUNC
1460 */
1461 HWTEST_F(SceneSessionManagerTest2, SetSessionContinueState002, Function | SmallTest | Level3)
1462 {
1463 MessageParcel *data = new MessageParcel();
1464 sptr<IRemoteObject> token = data->ReadRemoteObject();
1465 auto continueState = static_cast<ContinueState>(0);
1466 SessionInfo info;
1467 info.abilityName_ = "test1";
1468 info.bundleName_ = "test2";
1469 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1470 if (sceneSession == nullptr) {
1471 delete data;
1472 return;
1473 }
1474 ssm_->sceneSessionMap_.insert({1000, sceneSession});
1475 ssm_->SetSessionContinueState(token, continueState);
1476 ASSERT_NE(sceneSession, nullptr);
1477 delete data;
1478 }
1479
1480 /**
1481 * @tc.name: StartWindowInfoReportLoop
1482 * @tc.desc: Test if pip window can be created;
1483 * @tc.type: FUNC
1484 */
1485 HWTEST_F(SceneSessionManagerTest2, StartWindowInfoReportLoop, Function | SmallTest | Level3)
1486 {
1487 ASSERT_NE(nullptr, ssm_);
1488 ssm_->StartWindowInfoReportLoop();
1489 ssm_->eventHandler_ = nullptr;
1490 ssm_->StartWindowInfoReportLoop();
1491 ssm_->isReportTaskStart_ = true;
1492 ssm_->StartWindowInfoReportLoop();
1493 }
1494
1495 /**
1496 * @tc.name: GetFocusWindowInfo
1497 * @tc.desc: Test if pip window can be created;
1498 * @tc.type: FUNC
1499 */
1500 HWTEST_F(SceneSessionManagerTest2, GetFocusWindowInfo, Function | SmallTest | Level3)
1501 {
1502 ASSERT_NE(nullptr, ssm_);
1503 FocusChangeInfo info;
1504 ssm_->GetFocusWindowInfo(info);
1505 }
1506
1507 /**
1508 * @tc.name: GetFocusWindowInfo
1509 * @tc.desc: Test if pip window can be created;
1510 * @tc.type: FUNC
1511 */
1512 HWTEST_F(SceneSessionManagerTest2, GetFocusWindowInfo2, Function | SmallTest | Level3)
1513 {
1514 ASSERT_NE(nullptr, ssm_);
1515 FocusChangeInfo fcinfo;
1516 ssm_->GetFocusWindowInfo(fcinfo);
1517
1518 SessionInfo info;
1519 info.abilityName_ = "BackgroundTask02";
1520 info.bundleName_ = "BackgroundTask02";
1521 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1522 ssm_->sceneSessionMap_.insert({0, sceneSession});
1523 ssm_->GetFocusWindowInfo(fcinfo);
1524 }
1525
1526 /**
1527 * @tc.name: SetSessionLabel
1528 * @tc.desc: Test if pip window can be created;
1529 * @tc.type: FUNC
1530 */
1531 HWTEST_F(SceneSessionManagerTest2, SetSessionLabel, Function | SmallTest | Level3)
1532 {
1533 ASSERT_NE(nullptr, ssm_);
1534 ssm_->SetSessionLabel(nullptr, "test");
1535
1536 SessionInfo info;
1537 info.abilityName_ = "BackgroundTask02";
1538 info.bundleName_ = "BackgroundTask02";
1539 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1540 ssm_->sceneSessionMap_.insert({100, sceneSession});
1541 ssm_->SetSessionLabel(nullptr, "test");
1542 }
1543
1544 /**
1545 * @tc.name: SetSessionIcon
1546 * @tc.desc: Test if pip window can be created;
1547 * @tc.type: FUNC
1548 */
1549 HWTEST_F(SceneSessionManagerTest2, SetSessionIcon, Function | SmallTest | Level3)
1550 {
1551 ASSERT_NE(nullptr, ssm_);
1552 ssm_->SetSessionIcon(nullptr, nullptr);
1553
1554 SessionInfo info;
1555 info.abilityName_ = "BackgroundTask02";
1556 info.bundleName_ = "BackgroundTask02";
1557 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1558 ssm_->sceneSessionMap_.insert({100, sceneSession});
1559 ssm_->SetSessionIcon(nullptr, nullptr);
1560 }
1561
1562 /**
1563 * @tc.name: InitWithRenderServiceAdded
1564 * @tc.desc: Test if pip window can be created;
1565 * @tc.type: FUNC
1566 */
1567 HWTEST_F(SceneSessionManagerTest2, InitWithRenderServiceAdded, Function | SmallTest | Level3)
1568 {
1569 ASSERT_NE(nullptr, ssm_);
1570 ssm_->InitWithRenderServiceAdded();
1571 }
1572
1573 /**
1574 * @tc.name: PendingSessionToForeground
1575 * @tc.desc: Test if pip window can be created;
1576 * @tc.type: FUNC
1577 */
1578 HWTEST_F(SceneSessionManagerTest2, PendingSessionToForeground, Function | SmallTest | Level3)
1579 {
1580 ASSERT_NE(nullptr, ssm_);
1581 ssm_->PendingSessionToForeground(nullptr);
1582
1583 SessionInfo info;
1584 info.abilityName_ = "BackgroundTask02";
1585 info.bundleName_ = "BackgroundTask02";
1586 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1587 ssm_->sceneSessionMap_.insert({100, sceneSession});
1588 ssm_->PendingSessionToForeground(nullptr);
1589 }
1590
1591 /**
1592 * @tc.name: GetFocusSessionElement
1593 * @tc.desc: Test if pip window can be created;
1594 * @tc.type: FUNC
1595 */
1596 HWTEST_F(SceneSessionManagerTest2, GetFocusSessionElement, Function | SmallTest | Level3)
1597 {
1598 ASSERT_NE(nullptr, ssm_);
1599 AppExecFwk::ElementName element;
1600 ssm_->GetFocusSessionElement(element);
1601
1602 SessionInfo info;
1603 info.abilityName_ = "BackgroundTask02";
1604 info.bundleName_ = "BackgroundTask02";
1605 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1606 ssm_->sceneSessionMap_.insert({100, sceneSession});
1607 ssm_->GetFocusSessionElement(element);
1608 }
1609
1610 /**
1611 * @tc.name: GetAllAbilityInfos
1612 * @tc.desc: Test if pip window can be created;
1613 * @tc.type: FUNC
1614 */
1615 HWTEST_F(SceneSessionManagerTest2, GetAllAbilityInfos, Function | SmallTest | Level3)
1616 {
1617 WSError ret;
1618 AAFwk::Want want;
1619 AppExecFwk::ElementName elementName = want.GetElement();
1620 int32_t userId = 1;
1621 std::vector<SCBAbilityInfo> scbAbilityInfos;
1622
1623 ret = ssm_->GetAllAbilityInfos(want, userId, scbAbilityInfos);
1624 ASSERT_EQ(WSError::WS_ERROR_INVALID_PARAM, ret);
1625
1626 elementName.bundleName_ = "test";
1627 ret = ssm_->GetAllAbilityInfos(want, userId, scbAbilityInfos);
1628 ASSERT_EQ(WSError::WS_ERROR_INVALID_PARAM, ret);
1629
1630 elementName.abilityName_ = "test";
1631 ret = ssm_->GetAllAbilityInfos(want, userId, scbAbilityInfos);
1632 ASSERT_EQ(WSError::WS_ERROR_INVALID_PARAM, ret);
1633
1634 elementName.bundleName_ = "";
1635 ret = ssm_->GetAllAbilityInfos(want, userId, scbAbilityInfos);
1636 ASSERT_EQ(WSError::WS_ERROR_INVALID_PARAM, ret);
1637
1638 ssm_->bundleMgr_ = nullptr;
1639 ret = ssm_->GetAllAbilityInfos(want, userId, scbAbilityInfos);
1640 ASSERT_EQ(WSError::WS_ERROR_NULLPTR, ret);
1641 }
1642
1643 /**
1644 * @tc.name: GetIsLayoutFullScreen
1645 * @tc.desc: Test if pip window can be created;
1646 * @tc.type: FUNC
1647 */
1648 HWTEST_F(SceneSessionManagerTest2, GetIsLayoutFullScreen, Function | SmallTest | Level3)
1649 {
1650 WSError ret;
1651 bool isLayoutFullScreen = true;
1652 ret = ssm_->GetIsLayoutFullScreen(isLayoutFullScreen);
1653 ASSERT_EQ(WSError::WS_OK, ret);
1654
1655 isLayoutFullScreen = false;
1656 ret = ssm_->GetIsLayoutFullScreen(isLayoutFullScreen);
1657 ASSERT_EQ(WSError::WS_OK, ret);
1658
1659 SessionInfo info;
1660 info.abilityName_ = "BackgroundTask02";
1661 info.bundleName_ = "BackgroundTask02";
1662 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1663 ssm_->sceneSessionMap_.insert({100, sceneSession});
1664 isLayoutFullScreen = true;
1665 ret = ssm_->GetIsLayoutFullScreen(isLayoutFullScreen);
1666 ASSERT_EQ(WSError::WS_OK, ret);
1667
1668 isLayoutFullScreen = false;
1669 ret = ssm_->GetIsLayoutFullScreen(isLayoutFullScreen);
1670 ASSERT_EQ(WSError::WS_OK, ret);
1671 }
1672
1673 /**
1674 * @tc.name: UpdateSessionAvoidAreaListener
1675 * @tc.desc: Test if pip window can be created;
1676 * @tc.type: FUNC
1677 */
1678 HWTEST_F(SceneSessionManagerTest2, UpdateSessionAvoidAreaListener, Function | SmallTest | Level3)
1679 {
1680 ASSERT_NE(nullptr, ssm_);
1681 {
1682 std::unique_lock<std::shared_mutex> lock(ssm_->sceneSessionMapMutex_);
1683 ssm_->sceneSessionMap_.clear();
1684 }
1685 int32_t persistentId = 100;
1686 ssm_->UpdateSessionAvoidAreaListener(persistentId, true);
1687
1688 SessionInfo info;
1689 info.abilityName_ = "BackgroundTask02";
1690 info.bundleName_ = "BackgroundTask02";
1691 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1692 ssm_->sceneSessionMap_.insert({100, sceneSession});
1693 ssm_->UpdateSessionAvoidAreaListener(persistentId, true);
1694 ssm_->UpdateSessionAvoidAreaListener(persistentId, false);
1695 }
1696
1697 /**
1698 * @tc.name: UpdateSessionTouchOutsideListener
1699 * @tc.desc: Test if pip window can be created;
1700 * @tc.type: FUNC
1701 */
1702 HWTEST_F(SceneSessionManagerTest2, UpdateSessionTouchOutsideListener, Function | SmallTest | Level3)
1703 {
1704 ASSERT_NE(nullptr, ssm_);
1705 {
1706 std::unique_lock<std::shared_mutex> lock(ssm_->sceneSessionMapMutex_);
1707 ssm_->sceneSessionMap_.clear();
1708 }
1709 int32_t persistentId = 100;
1710 ssm_->UpdateSessionTouchOutsideListener(persistentId, true);
1711
1712 SessionInfo info;
1713 info.abilityName_ = "BackgroundTask02";
1714 info.bundleName_ = "BackgroundTask02";
1715 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1716 ssm_->sceneSessionMap_.insert({100, sceneSession});
1717 ssm_->UpdateSessionTouchOutsideListener(persistentId, true);
1718
1719 ssm_->UpdateSessionTouchOutsideListener(persistentId, false);
1720 }
1721
1722 /**
1723 * @tc.name: GetSessionSnapshotById
1724 * @tc.desc: Test if pip window can be created;
1725 * @tc.type: FUNC
1726 */
1727 HWTEST_F(SceneSessionManagerTest2, GetSessionSnapshotById, Function | SmallTest | Level3)
1728 {
1729 ASSERT_NE(nullptr, ssm_);
1730 SessionSnapshot snapshot;
1731 ssm_->GetSessionSnapshotById(100, snapshot);
1732 }
1733
1734 /**
1735 * @tc.name: ClearSession
1736 * @tc.desc: Test if pip window can be created;
1737 * @tc.type: FUNC
1738 */
1739 HWTEST_F(SceneSessionManagerTest2, ClearSession, Function | SmallTest | Level3)
1740 {
1741 WSError ret;
1742 ret = ssm_->ClearSession(100);
1743 ASSERT_EQ(WSError::WS_ERROR_INVALID_PERMISSION, ret);
1744 }
1745
1746 /**
1747 * @tc.name: ClearAllSessions
1748 * @tc.desc: Test if pip window can be created;
1749 * @tc.type: FUNC
1750 */
1751 HWTEST_F(SceneSessionManagerTest2, ClearAllSessions, Function | SmallTest | Level3)
1752 {
1753 WSError ret;
1754 ret = ssm_->ClearAllSessions();
1755 ASSERT_EQ(WSError::WS_ERROR_INVALID_PERMISSION, ret);
1756 }
1757
1758 /**
1759 * @tc.name: GetTopWindowId
1760 * @tc.desc: Test if pip window can be created;
1761 * @tc.type: FUNC
1762 */
1763 HWTEST_F(SceneSessionManagerTest2, GetTopWindowId, Function | SmallTest | Level3)
1764 {
1765 WMError ret;
1766 {
1767 std::unique_lock<std::shared_mutex> lock(ssm_->sceneSessionMapMutex_);
1768 ssm_->sceneSessionMap_.clear();
1769 }
1770 uint32_t persistentId = 100;
1771 uint32_t topWinId = 200;
1772 ret = ssm_->GetTopWindowId(persistentId, topWinId);
1773 ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, ret);
1774
1775 SessionInfo info;
1776 info.abilityName_ = "BackgroundTask02";
1777 info.bundleName_ = "BackgroundTask02";
1778 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1779 ssm_->sceneSessionMap_.insert({100, sceneSession});
1780 ret = ssm_->GetTopWindowId(persistentId, topWinId);
1781 ASSERT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, ret);
1782 }
1783
1784 /**
1785 * @tc.name: InitPersistentStorage
1786 * @tc.desc: Test if pip window can be created;
1787 * @tc.type: FUNC
1788 */
1789 HWTEST_F(SceneSessionManagerTest2, InitPersistentStorage, Function | SmallTest | Level3)
1790 {
1791 ASSERT_NE(nullptr, ssm_);
1792 {
1793 std::unique_lock<std::shared_mutex> lock(ssm_->sceneSessionMapMutex_);
1794 ssm_->sceneSessionMap_.clear();
1795 }
1796 ssm_->InitPersistentStorage();
1797 }
1798
1799 /**
1800 * @tc.name: GetSessionSnapshotFilePath
1801 * @tc.desc: Test if pip window can be created;
1802 * @tc.type: FUNC
1803 */
1804 HWTEST_F(SceneSessionManagerTest2, GetSessionSnapshotFilePath, Function | SmallTest | Level3)
1805 {
1806 string ret;
1807 {
1808 std::unique_lock<std::shared_mutex> lock(ssm_->sceneSessionMapMutex_);
1809 ssm_->sceneSessionMap_.clear();
1810 }
1811 ret = ssm_->GetSessionSnapshotFilePath(100);
1812 ASSERT_EQ("", ret);
1813
1814 SessionInfo info;
1815 info.abilityName_ = "BackgroundTask02";
1816 info.bundleName_ = "BackgroundTask02";
1817 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1818 ssm_->sceneSessionMap_.insert({100, sceneSession});
1819 ret = ssm_->GetSessionSnapshotFilePath(100);
1820 ASSERT_EQ("", ret);
1821 }
1822
1823 /**
1824 * @tc.name: GetAccessibilityWindowInfo
1825 * @tc.desc: Test if pip window can be created;
1826 * @tc.type: FUNC
1827 */
1828 HWTEST_F(SceneSessionManagerTest2, GetAccessibilityWindowInfo, Function | SmallTest | Level3)
1829 {
1830 WMError ret;
1831 {
1832 std::unique_lock<std::shared_mutex> lock(ssm_->sceneSessionMapMutex_);
1833 ssm_->sceneSessionMap_.clear();
1834 }
1835 std::vector<sptr<AccessibilityWindowInfo>> infos;
1836 ret = ssm_->GetAccessibilityWindowInfo(infos);
1837 ASSERT_EQ(WMError::WM_OK, ret);
1838
1839 SessionInfo info;
1840 info.abilityName_ = "BackgroundTask02";
1841 info.bundleName_ = "BackgroundTask02";
1842 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1843 ssm_->sceneSessionMap_.insert({100, sceneSession});
1844 ret = ssm_->GetAccessibilityWindowInfo(infos);
1845 ASSERT_EQ(WMError::WM_OK, ret);
1846 }
1847
1848 /**
1849 * @tc.name: OnScreenshot
1850 * @tc.desc: Test if pip window can be created;
1851 * @tc.type: FUNC
1852 */
1853 HWTEST_F(SceneSessionManagerTest2, OnScreenshot, Function | SmallTest | Level3)
1854 {
1855 ASSERT_NE(nullptr, ssm_);
1856 {
1857 std::unique_lock<std::shared_mutex> lock(ssm_->sceneSessionMapMutex_);
1858 ssm_->sceneSessionMap_.clear();
1859 }
1860 DisplayId displayId = 0;
1861 ssm_->OnScreenshot(displayId);
1862
1863 SessionInfo info;
1864 info.abilityName_ = "BackgroundTask02";
1865 info.bundleName_ = "BackgroundTask02";
1866 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1867 ssm_->sceneSessionMap_.insert({100, sceneSession});
1868 ssm_->OnScreenshot(displayId);
1869
1870 sceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
1871 ssm_->OnScreenshot(displayId);
1872 sceneSession->SetSessionState(SessionState::STATE_ACTIVE);
1873 ssm_->OnScreenshot(displayId);
1874 sceneSession->SetSessionState(SessionState::STATE_DISCONNECT);
1875 ssm_->OnScreenshot(displayId);
1876 sceneSession->SetSessionState(SessionState::STATE_END);
1877 ssm_->OnScreenshot(displayId);
1878 }
1879
1880 /**
1881 * @tc.name: ProcessSubSessionForeground
1882 * @tc.desc: Test if pip window can be created;
1883 * @tc.type: FUNC
1884 */
1885 HWTEST_F(SceneSessionManagerTest2, ProcessSubSessionForeground, Function | SmallTest | Level3)
1886 {
1887 {
1888 std::unique_lock<std::shared_mutex> lock(ssm_->sceneSessionMapMutex_);
1889 ssm_->sceneSessionMap_.clear();
1890 }
1891 sptr<SceneSession> sceneSession = nullptr;
1892 ssm_->ProcessSubSessionForeground(sceneSession);
1893
1894 SessionInfo info;
1895 info.abilityName_ = "BackgroundTask02";
1896 info.bundleName_ = "BackgroundTask02";
1897 sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1898 ASSERT_NE(nullptr, sceneSession);
1899 ssm_->ProcessSubSessionForeground(sceneSession);
1900
1901 sptr<SceneSession> sub1 = nullptr;
1902 sptr<SceneSession> sub2 = new (std::nothrow) SceneSession(info, nullptr);
1903 std::vector<sptr<SceneSession>> subs;
1904 std::vector<sptr<SceneSession>> dialogs;
1905 subs.push_back(sub1);
1906 subs.push_back(sub2);
1907 dialogs.push_back(sub1);
1908 dialogs.push_back(sub2);
1909 sceneSession->subSession_ = subs;
1910 ssm_->ProcessSubSessionForeground(sceneSession);
1911 sptr<SceneSession> sub3 = new (std::nothrow) SceneSession(info, nullptr);
1912 sub3->state_ = SessionState::STATE_FOREGROUND;
1913 subs.push_back(sub3);
1914 dialogs.push_back(sub3);
1915 sceneSession->subSession_ = subs;
1916 ssm_->ProcessSubSessionForeground(sceneSession);
1917 sptr<SceneSession> sub4 = new (std::nothrow) SceneSession(info, nullptr);
1918 sub4->state_ = SessionState::STATE_FOREGROUND;
1919 sub4->persistentId_ = 100;
1920 subs.push_back(sub4);
1921 dialogs.push_back(sub4);
1922 sceneSession->subSession_ = subs;
1923 ssm_->ProcessSubSessionForeground(sceneSession);
1924
1925 ssm_->sceneSessionMap_.insert({0, sceneSession});
1926 ssm_->sceneSessionMap_.insert({100, sceneSession});
1927 ssm_->ProcessSubSessionForeground(sceneSession);
1928 ssm_->needBlockNotifyFocusStatusUntilForeground_ = true;
1929 ssm_->ProcessSubSessionForeground(sceneSession);
1930 ASSERT_NE(nullptr, ssm_);
1931 }
1932
1933 /**
1934 * @tc.name: ConfigSystemUIStatusBar
1935 * @tc.desc: call ConfigSystemUIStatusBar default.
1936 * @tc.type: FUNC
1937 */
1938 HWTEST_F(SceneSessionManagerTest2, ConfigSystemUIStatusBar02, Function | SmallTest | Level3)
1939 {
1940 std::string xmlStr = "<?xml version='1.0' encoding=\"utf-8\"?>"
1941 "<Configs>"
1942 "<systemUIStatusBar>"
1943 "</systemUIStatusBar>"
1944 "</Configs>";
1945 WindowSceneConfig::config_ = ReadConfig(xmlStr);
1946 SceneSessionManager* sceneSessionManager = new SceneSessionManager();
1947 ASSERT_NE(sceneSessionManager, nullptr);
1948 sceneSessionManager->ConfigWindowSceneXml();
1949 delete sceneSessionManager;
1950 }
1951
1952 /**
1953 * @tc.name: CreateAndConnectSpecificSession
1954 * @tc.desc: CreateAndConnectSpecificSession
1955 * @tc.type: FUNC
1956 */
1957 HWTEST_F(SceneSessionManagerTest2, CreateAndConnectSpecificSession02, Function | SmallTest | Level3)
1958 {
1959 sptr<ISessionStage> sessionStage;
1960 sptr<IWindowEventChannel> eventChannel;
1961 std::shared_ptr<RSSurfaceNode> node = nullptr;
1962 sptr<WindowSessionProperty> property;
1963 sptr<ISession> session;
1964 SystemSessionConfig systemConfig;
1965 sptr<IRemoteObject> token;
1966 int32_t id = 0;
1967 ASSERT_NE(ssm_, nullptr);
1968 ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session,
1969 systemConfig, token);
1970 property = new (std::nothrow) WindowSessionProperty();
1971 ASSERT_NE(property, nullptr);
1972 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1973 ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session,
1974 systemConfig, token);
1975 }
1976
1977 /**
1978 * @tc.name: ClosePipWindowIfExist
1979 * @tc.desc: ClosePipWindowIfExist
1980 * @tc.type: FUNC
1981 */
1982 HWTEST_F(SceneSessionManagerTest2, ClosePipWindowIfExist, Function | SmallTest | Level3)
1983 {
1984 sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
1985 ASSERT_NE(property, nullptr);
1986 ssm_->ClosePipWindowIfExist(WindowType::WINDOW_TYPE_PIP);
1987
1988 SessionInfo info;
1989 info.sessionState_ = {1};
1990 Rect reqRect = { 0, 0, 10, 10 };
1991 property->SetRequestRect(reqRect);
1992 property->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
1993 ASSERT_EQ(false, ssm_->isEnablePiPCreate(property));
1994 }
1995
1996 /**
1997 * @tc.name: RecoverAndConnectSpecificSession
1998 * @tc.desc: RecoverAndConnectSpecificSession
1999 * @tc.type: FUNC
2000 */
2001 HWTEST_F(SceneSessionManagerTest2, RecoverAndConnectSpecificSession, Function | SmallTest | Level3)
2002 {
2003 sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
2004 ASSERT_NE(property, nullptr);
2005 property->SetParentId(1);
2006 sptr<ISessionStage> sessionStage;
2007 sptr<IWindowEventChannel> eventChannel;
2008 std::shared_ptr<RSSurfaceNode> surfaceNode;
2009 sptr<ISession> session;
2010 sptr<IRemoteObject> token;
2011 auto result = ssm_->RecoverAndConnectSpecificSession(sessionStage, eventChannel,
2012 surfaceNode, property, session, token);
2013 ASSERT_EQ(result, WSError::WS_ERROR_NULLPTR);
2014 }
2015
2016 /**
2017 * @tc.name: CacheSubSessionForRecovering
2018 * @tc.desc: CacheSubSessionForRecovering
2019 * @tc.type: FUNC
2020 */
2021 HWTEST_F(SceneSessionManagerTest2, CacheSubSessionForRecovering, Function | SmallTest | Level3)
2022 {
2023 sptr<WindowSessionProperty> property;
2024 ASSERT_NE(ssm_, nullptr);
2025 ssm_->recoveringFinished_ = false;
2026 SessionInfo info;
2027 info.abilityName_ = "test1";
2028 info.bundleName_ = "test2";
2029 sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, property);
2030 ASSERT_NE(sceneSession, nullptr);
2031 ssm_->CacheSubSessionForRecovering(nullptr, property);
2032 ssm_->CacheSubSessionForRecovering(sceneSession, property);
2033
2034 property = new (std::nothrow) WindowSessionProperty();
2035 ASSERT_NE(property, nullptr);
2036 ssm_->CacheSubSessionForRecovering(nullptr, property);
2037 ssm_->CacheSubSessionForRecovering(sceneSession, property);
2038 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2039 ssm_->CacheSubSessionForRecovering(sceneSession, property);
2040 property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
2041 ssm_->CacheSubSessionForRecovering(sceneSession, property);
2042 property->SetParentPersistentId(1);
2043 ssm_->CacheSubSessionForRecovering(sceneSession, property);
2044 }
2045
2046 /**
2047 * @tc.name: NotifyCreateToastSession
2048 * @tc.desc: NotifyCreateToastSession
2049 * @tc.type: FUNC
2050 */
2051 HWTEST_F(SceneSessionManagerTest2, NotifyCreateToastSession, Function | SmallTest | Level3)
2052 {
2053 sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
2054 ASSERT_NE(property, nullptr);
2055 ssm_->NotifyCreateToastSession(1, nullptr);
2056 SessionInfo Info;
2057 Info.persistentId_ = 1;
2058 int32_t persistentId = Info.persistentId_;
2059 Info.abilityName_ = "testInfo1a";
2060 Info.bundleName_ = "testInfo1b";
2061 sptr<SceneSession> session = new (std::nothrow) SceneSession(Info, nullptr);
2062 ssm_->NotifyCreateToastSession(persistentId, session);
2063 }
2064
2065 /**
2066 * @tc.name: UpdateGestureBackEnabled
2067 * @tc.desc: UpdateGestureBackEnabled
2068 * @tc.type: FUNC
2069 */
2070 HWTEST_F(SceneSessionManagerTest2, UpdateGestureBackEnabled, Function | SmallTest | Level3)
2071 {
2072 ASSERT_NE(nullptr, ssm_);
2073 SessionInfo sessionInfo;
2074 sessionInfo.bundleName_ = "SceneSessionManagerTest2";
2075 sessionInfo.abilityName_ = "UpdateGestureBackEnabled";
2076 sptr<WindowSessionProperty> property;
2077 sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, property);
2078 ASSERT_NE(nullptr, sceneSession);
2079 ASSERT_NE(nullptr, sceneSession->property_);
2080 ssm_->sceneSessionMap_.insert({1, sceneSession});
2081 sceneSession->persistentId_ = 1;
2082 ASSERT_EQ(ssm_->GetSceneSession(1), sceneSession);
2083 sceneSession->isEnableGestureBack_ = false;
2084 sceneSession->isEnableGestureBackHadSet_ = false;
2085 ssm_->UpdateGestureBackEnabled(1);
2086 sleep(WAIT_SLEEP_TIME);
2087 sceneSession->isEnableGestureBackHadSet_ = true;
2088 sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
2089 sceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
2090 sceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
2091 ssm_->NotifyEnterRecentTask(false);
2092 ASSERT_EQ(ssm_->enterRecent_.load(), false);
2093 sceneSession->UpdateFocus(true);
2094 ASSERT_EQ(sceneSession->IsFocused(), true);
2095 ssm_->UpdateGestureBackEnabled(1);
2096 sleep(WAIT_SLEEP_TIME);
2097 sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
2098 ssm_->UpdateGestureBackEnabled(1);
2099 sleep(WAIT_SLEEP_TIME);
2100 sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
2101 ssm_->UpdateGestureBackEnabled(1);
2102 sleep(WAIT_SLEEP_TIME);
2103 ssm_->sceneSessionMap_.erase(1);
2104 }
2105
2106 /**
2107 * @tc.name: NotifyEnterRecentTask
2108 * @tc.desc: NotifyEnterRecentTask;
2109 * @tc.type: FUNC
2110 */
2111 HWTEST_F(SceneSessionManagerTest2, NotifyEnterRecentTask, Function | SmallTest | Level3)
2112 {
2113 ASSERT_NE(nullptr, ssm_);
2114 SessionInfo sessionInfo;
2115 sessionInfo.bundleName_ = "NotifyEnterRecentTask";
2116 sessionInfo.abilityName_ = "NotifyEnterRecentTask";
2117 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
2118 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
2119 sceneSession->SetSessionProperty(property);
2120 ssm_->sceneSessionMap_.insert({1, sceneSession});
2121 ssm_->gestureBackEnableWindowIdSet_.insert(1);
2122 ssm_->gestureBackEnableWindowIdSet_.insert(2);
2123 ASSERT_EQ(ssm_->NotifyEnterRecentTask(true), WSError::WS_OK);
2124 ASSERT_EQ(ssm_->NotifyEnterRecentTask(false), WSError::WS_OK);
2125 ssm_->sceneSessionMap_.erase(1);
2126 }
2127 }
2128 } // namespace Rosen
2129 } // namespace OHOS
2130