• 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 #include "window_helper.h"
16 #include "display_manager.h"
17 #include "pointer_event.h"
18 
19 #include <gtest/gtest.h>
20 #include "key_event.h"
21 #include "session/host/include/scene_session.h"
22 #include "session/host/include/sub_session.h"
23 #include "session/host/include/system_session.h"
24 #include "session/host/include/main_session.h"
25 #include "wm_common.h"
26 #include "mock/mock_session_stage.h"
27 #include "input_event.h"
28 #include <pointer_event.h>
29 #include "ui/rs_surface_node.h"
30 
31 using namespace testing;
32 using namespace testing::ext;
33 namespace OHOS {
34 namespace Rosen {
35 class SceneSessionTest2 : public testing::Test {
36 public:
37     static void SetUpTestCase();
38     static void TearDownTestCase();
39     void SetUp() override;
40     void TearDown() override;
41 };
42 
SetUpTestCase()43 void SceneSessionTest2::SetUpTestCase()
44 {
45 }
46 
TearDownTestCase()47 void SceneSessionTest2::TearDownTestCase()
48 {
49 }
50 
SetUp()51 void SceneSessionTest2::SetUp()
52 {
53 }
54 
TearDown()55 void SceneSessionTest2::TearDown()
56 {
57 }
58 
59 namespace {
60 /**
61  * @tc.name: RaiseAboveTarget
62  * @tc.desc: normal function
63  * @tc.type: FUNC
64  */
65 HWTEST_F(SceneSessionTest2, RaiseAboveTarget, Function | SmallTest | Level2)
66 {
67     SessionInfo info;
68     info.abilityName_ = "RaiseAboveTarget";
69     info.bundleName_ = "RaiseAboveTarget";
70     sptr<Rosen::ISession> session_;
71     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
72         new (std::nothrow) SceneSession::SpecificSessionCallback();
73     EXPECT_NE(specificCallback_, nullptr);
74     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
75     EXPECT_NE(sceneSession, nullptr);
76     sceneSession->isActive_ = true;
77 
78     sptr<WindowSessionProperty> property = new(std::nothrow) WindowSessionProperty();
79     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
80     property->keyboardLayoutParams_.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM;
81 
82     sceneSession->SetSessionProperty(property);
83     WSError result = sceneSession->RaiseAboveTarget(0);
84     ASSERT_EQ(result, WSError::WS_OK);
85 
86     sceneSession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback();
87     EXPECT_NE(sceneSession->sessionChangeCallback_, nullptr);
88     sceneSession->sessionChangeCallback_->onRaiseAboveTarget_ = nullptr;
89     result = sceneSession->RaiseAboveTarget(0);
90     ASSERT_EQ(result, WSError::WS_OK);
91 }
92 
93 /**
94  * @tc.name: BindDialogSessionTarget
95  * @tc.desc: normal function
96  * @tc.type: FUNC
97  */
98 HWTEST_F(SceneSessionTest2, BindDialogSessionTarget, Function | SmallTest | Level2)
99 {
100     SessionInfo info;
101     info.abilityName_ = "BindDialogSessionTarget";
102     info.bundleName_ = "BindDialogSessionTarget";
103     sptr<Rosen::ISession> session_;
104     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
105         new (std::nothrow) SceneSession::SpecificSessionCallback();
106     EXPECT_NE(specificCallback_, nullptr);
107     sptr<SceneSession> scensession = new (std::nothrow) SceneSession(info, nullptr);
108     EXPECT_NE(scensession, nullptr);
109     scensession->isActive_ = true;
110 
111     sptr<WindowSessionProperty> property = new(std::nothrow) WindowSessionProperty();
112     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
113     property->keyboardLayoutParams_.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM;
114     scensession->SetSessionProperty(property);
115 
116     sptr<SceneSession> sceneSession = nullptr;
117     WSError result = scensession->BindDialogSessionTarget(sceneSession);
118     ASSERT_EQ(result, WSError::WS_ERROR_NULLPTR);
119 
120     sptr<SceneSession> sceneSession1 = scensession;
121     result = scensession->BindDialogSessionTarget(sceneSession1);
122     ASSERT_EQ(result, WSError::WS_OK);
123 }
124 
125 /**
126  * @tc.name: NotifyPropertyWhenConnect1
127  * @tc.desc: NotifyPropertyWhenConnect1
128  * @tc.type: FUNC
129  */
130 HWTEST_F(SceneSessionTest2, NotifyPropertyWhenConnect1, Function | SmallTest | Level2)
131 {
132     SessionInfo info;
133     info.abilityName_ = "ability";
134     info.bundleName_ = "bundle";
135     info.moduleName_ = "module";
136     info.windowType_ = 1;
137     sptr<Rosen::ISession> session_;
138     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
139         new (std::nothrow) SceneSession::SpecificSessionCallback();
140     EXPECT_NE(specificCallback_, nullptr);
141     sptr<SceneSession> scensession;
142     scensession = new (std::nothrow) SceneSession(info, nullptr);
143     EXPECT_NE(scensession, nullptr);
144     int ret = 1;
145     std::string key = info.bundleName_ + info.moduleName_ + info.abilityName_;
146     scensession = new (std::nothrow) SceneSession(info, specificCallback_);
147     scensession->NotifyPropertyWhenConnect();
148 
149     sptr<WindowSessionProperty> property = nullptr;
150     scensession->NotifyPropertyWhenConnect();
151     ASSERT_EQ(ret, 1);
152 }
153 
154 /**
155  * @tc.name: GetSystemAvoidArea
156  * @tc.desc: normal function
157  * @tc.type: FUNC
158  */
159 HWTEST_F(SceneSessionTest2, GetSystemAvoidArea, Function | SmallTest | Level2)
160 {
161     SessionInfo info;
162     info.abilityName_ = "GetSystemAvoidArea";
163     info.bundleName_ = "GetSystemAvoidArea";
164     sptr<Rosen::ISession> session_;
165     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
166         new (std::nothrow) SceneSession::SpecificSessionCallback();
167     EXPECT_NE(specificCallback_, nullptr);
168     sptr<SceneSession> scensession = new (std::nothrow) SceneSession(info, nullptr);
169     EXPECT_NE(scensession, nullptr);
170     scensession->isActive_ = true;
171 
172     sptr<WindowSessionProperty> property = new(std::nothrow) WindowSessionProperty();
173     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
174     int32_t p = 10;
175     property->SetWindowFlags(static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_NEED_AVOID));
176 
177     scensession->SetSessionProperty(property);
178     WSRect rect({1, 1, 1, 1});
179     AvoidArea avoidArea;
180     scensession->GetSystemAvoidArea(rect, avoidArea);
181     ASSERT_EQ(p, 10);
182 }
183 
184 /**
185  * @tc.name: HandleEnterWinwdowArea1
186  * @tc.desc: normal function
187  * @tc.type: FUNC
188  */
189 HWTEST_F(SceneSessionTest2, HandleEnterWinwdowArea1, Function | SmallTest | Level2)
190 {
191     SessionInfo info;
192     info.abilityName_ = "HandleEnterWinwdowArea1";
193     info.bundleName_ = "HandleEnterWinwdowArea1";
194     sptr<Rosen::ISession> session_;
195     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
196         new (std::nothrow) SceneSession::SpecificSessionCallback();
197     EXPECT_NE(specificCallback_, nullptr);
198     sptr<SceneSession> scensession = new (std::nothrow) SceneSession(info, nullptr);
199     EXPECT_NE(scensession, nullptr);
200     scensession->isActive_ = true;
201 
202     sptr<WindowSessionProperty> property = new(std::nothrow) WindowSessionProperty();
203     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
204     property->SetWindowFlags(static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_NEED_AVOID));
205 
206     scensession->SetSessionProperty(property);
207     WSError result = scensession->HandleEnterWinwdowArea(-1, -1);
208     ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PARAM);
209 
210     result = scensession->HandleEnterWinwdowArea(1, -1);
211     ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PARAM);
212 
213     result = scensession->HandleEnterWinwdowArea(-1, 1);
214     ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PARAM);
215 }
216 
217 /**
218  * @tc.name: HandleEnterWinwdowArea2
219  * @tc.desc: normal function
220  * @tc.type: FUNC
221  */
222 HWTEST_F(SceneSessionTest2, HandleEnterWinwdowArea2, Function | SmallTest | Level2)
223 {
224     SessionInfo info;
225     info.abilityName_ = "HandleEnterWinwdowArea2";
226     info.bundleName_ = "HandleEnterWinwdowArea2";
227     sptr<Rosen::ISession> session_;
228     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
229         new (std::nothrow) SceneSession::SpecificSessionCallback();
230     EXPECT_NE(specificCallback_, nullptr);
231     sptr<SceneSession> scensession = new (std::nothrow) SceneSession(info, nullptr);
232     EXPECT_NE(scensession, nullptr);
233     scensession->isActive_ = true;
234 
235     sptr<WindowSessionProperty> property = new(std::nothrow) WindowSessionProperty();
236     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
237     property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
238     scensession->SetSessionProperty(property);
239     WSError result = scensession->HandleEnterWinwdowArea(1, 1);
240     ASSERT_EQ(result, WSError::WS_OK);
241 
242     scensession->sessionInfo_.isSystem_ = true;
243     result = scensession->HandleEnterWinwdowArea(1, 1);
244     result = scensession->HandleEnterWinwdowArea(1, 1);
245     ASSERT_EQ(result, WSError::WS_OK);
246 
247     property = new(std::nothrow) WindowSessionProperty();
248     property->SetWindowType(WindowType::ABOVE_APP_SYSTEM_WINDOW_END);
249     property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
250     scensession->SetSessionProperty(property);
251     result = scensession->HandleEnterWinwdowArea(1, 1);
252     ASSERT_EQ(result, WSError::WS_ERROR_INVALID_TYPE);
253 
254     property = new(std::nothrow) WindowSessionProperty();
255     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
256     property->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
257     scensession->SetSessionProperty(property);
258     result = scensession->HandleEnterWinwdowArea(1, 1);
259     ASSERT_EQ(result, WSError::WS_ERROR_INVALID_TYPE);
260 
261     property = new(std::nothrow) WindowSessionProperty();
262     property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
263     property->SetWindowMode(WindowMode::WINDOW_MODE_UNDEFINED);
264     scensession->SetSessionProperty(property);
265     result = scensession->HandleEnterWinwdowArea(1, 1);
266     ASSERT_EQ(result, WSError::WS_ERROR_INVALID_TYPE);
267 }
268 
269 /**
270  * @tc.name: TransferPointerEvent
271  * @tc.desc: TransferPointerEvent
272  * @tc.type: FUNC
273  */
274 HWTEST_F(SceneSessionTest2, TransferPointerEvent01, Function | SmallTest | Level2)
275 {
276     SessionInfo info;
277     info.abilityName_ = "Background01";
278     info.bundleName_ = "IsFloatingWindowAppType";
279     info.windowType_ = 1;
280     sptr<Rosen::ISession> session_;
281     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
282         new (std::nothrow) SceneSession::SpecificSessionCallback();
283     EXPECT_NE(specificCallback_, nullptr);
284     sptr<SceneSession> scensession;
285     scensession = new (std::nothrow) SceneSession(info, specificCallback_);
286     EXPECT_NE(scensession, nullptr);
287     std::shared_ptr<MMI::PointerEvent> pointerEvent = nullptr;
288     ASSERT_EQ(scensession->TransferPointerEvent(pointerEvent), WSError::WS_ERROR_NULLPTR);
289 
290     sptr<WindowSessionProperty> property = new WindowSessionProperty();
291     property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
292     property->SetMaximizeMode(MaximizeMode::MODE_FULL_FILL);
293     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
294     property->SetPersistentId(11);
295     scensession->property_ = property;
296 
297     std::shared_ptr<MMI::PointerEvent> pointerEvent_ = MMI::PointerEvent::Create();
298     pointerEvent_->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_ENTER_WINDOW);
299     ASSERT_EQ(scensession->TransferPointerEvent(pointerEvent_), WSError::WS_ERROR_INVALID_SESSION);
300 
301     scensession->sessionInfo_.isSystem_ = true;
302     pointerEvent_->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_BUTTON_DOWN);
303     ASSERT_EQ(scensession->TransferPointerEvent(pointerEvent_),
304     WSError::WS_ERROR_NULLPTR);
305 
306     pointerEvent_->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_ENTER_WINDOW);
307     ASSERT_EQ(scensession->TransferPointerEvent(pointerEvent_),
308     WSError::WS_ERROR_NULLPTR);
309 
310     scensession->sessionInfo_.isSystem_ = false;
311     pointerEvent_->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_BUTTON_DOWN);
312     ASSERT_EQ(scensession->TransferPointerEvent(pointerEvent_),
313     WSError::WS_ERROR_INVALID_SESSION);
314 
315     pointerEvent_->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_ENTER_WINDOW);
316     ASSERT_EQ(scensession->TransferPointerEvent(pointerEvent_),
317     WSError::WS_ERROR_INVALID_SESSION);
318 }
319 
320 /**
321  * @tc.name: TransferPointerEvent
322  * @tc.desc: TransferPointerEvent
323  * @tc.type: FUNC
324  */
325 HWTEST_F(SceneSessionTest2, TransferPointerEvent02, Function | SmallTest | Level2)
326 {
327     SessionInfo info;
328     info.abilityName_ = "Background01";
329     info.bundleName_ = "IsSubWindowAppType";
330     info.windowType_ = 1;
331     sptr<Rosen::ISession> session_;
332     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
333         new (std::nothrow) SceneSession::SpecificSessionCallback();
334     EXPECT_NE(specificCallback_, nullptr);
335     sptr<SceneSession> scensession;
336     scensession = new (std::nothrow) SceneSession(info, specificCallback_);
337     EXPECT_NE(scensession, nullptr);
338     std::shared_ptr<MMI::PointerEvent> pointerEvent = nullptr;
339     ASSERT_EQ(scensession->TransferPointerEvent(pointerEvent), WSError::WS_ERROR_NULLPTR);
340 
341     sptr<WindowSessionProperty> property = new WindowSessionProperty();
342     property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
343     property->SetMaximizeMode(MaximizeMode::MODE_FULL_FILL);
344     property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
345     property->SetPersistentId(11);
346     scensession->property_ = property;
347 
348     std::shared_ptr<MMI::PointerEvent> pointerEvent_ = MMI::PointerEvent::Create();
349     pointerEvent_->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_DOWN);
350     ASSERT_EQ(scensession->TransferPointerEvent(pointerEvent_), WSError::WS_ERROR_INVALID_SESSION);
351 }
352 
353 /**
354  * @tc.name: RequestSessionBack
355  * @tc.desc: normal function
356  * @tc.type: FUNC
357  */
358 HWTEST_F(SceneSessionTest2, RequestSessionBack, Function | SmallTest | Level2)
359 {
360     SessionInfo info;
361     info.abilityName_ = "RequestSessionBack";
362     info.bundleName_ = "RequestSessionBack";
363     sptr<Rosen::ISession> session_;
364     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
365         new (std::nothrow) SceneSession::SpecificSessionCallback();
366     EXPECT_NE(specificCallback_, nullptr);
367     sptr<SceneSession> scensession = new (std::nothrow) SceneSession(info, nullptr);
368     EXPECT_NE(scensession, nullptr);
369     scensession->isActive_ = true;
370 
371     sptr<WindowSessionProperty> property = new(std::nothrow) WindowSessionProperty();
372     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
373     property->keyboardLayoutParams_.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM;
374     scensession->SetSessionProperty(property);
375 
376     WSError result = scensession->RequestSessionBack(true);
377     ASSERT_EQ(result, WSError::WS_OK);
378 
379     struct RSSurfaceNodeConfig config;
380     std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
381     EXPECT_NE(nullptr, surfaceNode);
382     scensession->SetLeashWinSurfaceNode(surfaceNode);
383     result = scensession->RequestSessionBack(true);
384     ASSERT_EQ(result, WSError::WS_OK);
385 }
386 
387 /**
388  * @tc.name: SetParentPersistentId
389  * @tc.desc: normal function
390  * @tc.type: FUNC
391  */
392 HWTEST_F(SceneSessionTest2, SetParentPersistentId, Function | SmallTest | Level2)
393 {
394     SessionInfo info;
395     info.abilityName_ = "SetParentPersistentId";
396     info.bundleName_ = "SetParentPersistentId";
397     sptr<Rosen::ISession> session_;
398     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
399         new (std::nothrow) SceneSession::SpecificSessionCallback();
400     EXPECT_NE(specificCallback_, nullptr);
401     sptr<SceneSession> scensession = new (std::nothrow) SceneSession(info, nullptr);
402     EXPECT_NE(scensession, nullptr);
403     scensession->isActive_ = true;
404 
405     scensession->SetParentPersistentId(0);
406     int32_t result = scensession->GetParentPersistentId();
407     ASSERT_EQ(result, 0);
408 
409     sptr<WindowSessionProperty> property = new(std::nothrow) WindowSessionProperty();
410     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
411 
412     scensession->SetSessionProperty(property);
413     scensession->SetParentPersistentId(0);
414     result = scensession->GetParentPersistentId();
415     ASSERT_EQ(result, 0);
416 
417     scensession->SetSessionProperty(nullptr);
418     scensession->SetParentPersistentId(0);
419     ASSERT_EQ(0, scensession->GetParentPersistentId());
420 }
421 
422 /**
423  * @tc.name: GetMainSessionId
424  * @tc.desc: GetMainSessionId Test
425  * @tc.type: FUNC
426  */
427 HWTEST_F(SceneSessionTest2, GetMainSessionId, Function | SmallTest | Level2)
428 {
429     SessionInfo info;
430     info.abilityName_ = "GetMainSessionId";
431     info.moduleName_ = "GetMainSessionId";
432     info.bundleName_ = "GetMainSessionId";
433 
434     sptr<Session> session = sptr<Session>::MakeSptr(info);
435     EXPECT_NE(session, nullptr);
436     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
437     EXPECT_NE(property, nullptr);
438     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
439     property->SetPersistentId(0);
440     session->SetSessionProperty(property);
441 
442     sptr<Session> subSession = sptr<Session>::MakeSptr(info);
443     EXPECT_NE(subSession, nullptr);
444     subSession->SetParentSession(session);
445     sptr<WindowSessionProperty> subProperty = sptr<WindowSessionProperty>::MakeSptr();
446     EXPECT_NE(subProperty, nullptr);
447     subProperty->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
448     subProperty->SetPersistentId(1);
449     subSession->SetSessionProperty(subProperty);
450 
451     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
452     EXPECT_NE(sceneSession, nullptr);
453     sceneSession->SetParentSession(subSession);
454     sptr<WindowSessionProperty> sceneProperty = sptr<WindowSessionProperty>::MakeSptr();
455     EXPECT_NE(sceneProperty, nullptr);
456     sceneProperty->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
457     sceneProperty->SetPersistentId(2);
458     sceneSession->SetSessionProperty(sceneProperty);
459     auto result = sceneSession->GetMainSessionId();
460     ASSERT_EQ(result, 0);
461 }
462 
463 /**
464  * @tc.name: GetSessionSnapshotFilePath
465  * @tc.desc: normal function
466  * @tc.type: FUNC
467  */
468 HWTEST_F(SceneSessionTest2, GetSessionSnapshotFilePath, Function | SmallTest | Level2)
469 {
470     SessionInfo info;
471     info.abilityName_ = "GetSessionSnapshotFilePath";
472     info.bundleName_ = "GetSessionSnapshotFilePath";
473     sptr<Rosen::ISession> session_;
474     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
475         new (std::nothrow) SceneSession::SpecificSessionCallback();
476     EXPECT_NE(specificCallback_, nullptr);
477     sptr<SceneSession> scensession = new (std::nothrow) SceneSession(info, nullptr);
478     EXPECT_NE(scensession, nullptr);
479     scensession->isActive_ = true;
480 
481     sptr<WindowSessionProperty> property = new(std::nothrow) WindowSessionProperty();
482     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
483     scensession->SetSessionProperty(property);
484 
485     std::string result = scensession->GetSessionSnapshotFilePath();
486     ASSERT_NE(result, "0");
487 }
488 
489 /**
490  * @tc.name: AddSubSession
491  * @tc.desc: AddSubSession Test
492  * @tc.type: FUNC
493  */
494 HWTEST_F(SceneSessionTest2, AddSubSession, Function | SmallTest | Level2)
495 {
496     SessionInfo info;
497     info.abilityName_ = "NotifySessionException";
498     info.bundleName_ = "NotifySessionException";
499 
500     sptr<SceneSession> session = new (std::nothrow) SceneSession(info, nullptr);
501     EXPECT_NE(session, nullptr);
502 
503     sptr<SceneSession> subSession = nullptr;
504     bool res = session->AddSubSession(subSession);
505     ASSERT_EQ(res, false);
506 
507     subSession = new (std::nothrow) SceneSession(info, nullptr);
508     EXPECT_NE(subSession, nullptr);
509 
510     res = session->AddSubSession(subSession);
511     ASSERT_EQ(res, true);
512 
513     res = session->AddSubSession(subSession);
514     ASSERT_EQ(res, false);
515 }
516 
517 /**
518  * @tc.name: RemoveSubSession
519  * @tc.desc: RemoveSubSession Test
520  * @tc.type: FUNC
521  */
522 HWTEST_F(SceneSessionTest2, RemoveSubSession, Function | SmallTest | Level2)
523 {
524     SessionInfo info;
525     info.abilityName_ = "NotifySessionException";
526     info.bundleName_ = "NotifySessionException";
527 
528     sptr<SceneSession> session = new (std::nothrow) SceneSession(info, nullptr);
529     EXPECT_NE(session, nullptr);
530 
531     bool res = session->RemoveSubSession(0);
532     ASSERT_EQ(res, false);
533 
534     sptr<SceneSession> subSession = new (std::nothrow) SceneSession(info, nullptr);
535     EXPECT_NE(subSession, nullptr);
536 
537     res = session->AddSubSession(subSession);
538     ASSERT_EQ(res, true);
539 
540     res = session->RemoveSubSession(subSession->GetPersistentId());
541     ASSERT_EQ(res, true);
542 }
543 
544 /**
545  * @tc.name: AddToastSession
546  * @tc.desc: AddToastSession Test
547  * @tc.type: FUNC
548  */
549 HWTEST_F(SceneSessionTest2, AddToastSession, Function | SmallTest | Level2)
550 {
551     SessionInfo info;
552     info.abilityName_ = "NotifySessionException";
553     info.bundleName_ = "NotifySessionException";
554 
555     sptr<SceneSession> session = new (std::nothrow) SceneSession(info, nullptr);
556     EXPECT_NE(session, nullptr);
557 
558     sptr<SceneSession> toastSession = nullptr;
559     bool res = session->AddToastSession(toastSession);
560     ASSERT_EQ(res, false);
561 
562     toastSession = new (std::nothrow) SceneSession(info, nullptr);
563     EXPECT_NE(toastSession, nullptr);
564 
565     res = session->AddToastSession(toastSession);
566     ASSERT_EQ(res, true);
567 
568     res = session->AddToastSession(toastSession);
569     ASSERT_EQ(res, false);
570 }
571 
572 /**
573  * @tc.name: RemoveToastSession
574  * @tc.desc: RemoveToastSession Test
575  * @tc.type: FUNC
576  */
577 HWTEST_F(SceneSessionTest2, RemoveToastSession, Function | SmallTest | Level2)
578 {
579     SessionInfo info;
580     info.abilityName_ = "NotifySessionException";
581     info.bundleName_ = "NotifySessionException";
582 
583     sptr<SceneSession> session = new (std::nothrow) SceneSession(info, nullptr);
584     EXPECT_NE(session, nullptr);
585 
586     bool res = session->RemoveToastSession(0);
587     ASSERT_EQ(res, false);
588 
589     sptr<SceneSession> toastSession = new (std::nothrow) SceneSession(info, nullptr);
590     EXPECT_NE(toastSession, nullptr);
591 
592     res = session->AddToastSession(toastSession);
593     ASSERT_EQ(res, true);
594 
595     res = session->RemoveToastSession(toastSession->GetPersistentId());
596     ASSERT_EQ(res, true);
597 }
598 
599 /**
600  * @tc.name: NotifySessionFullScreen01
601  * @tc.desc: NotifySessionFullScreen
602  * @tc.type: FUNC
603  */
604 HWTEST_F(SceneSessionTest2, NotifySessionFullScreen, Function | SmallTest | Level2)
605 {
606     SessionInfo info;
607     info.abilityName_ = "FullScreen01";
608     info.bundleName_ = "IsFloatingWindowAppType";
609     info.windowType_ = 1;
610     sptr<SceneSession::SpecificSessionCallback> specificCallback =
611         new (std::nothrow) SceneSession::SpecificSessionCallback();
612     EXPECT_NE(specificCallback, nullptr);
613     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
614     EXPECT_NE(sceneSession, nullptr);
615     sptr<SessionStageMocker> mockSessionStage = new (std::nothrow) SessionStageMocker();
616     ASSERT_NE(mockSessionStage, nullptr);
617     bool fullScreen = true;
618     int ret = 1;
619     sceneSession->sessionStage_ = mockSessionStage;
620     sceneSession->NotifySessionFullScreen(fullScreen);
621     ASSERT_EQ(ret, 1);
622 }
623 
624 /**
625  * @tc.name: NotifyClientToUpdateRect01
626  * @tc.desc: NotifyClientToUpdateRect
627  * @tc.type: FUNC
628  */
629 HWTEST_F(SceneSessionTest2, NotifyClientToUpdateRect01, Function | SmallTest | Level2)
630 {
631     SessionInfo info;
632     info.abilityName_ = "NotifyClientToUpdateRect01";
633     info.bundleName_ = "NotifyClientToUpdateRect01";
634     info.windowType_ = 1;
635     sptr<Rosen::ISession> session_;
636     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
637         new (std::nothrow) SceneSession::SpecificSessionCallback();
638     EXPECT_NE(specificCallback_, nullptr);
639     sptr<SceneSession> scensession;
640     scensession = new (std::nothrow) SceneSession(info, nullptr);
641     EXPECT_NE(scensession, nullptr);
642     sptr<SessionStageMocker> mockSessionStage = new (std::nothrow) SessionStageMocker();
643     ASSERT_NE(mockSessionStage, nullptr);
644     scensession->dirtyFlags_ |= static_cast<uint32_t>(SessionUIDirtyFlag::RECT);
645     scensession->sessionStage_ = mockSessionStage;
646     auto ret = scensession->NotifyClientToUpdateRect("SceneSessionTest2", nullptr);
647     ASSERT_EQ(ret, WSError::WS_OK);
648 }
649 
650 /**
651  * @tc.name: UpdateSizeChangeReason01
652  * @tc.desc: UpdateSizeChangeReason01
653  * @tc.type: FUNC
654  */
655 HWTEST_F(SceneSessionTest2, UpdateSizeChangeReason01, Function | SmallTest | Level2)
656 {
657     SessionInfo info;
658     info.abilityName_ = "UpdateSizeChangeReason01";
659     info.bundleName_ = "UpdateSizeChangeReason01";
660     info.windowType_ = 1;
661     sptr<Rosen::ISession> session_;
662     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
663         new (std::nothrow) SceneSession::SpecificSessionCallback();
664     EXPECT_NE(specificCallback_, nullptr);
665     sptr<SceneSession> scensession;
666     scensession = new (std::nothrow) SceneSession(info, nullptr);
667     EXPECT_NE(scensession, nullptr);
668     sptr<SessionStageMocker> mockSessionStage = new (std::nothrow) SessionStageMocker();
669     ASSERT_NE(mockSessionStage, nullptr);
670     scensession->dirtyFlags_ |= static_cast<uint32_t>(SessionUIDirtyFlag::RECT);
671     scensession->sessionStage_ = mockSessionStage;
672     scensession->UpdateSizeChangeReason(SizeChangeReason::ROTATION);
673     ASSERT_EQ(scensession->reason_, SizeChangeReason::ROTATION);
674     ASSERT_EQ(WSError::WS_OK, scensession->UpdateSizeChangeReason(SizeChangeReason::UNDEFINED));
675 }
676 
677 /**
678  * @tc.name: UpdatePiPRect01
679  * @tc.desc: UpdatePiPRect
680  * @tc.type: FUNC
681  */
682 HWTEST_F(SceneSessionTest2, UpdatePiPRect, Function | SmallTest | Level2)
683 {
684     SessionInfo info;
685     info.abilityName_ = "UpdatePiPRect01";
686     info.bundleName_ = "UpdatePiPRect";
687     sptr<Rosen::ISession> session_;
688     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
689         new (std::nothrow) SceneSession::SpecificSessionCallback();
690     EXPECT_NE(specificCallback_, nullptr);
691     sptr<SceneSession> scenesession;
692     scenesession = new (std::nothrow) SceneSession(info, nullptr);
693     EXPECT_NE(scenesession, nullptr);
694     scenesession->isActive_ = true;
695 
696     sptr<WindowSessionProperty> property = new(std::nothrow) WindowSessionProperty();
697     property->SetWindowType(WindowType::WINDOW_TYPE_PIP);
698     scenesession->SetSessionProperty(property);
699 
700     Rect rect = {0, 0, 800, 600};
701     SizeChangeReason reason = SizeChangeReason::PIP_START;
702     WSError result = scenesession->UpdatePiPRect(rect, reason);
703     ASSERT_EQ(result, WSError::WS_OK);
704 
705     property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
706     scenesession->SetSessionProperty(property);
707     result = scenesession->UpdatePiPRect(rect, reason);
708     ASSERT_EQ(result, WSError::WS_DO_NOTHING);
709 
710     property->SetWindowType(WindowType::WINDOW_TYPE_PIP);
711     scenesession->SetSessionProperty(property);
712     scenesession->isTerminating_ = true;
713     result = scenesession->UpdatePiPRect(rect, reason);
714     ASSERT_EQ(result, WSError::WS_OK);
715 
716     scenesession->isTerminating_ = false;
717     result = scenesession->UpdatePiPRect(rect, reason);
718     ASSERT_EQ(result, WSError::WS_OK);
719 }
720 
721 /**
722  * @tc.name: UpdatePiPControlStatus
723  * @tc.desc: UpdatePiPControlStatus
724  * @tc.type: FUNC
725  */
726 HWTEST_F(SceneSessionTest2, UpdatePiPControlStatus, Function | SmallTest | Level2)
727 {
728     SessionInfo info;
729     info.abilityName_ = "UpdatePiPControlStatus";
730     info.bundleName_ = "UpdatePiPControlStatus";
731     auto sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
732     EXPECT_NE(sceneSession, nullptr);
733     sceneSession->isActive_ = true;
734 
735     auto property = sptr<WindowSessionProperty>::MakeSptr();
736     EXPECT_NE(property, nullptr);
737     property->SetWindowType(WindowType::WINDOW_TYPE_PIP);
738     sceneSession->SetSessionProperty(property);
739 
740     auto controlType = WsPiPControlType::VIDEO_PLAY_PAUSE;
741     auto status = WsPiPControlStatus::PLAY;
742     WSError result = sceneSession->UpdatePiPControlStatus(controlType, status);
743     ASSERT_EQ(result, WSError::WS_OK);
744 
745     property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
746     sceneSession->SetSessionProperty(property);
747     result = sceneSession->UpdatePiPControlStatus(controlType, status);
748     ASSERT_EQ(result, WSError::WS_DO_NOTHING);
749 }
750 
751 /**
752  * @tc.name: SetScale
753  * @tc.desc: SetScale
754  * @tc.type: FUNC
755  */
756 HWTEST_F(SceneSessionTest2, SetScale, Function | SmallTest | Level2)
757 {
758     SessionInfo info;
759     info.abilityName_ = "SetScale";
760     info.bundleName_ = "SetScale";
761     sptr<Rosen::ISession> session_;
762     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
763         new (std::nothrow) SceneSession::SpecificSessionCallback();
764     EXPECT_NE(specificCallback_, nullptr);
765     int resultValue = 0;
766     sptr<SceneSession> scensession;
767     scensession = new (std::nothrow) SceneSession(info, nullptr);
768     EXPECT_NE(scensession, nullptr);
769     scensession->SetScale(1.0f, 1.0f, 0.0f, 0.0f);
770     ASSERT_EQ(0, resultValue);
771 }
772 
773 /**
774  * @tc.name: RequestHideKeyboard
775  * @tc.desc:  * @tc.name: RequestHideKeyboard
776  * @tc.type: FUNC
777  */
778 HWTEST_F(SceneSessionTest2, RequestHideKeyboard, Function | SmallTest | Level2)
779 {
780     SessionInfo info;
781     info.abilityName_ = "RequestHideKeyboard";
782     info.bundleName_ = "RequestHideKeyboard";
783     sptr<Rosen::ISession> session_;
784     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
785         new (std::nothrow) SceneSession::SpecificSessionCallback();
786     EXPECT_NE(specificCallback_, nullptr);
787     int resultValue = 0;
788     sptr<SceneSession> scensession;
789     scensession = new (std::nothrow) SceneSession(info, nullptr);
790     EXPECT_NE(scensession, nullptr);
791     scensession->RequestHideKeyboard();
792     ASSERT_EQ(0, resultValue);
793 }
794 
795 /**
796  * @tc.name: SetIsDisplayStatusBarTemporarily
797  * @tc.desc:  * @tc.name: SetIsDisplayStatusBarTemporarily
798  * @tc.type: FUNC
799  */
800 HWTEST_F(SceneSessionTest2, SetIsDisplayStatusBarTemporarily, Function | SmallTest | Level2)
801 {
802     SessionInfo info;
803     info.abilityName_ = "SetIsDisplayStatusBarTemporarily";
804     info.bundleName_ = "SetIsDisplayStatusBarTemporarily";
805     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
806     EXPECT_NE(sceneSession, nullptr);
807     sceneSession->SetIsDisplayStatusBarTemporarily(true);
808     ASSERT_EQ(true, sceneSession->GetIsDisplayStatusBarTemporarily());
809     sceneSession->SetIsDisplayStatusBarTemporarily(false);
810     ASSERT_EQ(false, sceneSession->GetIsDisplayStatusBarTemporarily());
811 }
812 
813 /**
814  * @tc.name: UpdateAvoidArea
815  * @tc.desc:  * @tc.name: UpdateAvoidArea
816  * @tc.type: FUNC
817  */
818 HWTEST_F(SceneSessionTest2, UpdateAvoidArea, Function | SmallTest | Level2)
819 {
820     SessionInfo info;
821     info.abilityName_ = "UpdateAvoidArea";
822     info.bundleName_ = "UpdateAvoidArea";
823     sptr<SceneSession> scensession;
824     scensession = new (std::nothrow) SceneSession(info, nullptr);
825     scensession->sessionStage_ = nullptr;
826     WSError result = scensession->UpdateAvoidArea(nullptr, AvoidAreaType::TYPE_SYSTEM);
827     EXPECT_EQ(WSError::WS_ERROR_NULLPTR, result);
828 
829     scensession->sessionStage_ = new SessionStageMocker();
830     EXPECT_NE(nullptr, scensession->sessionStage_);
831     result = scensession->UpdateAvoidArea(nullptr, AvoidAreaType::TYPE_SYSTEM);
832     EXPECT_EQ(WSError::WS_OK, result);
833     sceneSession->foregroundInteractiveStatus_.store(false);
834     result = sceneSession->UpdateAvoidArea(nullptr, AvoidAreaType::TYPE_SYSTEM);
835     EXPECT_EQ(WSError::WS_DO_NOTHING, result);
836 }
837 
838 /**
839  * @tc.name: ChangeSessionVisibilityWithStatusBar
840  * @tc.desc: normal function
841  * @tc.type: FUNC
842  */
843 HWTEST_F(SceneSessionTest2, ChangeSessionVisibilityWithStatusBar, Function | SmallTest | Level2)
844 {
845     SessionInfo info;
846     info.abilityName_ = "ChangeSessionVisibilityWithStatusBar";
847     info.bundleName_ = "ChangeSessionVisibilityWithStatusBar";
848     sptr<Rosen::ISession> session_;
849 
850     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
851     EXPECT_NE(sceneSession, nullptr);
852     sceneSession->isActive_ = true;
853 
854     sptr<AAFwk::SessionInfo> info1 = nullptr;
855     WSError result = sceneSession->ChangeSessionVisibilityWithStatusBar(info1, false);
856     ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
857 
858     sptr<AAFwk::SessionInfo> abilitySessionInfo = new AAFwk::SessionInfo();
859     result = sceneSession->ChangeSessionVisibilityWithStatusBar(abilitySessionInfo, false);
860     ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
861 }
862 
863 /**
864  * @tc.name: SetShouldHideNonSecureWindows
865  * @tc.desc: SetShouldHideNonSecureWindows
866  * @tc.type: FUNC
867  */
868 HWTEST_F(SceneSessionTest2, SetShouldHideNonSecureWindows, Function | SmallTest | Level2)
869 {
870     SessionInfo info;
871     info.abilityName_ = "SetShouldHideNonSecureWindows";
872     info.bundleName_ = "SetShouldHideNonSecureWindows";
873 
874     sptr<SceneSession> sceneSession;
875     sceneSession = new (std::nothrow) SceneSession(info, nullptr);
876     EXPECT_NE(sceneSession, nullptr);
877 
878     EXPECT_FALSE(sceneSession->shouldHideNonSecureWindows_.load());
879     sceneSession->SetShouldHideNonSecureWindows(true);
880     EXPECT_TRUE(sceneSession->shouldHideNonSecureWindows_.load());
881 }
882 
883 /**
884  * @tc.name: UpdateExtWindowFlags
885  * @tc.desc: update uiextension window flags
886  * @tc.type: FUNC
887  */
888 HWTEST_F(SceneSessionTest2, UpdateExtWindowFlags, Function | SmallTest | Level2)
889 {
890     SessionInfo info;
891     info.abilityName_ = "UpdateExtWindowFlags";
892     info.bundleName_ = "UpdateExtWindowFlags";
893 
894     sptr<SceneSession> sceneSession;
895     sceneSession = new (std::nothrow) SceneSession(info, nullptr);
896     EXPECT_NE(sceneSession, nullptr);
897 
898     EXPECT_TRUE(sceneSession->extWindowFlagsMap_.empty());
899     int32_t persistentId = 12345;
900     ExtensionWindowFlags flags(7);
901     ExtensionWindowFlags actions(7);
902     sceneSession->UpdateExtWindowFlags(persistentId, flags, actions);
903     EXPECT_EQ(sceneSession->extWindowFlagsMap_.size(), 1);
904     EXPECT_EQ(sceneSession->extWindowFlagsMap_.begin()->first, persistentId);
905     EXPECT_EQ(sceneSession->extWindowFlagsMap_.begin()->second.bitData, 7);
906     flags.bitData = 0;
907     actions.bitData = 3;
908     sceneSession->UpdateExtWindowFlags(persistentId, flags, actions);
909     EXPECT_EQ(sceneSession->extWindowFlagsMap_.size(), 1);
910     EXPECT_EQ(sceneSession->extWindowFlagsMap_.begin()->first, persistentId);
911     EXPECT_EQ(sceneSession->extWindowFlagsMap_.begin()->second.bitData, 4);
912     actions.bitData = 4;
913     sceneSession->UpdateExtWindowFlags(persistentId, flags, actions);
914     EXPECT_TRUE(sceneSession->extWindowFlagsMap_.empty());
915 }
916 
917 /**
918  * @tc.name: GetCombinedExtWindowFlags
919  * @tc.desc: get combined uiextension window flags
920  * @tc.type: FUNC
921  */
922 HWTEST_F(SceneSessionTest2, GetCombinedExtWindowFlags, Function | SmallTest | Level2)
923 {
924     SessionInfo info;
925     info.abilityName_ = "GetCombinedExtWindowFlags";
926     info.bundleName_ = "GetCombinedExtWindowFlags";
927 
928     sptr<SceneSession> sceneSession;
929     sceneSession = new (std::nothrow) SceneSession(info, nullptr);
930     EXPECT_NE(sceneSession, nullptr);
931 
932     auto combinedExtWindowFlags = sceneSession->GetCombinedExtWindowFlags();
933     EXPECT_EQ(combinedExtWindowFlags.bitData, 0);
934     sceneSession->UpdateExtWindowFlags(1234, ExtensionWindowFlags(3), ExtensionWindowFlags(3));
935     sceneSession->UpdateExtWindowFlags(5678, ExtensionWindowFlags(4), ExtensionWindowFlags(4));
936 
937     sceneSession->state_ = SessionState::STATE_FOREGROUND;
938     combinedExtWindowFlags = sceneSession->GetCombinedExtWindowFlags();
939     EXPECT_EQ(combinedExtWindowFlags.bitData, 7);
940 
941     sceneSession->state_ = SessionState::STATE_BACKGROUND;
942     combinedExtWindowFlags = sceneSession->GetCombinedExtWindowFlags();
943     EXPECT_EQ(combinedExtWindowFlags.bitData, 6);
944 }
945 
946 /**
947  * @tc.name: RemoveExtWindowFlags
948  * @tc.desc: remove uiextension window flags
949  * @tc.type: FUNC
950  */
951 HWTEST_F(SceneSessionTest2, RemoveExtWindowFlags, Function | SmallTest | Level2)
952 {
953     SessionInfo info;
954     info.abilityName_ = "RemoveExtWindowFlags";
955     info.bundleName_ = "RemoveExtWindowFlags";
956 
957     sptr<SceneSession> sceneSession;
958     sceneSession = new (std::nothrow) SceneSession(info, nullptr);
959     EXPECT_NE(sceneSession, nullptr);
960 
961     EXPECT_TRUE(sceneSession->extWindowFlagsMap_.empty());
962     sceneSession->UpdateExtWindowFlags(1234, ExtensionWindowFlags(3), ExtensionWindowFlags(3));
963     EXPECT_EQ(sceneSession->extWindowFlagsMap_.size(), 1);
964     sceneSession->RemoveExtWindowFlags(1234);
965     EXPECT_TRUE(sceneSession->extWindowFlagsMap_.empty());
966 }
967 
968 /**
969  * @tc.name: ClearExtWindowFlags
970  * @tc.desc: clear uiextension window flags
971  * @tc.type: FUNC
972  */
973 HWTEST_F(SceneSessionTest2, ClearExtWindowFlags, Function | SmallTest | Level2)
974 {
975     SessionInfo info;
976     info.abilityName_ = "ClearExtWindowFlags";
977     info.bundleName_ = "ClearExtWindowFlags";
978 
979     sptr<SceneSession> sceneSession;
980     sceneSession = new (std::nothrow) SceneSession(info, nullptr);
981     EXPECT_NE(sceneSession, nullptr);
982 
983     EXPECT_TRUE(sceneSession->extWindowFlagsMap_.empty());
984     sceneSession->UpdateExtWindowFlags(1234, ExtensionWindowFlags(3), ExtensionWindowFlags(3));
985     sceneSession->UpdateExtWindowFlags(5678, ExtensionWindowFlags(4), ExtensionWindowFlags(4));
986     EXPECT_EQ(sceneSession->extWindowFlagsMap_.size(), 2);
987     sceneSession->ClearExtWindowFlags();
988     EXPECT_TRUE(sceneSession->extWindowFlagsMap_.empty());
989 }
990 
991 /**
992  * @tc.name: CalculateCombinedExtWindowFlags
993  * @tc.desc: calculate combined uiextension window flags
994  * @tc.type: FUNC
995  */
996 HWTEST_F(SceneSessionTest2, CalculateCombinedExtWindowFlags, Function | SmallTest | Level2)
997 {
998     SessionInfo info;
999     info.abilityName_ = "CalculateCombinedExtWindowFlags";
1000     info.bundleName_ = "CalculateCombinedExtWindowFlags";
1001 
1002     sptr<SceneSession> sceneSession;
1003     sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1004     EXPECT_NE(sceneSession, nullptr);
1005 
1006     EXPECT_EQ(sceneSession->combinedExtWindowFlags_.bitData, 0);
1007     sceneSession->UpdateExtWindowFlags(1234, ExtensionWindowFlags(3), ExtensionWindowFlags(3));
1008     sceneSession->UpdateExtWindowFlags(5678, ExtensionWindowFlags(4), ExtensionWindowFlags(4));
1009     sceneSession->CalculateCombinedExtWindowFlags();
1010     EXPECT_EQ(sceneSession->combinedExtWindowFlags_.bitData, 7);
1011 }
1012 
1013 /**
1014  * @tc.name: SaveUpdatedIcon
1015  * @tc.desc:  * @tc.name: SaveUpdatedIcon
1016  * @tc.type: FUNC
1017  */
1018 HWTEST_F(SceneSessionTest2, SaveUpdatedIcon, Function | SmallTest | Level2)
1019 {
1020     SessionInfo info;
1021     info.abilityName_ = "SaveUpdatedIcon";
1022     info.bundleName_ = "SaveUpdatedIcon";
1023     sptr<SceneSession> scensession;
1024     scensession = new (std::nothrow) SceneSession(info, nullptr);
1025 
1026     scensession->scenePersistence_ = new ScenePersistence("OpenHarmony", 1);
1027     EXPECT_NE(nullptr, scensession->scenePersistence_);
1028     scensession->SaveUpdatedIcon(nullptr);
1029 }
1030 
1031 /**
1032  * @tc.name: NotifyTouchOutside
1033  * @tc.desc:  * @tc.name: NotifyTouchOutside
1034  * @tc.type: FUNC
1035  */
1036 HWTEST_F(SceneSessionTest2, NotifyTouchOutside, Function | SmallTest | Level2)
1037 {
1038     SessionInfo info;
1039     info.abilityName_ = "NotifyTouchOutside";
1040     info.bundleName_ = "NotifyTouchOutside";
1041     sptr<SceneSession> sceneSession = new SceneSession(info, nullptr);
1042 
1043     sceneSession->sessionStage_ = new SessionStageMocker();
1044     EXPECT_NE(nullptr, sceneSession->sessionStage_);
1045     sceneSession->NotifyTouchOutside();
1046 
__anon5dbd079e0202() 1047     auto func = [sceneSession]() {
1048         sceneSession->SaveUpdatedIcon(nullptr);
1049     };
1050     sceneSession->onTouchOutside_ = func;
1051     EXPECT_NE(nullptr, &func);
1052     sceneSession->sessionStage_ = nullptr;
1053     sceneSession->NotifyTouchOutside();
1054 
1055     sceneSession->onTouchOutside_ = nullptr;
1056     sceneSession->sessionStage_ = nullptr;
1057     sceneSession->NotifyTouchOutside();
1058 }
1059 
1060 /**
1061  * @tc.name: CheckTouchOutsideCallbackRegistered
1062  * @tc.desc: CheckTouchOutsideCallbackRegistered
1063  * @tc.type: FUNC
1064  */
1065 HWTEST_F(SceneSessionTest2, CheckTouchOutsideCallbackRegistered, Function | SmallTest | Level2)
1066 {
1067     SessionInfo info;
1068     info.abilityName_ = "CheckTouchOutsideCallbackRegistered";
1069     info.bundleName_ = "CheckTouchOutsideCallbackRegistered";
1070     sptr<SceneSession> sceneSession = new SceneSession(info, nullptr);
1071 
__anon5dbd079e0302() 1072     auto func = [sceneSession]() {
1073         sceneSession->NotifyWindowVisibility();
1074     };
1075     sceneSession->onTouchOutside_ = func;
1076     bool result = sceneSession->CheckTouchOutsideCallbackRegistered();
1077     EXPECT_EQ(true, result);
1078 
1079     sceneSession->onTouchOutside_ = nullptr;
1080     result = sceneSession->CheckTouchOutsideCallbackRegistered();
1081     EXPECT_EQ(false, result);
1082 }
1083 
1084 /**
1085  * @tc.name: RegisterTouchOutsideCallback
1086  * @tc.desc: test RegisterTouchOutsideCallback
1087  * @tc.type: FUNC
1088  */
1089 HWTEST_F(SceneSessionTest2, RegisterTouchOutsideCallback, Function | SmallTest | Level2)
1090 {
1091     SessionInfo info;
1092     info.abilityName_ = "RegisterTouchOutsideCallback";
1093     info.bundleName_ = "RegisterTouchOutsideCallback";
1094     sptr<SceneSession> sceneSession = new SceneSession(info, nullptr);
1095     sceneSession->onTouchOutside_ = nullptr;
__anon5dbd079e0402() 1096     NotifyTouchOutsideFunc func = []() {};
1097     sceneSession->RegisterTouchOutsideCallback(std::move(func));
1098 
1099     ASSERT_NE(sceneSession->onTouchOutside_, nullptr);
1100 }
1101 
1102 /**
1103  * @tc.name: UpdateRotationAvoidArea
1104  * @tc.desc:  * @tc.name: UpdateRotationAvoidArea
1105  * @tc.type: FUNC
1106  */
1107 HWTEST_F(SceneSessionTest2, UpdateRotationAvoidArea, Function | SmallTest | Level2)
1108 {
1109     SessionInfo info;
1110     info.abilityName_ = "UpdateRotationAvoidArea";
1111     info.bundleName_ = "UpdateRotationAvoidArea";
1112     sptr<SceneSession> scensession;
1113     scensession = new (std::nothrow) SceneSession(info, nullptr);
1114     scensession->specificCallback_ = new SceneSession::SpecificSessionCallback();
1115     EXPECT_NE(nullptr, scensession->specificCallback_);
__anon5dbd079e0502(const int32_t& persistentId) 1116     auto func = [scensession](const int32_t& persistentId) {
1117         scensession->SetParentPersistentId(persistentId);
1118         scensession->GetParentPersistentId();
1119     };
1120     scensession->specificCallback_->onUpdateAvoidArea_ = func;
1121     sptr<Session> session;
1122     session = new (std::nothrow) Session(info);
1123     int result = session->GetPersistentId();
1124     EXPECT_EQ(0, result);
1125     scensession->UpdateRotationAvoidArea();
1126 
1127     scensession->specificCallback_ = nullptr;
1128     scensession->UpdateRotationAvoidArea();
1129 }
1130 
1131 /**
1132  * @tc.name: NotifyForceHideChange
1133  * @tc.desc:  * @tc.name: NotifyForceHideChange
1134  * @tc.type: FUNC
1135  */
1136 HWTEST_F(SceneSessionTest2, NotifyForceHideChange, Function | SmallTest | Level2)
1137 {
1138     SessionInfo info;
1139     info.abilityName_ = "NotifyForceHideChange";
1140     info.bundleName_ = "NotifyForceHideChange";
1141     sptr<SceneSession> scensession;
1142     scensession = new (std::nothrow) SceneSession(info, nullptr);
1143     scensession->NotifyForceHideChange(true);
1144 
1145     sptr<Session> session;
1146     session = new (std::nothrow) Session(info);
1147     scensession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback();
__anon5dbd079e0602(bool hide) 1148     auto func = [scensession](bool hide) {
1149         scensession->SetPrivacyMode(hide);
1150     };
1151     scensession->onForceHideChangeFunc_ = func;
1152     EXPECT_NE(nullptr, &func);
1153     scensession->NotifyForceHideChange(true);
1154 
1155     scensession->SetSessionProperty(nullptr);
1156     scensession->NotifyForceHideChange(true);
1157     ASSERT_EQ(scensession->property_, nullptr);
1158 }
1159 
1160 /**
1161  * @tc.name: RegisterSessionChangeCallback
1162  * @tc.desc:  * @tc.name: RegisterSessionChangeCallback
1163  * @tc.type: FUNC
1164  */
1165 HWTEST_F(SceneSessionTest2, RegisterSessionChangeCallback, Function | SmallTest | Level2)
1166 {
1167     SessionInfo info;
1168     info.abilityName_ = "RegisterSessionChangeCallback";
1169     info.bundleName_ = "RegisterSessionChangeCallback";
1170     sptr<SceneSession> scensession;
1171     scensession = new (std::nothrow) SceneSession(info, nullptr);
1172     sptr<SceneSession::SessionChangeCallback> callback = new SceneSession::SessionChangeCallback();
1173     EXPECT_NE(nullptr, callback);
1174     scensession->RegisterSessionChangeCallback(callback);
1175 }
1176 
1177 /**
1178  * @tc.name: ClearSpecificSessionCbMap
1179  * @tc.desc:  * @tc.name: ClearSpecificSessionCbMap
1180  * @tc.type: FUNC
1181  */
1182 HWTEST_F(SceneSessionTest2, ClearSpecificSessionCbMap, Function | SmallTest | Level2)
1183 {
1184     SessionInfo info;
1185     info.abilityName_ = "ClearSpecificSessionCbMap";
1186     info.bundleName_ = "ClearSpecificSessionCbMap";
1187     sptr<SceneSession> scensession;
1188     scensession = new (std::nothrow) SceneSession(info, nullptr);
1189     EXPECT_NE(nullptr, scensession);
1190     scensession->ClearSpecificSessionCbMap();
1191 }
1192 
1193 /**
1194  * @tc.name: SendPointerEventToUI
1195  * @tc.desc:  * @tc.name: SendPointerEventToUI
1196  * @tc.type: FUNC
1197  */
1198 HWTEST_F(SceneSessionTest2, SendPointerEventToUI, Function | SmallTest | Level2)
1199 {
1200     SessionInfo info;
1201     info.abilityName_ = "SendPointerEventToUI";
1202     info.bundleName_ = "SendPointerEventToUI";
1203     sptr<SceneSession> scensession;
1204     scensession = new (std::nothrow) SceneSession(info, nullptr);
1205     EXPECT_NE(nullptr, scensession);
__anon5dbd079e0702(std::shared_ptr<MMI::PointerEvent> pointerEvent) 1206     auto pointerEventFunc = [scensession](std::shared_ptr<MMI::PointerEvent> pointerEvent) {
1207         scensession->NotifyOutsideDownEvent(pointerEvent);
1208     };
1209     scensession->systemSessionPointerEventFunc_ = pointerEventFunc;
1210     std::shared_ptr<MMI::PointerEvent> pointerEvent =
1211          MMI::PointerEvent::Create();
1212     scensession->SendPointerEventToUI(pointerEvent);
1213     EXPECT_NE(nullptr, pointerEvent);
1214 }
1215 
1216 /**
1217  * @tc.name: SetFloatingScale
1218  * @tc.desc:  * @tc.name: SetFloatingScale
1219  * @tc.type: FUNC
1220  */
1221 HWTEST_F(SceneSessionTest2, SetFloatingScale, Function | SmallTest | Level2)
1222 {
1223     SessionInfo info;
1224     info.abilityName_ = "SetFloatingScale";
1225     info.bundleName_ = "SetFloatingScale";
1226     sptr<SceneSession> scensession;
1227     scensession = new (std::nothrow) SceneSession(info, nullptr);
1228     scensession->specificCallback_ = new SceneSession::SpecificSessionCallback();
__anon5dbd079e0802(int32_t persistentId, WindowUpdateType type) 1229     auto windowInfoUpdateFun = [scensession](int32_t persistentId, WindowUpdateType type) {
1230         if (WindowUpdateType::WINDOW_UPDATE_PROPERTY == type) {
1231             scensession->SetCollaboratorType(persistentId);
1232             return;
1233         } else {
1234             persistentId++;
1235             scensession->SetParentPersistentId(persistentId);
1236             return;
1237         }
1238     };
__anon5dbd079e0902(const int32_t& persistentId) 1239     auto updateAvoidAreaFun = [scensession](const int32_t& persistentId) {
1240         bool result = scensession->RemoveSubSession(persistentId);
1241         scensession->SetWindowAnimationFlag(result);
1242     };
1243     scensession->specificCallback_->onWindowInfoUpdate_ = windowInfoUpdateFun;
1244     scensession->specificCallback_->onUpdateAvoidArea_ = updateAvoidAreaFun;
1245     scensession->SetFloatingScale(3.14f);
1246     EXPECT_EQ(3.14f, scensession->floatingScale_);
1247 
1248     scensession->floatingScale_ = 3.0f;
1249     scensession->SetFloatingScale(3.0f);
1250     EXPECT_EQ(3.0f, scensession->floatingScale_);
1251 }
1252 
1253 /**
1254  * @tc.name: ProcessPointDownSession
1255  * @tc.desc:  * @tc.name: ProcessPointDownSession
1256  * @tc.type: FUNC
1257  */
1258 HWTEST_F(SceneSessionTest2, ProcessPointDownSession, Function | SmallTest | Level2)
1259 {
1260     SessionInfo info;
1261     info.abilityName_ = "ProcessPointDownSession";
1262     info.bundleName_ = "ProcessPointDownSession";
1263     sptr<SceneSession> scensession;
1264     scensession = new (std::nothrow) SceneSession(info, nullptr);
1265     scensession->specificCallback_ = new SceneSession::SpecificSessionCallback();
1266     EXPECT_NE(nullptr, scensession->specificCallback_);
__anon5dbd079e0a02(int32_t persistentId) 1267     auto sessionTouchOutsideFun = [scensession](int32_t persistentId) {
1268         scensession->SetCollaboratorType(persistentId);
1269     };
__anon5dbd079e0b02(int32_t x, int32_t y) 1270     auto outsideDownEventFun = [scensession](int32_t x, int32_t y) {
1271         int z = x + y;
1272         scensession->SetCollaboratorType(z);
1273     };
1274     scensession->specificCallback_->onSessionTouchOutside_ = sessionTouchOutsideFun;
1275     scensession->specificCallback_->onOutsideDownEvent_ = outsideDownEventFun;
1276     EXPECT_EQ(WSError::WS_OK, scensession->ProcessPointDownSession(3, 4));
1277 
1278     scensession->specificCallback_->onSessionTouchOutside_ = nullptr;
1279     EXPECT_EQ(WSError::WS_OK, scensession->ProcessPointDownSession(3, 4));
1280 
1281     scensession->sessionInfo_.bundleName_ = "SCBGestureBack";
1282     scensession->specificCallback_->onOutsideDownEvent_ = nullptr;
1283     EXPECT_EQ(WSError::WS_OK, scensession->ProcessPointDownSession(3, 4));
1284 }
1285 
1286 /**
1287  * @tc.name: SetSelfToken
1288  * @tc.desc:  * @tc.name: SetSelfToken
1289  * @tc.type: FUNC
1290  */
1291 HWTEST_F(SceneSessionTest2, SetSelfToken, Function | SmallTest | Level2)
1292 {
1293     SessionInfo info;
1294     info.abilityName_ = "SetSelfToken";
1295     info.bundleName_ = "SetSelfToken";
1296     sptr<SceneSession> scensession;
1297     sptr<SceneSession::SpecificSessionCallback> specificSession =
1298         new SceneSession::SpecificSessionCallback();
1299     scensession = new (std::nothrow) SceneSession(info, specificSession);
1300     EXPECT_NE(nullptr, scensession);
1301     scensession->SetSessionState(SessionState::STATE_DISCONNECT);
1302     scensession->UpdateSessionState(SessionState::STATE_CONNECT);
1303     scensession->UpdateSessionState(SessionState::STATE_ACTIVE);
1304     scensession->isVisible_ = true;
1305     EXPECT_EQ(true, scensession->IsVisibleForAccessibility());
1306     scensession->SetSystemTouchable(false);
1307     EXPECT_EQ(false, scensession->IsVisibleForAccessibility());
1308     scensession->SetForegroundInteractiveStatus(true);
1309     scensession->NotifyAccessibilityVisibilityChange();
__anon5dbd079e0c02(int32_t persistentId, WindowUpdateType type) 1310     auto windowInfoUpdateFun = [scensession](int32_t persistentId, WindowUpdateType type) {
1311         if (WindowUpdateType::WINDOW_UPDATE_PROPERTY == type) {
1312             scensession->SetCollaboratorType(persistentId);
1313             return;
1314         } else {
1315             persistentId++;
1316             scensession->SetParentPersistentId(persistentId);
1317             return;
1318         }
1319     };
1320     scensession->specificCallback_->onWindowInfoUpdate_ = windowInfoUpdateFun;
1321     scensession->NotifyAccessibilityVisibilityChange();
1322     EXPECT_NE(nullptr, scensession->specificCallback_);
1323 }
1324 
1325 /**
1326  * @tc.name: SetLastSafeRect
1327  * @tc.desc:  * @tc.name: SetLastSafeRect
1328  * @tc.type: FUNC
1329  */
1330 HWTEST_F(SceneSessionTest2, SetLastSafeRect, Function | SmallTest | Level2)
1331 {
1332     SessionInfo info;
1333     info.abilityName_ = "SetLastSafeRect";
1334     info.bundleName_ = "SetLastSafeRect";
1335     sptr<SceneSession> scensession;
1336     sptr<SceneSession::SpecificSessionCallback> specificSession =
1337         new SceneSession::SpecificSessionCallback();
1338     scensession = new (std::nothrow) SceneSession(info, specificSession);
1339     WSRect rect = {3, 4, 5, 6};
1340     scensession->SetLastSafeRect(rect);
1341     WSRect result = scensession->GetLastSafeRect();
1342     EXPECT_EQ(3, result.posX_);
1343     EXPECT_EQ(4, result.posY_);
1344     EXPECT_EQ(5, result.width_);
1345     EXPECT_EQ(6, result.height_);
1346 }
1347 
1348 /**
1349  * @tc.name: GetSessionTargetRect
1350  * @tc.desc:  * @tc.name: GetSessionTargetRect
1351  * @tc.type: FUNC
1352  */
1353 HWTEST_F(SceneSessionTest2, GetSessionTargetRect, Function | SmallTest | Level2)
1354 {
1355     SessionInfo info;
1356     info.abilityName_ = "GetSubSession";
1357     info.bundleName_ = "GetSessionTargetRect";
1358     sptr<SceneSession> scensession;
1359     sptr<SceneSession::SpecificSessionCallback> specificSession =
1360         new SceneSession::SpecificSessionCallback();
1361     scensession = new (std::nothrow) SceneSession(info, specificSession);
1362     bool res = scensession->AddSubSession(scensession);
1363     EXPECT_EQ(true, res);
1364     EXPECT_EQ(scensession, (scensession->GetSubSession())[0]);
1365     scensession->moveDragController_ = new MoveDragController(1024);
1366     WSRect rectResult = scensession->GetSessionTargetRect();
1367     EXPECT_EQ(0, rectResult.posX_);
1368     EXPECT_EQ(0, rectResult.width_);
__anon5dbd079e0d02(int32_t type, const SizeChangeReason& reason) 1369     auto dragHotAreaFunc = [scensession](int32_t type, const SizeChangeReason& reason) {
1370         if (SizeChangeReason::END == reason) {
1371             GTEST_LOG_(INFO) << "type = " << type;
1372         }
1373         return;
1374     };
1375     scensession->SetWindowDragHotAreaListener(dragHotAreaFunc);
1376     EXPECT_NE(nullptr,  scensession->moveDragController_);
1377     scensession->moveDragController_ = nullptr;
1378     rectResult = scensession->GetSessionTargetRect();
1379     scensession->SetWindowDragHotAreaListener(dragHotAreaFunc);
1380     ASSERT_EQ(0, rectResult.width_);
1381 }
1382 
1383 /**
1384  * @tc.name: SetPipActionEvent
1385  * @tc.desc:  * @tc.name: SetPipActionEvent
1386  * @tc.type: FUNC
1387  */
1388 HWTEST_F(SceneSessionTest2, SetPipActionEvent, Function | SmallTest | Level2)
1389 {
1390     SessionInfo info;
1391     info.abilityName_ = "SetPipActionEvent";
1392     info.bundleName_ = "SetPipActionEvent";
1393     auto sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1394     EXPECT_NE(sceneSession, nullptr);
1395 
1396     WSError res = sceneSession->SetPipActionEvent("close", 0);
1397     ASSERT_EQ(res, WSError::WS_ERROR_NULLPTR);
1398     auto mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
1399     sceneSession->sessionStage_ = mockSessionStage;
1400     res = sceneSession->SetPipActionEvent("close", 0);
1401     ASSERT_EQ(res, WSError::WS_OK);
1402 }
1403 
1404 /*
1405  * @tc.name: SetPiPControlEvent
1406  * @tc.desc:  * @tc.name: SetPiPControlEvent
1407  * @tc.type: FUNC
1408  */
1409 HWTEST_F(SceneSessionTest2, SetPiPControlEvent, Function | SmallTest | Level2)
1410 {
1411     SessionInfo info;
1412     info.abilityName_ = "SetPiPControlEvent";
1413     info.bundleName_ = "SetPiPControlEvent";
1414     auto sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1415     EXPECT_NE(sceneSession, nullptr);
1416 
1417     auto property = sptr<WindowSessionProperty>::MakeSptr();
1418     EXPECT_NE(property, nullptr);
1419     property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1420     sceneSession->SetSessionProperty(property);
1421     auto controlType = WsPiPControlType::VIDEO_PLAY_PAUSE;
1422     auto status = WsPiPControlStatus::PLAY;
1423     WSError res = sceneSession->SetPiPControlEvent(controlType, status);
1424     ASSERT_EQ(res, WSError::WS_ERROR_INVALID_TYPE);
1425 
1426     auto sessionStage = sptr<SessionStageMocker>::MakeSptr();
1427     ASSERT_NE(sessionStage, nullptr);
1428 
1429     property->SetWindowType(WindowType::WINDOW_TYPE_PIP);
1430     property->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
1431     sceneSession->SetSessionProperty(property);
1432     res = sceneSession->SetPiPControlEvent(controlType, status);
1433     ASSERT_EQ(res, WSError::WS_ERROR_NULLPTR);
1434 }
1435 
1436 /**
1437  * @tc.name: SetForceHideState
1438  * @tc.desc: SetForceHideState
1439  * @tc.type: FUNC
1440  */
1441 HWTEST_F(SceneSessionTest2, SetForceHideState, Function | SmallTest | Level2)
1442 {
1443     SessionInfo info;
1444     info.abilityName_ = "SetForceHideState";
1445     info.bundleName_ = "SetForceHideState";
1446     sptr<SceneSession> sceneSession;
1447     sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1448     EXPECT_NE(sceneSession, nullptr);
1449 
1450     sceneSession->SetForceHideState(ForceHideState::NOT_HIDDEN);
1451     bool hide = sceneSession->GetForceHideState();
1452     ASSERT_EQ(hide, ForceHideState::NOT_HIDDEN);
1453     sceneSession->SetForceHideState(ForceHideState::HIDDEN_WHEN_FOCUSED);
1454     hide = sceneSession->GetForceHideState();
1455     ASSERT_EQ(hide, ForceHideState::HIDDEN_WHEN_FOCUSED);
1456 }
1457 
1458 /**
1459  * @tc.name: ClearSpecificSessionCbMap
1460  * @tc.desc:  * @tc.name: ClearSpecificSessionCbMap
1461  * @tc.type: FUNC
1462  */
1463 HWTEST_F(SceneSessionTest2, ClearSpecificSessionCbMap01, Function | SmallTest | Level2)
1464 {
1465     SessionInfo info;
1466     info.abilityName_ = "ClearSpecificSessionCbMap01";
1467     info.bundleName_ = "ClearSpecificSessionCbMap01";
1468     sptr<SceneSession> scensession;
1469     scensession = new (std::nothrow) SceneSession(info, nullptr);
1470     EXPECT_NE(nullptr, scensession);
1471     sptr<Session> session;
1472     session = new (std::nothrow) Session(info);
1473     scensession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback();
1474     scensession->ClearSpecificSessionCbMap();
1475 
1476     bool isFromClient = true;
1477     scensession->needSnapshot_ = true;
1478     scensession->specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback();
1479     scensession->Disconnect(isFromClient);
1480 
1481     bool isActive = false;
1482     scensession->UpdateActiveStatus(isActive);
1483     isActive = true;
1484     Session ssession(info);
1485     ssession.state_ = SessionState::STATE_FOREGROUND;
1486     isActive = false;
1487     ssession.state_ = SessionState::STATE_ACTIVE;
1488 }
1489 
1490 /**
1491  * @tc.name: OnSessionEvent01
1492  * @tc.desc:  * @tc.name: OnSessionEvent
1493  * @tc.type: FUNC
1494  */
1495 HWTEST_F(SceneSessionTest2, OnSessionEvent01, Function | SmallTest | Level2)
1496 {
1497     SessionInfo info;
1498     info.abilityName_ = "OnSessionEvent01";
1499     info.bundleName_ = "OnSessionEvent01";
1500 
1501     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1502     EXPECT_NE(sceneSession, nullptr);
1503 
1504     SessionEvent event = SessionEvent::EVENT_START_MOVE;
1505     sceneSession->moveDragController_ = new MoveDragController(1);
1506     sceneSession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback();
1507     sceneSession->OnSessionEvent(event);
1508 
1509     sceneSession->moveDragController_->isStartDrag_ = true;
1510     sceneSession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback();
1511     EXPECT_NE(sceneSession->sessionChangeCallback_, nullptr);
1512     auto result = sceneSession->OnSessionEvent(event);
1513     ASSERT_EQ(result, WSError::WS_OK);
1514 }
1515 
1516 /**
1517  * @tc.name: SetSessionRectChangeCallback
1518  * @tc.desc:  * @tc.name: SetSessionRectChangeCallback
1519  * @tc.type: FUNC
1520  */
1521 HWTEST_F(SceneSessionTest2, SetSessionRectChangeCallback, Function | SmallTest | Level2)
1522 {
1523     SessionInfo info;
1524     info.abilityName_ = "SetSessionRectChangeCallback";
1525     info.bundleName_ = "SetSessionRectChangeCallback";
1526 
1527     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1528     EXPECT_NE(sceneSession, nullptr);
1529 
1530     NotifySessionRectChangeFunc func;
1531     sceneSession->SetSessionRectChangeCallback(func);
1532     sceneSession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback();
1533 
1534     sceneSession->RaiseToAppTop();
1535     sceneSession = nullptr;
1536     GTEST_LOG_(INFO) << "2";
1537     sceneSession->BindDialogSessionTarget(sceneSession);
1538 
1539     Session ssession(info);
1540     ssession.property_ = nullptr;
1541 }
1542 
1543 /**
1544  * @tc.name: SetSessionPiPControlStatusChangeCallback
1545  * @tc.desc:  * @tc.name: SetSessionPiPControlStatusChangeCallback
1546  * @tc.type: FUNC
1547  */
1548 HWTEST_F(SceneSessionTest2, SetSessionPiPControlStatusChangeCallback, Function | SmallTest | Level2)
1549 {
1550     SessionInfo info;
1551     info.abilityName_ = "SetSessionPiPControlStatusChangeCallback";
1552     info.bundleName_ = "SetSessionPiPControlStatusChangeCallback";
1553     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1554     EXPECT_NE(sceneSession, nullptr);
1555     NotifySessionPiPControlStatusChangeFunc func;
1556     sceneSession->SetSessionPiPControlStatusChangeCallback(func);
1557 }
1558 
1559 /**
1560  * @tc.name: SetAutoStartPiPStatusChangeCallback
1561  * @tc.desc: SetAutoStartPiPStatusChangeCallback
1562  * @tc.type: FUNC
1563  */
1564 HWTEST_F(SceneSessionTest2, SetAutoStartPiPStatusChangeCallback, Function | SmallTest | Level2)
1565 {
1566     SessionInfo info;
1567     info.abilityName_ = "SetAutoStartPiPStatusChangeCallback";
1568     info.bundleName_ = "SetAutoStartPiPStatusChangeCallback";
1569     auto sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1570     EXPECT_NE(sceneSession, nullptr);
1571     NotifyAutoStartPiPStatusChangeFunc func;
1572     sceneSession->SetAutoStartPiPStatusChangeCallback(func);
1573 }
1574 
1575 /**
1576  * @tc.name: RaiseAppMainWindowToTop
1577  * @tc.desc:  * @tc.name: RaiseAppMainWindowToTop
1578  * @tc.type: FUNC
1579  */
1580 HWTEST_F(SceneSessionTest2, RaiseAppMainWindowToTop, Function | SmallTest | Level2)
1581 {
1582     SessionInfo info;
1583     info.abilityName_ = "RaiseAppMainWindowToTop";
1584     info.bundleName_ = "RaiseAppMainWindowToTop";
1585 
1586     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1587     EXPECT_NE(sceneSession, nullptr);
1588 
1589     sceneSession->RaiseAppMainWindowToTop();
1590     sceneSession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback();
1591     bool status = true;
1592     sceneSession->OnNeedAvoid(status);
1593 
1594     bool showWhenLocked = true;
1595     sceneSession->OnShowWhenLocked(showWhenLocked);
1596     sceneSession->NotifyPropertyWhenConnect();
1597 }
1598 
1599 /**
1600  * @tc.name: GetKeyboardAvoidArea
1601  * @tc.desc:  * @tc.name: GetKeyboardAvoidArea01
1602  * @tc.type: FUNC
1603  */
1604 HWTEST_F(SceneSessionTest2, GetKeyboardAvoidArea01, Function | SmallTest | Level2)
1605 {
1606     SessionInfo info;
1607     info.abilityName_ = "GetKeyboardAvoidArea";
1608     info.bundleName_ = "GetKeyboardAvoidArea";
1609 
1610     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1611     EXPECT_NE(sceneSession, nullptr);
1612 
1613     WSRect rect;
1614     AvoidArea avoidArea;
1615     GTEST_LOG_(INFO) << "1";
1616     sceneSession->GetKeyboardAvoidArea(rect, avoidArea);
1617 }
1618 
1619 /**
1620  * @tc.name: GetCutoutAvoidArea
1621  * @tc.desc:  * @tc.name: GetCutoutAvoidArea
1622  * @tc.type: FUNC
1623  */
1624 HWTEST_F(SceneSessionTest2, GetCutoutAvoidArea01, Function | SmallTest | Level2)
1625 {
1626     SessionInfo info;
1627     info.abilityName_ = "GetCutoutAvoidArea";
1628     info.bundleName_ = "GetCutoutAvoidArea";
1629 
1630     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1631     EXPECT_NE(sceneSession, nullptr);
1632 
1633     WSRect rect;
1634     AvoidArea avoidArea;
1635     DisplayManager displayManager;
1636     Session ssession(info);
1637     auto display = DisplayManager::GetInstance().GetDisplayById(
1638         ssession.GetSessionProperty()->GetDisplayId());
1639     sceneSession->GetCutoutAvoidArea(rect, avoidArea);
1640 }
1641 
1642 /**
1643  * @tc.name: GetAINavigationBarArea
1644  * @tc.desc:  * @tc.name: GetAINavigationBarArea
1645  * @tc.type: FUNC
1646  */
1647 HWTEST_F(SceneSessionTest2, GetAINavigationBarArea, Function | SmallTest | Level2)
1648 {
1649     SessionInfo info;
1650     info.abilityName_ = "GetAINavigationBarArea";
1651     info.bundleName_ = "GetAINavigationBarArea";
1652 
1653     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1654     EXPECT_NE(sceneSession, nullptr);
1655 
1656     WSRect rect;
1657     AvoidArea avoidArea;
1658     sceneSession->GetAINavigationBarArea(rect, avoidArea);
1659 
1660     sceneSession->SetIsDisplayStatusBarTemporarily(true);
1661     sceneSession->GetAINavigationBarArea(rect, avoidArea);
1662     ASSERT_EQ(sceneSession->GetIsDisplayStatusBarTemporarily(), true);
1663 
1664     auto property = sptr<WindowSessionProperty>::MakeSptr();
1665     EXPECT_NE(property, nullptr);
1666     property->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
1667     sceneSession->property_ = property;
1668     sceneSession->GetAINavigationBarArea(rect, avoidArea);
1669 
1670     sceneSession->SetSessionProperty(nullptr);
1671     sceneSession->GetAINavigationBarArea(rect, avoidArea);
1672 
1673     property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1674     sceneSession->SetSessionProperty(property);
1675     sceneSession->specificCallback_ = new SceneSession::SpecificSessionCallback();
1676     ASSERT_NE(nullptr, sceneSession->specificCallback_);
__anon5dbd079e0e02(uint64_t displayId) 1677     sceneSession->specificCallback_->onGetAINavigationBarArea_ = [](uint64_t displayId) {
1678         WSRect rect = {1, 1, 1, 1};
1679         return rect;
1680     };
1681     sceneSession->GetAINavigationBarArea(rect, avoidArea);
1682 }
1683 
1684 /**
1685  * @tc.name: TransferPointerEvent
1686  * @tc.desc:  * @tc.name: TransferPointerEvent
1687  * @tc.type: FUNC
1688  */
1689 HWTEST_F(SceneSessionTest2, TransferPointerEvent03, Function | SmallTest | Level2)
1690 {
1691     SessionInfo info;
1692     info.abilityName_ = "TransferPointerEvent";
1693     info.bundleName_ = "TransferPointerEvent";
1694 
1695     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1696     EXPECT_NE(sceneSession, nullptr);
1697 
1698     std::shared_ptr<MMI::PointerEvent> pointerEvent = nullptr;
1699     sceneSession->specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback();
1700 
1701     sceneSession->TransferPointerEvent(pointerEvent);
1702 
1703     WindowLimits limits;
1704     WSRect rect;
1705     float ratio = 0.0;
1706     bool isDecor = true;
1707     float vpr = 0.0;
1708     sceneSession->FixRectByLimits(limits, rect, ratio, isDecor, vpr);
1709     sceneSession->SetPipActionEvent("pointerEvent", 0);
1710 
1711     auto property = sptr<WindowSessionProperty>::MakeSptr();
1712     EXPECT_NE(property, nullptr);
1713     property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
1714     sceneSession->SetSessionProperty(property);
1715     ASSERT_EQ(WSError::WS_ERROR_NULLPTR, sceneSession->SetPipActionEvent("pointerEvent", 0));
1716 
1717     sceneSession->sessionStage_ = sptr<SessionStageMocker>::MakeSptr();
1718     property->SetWindowType(WindowType::WINDOW_TYPE_PIP);
1719     property->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
1720     ASSERT_EQ(WSError::WS_OK, sceneSession->SetPipActionEvent("pointerEvent", 0));
1721 
1722     sceneSession->FixRectByLimits(limits, rect, ratio, false, vpr);
1723 }
1724 
1725 /**
1726  * @tc.name: OnMoveDragCallback
1727  * @tc.desc:  * @tc.name: OnMoveDragCallback
1728  * @tc.type: FUNC
1729  */
1730 HWTEST_F(SceneSessionTest2, OnMoveDragCallback, Function | SmallTest | Level2)
1731 {
1732     SessionInfo info;
1733     info.abilityName_ = "OnMoveDragCallback";
1734     info.bundleName_ = "OnMoveDragCallback";
1735 
1736     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1737     EXPECT_NE(sceneSession, nullptr);
1738 
1739     Session session(info);
1740     WSRect rect;
1741     sceneSession->UpdateWinRectForSystemBar(rect);
1742     sceneSession->SetSurfaceBounds(rect);
1743     sceneSession->GetWindowNameAllType();
1744     session.scenePersistence_ = new ScenePersistence("aa", 0);
1745     sceneSession->GetUpdatedIconPath();
1746 
1747     bool visible = true;
1748     sceneSession->UpdateNativeVisibility(visible);
1749 
1750     sceneSession->scenePersistence_ = new (std::nothrow) ScenePersistence(info.bundleName_, 0);
1751     EXPECT_NE(sceneSession->scenePersistence_, nullptr);
1752     sceneSession->GetUpdatedIconPath();
1753 }
1754 
1755 /**
1756  * @tc.name: OnMoveDragCallback
1757  * @tc.desc:  * @tc.name: OnMoveDragCallback
1758  * @tc.type: FUNC
1759  */
1760 HWTEST_F(SceneSessionTest2, OnMoveDragCallback01, Function | SmallTest | Level2)
1761 {
1762     SessionInfo info;
1763     info.abilityName_ = "OnMoveDragCallback01";
1764     info.bundleName_ = "OnMoveDragCallback01";
1765 
1766     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1767     EXPECT_NE(sceneSession, nullptr);
1768 
1769     double alpha = 0.5;
1770     Session session(info);
1771 
1772     sceneSession->SetSystemSceneOcclusionAlpha(alpha);
1773     sceneSession->IsNeedDefaultAnimation();
1774     bool isPlaying = true;
1775     sceneSession->NotifyIsCustomAnimationPlaying(isPlaying);
1776 
1777     sptr<AAFwk::SessionInfo> abilitySessionInfo = nullptr;
1778     bool visible = true;
1779     sceneSession->ChangeSessionVisibilityWithStatusBar(abilitySessionInfo, visible);
1780 }
1781 
1782 /**
1783  * @tc.name: OnMoveDragCallback
1784  * @tc.desc:  * @tc.name: OnMoveDragCallback
1785  * @tc.type: FUNC
1786  */
1787 HWTEST_F(SceneSessionTest2, OnMoveDragCallback02, Function | SmallTest | Level2)
1788 {
1789     SessionInfo info;
1790     info.abilityName_ = "OnMoveDragCallback02";
1791     info.bundleName_ = "OnMoveDragCallback02";
1792 
1793     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1794     EXPECT_NE(sceneSession, nullptr);
1795     sptr<SceneSession> ssession = nullptr;
1796     sceneSession->HandleCastScreenConnection(info, ssession);
1797 
1798     Session session(info);
1799     sptr<AAFwk::SessionInfo> abilitySessionInfo = nullptr;
1800     session.isTerminating_ = true;
1801     sceneSession->TerminateSession(abilitySessionInfo);
1802 
1803     bool needRemoveSession = true;
__anon5dbd079e0f02(const SessionInfo& info, bool removeSession, bool startFail) 1804     session.sessionExceptionFunc_ = [](const SessionInfo& info, bool removeSession, bool startFail) {};
__anon5dbd079e1002(const SessionInfo& info, bool removeSession, bool startFail) 1805     session.jsSceneSessionExceptionFunc_ = [](const SessionInfo& info, bool removeSession, bool startFail) {};
1806     sceneSession->NotifySessionException(abilitySessionInfo, needRemoveSession);
1807 
1808     sceneSession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback();
1809     sceneSession->NotifyPiPWindowPrepareClose();
1810 
1811     bool isLandscapeMultiWindow = true;
1812     sceneSession->SetLandscapeMultiWindow(isLandscapeMultiWindow);
1813 
1814     std::shared_ptr<MMI::KeyEvent> keyEvent = std::make_shared<MMI::KeyEvent>(MMI::KeyEvent::KEYCODE_BACK);
1815     bool isPreImeEvent = true;
1816     sceneSession->SendKeyEventToUI(keyEvent, isPreImeEvent);
1817     sceneSession->IsDirtyWindow();
1818     sceneSession->moveDragController_ = new MoveDragController(0);
1819     sceneSession->NotifyUILostFocus();
1820 }
1821 
1822 /**
1823  * @tc.name: IsStartMoving
1824  * @tc.desc:  * @tc.name: IsStartMoving
1825  * @tc.type: FUNC
1826  */
1827 HWTEST_F(SceneSessionTest2, IsStartMoving, Function | SmallTest | Level2)
1828 {
1829     SessionInfo info;
1830     info.abilityName_ = "IsStartMoving";
1831     info.bundleName_ = "IsStartMoving";
1832 
1833     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1834     EXPECT_NE(sceneSession, nullptr);
1835 
1836     sceneSession->IsStartMoving();
1837     bool startMoving = true;
1838     sceneSession->SetIsStartMoving(startMoving);
1839     DisplayId from = 0;
1840     DisplayId to = 0;
1841     sceneSession->NotifyDisplayMove(from, to);
1842     sceneSession->ClearExtWindowFlags();
1843     bool isRegister = true;
1844     sceneSession->UpdateRectChangeListenerRegistered(isRegister);
1845 
1846     sceneSession->sessionStage_ = new SessionStageMocker();
1847     EXPECT_NE(nullptr, sceneSession->sessionStage_);
1848     sceneSession->NotifyDisplayMove(from, to);
1849 }
1850 
1851 /**
1852  * @tc.name: IsSystemSpecificSession
1853  * @tc.desc: IsSystemSpecificSession
1854  * @tc.type: FUNC
1855  */
1856 HWTEST_F(SceneSessionTest2, IsSystemSpecificSession, Function | SmallTest | Level2)
1857 {
1858     SessionInfo info;
1859     info.abilityName_ = "IsSystemSpecificSession";
1860     info.bundleName_ = "IsSystemSpecificSession";
1861 
1862     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1863     ASSERT_NE(sceneSession, nullptr);
1864 
1865     ASSERT_FALSE(sceneSession->IsSystemSpecificSession());
1866     sceneSession->SetIsSystemSpecificSession(true);
1867     ASSERT_TRUE(sceneSession->IsSystemSpecificSession());
1868 }
1869 
1870 /**
1871  * @tc.name: SetTemporarilyShowWhenLocked
1872  * @tc.desc:  * @tc.name: SetTemporarilyShowWhenLocked
1873  * @tc.type: FUNC
1874  */
1875 HWTEST_F(SceneSessionTest2, SetTemporarilyShowWhenLocked, Function | SmallTest | Level2)
1876 {
1877     SessionInfo info;
1878     info.abilityName_ = "SetTemporarilyShowWhenLocked";
1879     info.bundleName_ = "SetTemporarilyShowWhenLocked";
1880     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1881     EXPECT_NE(sceneSession, nullptr);
1882     bool isTemporarilyShowWhenLocked = sceneSession->IsTemporarilyShowWhenLocked();
1883     ASSERT_EQ(isTemporarilyShowWhenLocked, false);
1884     sceneSession->SetTemporarilyShowWhenLocked(true);
1885     isTemporarilyShowWhenLocked = sceneSession->IsTemporarilyShowWhenLocked();
1886     ASSERT_EQ(isTemporarilyShowWhenLocked, true);
1887     sceneSession->SetTemporarilyShowWhenLocked(false);
1888     isTemporarilyShowWhenLocked = sceneSession->IsTemporarilyShowWhenLocked();
1889     ASSERT_EQ(isTemporarilyShowWhenLocked, false);
1890 
1891     sceneSession->isTemporarilyShowWhenLocked_.store(true);
1892     sceneSession->SetTemporarilyShowWhenLocked(true);
1893     ASSERT_EQ(sceneSession->IsTemporarilyShowWhenLocked(), true);
1894 }
1895 
1896 /**
1897  * @tc.name: GetShowWhenLockedFlagValue
1898  * @tc.desc:  * @tc.name: GetShowWhenLockedFlagValue
1899  * @tc.type: FUNC
1900  */
1901 HWTEST_F(SceneSessionTest2, GetShowWhenLockedFlagValue, Function | SmallTest | Level2)
1902 {
1903     SessionInfo info;
1904     info.abilityName_ = "GetShowWhenLockedFlagValue";
1905     info.bundleName_ = "GetShowWhenLockedFlagValue";
1906     info.windowType_ = 1;
1907     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1908         new (std::nothrow) SceneSession::SpecificSessionCallback();
1909     EXPECT_NE(specificCallback_, nullptr);
1910     sptr<SceneSession> scensession;
1911     scensession = new (std::nothrow) SceneSession(info, specificCallback_);
1912     EXPECT_NE(scensession, nullptr);
1913     sptr<WindowSessionProperty> property = new WindowSessionProperty();
1914     EXPECT_NE(property, nullptr);
1915     property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1916     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1917     ASSERT_EQ(scensession->GetShowWhenLockedFlagValue(), false);
1918     scensession->property_ = property;
1919     property->SetWindowFlags(4);
1920     ASSERT_EQ(scensession->GetShowWhenLockedFlagValue(), true);
1921 }
1922 
1923 /**
1924  * @tc.name: SetClientIdentityToken
1925  * @tc.desc: SetClientIdentityToken
1926  * @tc.type: FUNC
1927  */
1928 HWTEST_F(SceneSessionTest2, SetClientIdentityToken, Function | SmallTest | Level2)
1929 {
1930     SessionInfo info;
1931     info.abilityName_ = "SetClientIdentityToken";
1932     info.bundleName_ = "SetClientIdentityToken";
1933     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1934     EXPECT_NE(sceneSession, nullptr);
1935     std::string token = "testToken";
1936     sceneSession->SetClientIdentityToken(token);
1937     ASSERT_EQ(sceneSession->GetClientIdentityToken(), token);
1938 }
1939 
1940 /**
1941  * @tc.name: SetSkipDraw
1942  * @tc.desc: SetSkipDraw
1943  * @tc.type: FUNC
1944  */
1945 HWTEST_F(SceneSessionTest2, SetSkipDraw, Function | SmallTest | Level2)
1946 {
1947     SessionInfo info;
1948     info.abilityName_ = "SetSkipDraw";
1949     info.bundleName_ = "SetSkipDraw";
1950     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1951     EXPECT_NE(sceneSession, nullptr);
1952     sceneSession->SetSkipDraw(true);
1953     sceneSession->SetSkipDraw(false);
1954 }
1955 
1956 /**
1957  * @tc.name: GetWindowDragHotAreaType
1958  * @tc.desc: GetWindowDragHotAreaType
1959  * @tc.type: FUNC
1960  */
1961 HWTEST_F(SceneSessionTest2, GetWindowDragHotAreaType, Function | SmallTest | Level2)
1962 {
1963     SessionInfo info;
1964     info.abilityName_ = "HotAreaType";
1965     info.bundleName_ = "HotAreaType";
1966     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1967     EXPECT_NE(sceneSession, nullptr);
1968     WSRect rect = {0, 0, 10, 10};
1969     sceneSession->AddOrUpdateWindowDragHotArea(1, rect);
1970     sceneSession->AddOrUpdateWindowDragHotArea(1, rect);
1971     auto type = sceneSession->GetWindowDragHotAreaType(1, 2, 2);
1972     ASSERT_EQ(type, 1);
1973 }
1974 
1975 /**
1976  * @tc.name: RegisterSubModalTypeChangeCallback
1977  * @tc.desc: RegisterSubModalTypeChangeCallback
1978  * @tc.type: FUNC
1979  */
1980 HWTEST_F(SceneSessionTest2, RegisterSubModalTypeChangeCallback, Function | SmallTest | Level2)
1981 {
1982     SessionInfo info;
1983     info.abilityName_ = "RegisterSubModalTypeChangeCallback";
1984     info.bundleName_ = "RegisterSubModalTypeChangeCallback";
1985     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1986     EXPECT_NE(sceneSession, nullptr);
__anon5dbd079e1102(SubWindowModalType subWindowModalType) 1987     sceneSession->RegisterSubModalTypeChangeCallback([](SubWindowModalType subWindowModalType) {
1988         return;
1989     });
1990     EXPECT_NE(sceneSession->onSubModalTypeChange_, nullptr);
1991 }
1992 
1993 /**
1994  * @tc.name: NotifySubModalTypeChange
1995  * @tc.desc: NotifySubModalTypeChange
1996  * @tc.type: FUNC
1997  */
1998 HWTEST_F(SceneSessionTest2, NotifySubModalTypeChange, Function | SmallTest | Level2)
1999 {
2000     SessionInfo info;
2001     info.abilityName_ = "NotifySubModalTypeChange";
2002     info.bundleName_ = "NotifySubModalTypeChange";
2003     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
2004     EXPECT_NE(sceneSession, nullptr);
__anon5dbd079e1202(SubWindowModalType subWindowModalType) 2005     sceneSession->RegisterSubModalTypeChangeCallback([](SubWindowModalType subWindowModalType) {
2006         return;
2007     });
2008     EXPECT_NE(sceneSession->onSubModalTypeChange_, nullptr);
2009     EXPECT_EQ(sceneSession->NotifySubModalTypeChange(SubWindowModalType::TYPE_WINDOW_MODALITY), WSError::WS_OK);
2010 }
2011 
2012 /**
2013  * @tc.name: RegisterMainModalTypeChangeCallback
2014  * @tc.desc: RegisterMainModalTypeChangeCallback
2015  * @tc.type: FUNC
2016  */
2017 HWTEST_F(SceneSessionTest2, RegisterMainModalTypeChangeCallback, Function | SmallTest | Level2)
2018 {
2019     SessionInfo info;
2020     info.abilityName_ = "RegisterMainModalTypeChangeCallback";
2021     info.bundleName_ = "RegisterMainModalTypeChangeCallback";
2022     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
2023     EXPECT_NE(sceneSession, nullptr);
__anon5dbd079e1302(bool isModal) 2024     sceneSession->RegisterMainModalTypeChangeCallback([](bool isModal) {
2025         return;
2026     });
2027     EXPECT_NE(sceneSession->onMainModalTypeChange_, nullptr);
2028 }
2029 
2030 /**
2031  * @tc.name: GetSubWindowModalType
2032  * @tc.desc: GetSubWindowModalType
2033  * @tc.type: FUNC
2034  */
2035 HWTEST_F(SceneSessionTest2, GetSubWindowModalType, Function | SmallTest | Level2)
2036 {
2037     SessionInfo info;
2038     info.abilityName_ = "ModalType";
2039     info.bundleName_ = "ModalType";
2040     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
2041     EXPECT_NE(sceneSession, nullptr);
2042 
2043     sceneSession->SetSessionProperty(nullptr);
2044     auto result = sceneSession->GetSubWindowModalType();
2045     ASSERT_EQ(result, SubWindowModalType::TYPE_UNDEFINED);
2046 
2047     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
2048     EXPECT_NE(property, nullptr);
2049     property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
2050     sceneSession->SetSessionProperty(property);
2051     result = sceneSession->GetSubWindowModalType();
2052     ASSERT_EQ(result, SubWindowModalType::TYPE_DIALOG);
2053 }
2054 
2055 /**
2056  * @tc.name: CheckGetAvoidAreaAvailable
2057  * @tc.desc: CheckGetAvoidAreaAvailable
2058  * @tc.type: FUNC
2059  */
2060 HWTEST_F(SceneSessionTest2, CheckGetAvoidAreaAvailable, Function | SmallTest | Level2)
2061 {
2062     SessionInfo info;
2063     info.abilityName_ = "CheckGetAvoidAreaAvailable";
2064     info.bundleName_ = "CheckGetAvoidAreaAvailable";
2065     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
2066     EXPECT_NE(sceneSession, nullptr);
2067 
2068     sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
2069     EXPECT_NE(property, nullptr);
2070     property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
2071     sceneSession->SetSessionProperty(property);
2072     sceneSession->CheckGetAvoidAreaAvailable(AvoidAreaType::TYPE_SYSTEM);
2073 
2074     property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
2075     sceneSession->SetSessionProperty(property);
2076     sceneSession->CheckGetAvoidAreaAvailable(AvoidAreaType::TYPE_SYSTEM);
2077 }
2078 
2079 /**
2080  * @tc.name: SetWindowAnimationFlag
2081  * @tc.desc: SetWindowAnimationFlag
2082  * @tc.type: FUNC
2083  */
2084 HWTEST_F(SceneSessionTest2, SetWindowAnimationFlag, Function | SmallTest | Level2)
2085 {
2086     SessionInfo info;
2087     info.abilityName_ = "SetWindowAnimationFlag";
2088     info.bundleName_ = "SetWindowAnimationFlag";
2089     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
2090     EXPECT_NE(sceneSession, nullptr);
2091 
__anon5dbd079e1402(bool isNeedDefaultAnimationFlag) 2092     sceneSession->onWindowAnimationFlagChange_ = [](bool isNeedDefaultAnimationFlag) {};
2093     sceneSession->SetWindowAnimationFlag(true);
2094     ASSERT_EQ(true, sceneSession->needDefaultAnimationFlag_);
2095 }
2096 
2097 /**
2098  * @tc.name: SetTitleAndDockHoverShowChangeCallback
2099  * @tc.desc: SetTitleAndDockHoverShowChangeCallback
2100  * @tc.type: FUNC
2101  */
2102 HWTEST_F(SceneSessionTest2, SetTitleAndDockHoverShowChangeCallback, Function | SmallTest | Level2)
2103 {
2104     SessionInfo info;
2105     info.abilityName_ = "SetTitleAndDockHoverShowChangeCallback";
2106     info.bundleName_ = "SetTitleAndDockHoverShowChangeCallback";
2107     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
__anon5dbd079e1502(bool isTitleHoverShown, bool isDockHoverShown) 2108     sceneSession->SetTitleAndDockHoverShowChangeCallback([](bool isTitleHoverShown, bool isDockHoverShown) {
2109         return;
2110     });
2111     EXPECT_NE(sceneSession->onTitleAndDockHoverShowChangeFunc_, nullptr);
2112 }
2113 
2114 }
2115 
2116 /**
2117  * @tc.name: IsFullScreenMovable
2118  * @tc.desc: IsFullScreenMovable
2119  * @tc.type: FUNC
2120  */
2121 HWTEST_F(SceneSessionTest2, IsFullScreenMovable, Function | SmallTest | Level2)
2122 {
2123     SessionInfo info;
2124     info.abilityName_ = "IsFullScreenMovable";
2125     info.bundleName_ = "IsFullScreenMovable";
2126     sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
2127     EXPECT_NE(sceneSession, nullptr);
2128 
2129     sceneSession->SetSessionProperty(nullptr);
2130     auto result = sceneSession->IsFullScreenMovable();
2131     ASSERT_EQ(false, result);
2132 }
2133 }
2134 }