• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 "key_event.h"
22 #include "session/host/include/scene_session.h"
23 #include "session/host/include/sub_session.h"
24 #include "session/host/include/system_session.h"
25 #include "session/host/include/main_session.h"
26 #include "wm_common.h"
27 #include "mock/mock_session_stage.h"
28 #include "input_event.h"
29 #include <pointer_event.h>
30 #include <ui/rs_surface_node.h>
31 
32 using namespace testing;
33 using namespace testing::ext;
34 namespace OHOS {
35 namespace Rosen {
36 constexpr int WAIT_ASYNC_US = 1000000;
37 class SceneSessionTest : 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 SceneSessionTest::SetUpTestCase()
46 {
47 }
48 
TearDownTestCase()49 void SceneSessionTest::TearDownTestCase()
50 {
51 }
52 
SetUp()53 void SceneSessionTest::SetUp()
54 {
55 }
56 
TearDown()57 void SceneSessionTest::TearDown()
58 {
59 }
60 
61 namespace {
62 
63 /**
64  * @tc.name: SetGlobalMaximizeMode01
65  * @tc.desc: SetGlobalMaximizeMode
66  * @tc.type: FUNC
67  */
68 HWTEST_F(SceneSessionTest, SetGlobalMaximizeMode01, Function | SmallTest | Level2)
69 {
70     SessionInfo info;
71     info.abilityName_ = "SetGlobalMaximizeMode01";
72     info.bundleName_ = "SetGlobalMaximizeMode01";
73     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
74     EXPECT_NE(sceneSession, nullptr);
75     sceneSession->isActive_ = true;
76     auto result = sceneSession->SetGlobalMaximizeMode(MaximizeMode::MODE_AVOID_SYSTEM_BAR);
77     ASSERT_EQ(result, WSError::WS_OK);
78 }
79 
80 /**
81  * @tc.name: GetGlobalMaximizeMode01
82  * @tc.desc: GetGlobalMaximizeMode
83  * @tc.type: FUNC
84  */
85 HWTEST_F(SceneSessionTest, GetGlobalMaximizeMode01, Function | SmallTest | Level2)
86 {
87     SessionInfo info;
88     info.abilityName_ = "GetGlobalMaximizeMode01";
89     info.bundleName_ = "GetGlobalMaximizeMode01";
90     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
91     EXPECT_NE(sceneSession, nullptr);
92     sceneSession->isActive_ = true;
93     MaximizeMode mode;
94     auto result = sceneSession->GetGlobalMaximizeMode(mode);
95     ASSERT_EQ(result, WSError::WS_OK);
96 }
97 
98 /**
99  * @tc.name: GlobalMaximizeMode01
100  * @tc.desc: GlobalMaximizeMode MODE_AVOID_SYSTEM_BAR
101  * @tc.type: FUNC
102  */
103 HWTEST_F(SceneSessionTest, GlobalMaximizeMode01, Function | SmallTest | Level2)
104 {
105     SessionInfo info;
106     info.abilityName_ = "GlobalMaximizeMode01";
107     info.bundleName_ = "GlobalMaximizeMode01";
108     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
109     EXPECT_NE(sceneSession, nullptr);
110     sceneSession->isActive_ = true;
111     auto result = sceneSession->SetGlobalMaximizeMode(MaximizeMode::MODE_AVOID_SYSTEM_BAR);
112     ASSERT_EQ(result, WSError::WS_OK);
113 
114     MaximizeMode mode;
115     result = sceneSession->GetGlobalMaximizeMode(mode);
116     ASSERT_EQ(result, WSError::WS_OK);
117     ASSERT_EQ(mode, MaximizeMode::MODE_AVOID_SYSTEM_BAR);
118 }
119 
120 /**
121  * @tc.name: GlobalMaximizeMode02
122  * @tc.desc: GlobalMaximizeMode MODE_FULL_FILL
123  * @tc.type: FUNC
124  */
125 HWTEST_F(SceneSessionTest, GlobalMaximizeMode02, Function | SmallTest | Level2)
126 {
127     SessionInfo info;
128     info.abilityName_ = "GlobalMaximizeMode02";
129     info.bundleName_ = "GlobalMaximizeMode02";
130     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
131     EXPECT_NE(sceneSession, nullptr);
132     sceneSession->isActive_ = true;
133     auto result = sceneSession->SetGlobalMaximizeMode(MaximizeMode::MODE_FULL_FILL);
134     ASSERT_EQ(result, WSError::WS_OK);
135     MaximizeMode mode;
136     result = sceneSession->GetGlobalMaximizeMode(mode);
137     ASSERT_EQ(result, WSError::WS_OK);
138     ASSERT_EQ(mode, MaximizeMode::MODE_FULL_FILL);
139 }
140 
141 /**
142  * @tc.name: SetAndGetPipTemplateInfo
143  * @tc.desc: SetAndGetPipTemplateInfo Test
144  * @tc.type: FUNC
145  */
146 HWTEST_F(SceneSessionTest, SetAndGetPipTemplateInfo, Function | SmallTest | Level2)
147 {
148     SessionInfo info;
149     info.abilityName_ = "Background01";
150     info.bundleName_ = "Background01";
151     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
152     EXPECT_NE(sceneSession, nullptr);
153     sceneSession->isActive_ = true;
154     PiPTemplateInfo pipTemplateInfo;
155     pipTemplateInfo.pipTemplateType = static_cast<uint32_t>(PiPTemplateType::VIDEO_CALL);
156     sceneSession->SetPiPTemplateInfo(pipTemplateInfo);
157     ASSERT_EQ(sceneSession->GetPiPTemplateInfo().pipTemplateType,
158         static_cast<uint32_t>(PiPTemplateType::VIDEO_CALL));
159 
160     pipTemplateInfo.pipTemplateType = static_cast<uint32_t>(PiPTemplateType::VIDEO_MEETING);
161     sceneSession->SetPiPTemplateInfo(pipTemplateInfo);
162     ASSERT_EQ(sceneSession->GetPiPTemplateInfo().pipTemplateType,
163         static_cast<uint32_t>(PiPTemplateType::VIDEO_MEETING));
164 }
165 
166 /**
167  * @tc.name: UpdateWindowSceneAfterCustomAnimation01
168  * @tc.desc: UpdateWindowSceneAfterCustomAnimation
169  * @tc.type: FUNC
170  */
171 HWTEST_F(SceneSessionTest, UpdateWindowSceneAfterCustomAnimation01, Function | SmallTest | Level2)
172 {
173     SessionInfo info;
174     info.abilityName_ = "Background01";
175     info.bundleName_ = "Background01";
176     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
177     EXPECT_NE(sceneSession, nullptr);
178     sceneSession->isActive_ = true;
179     auto result = sceneSession->UpdateWindowSceneAfterCustomAnimation(false);
180     ASSERT_EQ(result, WSError::WS_OK);
181     result = sceneSession->UpdateWindowSceneAfterCustomAnimation(true);
182     ASSERT_EQ(result, WSError::WS_OK);
183 }
184 
185 /**
186  * @tc.name: SetZOrder01
187  * @tc.desc: SetZOrder
188  * @tc.type: FUNC
189  */
190 HWTEST_F(SceneSessionTest, SetZOrder01, Function | SmallTest | Level2)
191 {
192     SessionInfo info;
193     info.abilityName_ = "SetZOrder01";
194     info.bundleName_ = "SetZOrder01";
195     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
196     EXPECT_NE(sceneSession, nullptr);
197     uint32_t zOrder = 2;
198     sceneSession->SetZOrder(zOrder);
199     usleep(WAIT_ASYNC_US);
200     ASSERT_EQ(zOrder, sceneSession->zOrder_);
201     sceneSession->SetZOrder(zOrder);
202     usleep(WAIT_ASYNC_US);
203     ASSERT_EQ(zOrder, sceneSession->zOrder_);
204 }
205 
206 /**
207  * @tc.name: GetTouchHotAreas01
208  * @tc.desc: GetTouchHotAreas
209  * @tc.type: FUNC
210  */
211 HWTEST_F(SceneSessionTest, GetTouchHotAreas01, Function | SmallTest | Level2)
212 {
213     SessionInfo info;
214     info.abilityName_ = "Background01";
215     info.bundleName_ = "GetTouchHotAreas01";
216     sptr<Rosen::ISession> session_;
217     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
218         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
219     EXPECT_NE(specificCallback_, nullptr);
220     sptr<SceneSession> sceneSession;
221     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
222     EXPECT_NE(sceneSession, nullptr);
223     Rect windowRect = {1, 1, 1, 1};
224     std::vector<Rect> rects;
225     uint32_t hotAreasNum = 10;
226     uint32_t hotAreaWidth = windowRect.width_ / hotAreasNum;
227     uint32_t hotAreaHeight = windowRect.height_ / hotAreasNum;
228     for (uint32_t i = 0; i < hotAreasNum; ++i) {
229         rects.emplace_back(Rect{hotAreaWidth * i, hotAreaHeight * i, hotAreaWidth, hotAreaHeight});
230     }
231     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
232 
233     ASSERT_NE(nullptr, property);
234     property->SetTouchHotAreas(rects);
235     ASSERT_NE(rects, sceneSession->GetTouchHotAreas());
236 }
237 
238 /**
239  * @tc.name: SetTurnScreenOn01
240  * @tc.desc: SetTurnScreenOn
241  * @tc.type: FUNC
242  */
243 HWTEST_F(SceneSessionTest, SetTurnScreenOn01, Function | SmallTest | Level2)
244 {
245     SessionInfo info;
246     info.abilityName_ = "SetTurnScreenOn01";
247     info.bundleName_ = "SetTurnScreenOn01";
248     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
249     EXPECT_NE(sceneSession, nullptr);
250     ASSERT_EQ(WSError::WS_OK, sceneSession->SetTurnScreenOn(true));
251     ASSERT_EQ(true, sceneSession->IsTurnScreenOn());
252 }
253 
254 /**
255  * @tc.name: SetTurnScreenOn02
256  * @tc.desc: SetTurnScreenOn
257  * @tc.type: FUNC
258  */
259 HWTEST_F(SceneSessionTest, SetTurnScreenOn02, Function | SmallTest | Level2)
260 {
261     SessionInfo info;
262     info.abilityName_ = "SetTurnScreenOn02";
263     info.bundleName_ = "SetTurnScreenOn02";
264     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
265     EXPECT_NE(sceneSession, nullptr);
266     ASSERT_EQ(WSError::WS_OK, sceneSession->SetTurnScreenOn(false));
267     ASSERT_EQ(false, sceneSession->IsTurnScreenOn());
268 }
269 
270 /**
271  * @tc.name: UpdateWindowAnimationFlag01
272  * @tc.desc: UpdateWindowAnimationFlag true
273  * @tc.type: FUNC
274  */
275 HWTEST_F(SceneSessionTest, UpdateWindowAnimationFlag01, Function | SmallTest | Level2)
276 {
277     SessionInfo info;
278     info.abilityName_ = "UpdateWindowAnimationFlag01";
279     info.bundleName_ = "UpdateWindowAnimationFlag01";
280     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
281     EXPECT_NE(sceneSession, nullptr);
282     ASSERT_EQ(WSError::WS_OK, sceneSession->UpdateWindowAnimationFlag(true));
283 }
284 
285 /**
286  * @tc.name: UpdateWindowAnimationFlag02
287  * @tc.desc: UpdateWindowAnimationFlag false
288  * @tc.type: FUNC
289  */
290 HWTEST_F(SceneSessionTest, UpdateWindowAnimationFlag02, Function | SmallTest | Level2)
291 {
292     SessionInfo info;
293     info.abilityName_ = "UpdateWindowAnimationFlag02";
294     info.bundleName_ = "UpdateWindowAnimationFlag02";
295     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
296     EXPECT_NE(sceneSession, nullptr);
297     ASSERT_EQ(WSError::WS_OK, sceneSession->UpdateWindowAnimationFlag(false));
298 }
299 
300 /**
301  * @tc.name: SetRequestedOrientation
302  * @tc.desc: SetRequestedOrientation
303  * @tc.type: FUNC
304  */
305 HWTEST_F(SceneSessionTest, SetRequestedOrientation01, Function | SmallTest | Level2)
306 {
307     SessionInfo info;
308     info.abilityName_ = "SetRequestedOrientation01";
309     info.bundleName_ = "SetRequestedOrientation01";
310     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
311     EXPECT_NE(sceneSession, nullptr);
312     Orientation ori = Orientation::UNSPECIFIED;
313     sceneSession->SetRequestedOrientation(ori);
314     Orientation ret = sceneSession->GetRequestedOrientation();
315     ASSERT_EQ(ori, ret);
316 
317     sceneSession->SetRequestedOrientation(Orientation::AUTO_ROTATION_UNSPECIFIED);
318     Orientation ret1 = sceneSession->GetRequestedOrientation();
319     ASSERT_EQ(ret1, Orientation::AUTO_ROTATION_UNSPECIFIED);
320 
321     sceneSession->SetRequestedOrientation(Orientation::USER_ROTATION_PORTRAIT);
322     Orientation ret2 = sceneSession->GetRequestedOrientation();
323     ASSERT_EQ(ret2, Orientation::USER_ROTATION_PORTRAIT);
324 
325     sceneSession->SetRequestedOrientation(Orientation::USER_ROTATION_LANDSCAPE);
326     Orientation ret3 = sceneSession->GetRequestedOrientation();
327     ASSERT_EQ(ret3, Orientation::USER_ROTATION_LANDSCAPE);
328 
329     sceneSession->SetRequestedOrientation(Orientation::USER_ROTATION_PORTRAIT_INVERTED);
330     Orientation ret4 = sceneSession->GetRequestedOrientation();
331     ASSERT_EQ(ret4, Orientation::USER_ROTATION_PORTRAIT_INVERTED);
332 
333     sceneSession->SetRequestedOrientation(Orientation::USER_ROTATION_LANDSCAPE_INVERTED);
334     Orientation ret5 = sceneSession->GetRequestedOrientation();
335     ASSERT_EQ(ret5, Orientation::USER_ROTATION_LANDSCAPE_INVERTED);
336 
337     sceneSession->SetRequestedOrientation(Orientation::FOLLOW_DESKTOP);
338     Orientation ret6 = sceneSession->GetRequestedOrientation();
339     ASSERT_EQ(ret6, Orientation::FOLLOW_DESKTOP);
340 }
341 
342 /**
343  * @tc.name: GetRequestedOrientation
344  * @tc.desc: GetRequestedOrientation
345  * @tc.type: FUNC
346  */
347 HWTEST_F(SceneSessionTest, GetRequestedOrientation, Function | SmallTest | Level2)
348 {
349     SessionInfo info;
350     info.abilityName_ = "GetRequestedOrientation";
351     info.bundleName_ = "GetRequestedOrientation";
352     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
353     Orientation ori = Orientation::HORIZONTAL;
354     sceneSession->SetRequestedOrientation(ori);
355     Orientation ret = sceneSession->GetRequestedOrientation();
356     ASSERT_EQ(ori, ret);
357 
358     sceneSession->SetRequestedOrientation(Orientation::AUTO_ROTATION_UNSPECIFIED);
359     Orientation ret1 = sceneSession->GetRequestedOrientation();
360     ASSERT_EQ(ret1, Orientation::AUTO_ROTATION_UNSPECIFIED);
361 
362     sceneSession->SetRequestedOrientation(Orientation::USER_ROTATION_PORTRAIT);
363     Orientation ret2 = sceneSession->GetRequestedOrientation();
364     ASSERT_EQ(ret2, Orientation::USER_ROTATION_PORTRAIT);
365 
366     sceneSession->SetRequestedOrientation(Orientation::USER_ROTATION_LANDSCAPE);
367     Orientation ret3 = sceneSession->GetRequestedOrientation();
368     ASSERT_EQ(ret3, Orientation::USER_ROTATION_LANDSCAPE);
369 
370     sceneSession->SetRequestedOrientation(Orientation::USER_ROTATION_PORTRAIT_INVERTED);
371     Orientation ret4 = sceneSession->GetRequestedOrientation();
372     ASSERT_EQ(ret4, Orientation::USER_ROTATION_PORTRAIT_INVERTED);
373 
374     sceneSession->SetRequestedOrientation(Orientation::USER_ROTATION_LANDSCAPE_INVERTED);
375     Orientation ret5 = sceneSession->GetRequestedOrientation();
376     ASSERT_EQ(ret5, Orientation::USER_ROTATION_LANDSCAPE_INVERTED);
377 
378     sceneSession->SetRequestedOrientation(Orientation::FOLLOW_DESKTOP);
379     Orientation ret6 = sceneSession->GetRequestedOrientation();
380     ASSERT_EQ(ret6, Orientation::FOLLOW_DESKTOP);
381 }
382 
383 /**
384  * @tc.name: SetDefaultRequestedOrientation
385  * @tc.desc: SetDefaultRequestedOrientation
386  * @tc.type: FUNC
387  */
388 HWTEST_F(SceneSessionTest, SetDefaultRequestedOrientation, Function | SmallTest | Level2)
389 {
390     SessionInfo info;
391     info.abilityName_ = "SetDefaultRequestedOrientation";
392     info.bundleName_ = "SetDefaultRequestedOrientation";
393     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
394     EXPECT_NE(sceneSession, nullptr);
395     Orientation orientation = Orientation::AUTO_ROTATION_UNSPECIFIED;
396     sceneSession->SetDefaultRequestedOrientation(orientation);
397     Orientation ret = sceneSession->GetRequestedOrientation();
398     ASSERT_EQ(orientation, ret);
399 
400     orientation = Orientation::USER_ROTATION_PORTRAIT;
401     sceneSession->SetDefaultRequestedOrientation(orientation);
402     ret = sceneSession->GetRequestedOrientation();
403     ASSERT_EQ(orientation, ret);
404 
405     orientation = Orientation::USER_ROTATION_LANDSCAPE;
406     sceneSession->SetDefaultRequestedOrientation(orientation);
407     ret = sceneSession->GetRequestedOrientation();
408     ASSERT_EQ(orientation, ret);
409 
410     orientation = Orientation::USER_ROTATION_PORTRAIT_INVERTED;
411     sceneSession->SetDefaultRequestedOrientation(orientation);
412     ret = sceneSession->GetRequestedOrientation();
413     ASSERT_EQ(orientation, ret);
414 
415     orientation = Orientation::USER_ROTATION_LANDSCAPE_INVERTED;
416     sceneSession->SetDefaultRequestedOrientation(orientation);
417     ret = sceneSession->GetRequestedOrientation();
418     ASSERT_EQ(orientation, ret);
419 
420     orientation = Orientation::FOLLOW_DESKTOP;
421     sceneSession->SetDefaultRequestedOrientation(orientation);
422     ret = sceneSession->GetRequestedOrientation();
423     ASSERT_EQ(orientation, ret);
424 }
425 
426 /**
427  * @tc.name: IsKeepScreenOn01
428  * @tc.desc: IsKeepScreenOn true
429  * @tc.type: FUNC
430  */
431 HWTEST_F(SceneSessionTest, IsKeepScreenOn01, Function | SmallTest | Level2)
432 {
433     SessionInfo info;
434     info.abilityName_ = "IsKeepScreenOn01";
435     info.bundleName_ = "IsKeepScreenOn01";
436     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
437     ASSERT_NE(sceneSession, nullptr);
438     ASSERT_EQ(WSError::WS_OK, sceneSession->SetKeepScreenOn(true));
439     ASSERT_EQ(true, sceneSession->IsKeepScreenOn());
440 }
441 
442 /**
443  * @tc.name: IsKeepScreenOn02
444  * @tc.desc: IsKeepScreenOn false
445  * @tc.type: FUNC
446  */
447 HWTEST_F(SceneSessionTest, IsKeepScreenOn02, Function | SmallTest | Level2)
448 {
449     SessionInfo info;
450     info.abilityName_ = "IsKeepScreenOn02";
451     info.bundleName_ = "IsKeepScreenOn02";
452     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
453     ASSERT_NE(sceneSession, nullptr);
454     ASSERT_EQ(WSError::WS_OK, sceneSession->SetKeepScreenOn(false));
455     ASSERT_EQ(false, sceneSession->IsKeepScreenOn());
456 }
457 
458 /**
459  * @tc.name: IsViewKeepScreenOn01
460  * @tc.desc: IsViewKeepScreenOn true
461  * @tc.type: FUNC
462  */
463 HWTEST_F(SceneSessionTest, IsViewKeepScreenOn01, TestSize.Level1)
464 {
465     SessionInfo info;
466     info.abilityName_ = "IsViewKeepScreenOn01";
467     info.bundleName_ = "IsViewKeepScreenOn01";
468     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
469     ASSERT_NE(sceneSession, nullptr);
470     ASSERT_EQ(WSError::WS_OK, sceneSession->SetViewKeepScreenOn(true));
471     ASSERT_EQ(true, sceneSession->IsViewKeepScreenOn());
472 }
473 
474 /**
475  * @tc.name: IsViewKeepScreenOn02
476  * @tc.desc: IsViewKeepScreenOn false
477  * @tc.type: FUNC
478  */
479 HWTEST_F(SceneSessionTest, IsViewKeepScreenOn02, TestSize.Level1)
480 {
481     SessionInfo info;
482     info.abilityName_ = "IsViewKeepScreenOn02";
483     info.bundleName_ = "IsViewKeepScreenOn02";
484     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
485     ASSERT_NE(sceneSession, nullptr);
486     ASSERT_EQ(WSError::WS_OK, sceneSession->SetViewKeepScreenOn(false));
487     ASSERT_EQ(false, sceneSession->IsViewKeepScreenOn());
488 }
489 
490 /**
491  * @tc.name: IsAppSession
492  * @tc.desc: IsAppSession true
493  * @tc.type: FUNC
494  */
495 HWTEST_F(SceneSessionTest, IsAppSession01, Function | SmallTest | Level2)
496 {
497     SessionInfo info;
498     info.abilityName_ = "IsAppSession01";
499     info.bundleName_ = "IsAppSession01";
500     info.windowType_ = 1;
501     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
502     EXPECT_NE(sceneSession, nullptr);
503     ASSERT_EQ(true, sceneSession->IsAppSession());
504 }
505 
506 /**
507  * @tc.name: IsAppSession
508  * @tc.desc: IsAppSession false
509  * @tc.type: FUNC
510  */
511 HWTEST_F(SceneSessionTest, IsAppSession02, Function | SmallTest | Level2)
512 {
513     SessionInfo info;
514     info.abilityName_ = "IsAppSession02";
515     info.bundleName_ = "IsAppSession02";
516     info.windowType_ = 2106;
517     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
518     EXPECT_NE(sceneSession, nullptr);
519     ASSERT_EQ(false, sceneSession->IsAppSession());
520 
521     SessionInfo parentInfo;
522     parentInfo.abilityName_ = "testSession1";
523     parentInfo.moduleName_ = "testSession2";
524     parentInfo.bundleName_ = "testSession3";
525     sptr<Session> parentSession = sptr<Session>::MakeSptr(parentInfo);
526     ASSERT_NE(parentSession, nullptr);
527 
528     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
529     EXPECT_NE(property, nullptr);
530     property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
531     parentSession->SetSessionProperty(property);
532     sceneSession->SetParentSession(parentSession);
533     ASSERT_EQ(false, sceneSession->IsAppSession());
534 
535     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
536     parentSession->SetSessionProperty(property);
537     sceneSession->SetParentSession(parentSession);
538     ASSERT_EQ(true, sceneSession->IsAppSession());
539 }
540 
541 /**
542  * @tc.name: IsAppOrLowerSystemSession
543  * @tc.desc: IsAppOrLowerSystemSession true
544  * @tc.type: FUNC
545  */
546 HWTEST_F(SceneSessionTest, IsAppOrLowerSystemSession01, Function | SmallTest | Level2)
547 {
548     SessionInfo info;
549     info.abilityName_ = "Background01";
550     info.bundleName_ = "IsAppOrLowerSystemSession01";
551     info.windowType_ = 2126;
552 
553     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
554     EXPECT_NE(sceneSession, nullptr);
555     ASSERT_EQ(true, sceneSession->IsAppOrLowerSystemSession());
556 }
557 
558 /**
559  * @tc.name: IsAppOrLowerSystemSession
560  * @tc.desc: IsAppOrLowerSystemSession false
561  * @tc.type: FUNC
562  */
563 HWTEST_F(SceneSessionTest, IsAppOrLowerSystemSession02, Function | SmallTest | Level2)
564 {
565     SessionInfo info;
566     info.abilityName_ = "Background02";
567     info.bundleName_ = "IsAppOrLowerSystemSession02";
568     info.windowType_ = 2106;
569 
570     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
571     EXPECT_NE(sceneSession, nullptr);
572     ASSERT_EQ(false, sceneSession->IsAppOrLowerSystemSession());
573 
574     SessionInfo parentInfo;
575     parentInfo.abilityName_ = "testSession1";
576     parentInfo.moduleName_ = "testSession2";
577     parentInfo.bundleName_ = "testSession3";
578     sptr<Session> parentSession = sptr<Session>::MakeSptr(parentInfo);
579     ASSERT_NE(parentSession, nullptr);
580 
581     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
582     EXPECT_NE(property, nullptr);
583     property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
584     parentSession->SetSessionProperty(property);
585     sceneSession->SetParentSession(parentSession);
586     ASSERT_EQ(false, sceneSession->IsAppOrLowerSystemSession());
587 
588     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
589     parentSession->SetSessionProperty(property);
590     sceneSession->SetParentSession(parentSession);
591     ASSERT_EQ(true, sceneSession->IsAppOrLowerSystemSession());
592 }
593 
594 /**
595  * @tc.name: IsSystemSessionAboveApp
596  * @tc.desc: IsSystemSessionAboveApp true
597  * @tc.type: FUNC
598  */
599 HWTEST_F(SceneSessionTest, IsSystemSessionAboveApp01, Function | SmallTest | Level2)
600 {
601     SessionInfo info1;
602     info1.abilityName_ = "HighZOrder01";
603     info1.bundleName_ = "IsSystemSessionAboveApp01";
604     info1.windowType_ = 2122;
605 
606     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(info1, nullptr);
607     ASSERT_EQ(true, sceneSession1->IsSystemSessionAboveApp());
608 
609     SessionInfo info2;
610     info2.abilityName_ = "HighZOrder02";
611     info2.bundleName_ = "IsSystemSessionAboveApp02";
612     info2.windowType_ = 2104;
613 
614     sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(info2, nullptr);
615     ASSERT_EQ(true, sceneSession2->IsSystemSessionAboveApp());
616 
617     SessionInfo info3;
618     info3.abilityName_ = "HighZOrder03";
619     info3.bundleName_ = "SCBDropdownPanel13";
620     info3.windowType_ = 2109;
621 
622     sptr<SceneSession> sceneSession3 = sptr<SceneSession>::MakeSptr(info3, nullptr);
623     ASSERT_EQ(true, sceneSession3->IsSystemSessionAboveApp());
624 
625     SessionInfo info4;
626     info4.abilityName_ = "HighZOrder04";
627     info4.bundleName_ = "IsSystemSessionAboveApp04";
628     info4.windowType_ = 2109;
629 
630     sptr<SceneSession> sceneSession4 = sptr<SceneSession>::MakeSptr(info4, nullptr);
631     ASSERT_EQ(false, sceneSession4->IsSystemSessionAboveApp());
632 
633     SessionInfo info5;
634     info5.abilityName_ = "HighZOrderGestureDock";
635     info5.bundleName_ = "SCBGestureDock21";
636     info5.windowType_ = 2106;
637 
638     sptr<SceneSession> sceneSession5 = sptr<SceneSession>::MakeSptr(info5, nullptr);
639     ASSERT_EQ(true, sceneSession5->IsSystemSessionAboveApp());
640 }
641 
642 /**
643  * @tc.name: IsSystemSessionAboveApp
644  * @tc.desc: IsSystemSessionAboveApp false
645  * @tc.type: FUNC
646  */
647 HWTEST_F(SceneSessionTest, IsSystemSessionAboveApp02, Function | SmallTest | Level2)
648 {
649     SessionInfo info;
650     info.abilityName_ = "HighZOrder05";
651     info.bundleName_ = "IsSystemSessionAboveApp05";
652     info.windowType_ = 1;
653 
654     sptr<SceneSession> sceneSession;
655     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
656     EXPECT_NE(sceneSession, nullptr);
657     ASSERT_EQ(false, sceneSession->IsSystemSessionAboveApp());
658 }
659 
660 /**
661  * @tc.name: GetWindowName
662  * @tc.desc: GetWindowName
663  * @tc.type: FUNC
664  */
665 HWTEST_F(SceneSessionTest, GetWindowName, Function | SmallTest | Level2)
666 {
667     SessionInfo info;
668     info.abilityName_ = "Background01";
669     info.bundleName_ = "GetWindowName";
670     sptr<Rosen::ISession> session_;
671     sptr<SceneSession> sceneSession;
672     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
673     EXPECT_NE(sceneSession, nullptr);
674     ASSERT_NE("ww", sceneSession->GetWindowName());
675 }
676 
677 /**
678  * @tc.name: IsDecorEnable
679  * @tc.desc: IsDecorEnable
680  * @tc.type: FUNC
681  */
682 HWTEST_F(SceneSessionTest, IsDecorEnable, Function | SmallTest | Level2)
683 {
684     SessionInfo info;
685     info.abilityName_ = "IsDecorEnable";
686     info.bundleName_ = "IsDecorEnable";
687     info.windowType_ = 1;
688     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
689     EXPECT_NE(sceneSession, nullptr);
690     ASSERT_EQ(true, sceneSession->IsDecorEnable());
691     SessionInfo info_;
692     info_.abilityName_ = "Background01";
693     info_.bundleName_ = "IsDecorEnable";
694     info_.windowType_ = 1000;
695     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(info_, nullptr);
696     EXPECT_NE(sceneSession1, nullptr);
697     ASSERT_EQ(false, sceneSession1->IsDecorEnable());
698 }
699 
700 /**
701  * @tc.name: IsDecorEnable01
702  * @tc.desc: IsDecorEnable
703  * @tc.type: FUNC
704  */
705 HWTEST_F(SceneSessionTest, IsDecorEnable01, Function | SmallTest | Level2)
706 {
707     SessionInfo info;
708     info.abilityName_ = "Background01";
709     info.bundleName_ = "IsDecorEnable01";
710     info.windowType_ = 1;
711     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
712     EXPECT_NE(sceneSession, nullptr);
713     EXPECT_NE(sceneSession->property_, nullptr);
714     sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
715     sceneSession->property_->SetDecorEnable(true);
716     sceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
717     ASSERT_EQ(true, sceneSession->IsDecorEnable());
718 }
719 
720 /**
721  * @tc.name: UpdateNativeVisibility
722  * @tc.desc: UpdateNativeVisibility
723  * @tc.type: FUNC
724  */
725 HWTEST_F(SceneSessionTest, UpdateNativeVisibility, Function | SmallTest | Level2)
726 {
727     SessionInfo info;
728     info.abilityName_ = "Background01";
729     info.bundleName_ = "UpdateNativeVisibility";
730     info.windowType_ = 1;
731     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
732     EXPECT_NE(sceneSession, nullptr);
733     sceneSession->UpdateNativeVisibility(false);
734     ASSERT_EQ(false, sceneSession->IsVisible());
735     sceneSession->NotifyWindowVisibility();
736 
737     sptr<SessionStageMocker> mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
738     ASSERT_NE(mockSessionStage, nullptr);
739     sceneSession->sessionStage_ = mockSessionStage;
740     sceneSession->NotifyWindowVisibility();
741 }
742 
743 /**
744  * @tc.name: SetPrivacyMode01
745  * @tc.desc: Set PrivacyMode as false
746  * @tc.type: FUNC
747  */
748 HWTEST_F(SceneSessionTest, SetPrivacyMode01, Function | SmallTest | Level2)
749 {
750     SessionInfo info;
751     info.abilityName_ = "SetPrivacyMode01";
752     info.bundleName_ = "SetPrivacyMode01";
753     info.windowType_ = 1;
754     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
755     EXPECT_NE(sceneSession, nullptr);
756     struct RSSurfaceNodeConfig config;
757     std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
758     sceneSession->surfaceNode_ = surfaceNode;
759     sceneSession->SetPrivacyMode(false);
760     ASSERT_EQ(false, sceneSession->property_->GetPrivacyMode());
761     ASSERT_EQ(false, sceneSession->property_->GetSystemPrivacyMode());
762 }
763 
764 /**
765  * @tc.name: SetPrivacyMode02
766  * @tc.desc: Set PrivacyMode as true
767  * @tc.type: FUNC
768  */
769 HWTEST_F(SceneSessionTest, SetPrivacyMode02, Function | SmallTest | Level2)
770 {
771     SessionInfo info;
772     info.abilityName_ = "SetPrivacyMode02";
773     info.bundleName_ = "SetPrivacyMode";
774     info.windowType_ = 1;
775     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
776     EXPECT_NE(sceneSession, nullptr);
777     struct RSSurfaceNodeConfig config;
778     std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
779     sceneSession->surfaceNode_ = surfaceNode;
780     sceneSession->SetPrivacyMode(true);
781     ASSERT_EQ(true, sceneSession->property_->GetPrivacyMode());
782     ASSERT_EQ(true, sceneSession->property_->GetSystemPrivacyMode());
783 }
784 
785 /**
786  * @tc.name: IsFloatingWindowAppType01
787  * @tc.desc: IsFloatingWindowAppType true
788  * @tc.type: FUNC
789  */
790 HWTEST_F(SceneSessionTest, IsFloatingWindowAppType01, Function | SmallTest | Level2)
791 {
792     SessionInfo info;
793     info.abilityName_ = "IsFloatingWindowAppType01";
794     info.bundleName_ = "IsFloatingWindowAppType01";
795     info.windowType_ = 1;
796     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
797     EXPECT_NE(sceneSession, nullptr);
798     EXPECT_NE(sceneSession->property_, nullptr);
799     sceneSession->property_->SetFloatingWindowAppType(true);
800     ASSERT_EQ(true, sceneSession->IsFloatingWindowAppType());
801 }
802 
803 /**
804  * @tc.name: IsFloatingWindowAppType02
805  * @tc.desc: IsFloatingWindowAppType false
806  * @tc.type: FUNC
807  */
808 HWTEST_F(SceneSessionTest, IsFloatingWindowAppType02, Function | SmallTest | Level2)
809 {
810     SessionInfo info;
811     info.abilityName_ = "IsFloatingWindowAppType02";
812     info.bundleName_ = "IsFloatingWindowAppType02";
813     info.windowType_ = 1;
814     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
815     EXPECT_NE(sceneSession, nullptr);
816     EXPECT_NE(sceneSession->property_, nullptr);
817     ASSERT_EQ(false, sceneSession->IsFloatingWindowAppType());
818 }
819 
820 /**
821  * @tc.name: DumpSessionElementInfo01
822  * @tc.desc: DumpSessionElementInfo
823  * @tc.type: FUNC
824  */
825 HWTEST_F(SceneSessionTest, DumpSessionElementInfo, Function | SmallTest | Level2)
826 {
827     SessionInfo info;
828     info.abilityName_ = "Background01";
829     info.bundleName_ = "IsFloatingWindowAppType";
830     info.windowType_ = 1;
831     sptr<Rosen::ISession> session_;
832     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
833         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
834     EXPECT_NE(specificCallback_, nullptr);
835     sptr<SceneSession> sceneSession;
836     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
837     EXPECT_NE(sceneSession, nullptr);
838     sptr<SessionStageMocker> mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
839     ASSERT_NE(mockSessionStage, nullptr);
840     std::vector<std::string> params;
841     sceneSession->DumpSessionElementInfo(params);
842     int ret = 1;
843     sceneSession->sessionStage_ = mockSessionStage;
844     sceneSession->DumpSessionElementInfo(params);
845     ASSERT_EQ(ret, 1);
846 }
847 
848 /**
849  * @tc.name: NotifyIsCustomAnimationPlaying
850  * @tc.desc: NotifyIsCustomAnimationPlaying
851  * @tc.type: FUNC
852  */
853 HWTEST_F(SceneSessionTest, NotifyIsCustomAnimationPlaying, Function | SmallTest | Level2)
854 {
855     SessionInfo info;
856     info.abilityName_ = "Background01";
857     info.bundleName_ = "IsFloatingWindowAppType";
858     info.windowType_ = 1;
859     sptr<Rosen::ISession> session_;
860     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
861         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
862     EXPECT_NE(specificCallback_, nullptr);
863     sptr<SceneSession> sceneSession;
864     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
865     EXPECT_NE(sceneSession, nullptr);
866     sceneSession->NotifyIsCustomAnimationPlaying(false);
867 
__anon1a72d88a0202(bool status) 868     sceneSession->onIsCustomAnimationPlaying_ = [](bool status) {};
869     sceneSession->NotifyIsCustomAnimationPlaying(false);
870 }
871 
872 /**
873  * @tc.name: ModalUIExtension
874  * @tc.desc: ModalUIExtension
875  * @tc.type: FUNC
876  */
877 HWTEST_F(SceneSessionTest, ModalUIExtension, Function | SmallTest | Level2)
878 {
879     SessionInfo info;
880     info.abilityName_ = "ModalUIExtension";
881     info.bundleName_ = "ModalUIExtension";
882     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
883     ASSERT_NE(sceneSession, nullptr);
884 
885     EXPECT_FALSE(sceneSession->GetLastModalUIExtensionEventInfo());
886     ExtensionWindowEventInfo extensionInfo;
887     extensionInfo.persistentId = 12345;
888     extensionInfo.pid = 1234;
889     extensionInfo.windowRect = { 1, 2, 3, 4 };
890     sceneSession->AddNormalModalUIExtension(extensionInfo);
891 
892     auto getInfo = sceneSession->GetLastModalUIExtensionEventInfo();
893     EXPECT_TRUE(getInfo);
894     EXPECT_EQ(getInfo.value().persistentId, extensionInfo.persistentId);
895     EXPECT_EQ(getInfo.value().pid, extensionInfo.pid);
896     EXPECT_EQ(getInfo.value().windowRect, extensionInfo.windowRect);
897 
898     Rect windowRect = { 5, 6, 7, 8 };
899     extensionInfo.windowRect = windowRect;
900     sceneSession->UpdateNormalModalUIExtension(extensionInfo);
901     getInfo = sceneSession->GetLastModalUIExtensionEventInfo();
902     EXPECT_TRUE(getInfo);
903     EXPECT_EQ(getInfo.value().windowRect, windowRect);
904 
905     sceneSession->RemoveNormalModalUIExtension(extensionInfo.persistentId);
906     EXPECT_FALSE(sceneSession->GetLastModalUIExtensionEventInfo());
907 }
908 
909 /**
910  * @tc.name: NotifySessionRectChange
911  * @tc.desc: NotifySessionRectChange
912  * @tc.type: FUNC
913  */
914 HWTEST_F(SceneSessionTest, NotifySessionRectChange, Function | SmallTest | Level2)
915 {
916     SessionInfo info;
917     info.abilityName_ = "NotifySessionRectChange";
918     info.bundleName_ = "NotifySessionRectChangebundle";
919     info.windowType_ = 1;
920     sptr<Rosen::ISession> session_;
921     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
922         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
923     EXPECT_NE(specificCallback_, nullptr);
924     sptr<SceneSession> sceneSession;
925     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
926     EXPECT_NE(sceneSession, nullptr);
927     WSRect overlapRect = { 0, 0, 0, 0 };
928     sceneSession->NotifySessionRectChange(overlapRect, SizeChangeReason::ROTATION, -1);
929     sceneSession->NotifySessionRectChange(overlapRect, SizeChangeReason::ROTATION, 11);
930     sceneSession->sessionRectChangeFunc_ = [](const WSRect& rect,
__anon1a72d88a0302(const WSRect& rect, SizeChangeReason reason, DisplayId displayId, const RectAnimationConfig& rectAnimationConfig) 931         SizeChangeReason reason, DisplayId displayId, const RectAnimationConfig& rectAnimationConfig) {
932         return;
933     };
934     sceneSession->NotifySessionRectChange(overlapRect, SizeChangeReason::ROTATION, -1);
935     sceneSession->NotifySessionRectChange(overlapRect, SizeChangeReason::ROTATION, 11);
936 }
937 
938 /**
939  * @tc.name: GetKeyboardAvoidArea
940  * @tc.desc: GetKeyboardAvoidArea
941  * @tc.type: FUNC
942  */
943 HWTEST_F(SceneSessionTest, GetKeyboardAvoidArea, Function | SmallTest | Level2)
944 {
945     SessionInfo info;
946     info.abilityName_ = "Background01";
947     info.bundleName_ = "IsFloatingWindowAppType";
948     info.windowType_ = 1;
949     sptr<Rosen::ISession> session_;
950     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
951         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
952     EXPECT_NE(specificCallback_, nullptr);
__anon1a72d88a0402(WindowType type) 953     specificCallback_->onGetSceneSessionVectorByType_ = [](WindowType type) -> std::vector<sptr<SceneSession>> {
954         std::vector<sptr<SceneSession>> backgroundSession;
955         return backgroundSession;
956     };
957 
958     sptr<SceneSession> sceneSession;
959     sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback_);
960     EXPECT_NE(sceneSession, nullptr);
961     WSRect overlapRect = {0, 0, 0, 0};
962     AvoidArea avoidArea;
963     sceneSession->GetKeyboardAvoidArea(overlapRect, avoidArea);
964     ASSERT_EQ(true, overlapRect.IsEmpty());
965     ASSERT_EQ(true, sceneSession->keyboardAvoidAreaActive_);
966     sceneSession->keyboardAvoidAreaActive_ = false;
967     sceneSession->GetKeyboardAvoidArea(overlapRect, avoidArea);
968     ASSERT_EQ(false, sceneSession->keyboardAvoidAreaActive_);
969     ASSERT_EQ(true, overlapRect.IsEmpty());
970 }
971 
972 /**
973  * @tc.name: GetCutoutAvoidArea
974  * @tc.desc: GetCutoutAvoidArea
975  * @tc.type: FUNC
976  */
977 HWTEST_F(SceneSessionTest, GetCutoutAvoidArea, Function | SmallTest | Level2)
978 {
979     SessionInfo info;
980     info.abilityName_ = "Background01";
981     info.bundleName_ = "IsFloatingWindowAppType";
982     info.windowType_ = 1;
983     sptr<Rosen::ISession> session_;
984     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
985         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
986     EXPECT_NE(specificCallback_, nullptr);
987     sptr<SceneSession> sceneSession;
988     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
989     EXPECT_NE(sceneSession, nullptr);
990     WSRect overlapRect = { 0, 0, 0, 0 };
991     AvoidArea avoidArea;
992     int ret = 1;
993     sceneSession->GetCutoutAvoidArea(overlapRect, avoidArea);
994     ASSERT_EQ(ret, 1);
995 }
996 
997 /**
998  * @tc.name: SetSystemBarProperty
999  * @tc.desc: SetSystemBarProperty
1000  * @tc.type: FUNC
1001  */
1002 HWTEST_F(SceneSessionTest, SetSystemBarProperty, Function | SmallTest | Level2)
1003 {
1004     SessionInfo info;
1005     info.abilityName_ = "Background01";
1006     info.bundleName_ = "IsFloatingWindowAppType";
1007     info.windowType_ = 1;
1008     sptr<SceneSession::SpecificSessionCallback> specificCallback =
1009         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1010 
1011     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback);
1012     SystemBarProperty statusBarProperty;
1013     sceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1014     sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1015     ASSERT_EQ(sceneSession->SetSystemBarProperty(WindowType::WINDOW_TYPE_FLOAT_CAMERA, statusBarProperty),
1016               WSError::WS_OK);
1017 }
1018 
1019 /**
1020  * @tc.name: SetSystemBarProperty02
1021  * @tc.desc: SetSystemBarProperty02
1022  * @tc.type: FUNC
1023  */
1024 HWTEST_F(SceneSessionTest, SetSystemBarProperty02, Function | SmallTest | Level2)
1025 {
1026     SessionInfo info;
1027     info.abilityName_ = "Background01";
1028     info.bundleName_ = "IsFloatingWindowAppType";
1029     info.windowType_ = 1;
1030     sptr<SceneSession::SpecificSessionCallback> specificCallback =
1031         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1032     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback);
1033     SystemBarProperty statusBarProperty;
1034     ASSERT_EQ(sceneSession->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, statusBarProperty),
1035               WSError::WS_OK);
1036     auto propMap = sceneSession->property_->GetSystemBarProperty();
1037     ASSERT_EQ(statusBarProperty, propMap[WindowType::WINDOW_TYPE_STATUS_BAR]);
1038     sceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1039     sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1040     ASSERT_EQ(sceneSession->SetSystemBarProperty(WindowType::WINDOW_TYPE_FLOAT_CAMERA, statusBarProperty),
1041               WSError::WS_OK);
1042 }
1043 
1044 /**
1045  * @tc.name: OnShowWhenLocked
1046  * @tc.desc: OnShowWhenLocked
1047  * @tc.type: FUNC ok
1048  */
1049 HWTEST_F(SceneSessionTest, OnShowWhenLocked, Function | SmallTest | Level2)
1050 {
1051     SessionInfo info;
1052     info.abilityName_ = "Background01";
1053     info.bundleName_ = "IsFloatingWindowAppType";
1054     info.windowType_ = 1;
1055     sptr<Rosen::ISession> session_;
1056     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1057         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1058     EXPECT_NE(specificCallback_, nullptr);
1059     sptr<SceneSession> sceneSession;
1060     sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback_);
1061     EXPECT_NE(sceneSession, nullptr);
1062     int ret = 0;
1063     sceneSession->OnShowWhenLocked(false);
1064     ASSERT_EQ(ret, 0);
1065 }
1066 
1067 /**
1068  * @tc.name: IsShowWhenLocked
1069  * @tc.desc: IsShowWhenLocked
1070  * @tc.type: FUNC ok
1071  */
1072 HWTEST_F(SceneSessionTest, IsShowWhenLocked, Function | SmallTest | Level2)
1073 {
1074     SessionInfo info;
1075     info.abilityName_ = "Background01";
1076     info.bundleName_ = "IsFloatingWindowAppType";
1077     info.windowType_ = 1;
1078     sptr<Rosen::ISession> session_;
1079     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1080         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1081     EXPECT_NE(specificCallback_, nullptr);
1082     sptr<SceneSession> sceneSession;
1083     sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback_);
1084     EXPECT_NE(sceneSession, nullptr);
1085     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1086     EXPECT_NE(property, nullptr);
1087     property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1088     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1089     ASSERT_EQ(sceneSession->IsShowWhenLocked(), false);
1090     sceneSession->property_ = property;
1091     sceneSession->SetTemporarilyShowWhenLocked(true);
1092     ASSERT_EQ(sceneSession->IsShowWhenLocked(), true);
1093     property->SetWindowFlags(4);
1094     sceneSession->SetTemporarilyShowWhenLocked(false);
1095     ASSERT_EQ(sceneSession->IsShowWhenLocked(), true);
1096     sceneSession->SetTemporarilyShowWhenLocked(true);
1097     ASSERT_EQ(sceneSession->IsShowWhenLocked(), true);
1098 }
1099 
1100 /**
1101  * @tc.name: GetAvoidAreaByType
1102  * @tc.desc: GetAvoidAreaByType
1103  * @tc.type: FUNC ok
1104  */
1105 HWTEST_F(SceneSessionTest, GetAvoidAreaByType, Function | SmallTest | Level2)
1106 {
1107     SessionInfo info;
1108     info.abilityName_ = "Background01";
1109     info.bundleName_ = "IsFloatingWindowAppType";
1110     info.windowType_ = 1;
1111     sptr<Rosen::ISession> session_;
1112     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1113         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1114     EXPECT_NE(specificCallback_, nullptr);
1115         specificCallback_->onGetSceneSessionVectorByTypeAndDisplayId_ = [](WindowType type,
1116             uint64_t displayId)-> std::vector<sptr<SceneSession>>
__anon1a72d88a0502(WindowType type, uint64_t displayId)1117     {
1118         SessionInfo info_;
1119         info_.abilityName_ = "Background01";
1120         info_.bundleName_ = "IsFloatingWindowAppType";
1121         std::vector<sptr<SceneSession>> backgroundSession;
1122         sptr<SceneSession> session2= sptr<SceneSession>::MakeSptr(info_, nullptr);
1123         backgroundSession.push_back(session2);
1124         return backgroundSession;
1125     };
1126     sptr<SceneSession> sceneSession;
1127     sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback_);
1128     EXPECT_NE(sceneSession, nullptr);
1129     WSRect rect = { 0, 0, 320, 240}; // width: 320, height: 240
1130     sceneSession->SetSessionRect(rect);
1131     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1132     property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1133     sceneSession->property_ = property;
1134     AvoidArea avoidArea;
1135     sceneSession->GetAvoidAreaByType(AvoidAreaType::TYPE_CUTOUT);
1136     sceneSession->GetAvoidAreaByType(AvoidAreaType::TYPE_SYSTEM);
1137     sceneSession->GetAvoidAreaByType(AvoidAreaType::TYPE_KEYBOARD);
1138     sceneSession->GetAvoidAreaByType(AvoidAreaType::TYPE_SYSTEM_GESTURE);
1139     EXPECT_NE(sceneSession, nullptr);
1140 }
1141 
1142 /**
1143  * @tc.name: TransferPointerEvent
1144  * @tc.desc: TransferPointerEvent
1145  * @tc.type: FUNC
1146  */
1147 HWTEST_F(SceneSessionTest, TransferPointerEvent, Function | SmallTest | Level2)
1148 {
1149     SessionInfo info;
1150     info.abilityName_ = "Background01";
1151     info.bundleName_ = "IsFloatingWindowAppType";
1152     info.windowType_ = 1;
1153     sptr<Rosen::ISession> session_;
1154     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1155         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1156     EXPECT_NE(specificCallback_, nullptr);
1157     sptr<SceneSession> sceneSession;
1158     sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback_);
1159     EXPECT_NE(sceneSession, nullptr);
1160     std::shared_ptr<MMI::PointerEvent> pointerEvent = nullptr;
1161     ASSERT_EQ(sceneSession->TransferPointerEvent(pointerEvent), WSError::WS_OK);
1162     std::shared_ptr<MMI::PointerEvent> pointerEvent_ = MMI::PointerEvent::Create();
1163     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1164     property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1165     property->SetMaximizeMode(MaximizeMode::MODE_FULL_FILL);
1166     property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1167     property->SetPersistentId(11);
1168     sceneSession->property_ = property;
1169     ASSERT_EQ(sceneSession->TransferPointerEvent(pointerEvent_), WSError::WS_OK);
1170 }
1171 
1172 /**
1173  * @tc.name: TransferPointerEventDecorDialog
1174  * @tc.desc: TransferPointerEventDecorDialog
1175  * @tc.type: FUNC
1176  */
1177 HWTEST_F(SceneSessionTest, TransferPointerEventDecorDialog, Function | SmallTest | Level2)
1178 {
1179     SessionInfo info;
1180     info.abilityName_ = "TransferPointerEventDecorDialog";
1181     info.bundleName_ = "TransferPointerEventDecorDialogbundle";
1182     info.windowType_ = 1;
1183     sptr<Rosen::ISession> session_;
1184     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1185         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1186     sptr<SceneSession> sceneSession =
1187         sptr<SceneSession>::MakeSptr(info, specificCallback_);
1188     sceneSession->moveDragController_ = sptr<MoveDragController>::MakeSptr(12, WindowType::WINDOW_TYPE_FLOAT);
1189     sceneSession->SetSessionState(SessionState::STATE_ACTIVE);
1190     std::shared_ptr<MMI::PointerEvent> pointerEvent_ =  MMI::PointerEvent::Create();
1191     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1192     property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1193     property->SetMaximizeMode(MaximizeMode::MODE_FULL_FILL);
1194     property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
1195     property->SetDecorEnable(true);
1196     property->SetDragEnabled(true);
1197     property->SetPersistentId(12);
1198     sceneSession->property_ = property;
1199     EXPECT_NE(sceneSession, nullptr);
1200 }
1201 
1202 /**
1203  * @tc.name: ProcessWindowMoving
1204  * @tc.desc: ProcessWindowMoving
1205  * @tc.type: FUNC
1206  */
1207 HWTEST_F(SceneSessionTest, ProcessWindowMoving, Function | SmallTest | Level2)
1208 {
1209     SessionInfo info;
1210     info.abilityName_ = "ProcessWindowMoving";
1211     info.bundleName_ = "ProcessWindowMovingBundle";
1212     info.windowType_ = 1;
1213     auto specificCallback = sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1214     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback);
1215     EXPECT_NE(sceneSession, nullptr);
1216     std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
1217     sceneSession->ProcessWindowMoving(pointerEvent);
1218 }
1219 
1220 /**
1221  * @tc.name: CalculateAvoidAreaRect
1222  * @tc.desc: CalculateAvoidAreaRect
1223  * @tc.type: FUNC
1224  */
1225 HWTEST_F(SceneSessionTest, CalculateAvoidAreaRect, Function | SmallTest | Level2)
1226 {
1227     SessionInfo info;
1228     info.abilityName_ = "Background01";
1229     info.bundleName_ = "IsFloatingWindowAppType";
1230     info.windowType_ = 1;
1231     sptr<Rosen::ISession> session_;
1232     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1233         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1234     EXPECT_NE(specificCallback_, nullptr);
1235     sptr<SceneSession> sceneSession;
1236     sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback_);
1237     EXPECT_NE(sceneSession, nullptr);
1238     int ret = 0;
1239     WSRect overlapRect = { 0, 0, 0, 0 };
1240     WSRect avoidRect = { 0, 0, 0, 0 };
1241     AvoidArea avoidArea;
1242     sceneSession->CalculateAvoidAreaRect(overlapRect, avoidRect, avoidArea);
1243     WSRect overlapRect_ = { 1, 1, 1, 1 };
1244     WSRect avoidRect_ = { 1, 1, 1, 1 };
1245     sceneSession->CalculateAvoidAreaRect(overlapRect_, avoidRect_, avoidArea);
1246     ASSERT_EQ(ret, 0);
1247 }
1248 
1249 /**
1250  * @tc.name: OnNeedAvoid
1251  * @tc.desc: OnNeedAvoid
1252  * @tc.type: FUNC
1253  */
1254 HWTEST_F(SceneSessionTest, OnNeedAvoid, Function | SmallTest | Level2)
1255 {
1256     SessionInfo info;
1257     info.abilityName_ = "Background01";
1258     info.bundleName_ = "IsFloatingWindowAppType";
1259     info.windowType_ = 1;
1260     sptr<Rosen::ISession> session_;
1261     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1262         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1263     EXPECT_NE(specificCallback_, nullptr);
1264     sptr<SceneSession> sceneSession;
1265     sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback_);
1266     EXPECT_NE(sceneSession, nullptr);
1267     ASSERT_EQ(sceneSession->OnNeedAvoid(false), WSError::WS_OK);
1268 
__anon1a72d88a0602(bool state) 1269     sceneSession->onNeedAvoid_ = [](bool state) {};
1270     ASSERT_EQ(sceneSession->OnNeedAvoid(false), WSError::WS_OK);
1271 }
1272 
1273 /**
1274  * @tc.name: SetCollaboratorType
1275  * @tc.desc: SetCollaboratorType
1276  * @tc.type: FUNC
1277  */
1278 HWTEST_F(SceneSessionTest, SetCollaboratorType, Function | SmallTest | Level2)
1279 {
1280     SessionInfo info;
1281     info.abilityName_ = "Background01";
1282     info.bundleName_ = "IsFloatingWindowAppType";
1283     info.windowType_ = 1;
1284     sptr<Rosen::ISession> session_;
1285     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1286         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1287     EXPECT_NE(specificCallback_, nullptr);
1288     sptr<SceneSession> sceneSession;
1289     sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback_);
1290     EXPECT_NE(sceneSession, nullptr);
1291     sceneSession->SetCollaboratorType(2);
1292     ASSERT_EQ(sceneSession->GetCollaboratorType(), 2);
1293 }
1294 
1295 /**
1296  * @tc.name: GetAbilityInfo
1297  * @tc.desc: GetAbilityInfo
1298  * @tc.type: FUNC
1299  */
1300 HWTEST_F(SceneSessionTest, GetAbilityInfo, Function | SmallTest | Level2)
1301 {
1302     SessionInfo info;
1303     info.abilityName_ = "Background01";
1304     info.bundleName_ = "IsFloatingWindowAppType";
1305     info.windowType_ = 1;
1306     sptr<Rosen::ISession> session_;
1307     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1308         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1309     EXPECT_NE(specificCallback_, nullptr);
1310     sptr<SceneSession> sceneSession;
1311     sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback_);
1312     EXPECT_NE(sceneSession, nullptr);
1313     std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo;
1314     sceneSession->SetAbilitySessionInfo(abilityInfo);
1315     ASSERT_EQ(sceneSession->GetAbilityInfo(), abilityInfo);
1316 }
1317 
1318 /**
1319  * @tc.name: UpdateCameraWindowStatus
1320  * @tc.desc: UpdateCameraWindowStatus
1321  * @tc.type: FUNC
1322  */
1323 HWTEST_F(SceneSessionTest, UpdateCameraWindowStatus, Function | SmallTest | Level2)
1324 {
1325     SessionInfo info;
1326     info.abilityName_ = "Background01";
1327     info.bundleName_ = "UpdateCameraWindowStatus";
1328     info.windowType_ = 1;
1329     sptr<Rosen::ISession> session_;
1330     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1331         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1332     EXPECT_NE(specificCallback_, nullptr);
1333     sptr<SystemSession> sysSession;
1334     sysSession = sptr<SystemSession>::MakeSptr(info, specificCallback_);
1335     EXPECT_NE(sysSession, nullptr);
1336     int ret = 1;
__anon1a72d88a0702(uint32_t accessTokenId, bool isShowing) 1337     specificCallback_->onCameraFloatSessionChange_ = [](uint32_t accessTokenId, bool isShowing) {};
__anon1a72d88a0802(uint32_t accessTokenId, bool isShowing) 1338     specificCallback_->onCameraSessionChange_ = [](uint32_t accessTokenId, bool isShowing) {};
1339 
1340     sysSession->UpdateCameraWindowStatus(false);
1341     sysSession = sptr<SystemSession>::MakeSptr(info, specificCallback_);
1342     sysSession->UpdateCameraWindowStatus(false);
1343     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1344     property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1345     sysSession->property_ = property;
1346     sysSession->UpdateCameraWindowStatus(false);
1347     property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT_CAMERA);
1348     sysSession->property_ = property;
1349     sysSession->UpdateCameraWindowStatus(false);
1350     property->SetWindowType(WindowType::WINDOW_TYPE_PIP);
1351     property->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
1352     PiPTemplateInfo pipType;
1353     pipType.pipTemplateType = static_cast<uint32_t>(PiPTemplateType::VIDEO_CALL);
1354     sysSession->SetPiPTemplateInfo(pipType);
1355     sysSession->property_ = property;
1356     sysSession->UpdateCameraWindowStatus(false);
1357     ASSERT_EQ(ret, 1);
1358 }
1359 
1360 /**
1361  * @tc.name: GetRatioPreferenceKey
1362  * @tc.desc: GetRatioPreferenceKey
1363  * @tc.type: FUNC
1364  */
1365 HWTEST_F(SceneSessionTest, GetRatioPreferenceKey, Function | SmallTest | Level2)
1366 {
1367     SessionInfo info;
1368     info.abilityName_ = "ability";
1369     info.bundleName_ = "bundle";
1370     info.moduleName_ = "module";
1371     info.windowType_ = 1;
1372     sptr<Rosen::ISession> session_;
1373     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1374         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1375     EXPECT_NE(specificCallback_, nullptr);
1376     sptr<SceneSession> sceneSession;
1377     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1378     EXPECT_NE(sceneSession, nullptr);
1379     std::string key = info.bundleName_ + info.moduleName_ + info.abilityName_;
1380     sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback_);
1381     ASSERT_EQ(key, sceneSession->GetRatioPreferenceKey());
1382 
1383     std::string key2(30, 'a');
1384     std::string key3(80, 'a');
1385     sceneSession->sessionInfo_.bundleName_ = key2;
1386     sceneSession->sessionInfo_.moduleName_ = key2;
1387     sceneSession->sessionInfo_.abilityName_ = key2;
1388     ASSERT_EQ(key3, sceneSession->GetRatioPreferenceKey());
1389 }
1390 
1391 /**
1392  * @tc.name: NotifyPropertyWhenConnect
1393  * @tc.desc: NotifyPropertyWhenConnect
1394  * @tc.type: FUNC
1395  */
1396 HWTEST_F(SceneSessionTest, NotifyPropertyWhenConnect, Function | SmallTest | Level2)
1397 {
1398     SessionInfo info;
1399     info.abilityName_ = "ability";
1400     info.bundleName_ = "bundle";
1401     info.moduleName_ = "module";
1402     info.windowType_ = 1;
1403     sptr<Rosen::ISession> session_;
1404     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1405         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1406     EXPECT_NE(specificCallback_, nullptr);
1407     sptr<SceneSession> sceneSession;
1408     sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1409     EXPECT_NE(sceneSession, nullptr);
1410     int ret = 1;
1411     std::string key = info.bundleName_ + info.moduleName_ + info.abilityName_;
1412     sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback_);
1413     sceneSession->NotifyPropertyWhenConnect();
1414     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1415     property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1416     sceneSession->property_ = property;
1417     sceneSession->NotifyPropertyWhenConnect();
1418     ASSERT_EQ(ret, 1);
1419 }
1420 
1421 /**
1422  * @tc.name: DumpSessionInfo
1423  * @tc.desc: DumpSessionInfo
1424  * @tc.type: FUNC
1425  */
1426 HWTEST_F(SceneSessionTest, DumpSessionInfo, Function | SmallTest | Level2)
1427 {
1428     SessionInfo info;
1429     info.bundleName_ = "SceneSessionTest";
1430     info.abilityName_ = "DumpSessionInfo";
1431     info.windowType_ = 1;
1432     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1433     EXPECT_NE(sceneSession, nullptr);
1434     std::vector<std::string> infos;
1435     sceneSession->DumpSessionInfo(infos);
1436     ASSERT_FALSE(infos.empty());
1437 }
1438 
1439 /**
1440  * @tc.name: CalcRectForStatusBar
1441  * @tc.desc: CalcRectForStatusBar
1442  * @tc.type: FUNC
1443  */
1444 HWTEST_F(SceneSessionTest, CalcRectForStatusBar, Function | SmallTest | Level2)
1445 {
1446     SessionInfo info;
1447     info.abilityName_ = "CalcRectForStatusBar";
1448     info.bundleName_ = "CalcRectForStatusBar";
1449     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1450     uint32_t width = sceneSession->CalcRectForStatusBar().width_;
1451     uint32_t height = sceneSession->CalcRectForStatusBar().height_;
1452     EXPECT_EQ(width, 0);
1453     EXPECT_EQ(height, 0);
1454 }
1455 
1456 /**
1457  * @tc.name: InitializeMoveInputBar
1458  * @tc.desc: InitializeMoveInputBar
1459  * @tc.type: FUNC
1460  */
1461 HWTEST_F(SceneSessionTest, InitializeMoveInputBar, Function | SmallTest | Level2)
1462 {
1463     SessionInfo info;
1464     info.abilityName_ = "InitializeMoveInputBar";
1465     info.bundleName_ = "InitializeMoveInputBar";
1466     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1467     auto property = sceneSession->GetSessionProperty();
1468     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_STATUS_BAR);
1469     property->SetDisplayId(1);
1470 
1471     auto result = sceneSession->InitializeMoveInputBar();
1472     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_OPERATION);
1473 }
1474 
1475 /**
1476  * @tc.name: OnSessionEvent
1477  * @tc.desc: normal function
1478  * @tc.type: FUNC
1479  */
1480 HWTEST_F(SceneSessionTest, OnSessionEvent, Function | SmallTest | Level2)
1481 {
1482     SessionInfo info;
1483     info.abilityName_ = "OnSessionEvent";
1484     info.bundleName_ = "OnSessionEvent";
1485     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1486     EXPECT_NE(sceneSession, nullptr);
1487     sceneSession->moveDragController_ = sptr<MoveDragController>::MakeSptr(1, WindowType::WINDOW_TYPE_FLOAT);
1488     sceneSession->OnSessionEvent(SessionEvent::EVENT_START_MOVE);
1489     sceneSession->moveDragController_->isStartDrag_ = true;
1490     sceneSession->moveDragController_->hasPointDown_ = true;
1491     ASSERT_EQ(sceneSession->OnSessionEvent(SessionEvent::EVENT_START_MOVE), WSError::WS_OK);
1492     ASSERT_EQ(sceneSession->OnSessionEvent(SessionEvent::EVENT_END_MOVE), WSError::WS_OK);
1493 }
1494 
1495 /**
1496  * @tc.name: SyncSessionEvent
1497  * @tc.desc: normal function
1498  * @tc.type: FUNC
1499  */
1500 HWTEST_F(SceneSessionTest, SyncSessionEvent, Function | SmallTest | Level2)
1501 {
1502     SessionInfo info;
1503     info.abilityName_ = "SyncSessionEvent";
1504     info.bundleName_ = "SyncSessionEvent";
1505     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1506 
1507     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1508     property->SetWindowType(WindowType::WINDOW_TYPE_GLOBAL_SEARCH);
1509     property->isSystemCalling_ = true;
1510     sceneSession->SetSessionProperty(property);
1511     sceneSession->isActive_ = false;
1512 
1513     SessionEvent event = SessionEvent::EVENT_START_MOVE;
1514     auto result = sceneSession->SyncSessionEvent(event);
1515     ASSERT_EQ(result, WSError::WS_ERROR_NULLPTR);
1516 
1517     sceneSession->property_->isSystemCalling_ = false;
1518     result = sceneSession->SyncSessionEvent(event);
1519     ASSERT_EQ(result, WSError::WS_ERROR_NULLPTR);
1520 }
1521 
1522 /**
1523  * @tc.name: SetTopmost
1524  * @tc.desc: normal function
1525  * @tc.type: FUNC
1526  */
1527 HWTEST_F(SceneSessionTest, SetTopmost, Function | SmallTest | Level2)
1528 {
1529     SessionInfo info;
1530     info.abilityName_ = "SetTopmost";
1531     info.bundleName_ = "SetTopmost";
1532     sptr<Rosen::ISession> session_;
1533     sptr<SceneSession> sceneSession = sptr<MainSession>::MakeSptr(info, nullptr);
1534     EXPECT_NE(sceneSession, nullptr);
1535 
1536     auto result = sceneSession->SetTopmost(false);
1537     ASSERT_EQ(result, WSError::WS_OK);
1538     ASSERT_FALSE(sceneSession->IsTopmost());
1539 }
1540 
1541 /**
1542  * @tc.name: SetMainWindowTopmost
1543  * @tc.desc: normal function
1544  * @tc.type: FUNC
1545  */
1546 HWTEST_F(SceneSessionTest, SetMainWindowTopmost, Function | SmallTest | Level2)
1547 {
1548     SessionInfo info;
1549     info.abilityName_ = "SetMainWindowTopmost";
1550     info.bundleName_ = "SetMainWindowTopmost";
1551     sptr<SceneSession> sceneSession = sptr<MainSession>::MakeSptr(info, nullptr);
1552     auto result = sceneSession->SetMainWindowTopmost(false);
1553     ASSERT_EQ(result, WSError::WS_OK);
1554     ASSERT_FALSE(sceneSession->IsMainWindowTopmost());
1555 }
1556 
1557 /**
1558  * @tc.name: UpdateSessionRectPosYFromClient01
1559  * @tc.desc: normal function
1560  * @tc.type: FUNC
1561  */
1562 HWTEST_F(SceneSessionTest, UpdateSessionRectPosYFromClient01, Function | SmallTest | Level2)
1563 {
1564     DisplayId displayId = 0;
1565     SessionInfo info;
1566     info.abilityName_ = "UpdateSessionRectPosYFromClient";
1567     info.bundleName_ = "UpdateSessionRectPosYFromClient";
1568     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1569     ASSERT_NE(sceneSession, nullptr);
1570     sceneSession->sessionInfo_.screenId_ = 0;
1571     EXPECT_EQ(sceneSession->GetScreenId(), 0);
1572     PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::EXPANDED,
1573         { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 });
1574     WSRect rect = {0, 0, 0, 0};
1575     sceneSession->UpdateSessionRectPosYFromClient(SizeChangeReason::UNDEFINED, displayId, rect);
1576     EXPECT_EQ(rect.posY_, 0);
1577     PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::KEYBOARD,
1578         { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 });
1579     rect = {0, 100, 0, 0};
1580     sceneSession->UpdateSessionRectPosYFromClient(SizeChangeReason::UNDEFINED, displayId, rect);
1581     EXPECT_EQ(rect.posY_, 100);
1582 
1583     PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::HALF_FOLDED,
1584         { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1649, 2472, 40 });
1585     sceneSession->clientDisplayId_ = 0;
1586     rect = {0, 100, 100, 100};
1587     sceneSession->UpdateSessionRectPosYFromClient(SizeChangeReason::UNDEFINED, displayId, rect);
1588     EXPECT_EQ(rect.posY_, 100);
1589     sceneSession->clientDisplayId_ = 999;
1590     rect = {0, 100, 100, 100};
1591     auto rect2 = rect;
1592     sceneSession->UpdateSessionRectPosYFromClient(SizeChangeReason::UNDEFINED, displayId, rect);
1593     EXPECT_NE(rect.posY_, rect2.posY_);
1594 }
1595 
1596 /**
1597  * @tc.name: UpdateSessionRect
1598  * @tc.desc: normal function
1599  * @tc.type: FUNC
1600  */
1601 HWTEST_F(SceneSessionTest, UpdateSessionRect, Function | SmallTest | Level2)
1602 {
1603     SessionInfo info;
1604     info.abilityName_ = "UpdateSessionRect";
1605     info.bundleName_ = "UpdateSessionRect";
1606     sptr<Rosen::ISession> session_;
1607     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1608         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1609     EXPECT_NE(specificCallback_, nullptr);
1610     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1611     EXPECT_NE(sceneSession, nullptr);
1612     sceneSession->isActive_ = true;
1613 
1614     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1615     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1616     property->keyboardLayoutParams_.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM;
1617 
1618     sceneSession->SetSessionProperty(property);
1619     WSRect rect({1, 1, 1, 1});
1620     SizeChangeReason reason = SizeChangeReason::MOVE;
1621     WSError result = sceneSession->UpdateSessionRect(rect, reason);
1622     ASSERT_EQ(result, WSError::WS_OK);
1623 }
1624 
1625 /**
1626  * @tc.name: UpdateSessionRect1
1627  * @tc.desc: normal function
1628  * @tc.type: FUNC
1629  */
1630 HWTEST_F(SceneSessionTest, UpdateSessionRect1, Function | SmallTest | Level2)
1631 {
1632     SessionInfo info;
1633     info.abilityName_ = "UpdateSessionRect";
1634     info.bundleName_ = "UpdateSessionRect";
1635     sptr<Rosen::ISession> session_;
1636     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1637         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1638     EXPECT_NE(specificCallback_, nullptr);
1639     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1640     EXPECT_NE(sceneSession, nullptr);
1641     sceneSession->isActive_ = true;
1642 
1643     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1644     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1645     property->keyboardLayoutParams_.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM;
1646 
1647     sceneSession->SetSessionProperty(property);
1648     WSRect rect({1, 1, 1, 1});
1649     SizeChangeReason reason = SizeChangeReason::RESIZE;
1650     WSError result = sceneSession->UpdateSessionRect(rect, reason);
1651     ASSERT_EQ(result, WSError::WS_OK);
1652 }
1653 
1654 /**
1655  * @tc.name: UpdateSessionRect2
1656  * @tc.desc: normal function
1657  * @tc.type: FUNC
1658  */
1659 HWTEST_F(SceneSessionTest, UpdateSessionRect2, Function | SmallTest | Level2)
1660 {
1661     SessionInfo info;
1662     info.abilityName_ = "UpdateSessionRect";
1663     info.bundleName_ = "UpdateSessionRect";
1664     sptr<Rosen::ISession> session_;
1665     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1666         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1667     EXPECT_NE(specificCallback_, nullptr);
1668     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1669     EXPECT_NE(sceneSession, nullptr);
1670     sceneSession->isActive_ = true;
1671 
1672     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1673     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1674     property->keyboardLayoutParams_.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM;
1675 
1676     sceneSession->SetSessionProperty(property);
1677     WSRect rect({1, 1, 1, 1});
1678     SizeChangeReason reason = SizeChangeReason::UNDEFINED;
1679     WSError result = sceneSession->UpdateSessionRect(rect, reason);
1680     ASSERT_EQ(result, WSError::WS_OK);
1681 }
1682 
1683 /**
1684  * @tc.name: UpdateSessionRect3
1685  * @tc.desc: test for isGlobal is true
1686  * @tc.type: FUNC
1687  */
1688 HWTEST_F(SceneSessionTest, UpdateSessionRect3, Function | SmallTest | Level2)
1689 {
1690     SessionInfo info;
1691     info.abilityName_ = "UpdateSessionRect";
1692     info.bundleName_ = "UpdateSessionRect";
1693     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1694     sceneSession->isActive_ = true;
1695 
1696     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1697     property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1698     property->keyboardLayoutParams_.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM;
1699 
1700     sceneSession->SetSessionProperty(property);
1701     SizeChangeReason reason = SizeChangeReason::UNDEFINED;
1702     WSRect oldRect({1, 1, 1, 1});
1703     WSRect parentRect({10, 10, 1, 1});
1704 
1705     sptr<SceneSession> parentSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1706     sceneSession->SetParentSession(parentSession);
1707     EXPECT_NE(sceneSession->GetParentSession(), nullptr);
1708     parentSession->SetSessionRect(parentRect);
1709     sceneSession->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
1710 
1711     bool isGlobal = true;
1712     WSError result = sceneSession->UpdateSessionRect(oldRect, reason, isGlobal);
1713     ASSERT_EQ(result, WSError::WS_OK);
1714 
1715     WSRect newRect = sceneSession->GetSessionRect();
1716     ASSERT_EQ(newRect.posX_, oldRect.posX_ - parentRect.posX_);
1717     ASSERT_EQ(newRect.posY_, oldRect.posY_ - parentRect.posY_);
1718 }
1719 
1720 /**
1721  * @tc.name: GetStatusBarHeight
1722  * @tc.desc: normal function
1723  * @tc.type: FUNC
1724  */
1725 HWTEST_F(SceneSessionTest, GetStatusBarHeight, Function | SmallTest | Level1)
1726 {
1727     SessionInfo info;
1728     info.abilityName_ = "GetStatusBarHeight";
1729     info.bundleName_ = "GetStatusBarHeight";
1730     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1731     EXPECT_NE(sceneSession, nullptr);
1732     int32_t height = sceneSession->GetStatusBarHeight();
1733     ASSERT_EQ(height, 0);
1734     SystemBarProperty propertyHide;
1735     propertyHide.enable_ = false;
1736     ASSERT_EQ(WSError::WS_OK, sceneSession->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR,
1737         propertyHide));
1738     ASSERT_EQ(height, 0);
1739     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1740         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1741     EXPECT_NE(specificCallback_, nullptr);
1742     sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback_);
1743     height = sceneSession->GetStatusBarHeight();
1744     ASSERT_EQ(height, 0);
1745     WSRect rect({0, 0, 0, 1});
1746     sceneSession->winRect_ = rect;
1747     specificCallback_->onGetSceneSessionVectorByTypeAndDisplayId_ = [&](WindowType type,
1748         uint64_t displayId)->std::vector<sptr<SceneSession>>
__anon1a72d88a0902(WindowType type, uint64_t displayId)1749     {
1750         std::vector<sptr<SceneSession>> vec;
1751         vec.push_back(sceneSession);
1752         return vec;
1753     };
1754     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1755     EXPECT_NE(property, nullptr);
1756     sceneSession->property_ = property;
1757     height = sceneSession->GetStatusBarHeight();
1758     ASSERT_EQ(height, 1);
1759     ASSERT_EQ(WSError::WS_OK, sceneSession->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR,
1760         propertyHide));
1761     ASSERT_EQ(height, 1);
1762 }
1763 
1764 /**
1765  * @tc.name: GetDockHeight
1766  * @tc.desc: normal function
1767  * @tc.type: FUNC
1768  */
1769 HWTEST_F(SceneSessionTest, GetDockHeight, Function | SmallTest | Level1)
1770 {
1771     SessionInfo info;
1772     info.abilityName_ = "GetDockHeight";
1773     info.bundleName_ = "GetDockHeight";
1774     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1775     EXPECT_NE(sceneSession, nullptr);
1776     ASSERT_EQ(sceneSession->GetDockHeight(), 0);
1777     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1778         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1779     EXPECT_NE(specificCallback_, nullptr);
1780     sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback_);
1781     ASSERT_EQ(sceneSession->GetDockHeight(), 0);
1782     WSRect rect({0, 0, 0, 112});
1783     sceneSession->winRect_ = rect;
1784     specificCallback_->onGetSceneSessionVectorByTypeAndDisplayId_ = [&](WindowType type,
1785         uint64_t displayId)->std::vector<sptr<SceneSession>>
__anon1a72d88a0a02(WindowType type, uint64_t displayId)1786     {
1787         std::vector<sptr<SceneSession>> vec;
1788         vec.push_back(sceneSession);
1789         return vec;
1790     };
1791     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1792     EXPECT_NE(property, nullptr);
1793     sceneSession->property_ = property;
1794     ASSERT_EQ(sceneSession->GetDockHeight(), 0);
1795     sceneSession->isVisible_ = true;
1796     ASSERT_EQ(sceneSession->GetDockHeight(), 0);
1797     sceneSession->property_->windowName_ = "SCBSmartDock";
1798     ASSERT_EQ(sceneSession->GetDockHeight(), 112);
1799 }
1800 
1801 /**
1802  * @tc.name: GetAppForceLandscapeConfig
1803  * @tc.desc: GetAppForceLandscapeConfig
1804  * @tc.type: FUNC
1805  */
1806 HWTEST_F(SceneSessionTest, GetAppForceLandscapeConfig, Function | SmallTest | Level2)
1807 {
1808     SessionInfo info;
1809     info.abilityName_ = "GetAppForceLandscapeConfig";
1810     info.bundleName_ = "GetAppForceLandscapeConfig";
1811     sptr<SceneSession::SpecificSessionCallback> specificCallback =
1812         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1813     EXPECT_NE(specificCallback, nullptr);
1814     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1815     EXPECT_NE(sceneSession, nullptr);
1816     AppForceLandscapeConfig config = {};
1817     auto result = sceneSession->GetAppForceLandscapeConfig(config);
1818     ASSERT_EQ(result, WMError::WM_ERROR_NULLPTR);
1819 }
1820 
1821 /**
1822  * @tc.name: HandleCompatibleModeMoveDrag
1823  * @tc.desc: HandleCompatibleModeMoveDrag
1824  * @tc.type: FUNC
1825  */
1826 HWTEST_F(SceneSessionTest, HandleCompatibleModeMoveDrag, Function | SmallTest | Level2)
1827 {
1828     SessionInfo info;
1829     info.abilityName_ = "HandleCompatibleModeMoveDrag";
1830     info.bundleName_ = "HandleCompatibleModeMoveDrag";
1831     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1832     EXPECT_NE(sceneSession, nullptr);
1833     sceneSession->moveDragController_ = sptr<MoveDragController>::MakeSptr(12, WindowType::WINDOW_TYPE_FLOAT);
1834 
1835     WSRect rect = {1, 1, 1, 1};
1836     WSRect rect2 = {2, 2, 2, 1};
1837     sceneSession->winRect_ = rect2;
1838     sceneSession->moveDragController_->moveDragProperty_.originalRect_ = rect;
1839     sceneSession->HandleCompatibleModeMoveDrag(rect2, SizeChangeReason::HIDE);
1840     WSRect rect3 = {1, 1, 2, 1};
1841     ASSERT_NE(rect2, rect3);
1842     ASSERT_EQ(rect2.posX_, 2);
1843     ASSERT_EQ(rect2.posY_, 2);
1844 
1845     sceneSession->HandleCompatibleModeMoveDrag(rect2, SizeChangeReason::DRAG_MOVE);
1846     ASSERT_NE(rect2, rect3);
1847     ASSERT_EQ(rect2.posX_, 2);
1848     ASSERT_EQ(rect2.posY_, 2);
1849 }
1850 
1851 /**
1852  * @tc.name: HandleCompatibleModeDrag
1853  * @tc.desc: HandleCompatibleModeDrag
1854  * @tc.type: FUNC
1855  */
1856 HWTEST_F(SceneSessionTest, HandleCompatibleModeDrag, Function | SmallTest | Level2)
1857 {
1858     SessionInfo info;
1859     info.abilityName_ = "HandleCompatibleModeDrag";
1860     info.bundleName_ = "HandleCompatibleModeDrag";
1861     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1862     EXPECT_NE(sceneSession, nullptr);
1863     sceneSession->moveDragController_ = sptr<MoveDragController>::MakeSptr(12, WindowType::WINDOW_TYPE_FLOAT);
1864 
1865     WSRect rect = {1, 1, 1, 1};
1866     WSRect rect2 = {2, 1, 1, 1};
1867     sceneSession->winRect_ = rect2;
1868     sceneSession->HandleCompatibleModeDrag(rect, SizeChangeReason::DRAG_MOVE, false);
1869     ASSERT_EQ(sceneSession->winRect_, rect2);
1870 
1871     rect2 = {1, 2, 1, 1};
1872     sceneSession->winRect_ = rect2;
1873     sceneSession->HandleCompatibleModeDrag(rect, SizeChangeReason::DRAG_MOVE, false);
1874     ASSERT_EQ(sceneSession->winRect_, rect2);
1875 
1876     rect2 = {1, 1, 2, 1};
1877     sceneSession->winRect_ = rect2;
1878     sceneSession->HandleCompatibleModeDrag(rect, SizeChangeReason::DRAG_MOVE, false);
1879     ASSERT_EQ(sceneSession->winRect_, rect2);
1880 
1881     rect2 = {1, 1, 1, 2};
1882     sceneSession->winRect_ = rect2;
1883     sceneSession->HandleCompatibleModeDrag(rect, SizeChangeReason::DRAG_MOVE, false);
1884     ASSERT_EQ(sceneSession->winRect_, rect2);
1885 }
1886 
1887 /**
1888  * @tc.name: SetMoveDragCallback
1889  * @tc.desc: SetMoveDragCallback
1890  * @tc.type: FUNC
1891  */
1892 HWTEST_F(SceneSessionTest, SetMoveDragCallback, Function | SmallTest | Level2)
1893 {
1894     SessionInfo info;
1895     info.abilityName_ = "SetMoveDragCallback";
1896     info.bundleName_ = "SetMoveDragCallback";
1897     sptr<SceneSession::SpecificSessionCallback> specificCallback =
1898         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1899     EXPECT_NE(specificCallback, nullptr);
1900     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1901     EXPECT_NE(sceneSession, nullptr);
1902 
1903     sceneSession->moveDragController_ = nullptr;
1904     sceneSession->SetMoveDragCallback();
1905 }
1906 
1907 /**
1908  * @tc.name: GetScreenWidthAndHeightFromServer
1909  * @tc.desc: GetScreenWidthAndHeightFromServer
1910  * @tc.type: FUNC
1911  */
1912 HWTEST_F(SceneSessionTest, GetScreenWidthAndHeightFromServer, Function | SmallTest | Level2)
1913 {
1914     SessionInfo info;
1915     info.abilityName_ = "GetScreenWidthAndHeightFromServer";
1916     info.bundleName_ = "GetScreenWidthAndHeightFromServer";
1917     sptr<Rosen::ISession> session_;
1918     sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1919         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1920     EXPECT_NE(specificCallback_, nullptr);
1921     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1922     EXPECT_NE(sceneSession, nullptr);
1923     sceneSession->isActive_ = true;
1924 
1925     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1926     EXPECT_NE(property, nullptr);
1927     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1928     property->keyboardLayoutParams_.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM;
1929     sceneSession->SetSessionProperty(property);
1930 
1931     uint32_t screenWidth = 0;
1932     uint32_t screenHeight = 0;
1933     bool result = sceneSession->GetScreenWidthAndHeightFromServer(property, screenWidth, screenHeight);
1934     ASSERT_EQ(result, true);
1935 }
1936 
1937 /**
1938  * @tc.name: SetDefaultDisplayIdIfNeed
1939  * @tc.desc: SetDefaultDisplayIdIfNeed
1940  * @tc.type: FUNC
1941  */
1942 HWTEST_F(SceneSessionTest, SetDefaultDisplayIdIfNeed, Function | SmallTest | Level2)
1943 {
1944     SessionInfo info;
1945     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1946     EXPECT_NE(sceneSession, nullptr);
1947     sceneSession->SetDefaultDisplayIdIfNeed();
1948 
1949     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1950     EXPECT_NE(property, nullptr);
1951     property->SetDisplayId(-1);
1952     sceneSession->SetSessionProperty(property);
1953     sceneSession->SetDefaultDisplayIdIfNeed();
1954     EXPECT_EQ(property->GetDisplayId(), SCREEN_ID_INVALID);
1955 }
1956 
1957 /**
1958  * @tc.name: SetSessionGlobalRect/GetSessionGlobalRect
1959  * @tc.desc: SetSessionGlobalRect
1960  * @tc.type: FUNC
1961  */
1962 HWTEST_F(SceneSessionTest, SetSessionGlobalRect, Function | SmallTest | Level2)
1963 {
1964     SessionInfo info;
1965     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1966     EXPECT_NE(sceneSession, nullptr);
1967     WSRect test = { 100, 100, 100, 100 };
1968     sceneSession->SetSessionGlobalRect(test);
1969     sceneSession->SetScbCoreEnabled(true);
1970     EXPECT_EQ(test, sceneSession->GetSessionGlobalRect());
1971 }
1972 
1973 /**
1974  * @tc.name: SetSessionGlobalRect/GetSessionGlobalRect
1975  * @tc.desc: SetSessionGlobalRect
1976  * @tc.type: FUNC
1977  */
1978 HWTEST_F(SceneSessionTest, SetIsStatusBarVisibleInner01, Function | SmallTest | Level2)
1979 {
1980     SessionInfo info;
1981     info.abilityName_ = "SetIsStatusBarVisibleInner01";
1982     info.bundleName_ = "SetIsStatusBarVisibleInner01";
1983     info.windowType_ = 1;
1984     sptr<SceneSession::SpecificSessionCallback> specificCallback =
1985         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1986     EXPECT_NE(specificCallback, nullptr);
1987     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback);
1988     EXPECT_NE(sceneSession, nullptr);
1989     sceneSession->isStatusBarVisible_ = true;
1990     EXPECT_EQ(sceneSession->SetIsStatusBarVisibleInner(true), WSError::WS_OK);
1991     EXPECT_EQ(sceneSession->SetIsStatusBarVisibleInner(false), WSError::WS_ERROR_NULLPTR);
1992 
__anon1a72d88a0b02(bool& isLayoutFinished) 1993     sceneSession->isLastFrameLayoutFinishedFunc_ = [](bool& isLayoutFinished) {
1994         return WSError::WS_ERROR_NULLPTR;
1995     };
1996     EXPECT_EQ(sceneSession->SetIsStatusBarVisibleInner(true), WSError::WS_ERROR_NULLPTR);
1997 
__anon1a72d88a0c02(bool& isLayoutFinished) 1998     sceneSession->isLastFrameLayoutFinishedFunc_ = [](bool& isLayoutFinished) {
1999         isLayoutFinished = false;
2000         return WSError::WS_OK;
2001     };
2002     EXPECT_EQ(sceneSession->SetIsStatusBarVisibleInner(false), WSError::WS_OK);
2003 
__anon1a72d88a0d02(bool& isLayoutFinished) 2004     sceneSession->isLastFrameLayoutFinishedFunc_ = [](bool& isLayoutFinished) {
2005         isLayoutFinished = true;
2006         return WSError::WS_OK;
2007     };
2008     sceneSession->specificCallback_ = nullptr;
2009     EXPECT_EQ(sceneSession->SetIsStatusBarVisibleInner(false), WSError::WS_OK);
2010 }
2011 
2012 /**
2013  * @tc.name: SetMousePointerDownEventStatus
2014  * @tc.desc: SetMousePointerDownEventStatus
2015  * @tc.type: FUNC
2016  */
2017 HWTEST_F(SceneSessionTest, SetMousePointerDownEventStatus, Function | SmallTest | Level2)
2018 {
2019     SessionInfo info;
2020     info.abilityName_ = "SetMousePointerDownEventStatus";
2021     info.bundleName_ = "SetMousePointerDownEventStatus";
2022     info.windowType_ = 1;
2023     sptr<SceneSession::SpecificSessionCallback> specificCallback =
2024         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
2025     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback);
2026     EXPECT_NE(sceneSession, nullptr);
2027 
2028     sceneSession->SetMousePointerDownEventStatus(true);
2029     EXPECT_EQ(sceneSession->GetMousePointerDownEventStatus(), true);
2030 }
2031 
2032 /**
2033  * @tc.name: SetFingerPointerDownStatus
2034  * @tc.desc: SetFingerPointerDownStatus
2035  * @tc.type: FUNC
2036  */
2037 HWTEST_F(SceneSessionTest, SetFingerPointerDownStatus, Function | SmallTest | Level2)
2038 {
2039     SessionInfo info;
2040     info.abilityName_ = "SetFingerPointerDownStatus";
2041     info.bundleName_ = "SetFingerPointerDownStatus";
2042     info.windowType_ = 1;
2043     sptr<SceneSession::SpecificSessionCallback> specificCallback =
2044         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
2045     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback);
2046     EXPECT_NE(sceneSession, nullptr);
2047 
2048     sceneSession->SetFingerPointerDownStatus(0);
2049     sceneSession->SetFingerPointerDownStatus(1);
2050     auto fingerPointerDownStatusList = sceneSession->GetFingerPointerDownStatusList();
2051     EXPECT_EQ(fingerPointerDownStatusList.size(), 2);
2052     sceneSession->RemoveFingerPointerDownStatus(0);
2053     fingerPointerDownStatusList = sceneSession->GetFingerPointerDownStatusList();
2054     EXPECT_EQ(fingerPointerDownStatusList.size(), 1);
2055 
2056     sceneSession->RemoveFingerPointerDownStatus(1);
2057     fingerPointerDownStatusList = sceneSession->GetFingerPointerDownStatusList();
2058     EXPECT_EQ(fingerPointerDownStatusList.size(), 0);
2059 }
2060 
2061 /**
2062  * @tc.name: SetUIFirstSwitch
2063  * @tc.desc: SetUIFirstSwitch
2064  * @tc.type: FUNC
2065  */
2066 HWTEST_F(SceneSessionTest, SetUIFirstSwitch, Function | SmallTest | Level2)
2067 {
2068     SessionInfo info;
2069     info.abilityName_ = "SetUIFirstSwitch";
2070     info.bundleName_ = "SetUIFirstSwitch";
2071     info.windowType_ = 1;
2072     sptr<SceneSession::SpecificSessionCallback> specificCallback =
2073         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
2074     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback);
2075     EXPECT_NE(sceneSession, nullptr);
2076     sceneSession->SetUIFirstSwitch(RSUIFirstSwitch::FORCE_DISABLE_NONFOCUS);
2077 }
2078 
2079 /**
2080  * @tc.name: IsFollowParentMultiScreenPolicy
2081  * @tc.desc: IsFollowParentMultiScreenPolicy
2082  * @tc.type: FUNC
2083  */
2084 HWTEST_F(SceneSessionTest, IsFollowParentMultiScreenPolicy, Function | SmallTest | Level2)
2085 {
2086     SessionInfo info;
2087     sptr<SceneSession::SpecificSessionCallback> specificCallback =
2088         sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
2089     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback);
2090     EXPECT_EQ(sceneSession->IsFollowParentMultiScreenPolicy(), false);
2091 }
2092 } // namespace
2093 } // Rosen
2094 } // OHOS