• 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 "window_helper.h"
17 #include "display_manager.h"
18 #include "pointer_event.h"
19 
20 #include <gtest/gtest.h>
21 #include "scene_board_judgement.h"
22 #include "key_event.h"
23 #include "session/host/include/scene_session.h"
24 #include "session/host/include/sub_session.h"
25 #include "session/host/include/system_session.h"
26 #include "session/host/include/main_session.h"
27 #include "wm_common.h"
28 #include "mock/mock_session_stage.h"
29 #include "input_event.h"
30 #include <pointer_event.h>
31 #include "ui/rs_surface_node.h"
32 
33 using namespace testing;
34 using namespace testing::ext;
35 namespace OHOS {
36 namespace Rosen {
37 class SceneSessionTest2 : public testing::Test {
38 public:
39     static void SetUpTestCase();
40     static void TearDownTestCase();
41     void SetUp() override;
42     void TearDown() override;
43 };
44 
SetUpTestCase()45 void SceneSessionTest2::SetUpTestCase()
46 {
47 }
48 
TearDownTestCase()49 void SceneSessionTest2::TearDownTestCase()
50 {
51 }
52 
SetUp()53 void SceneSessionTest2::SetUp()
54 {
55 }
56 
TearDown()57 void SceneSessionTest2::TearDown()
58 {
59 }
60 
61 namespace {
62 /**
63  * @tc.name: RaiseAboveTarget
64  * @tc.desc: normal function
65  * @tc.type: FUNC
66  */
67 HWTEST_F(SceneSessionTest2, RaiseAboveTarget, Function | SmallTest | Level2)
68 {
69     SessionInfo info;
70     info.abilityName_ = "RaiseAboveTarget";
71     info.bundleName_ = "RaiseAboveTarget";
72     sptr<Rosen::ISession> session_;
73     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
74         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
75     EXPECT_NE(specificCallback_, nullptr);
76     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
77     EXPECT_NE(sceneSession, nullptr);
78     sceneSession->isActive_ = true;
79 
80     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
81     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
82     property->keyboardLayoutParams_.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM;
83 
84     sceneSession->SetSessionProperty(property);
85     WSError result = sceneSession->RaiseAboveTarget(0);
86     ASSERT_EQ(result, WSError::WS_OK);
87 
88     sptr<SceneSession> tempSession = sptr<SceneSession>::MakeSptr(info, nullptr);
89     int32_t persistentId = 1;
90     tempSession->persistentId_ = persistentId;
91     int32_t callingPid = 2;
92     tempSession->callingPid_ = callingPid;
93     sceneSession->subSession_.push_back(tempSession);
94     int32_t subWindowId = 1;
95     result = sceneSession->RaiseAboveTarget(subWindowId);
96     ASSERT_EQ(result, WSError::WS_ERROR_INVALID_CALLING);
97 
98     sceneSession->onRaiseAboveTarget_ = nullptr;
99     result = sceneSession->RaiseAboveTarget(0);
100     ASSERT_EQ(result, WSError::WS_OK);
101 }
102 
103 /**
104  * @tc.name: NotifyPropertyWhenConnect1
105  * @tc.desc: NotifyPropertyWhenConnect1
106  * @tc.type: FUNC
107  */
108 HWTEST_F(SceneSessionTest2, NotifyPropertyWhenConnect1, Function | SmallTest | Level2)
109 {
110     SessionInfo info;
111     info.abilityName_ = "ability";
112     info.bundleName_ = "bundle";
113     info.moduleName_ = "module";
114     info.windowType_ = 1;
115     sptr<Rosen::ISession> session_;
116     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
117         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
118     EXPECT_NE(specificCallback_, nullptr);
119     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
120     EXPECT_NE(sceneSession, nullptr);
121     int ret = 1;
122     std::string key = info.bundleName_ + info.moduleName_ + info.abilityName_;
123     sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback_);
124     sceneSession->NotifyPropertyWhenConnect();
125 
126     sptr<WindowSessionProperty> property = nullptr;
127     sceneSession->NotifyPropertyWhenConnect();
128     ASSERT_EQ(ret, 1);
129 }
130 
131 /**
132  * @tc.name: GetSystemAvoidArea
133  * @tc.desc: normal function
134  * @tc.type: FUNC
135  */
136 HWTEST_F(SceneSessionTest2, GetSystemAvoidArea, Function | SmallTest | Level2)
137 {
138     SessionInfo info;
139     info.abilityName_ = "GetSystemAvoidArea";
140     info.bundleName_ = "GetSystemAvoidArea";
141     sptr<Rosen::ISession> session_;
142     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
143         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
144     EXPECT_NE(specificCallback_, nullptr);
145     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
146     EXPECT_NE(sceneSession, nullptr);
147     sceneSession->isActive_ = true;
148 
149     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
150     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
151     int32_t p = 10;
152     property->SetWindowFlags(static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_NEED_AVOID));
153 
154     sceneSession->SetSessionProperty(property);
155     WSRect rect({1, 1, 1, 1});
156     AvoidArea avoidArea;
157     sceneSession->GetSystemAvoidArea(rect, avoidArea);
158     ASSERT_EQ(p, 10);
159 }
160 
161 /**
162  * @tc.name: TransferPointerEvent
163  * @tc.desc: TransferPointerEvent
164  * @tc.type: FUNC
165  */
166 HWTEST_F(SceneSessionTest2, TransferPointerEvent01, Function | SmallTest | Level2)
167 {
168     SessionInfo info;
169     info.abilityName_ = "Background01";
170     info.bundleName_ = "IsFloatingWindowAppType";
171     info.windowType_ = 1;
172     sptr<Rosen::ISession> session_;
173     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
174         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
175     EXPECT_NE(specificCallback_, nullptr);
176     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback_);
177     EXPECT_NE(sceneSession, nullptr);
178     std::shared_ptr<MMI::PointerEvent> pointerEvent = nullptr;
179     ASSERT_EQ(sceneSession->TransferPointerEvent(pointerEvent), WSError::WS_OK);
180 
181     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
182     property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
183     property->SetMaximizeMode(MaximizeMode::MODE_FULL_FILL);
184     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
185     property->SetPersistentId(11);
186     sceneSession->property_ = property;
187 
188     std::shared_ptr<MMI::PointerEvent> pointerEvent_ = MMI::PointerEvent::Create();
189     pointerEvent_->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_ENTER_WINDOW);
190     ASSERT_EQ(sceneSession->TransferPointerEvent(pointerEvent_), WSError::WS_OK);
191 
192     sceneSession->sessionInfo_.isSystem_ = true;
193     pointerEvent_->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_BUTTON_DOWN);
194     ASSERT_EQ(sceneSession->TransferPointerEvent(pointerEvent_), WSError::WS_OK);
195 
196     pointerEvent_->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_ENTER_WINDOW);
197     ASSERT_EQ(sceneSession->TransferPointerEvent(pointerEvent_), WSError::WS_OK);
198 
199     sceneSession->sessionInfo_.isSystem_ = false;
200     pointerEvent_->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_BUTTON_DOWN);
201     ASSERT_EQ(sceneSession->TransferPointerEvent(pointerEvent_), WSError::WS_OK);
202 
203     pointerEvent_->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_ENTER_WINDOW);
204     ASSERT_EQ(sceneSession->TransferPointerEvent(pointerEvent_), WSError::WS_OK);
205 }
206 
207 /**
208  * @tc.name: TransferPointerEvent
209  * @tc.desc: TransferPointerEvent
210  * @tc.type: FUNC
211  */
212 HWTEST_F(SceneSessionTest2, TransferPointerEvent02, Function | SmallTest | Level2)
213 {
214     SessionInfo info;
215     info.abilityName_ = "Background01";
216     info.bundleName_ = "IsSubWindowAppType";
217     info.windowType_ = 1;
218     sptr<Rosen::ISession> session_;
219     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
220         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
221     EXPECT_NE(specificCallback_, nullptr);
222     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback_);
223     EXPECT_NE(sceneSession, nullptr);
224     std::shared_ptr<MMI::PointerEvent> pointerEvent = nullptr;
225     ASSERT_EQ(sceneSession->TransferPointerEvent(pointerEvent), WSError::WS_OK);
226 
227     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
228     property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
229     property->SetMaximizeMode(MaximizeMode::MODE_FULL_FILL);
230     property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
231     property->SetPersistentId(11);
232     sceneSession->property_ = property;
233 
234     std::shared_ptr<MMI::PointerEvent> pointerEvent_ = MMI::PointerEvent::Create();
235     pointerEvent_->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_DOWN);
236     ASSERT_EQ(sceneSession->TransferPointerEvent(pointerEvent_), WSError::WS_OK);
237 }
238 
239 /**
240  * @tc.name: RequestSessionBack
241  * @tc.desc: normal function
242  * @tc.type: FUNC
243  */
244 HWTEST_F(SceneSessionTest2, RequestSessionBack, Function | SmallTest | Level2)
245 {
246     SessionInfo info;
247     info.abilityName_ = "RequestSessionBack";
248     info.bundleName_ = "RequestSessionBack";
249     sptr<Rosen::ISession> session_;
250     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
251         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
252     EXPECT_NE(specificCallback_, nullptr);
253     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
254     EXPECT_NE(sceneSession, nullptr);
255     sceneSession->isActive_ = true;
256 
257     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
258     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
259     property->keyboardLayoutParams_.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM;
260     sceneSession->SetSessionProperty(property);
261 
262     WSError result = sceneSession->RequestSessionBack(true);
263     ASSERT_EQ(result, WSError::WS_OK);
264 
265     struct RSSurfaceNodeConfig config;
266     std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
267     EXPECT_NE(nullptr, surfaceNode);
268     sceneSession->SetLeashWinSurfaceNode(surfaceNode);
269     result = sceneSession->RequestSessionBack(true);
270     ASSERT_EQ(result, WSError::WS_OK);
271 }
272 
273 /**
274  * @tc.name: SetParentPersistentId
275  * @tc.desc: normal function
276  * @tc.type: FUNC
277  */
278 HWTEST_F(SceneSessionTest2, SetParentPersistentId, Function | SmallTest | Level2)
279 {
280     SessionInfo info;
281     info.abilityName_ = "SetParentPersistentId";
282     info.bundleName_ = "SetParentPersistentId";
283     sptr<Rosen::ISession> session_;
284     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
285         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
286     EXPECT_NE(specificCallback_, nullptr);
287     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
288     EXPECT_NE(sceneSession, nullptr);
289     sceneSession->isActive_ = true;
290 
291     sceneSession->SetParentPersistentId(0);
292     int32_t result = sceneSession->GetParentPersistentId();
293     ASSERT_EQ(result, 0);
294 
295     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
296     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
297 
298     sceneSession->SetSessionProperty(property);
299     sceneSession->SetParentPersistentId(0);
300     result = sceneSession->GetParentPersistentId();
301     ASSERT_EQ(result, 0);
302 }
303 
304 /**
305  * @tc.name: GetMainSessionId
306  * @tc.desc: GetMainSessionId Test
307  * @tc.type: FUNC
308  */
309 HWTEST_F(SceneSessionTest2, GetMainSessionId, Function | SmallTest | Level2)
310 {
311     SessionInfo info;
312     info.abilityName_ = "GetMainSessionId";
313     info.moduleName_ = "GetMainSessionId";
314     info.bundleName_ = "GetMainSessionId";
315 
316     sptr<Session> session = sptr<Session>::MakeSptr(info);
317     EXPECT_NE(session, nullptr);
318     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
319     EXPECT_NE(property, nullptr);
320     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
321     property->SetPersistentId(0);
322     session->SetSessionProperty(property);
323 
324     sptr<Session> subSession = sptr<Session>::MakeSptr(info);
325     EXPECT_NE(subSession, nullptr);
326     subSession->SetParentSession(session);
327     sptr<WindowSessionProperty> subProperty = sptr<WindowSessionProperty>::MakeSptr();
328     EXPECT_NE(subProperty, nullptr);
329     subProperty->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
330     subProperty->SetPersistentId(1);
331     subSession->SetSessionProperty(subProperty);
332 
333     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
334     EXPECT_NE(sceneSession, nullptr);
335     sceneSession->SetParentSession(subSession);
336     sptr<WindowSessionProperty> sceneProperty = sptr<WindowSessionProperty>::MakeSptr();
337     EXPECT_NE(sceneProperty, nullptr);
338     sceneProperty->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
339     sceneProperty->SetPersistentId(2);
340     sceneSession->SetSessionProperty(sceneProperty);
341     auto result = sceneSession->GetMainSessionId();
342     ASSERT_EQ(result, 0);
343 }
344 
345 /**
346  * @tc.name: UpdateSizeChangeReason01
347  * @tc.desc: UpdateSizeChangeReason01
348  * @tc.type: FUNC
349  */
350 HWTEST_F(SceneSessionTest2, UpdateSizeChangeReason01, Function | SmallTest | Level2)
351 {
352     SessionInfo info;
353     info.abilityName_ = "UpdateSizeChangeReason01";
354     info.bundleName_ = "UpdateSizeChangeReason01";
355     info.windowType_ = 1;
356     sptr<Rosen::ISession> session_;
357     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
358         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
359     EXPECT_NE(specificCallback_, nullptr);
360     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
361     EXPECT_NE(sceneSession, nullptr);
362     sptr<SessionStageMocker> mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
363     ASSERT_NE(mockSessionStage, nullptr);
364     sceneSession->dirtyFlags_ |= static_cast<uint32_t>(SessionUIDirtyFlag::RECT);
365     sceneSession->sessionStage_ = mockSessionStage;
366     sceneSession->UpdateSizeChangeReason(SizeChangeReason::ROTATION);
367     ASSERT_EQ(sceneSession->reason_, SizeChangeReason::ROTATION);
368     ASSERT_EQ(WSError::WS_OK, sceneSession->UpdateSizeChangeReason(SizeChangeReason::UNDEFINED));
369 }
370 
371 /**
372  * @tc.name: SetMinimizedFlagByUserSwitch/IsMinimizedByUserSwitch
373  * @tc.desc: SetMinimizedFlagByUserSwitch/IsMinimizedByUserSwitch Test
374  * @tc.type: FUNC
375  */
376 HWTEST_F(SceneSessionTest2, SetMinimizedFlagByUserSwitch, Function | SmallTest | Level2)
377 {
378     SessionInfo info;
379     info.abilityName_ = "SetMinimizedFlagByUserSwitch";
380     info.bundleName_ = "SetMinimizedFlagByUserSwitch";
381 
382     sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
383     EXPECT_NE(session, nullptr);
384 
385     bool isMinimized = true;
386     session->SetMinimizedFlagByUserSwitch(isMinimized);
387     bool ret = session->IsMinimizedByUserSwitch();
388     ASSERT_EQ(ret, true);
389 
390     isMinimized = false;
391     session->SetMinimizedFlagByUserSwitch(isMinimized);
392     ret = session->IsMinimizedByUserSwitch();
393     ASSERT_EQ(ret, false);
394 }
395 
396 /**
397  * @tc.name: UpdatePiPRect01
398  * @tc.desc: UpdatePiPRect
399  * @tc.type: FUNC
400  */
401 HWTEST_F(SceneSessionTest2, UpdatePiPRect, Function | SmallTest | Level2)
402 {
403     SessionInfo info;
404     info.abilityName_ = "UpdatePiPRect01";
405     info.bundleName_ = "UpdatePiPRect";
406     sptr<Rosen::ISession> session_;
407     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
408         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
409     EXPECT_NE(specificCallback_, nullptr);
410     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
411     EXPECT_NE(sceneSession, nullptr);
412     sceneSession->isActive_ = true;
413 
414     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
415     property->SetWindowType(WindowType::WINDOW_TYPE_PIP);
416     sceneSession->SetSessionProperty(property);
417 
418     Rect rect = {0, 0, 800, 600};
419     SizeChangeReason reason = SizeChangeReason::PIP_START;
420     WSError result = sceneSession->UpdatePiPRect(rect, reason);
421     ASSERT_EQ(result, WSError::WS_OK);
422 
423     property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
424     sceneSession->SetSessionProperty(property);
425     result = sceneSession->UpdatePiPRect(rect, reason);
426     ASSERT_EQ(result, WSError::WS_DO_NOTHING);
427 
428     property->SetWindowType(WindowType::WINDOW_TYPE_PIP);
429     sceneSession->SetSessionProperty(property);
430     sceneSession->isTerminating_ = true;
431     result = sceneSession->UpdatePiPRect(rect, reason);
432     ASSERT_EQ(result, WSError::WS_OK);
433 
434     sceneSession->isTerminating_ = false;
435     result = sceneSession->UpdatePiPRect(rect, reason);
436     ASSERT_EQ(result, WSError::WS_OK);
437 }
438 
439 /**
440  * @tc.name: UpdatePiPControlStatus
441  * @tc.desc: UpdatePiPControlStatus
442  * @tc.type: FUNC
443  */
444 HWTEST_F(SceneSessionTest2, UpdatePiPControlStatus, Function | SmallTest | Level2)
445 {
446     SessionInfo info;
447     info.abilityName_ = "UpdatePiPControlStatus";
448     info.bundleName_ = "UpdatePiPControlStatus";
449     auto sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
450     EXPECT_NE(sceneSession, nullptr);
451     sceneSession->isActive_ = true;
452 
453     auto property = sptr<WindowSessionProperty>::MakeSptr();
454     EXPECT_NE(property, nullptr);
455     property->SetWindowType(WindowType::WINDOW_TYPE_PIP);
456     sceneSession->SetSessionProperty(property);
457 
458     auto controlType = WsPiPControlType::VIDEO_PLAY_PAUSE;
459     auto status = WsPiPControlStatus::PLAY;
460     WSError result = sceneSession->UpdatePiPControlStatus(controlType, status);
461     ASSERT_EQ(result, WSError::WS_OK);
462 
463     property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
464     sceneSession->SetSessionProperty(property);
465     result = sceneSession->UpdatePiPControlStatus(controlType, status);
466     ASSERT_EQ(result, WSError::WS_DO_NOTHING);
467 }
468 
469 /**
470  * @tc.name: SetScale
471  * @tc.desc: SetScale
472  * @tc.type: FUNC
473  */
474 HWTEST_F(SceneSessionTest2, SetScale, Function | SmallTest | Level2)
475 {
476     SessionInfo info;
477     info.abilityName_ = "SetScale";
478     info.bundleName_ = "SetScale";
479     sptr<Rosen::ISession> session_;
480     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
481         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
482     EXPECT_NE(specificCallback_, nullptr);
483     int resultValue = 0;
484     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
485     EXPECT_NE(sceneSession, nullptr);
486     sceneSession->SetScale(1.0f, 1.0f, 0.0f, 0.0f);
487     ASSERT_EQ(0, resultValue);
488 }
489 
490 /**
491  * @tc.name: SetIsDisplayStatusBarTemporarily
492  * @tc.desc: SetIsDisplayStatusBarTemporarily
493  * @tc.type: FUNC
494  */
495 HWTEST_F(SceneSessionTest2, SetIsDisplayStatusBarTemporarily, Function | SmallTest | Level2)
496 {
497     SessionInfo info;
498     info.abilityName_ = "SetIsDisplayStatusBarTemporarily";
499     info.bundleName_ = "SetIsDisplayStatusBarTemporarily";
500     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
501     EXPECT_NE(sceneSession, nullptr);
502     sceneSession->SetIsDisplayStatusBarTemporarily(true);
503     ASSERT_EQ(true, sceneSession->GetIsDisplayStatusBarTemporarily());
504     sceneSession->SetIsDisplayStatusBarTemporarily(false);
505     ASSERT_EQ(false, sceneSession->GetIsDisplayStatusBarTemporarily());
506 }
507 
508 /**
509  * @tc.name: UpdateAvoidArea
510  * @tc.desc: UpdateAvoidArea
511  * @tc.type: FUNC
512  */
513 HWTEST_F(SceneSessionTest2, UpdateAvoidArea, Function | SmallTest | Level2)
514 {
515     SessionInfo info;
516     info.abilityName_ = "UpdateAvoidArea";
517     info.bundleName_ = "UpdateAvoidArea";
518     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
519     sceneSession->sessionStage_ = nullptr;
520     WSError result = sceneSession->UpdateAvoidArea(nullptr, AvoidAreaType::TYPE_SYSTEM);
521     EXPECT_EQ(WSError::WS_ERROR_NULLPTR, result);
522 
523     sceneSession->sessionStage_ = sptr<SessionStageMocker>::MakeSptr();
524     EXPECT_NE(nullptr, sceneSession->sessionStage_);
525     result = sceneSession->UpdateAvoidArea(nullptr, AvoidAreaType::TYPE_SYSTEM);
526     EXPECT_EQ(WSError::WS_OK, result);
527     sceneSession->foregroundInteractiveStatus_.store(false);
528     result = sceneSession->UpdateAvoidArea(nullptr, AvoidAreaType::TYPE_SYSTEM);
529     EXPECT_EQ(WSError::WS_DO_NOTHING, result);
530 }
531 
532 /**
533  * @tc.name: ChangeSessionVisibilityWithStatusBar
534  * @tc.desc: normal function
535  * @tc.type: FUNC
536  */
537 HWTEST_F(SceneSessionTest2, ChangeSessionVisibilityWithStatusBar, Function | SmallTest | Level2)
538 {
539     SessionInfo info;
540     info.abilityName_ = "ChangeSessionVisibilityWithStatusBar";
541     info.bundleName_ = "ChangeSessionVisibilityWithStatusBar";
542 
543     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
544     EXPECT_NE(sceneSession, nullptr);
545     sceneSession->isActive_ = true;
546 
547     sptr<AAFwk::SessionInfo> info1 = nullptr;
548     WSError result = sceneSession->ChangeSessionVisibilityWithStatusBar(info1, false);
549     ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
550 
551     sptr<AAFwk::SessionInfo> abilitySessionInfo = sptr<AAFwk::SessionInfo>::MakeSptr();
552     result = sceneSession->ChangeSessionVisibilityWithStatusBar(abilitySessionInfo, false);
553     ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
554 }
555 
556 /**
557  * @tc.name: SetShouldHideNonSecureWindows
558  * @tc.desc: SetShouldHideNonSecureWindows
559  * @tc.type: FUNC
560  */
561 HWTEST_F(SceneSessionTest2, SetShouldHideNonSecureWindows, Function | SmallTest | Level2)
562 {
563     SessionInfo info;
564     info.abilityName_ = "SetShouldHideNonSecureWindows";
565     info.bundleName_ = "SetShouldHideNonSecureWindows";
566 
567     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
568     EXPECT_NE(sceneSession, nullptr);
569 
570     EXPECT_FALSE(sceneSession->shouldHideNonSecureWindows_.load());
571     sceneSession->SetShouldHideNonSecureWindows(true);
572     EXPECT_TRUE(sceneSession->shouldHideNonSecureWindows_.load());
573 }
574 
575 /**
576  * @tc.name: UpdateExtWindowFlags
577  * @tc.desc: update uiextension window flags
578  * @tc.type: FUNC
579  */
580 HWTEST_F(SceneSessionTest2, UpdateExtWindowFlags, Function | SmallTest | Level2)
581 {
582     SessionInfo info;
583     info.abilityName_ = "UpdateExtWindowFlags";
584     info.bundleName_ = "UpdateExtWindowFlags";
585 
586     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
587     EXPECT_NE(sceneSession, nullptr);
588 
589     EXPECT_TRUE(sceneSession->extWindowFlagsMap_.empty());
590     int32_t persistentId = 12345;
591     ExtensionWindowFlags flags(7);
592     ExtensionWindowFlags actions(7);
593     sceneSession->UpdateExtWindowFlags(persistentId, flags, actions);
594     EXPECT_EQ(sceneSession->extWindowFlagsMap_.size(), 1);
595     EXPECT_EQ(sceneSession->extWindowFlagsMap_.begin()->first, persistentId);
596     EXPECT_EQ(sceneSession->extWindowFlagsMap_.begin()->second.bitData, 7);
597     flags.bitData = 0;
598     actions.bitData = 3;
599     sceneSession->UpdateExtWindowFlags(persistentId, flags, actions);
600     EXPECT_EQ(sceneSession->extWindowFlagsMap_.size(), 1);
601     EXPECT_EQ(sceneSession->extWindowFlagsMap_.begin()->first, persistentId);
602     EXPECT_EQ(sceneSession->extWindowFlagsMap_.begin()->second.bitData, 4);
603     actions.bitData = 4;
604     sceneSession->UpdateExtWindowFlags(persistentId, flags, actions);
605     EXPECT_TRUE(sceneSession->extWindowFlagsMap_.empty());
606 }
607 
608 /**
609  * @tc.name: GetCombinedExtWindowFlags
610  * @tc.desc: get combined uiextension window flags
611  * @tc.type: FUNC
612  */
613 HWTEST_F(SceneSessionTest2, GetCombinedExtWindowFlags, Function | SmallTest | Level2)
614 {
615     SessionInfo info;
616     info.abilityName_ = "GetCombinedExtWindowFlags";
617     info.bundleName_ = "GetCombinedExtWindowFlags";
618 
619     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
620     EXPECT_NE(sceneSession, nullptr);
621 
622     auto combinedExtWindowFlags = sceneSession->GetCombinedExtWindowFlags();
623     EXPECT_EQ(combinedExtWindowFlags.bitData, 0);
624     sceneSession->UpdateExtWindowFlags(1234, ExtensionWindowFlags(3), ExtensionWindowFlags(3));
625     sceneSession->UpdateExtWindowFlags(5678, ExtensionWindowFlags(4), ExtensionWindowFlags(4));
626 
627     sceneSession->state_ = SessionState::STATE_FOREGROUND;
628     combinedExtWindowFlags = sceneSession->GetCombinedExtWindowFlags();
629     EXPECT_EQ(combinedExtWindowFlags.bitData, 7);
630 
631     sceneSession->state_ = SessionState::STATE_BACKGROUND;
632     combinedExtWindowFlags = sceneSession->GetCombinedExtWindowFlags();
633     EXPECT_EQ(combinedExtWindowFlags.bitData, 6);
634 }
635 
636 /**
637  * @tc.name: RemoveExtWindowFlags
638  * @tc.desc: remove uiextension window flags
639  * @tc.type: FUNC
640  */
641 HWTEST_F(SceneSessionTest2, RemoveExtWindowFlags, Function | SmallTest | Level2)
642 {
643     SessionInfo info;
644     info.abilityName_ = "RemoveExtWindowFlags";
645     info.bundleName_ = "RemoveExtWindowFlags";
646 
647     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
648     EXPECT_NE(sceneSession, nullptr);
649 
650     EXPECT_TRUE(sceneSession->extWindowFlagsMap_.empty());
651     sceneSession->UpdateExtWindowFlags(1234, ExtensionWindowFlags(3), ExtensionWindowFlags(3));
652     EXPECT_EQ(sceneSession->extWindowFlagsMap_.size(), 1);
653     sceneSession->RemoveExtWindowFlags(1234);
654     EXPECT_TRUE(sceneSession->extWindowFlagsMap_.empty());
655 }
656 
657 /**
658  * @tc.name: ClearExtWindowFlags
659  * @tc.desc: clear uiextension window flags
660  * @tc.type: FUNC
661  */
662 HWTEST_F(SceneSessionTest2, ClearExtWindowFlags, Function | SmallTest | Level2)
663 {
664     SessionInfo info;
665     info.abilityName_ = "ClearExtWindowFlags";
666     info.bundleName_ = "ClearExtWindowFlags";
667 
668     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
669     EXPECT_NE(sceneSession, nullptr);
670 
671     EXPECT_TRUE(sceneSession->extWindowFlagsMap_.empty());
672     sceneSession->UpdateExtWindowFlags(1234, ExtensionWindowFlags(3), ExtensionWindowFlags(3));
673     sceneSession->UpdateExtWindowFlags(5678, ExtensionWindowFlags(4), ExtensionWindowFlags(4));
674     EXPECT_EQ(sceneSession->extWindowFlagsMap_.size(), 2);
675     sceneSession->ClearExtWindowFlags();
676     EXPECT_TRUE(sceneSession->extWindowFlagsMap_.empty());
677 }
678 
679 /**
680  * @tc.name: CalculateCombinedExtWindowFlags
681  * @tc.desc: calculate combined uiextension window flags
682  * @tc.type: FUNC
683  */
684 HWTEST_F(SceneSessionTest2, CalculateCombinedExtWindowFlags, Function | SmallTest | Level2)
685 {
686     SessionInfo info;
687     info.abilityName_ = "CalculateCombinedExtWindowFlags";
688     info.bundleName_ = "CalculateCombinedExtWindowFlags";
689 
690     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
691     EXPECT_NE(sceneSession, nullptr);
692 
693     EXPECT_EQ(sceneSession->combinedExtWindowFlags_.bitData, 0);
694     sceneSession->UpdateExtWindowFlags(1234, ExtensionWindowFlags(3), ExtensionWindowFlags(3));
695     sceneSession->UpdateExtWindowFlags(5678, ExtensionWindowFlags(4), ExtensionWindowFlags(4));
696     sceneSession->CalculateCombinedExtWindowFlags();
697     EXPECT_EQ(sceneSession->combinedExtWindowFlags_.bitData, 7);
698 }
699 
700 /**
701  * @tc.name: SaveUpdatedIcon
702  * @tc.desc: SaveUpdatedIcon
703  * @tc.type: FUNC
704  */
705 HWTEST_F(SceneSessionTest2, SaveUpdatedIcon, Function | SmallTest | Level2)
706 {
707     SessionInfo info;
708     info.abilityName_ = "SaveUpdatedIcon";
709     info.bundleName_ = "SaveUpdatedIcon";
710     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
711 
712     sceneSession->scenePersistence_ = sptr<ScenePersistence>::MakeSptr("OpenHarmony", 1);
713     EXPECT_NE(nullptr, sceneSession->scenePersistence_);
714     sceneSession->SaveUpdatedIcon(nullptr);
715 }
716 
717 /**
718  * @tc.name: NotifyTouchOutside
719  * @tc.desc: NotifyTouchOutside
720  * @tc.type: FUNC
721  */
722 HWTEST_F(SceneSessionTest2, NotifyTouchOutside, Function | SmallTest | Level2)
723 {
724     SessionInfo info;
725     info.abilityName_ = "NotifyTouchOutside";
726     info.bundleName_ = "NotifyTouchOutside";
727     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
728 
729     sceneSession->sessionStage_ = sptr<SessionStageMocker>::MakeSptr();
730     EXPECT_NE(nullptr, sceneSession->sessionStage_);
731     sceneSession->NotifyTouchOutside();
732 
__anon68f904dc0202() 733     auto func = [sceneSession]() {
734         sceneSession->SaveUpdatedIcon(nullptr);
735     };
736     sceneSession->onTouchOutside_ = func;
737     EXPECT_NE(nullptr, &func);
738     sceneSession->sessionStage_ = nullptr;
739     sceneSession->NotifyTouchOutside();
740 
741     sceneSession->onTouchOutside_ = nullptr;
742     sceneSession->sessionStage_ = nullptr;
743     sceneSession->NotifyTouchOutside();
744 }
745 
746 /**
747  * @tc.name: CheckTouchOutsideCallbackRegistered
748  * @tc.desc: CheckTouchOutsideCallbackRegistered
749  * @tc.type: FUNC
750  */
751 HWTEST_F(SceneSessionTest2, CheckTouchOutsideCallbackRegistered, Function | SmallTest | Level2)
752 {
753     SessionInfo info;
754     info.abilityName_ = "CheckTouchOutsideCallbackRegistered";
755     info.bundleName_ = "CheckTouchOutsideCallbackRegistered";
756     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
757 
__anon68f904dc0302() 758     auto func = [sceneSession]() {
759         sceneSession->NotifyWindowVisibility();
760     };
761     sceneSession->onTouchOutside_ = func;
762     bool result = sceneSession->CheckTouchOutsideCallbackRegistered();
763     EXPECT_EQ(true, result);
764 
765     sceneSession->onTouchOutside_ = nullptr;
766     result = sceneSession->CheckTouchOutsideCallbackRegistered();
767     EXPECT_EQ(false, result);
768 }
769 
770 /**
771  * @tc.name: RegisterTouchOutsideCallback
772  * @tc.desc: test RegisterTouchOutsideCallback
773  * @tc.type: FUNC
774  */
775 HWTEST_F(SceneSessionTest2, RegisterTouchOutsideCallback, Function | SmallTest | Level2)
776 {
777     SessionInfo info;
778     info.abilityName_ = "RegisterTouchOutsideCallback";
779     info.bundleName_ = "RegisterTouchOutsideCallback";
780     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
781     sceneSession->onTouchOutside_ = nullptr;
__anon68f904dc0402() 782     NotifyTouchOutsideFunc func = []() {};
783     sceneSession->RegisterTouchOutsideCallback(std::move(func));
784 
785     ASSERT_NE(sceneSession->onTouchOutside_, nullptr);
786 }
787 
788 /**
789  * @tc.name: UpdateRotationAvoidArea
790  * @tc.desc: UpdateRotationAvoidArea
791  * @tc.type: FUNC
792  */
793 HWTEST_F(SceneSessionTest2, UpdateRotationAvoidArea, Function | SmallTest | Level2)
794 {
795     SessionInfo info;
796     info.abilityName_ = "UpdateRotationAvoidArea";
797     info.bundleName_ = "UpdateRotationAvoidArea";
798     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
799     sceneSession->specificCallback_ = sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
800     EXPECT_NE(nullptr, sceneSession->specificCallback_);
__anon68f904dc0502(const int32_t& persistentId) 801     auto func = [sceneSession](const int32_t& persistentId) {
802         sceneSession->SetParentPersistentId(persistentId);
803         sceneSession->GetParentPersistentId();
804     };
805     sceneSession->specificCallback_->onUpdateAvoidArea_ = func;
806     sptr<Session> session;
807     session = sptr<Session>::MakeSptr(info);
808     int result = session->GetPersistentId();
809     EXPECT_EQ(0, result);
810     sceneSession->UpdateRotationAvoidArea();
811 
812     sceneSession->specificCallback_ = nullptr;
813     sceneSession->UpdateRotationAvoidArea();
814 }
815 
816 /**
817  * @tc.name: NotifyForceHideChange
818  * @tc.desc: NotifyForceHideChange
819  * @tc.type: FUNC
820  */
821 HWTEST_F(SceneSessionTest2, NotifyForceHideChange, Function | SmallTest | Level2)
822 {
823     SessionInfo info;
824     info.abilityName_ = "NotifyForceHideChange";
825     info.bundleName_ = "NotifyForceHideChange";
826     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
827     sceneSession->NotifyForceHideChange(true);
828 
829     sptr<Session> session = sptr<Session>::MakeSptr(info);
__anon68f904dc0602(bool hide) 830     auto func = [sceneSession](bool hide) {
831         sceneSession->SetPrivacyMode(hide);
832     };
833     sceneSession->onForceHideChangeFunc_ = func;
834     EXPECT_NE(nullptr, &func);
835     sceneSession->NotifyForceHideChange(true);
836 }
837 
838 /**
839  * @tc.name: SendPointerEventToUI
840  * @tc.desc: SendPointerEventToUI
841  * @tc.type: FUNC
842  */
843 HWTEST_F(SceneSessionTest2, SendPointerEventToUI, Function | SmallTest | Level2)
844 {
845     SessionInfo info;
846     info.abilityName_ = "SendPointerEventToUI";
847     info.bundleName_ = "SendPointerEventToUI";
848     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
849     EXPECT_NE(nullptr, sceneSession);
__anon68f904dc0702(std::shared_ptr<MMI::PointerEvent> pointerEvent) 850     auto pointerEventFunc = [sceneSession](std::shared_ptr<MMI::PointerEvent> pointerEvent) {
851         sceneSession->NotifyOutsideDownEvent(pointerEvent);
852     };
853     sceneSession->systemSessionPointerEventFunc_ = pointerEventFunc;
854     std::shared_ptr<MMI::PointerEvent> pointerEvent =
855          MMI::PointerEvent::Create();
856     sceneSession->SendPointerEventToUI(pointerEvent);
857     EXPECT_NE(nullptr, pointerEvent);
858 }
859 
860 /**
861  * @tc.name: SetFloatingScale
862  * @tc.desc: SetFloatingScale
863  * @tc.type: FUNC
864  */
865 HWTEST_F(SceneSessionTest2, SetFloatingScale, Function | SmallTest | Level2)
866 {
867     SessionInfo info;
868     info.abilityName_ = "SetFloatingScale";
869     info.bundleName_ = "SetFloatingScale";
870     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
871     sceneSession->specificCallback_ = sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
__anon68f904dc0802(int32_t persistentId, WindowUpdateType type) 872     auto windowInfoUpdateFun = [sceneSession](int32_t persistentId, WindowUpdateType type) {
873         if (WindowUpdateType::WINDOW_UPDATE_PROPERTY == type) {
874             sceneSession->SetCollaboratorType(persistentId);
875             return;
876         } else {
877             persistentId++;
878             sceneSession->SetParentPersistentId(persistentId);
879             return;
880         }
881     };
__anon68f904dc0902(const int32_t& persistentId) 882     auto updateAvoidAreaFun = [sceneSession](const int32_t& persistentId) {
883         bool result = sceneSession->RemoveSubSession(persistentId);
884         sceneSession->SetWindowAnimationFlag(result);
885     };
886     sceneSession->specificCallback_->onWindowInfoUpdate_ = windowInfoUpdateFun;
887     sceneSession->specificCallback_->onUpdateAvoidArea_ = updateAvoidAreaFun;
888     sceneSession->SetFloatingScale(3.14f);
889     EXPECT_EQ(3.14f, sceneSession->floatingScale_);
890 
891     sceneSession->floatingScale_ = 3.0f;
892     sceneSession->SetFloatingScale(3.0f);
893     EXPECT_EQ(3.0f, sceneSession->floatingScale_);
894 }
895 
896 /**
897  * @tc.name: ProcessPointDownSession
898  * @tc.desc: ProcessPointDownSession
899  * @tc.type: FUNC
900  */
901 HWTEST_F(SceneSessionTest2, ProcessPointDownSession, Function | SmallTest | Level2)
902 {
903     SessionInfo info;
904     info.abilityName_ = "ProcessPointDownSession";
905     info.bundleName_ = "ProcessPointDownSession";
906     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
907     sceneSession->specificCallback_ = sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
908     EXPECT_NE(nullptr, sceneSession->specificCallback_);
__anon68f904dc0a02(int32_t persistentId) 909     auto sessionTouchOutsideFun = [sceneSession](int32_t persistentId) {
910         sceneSession->SetCollaboratorType(persistentId);
911     };
__anon68f904dc0b02(int32_t x, int32_t y) 912     auto outsideDownEventFun = [sceneSession](int32_t x, int32_t y) {
913         int z = x + y;
914         sceneSession->SetCollaboratorType(z);
915     };
916     sceneSession->specificCallback_->onSessionTouchOutside_ = sessionTouchOutsideFun;
917     sceneSession->specificCallback_->onOutsideDownEvent_ = outsideDownEventFun;
918     EXPECT_EQ(WSError::WS_OK, sceneSession->ProcessPointDownSession(3, 4));
919 
920     sceneSession->specificCallback_->onSessionTouchOutside_ = nullptr;
921     EXPECT_EQ(WSError::WS_OK, sceneSession->ProcessPointDownSession(3, 4));
922 
923     sceneSession->sessionInfo_.bundleName_ = "SCBGestureBack";
924     sceneSession->specificCallback_->onOutsideDownEvent_ = nullptr;
925     EXPECT_EQ(WSError::WS_OK, sceneSession->ProcessPointDownSession(3, 4));
926 }
927 
928 /**
929  * @tc.name: SetSelfToken
930  * @tc.desc: SetSelfToken
931  * @tc.type: FUNC
932  */
933 HWTEST_F(SceneSessionTest2, SetSelfToken, Function | SmallTest | Level2)
934 {
935     SessionInfo info;
936     info.abilityName_ = "SetSelfToken";
937     info.bundleName_ = "SetSelfToken";
938     sptr<SceneSession> sceneSession;
939     sptr<SceneSession::SpecificSessionCallback> specificSession =
940         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
941     sceneSession = sptr<SceneSession>::MakeSptr(info, specificSession);
942     EXPECT_NE(nullptr, sceneSession);
943     sceneSession->SetSessionState(SessionState::STATE_DISCONNECT);
944     sceneSession->UpdateSessionState(SessionState::STATE_CONNECT);
945     sceneSession->UpdateSessionState(SessionState::STATE_ACTIVE);
946     sceneSession->isVisible_ = true;
947     EXPECT_EQ(true, sceneSession->IsVisibleForAccessibility());
948     sceneSession->SetSystemTouchable(false);
949     EXPECT_EQ(false, sceneSession->IsVisibleForAccessibility());
950     sceneSession->SetForegroundInteractiveStatus(true);
951     sceneSession->NotifyAccessibilityVisibilityChange();
__anon68f904dc0c02(int32_t persistentId, WindowUpdateType type) 952     auto windowInfoUpdateFun = [sceneSession](int32_t persistentId, WindowUpdateType type) {
953         if (WindowUpdateType::WINDOW_UPDATE_PROPERTY == type) {
954             sceneSession->SetCollaboratorType(persistentId);
955             return;
956         } else {
957             persistentId++;
958             sceneSession->SetParentPersistentId(persistentId);
959             return;
960         }
961     };
962     sceneSession->specificCallback_->onWindowInfoUpdate_ = windowInfoUpdateFun;
963     sceneSession->NotifyAccessibilityVisibilityChange();
964     EXPECT_NE(nullptr, sceneSession->specificCallback_);
965 }
966 
967 /**
968  * @tc.name: SetLastSafeRect
969  * @tc.desc: SetLastSafeRect
970  * @tc.type: FUNC
971  */
972 HWTEST_F(SceneSessionTest2, SetLastSafeRect, Function | SmallTest | Level2)
973 {
974     SessionInfo info;
975     info.abilityName_ = "SetLastSafeRect";
976     info.bundleName_ = "SetLastSafeRect";
977     sptr<SceneSession> sceneSession;
978     sptr<SceneSession::SpecificSessionCallback> specificSession =
979         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
980     sceneSession = sptr<SceneSession>::MakeSptr(info, specificSession);
981     WSRect rect = {3, 4, 5, 6};
982     sceneSession->SetLastSafeRect(rect);
983     WSRect result = sceneSession->GetLastSafeRect();
984     EXPECT_EQ(3, result.posX_);
985     EXPECT_EQ(4, result.posY_);
986     EXPECT_EQ(5, result.width_);
987     EXPECT_EQ(6, result.height_);
988 }
989 
990 /**
991  * @tc.name: GetSessionTargetRectByDisplayId
992  * @tc.desc: GetSessionTargetRectByDisplayId
993  * @tc.type: FUNC
994  */
995 HWTEST_F(SceneSessionTest2, GetSessionTargetRectByDisplayId, Function | SmallTest | Level2)
996 {
997     SessionInfo info;
998     info.abilityName_ = "GetSubSession";
999     info.bundleName_ = "GetSessionTargetRectByDisplayId";
1000     sptr<SceneSession> sceneSession;
1001     sptr<SceneSession::SpecificSessionCallback> specificSession =
1002         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1003     sceneSession = sptr<SceneSession>::MakeSptr(info, specificSession);
1004     bool res = sceneSession->AddSubSession(sceneSession);
1005     EXPECT_EQ(true, res);
1006     EXPECT_EQ(sceneSession, (sceneSession->GetSubSession())[0]);
1007     sceneSession->moveDragController_ = sptr<MoveDragController>::MakeSptr(1024, WindowType::WINDOW_TYPE_FLOAT);
1008     WSRect rectResult = sceneSession->GetSessionTargetRectByDisplayId(0);
1009     EXPECT_EQ(0, rectResult.posX_);
1010     EXPECT_EQ(0, rectResult.width_);
__anon68f904dc0d02(DisplayId displayId, int32_t type, SizeChangeReason reason) 1011     auto dragHotAreaFunc = [sceneSession](DisplayId displayId, int32_t type, SizeChangeReason reason) {
1012         if (SizeChangeReason::END == reason) {
1013             GTEST_LOG_(INFO) << "type = " << type;
1014         }
1015         return;
1016     };
1017     sceneSession->SetWindowDragHotAreaListener(dragHotAreaFunc);
1018     EXPECT_NE(nullptr,  sceneSession->moveDragController_);
1019     sceneSession->moveDragController_ = nullptr;
1020     rectResult = sceneSession->GetSessionTargetRectByDisplayId(0);
1021     sceneSession->SetWindowDragHotAreaListener(dragHotAreaFunc);
1022     ASSERT_EQ(0, rectResult.width_);
1023 }
1024 
1025 /**
1026  * @tc.name: SetPipActionEvent
1027  * @tc.desc: SetPipActionEvent
1028  * @tc.type: FUNC
1029  */
1030 HWTEST_F(SceneSessionTest2, SetPipActionEvent, Function | SmallTest | Level2)
1031 {
1032     SessionInfo info;
1033     info.abilityName_ = "SetPipActionEvent";
1034     info.bundleName_ = "SetPipActionEvent";
1035     auto sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1036     EXPECT_NE(sceneSession, nullptr);
1037 
1038     WSError res = sceneSession->SetPipActionEvent("close", 0);
1039     ASSERT_EQ(res, WSError::WS_ERROR_NULLPTR);
1040     auto mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
1041     sceneSession->sessionStage_ = mockSessionStage;
1042     res = sceneSession->SetPipActionEvent("close", 0);
1043     ASSERT_EQ(res, WSError::WS_OK);
1044 }
1045 
1046 /**
1047  * @tc.name: SetPiPControlEvent
1048  * @tc.desc: SetPiPControlEvent
1049  * @tc.type: FUNC
1050  */
1051 HWTEST_F(SceneSessionTest2, SetPiPControlEvent, Function | SmallTest | Level2)
1052 {
1053     SessionInfo info;
1054     info.abilityName_ = "SetPiPControlEvent";
1055     info.bundleName_ = "SetPiPControlEvent";
1056     auto sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1057     EXPECT_NE(sceneSession, nullptr);
1058 
1059     auto property = sptr<WindowSessionProperty>::MakeSptr();
1060     EXPECT_NE(property, nullptr);
1061     property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1062     sceneSession->SetSessionProperty(property);
1063     auto controlType = WsPiPControlType::VIDEO_PLAY_PAUSE;
1064     auto status = WsPiPControlStatus::PLAY;
1065     WSError res = sceneSession->SetPiPControlEvent(controlType, status);
1066     ASSERT_EQ(res, WSError::WS_ERROR_INVALID_TYPE);
1067 
1068     auto sessionStage = sptr<SessionStageMocker>::MakeSptr();
1069     ASSERT_NE(sessionStage, nullptr);
1070 
1071     property->SetWindowType(WindowType::WINDOW_TYPE_PIP);
1072     property->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
1073     sceneSession->SetSessionProperty(property);
1074     res = sceneSession->SetPiPControlEvent(controlType, status);
1075     ASSERT_EQ(res, WSError::WS_ERROR_NULLPTR);
1076 }
1077 
1078 /**
1079  * @tc.name: SetForceHideState
1080  * @tc.desc: SetForceHideState
1081  * @tc.type: FUNC
1082  */
1083 HWTEST_F(SceneSessionTest2, SetForceHideState, Function | SmallTest | Level2)
1084 {
1085     SessionInfo info;
1086     info.abilityName_ = "SetForceHideState";
1087     info.bundleName_ = "SetForceHideState";
1088     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1089     EXPECT_NE(sceneSession, nullptr);
1090 
1091     sceneSession->SetForceHideState(ForceHideState::NOT_HIDDEN);
1092     bool hide = sceneSession->GetForceHideState();
1093     ASSERT_EQ(hide, ForceHideState::NOT_HIDDEN);
1094     sceneSession->SetForceHideState(ForceHideState::HIDDEN_WHEN_FOCUSED);
1095     hide = sceneSession->GetForceHideState();
1096     ASSERT_EQ(hide, ForceHideState::HIDDEN_WHEN_FOCUSED);
1097 }
1098 
1099 /**
1100  * @tc.name: OnSessionEvent01
1101  * @tc.desc: OnSessionEvent
1102  * @tc.type: FUNC
1103  */
1104 HWTEST_F(SceneSessionTest2, OnSessionEvent01, Function | SmallTest | Level2)
1105 {
1106     SessionInfo info;
1107     info.abilityName_ = "OnSessionEvent01";
1108     info.bundleName_ = "OnSessionEvent01";
1109 
1110     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1111     EXPECT_NE(sceneSession, nullptr);
1112 
1113     sceneSession->leashWinSurfaceNode_ = nullptr;
1114     SessionEvent event = SessionEvent::EVENT_START_MOVE;
1115     sceneSession->moveDragController_ = sptr<MoveDragController>::MakeSptr(1, WindowType::WINDOW_TYPE_FLOAT);
1116     sceneSession->OnSessionEvent(event);
1117 
1118     sceneSession->moveDragController_->isStartDrag_ = true;
1119     auto result = sceneSession->OnSessionEvent(event);
1120     ASSERT_EQ(result, WSError::WS_OK);
1121     event = SessionEvent::EVENT_DRAG_START;
1122     ASSERT_EQ(sceneSession->OnSessionEvent(event), WSError::WS_OK);
1123 }
1124 
1125 /**
1126  * @tc.name: SetSessionRectChangeCallback
1127  * @tc.desc: SetSessionRectChangeCallback
1128  * @tc.type: FUNC
1129  */
1130 HWTEST_F(SceneSessionTest2, SetSessionRectChangeCallback, Function | SmallTest | Level2)
1131 {
1132     SessionInfo info;
1133     info.abilityName_ = "SetSessionRectChangeCallback";
1134     info.bundleName_ = "SetSessionRectChangeCallback";
1135 
1136     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1137     EXPECT_NE(sceneSession, nullptr);
1138 
1139     NotifySessionRectChangeFunc func;
1140     sceneSession->SetSessionRectChangeCallback(func);
1141 
1142     sceneSession->RaiseToAppTop();
1143     sceneSession = nullptr;
1144     GTEST_LOG_(INFO) << "2";
1145     sceneSession->BindDialogSessionTarget(sceneSession);
1146 
1147     Session ssession(info);
1148     ssession.property_ = nullptr;
1149 }
1150 
1151 /**
1152  * @tc.name: SetSessionPiPControlStatusChangeCallback
1153  * @tc.desc: SetSessionPiPControlStatusChangeCallback
1154  * @tc.type: FUNC
1155  */
1156 HWTEST_F(SceneSessionTest2, SetSessionPiPControlStatusChangeCallback, Function | SmallTest | Level2)
1157 {
1158     SessionInfo info;
1159     info.abilityName_ = "SetSessionPiPControlStatusChangeCallback";
1160     info.bundleName_ = "SetSessionPiPControlStatusChangeCallback";
1161     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1162     EXPECT_NE(sceneSession, nullptr);
1163     NotifySessionPiPControlStatusChangeFunc func;
1164     sceneSession->SetSessionPiPControlStatusChangeCallback(func);
1165 }
1166 
1167 /**
1168  * @tc.name: SetAutoStartPiPStatusChangeCallback
1169  * @tc.desc: SetAutoStartPiPStatusChangeCallback
1170  * @tc.type: FUNC
1171  */
1172 HWTEST_F(SceneSessionTest2, SetAutoStartPiPStatusChangeCallback, Function | SmallTest | Level2)
1173 {
1174     SessionInfo info;
1175     info.abilityName_ = "SetAutoStartPiPStatusChangeCallback";
1176     info.bundleName_ = "SetAutoStartPiPStatusChangeCallback";
1177     auto sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1178     EXPECT_NE(sceneSession, nullptr);
1179     NotifyAutoStartPiPStatusChangeFunc func;
1180     sceneSession->SetAutoStartPiPStatusChangeCallback(func);
1181 }
1182 
1183 /**
1184  * @tc.name: RaiseAppMainWindowToTop
1185  * @tc.desc: RaiseAppMainWindowToTop
1186  * @tc.type: FUNC
1187  */
1188 HWTEST_F(SceneSessionTest2, RaiseAppMainWindowToTop, Function | SmallTest | Level2)
1189 {
1190     SessionInfo info;
1191     info.abilityName_ = "RaiseAppMainWindowToTop";
1192     info.bundleName_ = "RaiseAppMainWindowToTop";
1193 
1194     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1195     EXPECT_NE(sceneSession, nullptr);
1196 
1197     WSError result = sceneSession->RaiseAppMainWindowToTop();
1198     EXPECT_EQ(WSError::WS_OK, result);
1199     bool status = true;
1200     sceneSession->OnNeedAvoid(status);
1201 
1202     bool showWhenLocked = true;
1203     sceneSession->OnShowWhenLocked(showWhenLocked);
1204     sceneSession->NotifyPropertyWhenConnect();
1205 
1206     sceneSession->focusedOnShow_ = false;
1207     result = sceneSession->RaiseAppMainWindowToTop();
1208     EXPECT_EQ(WSError::WS_OK, result);
1209 }
1210 
1211 /**
1212  * @tc.name: GetCutoutAvoidArea
1213  * @tc.desc: GetCutoutAvoidArea
1214  * @tc.type: FUNC
1215  */
1216 HWTEST_F(SceneSessionTest2, GetCutoutAvoidArea01, Function | SmallTest | Level2)
1217 {
1218     SessionInfo info;
1219     info.abilityName_ = "GetCutoutAvoidArea";
1220     info.bundleName_ = "GetCutoutAvoidArea";
1221 
1222     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1223     EXPECT_NE(sceneSession, nullptr);
1224 
1225     WSRect rect;
1226     AvoidArea avoidArea;
1227     DisplayManager displayManager;
1228     Session ssession(info);
1229     auto display = DisplayManager::GetInstance().GetDisplayById(
1230         ssession.GetSessionProperty()->GetDisplayId());
1231     sceneSession->GetCutoutAvoidArea(rect, avoidArea);
1232 }
1233 
1234 /**
1235  * @tc.name: GetAINavigationBarArea
1236  * @tc.desc: GetAINavigationBarArea
1237  * @tc.type: FUNC
1238  */
1239 HWTEST_F(SceneSessionTest2, GetAINavigationBarArea, Function | SmallTest | Level2)
1240 {
1241     SessionInfo info;
1242     info.abilityName_ = "GetAINavigationBarArea";
1243     info.bundleName_ = "GetAINavigationBarArea";
1244 
1245     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1246     EXPECT_NE(sceneSession, nullptr);
1247 
1248     WSRect rect;
1249     AvoidArea avoidArea;
1250     sceneSession->GetAINavigationBarArea(rect, avoidArea);
1251 
1252     sceneSession->SetIsDisplayStatusBarTemporarily(true);
1253     sceneSession->GetAINavigationBarArea(rect, avoidArea);
1254     ASSERT_EQ(sceneSession->GetIsDisplayStatusBarTemporarily(), true);
1255 
1256     auto property = sptr<WindowSessionProperty>::MakeSptr();
1257     EXPECT_NE(property, nullptr);
1258     property->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
1259     sceneSession->property_ = property;
1260     sceneSession->GetAINavigationBarArea(rect, avoidArea);
1261 
1262     property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1263     sceneSession->SetSessionProperty(property);
1264     sceneSession->specificCallback_ = sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1265     ASSERT_NE(nullptr, sceneSession->specificCallback_);
__anon68f904dc0e02(uint64_t displayId) 1266     sceneSession->specificCallback_->onGetAINavigationBarArea_ = [](uint64_t displayId) {
1267         WSRect rect = {1, 1, 1, 1};
1268         return rect;
1269     };
1270     sceneSession->GetAINavigationBarArea(rect, avoidArea);
1271 }
1272 
1273 /**
1274  * @tc.name: TransferPointerEvent
1275  * @tc.desc: TransferPointerEvent
1276  * @tc.type: FUNC
1277  */
1278 HWTEST_F(SceneSessionTest2, TransferPointerEvent03, Function | SmallTest | Level2)
1279 {
1280     SessionInfo info;
1281     info.abilityName_ = "TransferPointerEvent";
1282     info.bundleName_ = "TransferPointerEvent";
1283 
1284     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1285     EXPECT_NE(sceneSession, nullptr);
1286 
1287     std::shared_ptr<MMI::PointerEvent> pointerEvent = nullptr;
1288     sceneSession->specificCallback_ = sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1289 
1290     sceneSession->TransferPointerEvent(pointerEvent);
1291 
1292     WindowLimits limits;
1293     WSRect rect;
1294     float ratio = 0.0;
1295     bool isDecor = true;
1296     float vpr = 0.0;
1297     sceneSession->AdjustRectByLimits(limits, ratio, isDecor, vpr, rect);
1298     sceneSession->SetPipActionEvent("pointerEvent", 0);
1299 
1300     auto property = sptr<WindowSessionProperty>::MakeSptr();
1301     EXPECT_NE(property, nullptr);
1302     property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
1303     sceneSession->SetSessionProperty(property);
1304     ASSERT_EQ(WSError::WS_ERROR_NULLPTR, sceneSession->SetPipActionEvent("pointerEvent", 0));
1305 
1306     sceneSession->sessionStage_ = sptr<SessionStageMocker>::MakeSptr();
1307     property->SetWindowType(WindowType::WINDOW_TYPE_PIP);
1308     property->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
1309     sceneSession->SetSessionProperty(property);
1310     sceneSession->AdjustRectByLimits(limits, ratio, false, vpr, rect);
1311     ASSERT_EQ(WSError::WS_OK, sceneSession->SetPipActionEvent("pointerEvent", 0));
1312 }
1313 
1314 /**
1315  * @tc.name: OnMoveDragCallback
1316  * @tc.desc: OnMoveDragCallback
1317  * @tc.type: FUNC
1318  */
1319 HWTEST_F(SceneSessionTest2, OnMoveDragCallback, Function | SmallTest | Level2)
1320 {
1321     SessionInfo info;
1322     info.abilityName_ = "OnMoveDragCallback";
1323     info.bundleName_ = "OnMoveDragCallback";
1324 
1325     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1326     EXPECT_NE(sceneSession, nullptr);
1327 
1328     Session session(info);
1329     WSRect rect;
1330     sceneSession->UpdateWinRectForSystemBar(rect);
1331     sceneSession->SetSurfaceBounds(rect, false);
1332     sceneSession->GetWindowNameAllType();
1333     session.scenePersistence_ = sptr<ScenePersistence>::MakeSptr("aa", 0);
1334     sceneSession->GetUpdatedIconPath();
1335 
1336     bool visible = true;
1337     sceneSession->UpdateNativeVisibility(visible);
1338 
1339     sceneSession->scenePersistence_ = sptr<ScenePersistence>::MakeSptr(info.bundleName_, 0);
1340     EXPECT_NE(sceneSession->scenePersistence_, nullptr);
1341     sceneSession->GetUpdatedIconPath();
1342 }
1343 
1344 /**
1345  * @tc.name: OnMoveDragCallback
1346  * @tc.desc: OnMoveDragCallback
1347  * @tc.type: FUNC
1348  */
1349 HWTEST_F(SceneSessionTest2, OnMoveDragCallback01, Function | SmallTest | Level2)
1350 {
1351     SessionInfo info;
1352     info.abilityName_ = "OnMoveDragCallback01";
1353     info.bundleName_ = "OnMoveDragCallback01";
1354 
1355     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1356     EXPECT_NE(sceneSession, nullptr);
1357 
1358     double alpha = 0.5;
1359     Session session(info);
1360 
1361     sceneSession->SetSystemSceneOcclusionAlpha(alpha);
1362     sceneSession->IsNeedDefaultAnimation();
1363     bool isPlaying = true;
1364     sceneSession->NotifyIsCustomAnimationPlaying(isPlaying);
1365 
1366     sptr<AAFwk::SessionInfo> abilitySessionInfo = nullptr;
1367     bool visible = true;
1368     sceneSession->ChangeSessionVisibilityWithStatusBar(abilitySessionInfo, visible);
1369 }
1370 
1371 /**
1372  * @tc.name: OnMoveDragCallback
1373  * @tc.desc: OnMoveDragCallback
1374  * @tc.type: FUNC
1375  */
1376 HWTEST_F(SceneSessionTest2, OnMoveDragCallback02, Function | SmallTest | Level2)
1377 {
1378     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
1379         GTEST_SKIP() << "SceneBoard is not enabled, skipping test.";
1380     }
1381     SessionInfo info;
1382     info.abilityName_ = "OnMoveDragCallback02";
1383     info.bundleName_ = "OnMoveDragCallback02";
1384 
1385     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1386     EXPECT_NE(sceneSession, nullptr);
1387     sptr<SceneSession> ssession = nullptr;
1388     sceneSession->HandleCastScreenConnection(info, ssession);
1389 
1390     Session session(info);
1391     sptr<AAFwk::SessionInfo> abilitySessionInfo = nullptr;
1392     ExceptionInfo exceptionInfo;
1393     NotifySessionExceptionFunc func = [](const SessionInfo& info,
__anon68f904dc0f02(const SessionInfo& info, const ExceptionInfo& exceInfo, bool startFail) 1394         const ExceptionInfo& exceInfo, bool startFail) {};
1395     session.sessionExceptionFunc_ = func;
1396     NotifySessionExceptionFunc func1 = [](const SessionInfo& info,
__anon68f904dc1002(const SessionInfo& info, const ExceptionInfo& exceInfo, bool startFail) 1397         const ExceptionInfo& exceInfo, bool startFail) {};
1398     session.jsSceneSessionExceptionFunc_ = func1;
1399     sceneSession->NotifySessionException(abilitySessionInfo, exceptionInfo);
1400 
1401     sceneSession->NotifyPiPWindowPrepareClose();
1402 
1403     bool isLandscapeMultiWindow = true;
1404     sceneSession->SetLandscapeMultiWindow(isLandscapeMultiWindow);
1405 
1406     std::shared_ptr<MMI::KeyEvent> keyEvent = std::make_shared<MMI::KeyEvent>(MMI::KeyEvent::KEYCODE_BACK);
1407     bool isPreImeEvent = true;
1408     sceneSession->SendKeyEventToUI(keyEvent, isPreImeEvent);
1409     sceneSession->IsDirtyWindow();
1410     sceneSession->moveDragController_ = sptr<MoveDragController>::MakeSptr(0, WindowType::WINDOW_TYPE_FLOAT);
1411     sceneSession->NotifyUILostFocus();
1412 }
1413 
1414 /**
1415  * @tc.name: IsStartMoving
1416  * @tc.desc: IsStartMoving
1417  * @tc.type: FUNC
1418  */
1419 HWTEST_F(SceneSessionTest2, IsStartMoving, Function | SmallTest | Level2)
1420 {
1421     SessionInfo info;
1422     info.abilityName_ = "IsStartMoving";
1423     info.bundleName_ = "IsStartMoving";
1424 
1425     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1426     EXPECT_NE(sceneSession, nullptr);
1427 
1428     sceneSession->IsStartMoving();
1429     bool startMoving = true;
1430     sceneSession->SetIsStartMoving(startMoving);
1431     DisplayId from = 0;
1432     DisplayId to = 0;
1433     sceneSession->NotifyDisplayMove(from, to);
1434     sceneSession->ClearExtWindowFlags();
1435     bool isRegister = true;
1436     sceneSession->UpdateRectChangeListenerRegistered(isRegister);
1437 
1438     sceneSession->sessionStage_ = sptr<SessionStageMocker>::MakeSptr();
1439     EXPECT_NE(nullptr, sceneSession->sessionStage_);
1440     sceneSession->NotifyDisplayMove(from, to);
1441 }
1442 
1443 /**
1444  * @tc.name: SetTemporarilyShowWhenLocked
1445  * @tc.desc: SetTemporarilyShowWhenLocked
1446  * @tc.type: FUNC
1447  */
1448 HWTEST_F(SceneSessionTest2, SetTemporarilyShowWhenLocked, Function | SmallTest | Level2)
1449 {
1450     SessionInfo info;
1451     info.abilityName_ = "SetTemporarilyShowWhenLocked";
1452     info.bundleName_ = "SetTemporarilyShowWhenLocked";
1453     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1454     EXPECT_NE(sceneSession, nullptr);
1455     bool isTemporarilyShowWhenLocked = sceneSession->IsTemporarilyShowWhenLocked();
1456     ASSERT_EQ(isTemporarilyShowWhenLocked, false);
1457     sceneSession->SetTemporarilyShowWhenLocked(true);
1458     isTemporarilyShowWhenLocked = sceneSession->IsTemporarilyShowWhenLocked();
1459     ASSERT_EQ(isTemporarilyShowWhenLocked, true);
1460     sceneSession->SetTemporarilyShowWhenLocked(false);
1461     isTemporarilyShowWhenLocked = sceneSession->IsTemporarilyShowWhenLocked();
1462     ASSERT_EQ(isTemporarilyShowWhenLocked, false);
1463 
1464     sceneSession->isTemporarilyShowWhenLocked_.store(true);
1465     sceneSession->SetTemporarilyShowWhenLocked(true);
1466     ASSERT_EQ(sceneSession->IsTemporarilyShowWhenLocked(), true);
1467 }
1468 
1469 /**
1470  * @tc.name: GetShowWhenLockedFlagValue
1471  * @tc.desc: GetShowWhenLockedFlagValue
1472  * @tc.type: FUNC
1473  */
1474 HWTEST_F(SceneSessionTest2, GetShowWhenLockedFlagValue, Function | SmallTest | Level2)
1475 {
1476     SessionInfo info;
1477     info.abilityName_ = "GetShowWhenLockedFlagValue";
1478     info.bundleName_ = "GetShowWhenLockedFlagValue";
1479     info.windowType_ = 1;
1480     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1481         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1482     EXPECT_NE(specificCallback_, nullptr);
1483     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback_);
1484     EXPECT_NE(sceneSession, nullptr);
1485     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1486     EXPECT_NE(property, nullptr);
1487     property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1488     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1489     ASSERT_EQ(sceneSession->GetShowWhenLockedFlagValue(), false);
1490     sceneSession->property_ = property;
1491     property->SetWindowFlags(4);
1492     ASSERT_EQ(sceneSession->GetShowWhenLockedFlagValue(), true);
1493 }
1494 
1495 /**
1496  * @tc.name: SetClientIdentityToken
1497  * @tc.desc: SetClientIdentityToken
1498  * @tc.type: FUNC
1499  */
1500 HWTEST_F(SceneSessionTest2, SetClientIdentityToken, Function | SmallTest | Level2)
1501 {
1502     SessionInfo info;
1503     info.abilityName_ = "SetClientIdentityToken";
1504     info.bundleName_ = "SetClientIdentityToken";
1505     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1506     EXPECT_NE(sceneSession, nullptr);
1507     std::string token = "testToken";
1508     sceneSession->SetClientIdentityToken(token);
1509     ASSERT_EQ(sceneSession->GetClientIdentityToken(), token);
1510 }
1511 
1512 /**
1513  * @tc.name: SetSkipDraw
1514  * @tc.desc: SetSkipDraw
1515  * @tc.type: FUNC
1516  */
1517 HWTEST_F(SceneSessionTest2, SetSkipDraw, Function | SmallTest | Level2)
1518 {
1519     SessionInfo info;
1520     info.abilityName_ = "SetSkipDraw";
1521     info.bundleName_ = "SetSkipDraw";
1522     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1523     EXPECT_NE(sceneSession, nullptr);
1524     sceneSession->SetSkipDraw(true);
1525     sceneSession->SetSkipDraw(false);
1526 }
1527 
1528 /**
1529  * @tc.name: GetWindowDragHotAreaType
1530  * @tc.desc: GetWindowDragHotAreaType
1531  * @tc.type: FUNC
1532  */
1533 HWTEST_F(SceneSessionTest2, GetWindowDragHotAreaType, Function | SmallTest | Level2)
1534 {
1535     SessionInfo info;
1536     info.abilityName_ = "HotAreaType";
1537     info.bundleName_ = "HotAreaType";
1538     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1539     EXPECT_NE(sceneSession, nullptr);
1540     WSRect rect = {0, 0, 10, 10};
1541     sceneSession->AddOrUpdateWindowDragHotArea(0, 1, rect);
1542     sceneSession->AddOrUpdateWindowDragHotArea(0, 1, rect);
1543     auto type = sceneSession->GetWindowDragHotAreaType(0, 1, 2, 2);
1544     ASSERT_EQ(type, 1);
1545 }
1546 
1547 /**
1548  * @tc.name: RegisterSubModalTypeChangeCallback
1549  * @tc.desc: RegisterSubModalTypeChangeCallback
1550  * @tc.type: FUNC
1551  */
1552 HWTEST_F(SceneSessionTest2, RegisterSubModalTypeChangeCallback, Function | SmallTest | Level2)
1553 {
1554     SessionInfo info;
1555     info.abilityName_ = "RegisterSubModalTypeChangeCallback";
1556     info.bundleName_ = "RegisterSubModalTypeChangeCallback";
1557     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1558     EXPECT_NE(sceneSession, nullptr);
__anon68f904dc1102(SubWindowModalType subWindowModalType) 1559     sceneSession->RegisterSubModalTypeChangeCallback([](SubWindowModalType subWindowModalType) {
1560         return;
1561     });
1562     EXPECT_NE(sceneSession->onSubModalTypeChange_, nullptr);
1563 }
1564 
1565 /**
1566  * @tc.name: NotifySubModalTypeChange
1567  * @tc.desc: NotifySubModalTypeChange
1568  * @tc.type: FUNC
1569  */
1570 HWTEST_F(SceneSessionTest2, NotifySubModalTypeChange, Function | SmallTest | Level2)
1571 {
1572     SessionInfo info;
1573     info.abilityName_ = "NotifySubModalTypeChange";
1574     info.bundleName_ = "NotifySubModalTypeChange";
1575     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1576     EXPECT_NE(sceneSession, nullptr);
__anon68f904dc1202(SubWindowModalType subWindowModalType) 1577     sceneSession->RegisterSubModalTypeChangeCallback([](SubWindowModalType subWindowModalType) {
1578         return;
1579     });
1580     EXPECT_NE(sceneSession->onSubModalTypeChange_, nullptr);
1581     EXPECT_EQ(sceneSession->NotifySubModalTypeChange(SubWindowModalType::TYPE_WINDOW_MODALITY), WSError::WS_OK);
1582 }
1583 
1584 /**
1585  * @tc.name: RegisterMainModalTypeChangeCallback
1586  * @tc.desc: RegisterMainModalTypeChangeCallback
1587  * @tc.type: FUNC
1588  */
1589 HWTEST_F(SceneSessionTest2, RegisterMainModalTypeChangeCallback, Function | SmallTest | Level2)
1590 {
1591     SessionInfo info;
1592     info.abilityName_ = "RegisterMainModalTypeChangeCallback";
1593     info.bundleName_ = "RegisterMainModalTypeChangeCallback";
1594     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1595     EXPECT_NE(sceneSession, nullptr);
__anon68f904dc1302(bool isModal) 1596     sceneSession->RegisterMainModalTypeChangeCallback([](bool isModal) {
1597         return;
1598     });
1599     EXPECT_NE(sceneSession->onMainModalTypeChange_, nullptr);
1600 }
1601 
1602 /**
1603  * @tc.name: GetSubWindowModalType
1604  * @tc.desc: GetSubWindowModalType
1605  * @tc.type: FUNC
1606  */
1607 HWTEST_F(SceneSessionTest2, GetSubWindowModalType, Function | SmallTest | Level2)
1608 {
1609     SessionInfo info;
1610     info.abilityName_ = "ModalType";
1611     info.bundleName_ = "ModalType";
1612     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1613     EXPECT_NE(sceneSession, nullptr);
1614 
1615     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1616     EXPECT_NE(property, nullptr);
1617     property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
1618     sceneSession->SetSessionProperty(property);
1619     auto result = sceneSession->GetSubWindowModalType();
1620     ASSERT_EQ(result, SubWindowModalType::TYPE_DIALOG);
1621 }
1622 
1623 /**
1624  * @tc.name: CheckGetAvoidAreaAvailable
1625  * @tc.desc: CheckGetAvoidAreaAvailable
1626  * @tc.type: FUNC
1627  */
1628 HWTEST_F(SceneSessionTest2, CheckGetAvoidAreaAvailable, Function | SmallTest | Level2)
1629 {
1630     SessionInfo info;
1631     info.abilityName_ = "CheckGetAvoidAreaAvailable";
1632     info.bundleName_ = "CheckGetAvoidAreaAvailable";
1633     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1634     EXPECT_NE(sceneSession, nullptr);
1635 
1636     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1637     EXPECT_NE(property, nullptr);
1638     property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1639     sceneSession->SetSessionProperty(property);
1640     sceneSession->CheckGetAvoidAreaAvailable(AvoidAreaType::TYPE_SYSTEM);
1641 
1642     property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1643     sceneSession->SetSessionProperty(property);
1644     sceneSession->CheckGetAvoidAreaAvailable(AvoidAreaType::TYPE_SYSTEM);
1645 }
1646 
1647 /**
1648  * @tc.name: SetWindowAnimationFlag
1649  * @tc.desc: SetWindowAnimationFlag
1650  * @tc.type: FUNC
1651  */
1652 HWTEST_F(SceneSessionTest2, SetWindowAnimationFlag, Function | SmallTest | Level2)
1653 {
1654     SessionInfo info;
1655     info.abilityName_ = "SetWindowAnimationFlag";
1656     info.bundleName_ = "SetWindowAnimationFlag";
1657     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1658     EXPECT_NE(sceneSession, nullptr);
1659 
__anon68f904dc1402(bool isNeedDefaultAnimationFlag) 1660     sceneSession->onWindowAnimationFlagChange_ = [](bool isNeedDefaultAnimationFlag) {};
1661     sceneSession->SetWindowAnimationFlag(true);
1662     ASSERT_EQ(true, sceneSession->needDefaultAnimationFlag_);
1663 }
1664 
1665 /**
1666  * @tc.name: IsFullScreenMovable
1667  * @tc.desc: IsFullScreenMovable
1668  * @tc.type: FUNC
1669  */
1670 HWTEST_F(SceneSessionTest2, IsFullScreenMovable, Function | SmallTest | Level2)
1671 {
1672     SessionInfo info;
1673     info.abilityName_ = "IsFullScreenMovable";
1674     info.bundleName_ = "IsFullScreenMovable";
1675     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1676     EXPECT_NE(sceneSession, nullptr);
1677     auto result = sceneSession->IsFullScreenMovable();
1678     ASSERT_EQ(true, result);
1679 }
1680 
1681 /**
1682  * @tc.name: SetTitleAndDockHoverShowChangeCallback
1683  * @tc.desc: SetTitleAndDockHoverShowChangeCallback
1684  * @tc.type: FUNC
1685  */
1686 HWTEST_F(SceneSessionTest2, SetTitleAndDockHoverShowChangeCallback, Function | SmallTest | Level2)
1687 {
1688     SessionInfo info;
1689     info.abilityName_ = "SetTitleAndDockHoverShowChangeCallback";
1690     info.bundleName_ = "SetTitleAndDockHoverShowChangeCallback";
1691     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
__anon68f904dc1502(bool isTitleHoverShown, bool isDockHoverShown) 1692     sceneSession->SetTitleAndDockHoverShowChangeCallback([](bool isTitleHoverShown, bool isDockHoverShown) {
1693         return;
1694     });
1695     EXPECT_NE(sceneSession->onTitleAndDockHoverShowChangeFunc_, nullptr);
1696 }
1697 }
1698 }
1699 }