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