• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <gtest/gtest.h>
17 #include <regex>
18 #include <pointer_event.h>
19 #include <ui/rs_surface_node.h>
20 
21 #include "key_event.h"
22 #include "mock/mock_session_stage.h"
23 #include "mock/mock_window_event_channel.h"
24 #include "mock/mock_pattern_detach_callback.h"
25 #include "session/host/include/extension_session.h"
26 #include "session/host/include/move_drag_controller.h"
27 #include "session/host/include/scene_session.h"
28 #include "session_manager/include/scene_session_manager.h"
29 #include "session/host/include/session.h"
30 #include "session_info.h"
31 #include "wm_common.h"
32 #include "window_manager_hilog.h"
33 
34 using namespace testing;
35 using namespace testing::ext;
36 
37 namespace OHOS {
38 namespace Rosen {
39 namespace {
40 const std::string UNDEFINED = "undefined";
41 constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowSessionTest4"};
42 }
43 
44 class WindowSessionTest4 : public testing::Test {
45 public:
46     static void SetUpTestCase();
47     static void TearDownTestCase();
48     void SetUp() override;
49     void TearDown() override;
50     int32_t GetTaskCount();
51     sptr<SceneSessionManager> ssm_;
52 
53 private:
54     RSSurfaceNode::SharedPtr CreateRSSurfaceNode();
55     sptr<Session> session_ = nullptr;
56     static constexpr uint32_t waitSyncInNs_ = 500000;
57 };
58 
SetUpTestCase()59 void WindowSessionTest4::SetUpTestCase()
60 {
61 }
62 
TearDownTestCase()63 void WindowSessionTest4::TearDownTestCase()
64 {
65 }
66 
SetUp()67 void WindowSessionTest4::SetUp()
68 {
69     SessionInfo info;
70     info.abilityName_ = "testSession1";
71     info.moduleName_ = "testSession2";
72     info.bundleName_ = "testSession4";
73     session_ = sptr<Session>::MakeSptr(info);
74     session_->surfaceNode_ = CreateRSSurfaceNode();
75     EXPECT_NE(nullptr, session_);
76     ssm_ = sptr<SceneSessionManager>::MakeSptr();
77     session_->SetEventHandler(ssm_->taskScheduler_->GetEventHandler(), ssm_->eventHandler_);
78     auto isScreenLockedCallback = [this]() {
79         return ssm_->IsScreenLocked();
80     };
81     session_->RegisterIsScreenLockedCallback(isScreenLockedCallback);
82 }
83 
TearDown()84 void WindowSessionTest4::TearDown()
85 {
86     session_ = nullptr;
87     usleep(waitSyncInNs_);
88 }
89 
CreateRSSurfaceNode()90 RSSurfaceNode::SharedPtr WindowSessionTest4::CreateRSSurfaceNode()
91 {
92     struct RSSurfaceNodeConfig rsSurfaceNodeConfig;
93     rsSurfaceNodeConfig.SurfaceNodeName = "WindowSessionTest4SurfaceNode";
94     auto surfaceNode = RSSurfaceNode::Create(rsSurfaceNodeConfig);
95     if (surfaceNode == nullptr) {
96         GTEST_LOG_(INFO) << "WindowSessionTest4::CreateRSSurfaceNode surfaceNode is nullptr";
97     }
98     return surfaceNode;
99 }
100 
GetTaskCount()101 int32_t WindowSessionTest4::GetTaskCount()
102 {
103     std::string dumpInfo = session_->handler_->GetEventRunner()->GetEventQueue()->DumpCurrentQueueSize();
104     std::regex pattern("\\d+");
105     std::smatch matches;
106     int32_t taskNum = 0;
107     while (std::regex_search(dumpInfo, matches, pattern)) {
108         taskNum += std::stoi(matches.str());
109         dumpInfo = matches.suffix();
110     }
111     return taskNum;
112 }
113 
114 namespace {
115 /**
116  * @tc.name: SetShowRecent001
117  * @tc.desc: Exist detect task when in recent.
118  * @tc.type: FUNC
119  */
120 HWTEST_F(WindowSessionTest4, SetShowRecent001, Function | SmallTest | Level2)
121 {
122     std::string taskName = "wms:WindowStateDetect" + std::to_string(session_->persistentId_);
__anon58f651b10402()123     auto task = [](){};
124     int64_t delayTime = 3000;
125     session_->handler_->PostTask(task, taskName, delayTime);
126     int32_t beforeTaskNum = GetTaskCount();
127 
128     session_->SetShowRecent(true);
129     ASSERT_EQ(beforeTaskNum, GetTaskCount());
130     session_->handler_->RemoveTask(taskName);
131 }
132 
133 /**
134  * @tc.name: SetShowRecent002
135  * @tc.desc: SetShowRecent:showRecent is false, showRecent_ is false.
136  * @tc.type: FUNC
137  */
138 HWTEST_F(WindowSessionTest4, SetShowRecent002, Function | SmallTest | Level2)
139 {
140     std::string taskName = "wms:WindowStateDetect" + std::to_string(session_->persistentId_);
__anon58f651b10502()141     auto task = [](){};
142     int64_t delayTime = 3000;
143     session_->handler_->PostTask(task, taskName, delayTime);
144     session_->showRecent_ = false;
145     int32_t beforeTaskNum = GetTaskCount();
146 
147     session_->SetShowRecent(false);
148     ASSERT_EQ(beforeTaskNum, GetTaskCount());
149     session_->handler_->RemoveTask(taskName);
150 }
151 
152 /**
153  * @tc.name: SetShowRecent003
154  * @tc.desc: SetShowRecent:showRecent is false, showRecent_ is true, detach task.
155  * @tc.type: FUNC
156  */
157 HWTEST_F(WindowSessionTest4, SetShowRecent003, Function | SmallTest | Level2)
158 {
159     std::string taskName = "wms:WindowStateDetect" + std::to_string(session_->persistentId_);
__anon58f651b10602()160     auto task = [](){};
161     int64_t delayTime = 3000;
162     session_->handler_->PostTask(task, taskName, delayTime);
163     session_->showRecent_ = true;
164     session_->isAttach_ = false;
165     int32_t beforeTaskNum = GetTaskCount();
166 
167     session_->SetShowRecent(false);
168     ASSERT_EQ(beforeTaskNum, GetTaskCount());
169     session_->handler_->RemoveTask(taskName);
170 }
171 
172 /**
173  * @tc.name: SetShowRecent004
174  * @tc.desc: SetShowRecent
175  * @tc.type: FUNC
176  */
177 HWTEST_F(WindowSessionTest4, SetShowRecent004, Function | SmallTest | Level2)
178 {
179     session_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
180     ssm_->SetScreenLocked(false);
181     sleep(1);
182 
183     session_->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
184 
185     bool showRecent = false;
186     session_->showRecent_ = true;
187     session_->SetAttachState(true);
188     session_->SetShowRecent(showRecent);
189     ASSERT_EQ(session_->GetShowRecent(), showRecent);
190 }
191 
192 /**
193  * @tc.name: CreateDetectStateTask001
194  * @tc.desc: Create detection task when there are no pre_existing tasks.
195  * @tc.type: FUNC
196  */
197 HWTEST_F(WindowSessionTest4, CreateDetectStateTask001, Function | SmallTest | Level2)
198 {
199     session_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
200     std::string taskName = "wms:WindowStateDetect" + std::to_string(session_->persistentId_);
201     DetectTaskInfo detectTaskInfo;
202     detectTaskInfo.taskState = DetectTaskState::NO_TASK;
203     int32_t beforeTaskNum = GetTaskCount();
204     session_->SetDetectTaskInfo(detectTaskInfo);
205     session_->CreateDetectStateTask(false, WindowMode::WINDOW_MODE_FULLSCREEN);
206 
207     ASSERT_EQ(beforeTaskNum + 1, GetTaskCount());
208     ASSERT_EQ(DetectTaskState::DETACH_TASK, session_->GetDetectTaskInfo().taskState);
209     session_->handler_->RemoveTask(taskName);
210 
211     session_->showRecent_ = true;
212     session_->CreateDetectStateTask(false, WindowMode::WINDOW_MODE_FULLSCREEN);
213 }
214 
215 /**
216  * @tc.name: CreateDetectStateTask002
217  * @tc.desc: Detect state when window mode changed.
218  * @tc.type: FUNC
219  */
220 HWTEST_F(WindowSessionTest4, CreateDetectStateTask002, Function | SmallTest | Level2)
221 {
222     session_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
223     std::string taskName = "wms:WindowStateDetect" + std::to_string(session_->persistentId_);
__anon58f651b10702()224     auto task = [](){};
225     int64_t delayTime = 3000;
226     session_->handler_->PostTask(task, taskName, delayTime);
227     int32_t beforeTaskNum = GetTaskCount();
228 
229     DetectTaskInfo detectTaskInfo;
230     detectTaskInfo.taskState = DetectTaskState::DETACH_TASK;
231     detectTaskInfo.taskWindowMode = WindowMode::WINDOW_MODE_FULLSCREEN;
232     session_->SetDetectTaskInfo(detectTaskInfo);
233     session_->CreateDetectStateTask(true, WindowMode::WINDOW_MODE_SPLIT_SECONDARY);
234 
235     ASSERT_EQ(beforeTaskNum - 1, GetTaskCount());
236     ASSERT_EQ(DetectTaskState::NO_TASK, session_->GetDetectTaskInfo().taskState);
237     ASSERT_EQ(WindowMode::WINDOW_MODE_UNDEFINED, session_->GetDetectTaskInfo().taskWindowMode);
238     session_->handler_->RemoveTask(taskName);
239 
240     session_->showRecent_ = true;
241     session_->CreateDetectStateTask(false, WindowMode::WINDOW_MODE_SPLIT_SECONDARY);
242 }
243 
244 /**
245  * @tc.name: CreateDetectStateTask003
246  * @tc.desc: Detect sup and down tree tasks for the same type.
247  * @tc.type: FUNC
248  */
249 HWTEST_F(WindowSessionTest4, CreateDetectStateTask003, Function | SmallTest | Level2)
250 {
251     session_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
252     std::string taskName = "wms:WindowStateDetect" + std::to_string(session_->persistentId_);
253     DetectTaskInfo detectTaskInfo;
254     detectTaskInfo.taskState = DetectTaskState::DETACH_TASK;
255     detectTaskInfo.taskWindowMode = WindowMode::WINDOW_MODE_FULLSCREEN;
256     session_->SetDetectTaskInfo(detectTaskInfo);
257     session_->CreateDetectStateTask(true, WindowMode::WINDOW_MODE_SPLIT_SECONDARY);
258     ASSERT_EQ(DetectTaskState::NO_TASK, session_->GetDetectTaskInfo().taskState);
259     session_->handler_->RemoveTask(taskName);
260 
261     session_->showRecent_ = true;
262     session_->CreateDetectStateTask(false, WindowMode::WINDOW_MODE_SPLIT_SECONDARY);
263 }
264 
265 /**
266  * @tc.name: CreateDetectStateTask004
267  * @tc.desc: Detection tasks under the same window mode.
268  * @tc.type: FUNC
269  */
270 HWTEST_F(WindowSessionTest4, CreateDetectStateTask004, Function | SmallTest | Level2)
271 {
272     session_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
273     std::string taskName = "wms:WindowStateDetect" + std::to_string(session_->persistentId_);
274     DetectTaskInfo detectTaskInfo;
275     int32_t beforeTaskNum = GetTaskCount();
276     detectTaskInfo.taskState = DetectTaskState::DETACH_TASK;
277     detectTaskInfo.taskWindowMode = WindowMode::WINDOW_MODE_FULLSCREEN;
278     session_->SetDetectTaskInfo(detectTaskInfo);
279     session_->CreateDetectStateTask(true, WindowMode::WINDOW_MODE_FULLSCREEN);
280 
281     ASSERT_EQ(beforeTaskNum + 1, GetTaskCount());
282     ASSERT_EQ(DetectTaskState::ATTACH_TASK, session_->GetDetectTaskInfo().taskState);
283     session_->handler_->RemoveTask(taskName);
284 
285     session_->showRecent_ = true;
286     session_->CreateDetectStateTask(false, WindowMode::WINDOW_MODE_FULLSCREEN);
287 }
288 
289 /**
290  * @tc.name: GetAttachState001
291  * @tc.desc: GetAttachState001
292  * @tc.type: FUNC
293  */
294 HWTEST_F(WindowSessionTest4, GetAttachState001, Function | SmallTest | Level2)
295 {
296     std::string taskName = "wms:WindowStateDetect" + std::to_string(session_->persistentId_);
297     session_->SetAttachState(false);
298     bool isAttach = session_->GetAttachState();
299     ASSERT_EQ(false, isAttach);
300     session_->handler_->RemoveTask(taskName);
301 }
302 
303 /**
304  * @tc.name: ResetSessionConnectState
305  * @tc.desc: ResetSessionConnectState
306  * @tc.type: FUNC
307  */
308 HWTEST_F(WindowSessionTest4, ResetSessionConnectState, Function | SmallTest | Level2)
309 {
310     ASSERT_NE(session_, nullptr);
311     session_->ResetSessionConnectState();
312     ASSERT_EQ(session_->state_, SessionState::STATE_DISCONNECT);
313     ASSERT_EQ(session_->GetCallingPid(), -1);
314 }
315 
316 /**
317  * @tc.name: ResetIsActive
318  * @tc.desc: ResetIsActive
319  * @tc.type: FUNC
320  */
321 HWTEST_F(WindowSessionTest4, ResetIsActive, Function | SmallTest | Level2)
322 {
323     ASSERT_NE(session_, nullptr);
324     session_->ResetIsActive();
325     ASSERT_EQ(session_->isActive_, false);
326 }
327 
328 /**
329  * @tc.name: PostExportTask02
330  * @tc.desc: PostExportTask
331  * @tc.type: FUNC
332  */
333 HWTEST_F(WindowSessionTest4, PostExportTask02, Function | SmallTest | Level2)
334 {
335     ASSERT_NE(session_, nullptr);
336     std::string name = "sessionExportTask";
__anon58f651b10802()337     auto task = [](){};
338     int64_t delayTime = 0;
339 
340     session_->PostExportTask(task, name, delayTime);
341     auto result = session_->GetBufferAvailable();
342     ASSERT_EQ(result, false);
343 
344     sptr<SceneSessionManager> sceneSessionManager = sptr<SceneSessionManager>::MakeSptr();
345     session_->SetEventHandler(sceneSessionManager->taskScheduler_->GetEventHandler(),
346         sceneSessionManager->eventHandler_);
347     session_->PostExportTask(task, name, delayTime);
348     auto result2 = session_->GetBufferAvailable();
349     ASSERT_EQ(result2, false);
350 }
351 
352 /**
353  * @tc.name: SetLeashWinSurfaceNode02
354  * @tc.desc: SetLeashWinSurfaceNode
355  * @tc.type: FUNC
356  */
357 HWTEST_F(WindowSessionTest4, SetLeashWinSurfaceNode02, Function | SmallTest | Level2)
358 {
359     ASSERT_NE(session_, nullptr);
360     session_->leashWinSurfaceNode_ = WindowSessionTest4::CreateRSSurfaceNode();
361     session_->SetLeashWinSurfaceNode(nullptr);
362 
363     session_->leashWinSurfaceNode_ = nullptr;
364     session_->SetLeashWinSurfaceNode(nullptr);
365     auto result = session_->GetBufferAvailable();
366     ASSERT_EQ(result, false);
367 }
368 
369 /**
370  * @tc.name: GetCloseAbilityWantAndClean
371  * @tc.desc: GetCloseAbilityWantAndClean
372  * @tc.type: FUNC
373  */
374 HWTEST_F(WindowSessionTest4, GetCloseAbilityWantAndClean, Function | SmallTest | Level2)
375 {
376     ASSERT_NE(session_, nullptr);
377     AAFwk::Want outWant;
378     session_->sessionInfo_.closeAbilityWant = std::make_shared<AAFwk::Want>();
379     session_->GetCloseAbilityWantAndClean(outWant);
380 
381     session_->sessionInfo_.closeAbilityWant = nullptr;
382     session_->GetCloseAbilityWantAndClean(outWant);
383     auto result = session_->GetBufferAvailable();
384     ASSERT_EQ(result, false);
385 }
386 
387 /**
388  * @tc.name: SetScreenId02
389  * @tc.desc: SetScreenId Test
390  * @tc.type: FUNC
391  */
392 HWTEST_F(WindowSessionTest4, SetScreenId02, Function | SmallTest | Level2)
393 {
394     ASSERT_NE(session_, nullptr);
395     uint64_t screenId = 0;
396     session_->sessionStage_ = sptr<SessionStageMocker>::MakeSptr();
397     session_->SetScreenId(screenId);
398     ASSERT_EQ(0, session_->sessionInfo_.screenId_);
399 }
400 
401 /**
402  * @tc.name: SetSessionState
403  * @tc.desc: SetSessionState
404  * @tc.type: FUNC
405  */
406 HWTEST_F(WindowSessionTest4, SetSessionState, Function | SmallTest | Level2)
407 {
408     ASSERT_NE(session_, nullptr);
409 
410     SessionState state03 = SessionState::STATE_CONNECT;
411     session_->SetSessionState(state03);
412     ASSERT_EQ(state03, session_->state_);
413 }
414 
415 /**
416  * @tc.name: SetFocusable03
417  * @tc.desc: SetFocusable
418  * @tc.type: FUNC
419  */
420 HWTEST_F(WindowSessionTest4, SetFocusable03, Function | SmallTest | Level2)
421 {
422     ASSERT_NE(session_, nullptr);
423     session_->isFocused_ = true;
424     session_->property_->focusable_ = false;
425     bool isFocusable = true;
426 
427     auto result = session_->SetFocusable(isFocusable);
428     ASSERT_EQ(result, WSError::WS_OK);
429     ASSERT_EQ(session_->GetFocusable(), true);
430 }
431 
432 /**
433  * @tc.name: GetFocused
434  * @tc.desc: GetFocused Test
435  * @tc.type: FUNC
436  */
437 HWTEST_F(WindowSessionTest4, GetFocused, Function | SmallTest | Level2)
438 {
439     ASSERT_NE(session_, nullptr);
440     bool result = session_->GetFocused();
441     ASSERT_EQ(result, false);
442 
443     session_->isFocused_ = true;
444     bool result2 = session_->GetFocused();
445     ASSERT_EQ(result2, true);
446 }
447 
448 /**
449  * @tc.name: UpdatePointerArea
450  * @tc.desc: UpdatePointerArea Test
451  * @tc.type: FUNC
452  */
453 HWTEST_F(WindowSessionTest4, UpdatePointerArea, Function | SmallTest | Level2)
454 {
455     ASSERT_NE(session_, nullptr);
456     WSRect rect = { 0, 0, 0, 0 };
457     session_->preRect_ = rect;
458     session_->UpdatePointerArea(rect);
459     ASSERT_EQ(session_->GetFocused(), false);
460 }
461 
462 /**
463  * @tc.name: UpdateSizeChangeReason02
464  * @tc.desc: UpdateSizeChangeReason Test
465  * @tc.type: FUNC
466  */
467 HWTEST_F(WindowSessionTest4, UpdateSizeChangeReason02, Function | SmallTest | Level2)
468 {
469     ASSERT_NE(session_, nullptr);
470     SizeChangeReason reason = SizeChangeReason::UNDEFINED;
471     WSError result = session_->UpdateSizeChangeReason(reason);
472     ASSERT_EQ(result, WSError::WS_DO_NOTHING);
473 }
474 
475 /**
476  * @tc.name: UpdateDensity
477  * @tc.desc: UpdateDensity Test
478  * @tc.type: FUNC
479  */
480 HWTEST_F(WindowSessionTest4, UpdateDensity, Function | SmallTest | Level2)
481 {
482     ASSERT_NE(session_, nullptr);
483 
484     session_->state_ = SessionState::STATE_DISCONNECT;
485     ASSERT_FALSE(session_->IsSessionValid());
486     WSError result = session_->UpdateDensity();
487     ASSERT_EQ(result, WSError::WS_ERROR_INVALID_SESSION);
488 
489     session_->state_ = SessionState::STATE_CONNECT;
490     ASSERT_TRUE(session_->IsSessionValid());
491     session_->sessionStage_ = nullptr;
492     WSError result02 = session_->UpdateDensity();
493     ASSERT_EQ(result02, WSError::WS_ERROR_NULLPTR);
494 }
495 
496 /**
497  * @tc.name: UpdateSizeChangeReason
498  * @tc.desc: UpdateSizeChangeReason UpdateDensity
499  * @tc.type: FUNC
500  */
501 HWTEST_F(WindowSessionTest4, UpdateSizeChangeReason, Function | SmallTest | Level2)
502 {
503     SizeChangeReason reason = SizeChangeReason{1};
504     ASSERT_EQ(session_->UpdateSizeChangeReason(reason), WSError::WS_OK);
505 }
506 
507 /**
508  * @tc.name: SetPendingSessionActivationEventListener
509  * @tc.desc: SetPendingSessionActivationEventListener
510  * @tc.type: FUNC
511  */
512 HWTEST_F(WindowSessionTest4, SetPendingSessionActivationEventListener, Function | SmallTest | Level2)
513 {
514     int resultValue = 0;
__anon58f651b10902(const SessionInfo& info) 515     session_->SetPendingSessionActivationEventListener([&resultValue](const SessionInfo& info) {
516         resultValue = 1;
517     });
518     usleep(waitSyncInNs_);
__anon58f651b10a02(const SessionInfo& info) 519     session_->SetTerminateSessionListener([&resultValue](const SessionInfo& info) {
520         resultValue = 2;
521     });
522     usleep(waitSyncInNs_);
523     LifeCycleTaskType taskType = LifeCycleTaskType{0};
524     session_->RemoveLifeCycleTask(taskType);
525     ASSERT_EQ(resultValue, 0);
526 }
527 
528 /**
529  * @tc.name: SetSessionIcon
530  * @tc.desc: SetSessionIcon UpdateDensity
531  * @tc.type: FUNC
532  */
533 HWTEST_F(WindowSessionTest4, SetSessionIcon, Function | SmallTest | Level2)
534 {
535     std::shared_ptr<Media::PixelMap> icon;
536     session_->SetSessionIcon(icon);
537     ASSERT_EQ(session_->Clear(), WSError::WS_OK);
538     session_->SetSessionSnapshotListener(nullptr);
__anon58f651b10b02(const SessionInfo& info) 539     NotifyPendingSessionActivationFunc func = [](const SessionInfo& info) {};
540     session_->pendingSessionActivationFunc_ = func;
541     ASSERT_EQ(session_->PendingSessionToForeground(), WSError::WS_OK);
542 
543     session_->scenePersistence_ = sptr<ScenePersistence>::MakeSptr("SetSessionIcon", 1);
544     session_->updateSessionIconFunc_ = nullptr;
545     ASSERT_EQ(WSError::WS_OK, session_->SetSessionIcon(icon));
546 
__anon58f651b10c02(const std::string& iconPath) 547     NofitySessionIconUpdatedFunc func2 = [](const std::string& iconPath) {};
548     session_->updateSessionIconFunc_ = func2;
549     ASSERT_EQ(WSError::WS_OK, session_->SetSessionIcon(icon));
550 
__anon58f651b10d02(const SessionInfo& info, bool needStartCaller, bool isFromBroker) 551     NotifyTerminateSessionFuncNew func3 = [](const SessionInfo& info, bool needStartCaller, bool isFromBroker) {};
552     session_->terminateSessionFuncNew_ = func3;
553     ASSERT_EQ(WSError::WS_OK, session_->Clear());
554 }
555 
556 /**
557  * @tc.name: SetSessionExceptionListener
558  * @tc.desc: SetSessionExceptionListener
559  * @tc.type: FUNC
560  */
561 HWTEST_F(WindowSessionTest4, SetSessionExceptionListener, Function | SmallTest | Level2)
562 {
563     session_->SetSessionExceptionListener(nullptr, true);
564     session_->SetSessionExceptionListener([](const SessionInfo& info,
__anon58f651b10e02(const SessionInfo& info, const ExceptionInfo& exceptionInfo, bool startFail) 565         const ExceptionInfo& exceptionInfo, bool startFail) {}, true);
566     usleep(waitSyncInNs_);
567     ASSERT_NE(nullptr, session_->jsSceneSessionExceptionFunc_);
568 }
569 
570 /**
571  * @tc.name: SetRaiseToAppTopForPointDownFunc
572  * @tc.desc: SetRaiseToAppTopForPointDownFunc Test
573  * @tc.type: FUNC
574  */
575 HWTEST_F(WindowSessionTest4, SetRaiseToAppTopForPointDownFunc, Function | SmallTest | Level2)
576 {
577     ASSERT_NE(session_, nullptr);
578     session_->SetRaiseToAppTopForPointDownFunc(nullptr);
579 
__anon58f651b10f02() 580     NotifyRaiseToTopForPointDownFunc func = []() {};
581     session_->raiseToTopForPointDownFunc_ = func;
582     session_->RaiseToAppTopForPointDown();
583     session_->HandlePointDownDialog();
584     session_->ClearDialogVector();
585 
586     session_->SetBufferAvailableChangeListener(nullptr);
587     session_->UnregisterSessionChangeListeners();
588     session_->SetSessionStateChangeNotifyManagerListener(nullptr);
589     session_->SetSessionInfoChangeNotifyManagerListener(nullptr);
590     session_->NotifyFocusStatus(true);
591 
592     session_->SetRequestFocusStatusNotifyManagerListener(nullptr);
593     session_->SetNotifyUIRequestFocusFunc(nullptr);
594     session_->SetNotifyUILostFocusFunc(nullptr);
595     session_->UnregisterSessionChangeListeners();
596 
__anon58f651b11002(const SessionInfo& info, bool shouldBackToCaller) 597     NotifyPendingSessionToBackgroundForDelegatorFunc func2 = [](const SessionInfo& info, bool shouldBackToCaller) {};
598     session_->pendingSessionToBackgroundForDelegatorFunc_ = func2;
599     ASSERT_EQ(WSError::WS_OK, session_->PendingSessionToBackgroundForDelegator(true));
600 }
601 
602 /**
603  * @tc.name: NotifyCloseExistPipWindow
604  * @tc.desc: check func NotifyCloseExistPipWindow
605  * @tc.type: FUNC
606  */
607 HWTEST_F(WindowSessionTest4, NotifyCloseExistPipWindow, Function | SmallTest | Level2)
608 {
609     sptr<SessionStageMocker> mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
610     ASSERT_NE(mockSessionStage, nullptr);
611     ManagerState key = ManagerState{0};
612     session_->GetStateFromManager(key);
613     session_->NotifyUILostFocus();
614 
__anon58f651b11102() 615     session_->lostFocusFunc_ = []() {};
616     session_->NotifyUILostFocus();
617 
618     session_->SetSystemSceneBlockingFocus(true);
619     session_->GetBlockingFocus();
620     session_->sessionStage_ = mockSessionStage;
621     EXPECT_CALL(*(mockSessionStage), NotifyCloseExistPipWindow()).Times(1).WillOnce(Return(WSError::WS_OK));
622     ASSERT_EQ(WSError::WS_OK, session_->NotifyCloseExistPipWindow());
623     session_->sessionStage_ = nullptr;
624     ASSERT_EQ(WSError::WS_ERROR_NULLPTR, session_->NotifyCloseExistPipWindow());
625 }
626 
627 /**
628  * @tc.name: SetUseStartingWindowAboveLocked
629  * @tc.desc: SetUseStartingWindowAboveLocked Test
630  * @tc.type: FUNC
631  */
632  HWTEST_F(WindowSessionTest4, SetUseStartingWindowAboveLocked, Function | SmallTest | Level2)
633 {
634     ASSERT_NE(session_, nullptr);
635     session_->useStartingWindowAboveLocked_ = false;
636     ASSERT_EQ(session_->useStartingWindowAboveLocked_, false);
637     session_->SetUseStartingWindowAboveLocked(true);
638     ASSERT_EQ(session_->UseStartingWindowAboveLocked(), true);
639 }
640 
641 /**
642  * @tc.name: SetSystemConfig
643  * @tc.desc: SetSystemConfig Test
644  * @tc.type: FUNC
645  */
646 HWTEST_F(WindowSessionTest4, SetSystemConfig, Function | SmallTest | Level2)
647 {
648     ASSERT_NE(session_, nullptr);
649     SystemSessionConfig systemConfig;
650     session_->SetSystemConfig(systemConfig);
651     float snapshotScale = 0.5;
652     session_->SetSnapshotScale(snapshotScale);
653     session_->ProcessBackEvent();
654     session_->NotifyOccupiedAreaChangeInfo(nullptr);
655     session_->UpdateMaximizeMode(true);
656     ASSERT_EQ(session_->GetZOrder(), 0);
657 
658     session_->SetUINodeId(0);
659     session_->GetUINodeId();
660     session_->SetShowRecent(true);
661     session_->GetShowRecent();
662     session_->SetBufferAvailable(true);
663 
664     session_->SetNeedSnapshot(true);
665     session_->SetFloatingScale(0.5);
666     ASSERT_EQ(session_->GetFloatingScale(), 0.5f);
667     session_->SetScale(50, 100, 50, 100);
668     session_->GetScaleX();
669     session_->GetScaleY();
670     session_->GetPivotX();
671     session_->GetPivotY();
672     session_->SetSCBKeepKeyboard(true);
673     session_->GetSCBKeepKeyboardFlag();
674     ASSERT_EQ(WSError::WS_OK, session_->MarkProcessed(11));
675 }
676 
677 /**
678  * @tc.name: SetOffset
679  * @tc.desc: SetOffset Test
680  * @tc.type: FUNC
681  */
682 HWTEST_F(WindowSessionTest4, SetOffset, Function | SmallTest | Level2)
683 {
684     ASSERT_NE(session_, nullptr);
685     session_->SetOffset(50, 100);
686     session_->GetOffsetX();
687     session_->GetOffsetY();
688     WSRectF bounds;
689     session_->SetBounds(bounds);
690     session_->GetBounds();
691     session_->UpdateTitleInTargetPos(true, 100);
692     session_->SetNotifySystemSessionPointerEventFunc(nullptr);
693     session_->SetNotifySystemSessionKeyEventFunc(nullptr);
694     ASSERT_EQ(session_->GetBufferAvailable(), false);
695 }
696 
697 /**
698  * @tc.name: SetBackPressedListenser
699  * @tc.desc: SetBackPressedListenser Test
700  type: FUNC
701  */
702 HWTEST_F(WindowSessionTest4, SetBackPressedListenser, Function | SmallTest | Level2)
703 {
704     ASSERT_NE(session_, nullptr);
705     int32_t result = 0;
__anon58f651b11202(const bool needMoveToBackground) 706     session_->SetBackPressedListenser([&result](const bool needMoveToBackground) {
707         result = 1;
708     });
709     usleep(waitSyncInNs_);
710     session_->backPressedFunc_(true);
711     ASSERT_EQ(result, 1);
712 }
713 
714 /**
715  * @tc.name: SetUpdateSessionIconListener
716  * @tc.desc: SetUpdateSessionIconListener Test
717  * @tc.type: FUNC
718  */
719 HWTEST_F(WindowSessionTest4, SetUpdateSessionIconListener, Function | SmallTest | Level2)
720 {
721     ASSERT_NE(session_, nullptr);
722     WLOGFI("SetUpdateSessionIconListener begin!");
723 
724     session_->SetUpdateSessionIconListener(session_->updateSessionIconFunc_);
725 
726     WLOGFI("SetUpdateSessionIconListener end!");
727 }
728 
729 /**
730  * @tc.name: NotifyContextTransparent
731  * @tc.desc: NotifyContextTransparent Test
732  * @tc.type: FUNC
733  */
734 HWTEST_F(WindowSessionTest4, NotifyContextTransparent, Function | SmallTest | Level2)
735 {
736     WLOGFI("NotifyContextTransparent begin!");
737     ASSERT_NE(session_, nullptr);
738 
739     NotifyContextTransparentFunc contextTransparentFunc = session_->contextTransparentFunc_;
740     if (contextTransparentFunc == nullptr) {
__anon58f651b11302()741         contextTransparentFunc = [](){};
742     }
743     session_->contextTransparentFunc_ = nullptr;
744     session_->NotifyContextTransparent();
745 
746     session_->SetContextTransparentFunc(contextTransparentFunc);
747     session_->NotifyContextTransparent();
748 
749     WLOGFI("NotifyContextTransparent end!");
750 }
751 
752 /**
753  * @tc.name: NotifySessionInfoLockedStateChange
754  * @tc.desc: NotifySessionInfoLockedStateChange Test
755  * @tc.type: FUNC
756  */
757 HWTEST_F(WindowSessionTest4, NotifySessionInfoLockedStateChange, Function | SmallTest | Level2)
758 {
759     WLOGFI("NotifySessionInfoLockedStateChange begin!");
760     ASSERT_NE(session_, nullptr);
761 
762     NotifySessionInfoLockedStateChangeFunc sessionInfoLockedStateChangeFunc =
763         session_->sessionInfoLockedStateChangeFunc_;
764     if (sessionInfoLockedStateChangeFunc == nullptr) {
__anon58f651b11402(const bool lockedState) 765         sessionInfoLockedStateChangeFunc = [](const bool lockedState) {};
766     }
767     session_->sessionInfoLockedStateChangeFunc_ = nullptr;
768     session_->NotifySessionInfoLockedStateChange(true);
769 
770     session_->SetSessionInfoLockedStateChangeListener(sessionInfoLockedStateChangeFunc);
771     session_->NotifySessionInfoLockedStateChange(true);
772 
773     WLOGFI("NotifySessionInfoLockedStateChange end!");
774 }
775 
776 /**
777  * @tc.name: GetMainSession
778  * @tc.desc: GetMainSession Test
779  * @tc.type: FUNC
780  */
781 HWTEST_F(WindowSessionTest4, GetMainSession, Function | SmallTest | Level2)
782 {
783     ASSERT_NE(session_, nullptr);
784     SessionInfo info;
785     info.abilityName_ = "getMainSession";
786     info.moduleName_ = "getMainSession";
787     info.bundleName_ = "getMainSession";
788     sptr<Session> session = sptr<Session>::MakeSptr(info);
789     ASSERT_NE(session, nullptr);
790     session_->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
791     EXPECT_EQ(session, session->GetMainSession());
792 
793     sptr<Session> subSession = sptr<Session>::MakeSptr(info);
794     ASSERT_NE(subSession, nullptr);
795     subSession->SetParentSession(session);
796     subSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
797     EXPECT_EQ(session, subSession->GetMainSession());
798 
799     sptr<Session> subSubSession = sptr<Session>::MakeSptr(info);
800     ASSERT_NE(subSubSession, nullptr);
801     subSubSession->SetParentSession(subSession);
802     subSubSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
803     EXPECT_EQ(session, subSubSession->GetMainSession());
804 }
805 
806 /**
807  * @tc.name: GetMainOrFloatSession
808  * @tc.desc: GetMainOrFloatSession Test
809  * @tc.type: FUNC
810  */
811 HWTEST_F(WindowSessionTest4, GetMainOrFloatSession, Function | SmallTest | Level2)
812 {
813     ASSERT_NE(session_, nullptr);
814     SessionInfo info;
815     info.abilityName_ = "GetMainOrFloatSession";
816     info.moduleName_ = "GetMainOrFloatSession";
817     info.bundleName_ = "GetMainOrFloatSession";
818     sptr<Session> session = sptr<Session>::MakeSptr(info);
819     session_->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
820     EXPECT_EQ(session, session->GetMainOrFloatSession());
821 
822     sptr<Session> floatSession = sptr<Session>::MakeSptr(info);
823     floatSession->SetParentSession(session);
824     floatSession->property_->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
825     EXPECT_EQ(floatSession, floatSession->GetMainOrFloatSession());
826 
827     sptr<Session> subSession = sptr<Session>::MakeSptr(info);
828     subSession->SetParentSession(floatSession);
829     subSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
830     EXPECT_EQ(floatSession, subSession->GetMainOrFloatSession());
831 }
832 
833 /**
834  * @tc.name: IsAncestorsSession
835  * @tc.desc: IsAncestorsSession Test
836  * @tc.type: FUNC
837  */
838 HWTEST_F(WindowSessionTest4, IsAncestorsSession, Function | SmallTest | Level2)
839 {
840     SessionInfo info;
841     info.abilityName_ = "IsAncestorsSession";
842     info.moduleName_ = "IsAncestorsSession";
843     info.bundleName_ = "IsAncestorsSession";
844     sptr<Session> session = sptr<Session>::MakeSptr(info);
845     session->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
846     session->property_->SetPersistentId(1);
847 
848     sptr<Session> subSession = sptr<Session>::MakeSptr(info);
849     subSession->SetParentSession(session);
850     subSession->property_->SetPersistentId(2);
851     subSession->property_->SetParentPersistentId(1);
852     subSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
853     EXPECT_EQ(true, subSession->IsAncestorsSession(1));
854 
855     sptr<Session> subSubSession = sptr<Session>::MakeSptr(info);
856     subSubSession->SetParentSession(subSession);
857     subSubSession->property_->SetPersistentId(3);
858     subSubSession->property_->SetParentPersistentId(2);
859     subSubSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
860     EXPECT_EQ(true, subSubSession->IsAncestorsSession(1));
861     EXPECT_EQ(true, subSubSession->IsAncestorsSession(2));
862     EXPECT_EQ(false, subSubSession->IsAncestorsSession(3));
863 }
864 
865 /**
866  * @tc.name: IsSupportDetectWindow
867  * @tc.desc: IsSupportDetectWindow Test
868  * @tc.type: FUNC
869  */
870 HWTEST_F(WindowSessionTest4, IsSupportDetectWindow, Function | SmallTest | Level2)
871 {
872     session_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
873     ssm_->SetScreenLocked(true);
874     sleep(1);
875     bool ret = session_->IsSupportDetectWindow(true);
876     ASSERT_EQ(ret, false);
877 
878     ssm_->SetScreenLocked(false);
879     sleep(1);
880     session_->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
881     ret = session_->IsSupportDetectWindow(true);
882     ASSERT_EQ(ret, false);
883 
884     ssm_->SetScreenLocked(false);
885     sleep(1);
886     session_->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
887     session_->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
888     ret = session_->IsSupportDetectWindow(false);
889     ASSERT_EQ(ret, false);
890 }
891 
892 /**
893  * @tc.name: ShouldCreateDetectTask
894  * @tc.desc: ShouldCreateDetectTask Test
895  * @tc.type: FUNC
896  */
897 HWTEST_F(WindowSessionTest4, ShouldCreateDetectTask, Function | SmallTest | Level2)
898 {
899     DetectTaskInfo detectTaskInfo;
900     detectTaskInfo.taskState = DetectTaskState::ATTACH_TASK;
901     detectTaskInfo.taskWindowMode = WindowMode::WINDOW_MODE_FULLSCREEN;
902     session_->SetDetectTaskInfo(detectTaskInfo);
903     bool ret = session_->ShouldCreateDetectTask(true, WindowMode::WINDOW_MODE_UNDEFINED);
904     ASSERT_EQ(ret, true);
905     detectTaskInfo.taskState = DetectTaskState::DETACH_TASK;
906     session_->SetDetectTaskInfo(detectTaskInfo);
907     ret = session_->ShouldCreateDetectTask(false, WindowMode::WINDOW_MODE_UNDEFINED);
908     ASSERT_EQ(ret, true);
909     ret = session_->ShouldCreateDetectTask(true, WindowMode::WINDOW_MODE_UNDEFINED);
910     ASSERT_EQ(ret, false);
911 }
912 
913 /**
914  * @tc.name: ShouldCreateDetectTaskInRecent
915  * @tc.desc: ShouldCreateDetectTaskInRecent Test
916  * @tc.type: FUNC
917  */
918 HWTEST_F(WindowSessionTest4, ShouldCreateDetectTaskInRecent, Function | SmallTest | Level2)
919 {
920     bool ret = session_->ShouldCreateDetectTaskInRecent(true, true, true);
921     ASSERT_EQ(ret, false);
922     ret = session_->ShouldCreateDetectTaskInRecent(false, true, true);
923     ASSERT_EQ(ret, true);
924     ret = session_->ShouldCreateDetectTaskInRecent(false, true, false);
925     ASSERT_EQ(ret, false);
926     ret = session_->ShouldCreateDetectTaskInRecent(false, false, false);
927     ASSERT_EQ(ret, false);
928 }
929 
930 /**
931  * @tc.name: CreateWindowStateDetectTask
932  * @tc.desc: CreateWindowStateDetectTask Test
933  * @tc.type: FUNC
934  */
935 HWTEST_F(WindowSessionTest4, CreateWindowStateDetectTask, Function | SmallTest | Level2)
936 {
__anon58f651b11502() 937     auto isScreenLockedCallback = [this]() { return ssm_->IsScreenLocked(); };
938     session_->RegisterIsScreenLockedCallback(isScreenLockedCallback);
939     session_->SetSessionState(SessionState::STATE_CONNECT);
940     bool isAttach = true;
941     session_->CreateWindowStateDetectTask(isAttach, WindowMode::WINDOW_MODE_UNDEFINED);
942     ASSERT_EQ(isAttach, true);
943 
944     session_->handler_ = nullptr;
945     session_->CreateWindowStateDetectTask(false, WindowMode::WINDOW_MODE_UNDEFINED);
946     ASSERT_EQ(session_->handler_, nullptr);
947 }
948 
949 /**
950  * @tc.name: SetOffset01
951  * @tc.desc: SetOffset Test
952  * @tc.type: FUNC
953  */
954 HWTEST_F(WindowSessionTest4, SetOffset01, Function | SmallTest | Level2)
955 {
956     ASSERT_NE(session_, nullptr);
957     session_->SetOffset(0, 0);
958     ASSERT_EQ(session_->GetOffsetX(), 0);
959 }
960 
961 /**
962  * @tc.name: GetIsMidScene
963  * @tc.desc: GetIsMidScene Test
964  * @tc.type: FUNC
965  */
966 HWTEST_F(WindowSessionTest4, GetIsMidScene, Function | SmallTest | Level2)
967 {
968     ASSERT_NE(session_, nullptr);
969     bool isMidScene = false;
970     auto result = session_->GetIsMidScene(isMidScene);
971     ASSERT_EQ(result, WSError::WS_OK);
972     ASSERT_EQ(isMidScene, false);
973 }
974 
975 /**
976  * @tc.name: GetWindowUIInfoForWindowInfo01
977  * @tc.desc: GetWindowUIInfoForWindowInfo Test
978  * @tc.type: FUNC
979  */
980 HWTEST_F(WindowSessionTest4, GetWindowUIInfoForWindowInfo01, Function | SmallTest | Level2)
981 {
982     SessionInfo sessionInfo;
983     sessionInfo.isSystem_ = false;
984     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
985     sceneSession->SetVisibilityState(WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION);
986     WSRect rect = { 0, 0, 100, 100 };
987     sceneSession->SetSessionRect(rect);
988     sceneSession->SetSessionGlobalRect(rect);
989     sceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
990     sceneSession->GetSessionProperty()->SetDisplayId(0);
991 
992     WindowUIInfo windowUIInfo = sceneSession->GetWindowUIInfoForWindowInfo();
993     ASSERT_EQ(windowUIInfo.visibilityState, sceneSession->GetVisibilityState());
994 }
995 
996 /**
997  * @tc.name: GetWindowDisplayInfoForWindowInfo01
998  * @tc.desc: GetWindowDisplayInfoForWindowInfo Test
999  * @tc.type: FUNC
1000  */
1001 HWTEST_F(WindowSessionTest4, GetWindowDisplayInfoForWindowInfo01, Function | SmallTest | Level2)
1002 {
1003     SessionInfo sessionInfo;
1004     sessionInfo.isSystem_ = false;
1005     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1006     sceneSession->SetVisibilityState(WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION);
1007     WSRect rect = { 5, 0, 100, 100 };
1008     sceneSession->SetSessionRect(rect);
1009     sceneSession->SetSessionGlobalRect(rect);
1010     sceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
1011     constexpr DisplayId SECOND_DISPLAY_ID = 11;
1012     sceneSession->GetSessionProperty()->SetDisplayId(SECOND_DISPLAY_ID);
1013 
1014     WindowDisplayInfo windowDisplayInfo = sceneSession->GetWindowDisplayInfoForWindowInfo();
1015     ASSERT_EQ(windowDisplayInfo.displayId, sceneSession->GetSessionProperty()->GetDisplayId());
1016 }
1017 
1018 /**
1019  * @tc.name: GetWindowLayoutInfoForWindowInfo01
1020  * @tc.desc: GetWindowLayoutInfoForWindowInfo Test
1021  * @tc.type: FUNC
1022  */
1023 HWTEST_F(WindowSessionTest4, GetWindowLayoutInfoForWindowInfo01, Function | SmallTest | Level2)
1024 {
1025     SessionInfo sessionInfo;
1026     sessionInfo.isSystem_ = false;
1027     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1028     sceneSession->SetVisibilityState(WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION);
1029     WSRect rect = { 5, 0, 100, 100 };
1030     sceneSession->SetSessionRect(rect);
1031     sceneSession->SetSessionGlobalRect(rect);
1032     sceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
1033     sceneSession->GetSessionProperty()->SetDisplayId(0);
1034 
1035     WindowLayoutInfo windowLayoutInfo = sceneSession->GetWindowLayoutInfoForWindowInfo();
1036     ASSERT_EQ(windowLayoutInfo.rect.posX_, 5);
1037     ASSERT_EQ(windowLayoutInfo.rect.posY_, 0);
1038     ASSERT_EQ(windowLayoutInfo.rect.width_, 100);
1039     ASSERT_EQ(windowLayoutInfo.rect.height_, 100);
1040 }
1041 
1042 /**
1043  * @tc.name: GetWindowMetaInfoForWindowInfo01
1044  * @tc.desc: GetWindowMetaInfoForWindowInfo Test
1045  * @tc.type: FUNC
1046  */
1047 HWTEST_F(WindowSessionTest4, GetWindowMetaInfoForWindowInfo01, Function | SmallTest | Level2)
1048 {
1049     SessionInfo sessionInfo;
1050     sessionInfo.isSystem_ = false;
1051     sessionInfo.bundleName_ = "bundleName";
1052     sessionInfo.abilityName_ = "abilityName";
1053     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
1054     sceneSession->GetSessionProperty()->SetWindowName("sceneSession");
1055     sceneSession->SetVisibilityState(WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION);
1056     WSRect rect = { 5, 0, 100, 100 };
1057     sceneSession->SetSessionRect(rect);
1058     sceneSession->SetSessionGlobalRect(rect);
1059     sceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
1060     sceneSession->GetSessionProperty()->SetDisplayId(0);
1061     SessionInfo sessionInfo1;
1062     sessionInfo1.isSystem_ = true;
1063     sessionInfo1.abilityName_ = "abilityName1";
1064     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
1065     sceneSession1->SetVisibilityState(WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION);
1066     rect = { 200, 0, 100, 100 };
1067     sceneSession1->SetSessionRect(rect);
1068     sceneSession1->SetSessionGlobalRect(rect);
1069     sceneSession1->SetSessionState(SessionState::STATE_FOREGROUND);
1070     sceneSession1->GetSessionProperty()->SetDisplayId(0);
1071 
1072     WindowMetaInfo windowMetaInfo = sceneSession->GetWindowMetaInfoForWindowInfo();
1073     ASSERT_EQ(windowMetaInfo.windowId, sceneSession->GetWindowId());
1074     ASSERT_EQ(windowMetaInfo.windowName, sceneSession->GetSessionProperty()->GetWindowName());
1075     ASSERT_EQ(windowMetaInfo.bundleName, sceneSession->GetSessionInfo().bundleName_);
1076     ASSERT_EQ(windowMetaInfo.abilityName, sceneSession->GetSessionInfo().abilityName_);
1077     WindowMetaInfo windowMetaInfo1 = sceneSession1->GetWindowMetaInfoForWindowInfo();
1078     ASSERT_EQ(windowMetaInfo1 .windowName, sceneSession1->GetSessionInfo().abilityName_);
1079 }
1080 }
1081 } // namespace Rosen
1082 } // namespace OHOS
1083