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