• 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/host/include/session.h"
29 #include "session_manager/include/scene_session_manager.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 }
42 
43 class WindowSessionTest3 : public testing::Test {
44 public:
45     static void SetUpTestCase();
46     static void TearDownTestCase();
47     void SetUp() override;
48     void TearDown() override;
49 
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 WAIT_SYNC_IN_NS = 500000;
57 };
58 
SetUpTestCase()59 void WindowSessionTest3::SetUpTestCase()
60 {
61 }
62 
TearDownTestCase()63 void WindowSessionTest3::TearDownTestCase()
64 {
65 }
66 
SetUp()67 void WindowSessionTest3::SetUp()
68 {
69     SessionInfo info;
70     info.abilityName_ = "testSession1";
71     info.moduleName_ = "testSession2";
72     info.bundleName_ = "testSession3";
73     session_ = sptr<Session>::MakeSptr(info);
74     EXPECT_NE(nullptr, session_);
75     session_->surfaceNode_ = CreateRSSurfaceNode();
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 WindowSessionTest3::TearDown()
85 {
86     session_ = nullptr;
87     usleep(WAIT_SYNC_IN_NS);
88 }
89 
CreateRSSurfaceNode()90 RSSurfaceNode::SharedPtr WindowSessionTest3::CreateRSSurfaceNode()
91 {
92     struct RSSurfaceNodeConfig rsSurfaceNodeConfig;
93     rsSurfaceNodeConfig.SurfaceNodeName = "WindowSessionTest3SurfaceNode";
94     auto surfaceNode = RSSurfaceNode::Create(rsSurfaceNodeConfig);
95     if (surfaceNode == nullptr) {
96         GTEST_LOG_(INFO) << "WindowSessionTest3::CreateRSSurfaceNode surfaceNode is nullptr";
97     }
98     return surfaceNode;
99 }
100 
GetTaskCount()101 int32_t WindowSessionTest3::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: NotifyContextTransparent
117  * @tc.desc: NotifyContextTransparent Test
118  * @tc.type: FUNC
119  */
120 HWTEST_F(WindowSessionTest3, NotifyContextTransparent, Function | SmallTest | Level2)
121 {
122     ASSERT_NE(session_, nullptr);
123     NotifyContextTransparentFunc contextTransparentFunc = session_->contextTransparentFunc_;
124     if (contextTransparentFunc == nullptr) {
125         contextTransparentFunc = {};
126     }
127     session_->contextTransparentFunc_ = nullptr;
128     session_->NotifyContextTransparent();
129 
130     session_->SetContextTransparentFunc(contextTransparentFunc);
131     session_->NotifyContextTransparent();
132     session_->SetPendingSessionToBackgroundForDelegatorListener(nullptr);
133     EXPECT_EQ(WSError::WS_OK, session_->PendingSessionToBackgroundForDelegator(true));
134 }
135 
136 /**
137  * @tc.name: SetFocusable04
138  * @tc.desc: SetFocusable Test
139  * @tc.type: FUNC
140  */
141 HWTEST_F(WindowSessionTest3, SetFocusable04, Function | SmallTest | Level2)
142 {
143     ASSERT_NE(session_, nullptr);
144     session_->property_ = nullptr;
145     auto result = session_->SetFocusable(false);
146     ASSERT_EQ(result, WSError::WS_ERROR_NULLPTR);
147 
148     session_->isFocused_ = true;
149     session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
150     EXPECT_NE(session_->property_, nullptr);
151     session_->property_->SetFocusable(false);
152 
153     result = session_->SetFocusable(false);
154     EXPECT_EQ(result, WSError::WS_OK);
155 }
156 
157 /**
158  * @tc.name: SetFocusableOnShow
159  * @tc.desc: SetFocusableOnShow Test
160  * @tc.type: FUNC
161  */
162 HWTEST_F(WindowSessionTest3, SetFocusableOnShow, Function | SmallTest | Level2)
163 {
164     ASSERT_NE(session_, nullptr);
165     ASSERT_EQ(session_->IsFocusableOnShow(), true);
166     bool focusableOnShow = false;
167     session_->SetFocusableOnShow(focusableOnShow);
168     usleep(10000); // sleep 10ms
169     ASSERT_EQ(session_->IsFocusableOnShow(), focusableOnShow);
170 }
171 
172 /**
173  * @tc.name: SetTouchable03
174  * @tc.desc: IsSessionValid() and touchable return true
175  * @tc.type: FUNC
176  */
177 HWTEST_F(WindowSessionTest3, SetTouchable03, Function | SmallTest | Level2)
178 {
179     ASSERT_NE(session_, nullptr);
180     session_->SetSessionState(SessionState::STATE_FOREGROUND);
181     session_->sessionInfo_.isSystem_ = false;
182     EXPECT_EQ(WSError::WS_OK, session_->SetTouchable(true));
183 }
184 
185 /**
186  * @tc.name: GetTouchable02
187  * @tc.desc: GetTouchable Test
188  * @tc.type: FUNC
189  */
190 HWTEST_F(WindowSessionTest3, GetTouchable02, Function | SmallTest | Level2)
191 {
192     ASSERT_NE(session_, nullptr);
193     session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
194     ASSERT_NE(session_->property_, nullptr);
195     EXPECT_EQ(true, session_->GetTouchable());
196 
197     session_->property_ = nullptr;
198     EXPECT_EQ(true, session_->GetTouchable());
199 }
200 
201 /**
202  * @tc.name: UpdateDensity02
203  * @tc.desc: UpdateDensity Test
204  * @tc.type: FUNC
205  */
206 HWTEST_F(WindowSessionTest3, UpdateDensity02, Function | SmallTest | Level2)
207 {
208     ASSERT_NE(session_, nullptr);
209     session_->SetSessionState(SessionState::STATE_FOREGROUND);
210     sptr<SessionStageMocker> mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
211     EXPECT_NE(nullptr, mockSessionStage);
212     session_->sessionStage_ = mockSessionStage;
213     auto result = session_->UpdateDensity();
214     EXPECT_EQ(result, WSError::WS_OK);
215 }
216 
217 /**
218  * @tc.name: UpdateOrientation
219  * @tc.desc: UpdateOrientation Test
220  * @tc.type: FUNC
221  */
222 HWTEST_F(WindowSessionTest3, UpdateOrientation, Function | SmallTest | Level2)
223 {
224     ASSERT_NE(session_, nullptr);
225     session_->sessionInfo_.isSystem_ = true;
226     auto result = session_->UpdateOrientation();
227     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_SESSION);
228 
229     session_->sessionInfo_.isSystem_ = false;
230     session_->SetSessionState(SessionState::STATE_FOREGROUND);
231     result = session_->UpdateOrientation();
232     EXPECT_EQ(result, WSError::WS_ERROR_NULLPTR);
233 
234     sptr<SessionStageMocker> mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
235     EXPECT_NE(nullptr, mockSessionStage);
236     session_->sessionStage_ = mockSessionStage;
237     result = session_->UpdateOrientation();
238     EXPECT_EQ(result, WSError::WS_OK);
239 }
240 
241 /**
242  * @tc.name: HandleDialogBackground
243  * @tc.desc: HandleDialogBackground Test
244  * @tc.type: FUNC
245  */
246 HWTEST_F(WindowSessionTest3, HandleDialogBackground, Function | SmallTest | Level2)
247 {
248     ASSERT_NE(session_, nullptr);
249     session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
250     ASSERT_NE(session_->property_, nullptr);
251     session_->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
252     session_->HandleDialogBackground();
253 
254     session_->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
255     sptr<Session> session01 = nullptr;
256 
257     SessionInfo info;
258     info.abilityName_ = "testSession1";
259     info.moduleName_ = "testSession2";
260     info.bundleName_ = "testSession3";
261     sptr<Session> session02 = sptr<Session>::MakeSptr(info);
262     sptr<Session> session03 = sptr<Session>::MakeSptr(info);
263     EXPECT_NE(session02, nullptr);
264     EXPECT_NE(session03, nullptr);
265 
266     sptr<SessionStageMocker> mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
267     EXPECT_NE(nullptr, mockSessionStage);
268     session02->sessionStage_ = mockSessionStage;
269     session03->sessionStage_ = nullptr;
270 
271     session_->dialogVec_.push_back(session01);
272     session_->dialogVec_.push_back(session02);
273     session_->dialogVec_.push_back(session03);
274     session_->HandleDialogBackground();
275     session_->SetPendingSessionToBackgroundForDelegatorListener(nullptr);
276     EXPECT_EQ(WSError::WS_OK, session_->PendingSessionToBackgroundForDelegator(true));
277 }
278 
279 /**
280  * @tc.name: HandleDialogForeground
281  * @tc.desc: HandleDialogForeground Test
282  * @tc.type: FUNC
283  */
284 HWTEST_F(WindowSessionTest3, HandleDialogForeground, Function | SmallTest | Level2)
285 {
286     ASSERT_NE(session_, nullptr);
287     session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
288     ASSERT_NE(session_->property_, nullptr);
289     session_->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
290     session_->HandleDialogForeground();
291 
292     session_->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
293     sptr<Session> session01 = nullptr;
294 
295     SessionInfo info;
296     info.abilityName_ = "testSession1";
297     info.moduleName_ = "testSession2";
298     info.bundleName_ = "testSession3";
299     sptr<Session> session02 = sptr<Session>::MakeSptr(info);
300     sptr<Session> session03 = sptr<Session>::MakeSptr(info);
301     EXPECT_NE(session02, nullptr);
302     EXPECT_NE(session03, nullptr);
303 
304     sptr<SessionStageMocker> mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
305     EXPECT_NE(nullptr, mockSessionStage);
306     session02->sessionStage_ = mockSessionStage;
307     session03->sessionStage_ = nullptr;
308 
309     session_->dialogVec_.push_back(session01);
310     session_->dialogVec_.push_back(session02);
311     session_->dialogVec_.push_back(session03);
312     session_->HandleDialogForeground();
313     session_->SetPendingSessionToBackgroundForDelegatorListener(nullptr);
314     EXPECT_EQ(WSError::WS_OK, session_->PendingSessionToBackgroundForDelegator(true));
315 }
316 
317 /**
318  * @tc.name: SetActive
319  * @tc.desc: SetActive Test
320  * @tc.type: FUNC
321  */
322 HWTEST_F(WindowSessionTest3, SetActive, Function | SmallTest | Level2)
323 {
324     ASSERT_NE(session_, nullptr);
325     session_->SetSessionState(SessionState::STATE_CONNECT);
326     auto result = session_->SetActive(false);
327     EXPECT_EQ(result, WSError::WS_DO_NOTHING);
328 }
329 
330 /**
331  * @tc.name: SetActive02
332  * @tc.desc: SetActive Test
333  * @tc.type: FUNC
334  */
335 HWTEST_F(WindowSessionTest3, SetActive02, Function | SmallTest | Level2)
336 {
337     ASSERT_NE(session_, nullptr);
338     session_->SetSessionState(SessionState::STATE_FOREGROUND);
339     sptr<SessionStageMocker> mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
340     EXPECT_NE(nullptr, mockSessionStage);
341     session_->sessionStage_ = mockSessionStage;
342     auto result = session_->SetActive(true);
343     EXPECT_EQ(result, WSError::WS_OK);
344 }
345 
346 /**
347  * @tc.name: SetActive03
348  * @tc.desc: SetActive Test
349  * @tc.type: FUNC
350  */
351 HWTEST_F(WindowSessionTest3, SetActive03, Function | SmallTest | Level2)
352 {
353     ASSERT_NE(session_, nullptr);
354     sptr<SessionStageMocker> mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
355     EXPECT_NE(nullptr, mockSessionStage);
356     session_->sessionStage_ = mockSessionStage;
357 
358     session_->SetSessionState(SessionState::STATE_CONNECT);
359     auto result = session_->SetActive(true);
360     EXPECT_EQ(result, WSError::WS_OK);
361 
362     session_->isActive_ = true;
363     result = session_->SetActive(false);
364     EXPECT_EQ(result, WSError::WS_OK);
365 
366     session_->SetSessionState(SessionState::STATE_ACTIVE);
367     session_->isActive_ = true;
368     result = session_->SetActive(false);
369     EXPECT_EQ(result, WSError::WS_OK);
370 }
371 
372 /**
373  * @tc.name: IsTopDialog02
374  * @tc.desc: IsTopDialog Test
375  * @tc.type: FUNC
376  */
377 HWTEST_F(WindowSessionTest3, IsTopDialog02, Function | SmallTest | Level2)
378 {
379     ASSERT_NE(session_, nullptr);
380     session_->SetParentSession(nullptr);
381     EXPECT_EQ(false, session_->IsTopDialog());
382 
383     SessionInfo info;
384     info.abilityName_ = "testSession1";
385     info.moduleName_ = "testSession2";
386     info.bundleName_ = "testSession3";
387     sptr<Session> parentSession = sptr<Session>::MakeSptr(info);
388     ASSERT_NE(parentSession, nullptr);
389     parentSession->dialogVec_.clear();
390     session_->SetParentSession(parentSession);
391     auto result = session_->IsTopDialog();
392     EXPECT_EQ(result, true);
393 }
394 
395 /**
396  * @tc.name: IsTopDialog03
397  * @tc.desc: IsTopDialog Test
398  * @tc.type: FUNC
399  */
400 HWTEST_F(WindowSessionTest3, IsTopDialog03, Function | SmallTest | Level2)
401 {
402     ASSERT_NE(session_, nullptr);
403     session_->dialogVec_.clear();
404     SessionInfo info;
405     info.abilityName_ = "testSession1";
406     info.moduleName_ = "testSession2";
407     info.bundleName_ = "testSession3";
408     sptr<Session> dialogSession1 = sptr<Session>::MakeSptr(info);
409     sptr<Session> dialogSession2 = sptr<Session>::MakeSptr(info);
410     ASSERT_NE(dialogSession1, nullptr);
411     ASSERT_NE(dialogSession2, nullptr);
412     dialogSession1->SetParentSession(session_);
413     dialogSession2->SetParentSession(session_);
414     session_->dialogVec_.push_back(dialogSession1);
415     session_->dialogVec_.push_back(dialogSession2);
416     dialogSession1->SetSessionState(SessionState::STATE_INACTIVE);
417     dialogSession2->SetSessionState(SessionState::STATE_INACTIVE);
418     EXPECT_EQ(false, dialogSession1->IsTopDialog());
419 }
420 
421 /**
422  * @tc.name: PresentFocusIfPointDown
423  * @tc.desc: PresentFocusIfPointDown Test
424  * @tc.type: FUNC
425  */
426 HWTEST_F(WindowSessionTest3, PresentFocusIfPointDown, Function | SmallTest | Level2)
427 {
428     ASSERT_NE(session_, nullptr);
429     session_->isFocused_ = true;
430     session_->PresentFocusIfPointDown();
431 
432     session_->isFocused_ = false;
433     session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
434     EXPECT_NE(session_->property_, nullptr);
435     session_->property_->SetFocusable(false);
436     session_->PresentFocusIfPointDown();
437     session_->SetPendingSessionToBackgroundForDelegatorListener(nullptr);
438     EXPECT_EQ(WSError::WS_OK, session_->PendingSessionToBackgroundForDelegator(true));
439 }
440 
441 /**
442  * @tc.name: HandlePointDownDialog
443  * @tc.desc: HandlePointDownDialog Test
444  * @tc.type: FUNC
445  */
446 HWTEST_F(WindowSessionTest3, HandlePointDownDialog, Function | SmallTest | Level2)
447 {
448     ASSERT_NE(session_, nullptr);
449     SessionInfo info;
450     info.abilityName_ = "testSession1";
451     info.moduleName_ = "testSession2";
452     info.bundleName_ = "testSession3";
453     sptr<Session> dialogSession1 = sptr<Session>::MakeSptr(info);
454     sptr<Session> dialogSession2 = sptr<Session>::MakeSptr(info);
455     sptr<Session> dialogSession3 = sptr<Session>::MakeSptr(info);
456     sptr<Session> dialogSession4 = nullptr;
457     ASSERT_NE(dialogSession1, nullptr);
458     ASSERT_NE(dialogSession2, nullptr);
459     ASSERT_NE(dialogSession3, nullptr);
460     dialogSession1->SetSessionState(SessionState::STATE_FOREGROUND);
461     dialogSession2->SetSessionState(SessionState::STATE_ACTIVE);
462     dialogSession2->SetSessionState(SessionState::STATE_INACTIVE);
463     session_->dialogVec_.push_back(dialogSession1);
464     session_->dialogVec_.push_back(dialogSession2);
465     session_->dialogVec_.push_back(dialogSession3);
466     session_->dialogVec_.push_back(dialogSession4);
467     session_->HandlePointDownDialog();
468     session_->SetPendingSessionToBackgroundForDelegatorListener(nullptr);
469     EXPECT_EQ(WSError::WS_OK, session_->PendingSessionToBackgroundForDelegator(true));
470 }
471 
472 /**
473  * @tc.name: HandleSubWindowClick01
474  * @tc.desc: parentSession and property is nullptr
475  * @tc.type: FUNC
476  */
477 HWTEST_F(WindowSessionTest3, HandleSubWindowClick01, Function | SmallTest | Level2)
478 {
479     ASSERT_NE(session_, nullptr);
480     auto result = session_->HandleSubWindowClick(MMI::PointerEvent::POINTER_ACTION_DOWN);
481     EXPECT_EQ(result, WSError::WS_OK);
482 }
483 
484 /**
485  * @tc.name: HandleSubWindowClick03
486  * @tc.desc: parentSession->dialogVec_ is nullptr
487  * @tc.type: FUNC
488  */
489 HWTEST_F(WindowSessionTest3, HandleSubWindowClick03, Function | SmallTest | Level2)
490 {
491     ASSERT_NE(session_, nullptr);
492     SessionInfo info;
493     info.abilityName_ = "testSession1";
494     info.moduleName_ = "testSession2";
495     info.bundleName_ = "testSession3";
496     sptr<Session> dialogSession = sptr<Session>::MakeSptr(info);
497     ASSERT_NE(dialogSession, nullptr);
498     session_->SetParentSession(dialogSession);
499 
500     session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
501     ASSERT_NE(session_->property_, nullptr);
502 
503     auto result = session_->HandleSubWindowClick(MMI::PointerEvent::POINTER_ACTION_DOWN);
504     EXPECT_EQ(result, WSError::WS_OK);
505 
506     result = session_->HandleSubWindowClick(MMI::PointerEvent::POINTER_ACTION_MOVE);
507     EXPECT_EQ(result, WSError::WS_OK);
508 }
509 
510 /**
511  * @tc.name: TransferPointerEvent06
512  * @tc.desc: TransferPointerEvent Test
513  * @tc.type: FUNC
514  */
515 HWTEST_F(WindowSessionTest3, TransferPointerEvent06, Function | SmallTest | Level2)
516 {
517     ASSERT_NE(session_, nullptr);
518     session_->SetSessionState(SessionState::STATE_CONNECT);
519     std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
520     ASSERT_NE(pointerEvent, nullptr);
521 
522     SessionInfo info;
523     info.abilityName_ = "testSession1";
524     info.moduleName_ = "testSession2";
525     info.bundleName_ = "testSession3";
526     sptr<Session> dialogSession = sptr<Session>::MakeSptr(info);
527     ASSERT_NE(dialogSession, nullptr);
528     dialogSession->SetSessionState(SessionState::STATE_ACTIVE);
529     session_->dialogVec_.push_back(dialogSession);
530     pointerEvent->pointerAction_ = MMI::PointerEvent::POINTER_ACTION_DOWN;
531 
532     auto result = session_->TransferPointerEvent(pointerEvent);
533     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
534 }
535 
536 /**
537  * @tc.name: TransferPointerEvent07
538  * @tc.desc: TransferPointerEvent Test
539  * @tc.type: FUNC
540  */
541 HWTEST_F(WindowSessionTest3, TransferPointerEvent07, Function | SmallTest | Level2)
542 {
543     ASSERT_NE(session_, nullptr);
544     session_->SetSessionState(SessionState::STATE_CONNECT);
545     std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
546     ASSERT_NE(pointerEvent, nullptr);
547     session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
548     ASSERT_NE(session_->property_, nullptr);
549     session_->property_->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
550     auto result = session_->TransferPointerEvent(pointerEvent);
551     EXPECT_EQ(result, WSError::WS_ERROR_NULLPTR);
552 }
553 
554 /**
555  * @tc.name: TransferPointerEvent08
556  * @tc.desc: TransferPointerEvent Test
557  * @tc.type: FUNC
558  */
559 HWTEST_F(WindowSessionTest3, TransferPointerEvent08, Function | SmallTest | Level2)
560 {
561     ASSERT_NE(session_, nullptr);
562     session_->SetSessionState(SessionState::STATE_CONNECT);
563     std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
564     ASSERT_NE(pointerEvent, nullptr);
565 
566     session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
567     ASSERT_NE(session_->property_, nullptr);
568 
569     session_->property_->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
570     SessionInfo info;
571     info.abilityName_ = "testSession1";
572     info.moduleName_ = "testSession2";
573     info.bundleName_ = "testSession3";
574     sptr<Session> dialogSession = sptr<Session>::MakeSptr(info);
575     ASSERT_NE(dialogSession, nullptr);
576 
577     session_->SetParentSession(dialogSession);
578     auto result = session_->TransferPointerEvent(pointerEvent);
579     EXPECT_EQ(result, WSError::WS_ERROR_NULLPTR);
580 }
581 
582 /**
583  * @tc.name: TransferPointerEvent09
584  * @tc.desc: TransferPointerEvent Test
585  * @tc.type: FUNC
586  */
587 HWTEST_F(WindowSessionTest3, TransferPointerEvent09, Function | SmallTest | Level2)
588 {
589     ASSERT_NE(session_, nullptr);
590     session_->SetSessionState(SessionState::STATE_FOREGROUND);
591     std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
592     ASSERT_NE(pointerEvent, nullptr);
593 
594     session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
595     ASSERT_NE(session_->property_, nullptr);
596 
597     session_->property_->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
598     SessionInfo info;
599     info.abilityName_ = "testSession1";
600     info.moduleName_ = "testSession2";
601     info.bundleName_ = "testSession3";
602     sptr<Session> dialogSession = sptr<Session>::MakeSptr(info);
603     ASSERT_NE(dialogSession, nullptr);
604 
605     session_->SetParentSession(dialogSession);
606     dialogSession->dialogVec_.push_back(session_);
607     pointerEvent->pointerAction_ = MMI::PointerEvent::POINTER_ACTION_MOVE;
608     auto result = session_->TransferPointerEvent(pointerEvent);
609     EXPECT_EQ(result, WSError::WS_ERROR_NULLPTR);
610 }
611 
612 /**
613  * @tc.name: TransferPointerEvent10
614  * @tc.desc: TransferPointerEvent Test
615  * @tc.type: FUNC
616  */
617 HWTEST_F(WindowSessionTest3, TransferPointerEvent10, Function | SmallTest | Level2)
618 {
619     ASSERT_NE(session_, nullptr);
620     session_->SetSessionState(SessionState::STATE_FOREGROUND);
621     std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
622     ASSERT_NE(pointerEvent, nullptr);
623     pointerEvent->pointerAction_ = MMI::PointerEvent::POINTER_ACTION_DOWN;
624 
625     session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
626     ASSERT_NE(session_->property_, nullptr);
627     session_->property_->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
628 
629     SessionInfo info;
630     info.abilityName_ = "testSession1";
631     info.moduleName_ = "testSession2";
632     info.bundleName_ = "testSession3";
633     sptr<Session> dialogSession = sptr<Session>::MakeSptr(info);
634     sptr<Session> dialogSession2 = sptr<Session>::MakeSptr(info);
635     sptr<Session> dialogSession3 = sptr<Session>::MakeSptr(info);
636     ASSERT_NE(dialogSession, nullptr);
637     ASSERT_NE(dialogSession2, nullptr);
638     ASSERT_NE(dialogSession3, nullptr);
639     dialogSession2->SetSessionState(SessionState::STATE_FOREGROUND);
640     dialogSession3->SetSessionState(SessionState::STATE_ACTIVE);
641     dialogSession2->persistentId_ = 9;
642     session_->SetParentSession(dialogSession);
643     dialogSession->dialogVec_.push_back(dialogSession2);
644     dialogSession->dialogVec_.push_back(dialogSession3);
645     auto result = session_->TransferPointerEvent(pointerEvent);
646     EXPECT_EQ(result, WSError::WS_ERROR_NULLPTR);
647 }
648 
649 /**
650  * @tc.name: TransferPointerEvent11
651  * @tc.desc: TransferPointerEvent Test
652  * @tc.type: FUNC
653  */
654 HWTEST_F(WindowSessionTest3, TransferPointerEvent11, Function | SmallTest | Level2)
655 {
656     ASSERT_NE(session_, nullptr);
657     session_->SetSessionState(SessionState::STATE_FOREGROUND);
658     std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
659     ASSERT_NE(pointerEvent, nullptr);
660 
661     session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
662     ASSERT_NE(session_->property_, nullptr);
663     session_->property_->SetWindowType(WindowType::APP_WINDOW_BASE);
664 
665     session_->windowEventChannel_ = nullptr;
666     auto result = session_->TransferPointerEvent(pointerEvent);
667     EXPECT_EQ(result, WSError::WS_ERROR_NULLPTR);
668 }
669 
670 /**
671  * @tc.name: TransferFocusStateEvent03
672  * @tc.desc: TransferFocusStateEvent Test
673  * @tc.type: FUNC
674  */
675 HWTEST_F(WindowSessionTest3, TransferFocusStateEvent03, Function | SmallTest | Level2)
676 {
677     ASSERT_NE(session_, nullptr);
678     session_->windowEventChannel_ = nullptr;
679     session_->sessionInfo_.isSystem_ = true;
680     EXPECT_EQ(session_->TransferFocusStateEvent(true), WSError::WS_ERROR_NULLPTR);
681 }
682 
683 /**
684  * @tc.name: Snapshot
685  * @tc.desc: Snapshot Test
686  * @tc.type: FUNC
687  */
688 HWTEST_F(WindowSessionTest3, Snapshot, Function | SmallTest | Level2)
689 {
690     ASSERT_NE(session_, nullptr);
691     int32_t persistentId = 1424;
692     std::string bundleName = "testBundleName";
693     session_->scenePersistence_ = sptr<ScenePersistence>::MakeSptr(bundleName, persistentId);
694     ASSERT_NE(session_->scenePersistence_, nullptr);
695     struct RSSurfaceNodeConfig config;
696     session_->surfaceNode_ = RSSurfaceNode::Create(config);
697     ASSERT_NE(session_->surfaceNode_, nullptr);
698     EXPECT_EQ(nullptr, session_->Snapshot(false, 0.0f));
699 
700     session_->bufferAvailable_ = true;
701     EXPECT_EQ(nullptr, session_->Snapshot(false, 0.0f));
702 
703     session_->surfaceNode_->bufferAvailable_ = true;
704     EXPECT_EQ(nullptr, session_->Snapshot(false, 0.0f));
705 
706     session_->surfaceNode_ = nullptr;
707     EXPECT_EQ(nullptr, session_->Snapshot(false, 0.0f));
708 }
709 
710 /**
711  * @tc.name: SetBufferAvailableChangeListener
712  * @tc.desc: SetBufferAvailableChangeListener Test
713  * @tc.type: FUNC
714  */
715 HWTEST_F(WindowSessionTest3, SetBufferAvailableChangeListener, Function | SmallTest | Level2)
716 {
717     session_->SetSessionState(SessionState::STATE_CONNECT);
718     session_->SetSessionStateChangeNotifyManagerListener(nullptr);
719 
720     session_->bufferAvailable_ = true;
721     session_->SetBufferAvailableChangeListener(nullptr);
722 
723     int resultValue = 0;
__anon8615d2720402(const bool isAvailable) 724     NotifyBufferAvailableChangeFunc func = [&resultValue](const bool isAvailable) {
725         resultValue += 1;
726     };
727     session_->SetBufferAvailableChangeListener(func);
728     EXPECT_EQ(resultValue, 1);
729 }
730 
731 /**
732  * @tc.name: NotifySessionFocusableChange
733  * @tc.desc: NotifySessionFocusableChange Test
734  * @tc.type: FUNC
735  */
736 HWTEST_F(WindowSessionTest3, NotifySessionFocusableChange, Function | SmallTest | Level2)
737 {
738     int resultValue = 0;
__anon8615d2720502(const bool isFocusable) 739     NotifySessionFocusableChangeFunc func = [&resultValue](const bool isFocusable) {
740         resultValue += 1;
741     };
742     session_->SetSessionFocusableChangeListener(func);
743     session_->NotifySessionFocusableChange(true);
744     EXPECT_EQ(resultValue, 2);
745 }
746 
747 /**
748  * @tc.name: GetStateFromManager
749  * @tc.desc: GetStateFromManager Test
750  * @tc.type: FUNC
751  */
752 HWTEST_F(WindowSessionTest3, GetStateFromManager, Function | SmallTest | Level2)
753 {
754     ManagerState key = ManagerState{0};
__anon8615d2720602(const ManagerState key) 755     GetStateFromManagerFunc func = [](const ManagerState key) {
756         return true;
757     };
758     session_->getStateFromManagerFunc_ = func;
759     session_->GetStateFromManager(key);
760 
761     session_->getStateFromManagerFunc_ = nullptr;
762     ASSERT_EQ(false, session_->GetStateFromManager(key));
763 
764     // 覆盖default分支
765     key = ManagerState{-1};
766     ASSERT_EQ(false, session_->GetStateFromManager(key));
767 }
768 
769 /**
770  * @tc.name: NotifyUIRequestFocus
771  * @tc.desc: NotifyUIRequestFocus Test
772  * @tc.type: FUNC
773  */
774 HWTEST_F(WindowSessionTest3, NotifyUIRequestFocus, Function | SmallTest | Level2)
775 {
__anon8615d2720702() 776     session_->requestFocusFunc_ = []() {};
777     session_->NotifyUIRequestFocus();
778 
779     ASSERT_NE(session_, nullptr);
780 }
781 
782 /**
783  * @tc.name: SetCompatibleModeInPc
784  * @tc.desc: SetCompatibleModeInPc Test
785  * @tc.type: FUNC
786  */
787 HWTEST_F(WindowSessionTest3, SetCompatibleModeInPc, Function | SmallTest | Level2)
788 {
789     session_->property_ = nullptr;
790     auto enable = true;
791     auto isSupportDragInPcCompatibleMode = true;
792     ASSERT_EQ(WSError::WS_ERROR_NULLPTR, session_->SetCompatibleModeInPc(enable, isSupportDragInPcCompatibleMode));
793 
794     session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
795     ASSERT_EQ(WSError::WS_OK, session_->SetCompatibleModeInPc(enable, isSupportDragInPcCompatibleMode));
796 
797     enable = false;
798     ASSERT_EQ(WSError::WS_OK, session_->SetCompatibleModeInPc(enable, isSupportDragInPcCompatibleMode));
799 }
800 
801 /**
802  * @tc.name: NotifySessionTouchableChange
803  * @tc.desc: NotifySessionTouchableChange Test
804  * @tc.type: FUNC
805  */
806 HWTEST_F(WindowSessionTest3, NotifySessionTouchableChange, Function | SmallTest | Level2)
807 {
808     int resultValue = 0;
__anon8615d2720802(const bool touchable) 809     NotifySessionTouchableChangeFunc func = [&resultValue](const bool touchable) {
810         resultValue += 1;
811     };
812     session_->SetSessionTouchableChangeListener(func);
813     session_->NotifySessionTouchableChange(true);
814     EXPECT_EQ(resultValue, 2);
815 }
816 
817 /**
818  * @tc.name: NotifyClick
819  * @tc.desc: NotifyClick Test
820  * @tc.type: FUNC
821  */
822 HWTEST_F(WindowSessionTest3, NotifyClick, Function | SmallTest | Level2)
823 {
824     ASSERT_NE(session_, nullptr);
825     int resultValue = 0;
__anon8615d2720902() 826     NotifyClickFunc func = [&resultValue]() {
827         resultValue += 1;
828     };
829     session_->SetClickListener(func);
830     session_->NotifyClick();
831     EXPECT_EQ(resultValue, 1);
832 }
833 
834 /**
835  * @tc.name: NotifyRequestFocusStatusNotifyManager
836  * @tc.desc: NotifyRequestFocusStatusNotifyManager Test
837  * @tc.type: FUNC
838  */
839 HWTEST_F(WindowSessionTest3, NotifyRequestFocusStatusNotifyManager, Function | SmallTest | Level2)
840 {
841     ASSERT_NE(session_, nullptr);
842     int resultValue = 0;
843     NotifyRequestFocusStatusNotifyManagerFunc func = [&resultValue](int32_t persistentId,
__anon8615d2720a02(int32_t persistentId, const bool isFocused, const bool byForeground, FocusChangeReason reason) 844         const bool isFocused, const bool byForeground, FocusChangeReason reason) {
845         resultValue += 1;
846     };
847     session_->SetRequestFocusStatusNotifyManagerListener(func);
848     FocusChangeReason reason = FocusChangeReason::SCB_SESSION_REQUEST;
849     session_->NotifyRequestFocusStatusNotifyManager(true, false, reason);
850     EXPECT_EQ(resultValue, 1);
851 }
852 
853 /**
854  * @tc.name: PresentFoucusIfNeed
855  * @tc.desc: PresentFoucusIfNeed Test
856  * @tc.type: FUNC
857  */
858 HWTEST_F(WindowSessionTest3, PresentFoucusIfNeed, Function | SmallTest | Level2)
859 {
860     ASSERT_NE(session_, nullptr);
861     int32_t pointerAction = MMI::PointerEvent::POINTER_ACTION_DOWN;
862     session_->PresentFoucusIfNeed(pointerAction);
863     pointerAction = MMI::PointerEvent::POINTER_ACTION_BUTTON_DOWN;
864     session_->PresentFoucusIfNeed(pointerAction);
865     session_->property_->focusable_ = false;
866     session_->PresentFoucusIfNeed(pointerAction);
867     session_->isFocused_ = true;
868     session_->PresentFoucusIfNeed(pointerAction);
869     EXPECT_EQ(true, session_->CheckPointerEventDispatch(nullptr));
870 }
871 
872 /**
873  * @tc.name: UpdateFocus03
874  * @tc.desc: UpdateFocus Test
875  * @tc.type: FUNC
876  */
877 HWTEST_F(WindowSessionTest3, UpdateFocus03, Function | SmallTest | Level2)
878 {
879     ASSERT_NE(session_, nullptr);
880     session_->isFocused_ = true;
881     EXPECT_EQ(WSError::WS_OK, session_->UpdateFocus(false));
882 }
883 
884 /**
885  * @tc.name: NotifyFocusStatus
886  * @tc.desc: NotifyFocusStatus Test
887  * @tc.type: FUNC
888  */
889 HWTEST_F(WindowSessionTest3, NotifyFocusStatus, Function | SmallTest | Level2)
890 {
891     ASSERT_NE(session_, nullptr);
892     session_->state_ = SessionState::STATE_CONNECT;
893     sptr<SessionStageMocker> mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
894     EXPECT_NE(nullptr, mockSessionStage);
895     session_->sessionStage_ = mockSessionStage;
896     EXPECT_EQ(WSError::WS_OK, session_->NotifyFocusStatus(true));
897 }
898 
899 /**
900  * @tc.name: RequestFocus
901  * @tc.desc: RequestFocus Test
902  * @tc.type: FUNC
903  */
904 HWTEST_F(WindowSessionTest3, RequestFocus, Function | SmallTest | Level2)
905 {
906     ASSERT_NE(session_, nullptr);
907     session_->state_ = SessionState::STATE_FOREGROUND;
908     session_->sessionInfo_.isSystem_ = false;
909     EXPECT_EQ(WSError::WS_OK, session_->RequestFocus(true));
910     EXPECT_EQ(WSError::WS_OK, session_->RequestFocus(false));
911 }
912 
913 /**
914  * @tc.name: UpdateWindowMode
915  * @tc.desc: UpdateWindowMode Test
916  * @tc.type: FUNC
917  */
918 HWTEST_F(WindowSessionTest3, UpdateWindowMode, Function | SmallTest | Level2)
919 {
920     ASSERT_NE(session_, nullptr);
921     sptr<SessionStageMocker> mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
922     EXPECT_NE(nullptr, mockSessionStage);
923     session_->sessionStage_ = mockSessionStage;
924 
925     session_->state_ = SessionState::STATE_END;
926     auto result = session_->UpdateWindowMode(WindowMode::WINDOW_MODE_UNDEFINED);
927     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_SESSION);
928 
929     session_->state_ = SessionState::STATE_DISCONNECT;
930     result = session_->UpdateWindowMode(WindowMode::WINDOW_MODE_UNDEFINED);
931     EXPECT_EQ(session_->property_->windowMode_, WindowMode::WINDOW_MODE_UNDEFINED);
932     EXPECT_EQ(session_->property_->isNeedUpdateWindowMode_, true);
933     EXPECT_EQ(result, WSError::WS_OK);
934 
935     session_->state_ = SessionState::STATE_CONNECT;
936     result = session_->UpdateWindowMode(WindowMode::WINDOW_MODE_SPLIT_SECONDARY);
937     EXPECT_EQ(session_->property_->windowMode_, WindowMode::WINDOW_MODE_SPLIT_SECONDARY);
938     EXPECT_EQ(session_->property_->maximizeMode_, MaximizeMode::MODE_RECOVER);
939     EXPECT_EQ(result, WSError::WS_OK);
940 
941     session_->state_ = SessionState::STATE_CONNECT;
942     result = session_->UpdateWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY);
943     EXPECT_EQ(result, WSError::WS_OK);
944 
945     session_->state_ = SessionState::STATE_CONNECT;
946     result = session_->UpdateWindowMode(WindowMode::WINDOW_MODE_UNDEFINED);
947     EXPECT_EQ(result, WSError::WS_OK);
948 }
949 
950 /**
951  * @tc.name: RectSizeCheckProcess
952  * @tc.desc: RectSizeCheckProcess Test
953  * @tc.type: FUNC
954  */
955 HWTEST_F(WindowSessionTest3, RectSizeCheckProcess, Function | SmallTest | Level2)
956 {
957     ASSERT_NE(session_, nullptr);
958     session_->RectSizeCheckProcess(1, 0, 2, 0, 0);
959     session_->RectSizeCheckProcess(1, 0, 1, 0, 0);
960     session_->RectSizeCheckProcess(0, 1, 0, 2, 0);
961     session_->RectSizeCheckProcess(0, 1, 0, 0, 0);
962     EXPECT_EQ(true, session_->CheckPointerEventDispatch(nullptr));
963 }
964 
965 /**
966  * @tc.name: RectCheckProcess
967  * @tc.desc: RectCheckProcess Test
968  * @tc.type: FUNC
969  */
970 HWTEST_F(WindowSessionTest3, RectCheckProcess, Function | SmallTest | Level2)
971 {
972     ASSERT_NE(session_, nullptr);
973     session_->isVisible_ = true;
974     session_->property_ = nullptr;
975     session_->RectCheckProcess();
976 
977     session_->state_ = SessionState::STATE_FOREGROUND;
978     session_->property_ = nullptr;
979     session_->RectCheckProcess();
980     EXPECT_EQ(true, session_->CheckPointerEventDispatch(nullptr));
981 }
982 
983 /**
984  * @tc.name: SetAcquireRotateAnimationConfigFunc
985  * @tc.desc: SetAcquireRotateAnimationConfigFunc Test
986  * @tc.type: FUNC
987  */
988 HWTEST_F(WindowSessionTest3, SetAcquireRotateAnimationConfigFunc, Function | SmallTest | Level2)
989 {
990     ASSERT_NE(session_, nullptr);
991     session_->SetAcquireRotateAnimationConfigFunc(nullptr);
992     ASSERT_EQ(session_->acquireRotateAnimationConfigFunc_, nullptr);
993     int32_t duration = session_->GetRotateAnimationDuration();
994     ASSERT_EQ(duration, ROTATE_ANIMATION_DURATION);
995 
__anon8615d2720b02(RotateAnimationConfig& config) 996     AcquireRotateAnimationConfigFunc func = [](RotateAnimationConfig& config) {
997         config.duration_ = 800;
998     };
999     session_->SetAcquireRotateAnimationConfigFunc(func);
1000     ASSERT_NE(session_->acquireRotateAnimationConfigFunc_, nullptr);
1001     duration = session_->GetRotateAnimationDuration();
1002     ASSERT_EQ(duration, 800);
1003 }
1004 
1005 /**
1006  * @tc.name: SetIsPcAppInPad
1007  * @tc.desc: SetIsPcAppInPad Test
1008  * @tc.type: FUNC
1009  */
1010 HWTEST_F(WindowSessionTest3, SetIsPcAppInPad, Function | SmallTest | Level2)
1011 {
1012     ASSERT_NE(session_, nullptr);
1013     bool isPcAppInPad = false;
1014     session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
1015     auto result = session_->SetIsPcAppInPad(isPcAppInPad);
1016     EXPECT_EQ(result, WSError::WS_OK);
1017 
1018     session_->property_ = nullptr;
1019     EXPECT_EQ(WSError::WS_ERROR_NULLPTR, session_->SetIsPcAppInPad(isPcAppInPad));
1020 }
1021 
1022 /**
1023  * @tc.name: SetBufferAvailable
1024  * @tc.desc: SetBufferAvailable Test
1025  * @tc.type: FUNC
1026  */
1027 HWTEST_F(WindowSessionTest3, SetBufferAvailable, Function | SmallTest | Level2)
1028 {
1029     int resultValue = 0;
__anon8615d2720c02(const bool isAvailable) 1030     NotifyBufferAvailableChangeFunc func = [&resultValue](const bool isAvailable) {
1031         resultValue = 1;
1032     };
1033     session_->SetBufferAvailableChangeListener(func);
1034     session_->SetBufferAvailable(true);
1035     ASSERT_EQ(session_->bufferAvailable_, true);
1036 }
1037 
1038 /**
1039  * @tc.name: NotifySessionInfoChange
1040  * @tc.desc: NotifySessionInfoChange Test
1041  * @tc.type: FUNC
1042  */
1043 HWTEST_F(WindowSessionTest3, NotifySessionInfoChange, Function | SmallTest | Level2)
1044 {
1045     int resultValue = 0;
__anon8615d2720d02(const bool isAvailable) 1046     NotifyBufferAvailableChangeFunc func = [&resultValue](const bool isAvailable) {
1047         resultValue = 1;
1048     };
1049     session_->SetSessionInfoChangeNotifyManagerListener(func);
1050     session_->NotifySessionInfoChange();
1051     ASSERT_EQ(resultValue, 1);
1052 }
1053 
1054 /**
1055  * @tc.name: RectSizeCheckProcess01
1056  * @tc.desc: RectSizeCheckProcess Test
1057  * @tc.type: FUNC
1058  */
1059 HWTEST_F(WindowSessionTest3, RectSizeCheckProcess01, Function | SmallTest | Level2)
1060 {
1061     session_->SetSessionProperty(nullptr);
1062     session_->RectSizeCheckProcess(1, 1, 2, 2, 0);
1063     ASSERT_EQ(session_->property_, nullptr);
1064 }
1065 
1066 /**
1067  * @tc.name: SetCompatibleModeEnableInPad
1068  * @tc.desc: SetCompatibleModeEnableInPad Test
1069  * @tc.type: FUNC
1070  */
1071 HWTEST_F(WindowSessionTest3, SetCompatibleModeEnableInPad, Function | SmallTest | Level2)
1072 {
1073     ASSERT_NE(session_, nullptr);
1074     session_->state_ = SessionState::STATE_FOREGROUND;
1075     sptr<SessionStageMocker> mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
1076     EXPECT_NE(nullptr, mockSessionStage);
1077     session_->sessionStage_ = mockSessionStage;
1078     session_->property_ = nullptr;
1079     bool enable = true;
1080     ASSERT_EQ(WSError::WS_ERROR_NULLPTR, session_->SetCompatibleModeEnableInPad(enable));
1081 
1082     session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
1083     ASSERT_EQ(WSError::WS_OK, session_->SetCompatibleModeEnableInPad(enable));
1084 
1085     enable = false;
1086     ASSERT_EQ(WSError::WS_OK, session_->SetCompatibleModeEnableInPad(enable));
1087 }
1088 
1089 /**
1090  * @tc.name: SetStartingBeforeVisible
1091  * @tc.desc: test SetStartingBeforeVisible
1092  * @tc.type: FUNC
1093  */
1094 HWTEST_F(WindowSessionTest3, SetStartingBeforeVisible, Function | SmallTest | Level2)
1095 {
1096     ASSERT_NE(session_, nullptr);
1097     session_->SetStartingBeforeVisible(true);
1098     ASSERT_EQ(true, session_->isStartingBeforeVisible_);
1099     ASSERT_EQ(true, session_->GetStartingBeforeVisible());
1100 
1101     session_->SetStartingBeforeVisible(false);
1102     ASSERT_EQ(false, session_->isStartingBeforeVisible_);
1103     ASSERT_EQ(false, session_->GetStartingBeforeVisible());
1104 }
1105 
1106 /**
1107  * @tc.name: GetIsMidScene
1108  * @tc.desc: GetIsMidScene Test
1109  * @tc.type: FUNC
1110  */
1111 HWTEST_F(WindowSessionTest3, GetIsMidScene, Function | SmallTest | Level2)
1112 {
1113     ASSERT_NE(session_, nullptr);
1114     bool isMidScene = false;
1115     auto result = session_->GetIsMidScene(isMidScene);
1116     ASSERT_EQ(result, WSError::WS_OK);
1117     ASSERT_EQ(isMidScene, false);
1118 }
1119 
1120 /**
1121  * @tc.name: SetFreezeImmediately
1122  * @tc.desc: SetFreezeImmediately Test
1123  * @tc.type: FUNC
1124  */
1125 HWTEST_F(WindowSessionTest3, SetFreezeImmediately, Function | SmallTest | Level2)
1126 {
1127     ASSERT_NE(session_, nullptr);
1128     struct RSSurfaceNodeConfig config;
1129     session_->surfaceNode_ = RSSurfaceNode::Create(config);
1130     ASSERT_NE(session_->surfaceNode_, nullptr);
1131     ASSERT_EQ(nullptr, session_->SetFreezeImmediately(1.0f, false));
1132     session_->surfaceNode_->bufferAvailable_ = true;
1133     ASSERT_EQ(nullptr, session_->SetFreezeImmediately(1.0f, false));
1134     ASSERT_EQ(nullptr, session_->SetFreezeImmediately(1.0f, true));
1135     session_->surfaceNode_ = nullptr;
1136     ASSERT_EQ(nullptr, session_->SetFreezeImmediately(1.0f, false));
1137 }
1138 }
1139 } // namespace Rosen
1140 } // namespace OHOS