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 * @tc.name: SetDefaultRequestedOrientation
388 * @tc.desc: SetDefaultRequestedOrientation
389 * @tc.type: FUNC
390 */
391 HWTEST_F(SceneSessionTest, SetDefaultRequestedOrientation, Function | SmallTest | Level2)
392 {
393 SessionInfo info;
394 info.abilityName_ = "Background01";
395 info.bundleName_ = "SetDefaultRequestedOrientation";
396 sptr<SceneSession> sceneSession;
397 sceneSession = new (std::nothrow) SceneSession(info, nullptr);
398 EXPECT_NE(sceneSession, nullptr);
399 Orientation orientation = Orientation::AUTO_ROTATION_UNSPECIFIED;
400 sceneSession->SetDefaultRequestedOrientation(orientation);
401 Orientation ret = sceneSession->GetRequestedOrientation();
402 ASSERT_EQ(orientation, ret);
403 }
404
405 /**
406 * @tc.name: IsKeepScreenOn
407 * @tc.desc: IsKeepScreenOn
408 * @tc.type: FUNC
409 */
410 HWTEST_F(SceneSessionTest, IsKeepScreenOn, Function | SmallTest | Level2)
411 {
412 SessionInfo info;
413 info.abilityName_ = "Background01";
414 info.bundleName_ = "IsKeepScreenOn";
415 sptr<Rosen::ISession> session_;
416 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
417 new (std::nothrow) SceneSession::SpecificSessionCallback();
418 EXPECT_NE(specificCallback_, nullptr);
419 sptr<SceneSession> scensession;
420 scensession = new (std::nothrow) SceneSession(info, nullptr);
421 EXPECT_NE(scensession, nullptr);
422 ASSERT_EQ(WSError::WS_OK, scensession->SetKeepScreenOn(false));
423 ASSERT_EQ(false, scensession->IsKeepScreenOn());
424 }
425
426 /**
427 * @tc.name: IsAppSession
428 * @tc.desc: IsAppSession true
429 * @tc.type: FUNC
430 */
431 HWTEST_F(SceneSessionTest, IsAppSession01, Function | SmallTest | Level2)
432 {
433 SessionInfo info;
434 info.abilityName_ = "Background01";
435 info.bundleName_ = "IsAppSession";
436 info.windowType_ = 1;
437 sptr<Rosen::ISession> session_;
438 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
439 new (std::nothrow) SceneSession::SpecificSessionCallback();
440 EXPECT_NE(specificCallback_, nullptr);
441 sptr<SceneSession> scensession;
442 scensession = new (std::nothrow) SceneSession(info, nullptr);
443 EXPECT_NE(scensession, nullptr);
444 ASSERT_EQ(true, scensession->IsAppSession());
445 }
446
447 /**
448 * @tc.name: IsAppSession
449 * @tc.desc: IsAppSession false
450 * @tc.type: FUNC
451 */
452 HWTEST_F(SceneSessionTest, IsAppSession02, Function | SmallTest | Level2)
453 {
454 SessionInfo info;
455 info.abilityName_ = "Background01";
456 info.bundleName_ = "IsAppSession";
457 info.windowType_ = 2106;
458 sptr<Rosen::ISession> session_;
459 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
460 new (std::nothrow) SceneSession::SpecificSessionCallback();
461 EXPECT_NE(specificCallback_, nullptr);
462 sptr<SceneSession> scensession;
463 scensession = new (std::nothrow) SceneSession(info, nullptr);
464 EXPECT_NE(scensession, nullptr);
465 ASSERT_EQ(false, scensession->IsAppSession());
466
467 SessionInfo parentInfo;
468 parentInfo.abilityName_ = "testSession1";
469 parentInfo.moduleName_ = "testSession2";
470 parentInfo.bundleName_ = "testSession3";
471 sptr<Session> parentSession = sptr<Session>::MakeSptr(parentInfo);
472 ASSERT_NE(parentSession, nullptr);
473
474 sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
475 EXPECT_NE(property, nullptr);
476 property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
477 parentSession->SetSessionProperty(property);
478 scensession->SetParentSession(parentSession);
479 ASSERT_EQ(false, scensession->IsAppSession());
480
481 property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
482 parentSession->SetSessionProperty(property);
483 scensession->SetParentSession(parentSession);
484 ASSERT_EQ(true, scensession->IsAppSession());
485 }
486
487 /**
488 * @tc.name: IsAppOrLowerSystemSession
489 * @tc.desc: IsAppOrLowerSystemSession true
490 * @tc.type: FUNC
491 */
492 HWTEST_F(SceneSessionTest, IsAppOrLowerSystemSession01, Function | SmallTest | Level2)
493 {
494 SessionInfo info;
495 info.abilityName_ = "Background01";
496 info.bundleName_ = "IsAppOrLowerSystemSession01";
497 info.windowType_ = 2126;
498
499 sptr<SceneSession> scensession;
500 scensession = new (std::nothrow) SceneSession(info, nullptr);
501 EXPECT_NE(scensession, nullptr);
502 ASSERT_EQ(true, scensession->IsAppOrLowerSystemSession());
503 }
504
505 /**
506 * @tc.name: IsAppOrLowerSystemSession
507 * @tc.desc: IsAppOrLowerSystemSession false
508 * @tc.type: FUNC
509 */
510 HWTEST_F(SceneSessionTest, IsAppOrLowerSystemSession02, Function | SmallTest | Level2)
511 {
512 SessionInfo info;
513 info.abilityName_ = "Background02";
514 info.bundleName_ = "IsAppOrLowerSystemSession02";
515 info.windowType_ = 2106;
516
517 sptr<SceneSession> scensession;
518 scensession = new (std::nothrow) SceneSession(info, nullptr);
519 EXPECT_NE(scensession, nullptr);
520 ASSERT_EQ(false, scensession->IsAppOrLowerSystemSession());
521
522 SessionInfo parentInfo;
523 parentInfo.abilityName_ = "testSession1";
524 parentInfo.moduleName_ = "testSession2";
525 parentInfo.bundleName_ = "testSession3";
526 sptr<Session> parentSession = sptr<Session>::MakeSptr(parentInfo);
527 ASSERT_NE(parentSession, nullptr);
528
529 sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
530 EXPECT_NE(property, nullptr);
531 property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
532 parentSession->SetSessionProperty(property);
533 scensession->SetParentSession(parentSession);
534 ASSERT_EQ(false, scensession->IsAppOrLowerSystemSession());
535
536 property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
537 parentSession->SetSessionProperty(property);
538 scensession->SetParentSession(parentSession);
539 ASSERT_EQ(true, scensession->IsAppOrLowerSystemSession());
540 }
541
542 /**
543 * @tc.name: IsSystemSessionAboveApp
544 * @tc.desc: IsSystemSessionAboveApp true
545 * @tc.type: FUNC
546 */
547 HWTEST_F(SceneSessionTest, IsSystemSessionAboveApp01, Function | SmallTest | Level2)
548 {
549 SessionInfo info1;
550 info1.abilityName_ = "HighZOrder01";
551 info1.bundleName_ = "IsSystemSessionAboveApp01";
552 info1.windowType_ = 2122;
553
554 sptr<SceneSession> scensession1;
555 scensession1 = new (std::nothrow) SceneSession(info1, nullptr);
556 EXPECT_NE(scensession1, nullptr);
557 ASSERT_EQ(true, scensession1->IsSystemSessionAboveApp());
558
559 SessionInfo info2;
560 info2.abilityName_ = "HighZOrder02";
561 info2.bundleName_ = "IsSystemSessionAboveApp02";
562 info2.windowType_ = 2104;
563
564 sptr<SceneSession> scensession2;
565 scensession2 = new (std::nothrow) SceneSession(info2, nullptr);
566 EXPECT_NE(scensession2, nullptr);
567 ASSERT_EQ(true, scensession2->IsSystemSessionAboveApp());
568
569 SessionInfo info3;
570 info3.abilityName_ = "HighZOrder03";
571 info3.bundleName_ = "SCBDropdownPanel13";
572 info3.windowType_ = 2109;
573
574 sptr<SceneSession> scensession3;
575 scensession3 = new (std::nothrow) SceneSession(info3, nullptr);
576 EXPECT_NE(scensession3, nullptr);
577 ASSERT_EQ(true, scensession3->IsSystemSessionAboveApp());
578
579 SessionInfo info4;
580 info4.abilityName_ = "HighZOrder04";
581 info4.bundleName_ = "IsSystemSessionAboveApp04";
582 info4.windowType_ = 2109;
583
584 sptr<SceneSession> scensession4;
585 scensession4 = new (std::nothrow) SceneSession(info4, nullptr);
586 EXPECT_NE(scensession4, nullptr);
587 ASSERT_EQ(false, scensession4->IsSystemSessionAboveApp());
588 }
589
590 /**
591 * @tc.name: IsSystemSessionAboveApp
592 * @tc.desc: IsSystemSessionAboveApp false
593 * @tc.type: FUNC
594 */
595 HWTEST_F(SceneSessionTest, IsSystemSessionAboveApp02, Function | SmallTest | Level2)
596 {
597 SessionInfo info;
598 info.abilityName_ = "HighZOrder05";
599 info.bundleName_ = "IsSystemSessionAboveApp05";
600 info.windowType_ = 1;
601
602 sptr<SceneSession> scensession;
603 scensession = new (std::nothrow) SceneSession(info, nullptr);
604 EXPECT_NE(scensession, nullptr);
605 ASSERT_EQ(false, scensession->IsSystemSessionAboveApp());
606 }
607
608 /**
609 * @tc.name: GetWindowName
610 * @tc.desc: GetWindowName
611 * @tc.type: FUNC
612 */
613 HWTEST_F(SceneSessionTest, GetWindowName, Function | SmallTest | Level2)
614 {
615 SessionInfo info;
616 info.abilityName_ = "Background01";
617 info.bundleName_ = "GetWindowName";
618 sptr<Rosen::ISession> session_;
619 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
620 new (std::nothrow) SceneSession::SpecificSessionCallback();
621 EXPECT_NE(specificCallback_, nullptr);
622 sptr<SceneSession> scensession;
623 scensession = new (std::nothrow) SceneSession(info, nullptr);
624 EXPECT_NE(scensession, nullptr);
625 ASSERT_NE("ww", scensession->GetWindowName());
626 }
627
628 /**
629 * @tc.name: IsDecorEnable
630 * @tc.desc: IsDecorEnable
631 * @tc.type: FUNC
632 */
633 HWTEST_F(SceneSessionTest, IsDecorEnable, Function | SmallTest | Level2)
634 {
635 SessionInfo info;
636 info.abilityName_ = "Background01";
637 info.bundleName_ = "IsDecorEnable";
638 info.windowType_ = 1;
639 sptr<Rosen::ISession> session_;
640 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
641 new (std::nothrow) SceneSession::SpecificSessionCallback();
642 EXPECT_NE(specificCallback_, nullptr);
643 sptr<SceneSession> scensession;
644 scensession = new (std::nothrow) SceneSession(info, nullptr);
645 EXPECT_NE(scensession, nullptr);
646 ASSERT_EQ(true, scensession->IsDecorEnable());
647 SessionInfo info_;
648 info_.abilityName_ = "Background01";
649 info_.bundleName_ = "IsDecorEnable";
650 info_.windowType_ = 1000;
651 sptr<SceneSession> scensession_;
652 scensession_ = new (std::nothrow) SceneSession(info_, nullptr);
653 EXPECT_NE(scensession_, nullptr);
654 ASSERT_EQ(false, scensession_->IsDecorEnable());
655 }
656
657 /**
658 * @tc.name: IsDecorEnable01
659 * @tc.desc: IsDecorEnable
660 * @tc.type: FUNC
661 */
662 HWTEST_F(SceneSessionTest, IsDecorEnable01, Function | SmallTest | Level2)
663 {
664 SessionInfo info;
665 info.abilityName_ = "Background01";
666 info.bundleName_ = "IsDecorEnable01";
667 info.windowType_ = 1;
668 sptr<Rosen::ISession> session_;
669 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
670 new (std::nothrow) SceneSession::SpecificSessionCallback();
671 EXPECT_NE(specificCallback_, nullptr);
672
673 sptr<SceneSession> scensession;
674 scensession = new (std::nothrow) SceneSession(info, nullptr);
675 EXPECT_NE(scensession, nullptr);
676 sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
677 EXPECT_NE(property, nullptr);
678 property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
679 property->SetDecorEnable(true);
680 property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
681 scensession->property_ = property;
682 ASSERT_EQ(true, scensession->IsDecorEnable());
683
684 sptr<SceneSession> scensession_;
685 scensession_ = new (std::nothrow) SceneSession(info, nullptr);
686 EXPECT_NE(scensession_, nullptr);
687 property = new (std::nothrow) WindowSessionProperty();
688 EXPECT_NE(property, nullptr);
689 property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
690 property->SetDecorEnable(false);
691 property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
692 ASSERT_EQ(true, scensession_->IsDecorEnable());
693
694 scensession_->SetSessionProperty(nullptr);
695 ASSERT_EQ(false, scensession_->IsDecorEnable());
696 }
697
698 /**
699 * @tc.name: UpdateNativeVisibility
700 * @tc.desc: UpdateNativeVisibility
701 * @tc.type: FUNC
702 */
703 HWTEST_F(SceneSessionTest, UpdateNativeVisibility, Function | SmallTest | Level2)
704 {
705 SessionInfo info;
706 info.abilityName_ = "Background01";
707 info.bundleName_ = "UpdateNativeVisibility";
708 info.windowType_ = 1;
709 sptr<Rosen::ISession> session_;
710 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
711 new (std::nothrow) SceneSession::SpecificSessionCallback();
712 EXPECT_NE(specificCallback_, nullptr);
713 sptr<SceneSession> scensession;
714 scensession = new (std::nothrow) SceneSession(info, nullptr);
715 EXPECT_NE(scensession, nullptr);
716 scensession->UpdateNativeVisibility(false);
717 ASSERT_EQ(false, scensession->IsVisible());
718 scensession->NotifyWindowVisibility();
719
720 sptr<SessionStageMocker> mockSessionStage = new (std::nothrow) SessionStageMocker();
721 ASSERT_NE(mockSessionStage, nullptr);
722 scensession->sessionStage_ = mockSessionStage;
723 scensession->NotifyWindowVisibility();
724 }
725
726 /**
727 * @tc.name: SetPrivacyMode
728 * @tc.desc: SetPrivacyMode
729 * @tc.type: FUNC
730 */
731 HWTEST_F(SceneSessionTest, SetPrivacyMode, Function | SmallTest | Level2)
732 {
733 SessionInfo info;
734 info.abilityName_ = "Background01";
735 info.bundleName_ = "SetPrivacyMode";
736 info.windowType_ = 1;
737 sptr<Rosen::ISession> session_;
738 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
739 new (std::nothrow) SceneSession::SpecificSessionCallback();
740 EXPECT_NE(specificCallback_, nullptr);
741 sptr<SceneSession> scensession;
742 scensession = new (std::nothrow) SceneSession(info, nullptr);
743 EXPECT_NE(scensession, nullptr);
744 int ret = 0;
745 scensession->SetPrivacyMode(false);
746 ASSERT_EQ(0, ret);
747 }
748
749 /**
750 * @tc.name: IsFloatingWindowAppType
751 * @tc.desc: IsFloatingWindowAppType
752 * @tc.type: FUNC
753 */
754 HWTEST_F(SceneSessionTest, IsFloatingWindowAppType, Function | SmallTest | Level2)
755 {
756 SessionInfo info;
757 info.abilityName_ = "Background01";
758 info.bundleName_ = "IsFloatingWindowAppType";
759 info.windowType_ = 1;
760 sptr<Rosen::ISession> session_;
761 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
762 new (std::nothrow) SceneSession::SpecificSessionCallback();
763 EXPECT_NE(specificCallback_, nullptr);
764 sptr<SceneSession> scensession;
765 scensession = new (std::nothrow) SceneSession(info, nullptr);
766 EXPECT_NE(scensession, nullptr);
767 ASSERT_EQ(false, scensession->IsFloatingWindowAppType());
768
769 scensession->SetSessionProperty(nullptr);
770 ASSERT_EQ(false, scensession->IsFloatingWindowAppType());
771 }
772
773 /**
774 * @tc.name: DumpSessionElementInfo01
775 * @tc.desc: DumpSessionElementInfo
776 * @tc.type: FUNC
777 */
778 HWTEST_F(SceneSessionTest, DumpSessionElementInfo, Function | SmallTest | Level2)
779 {
780 SessionInfo info;
781 info.abilityName_ = "Background01";
782 info.bundleName_ = "IsFloatingWindowAppType";
783 info.windowType_ = 1;
784 sptr<Rosen::ISession> session_;
785 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
786 new (std::nothrow) SceneSession::SpecificSessionCallback();
787 EXPECT_NE(specificCallback_, nullptr);
788 sptr<SceneSession> scensession;
789 scensession = new (std::nothrow) SceneSession(info, nullptr);
790 EXPECT_NE(scensession, nullptr);
791 sptr<SessionStageMocker> mockSessionStage = new (std::nothrow) SessionStageMocker();
792 ASSERT_NE(mockSessionStage, nullptr);
793 std::vector<std::string> params;
794 scensession->DumpSessionElementInfo(params);
795 int ret = 1;
796 scensession->sessionStage_ = mockSessionStage;
797 scensession->DumpSessionElementInfo(params);
798 ASSERT_EQ(ret, 1);
799 }
800
801 /**
802 * @tc.name: SaveAspectRatio
803 * @tc.desc: SaveAspectRatio
804 * @tc.type: FUNC
805 */
806 HWTEST_F(SceneSessionTest, SaveAspectRatio, Function | SmallTest | Level2)
807 {
808 SessionInfo info;
809 info.abilityName_ = "Background01";
810 info.bundleName_ = "IsFloatingWindowAppType";
811 info.windowType_ = 1;
812 sptr<SceneSession> scensession;
813 scensession = new (std::nothrow) SceneSession(info, nullptr);
814 EXPECT_NE(scensession, nullptr);
815 ASSERT_EQ(true, scensession->SaveAspectRatio(0.1));
816
817 scensession->sessionInfo_.bundleName_ = "";
818 scensession->sessionInfo_.moduleName_ = "";
819 scensession->sessionInfo_.abilityName_ = "";
820 ASSERT_EQ(false, scensession->SaveAspectRatio(0.1));
821 }
822
823 /**
824 * @tc.name: NotifyIsCustomAnimationPlaying
825 * @tc.desc: NotifyIsCustomAnimationPlaying
826 * @tc.type: FUNC
827 */
828 HWTEST_F(SceneSessionTest, NotifyIsCustomAnimationPlaying, Function | SmallTest | Level2)
829 {
830 SessionInfo info;
831 info.abilityName_ = "Background01";
832 info.bundleName_ = "IsFloatingWindowAppType";
833 info.windowType_ = 1;
834 sptr<Rosen::ISession> session_;
835 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
836 new (std::nothrow) SceneSession::SpecificSessionCallback();
837 EXPECT_NE(specificCallback_, nullptr);
838 sptr<SceneSession> sceneSession;
839 sceneSession = new (std::nothrow) SceneSession(info, nullptr);
840 EXPECT_NE(sceneSession, nullptr);
841 sceneSession->NotifyIsCustomAnimationPlaying(false);
842
__anonad808b0c0202(bool status) 843 sceneSession->onIsCustomAnimationPlaying_ = [](bool status) {};
844 sceneSession->NotifyIsCustomAnimationPlaying(false);
845 }
846
847 /**
848 * @tc.name: ModalUIExtension
849 * @tc.desc: ModalUIExtension
850 * @tc.type: FUNC
851 */
852 HWTEST_F(SceneSessionTest, ModalUIExtension, Function | SmallTest | Level2)
853 {
854 SessionInfo info;
855 info.abilityName_ = "ModalUIExtension";
856 info.bundleName_ = "ModalUIExtension";
857 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
858 ASSERT_NE(sceneSession, nullptr);
859
860 EXPECT_FALSE(sceneSession->GetLastModalUIExtensionEventInfo());
861 ExtensionWindowEventInfo extensionInfo;
862 extensionInfo.persistentId = 12345;
863 extensionInfo.pid = 1234;
864 extensionInfo.windowRect = { 1, 2, 3, 4 };
865 sceneSession->AddNormalModalUIExtension(extensionInfo);
866
867 auto getInfo = sceneSession->GetLastModalUIExtensionEventInfo();
868 EXPECT_TRUE(getInfo);
869 EXPECT_EQ(getInfo.value().persistentId, extensionInfo.persistentId);
870 EXPECT_EQ(getInfo.value().pid, extensionInfo.pid);
871 EXPECT_EQ(getInfo.value().windowRect, extensionInfo.windowRect);
872
873 Rect windowRect = { 5, 6, 7, 8 };
874 extensionInfo.windowRect = windowRect;
875 sceneSession->UpdateNormalModalUIExtension(extensionInfo);
876 getInfo = sceneSession->GetLastModalUIExtensionEventInfo();
877 EXPECT_TRUE(getInfo);
878 EXPECT_EQ(getInfo.value().windowRect, windowRect);
879
880 sceneSession->RemoveNormalModalUIExtension(extensionInfo.persistentId);
881 EXPECT_FALSE(sceneSession->GetLastModalUIExtensionEventInfo());
882 }
883
884 /**
885 * @tc.name: NotifySessionRectChange
886 * @tc.desc: NotifySessionRectChange
887 * @tc.type: FUNC
888 */
889 HWTEST_F(SceneSessionTest, NotifySessionRectChange, Function | SmallTest | Level2)
890 {
891 SessionInfo info;
892 info.abilityName_ = "Background01";
893 info.bundleName_ = "IsFloatingWindowAppType";
894 info.windowType_ = 1;
895 sptr<Rosen::ISession> session_;
896 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
897 new (std::nothrow) SceneSession::SpecificSessionCallback();
898 EXPECT_NE(specificCallback_, nullptr);
899 sptr<SceneSession> scensession;
900 scensession = new (std::nothrow) SceneSession(info, nullptr);
901 EXPECT_NE(scensession, nullptr);
902 WSRect overlapRect = { 0, 0, 0, 0 };
903 scensession->NotifySessionRectChange(overlapRect, SizeChangeReason::ROTATION);
904
__anonad808b0c0302(const WSRect& rect, const SizeChangeReason& reason) 905 scensession->sessionRectChangeFunc_ = [](const WSRect& rect, const SizeChangeReason& reason) {
906 return;
907 };
908 scensession->NotifySessionRectChange(overlapRect, SizeChangeReason::ROTATION);
909 }
910
911 /**
912 * @tc.name: FixRectByAspectRatio
913 * @tc.desc: FixRectByAspectRatio
914 * @tc.type: FUNC
915 */
916 HWTEST_F(SceneSessionTest, FixRectByAspectRatio, Function | SmallTest | Level2)
917 {
918 SessionInfo info;
919 info.abilityName_ = "Background01";
920 info.bundleName_ = "IsFloatingWindowAppType";
921 info.windowType_ = 1;
922 sptr<Rosen::ISession> session_;
923 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
924 new (std::nothrow) SceneSession::SpecificSessionCallback();
925 EXPECT_NE(specificCallback_, nullptr);
926 sptr<SceneSession> scensession;
927 scensession = new (std::nothrow) SceneSession(info, nullptr);
928 EXPECT_NE(scensession, nullptr);
929 WSRect originalRect_ = { 0, 0, 0, 0 };
930 ASSERT_EQ(false, scensession->FixRectByAspectRatio(originalRect_));
931 }
932
933 /**
934 * @tc.name: GetKeyboardAvoidArea
935 * @tc.desc: GetKeyboardAvoidArea
936 * @tc.type: FUNC
937 */
938 HWTEST_F(SceneSessionTest, GetKeyboardAvoidArea, Function | SmallTest | Level2)
939 {
940 SessionInfo info;
941 info.abilityName_ = "Background01";
942 info.bundleName_ = "IsFloatingWindowAppType";
943 info.windowType_ = 1;
944 sptr<Rosen::ISession> session_;
945 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
946 new (std::nothrow) SceneSession::SpecificSessionCallback();
947 EXPECT_NE(specificCallback_, nullptr);
__anonad808b0c0402(WindowType type) 948 specificCallback_->onGetSceneSessionVectorByType_ = [](WindowType type) -> std::vector<sptr<SceneSession>> {
949 std::vector<sptr<SceneSession>> backgroundSession;
950 return backgroundSession;
951 };
952
953 sptr<SceneSession> scensession;
954 scensession = new (std::nothrow) SceneSession(info, specificCallback_);
955 EXPECT_NE(scensession, nullptr);
956 WSRect overlapRect = {0, 0, 0, 0};
957 AvoidArea avoidArea;
958 int ret = 1;
959 scensession->GetKeyboardAvoidArea(overlapRect, avoidArea);
960 ASSERT_EQ(ret, 1);
961 }
962
963 /**
964 * @tc.name: GetCutoutAvoidArea
965 * @tc.desc: GetCutoutAvoidArea
966 * @tc.type: FUNC
967 */
968 HWTEST_F(SceneSessionTest, GetCutoutAvoidArea, Function | SmallTest | Level2)
969 {
970 SessionInfo info;
971 info.abilityName_ = "Background01";
972 info.bundleName_ = "IsFloatingWindowAppType";
973 info.windowType_ = 1;
974 sptr<Rosen::ISession> session_;
975 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
976 new (std::nothrow) SceneSession::SpecificSessionCallback();
977 EXPECT_NE(specificCallback_, nullptr);
978 sptr<SceneSession> scensession;
979 scensession = new (std::nothrow) SceneSession(info, nullptr);
980 EXPECT_NE(scensession, nullptr);
981 WSRect overlapRect = { 0, 0, 0, 0 };
982 AvoidArea avoidArea;
983 int ret = 1;
984 scensession->GetCutoutAvoidArea(overlapRect, avoidArea);
985 ASSERT_EQ(ret, 1);
986 }
987
988 /**
989 * @tc.name: SetSystemBarProperty
990 * @tc.desc: SetSystemBarProperty
991 * @tc.type: FUNC
992 */
993 HWTEST_F(SceneSessionTest, SetSystemBarProperty, Function | SmallTest | Level2)
994 {
995 SessionInfo info;
996 info.abilityName_ = "Background01";
997 info.bundleName_ = "IsFloatingWindowAppType";
998 info.windowType_ = 1;
999 sptr<Rosen::ISession> session_;
1000 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1001 new (std::nothrow) SceneSession::SpecificSessionCallback();
1002 EXPECT_NE(specificCallback_, nullptr);
1003
1004 sptr<SceneSession> scensession;
1005 scensession = new (std::nothrow) SceneSession(info, specificCallback_);
1006 EXPECT_NE(scensession, nullptr);
1007 scensession->property_ = nullptr;
1008 SystemBarProperty statusBarProperty;
1009 scensession->SetSystemBarProperty(WindowType::WINDOW_TYPE_FLOAT_CAMERA, statusBarProperty);
1010 ASSERT_EQ(scensession->SetSystemBarProperty(WindowType::WINDOW_TYPE_FLOAT_CAMERA, statusBarProperty),
1011 WSError::WS_ERROR_NULLPTR);
1012 sptr<WindowSessionProperty> property = new WindowSessionProperty();
1013 property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1014 property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1015 scensession->property_ = property;
1016 ASSERT_EQ(scensession->SetSystemBarProperty(WindowType::WINDOW_TYPE_FLOAT_CAMERA, statusBarProperty),
1017 WSError::WS_OK);
1018 }
1019
1020 /**
1021 * @tc.name: OnShowWhenLocked
1022 * @tc.desc: OnShowWhenLocked
1023 * @tc.type: FUNC ok
1024 */
1025 HWTEST_F(SceneSessionTest, OnShowWhenLocked, Function | SmallTest | Level2)
1026 {
1027 SessionInfo info;
1028 info.abilityName_ = "Background01";
1029 info.bundleName_ = "IsFloatingWindowAppType";
1030 info.windowType_ = 1;
1031 sptr<Rosen::ISession> session_;
1032 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1033 new (std::nothrow) SceneSession::SpecificSessionCallback();
1034 EXPECT_NE(specificCallback_, nullptr);
1035 sptr<SceneSession> scensession;
1036 scensession = new (std::nothrow) SceneSession(info, specificCallback_);
1037 EXPECT_NE(scensession, nullptr);
1038 int ret = 0;
1039 scensession->OnShowWhenLocked(false);
1040 ASSERT_EQ(ret, 0);
1041 }
1042
1043 /**
1044 * @tc.name: IsShowWhenLocked
1045 * @tc.desc: IsShowWhenLocked
1046 * @tc.type: FUNC ok
1047 */
1048 HWTEST_F(SceneSessionTest, IsShowWhenLocked, Function | SmallTest | Level2)
1049 {
1050 SessionInfo info;
1051 info.abilityName_ = "Background01";
1052 info.bundleName_ = "IsFloatingWindowAppType";
1053 info.windowType_ = 1;
1054 sptr<Rosen::ISession> session_;
1055 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1056 new (std::nothrow) SceneSession::SpecificSessionCallback();
1057 EXPECT_NE(specificCallback_, nullptr);
1058 sptr<SceneSession> scensession;
1059 scensession = new (std::nothrow) SceneSession(info, specificCallback_);
1060 EXPECT_NE(scensession, nullptr);
1061 sptr<WindowSessionProperty> property = new WindowSessionProperty();
1062 EXPECT_NE(property, nullptr);
1063 property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1064 property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1065 ASSERT_EQ(scensession->IsShowWhenLocked(), false);
1066 scensession->property_ = property;
1067 scensession->SetTemporarilyShowWhenLocked(true);
1068 ASSERT_EQ(scensession->IsShowWhenLocked(), true);
1069 property->SetWindowFlags(4);
1070 scensession->SetTemporarilyShowWhenLocked(false);
1071 ASSERT_EQ(scensession->IsShowWhenLocked(), true);
1072 scensession->SetTemporarilyShowWhenLocked(true);
1073 ASSERT_EQ(scensession->IsShowWhenLocked(), true);
1074 }
1075
1076 /**
1077 * @tc.name: GetAvoidAreaByType
1078 * @tc.desc: GetAvoidAreaByType
1079 * @tc.type: FUNC ok
1080 */
1081 HWTEST_F(SceneSessionTest, GetAvoidAreaByType, Function | SmallTest | Level2)
1082 {
1083 SessionInfo info;
1084 info.abilityName_ = "Background01";
1085 info.bundleName_ = "IsFloatingWindowAppType";
1086 info.windowType_ = 1;
1087 sptr<Rosen::ISession> session_;
1088 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1089 new (std::nothrow) SceneSession::SpecificSessionCallback();
1090 EXPECT_NE(specificCallback_, nullptr);
1091 specificCallback_->onGetSceneSessionVectorByTypeAndDisplayId_ = [](WindowType type,
1092 uint64_t displayId)-> std::vector<sptr<SceneSession>>
__anonad808b0c0502(WindowType type, uint64_t displayId)1093 {
1094 SessionInfo info_;
1095 info_.abilityName_ = "Background01";
1096 info_.bundleName_ = "IsFloatingWindowAppType";
1097 std::vector<sptr<SceneSession>> backgroundSession;
1098 sptr<SceneSession> session2=new (std::nothrow) SceneSession(info_, nullptr);
1099 backgroundSession.push_back(session2);
1100 return backgroundSession;
1101 };
1102 sptr<SceneSession> scensession;
1103 scensession = new (std::nothrow) SceneSession(info, specificCallback_);
1104 EXPECT_NE(scensession, nullptr);
1105 WSRect rect = { 0, 0, 320, 240}; // width: 320, height: 240
1106 scensession->SetSessionRect(rect);
1107 sptr<WindowSessionProperty> property = new WindowSessionProperty();
1108 property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1109 scensession->property_ = property;
1110 AvoidArea avoidArea;
1111 scensession->GetAvoidAreaByType(AvoidAreaType::TYPE_CUTOUT);
1112 scensession->GetAvoidAreaByType(AvoidAreaType::TYPE_SYSTEM);
1113 scensession->GetAvoidAreaByType(AvoidAreaType::TYPE_KEYBOARD);
1114 scensession->GetAvoidAreaByType(AvoidAreaType::TYPE_SYSTEM_GESTURE);
1115 EXPECT_NE(scensession, nullptr);
1116 }
1117
1118 /**
1119 * @tc.name: TransferPointerEvent
1120 * @tc.desc: TransferPointerEvent
1121 * @tc.type: FUNC
1122 */
1123 HWTEST_F(SceneSessionTest, TransferPointerEvent, Function | SmallTest | Level2)
1124 {
1125 SessionInfo info;
1126 info.abilityName_ = "Background01";
1127 info.bundleName_ = "IsFloatingWindowAppType";
1128 info.windowType_ = 1;
1129 sptr<Rosen::ISession> session_;
1130 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1131 new (std::nothrow) SceneSession::SpecificSessionCallback();
1132 EXPECT_NE(specificCallback_, nullptr);
1133 sptr<SceneSession> scensession;
1134 scensession = new (std::nothrow) SceneSession(info, specificCallback_);
1135 EXPECT_NE(scensession, nullptr);
1136 std::shared_ptr<MMI::PointerEvent> pointerEvent = nullptr;
1137 ASSERT_EQ(scensession->TransferPointerEvent(pointerEvent), WSError::WS_ERROR_NULLPTR);
1138 std::shared_ptr<MMI::PointerEvent> pointerEvent_ = MMI::PointerEvent::Create();
1139 sptr<WindowSessionProperty> property = new WindowSessionProperty();
1140 property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1141 property->SetMaximizeMode(MaximizeMode::MODE_FULL_FILL);
1142 property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1143 property->SetPersistentId(11);
1144 scensession->property_ = property;
1145 ASSERT_EQ(scensession->TransferPointerEvent(pointerEvent_), WSError::WS_ERROR_INVALID_SESSION);
1146 }
1147
1148 /**
1149 * @tc.name: TransferPointerEventDecorDialog
1150 * @tc.desc: TransferPointerEventDecorDialog
1151 * @tc.type: FUNC
1152 */
1153 HWTEST_F(SceneSessionTest, TransferPointerEventDecorDialog, Function | SmallTest | Level2)
1154 {
1155 SessionInfo info;
1156 info.abilityName_ = "TransferPointerEventDecorDialog";
1157 info.bundleName_ = "TransferPointerEventDecorDialogBundle";
1158 info.windowType_ = 2122;
1159 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1160 new (std::nothrow) SceneSession::SpecificSessionCallback();
1161 sptr<SceneSession> scensession =
1162 new (std::nothrow) SceneSession(info, specificCallback_);
1163 scensession->moveDragController_ = new MoveDragController(12);
1164 scensession->SetSessionState(SessionState::STATE_ACTIVE);
1165 std::shared_ptr<MMI::PointerEvent> pointerEvent_ = MMI::PointerEvent::Create();
1166 sptr<WindowSessionProperty> property = new WindowSessionProperty();
1167 property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1168 property->SetMaximizeMode(MaximizeMode::MODE_FULL_FILL);
1169 property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
1170 property->SetDecorEnable(true);
1171 property->SetDragEnabled(true);
1172 property->SetPersistentId(12);
1173 scensession->property_ = property;
1174 EXPECT_NE(scensession, nullptr);
1175 }
1176
1177 /**
1178 * @tc.name: CalculateAvoidAreaRect
1179 * @tc.desc: CalculateAvoidAreaRect
1180 * @tc.type: FUNC
1181 */
1182 HWTEST_F(SceneSessionTest, CalculateAvoidAreaRect, Function | SmallTest | Level2)
1183 {
1184 SessionInfo info;
1185 info.abilityName_ = "Background01";
1186 info.bundleName_ = "IsFloatingWindowAppType";
1187 info.windowType_ = 1;
1188 sptr<Rosen::ISession> session_;
1189 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1190 new (std::nothrow) SceneSession::SpecificSessionCallback();
1191 EXPECT_NE(specificCallback_, nullptr);
1192 sptr<SceneSession> scensession;
1193 scensession = new (std::nothrow) SceneSession(info, specificCallback_);
1194 EXPECT_NE(scensession, nullptr);
1195 int ret = 0;
1196 WSRect overlapRect = { 0, 0, 0, 0 };
1197 WSRect avoidRect = { 0, 0, 0, 0 };
1198 AvoidArea avoidArea;
1199 scensession->CalculateAvoidAreaRect(overlapRect, avoidRect, avoidArea);
1200 WSRect overlapRect_ = { 1, 1, 1, 1 };
1201 WSRect avoidRect_ = { 1, 1, 1, 1 };
1202 scensession->CalculateAvoidAreaRect(overlapRect_, avoidRect_, avoidArea);
1203 ASSERT_EQ(ret, 0);
1204 }
1205
1206 /**
1207 * @tc.name: OnNeedAvoid
1208 * @tc.desc: OnNeedAvoid
1209 * @tc.type: FUNC
1210 */
1211 HWTEST_F(SceneSessionTest, OnNeedAvoid, Function | SmallTest | Level2)
1212 {
1213 SessionInfo info;
1214 info.abilityName_ = "Background01";
1215 info.bundleName_ = "IsFloatingWindowAppType";
1216 info.windowType_ = 1;
1217 sptr<Rosen::ISession> session_;
1218 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1219 new (std::nothrow) SceneSession::SpecificSessionCallback();
1220 EXPECT_NE(specificCallback_, nullptr);
1221 sptr<SceneSession> scensession;
1222 scensession = new (std::nothrow) SceneSession(info, specificCallback_);
1223 EXPECT_NE(scensession, nullptr);
1224 ASSERT_EQ(scensession->OnNeedAvoid(false), WSError::WS_OK);
1225 }
1226
1227 /**
1228 * @tc.name: SetCollaboratorType
1229 * @tc.desc: SetCollaboratorType
1230 * @tc.type: FUNC
1231 */
1232 HWTEST_F(SceneSessionTest, SetCollaboratorType, Function | SmallTest | Level2)
1233 {
1234 SessionInfo info;
1235 info.abilityName_ = "Background01";
1236 info.bundleName_ = "IsFloatingWindowAppType";
1237 info.windowType_ = 1;
1238 sptr<Rosen::ISession> session_;
1239 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1240 new (std::nothrow) SceneSession::SpecificSessionCallback();
1241 EXPECT_NE(specificCallback_, nullptr);
1242 sptr<SceneSession> scensession;
1243 scensession = new (std::nothrow) SceneSession(info, specificCallback_);
1244 EXPECT_NE(scensession, nullptr);
1245 scensession->SetCollaboratorType(2);
1246 ASSERT_EQ(scensession->GetCollaboratorType(), 2);
1247 }
1248
1249 /**
1250 * @tc.name: GetAbilityInfo
1251 * @tc.desc: GetAbilityInfo
1252 * @tc.type: FUNC
1253 */
1254 HWTEST_F(SceneSessionTest, GetAbilityInfo, 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 new (std::nothrow) SceneSession::SpecificSessionCallback();
1263 EXPECT_NE(specificCallback_, nullptr);
1264 sptr<SceneSession> scensession;
1265 scensession = new (std::nothrow) SceneSession(info, specificCallback_);
1266 EXPECT_NE(scensession, nullptr);
1267 std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo;
1268 scensession->SetAbilitySessionInfo(abilityInfo);
1269 ASSERT_EQ(scensession->GetAbilityInfo(), abilityInfo);
1270 }
1271
1272 /**
1273 * @tc.name: UpdateCameraWindowStatus
1274 * @tc.desc: UpdateCameraWindowStatus
1275 * @tc.type: FUNC
1276 */
1277 HWTEST_F(SceneSessionTest, UpdateCameraWindowStatus, Function | SmallTest | Level2)
1278 {
1279 SessionInfo info;
1280 info.abilityName_ = "Background01";
1281 info.bundleName_ = "UpdateCameraWindowStatus";
1282 info.windowType_ = 1;
1283 sptr<Rosen::ISession> session_;
1284 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1285 new (std::nothrow) SceneSession::SpecificSessionCallback();
1286 EXPECT_NE(specificCallback_, nullptr);
1287 sptr<SystemSession> sysSession;
1288 sysSession = new (std::nothrow) SystemSession(info, specificCallback_);
1289 EXPECT_NE(sysSession, nullptr);
1290 int ret = 1;
__anonad808b0c0602(uint32_t accessTokenId, bool isShowing) 1291 specificCallback_->onCameraFloatSessionChange_ = [](uint32_t accessTokenId, bool isShowing) {};
__anonad808b0c0702(uint32_t accessTokenId, bool isShowing) 1292 specificCallback_->onCameraSessionChange_ = [](uint32_t accessTokenId, bool isShowing) {};
1293
1294 sysSession->UpdateCameraWindowStatus(false);
1295 sysSession = new (std::nothrow) SystemSession(info, specificCallback_);
1296 sysSession->UpdateCameraWindowStatus(false);
1297 sptr<WindowSessionProperty> property = new WindowSessionProperty();
1298 property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1299 sysSession->property_ = property;
1300 sysSession->UpdateCameraWindowStatus(false);
1301 property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT_CAMERA);
1302 sysSession->property_ = property;
1303 sysSession->UpdateCameraWindowStatus(false);
1304 property->SetWindowType(WindowType::WINDOW_TYPE_PIP);
1305 property->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
1306 PiPTemplateInfo pipType;
1307 pipType.pipTemplateType = static_cast<uint32_t>(PiPTemplateType::VIDEO_CALL);
1308 sysSession->SetPiPTemplateInfo(pipType);
1309 sysSession->property_ = property;
1310 sysSession->UpdateCameraWindowStatus(false);
1311 ASSERT_EQ(ret, 1);
1312 }
1313
1314 /**
1315 * @tc.name: GetRatioPreferenceKey
1316 * @tc.desc: GetRatioPreferenceKey
1317 * @tc.type: FUNC
1318 */
1319 HWTEST_F(SceneSessionTest, GetRatioPreferenceKey, Function | SmallTest | Level2)
1320 {
1321 SessionInfo info;
1322 info.abilityName_ = "ability";
1323 info.bundleName_ = "bundle";
1324 info.moduleName_ = "module";
1325 info.windowType_ = 1;
1326 sptr<Rosen::ISession> session_;
1327 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1328 new (std::nothrow) SceneSession::SpecificSessionCallback();
1329 EXPECT_NE(specificCallback_, nullptr);
1330 sptr<SceneSession> scensession;
1331 scensession = new (std::nothrow) SceneSession(info, nullptr);
1332 EXPECT_NE(scensession, nullptr);
1333 std::string key = info.bundleName_ + info.moduleName_ + info.abilityName_;
1334 scensession = new (std::nothrow) SceneSession(info, specificCallback_);
1335 ASSERT_EQ(key, scensession->GetRatioPreferenceKey());
1336
1337 std::string key2(30, 'a');
1338 std::string key3(80, 'a');
1339 scensession->sessionInfo_.bundleName_ = key2;
1340 scensession->sessionInfo_.moduleName_ = key2;
1341 scensession->sessionInfo_.abilityName_ = key2;
1342 ASSERT_EQ(key3, scensession->GetRatioPreferenceKey());
1343 }
1344
1345 /**
1346 * @tc.name: NotifyPropertyWhenConnect
1347 * @tc.desc: NotifyPropertyWhenConnect
1348 * @tc.type: FUNC
1349 */
1350 HWTEST_F(SceneSessionTest, NotifyPropertyWhenConnect, Function | SmallTest | Level2)
1351 {
1352 SessionInfo info;
1353 info.abilityName_ = "ability";
1354 info.bundleName_ = "bundle";
1355 info.moduleName_ = "module";
1356 info.windowType_ = 1;
1357 sptr<Rosen::ISession> session_;
1358 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1359 new (std::nothrow) SceneSession::SpecificSessionCallback();
1360 EXPECT_NE(specificCallback_, nullptr);
1361 sptr<SceneSession> scensession;
1362 scensession = new (std::nothrow) SceneSession(info, nullptr);
1363 EXPECT_NE(scensession, nullptr);
1364 int ret = 1;
1365 std::string key = info.bundleName_ + info.moduleName_ + info.abilityName_;
1366 scensession = new (std::nothrow) SceneSession(info, specificCallback_);
1367 scensession->NotifyPropertyWhenConnect();
1368 sptr<WindowSessionProperty> property = new WindowSessionProperty();
1369 property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1370 scensession->property_ = property;
1371 scensession->NotifyPropertyWhenConnect();
1372 ASSERT_EQ(ret, 1);
1373 }
1374
1375 /**
1376 * @tc.name: DumpSessionInfo
1377 * @tc.desc: DumpSessionInfo
1378 * @tc.type: FUNC
1379 */
1380 HWTEST_F(SceneSessionTest, DumpSessionInfo, Function | SmallTest | Level2)
1381 {
1382 SessionInfo info;
1383 info.bundleName_ = "SceneSessionTest";
1384 info.abilityName_ = "DumpSessionInfo";
1385 info.windowType_ = 1;
1386 sptr<SceneSession> scensession = new (std::nothrow) SceneSession(info, nullptr);
1387 EXPECT_NE(scensession, nullptr);
1388 std::vector<std::string> infos;
1389 scensession->DumpSessionInfo(infos);
1390 ASSERT_FALSE(infos.empty());
1391 }
1392
1393 /**
1394 * @tc.name: CalcRectForStatusBar
1395 * @tc.desc: CalcRectForStatusBar
1396 * @tc.type: FUNC
1397 */
1398 HWTEST_F(SceneSessionTest, CalcRectForStatusBar, Function | SmallTest | Level2)
1399 {
1400 SessionInfo info;
1401 info.abilityName_ = "CalcRectForStatusBar";
1402 info.bundleName_ = "CalcRectForStatusBar";
1403 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1404 uint32_t width = sceneSession->CalcRectForStatusBar().width_;
1405 uint32_t height = sceneSession->CalcRectForStatusBar().height_;
1406 EXPECT_EQ(width, 0);
1407 EXPECT_EQ(height, 0);
1408 }
1409
1410 /**
1411 * @tc.name: InitializeMoveInputBar
1412 * @tc.desc: InitializeMoveInputBar
1413 * @tc.type: FUNC
1414 */
1415 HWTEST_F(SceneSessionTest, InitializeMoveInputBar, Function | SmallTest | Level2)
1416 {
1417 SessionInfo info;
1418 info.abilityName_ = "InitializeMoveInputBar";
1419 info.bundleName_ = "InitializeMoveInputBar";
1420 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1421 auto property = sceneSession->GetSessionProperty();
1422 property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_STATUS_BAR);
1423 property->SetDisplayId(1);
1424
1425 auto result = sceneSession->InitializeMoveInputBar();
1426 EXPECT_EQ(result, WSError::WS_ERROR_INVALID_OPERATION);
1427 }
1428
1429 /**
1430 * @tc.name: OnSessionEvent
1431 * @tc.desc: normal function
1432 * @tc.type: FUNC
1433 */
1434 HWTEST_F(SceneSessionTest, OnSessionEvent, Function | SmallTest | Level2)
1435 {
1436 SessionInfo info;
1437 info.abilityName_ = "OnSessionEvent";
1438 info.bundleName_ = "OnSessionEvent";
1439 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1440 EXPECT_NE(sceneSession, nullptr);
1441 sceneSession->moveDragController_ = new MoveDragController(1);
1442 sceneSession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback();
1443 sceneSession->OnSessionEvent(SessionEvent::EVENT_START_MOVE);
1444 sceneSession->moveDragController_->isStartDrag_ = true;
1445 sceneSession->moveDragController_->hasPointDown_ = true;
1446 sceneSession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback();
1447 EXPECT_NE(sceneSession->sessionChangeCallback_, nullptr);
1448 ASSERT_EQ(sceneSession->OnSessionEvent(SessionEvent::EVENT_START_MOVE), WSError::WS_OK);
1449 ASSERT_EQ(sceneSession->OnSessionEvent(SessionEvent::EVENT_END_MOVE), WSError::WS_OK);
1450 }
1451
1452 /**
1453 * @tc.name: SyncSessionEvent
1454 * @tc.desc: normal function
1455 * @tc.type: FUNC
1456 */
1457 HWTEST_F(SceneSessionTest, SyncSessionEvent, Function | SmallTest | Level2)
1458 {
1459 SessionInfo info;
1460 info.abilityName_ = "SyncSessionEvent";
1461 info.bundleName_ = "SyncSessionEvent";
1462 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1463
1464 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1465 property->SetWindowType(WindowType::WINDOW_TYPE_GLOBAL_SEARCH);
1466 property->isSystemCalling_ = true;
1467 sceneSession->SetSessionProperty(property);
1468 sceneSession->isActive_ = false;
1469 sceneSession->moveDragController_ = sptr<MoveDragController>::MakeSptr(sceneSession->GetPersistentId());
1470
1471 SessionEvent event = SessionEvent::EVENT_START_MOVE;
1472 auto result = sceneSession->SyncSessionEvent(event);
1473 ASSERT_EQ(result, WSError::WS_OK);
1474
1475 property->isSystemCalling_ = false;
1476 result = sceneSession->SyncSessionEvent(event);
1477 ASSERT_EQ(result, WSError::WS_OK);
1478 }
1479
1480 /**
1481 * @tc.name: SetTopmost
1482 * @tc.desc: normal function
1483 * @tc.type: FUNC
1484 */
1485 HWTEST_F(SceneSessionTest, SetTopmost, Function | SmallTest | Level2)
1486 {
1487 SessionInfo info;
1488 info.abilityName_ = "SetTopmost";
1489 info.bundleName_ = "SetTopmost";
1490 sptr<Rosen::ISession> session_;
1491 sptr<SceneSession> scenesession = new (std::nothrow) MainSession(info, nullptr);
1492 EXPECT_NE(scenesession, nullptr);
1493
1494 sptr<WindowSessionProperty> property = new(std::nothrow) WindowSessionProperty();
1495 scenesession->SetSessionProperty(property);
1496 auto result = scenesession->SetTopmost(false);
1497 ASSERT_EQ(result, WSError::WS_OK);
1498 ASSERT_FALSE(scenesession->IsTopmost());
1499 }
1500
1501 /**
1502 * @tc.name: SetMainWindowTopmost
1503 * @tc.desc: normal function
1504 * @tc.type: FUNC
1505 */
1506 HWTEST_F(SceneSessionTest, SetMainWindowTopmost, Function | SmallTest | Level2)
1507 {
1508 SessionInfo info;
1509 info.abilityName_ = "SetMainWindowTopmost";
1510 info.bundleName_ = "SetMainWindowTopmost";
1511 sptr<SceneSession> sceneSession = sptr<MainSession>::MakeSptr(info, nullptr);
1512 auto result = sceneSession->SetMainWindowTopmost(false);
1513 ASSERT_EQ(result, WSError::WS_OK);
1514 ASSERT_FALSE(sceneSession->IsMainWindowTopmost());
1515 }
1516
1517 /**
1518 * @tc.name: SetAspectRatio2
1519 * @tc.desc: normal function
1520 * @tc.type: FUNC
1521 */
1522 HWTEST_F(SceneSessionTest, SetAspectRatio2, Function | SmallTest | Level2)
1523 {
1524 SessionInfo info;
1525 info.abilityName_ = "SetAspectRatio2";
1526 info.bundleName_ = "SetAspectRatio2";
1527 sptr<Rosen::ISession> session_;
1528 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1529 new (std::nothrow) SceneSession::SpecificSessionCallback();
1530 EXPECT_NE(specificCallback_, nullptr);
1531 sptr<SceneSession> scensession = new (std::nothrow) SceneSession(info, nullptr);
1532 EXPECT_NE(scensession, nullptr);
1533 scensession->isActive_ = true;
1534
1535 float ratio = 0.0001;
1536 auto result = scensession->SetAspectRatio(ratio);
1537 ASSERT_EQ(result, WSError::WS_OK);
1538
1539 sptr<WindowSessionProperty> property = new(std::nothrow) WindowSessionProperty();
1540 property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1541 scensession->SetSessionProperty(property);
1542 result = scensession->SetAspectRatio(ratio);
1543 ASSERT_EQ(result, WSError::WS_OK);
1544 }
1545
1546 /**
1547 * @tc.name: SetAspectRatio3
1548 * @tc.desc: normal function
1549 * @tc.type: FUNC
1550 */
1551 HWTEST_F(SceneSessionTest, SetAspectRatio3, Function | SmallTest | Level2)
1552 {
1553 SessionInfo info;
1554 info.abilityName_ = "SetAspectRatio3";
1555 info.bundleName_ = "SetAspectRatio3";
1556 sptr<Rosen::ISession> session_;
1557 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1558 new (std::nothrow) SceneSession::SpecificSessionCallback();
1559 EXPECT_NE(specificCallback_, nullptr);
1560 sptr<SceneSession> scensession = new (std::nothrow) SceneSession(info, nullptr);
1561 EXPECT_NE(scensession, nullptr);
1562 scensession->isActive_ = true;
1563
1564 float ratio = 0.1;
1565 sptr<WindowSessionProperty> property = new(std::nothrow) WindowSessionProperty();
1566 property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1567 scensession->SetSessionProperty(property);
1568 auto result = scensession->SetAspectRatio(ratio);
1569 ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PARAM);
1570 }
1571
1572 /**
1573 * @tc.name: SetAspectRatio4
1574 * @tc.desc: normal function
1575 * @tc.type: FUNC
1576 */
1577 HWTEST_F(SceneSessionTest, SetAspectRatio4, Function | SmallTest | Level2)
1578 {
1579 SessionInfo info;
1580 info.abilityName_ = "SetAspectRatio4";
1581 info.bundleName_ = "SetAspectRatio4";
1582 sptr<Rosen::ISession> session_;
1583 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1584 new (std::nothrow) SceneSession::SpecificSessionCallback();
1585 EXPECT_NE(specificCallback_, nullptr);
1586 sptr<SceneSession> scensession = new (std::nothrow) SceneSession(info, nullptr);
1587 EXPECT_NE(scensession, nullptr);
1588 scensession->isActive_ = true;
1589
1590 float ratio = 0.1;
1591 sptr<WindowSessionProperty> property = new(std::nothrow) WindowSessionProperty();
1592 property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1593 WindowLimits limits;
1594 limits.maxHeight_ = 0;
1595 limits.minWidth_ = 0;
1596 property->SetWindowLimits(limits);
1597 scensession->SetSessionProperty(property);
1598 auto result = scensession->SetAspectRatio(ratio);
1599 ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PARAM);
1600 }
1601
1602 /**
1603 * @tc.name: SetAspectRatio5
1604 * @tc.desc: normal function
1605 * @tc.type: FUNC
1606 */
1607 HWTEST_F(SceneSessionTest, SetAspectRatio5, Function | SmallTest | Level2)
1608 {
1609 SessionInfo info;
1610 info.abilityName_ = "SetAspectRatio5";
1611 info.bundleName_ = "SetAspectRatio5";
1612 sptr<Rosen::ISession> session_;
1613 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1614 new (std::nothrow) SceneSession::SpecificSessionCallback();
1615 EXPECT_NE(specificCallback_, nullptr);
1616 sptr<SceneSession> scensession = new (std::nothrow) SceneSession(info, nullptr);
1617 EXPECT_NE(scensession, nullptr);
1618 scensession->isActive_ = true;
1619
1620 float ratio = 0.1;
1621 sptr<WindowSessionProperty> property = new(std::nothrow) WindowSessionProperty();
1622 property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1623 WindowLimits limits;
1624 limits.maxHeight_ = 10;
1625 limits.minWidth_ = 0;
1626 property->SetWindowLimits(limits);
1627 scensession->SetSessionProperty(property);
1628 scensession->SetAspectRatio(ratio);
1629 EXPECT_NE(scensession, nullptr);
1630 }
1631
1632 /**
1633 * @tc.name: SetAspectRatio6
1634 * @tc.desc: normal function
1635 * @tc.type: FUNC
1636 */
1637 HWTEST_F(SceneSessionTest, SetAspectRatio6, Function | SmallTest | Level2)
1638 {
1639 SessionInfo info;
1640 info.abilityName_ = "SetAspectRatio6";
1641 info.bundleName_ = "SetAspectRatio6";
1642 sptr<Rosen::ISession> session_;
1643 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1644 new (std::nothrow) SceneSession::SpecificSessionCallback();
1645 EXPECT_NE(specificCallback_, nullptr);
1646 sptr<SceneSession> scensession = new (std::nothrow) SceneSession(info, nullptr);
1647 EXPECT_NE(scensession, nullptr);
1648 scensession->isActive_ = true;
1649
1650 float ratio = 0.1;
1651 sptr<WindowSessionProperty> property = new(std::nothrow) WindowSessionProperty();
1652 property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1653 WindowLimits limits;
1654 limits.maxHeight_ = 0;
1655 limits.minWidth_ = 10;
1656 property->SetWindowLimits(limits);
1657 scensession->SetSessionProperty(property);
1658 auto result = scensession->SetAspectRatio(ratio);
1659 ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PARAM);
1660 }
1661
1662 /**
1663 * @tc.name: SetAspectRatio7
1664 * @tc.desc: normal function
1665 * @tc.type: FUNC
1666 */
1667 HWTEST_F(SceneSessionTest, SetAspectRatio7, Function | SmallTest | Level2)
1668 {
1669 SessionInfo info;
1670 info.abilityName_ = "SetAspectRatio7";
1671 info.bundleName_ = "SetAspectRatio7";
1672 sptr<Rosen::ISession> session_;
1673 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1674 new (std::nothrow) SceneSession::SpecificSessionCallback();
1675 EXPECT_NE(specificCallback_, nullptr);
1676 sptr<SceneSession> scensession = new (std::nothrow) SceneSession(info, nullptr);
1677 EXPECT_NE(scensession, nullptr);
1678 scensession->isActive_ = true;
1679
1680 float ratio = 0.1;
1681 sptr<WindowSessionProperty> property = new(std::nothrow) WindowSessionProperty();
1682 property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1683 WindowLimits limits;
1684 limits.maxHeight_ = 10;
1685 limits.minWidth_ = 10;
1686 property->SetWindowLimits(limits);
1687 scensession->SetSessionProperty(property);
1688 auto result = scensession->SetAspectRatio(ratio);
1689 ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PARAM);
1690 }
1691
1692 /**
1693 * @tc.name: UpdateRect
1694 * @tc.desc: normal function
1695 * @tc.type: FUNC
1696 */
1697 HWTEST_F(SceneSessionTest, UpdateRect, Function | SmallTest | Level2)
1698 {
1699 SessionInfo info;
1700 info.abilityName_ = "UpdateRect";
1701 info.bundleName_ = "UpdateRect";
1702 sptr<Rosen::ISession> session_;
1703 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1704 new (std::nothrow) SceneSession::SpecificSessionCallback();
1705 EXPECT_NE(specificCallback_, nullptr);
1706 sptr<SceneSession> scensession = new (std::nothrow) SceneSession(info, nullptr);
1707 EXPECT_NE(scensession, nullptr);
1708 scensession->isActive_ = true;
1709
1710 sptr<WindowSessionProperty> property = new(std::nothrow) WindowSessionProperty();
1711 property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1712
1713 scensession->SetSessionProperty(property);
1714 WSRect rect({1, 1, 1, 1});
1715 SizeChangeReason reason = SizeChangeReason::UNDEFINED;
1716 WSError result = scensession->UpdateRect(rect, reason, "SceneSessionTest");
1717 ASSERT_EQ(result, WSError::WS_OK);
1718 }
1719
1720 /**
1721 * @tc.name: UpdateInputMethodSessionRect
1722 * @tc.desc: normal function
1723 * @tc.type: FUNC
1724 */
1725 HWTEST_F(SceneSessionTest, UpdateInputMethodSessionRect, Function | SmallTest | Level2)
1726 {
1727 SessionInfo info;
1728 info.abilityName_ = "UpdateInputMethodSessionRect";
1729 info.bundleName_ = "UpdateInputMethodSessionRect";
1730 sptr<Rosen::ISession> session_;
1731 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1732 new (std::nothrow) SceneSession::SpecificSessionCallback();
1733 EXPECT_NE(specificCallback_, nullptr);
1734 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1735 EXPECT_NE(sceneSession, nullptr);
1736 sceneSession->isActive_ = true;
1737
1738 sptr<WindowSessionProperty> property = new(std::nothrow) WindowSessionProperty();
1739 property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1740 property->keyboardLayoutParams_.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM;
1741
1742 sceneSession->SetSessionProperty(property);
1743 WSRect rect({1, 1, 1, 1});
1744 WSRect newWinRect;
1745 WSRect newRequestRect;
1746
1747 sceneSession->UpdateInputMethodSessionRect(rect, newWinRect, newRequestRect);
1748 EXPECT_NE(sceneSession, nullptr);
1749
1750 sceneSession->SetSessionProperty(nullptr);
1751 sceneSession->UpdateInputMethodSessionRect(rect, newWinRect, newRequestRect);
1752 }
1753
1754 /**
1755 * @tc.name: UpdateSessionRect
1756 * @tc.desc: normal function
1757 * @tc.type: FUNC
1758 */
1759 HWTEST_F(SceneSessionTest, UpdateSessionRect, Function | SmallTest | Level2)
1760 {
1761 SessionInfo info;
1762 info.abilityName_ = "UpdateSessionRect";
1763 info.bundleName_ = "UpdateSessionRect";
1764 sptr<Rosen::ISession> session_;
1765 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1766 new (std::nothrow) SceneSession::SpecificSessionCallback();
1767 EXPECT_NE(specificCallback_, nullptr);
1768 sptr<SceneSession> scensession = new (std::nothrow) SceneSession(info, nullptr);
1769 EXPECT_NE(scensession, nullptr);
1770 scensession->isActive_ = true;
1771
1772 sptr<WindowSessionProperty> property = new(std::nothrow) WindowSessionProperty();
1773 property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1774 property->keyboardLayoutParams_.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM;
1775
1776 scensession->SetSessionProperty(property);
1777 WSRect rect({1, 1, 1, 1});
1778 SizeChangeReason reason = SizeChangeReason::MOVE;
1779 WSError result = scensession->UpdateSessionRect(rect, reason);
1780 ASSERT_EQ(result, WSError::WS_OK);
1781 }
1782
1783 /**
1784 * @tc.name: UpdateSessionRect1
1785 * @tc.desc: normal function
1786 * @tc.type: FUNC
1787 */
1788 HWTEST_F(SceneSessionTest, UpdateSessionRect1, Function | SmallTest | Level2)
1789 {
1790 SessionInfo info;
1791 info.abilityName_ = "UpdateSessionRect";
1792 info.bundleName_ = "UpdateSessionRect";
1793 sptr<Rosen::ISession> session_;
1794 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1795 new (std::nothrow) SceneSession::SpecificSessionCallback();
1796 EXPECT_NE(specificCallback_, nullptr);
1797 sptr<SceneSession> scensession = new (std::nothrow) SceneSession(info, nullptr);
1798 EXPECT_NE(scensession, nullptr);
1799 scensession->isActive_ = true;
1800
1801 sptr<WindowSessionProperty> property = new(std::nothrow) WindowSessionProperty();
1802 property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1803 property->keyboardLayoutParams_.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM;
1804
1805 scensession->SetSessionProperty(property);
1806 WSRect rect({1, 1, 1, 1});
1807 SizeChangeReason reason = SizeChangeReason::RESIZE;
1808 WSError result = scensession->UpdateSessionRect(rect, reason);
1809 ASSERT_EQ(result, WSError::WS_OK);
1810 }
1811
1812 /**
1813 * @tc.name: UpdateSessionRect2
1814 * @tc.desc: normal function
1815 * @tc.type: FUNC
1816 */
1817 HWTEST_F(SceneSessionTest, UpdateSessionRect2, Function | SmallTest | Level2)
1818 {
1819 SessionInfo info;
1820 info.abilityName_ = "UpdateSessionRect";
1821 info.bundleName_ = "UpdateSessionRect";
1822 sptr<Rosen::ISession> session_;
1823 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1824 new (std::nothrow) SceneSession::SpecificSessionCallback();
1825 EXPECT_NE(specificCallback_, nullptr);
1826 sptr<SceneSession> scensession = new (std::nothrow) SceneSession(info, nullptr);
1827 EXPECT_NE(scensession, nullptr);
1828 scensession->isActive_ = true;
1829
1830 sptr<WindowSessionProperty> property = new(std::nothrow) WindowSessionProperty();
1831 property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1832 property->keyboardLayoutParams_.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM;
1833
1834 scensession->SetSessionProperty(property);
1835 WSRect rect({1, 1, 1, 1});
1836 SizeChangeReason reason = SizeChangeReason::UNDEFINED;
1837 WSError result = scensession->UpdateSessionRect(rect, reason);
1838 ASSERT_EQ(result, WSError::WS_OK);
1839 }
1840
1841 /**
1842 * @tc.name: GetAppForceLandscapeConfig
1843 * @tc.desc: GetAppForceLandscapeConfig
1844 * @tc.type: FUNC
1845 */
1846 HWTEST_F(SceneSessionTest, GetAppForceLandscapeConfig, Function | SmallTest | Level2)
1847 {
1848 SessionInfo info;
1849 info.abilityName_ = "GetAppForceLandscapeConfig";
1850 info.bundleName_ = "GetAppForceLandscapeConfig";
1851 sptr<SceneSession::SpecificSessionCallback> specificCallback =
1852 sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1853 EXPECT_NE(specificCallback, nullptr);
1854 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1855 EXPECT_NE(sceneSession, nullptr);
1856 AppForceLandscapeConfig config = {};
1857 auto result = sceneSession->GetAppForceLandscapeConfig(config);
1858 ASSERT_EQ(result, WMError::WM_ERROR_NULLPTR);
1859 }
1860
1861 /**
1862 * @tc.name: HandleCompatibleModeMoveDrag
1863 * @tc.desc: HandleCompatibleModeMoveDrag
1864 * @tc.type: FUNC
1865 */
1866 HWTEST_F(SceneSessionTest, HandleCompatibleModeMoveDrag, Function | SmallTest | Level2)
1867 {
1868 SessionInfo info;
1869 info.abilityName_ = "HandleCompatibleModeMoveDrag";
1870 info.bundleName_ = "HandleCompatibleModeMoveDrag";
1871 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1872 EXPECT_NE(sceneSession, nullptr);
1873
1874 WSRect rect = {1, 1, 1, 1};
1875 WSRect rect2 = {1, 1, 2, 1};
1876 sceneSession->winRect_ = rect2;
1877 sceneSession->HandleCompatibleModeMoveDrag(rect, SizeChangeReason::HIDE, true);
1878 ASSERT_EQ(sceneSession->reason_, SizeChangeReason::HIDE);
1879
1880 sceneSession->HandleCompatibleModeMoveDrag(rect, SizeChangeReason::HIDE, false);
1881 ASSERT_EQ(sceneSession->reason_, SizeChangeReason::HIDE);
1882
1883 rect2 = {1, 1, 1, 2};
1884 sceneSession->winRect_ = rect2;
1885 sceneSession->HandleCompatibleModeMoveDrag(rect, SizeChangeReason::HIDE, true);
1886 ASSERT_EQ(sceneSession->reason_, SizeChangeReason::HIDE);
1887
1888 rect = {1, 1, 2000, 1};
1889 rect2 = {1, 1, 2, 1};
1890 sceneSession->winRect_ = rect2;
1891 sceneSession->HandleCompatibleModeMoveDrag(rect, SizeChangeReason::HIDE, true);
1892 ASSERT_EQ(sceneSession->reason_, SizeChangeReason::HIDE);
1893
1894 rect = {1, 1, 2000, 1};
1895 rect2 = {1, 1, 1, 2};
1896 sceneSession->winRect_ = rect2;
1897 sceneSession->HandleCompatibleModeMoveDrag(rect, SizeChangeReason::HIDE, true);
1898 ASSERT_EQ(sceneSession->reason_, SizeChangeReason::HIDE);
1899
1900 rect = {1, 1, 500, 1};
1901 rect2 = {1, 1, 1, 2};
1902 sceneSession->winRect_ = rect2;
1903 sceneSession->HandleCompatibleModeMoveDrag(rect, SizeChangeReason::HIDE, true);
1904 ASSERT_EQ(sceneSession->reason_, SizeChangeReason::HIDE);
1905
1906 rect = {1, 1, 500, 1};
1907 rect2 = {1, 1, 1, 2};
1908 sceneSession->winRect_ = rect2;
1909 sceneSession->HandleCompatibleModeMoveDrag(rect, SizeChangeReason::HIDE, false);
1910 ASSERT_EQ(sceneSession->reason_, SizeChangeReason::HIDE);
1911
1912 sceneSession->HandleCompatibleModeMoveDrag(rect, SizeChangeReason::MOVE, false);
1913 ASSERT_EQ(sceneSession->reason_, SizeChangeReason::MOVE);
1914
1915 sceneSession->HandleCompatibleModeMoveDrag(rect, SizeChangeReason::DRAG_MOVE, false);
1916 ASSERT_EQ(sceneSession->reason_, SizeChangeReason::DRAG_MOVE);
1917 }
1918
1919 /**
1920 * @tc.name: SetMoveDragCallback
1921 * @tc.desc: SetMoveDragCallback
1922 * @tc.type: FUNC
1923 */
1924 HWTEST_F(SceneSessionTest, SetMoveDragCallback, Function | SmallTest | Level2)
1925 {
1926 SessionInfo info;
1927 info.abilityName_ = "SetMoveDragCallback";
1928 info.bundleName_ = "SetMoveDragCallback";
1929 sptr<SceneSession::SpecificSessionCallback> specificCallback =
1930 sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1931 EXPECT_NE(specificCallback, nullptr);
1932 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1933 EXPECT_NE(sceneSession, nullptr);
1934
1935 sceneSession->moveDragController_ = nullptr;
1936 sceneSession->SetMoveDragCallback();
1937 }
1938
1939 /**
1940 * @tc.name: GetScreenWidthAndHeightFromServer
1941 * @tc.desc: GetScreenWidthAndHeightFromServer
1942 * @tc.type: FUNC
1943 */
1944 HWTEST_F(SceneSessionTest, GetScreenWidthAndHeightFromServer, Function | SmallTest | Level2)
1945 {
1946 SessionInfo info;
1947 info.abilityName_ = "GetScreenWidthAndHeightFromServer";
1948 info.bundleName_ = "GetScreenWidthAndHeightFromServer";
1949 sptr<Rosen::ISession> session_;
1950 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
1951 new (std::nothrow) SceneSession::SpecificSessionCallback();
1952 EXPECT_NE(specificCallback_, nullptr);
1953 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1954 EXPECT_NE(sceneSession, nullptr);
1955 sceneSession->isActive_ = true;
1956
1957 sptr<WindowSessionProperty> property = new(std::nothrow) WindowSessionProperty();
1958 EXPECT_NE(property, nullptr);
1959 property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1960 property->keyboardLayoutParams_.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM;
1961 sceneSession->SetSessionProperty(property);
1962
1963 uint32_t screenWidth = 0;
1964 uint32_t screenHeight = 0;
1965 bool result = sceneSession->GetScreenWidthAndHeightFromServer(property, screenWidth, screenHeight);
1966 ASSERT_EQ(result, true);
1967
1968 sceneSession->SetSessionProperty(nullptr);
1969 result = sceneSession->GetScreenWidthAndHeightFromServer(property, screenWidth, screenHeight);
1970 ASSERT_EQ(result, true);
1971 }
1972
1973 /**
1974 * @tc.name: SetDefaultDisplayIdIfNeed
1975 * @tc.desc: SetDefaultDisplayIdIfNeed
1976 * @tc.type: FUNC
1977 */
1978 HWTEST_F(SceneSessionTest, SetDefaultDisplayIdIfNeed, Function | SmallTest | Level2)
1979 {
1980 SessionInfo info;
1981 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1982 EXPECT_NE(sceneSession, nullptr);
1983 sceneSession->SetDefaultDisplayIdIfNeed();
1984
1985 sptr<WindowSessionProperty> property = new(std::nothrow) WindowSessionProperty();
1986 EXPECT_NE(property, nullptr);
1987 property->SetDisplayId(-99);
1988 sceneSession->SetSessionProperty(property);
1989 sceneSession->SetDefaultDisplayIdIfNeed();
1990 EXPECT_EQ(property->GetDisplayId(), SCREEN_ID_INVALID);
1991 }
1992
1993 /**
1994 * @tc.name: SetSessionGlobalRect/GetSessionGlobalRect
1995 * @tc.desc: SetSessionGlobalRect
1996 * @tc.type: FUNC
1997 */
1998 HWTEST_F(SceneSessionTest, SetSessionGlobalRect, Function | SmallTest | Level2)
1999 {
2000 SessionInfo info;
2001 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
2002 EXPECT_NE(sceneSession, nullptr);
2003 WSRect test = { 100, 100, 100, 100 };
2004 sceneSession->SetSessionGlobalRect(test);
2005 sceneSession->SetScbCoreEnabled(true);
2006 EXPECT_EQ(test, sceneSession->GetSessionGlobalRect());
2007 }
2008
2009 /**
2010 * @tc.name: SetSessionGlobalRect/GetSessionGlobalRect
2011 * @tc.desc: SetSessionGlobalRect
2012 * @tc.type: FUNC
2013 */
2014 HWTEST_F(SceneSessionTest, SetIsStatusBarVisibleInner01, Function | SmallTest | Level2)
2015 {
2016 SessionInfo info;
2017 info.abilityName_ = "SetIsStatusBarVisibleInner01";
2018 info.bundleName_ = "SetIsStatusBarVisibleInner01";
2019 info.windowType_ = 1;
2020 sptr<SceneSession::SpecificSessionCallback> specificCallback =
2021 sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
2022 EXPECT_NE(specificCallback, nullptr);
2023 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback);
2024 EXPECT_NE(sceneSession, nullptr);
2025 sceneSession->isStatusBarVisible_ = true;
2026 EXPECT_EQ(sceneSession->SetIsStatusBarVisibleInner(true), WSError::WS_OK);
2027 EXPECT_EQ(sceneSession->SetIsStatusBarVisibleInner(false), WSError::WS_ERROR_NULLPTR);
2028
__anonad808b0c0802(bool& isLayoutFinished) 2029 sceneSession->isLastFrameLayoutFinishedFunc_ = [](bool& isLayoutFinished) {
2030 return WSError::WS_ERROR_NULLPTR;
2031 };
2032 EXPECT_EQ(sceneSession->SetIsStatusBarVisibleInner(true), WSError::WS_ERROR_NULLPTR);
2033
__anonad808b0c0902(bool& isLayoutFinished) 2034 sceneSession->isLastFrameLayoutFinishedFunc_ = [](bool& isLayoutFinished) {
2035 isLayoutFinished = false;
2036 return WSError::WS_OK;
2037 };
2038 EXPECT_EQ(sceneSession->SetIsStatusBarVisibleInner(false), WSError::WS_OK);
2039
__anonad808b0c0a02(bool& isLayoutFinished) 2040 sceneSession->isLastFrameLayoutFinishedFunc_ = [](bool& isLayoutFinished) {
2041 isLayoutFinished = true;
2042 return WSError::WS_OK;
2043 };
2044 sceneSession->specificCallback_ = nullptr;
2045 EXPECT_EQ(sceneSession->SetIsStatusBarVisibleInner(false), WSError::WS_OK);
2046 }
2047
2048 /**
2049 * @tc.name: SetMousePointerDownEventStatus
2050 * @tc.desc: SetMousePointerDownEventStatus
2051 * @tc.type: FUNC
2052 */
2053 HWTEST_F(SceneSessionTest, SetMousePointerDownEventStatus, Function | SmallTest | Level2)
2054 {
2055 SessionInfo info;
2056 info.abilityName_ = "SetMousePointerDownEventStatus";
2057 info.bundleName_ = "SetMousePointerDownEventStatus";
2058 info.windowType_ = 1;
2059 sptr<SceneSession::SpecificSessionCallback> specificCallback =
2060 sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
2061 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback);
2062 EXPECT_NE(sceneSession, nullptr);
2063
2064 sceneSession->SetMousePointerDownEventStatus(true);
2065 EXPECT_EQ(sceneSession->GetMousePointerDownEventStatus(), true);
2066 }
2067
2068 /**
2069 * @tc.name: SetFingerPointerDownStatus
2070 * @tc.desc: SetFingerPointerDownStatus
2071 * @tc.type: FUNC
2072 */
2073 HWTEST_F(SceneSessionTest, SetFingerPointerDownStatus, Function | SmallTest | Level2)
2074 {
2075 SessionInfo info;
2076 info.abilityName_ = "SetFingerPointerDownStatus";
2077 info.bundleName_ = "SetFingerPointerDownStatus";
2078 info.windowType_ = 1;
2079 sptr<SceneSession::SpecificSessionCallback> specificCallback =
2080 sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
2081 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback);
2082 EXPECT_NE(sceneSession, nullptr);
2083
2084 sceneSession->SetFingerPointerDownStatus(0);
2085 sceneSession->SetFingerPointerDownStatus(1);
2086 auto fingerPointerDownStatusList = sceneSession->GetFingerPointerDownStatusList();
2087 EXPECT_EQ(fingerPointerDownStatusList.size(), 2);
2088 sceneSession->RemoveFingerPointerDownStatus(0);
2089 fingerPointerDownStatusList = sceneSession->GetFingerPointerDownStatusList();
2090 EXPECT_EQ(fingerPointerDownStatusList.size(), 1);
2091
2092 sceneSession->RemoveFingerPointerDownStatus(1);
2093 fingerPointerDownStatusList = sceneSession->GetFingerPointerDownStatusList();
2094 EXPECT_EQ(fingerPointerDownStatusList.size(), 0);
2095 }
2096
2097 /**
2098 * @tc.name: SetUIFirstSwitch
2099 * @tc.desc: SetUIFirstSwitch
2100 * @tc.type: FUNC
2101 */
2102 HWTEST_F(SceneSessionTest, SetUIFirstSwitch, Function | SmallTest | Level2)
2103 {
2104 SessionInfo info;
2105 info.abilityName_ = "SetUIFirstSwitch";
2106 info.bundleName_ = "SetUIFirstSwitch";
2107 info.windowType_ = 1;
2108 sptr<SceneSession::SpecificSessionCallback> specificCallback =
2109 sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
2110 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, specificCallback);
2111 EXPECT_NE(sceneSession, nullptr);
2112 sceneSession->SetUIFirstSwitch(RSUIFirstSwitch::FORCE_DISABLE_NONFOCUS);
2113 }
2114 } // namespace
2115 } // Rosen
2116 } // OHOS
2117