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