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