1 /*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <gtest/gtest.h>
17
18 #include "application_context.h"
19 #include "display_manager.h"
20 #include "input_event.h"
21 #include "key_event.h"
22 #include "mock/mock_session_stage.h"
23 #include "pointer_event.h"
24
25 #include "session/host/include/main_session.h"
26 #include "session/host/include/keyboard_session.h"
27 #define private public
28 #define protected public
29 #include "session/host/include/scene_session.h"
30 #undef private
31 #undef protected
32 #include "session/host/include/sub_session.h"
33 #include "session/host/include/system_session.h"
34 #include "ui/rs_surface_node.h"
35 #include "window_helper.h"
36 #include "wm_common.h"
37
38
39 using namespace testing;
40 using namespace testing::ext;
41 namespace OHOS {
42 namespace Rosen {
43 class SceneSessionTest3 : public testing::Test {
44 public:
45 static void SetUpTestCase();
46 static void TearDownTestCase();
47 void SetUp() override;
48 void TearDown() override;
49 };
50
SetUpTestCase()51 void SceneSessionTest3::SetUpTestCase()
52 {
53 }
54
TearDownTestCase()55 void SceneSessionTest3::TearDownTestCase()
56 {
57 }
58
SetUp()59 void SceneSessionTest3::SetUp()
60 {
61 }
62
TearDown()63 void SceneSessionTest3::TearDown()
64 {
65 }
66
67 namespace {
68 /**
69 * @tc.name: NotifyClientToUpdateRectTask
70 * @tc.desc: normal function
71 * @tc.type: FUNC
72 */
73 HWTEST_F(SceneSessionTest3, NotifyClientToUpdateRectTask, Function | SmallTest | Level2)
74 {
75 SessionInfo info;
76 info.abilityName_ = "NotifyClientToUpdateRectTask";
77 info.bundleName_ = "NotifyClientToUpdateRectTask";
78 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
79 EXPECT_NE(sceneSession, nullptr);
80 sceneSession->isActive_ = true;
81
82 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
83 EXPECT_NE(property, nullptr);
84 property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
85
86 sceneSession->SetSessionProperty(property);
87 sceneSession->SetSessionState(SessionState::STATE_ACTIVE);
88 auto result = sceneSession->NotifyClientToUpdateRectTask("SceneSessionTest3", nullptr);
89 ASSERT_EQ(result, WSError::WS_OK);
90
91 property->SetWindowType(WindowType::WINDOW_TYPE_KEYBOARD_PANEL);
92 sceneSession->SetSessionProperty(property);
93 sceneSession->isKeyboardPanelEnabled_ = true;
94 sceneSession->state_ = SessionState::STATE_FOREGROUND;
95 sceneSession->isScbCoreEnabled_ = false;
96 ASSERT_EQ(WSError::WS_OK,
97 sceneSession->NotifyClientToUpdateRectTask("SceneSessionTest3", nullptr));
98
99 property->SetWindowType(WindowType::WINDOW_TYPE_KEYBOARD_PANEL);
100 sceneSession->SetSessionProperty(property);
101 sceneSession->isKeyboardPanelEnabled_ = true;
102 ASSERT_EQ(WSError::WS_OK, sceneSession->NotifyClientToUpdateRectTask("SceneSessionTest3", nullptr));
103
104 std::shared_ptr<RSTransaction> rs;
105 ASSERT_EQ(WSError::WS_OK, sceneSession->NotifyClientToUpdateRectTask("SceneSessionTest3", rs));
106 }
107
108 /**
109 * @tc.name: BindDialogSessionTarget1
110 * @tc.desc: normal function
111 * @tc.type: FUNC
112 */
113 HWTEST_F(SceneSessionTest3, BindDialogSessionTarget1, Function | SmallTest | Level2)
114 {
115 SessionInfo info;
116 info.abilityName_ = "BindDialogSessionTarget1";
117 info.bundleName_ = "BindDialogSessionTarget1";
118 sptr<SceneSession::SpecificSessionCallback> specificCallback_ =
119 sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
120 EXPECT_NE(specificCallback_, nullptr);
121 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
122 EXPECT_NE(sceneSession, nullptr);
123 sceneSession->isActive_ = true;
124
125 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
126 EXPECT_NE(property, nullptr);
127 property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
128 property->keyboardLayoutParams_.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM;
129 sceneSession->SetSessionProperty(property);
130
131 sptr<SceneSession> sceneSession1 = nullptr;
132 WSError result = sceneSession->BindDialogSessionTarget(sceneSession1);
133 ASSERT_EQ(result, WSError::WS_ERROR_NULLPTR);
134
135 sptr<SceneSession> sceneSession2 = sceneSession;
136 result = sceneSession->BindDialogSessionTarget(sceneSession2);
137 ASSERT_EQ(result, WSError::WS_OK);
138
__anon690b1d5d0202(const sptr<SceneSession>&) 139 sceneSession->onBindDialogTarget_ = [](const sptr<SceneSession>&) {};
140 sceneSession1 = sptr<SceneSession>::MakeSptr(info, nullptr);
141 result = sceneSession->BindDialogSessionTarget(sceneSession1);
142 ASSERT_EQ(result, WSError::WS_OK);
143 }
144
145 /**
146 * @tc.name: RegisterBindDialogSessionCallback1
147 * @tc.desc: test RegisterBindDialogSessionCallback
148 * @tc.type: FUNC
149 */
150 HWTEST_F(SceneSessionTest3, RegisterBindDialogSessionCallback1, Function | SmallTest | Level2)
151 {
152 SessionInfo info;
153 info.abilityName_ = "RegisterBindDialogSessionCallback1";
154 info.bundleName_ = "RegisterBindDialogSessionCallback1";
155 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
156 sceneSession->onBindDialogTarget_ = nullptr;
__anon690b1d5d0302(const sptr<SceneSession>& sceneSession) 157 NotifyBindDialogSessionFunc func = [](const sptr<SceneSession>& sceneSession) {};
158 sceneSession->RegisterBindDialogSessionCallback(func);
159 ASSERT_NE(sceneSession->onBindDialogTarget_, nullptr);
160 }
161
162 /**
163 * @tc.name: ClearSpecificSessionCbMap1
164 * @tc.desc: normal function
165 * @tc.type: FUNC
166 */
167 HWTEST_F(SceneSessionTest3, ClearSpecificSessionCbMap1, Function | SmallTest | Level2)
168 {
169 SessionInfo info;
170 info.abilityName_ = "ClearSpecificSessionCbMap1";
171 info.bundleName_ = "ClearSpecificSessionCbMap1";
172 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
173 EXPECT_NE(nullptr, sceneSession);
174 sceneSession->ClearSpecificSessionCbMap();
175
__anon690b1d5d0402(bool) 176 sceneSession->clearCallbackMapFunc_ = [](bool) {};
177 sceneSession->ClearSpecificSessionCbMap();
178 }
179
180 /**
181 * @tc.name: IsMovableWindowType
182 * @tc.desc: normal function
183 * @tc.type: FUNC
184 */
185 HWTEST_F(SceneSessionTest3, IsMovableWindowType, Function | SmallTest | Level2)
186 {
187 SessionInfo info;
188 info.abilityName_ = "IsMovableWindowType";
189 info.bundleName_ = "IsMovableWindowType";
190 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
191 EXPECT_NE(nullptr, sceneSession);
192
193 sceneSession->property_ = nullptr;
194 EXPECT_EQ(sceneSession->IsMovableWindowType(), false);
195 }
196
197 /**
198 * @tc.name: SetBlank
199 * @tc.desc: check func SetBlank
200 * @tc.type: FUNC
201 */
202 HWTEST_F(SceneSessionTest3, SetBlank, Function | SmallTest | Level2)
203 {
204 SessionInfo info;
205 info.abilityName_ = "SetBlank";
206 info.bundleName_ = "SetBlank";
207 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
208 EXPECT_NE(nullptr, sceneSession);
209
210 bool isAddBlank = true;
211 sceneSession->SetBlank(isAddBlank);
212 ASSERT_EQ(isAddBlank, sceneSession->GetBlank());
213 }
214
215 /**
216 * @tc.name: GetBlank
217 * @tc.desc: check func GetBlank
218 * @tc.type: FUNC
219 */
220 HWTEST_F(SceneSessionTest3, GetBlank, Function | SmallTest | Level2)
221 {
222 SessionInfo info;
223 info.abilityName_ = "GetBlank";
224 info.bundleName_ = "GetBlank";
225 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
226 EXPECT_NE(nullptr, sceneSession);
227
228 bool isAddBlank = true;
229 sceneSession->SetBlank(isAddBlank);
230 ASSERT_EQ(isAddBlank, sceneSession->GetBlank());
231 }
232
233 /**
234 * @tc.name: SetBufferAvailableCallbackEnable
235 * @tc.desc: check func SetBufferAvailableCallbackEnable
236 * @tc.type: FUNC
237 */
238 HWTEST_F(SceneSessionTest3, SetBufferAvailableCallbackEnable, Function | SmallTest | Level2)
239 {
240 SessionInfo info;
241 info.abilityName_ = "SetBufferAvailableCallbackEnable";
242 info.bundleName_ = "SetBufferAvailableCallbackEnable";
243 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
244 EXPECT_NE(nullptr, sceneSession);
245
246 bool enable = true;
247 sceneSession->SetBufferAvailableCallbackEnable(enable);
248 ASSERT_EQ(enable, sceneSession->GetBufferAvailableCallbackEnable());
249 }
250
251 /**
252 * @tc.name: GetBufferAvailableCallbackEnable
253 * @tc.desc: check func GetBufferAvailableCallbackEnable
254 * @tc.type: FUNC
255 */
256 HWTEST_F(SceneSessionTest3, GetBufferAvailableCallbackEnable, Function | SmallTest | Level2)
257 {
258 SessionInfo info;
259 info.abilityName_ = "GetBufferAvailableCallbackEnable";
260 info.bundleName_ = "GetBufferAvailableCallbackEnable";
261 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
262 EXPECT_NE(nullptr, sceneSession);
263
264 bool enable = true;
265 sceneSession->SetBufferAvailableCallbackEnable(enable);
266 ASSERT_EQ(enable, sceneSession->GetBufferAvailableCallbackEnable());
267 }
268
269 /**
270 * @tc.name: NotifyClientToUpdateAvoidArea
271 * @tc.desc: check func NotifyClientToUpdateAvoidArea
272 * @tc.type: FUNC
273 */
274 HWTEST_F(SceneSessionTest3, NotifyClientToUpdateAvoidArea, Function | SmallTest | Level2)
275 {
276 SessionInfo info;
277 info.abilityName_ = "NotifyClientToUpdateAvoidArea";
278 info.bundleName_ = "NotifyClientToUpdateAvoidArea";
279 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
280 EXPECT_NE(nullptr, sceneSession);
281
282 sceneSession->NotifyClientToUpdateAvoidArea();
283 EXPECT_EQ(nullptr, sceneSession->specificCallback_);
284
285 sptr<SceneSession::SpecificSessionCallback> callback =
286 sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
287 sceneSession = sptr<SceneSession>::MakeSptr(info, callback);
288 EXPECT_NE(nullptr, sceneSession);
289 sceneSession->persistentId_ = 6;
290 callback->onUpdateAvoidArea_ = nullptr;
291 sceneSession->NotifyClientToUpdateAvoidArea();
292
__anon690b1d5d0502(int32_t persistentId) 293 UpdateAvoidAreaCallback callbackFun = [&sceneSession](int32_t persistentId) {
294 sceneSession->RemoveToastSession(persistentId);
295 return;
296 };
297 callback->onUpdateAvoidArea_ = callbackFun;
298
299 callback->onUpdateOccupiedAreaIfNeed_ = nullptr;
__anon690b1d5d0602(int32_t persistentId) 300 UpdateOccupiedAreaIfNeedCallback updateCallbackFun = [&sceneSession](int32_t persistentId) {
301 sceneSession->RemoveToastSession(persistentId);
302 return;
303 };
304 callback->onUpdateOccupiedAreaIfNeed_ = updateCallbackFun;
305 sceneSession->NotifyClientToUpdateAvoidArea();
306 EXPECT_EQ(6, sceneSession->GetPersistentId());
307 }
308
309 /**
310 * @tc.name: UpdateScaleInner
311 * @tc.desc: check func UpdateScaleInner
312 * @tc.type: FUNC
313 */
314 HWTEST_F(SceneSessionTest3, UpdateScaleInner, Function | SmallTest | Level2)
315 {
316 SessionInfo info;
317 info.abilityName_ = "UpdateScaleInner";
318 info.bundleName_ = "UpdateScaleInner";
319 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
320 EXPECT_NE(nullptr, sceneSession);
321
322 sceneSession->sessionStage_ = nullptr;
323 sceneSession->state_ = SessionState::STATE_FOREGROUND;
324 bool res = sceneSession->UpdateScaleInner(10.0f, 10.0f, 10.0f, 10.0f);
325 EXPECT_EQ(true, res);
326
327 res = sceneSession->UpdateScaleInner(10.0f, 9.0f, 10.0f, 10.0f);
328 res = sceneSession->UpdateScaleInner(10.0f, 9.0f, 9.0f, 10.0f);
329 res = sceneSession->UpdateScaleInner(10.0f, 9.0f, 9.0f, 9.0f);
330 EXPECT_EQ(true, res);
331
332 sceneSession->state_ = SessionState::STATE_BACKGROUND;
333 res = sceneSession->UpdateScaleInner(10.0f, 9.0f, 9.0f, 9.0f);
334 EXPECT_EQ(false, res);
335
336 sceneSession->state_ = SessionState::STATE_FOREGROUND;
337 sptr<SessionStageMocker> mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
338 ASSERT_NE(mockSessionStage, nullptr);
339 sceneSession->sessionStage_ = mockSessionStage;
340 res = sceneSession->UpdateScaleInner(1.0f, 2.0f, 3.0f, 4.0f);
341 EXPECT_EQ(true, res);
342 res = sceneSession->UpdateScaleInner(1.0f, 2.0f, 3.0f, 4.0f);
343 EXPECT_EQ(false, res);
344 }
345
346 /**
347 * @tc.name: UpdateZOrderInner
348 * @tc.desc: check func UpdateZOrderInner
349 * @tc.type: FUNC
350 */
351 HWTEST_F(SceneSessionTest3, UpdateZOrderInner, Function | SmallTest | Level2)
352 {
353 SessionInfo info;
354 info.abilityName_ = "UpdateZOrderInner";
355 info.bundleName_ = "UpdateZOrderInner";
356 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
357 EXPECT_NE(nullptr, sceneSession);
358
359 int res = sceneSession->UpdateZOrderInner(10);
360 EXPECT_EQ(true, res);
361
362 res = sceneSession->UpdateZOrderInner(10);
363 EXPECT_EQ(false, res);
364 }
365
366 /**
367 * @tc.name: GetSubWindowModalType02
368 * @tc.desc: GetSubWindowModalType
369 * @tc.type: FUNC
370 */
371 HWTEST_F(SceneSessionTest3, GetSubWindowModalType02, Function | SmallTest | Level2)
372 {
373 SessionInfo info;
374 info.abilityName_ = "ModalType2";
375 info.bundleName_ = "ModalType2";
376 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
377 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
378 property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
379 property->SetWindowFlags(static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_IS_TOAST));
380 sceneSession->SetSessionProperty(property);
381 auto result = sceneSession->GetSubWindowModalType();
382 ASSERT_EQ(result, SubWindowModalType::TYPE_TOAST);
383 }
384
385 /**
386 * @tc.name: GetSubWindowModalType03
387 * @tc.desc: GetSubWindowModalType
388 * @tc.type: FUNC
389 */
390 HWTEST_F(SceneSessionTest3, GetSubWindowModalType03, Function | SmallTest | Level2)
391 {
392 SessionInfo info;
393 info.abilityName_ = "ModalType3";
394 info.bundleName_ = "ModalType3";
395 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
396 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
397 property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
398 property->SetWindowFlags(static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_IS_MODAL));
399 sceneSession->SetSessionProperty(property);
400 auto result = sceneSession->GetSubWindowModalType();
401 ASSERT_EQ(result, SubWindowModalType::TYPE_WINDOW_MODALITY);
402 }
403
404 /**
405 * @tc.name: GetSubWindowModalType04
406 * @tc.desc: GetSubWindowModalType
407 * @tc.type: FUNC
408 */
409 HWTEST_F(SceneSessionTest3, GetSubWindowModalType04, Function | SmallTest | Level2)
410 {
411 SessionInfo info;
412 info.abilityName_ = "ModalType4";
413 info.bundleName_ = "ModalType4";
414 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
415 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
416 property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
417 property->SetWindowFlags(static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_NEED_AVOID));
418 sceneSession->SetSessionProperty(property);
419 auto result = sceneSession->GetSubWindowModalType();
420 ASSERT_EQ(result, SubWindowModalType::TYPE_NORMAL);
421 }
422
423 /**
424 * @tc.name: RegisterDefaultAnimationFlagChangeCallback
425 * @tc.desc: RegisterDefaultAnimationFlagChangeCallback
426 * @tc.type: FUNC
427 */
428 HWTEST_F(SceneSessionTest3, RegisterDefaultAnimationFlagChangeCallback, Function | SmallTest | Level2)
429 {
430 SessionInfo info;
431 info.abilityName_ = "RegisterDefaultAnimationFlagChangeCallback";
432 info.bundleName_ = "RegisterDefaultAnimationFlagChangeCallback";
433 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
__anon690b1d5d0702(const bool flag) 434 sceneSession->RegisterDefaultAnimationFlagChangeCallback([sceneSession](const bool flag) {
435 return;
436 });
437 ASSERT_EQ(WSError::WS_OK, sceneSession->UpdateWindowAnimationFlag(true));
438
__anon690b1d5d0802(const bool flag) 439 sceneSession->RegisterDefaultAnimationFlagChangeCallback([sceneSession](const bool flag) {
440 return;
441 });
442 ASSERT_EQ(WSError::WS_OK, sceneSession->UpdateWindowAnimationFlag(true));
443 }
444
445 /**
446 * @tc.name: SetMainWindowTopmostChangeCallback
447 * @tc.desc: SetMainWindowTopmostChangeCallback
448 * @tc.type: FUNC
449 */
450 HWTEST_F(SceneSessionTest3, SetMainWindowTopmostChangeCallback, Function | SmallTest | Level2)
451 {
452 SessionInfo info;
453 info.abilityName_ = "SetMainWindowTopmostChangeCallback";
454 info.bundleName_ = "SetMainWindowTopmostChangeCallback";
455 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
456
457 NotifyMainWindowTopmostChangeFunc func;
458 sceneSession->SetMainWindowTopmostChangeCallback(std::move(func));
459
__anon690b1d5d0902(bool isTopmost) 460 NotifyMainWindowTopmostChangeFunc func1 = [sceneSession](bool isTopmost) {
461 return;
462 };
463 sceneSession->SetMainWindowTopmostChangeCallback(std::move(func1));
464 ASSERT_NE(nullptr, sceneSession->mainWindowTopmostChangeFunc_);
465 }
466
467 /**
468 * @tc.name: SetRestoreMainWindowCallback
469 * @tc.desc: SetRestoreMainWindowCallback
470 * @tc.type: FUNC
471 */
472 HWTEST_F(SceneSessionTest3, SetRestoreMainWindowCallback, Function | SmallTest | Level2)
473 {
474 SessionInfo info;
475 info.abilityName_ = "SetRestoreMainWindowCallback";
476 info.bundleName_ = "SetRestoreMainWindowCallback";
477 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
478
__anon690b1d5d0a02null479 sceneSession->SetRestoreMainWindowCallback([] {
480 return;
481 });
482 ASSERT_NE(nullptr, sceneSession->onRestoreMainWindowFunc_);
483 }
484
485 /**
486 * @tc.name: SetAdjustKeyboardLayoutCallback
487 * @tc.desc: SetAdjustKeyboardLayoutCallback
488 * @tc.type: FUNC
489 */
490 HWTEST_F(SceneSessionTest3, SetAdjustKeyboardLayoutCallback, Function | SmallTest | Level2)
491 {
492 SessionInfo info;
493 info.abilityName_ = "SetAdjustKeyboardLayoutCallback";
494 info.bundleName_ = "SetAdjustKeyboardLayoutCallback";
495 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
496 sptr<WindowSessionProperty> windowSessionProperty = sptr<WindowSessionProperty>::MakeSptr();
497 sceneSession->property_ = windowSessionProperty;
498
499 NotifyKeyboardLayoutAdjustFunc func;
500 sceneSession->SetAdjustKeyboardLayoutCallback(func);
501
__anon690b1d5d0b02(const KeyboardLayoutParams& params) 502 NotifyKeyboardLayoutAdjustFunc func1 = [sceneSession](const KeyboardLayoutParams& params) {
503 return;
504 };
505 sceneSession->SetAdjustKeyboardLayoutCallback(func1);
506 ASSERT_NE(nullptr, sceneSession->adjustKeyboardLayoutFunc_);
507 }
508
509 /**
510 * @tc.name: IsStartMoving
511 * @tc.desc: get main window move flag, test IsStartMoving
512 * @tc.type: FUNC
513 */
514 HWTEST_F(SceneSessionTest3, IsStartMoving, Function | SmallTest | Level2)
515 {
516 SessionInfo info;
517 info.abilityName_ = "IsStartMoving";
518 info.bundleName_ = "IsStartMoving";
519
520 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
521 sceneSession->moveDragController_ = sptr<MoveDragController>::MakeSptr(1, WindowType::WINDOW_TYPE_FLOAT);
522 ASSERT_EQ(false, sceneSession->IsStartMoving());
523
524 sceneSession->moveDragController_ = sptr<MoveDragController>::MakeSptr(1024, WindowType::WINDOW_TYPE_FLOAT);
525 ASSERT_EQ(false, sceneSession->IsStartMoving());
526 }
527
528 /**
529 * @tc.name: SetCompatibleWindowSizeInPc
530 * @tc.desc: SetCompatibleWindowSizeInPc
531 * @tc.type: FUNC
532 */
533 HWTEST_F(SceneSessionTest3, SetCompatibleWindowSizeInPc, Function | SmallTest | Level2)
534 {
535 SessionInfo info;
536 info.abilityName_ = "SetCompatibleWindowSizeInPc";
537 info.bundleName_ = "SetCompatibleWindowSizeInPc";
538
539 int32_t portraitWidth = 10;
540 int32_t portraitHeight = 20;
541 int32_t landscapeWidth = 10;
542 int32_t landscapeHeight = 20;
543 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
544
545 sptr<WindowSessionProperty> windowSessionProperty = sptr<WindowSessionProperty>::MakeSptr();
546 sceneSession->property_ = windowSessionProperty;
547 ASSERT_EQ(WSError::WS_OK,
548 sceneSession->SetCompatibleWindowSizeInPc(portraitWidth, portraitHeight, landscapeWidth, landscapeHeight));
549 }
550
551 /**
552 * @tc.name: SetAppSupportPhoneInPc
553 * @tc.desc: SetAppSupportPhoneInPc
554 * @tc.type: FUNC
555 */
556 HWTEST_F(SceneSessionTest3, SetAppSupportPhoneInPc, Function | SmallTest | Level2)
557 {
558 SessionInfo info;
559 info.abilityName_ = "SetAppSupportPhoneInPc";
560 info.bundleName_ = "SetAppSupportPhoneInPc";
561
562 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
563 sptr<WindowSessionProperty> windowSessionProperty = sptr<WindowSessionProperty>::MakeSptr();
564 sceneSession->property_ = windowSessionProperty;
565 ASSERT_EQ(WSError::WS_OK, sceneSession->SetAppSupportPhoneInPc(false));
566 }
567
568 /**
569 * @tc.name: CompatibleFullScreenRecover
570 * @tc.desc: CompatibleFullScreenRecover
571 * @tc.type: FUNC
572 */
573 HWTEST_F(SceneSessionTest3, CompatibleFullScreenRecover, Function | SmallTest | Level2)
574 {
575 SessionInfo info;
576 info.abilityName_ = "CompatibleFullScreenRecover";
577 info.bundleName_ = "CompatibleFullScreenRecover";
578
579 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
580 sptr<SessionStageMocker> mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
581 sceneSession->sessionStage_ = mockSessionStage;
582 sceneSession->SetSessionState(SessionState::STATE_DISCONNECT);
583 ASSERT_EQ(WSError::WS_ERROR_INVALID_SESSION, sceneSession->CompatibleFullScreenRecover());
584
585 sptr<WindowSessionProperty> windowSessionProperty = sptr<WindowSessionProperty>::MakeSptr();
586 sceneSession->property_ = windowSessionProperty;
587 sceneSession->SetSessionState(SessionState::STATE_CONNECT);
588 ASSERT_EQ(WSError::WS_OK, sceneSession->CompatibleFullScreenRecover());
589 }
590
591 /**
592 * @tc.name: SetIsMidScene
593 * @tc.desc: SetIsMidScene
594 * @tc.type: FUNC
595 */
596 HWTEST_F(SceneSessionTest3, SetIsMidScene, Function | SmallTest | Level2)
597 {
598 SessionInfo info;
599 info.abilityName_ = "SetIsMidScene";
600 info.bundleName_ = "SetIsMidScene";
601 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
602 EXPECT_NE(sceneSession, nullptr);
603
604 sceneSession->SetIsMidScene(true);
605 bool res = sceneSession->GetIsMidScene();
606 EXPECT_EQ(res, true);
607 }
608
609 /**
610 * @tc.name: SetIsPcAppInPad
611 * @tc.desc: SetIsPcAppInPad
612 * @tc.type: FUNC
613 */
614 HWTEST_F(SceneSessionTest3, SetIsPcAppInPad, Function | SmallTest | Level2)
615 {
616 SessionInfo info;
617 info.abilityName_ = "SetIsPcAppInPad";
618 info.bundleName_ = "SetIsPcAppInPad";
619
620 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
621
622 sptr<WindowSessionProperty> windowSessionProperty = sptr<WindowSessionProperty>::MakeSptr();
623 sceneSession->property_ = windowSessionProperty;
624 ASSERT_EQ(WSError::WS_OK, sceneSession->SetIsPcAppInPad(false));
625 }
626
627 /**
628 * @tc.name: CompatibleFullScreenClose
629 * @tc.desc: CompatibleFullScreenClose
630 * @tc.type: FUNC
631 */
632 HWTEST_F(SceneSessionTest3, CompatibleFullScreenClose, Function | SmallTest | Level2)
633 {
634 SessionInfo info;
635 info.abilityName_ = "CompatibleFullScreenClose";
636 info.bundleName_ = "CompatibleFullScreenClose";
637
638 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
639 sptr<SessionStageMocker> mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
640 sceneSession->sessionStage_ = mockSessionStage;
641 sptr<WindowSessionProperty> windowSessionProperty = sptr<WindowSessionProperty>::MakeSptr();
642 sceneSession->property_ = windowSessionProperty;
643 sceneSession->SetSessionState(SessionState::STATE_DISCONNECT);
644 ASSERT_EQ(WSError::WS_ERROR_INVALID_SESSION, sceneSession->CompatibleFullScreenClose());
645 sceneSession->SetSessionState(SessionState::STATE_CONNECT);
646 ASSERT_EQ(WSError::WS_OK, sceneSession->CompatibleFullScreenClose());
647 }
648
649 /**
650 * @tc.name: SetWindowRectAutoSaveCallback
651 * @tc.desc: SetWindowRectAutoSaveCallback
652 * @tc.type: FUNC
653 */
654 HWTEST_F(SceneSessionTest3, SetWindowRectAutoSaveCallback, Function | SmallTest | Level2)
655 {
656 SessionInfo info;
657 info.abilityName_ = "SetWindowRectAutoSaveCallback";
658 info.bundleName_ = "SetWindowRectAutoSaveCallback";
659 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
660 sptr<WindowSessionProperty> windowSessionProperty = sptr<WindowSessionProperty>::MakeSptr();
661 sceneSession->property_ = windowSessionProperty;
662
__anon690b1d5d0c02(bool enabled, bool isSaveBySpecifiedFlag) 663 NotifySetWindowRectAutoSaveFunc func1 = [](bool enabled, bool isSaveBySpecifiedFlag) {
664 return;
665 };
666 sceneSession->SetWindowRectAutoSaveCallback(std::move(func1));
667 ASSERT_NE(nullptr, sceneSession->onSetWindowRectAutoSaveFunc_);
668 }
669
670 /**
671 * @tc.name: RegisterSupportWindowModesCallback
672 * @tc.desc: RegisterSupportWindowModesCallback
673 * @tc.type: FUNC
674 */
675 HWTEST_F(SceneSessionTest3, RegisterSupportWindowModesCallback, Function | SmallTest | Level2)
676 {
677 SessionInfo info;
678 info.abilityName_ = "RegisterSupportWindowModesCallback";
679 info.bundleName_ = "RegisterSupportWindowModesCallback";
680 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
681
682 NotifySetSupportedWindowModesFunc func1 = [sceneSession](
__anon690b1d5d0d02( std::vector<AppExecFwk::SupportWindowMode>&& supportedWindowModes) 683 std::vector<AppExecFwk::SupportWindowMode>&& supportedWindowModes) {
684 return;
685 };
686
687 sceneSession->RegisterSupportWindowModesCallback(std::move(func1));
688 ASSERT_NE(nullptr, sceneSession->onSetSupportedWindowModesFunc_);
689 }
690
691 /**
692 * @tc.name: SetWindowCornerRadiusCallback
693 * @tc.desc: SetWindowCornerRadiusCallback
694 * @tc.type: FUNC
695 */
696 HWTEST_F(SceneSessionTest3, SetWindowCornerRadiusCallback, Function | SmallTest | Level2)
697 {
698 SessionInfo info;
699 info.abilityName_ = "SetWindowCornerRadiusCallback";
700 info.bundleName_ = "SetWindowCornerRadiusCallback";
701 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
702
__anon690b1d5d0e02(float cornerRadius) 703 NotifySetWindowCornerRadiusFunc func1 = [](float cornerRadius) {
704 return;
705 };
706 sceneSession->SetWindowCornerRadiusCallback(std::move(func1));
707 ASSERT_NE(nullptr, sceneSession->onSetWindowCornerRadiusFunc_);
708 }
709
710 /**
711 * @tc.name: OnSetWindowCornerRadius
712 * @tc.desc: OnSetWindowCornerRadius
713 * @tc.type: FUNC
714 */
715 HWTEST_F(SceneSessionTest3, SetWindowCornerRadius, Function | SmallTest | Level2)
716 {
717 SessionInfo info;
718 info.abilityName_ = "SetWindowCornerRadius";
719 info.bundleName_ = "SetWindowCornerRadius";
720 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
721 EXPECT_NE(session, nullptr);
722 EXPECT_EQ(WSError::WS_OK, session->SetWindowCornerRadius(1.0f));
723
__anon690b1d5d0f02(float cornerRadius) 724 NotifySetWindowCornerRadiusFunc func = [](float cornerRadius) {
725 return;
726 };
727 session->onSetWindowCornerRadiusFunc_ = func;
728 EXPECT_EQ(WSError::WS_OK, session->SetWindowCornerRadius(1.0f));
729 }
730
731 /**
732 * @tc.name: AddSidebarBlur01
733 * @tc.desc: AddSidebarBlur01
734 * @tc.type: FUNC
735 */
736 HWTEST_F(SceneSessionTest3, AddSidebarBlur01, Function | SmallTest | Level2)
737 {
738 SessionInfo info;
739 info.abilityName_ = "AddSidebarBlur01";
740 info.bundleName_ = "AddSidebarBlur01";
741 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
742 EXPECT_NE(session, nullptr);
743
744 struct RSSurfaceNodeConfig surfaceNodeConfig;
745 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig);
746 EXPECT_EQ(nullptr, session->GetSurfaceNode());
747
748 session->AddSidebarBlur();
749 EXPECT_EQ(nullptr, session->blurRadiusValue_);
750 EXPECT_EQ(nullptr, session->blurSaturationValue_);
751 EXPECT_EQ(nullptr, session->blurBrightnessValue_);
752 EXPECT_EQ(nullptr, session->blurMaskColorValue_);
753
754 session->surfaceNode_ = surfaceNode;
755 EXPECT_NE(nullptr, session->GetSurfaceNode());
756
757 AbilityRuntime::Context::applicationContext_ = std::make_shared<
758 AbilityRuntime::ApplicationContext>();
759 std::shared_ptr<AbilityRuntime::ApplicationContext> appContext =
760 AbilityRuntime::Context::GetApplicationContext();
761 EXPECT_NE(nullptr, appContext);
762
763 appContext->contextImpl_ = std::make_shared<AbilityRuntime::ContextImpl>();
764 appContext->contextImpl_->config_ = std::make_shared<AppExecFwk::Configuration>();
765 std::shared_ptr<AppExecFwk::Configuration> appContextConfig = appContext->GetConfiguration();
766 EXPECT_NE(nullptr, appContextConfig);
767
768 appContextConfig->AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE,
769 AppExecFwk::ConfigurationInner::COLOR_MODE_DARK);
770
771 session->AddSidebarBlur();
772 EXPECT_NE(nullptr, session->blurRadiusValue_);
773 EXPECT_NE(nullptr, session->blurSaturationValue_);
774 EXPECT_NE(nullptr, session->blurBrightnessValue_);
775 EXPECT_NE(nullptr, session->blurMaskColorValue_);
776 }
777
778 /**
779 * @tc.name: AddSidebarBlur02
780 * @tc.desc: AddSidebarBlur02
781 * @tc.type: FUNC
782 */
783 HWTEST_F(SceneSessionTest3, AddSidebarBlur02, Function | SmallTest | Level2)
784 {
785 SessionInfo info;
786 info.abilityName_ = "AddSidebarBlur02";
787 info.bundleName_ = "AddSidebarBlur02";
788 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
789 EXPECT_NE(session, nullptr);
790
791 struct RSSurfaceNodeConfig surfaceNodeConfig;
792 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig);
793 EXPECT_EQ(nullptr, session->GetSurfaceNode());
794
795 session->AddSidebarBlur();
796 EXPECT_EQ(nullptr, session->blurRadiusValue_);
797 EXPECT_EQ(nullptr, session->blurSaturationValue_);
798 EXPECT_EQ(nullptr, session->blurBrightnessValue_);
799 EXPECT_EQ(nullptr, session->blurMaskColorValue_);
800
801 session->surfaceNode_ = surfaceNode;
802 EXPECT_NE(nullptr, session->GetSurfaceNode());
803
804 AbilityRuntime::Context::applicationContext_ = std::make_shared<
805 AbilityRuntime::ApplicationContext>();
806 std::shared_ptr<AbilityRuntime::ApplicationContext> appContext =
807 AbilityRuntime::Context::GetApplicationContext();
808 EXPECT_NE(nullptr, appContext);
809
810 appContext->contextImpl_ = std::make_shared<AbilityRuntime::ContextImpl>();
811 appContext->contextImpl_->config_ = std::make_shared<AppExecFwk::Configuration>();
812 std::shared_ptr<AppExecFwk::Configuration> appContextConfig = appContext->GetConfiguration();
813 EXPECT_NE(nullptr, appContextConfig);
814
815 appContextConfig->AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE,
816 AppExecFwk::ConfigurationInner::COLOR_MODE_LIGHT);
817
818 session->AddSidebarBlur();
819 EXPECT_NE(nullptr, session->blurRadiusValue_);
820 EXPECT_NE(nullptr, session->blurSaturationValue_);
821 EXPECT_NE(nullptr, session->blurBrightnessValue_);
822 EXPECT_NE(nullptr, session->blurMaskColorValue_);
823 }
824
825 /*
826 * @c.name: AddSidebarBlur03
827 * @c.desc: AddSidebarBlur03
828 * @c.type: FUNC
829 */
830 HWTEST_F(SceneSessionTest3, AddSidebarBlur03, Function | SmallTest | Level2)
831 {
832 SessionInfo info;
833 info.abilityName_ = "AddSidebarBlur03";
834 info.bundleName_ = "AddSidebarBlur03";
835 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
836 EXPECT_NE(session, nullptr);
837
838 struct RSSurfaceNodeConfig surfaceNodeConfig;
839 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig);
840 EXPECT_EQ(nullptr, session->GetSurfaceNode());
841 session->surfaceNode_ = surfaceNode;
842 EXPECT_NE(nullptr, session->GetSurfaceNode());
843
844 AbilityRuntime::Context::applicationContext_ = std::make_shared<
845 AbilityRuntime::ApplicationContext>();
846 std::shared_ptr<AbilityRuntime::ApplicationContext> appContext =
847 AbilityRuntime::Context::GetApplicationContext();
848 EXPECT_NE(nullptr, appContext);
849
850 appContext->contextImpl_ = std::make_shared<AbilityRuntime::ContextImpl>();
851 appContext->contextImpl_->config_ = std::make_shared<AppExecFwk::Configuration>();
852 std::shared_ptr<AppExecFwk::Configuration> appContextConfig = appContext->GetConfiguration();
853 EXPECT_NE(nullptr, appContextConfig);
854
855 appContextConfig->AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE,
856 AppExecFwk::ConfigurationInner::COLOR_MODE_DARK);
857
858 session->AddSidebarBlur();
859 float radiusOpenDark = session->blurRadiusValue_->Get();
860 float saturationOpenDark = session->blurSaturationValue_->Get();
861 float brightnessOpenDark = session->blurBrightnessValue_->Get();
862 Rosen::RSColor colorOpenDark = session->blurMaskColorValue_->Get();
863 EXPECT_EQ(SIDEBAR_DEFAULT_RADIUS_DARK, radiusOpenDark);
864 EXPECT_EQ(SIDEBAR_DEFAULT_SATURATION_DARK, saturationOpenDark);
865 EXPECT_EQ(SIDEBAR_DEFAULT_BRIGHTNESS_DARK, brightnessOpenDark);
866 EXPECT_EQ(SIDEBAR_DEFAULT_MASKCOLOR_DARK, colorOpenDark.AsArgbInt());
867 }
868
869 /**
870 * @tc.name: AddSidebarBlur04
871 * @tc.desc: AddSidebarBlur04
872 * @tc.type: FUNC
873 */
874 HWTEST_F(SceneSessionTest3, AddSidebarBlur04, Function | SmallTest | Level2)
875 {
876 SessionInfo info;
877 info.abilityName_ = "AddSidebarBlur04";
878 info.bundleName_ = "AddSidebarBlur04";
879 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
880 EXPECT_NE(session, nullptr);
881
882 struct RSSurfaceNodeConfig surfaceNodeConfig;
883 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig);
884 EXPECT_EQ(nullptr, session->GetSurfaceNode());
885 session->surfaceNode_ = surfaceNode;
886 EXPECT_NE(nullptr, session->GetSurfaceNode());
887
888 AbilityRuntime::Context::applicationContext_ = std::make_shared<
889 AbilityRuntime::ApplicationContext>();
890 std::shared_ptr<AbilityRuntime::ApplicationContext> appContext =
891 AbilityRuntime::Context::GetApplicationContext();
892 EXPECT_NE(nullptr, appContext);
893
894 appContext->contextImpl_ = std::make_shared<AbilityRuntime::ContextImpl>();
895 appContext->contextImpl_->config_ = std::make_shared<AppExecFwk::Configuration>();
896 std::shared_ptr<AppExecFwk::Configuration> appContextConfig = appContext->GetConfiguration();
897 EXPECT_NE(nullptr, appContextConfig);
898
899 appContextConfig->AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE,
900 AppExecFwk::ConfigurationInner::COLOR_MODE_LIGHT);
901
902 session->AddSidebarBlur();
903 float radiusOpenLight = session->blurRadiusValue_->Get();
904 float saturationOpenLight = session->blurSaturationValue_->Get();
905 float brightnessOpenLight = session->blurBrightnessValue_->Get();
906 Rosen::RSColor colorOpenLight = session->blurMaskColorValue_->Get();
907 EXPECT_EQ(SIDEBAR_DEFAULT_RADIUS_LIGHT, radiusOpenLight);
908 EXPECT_EQ(SIDEBAR_DEFAULT_SATURATION_LIGHT, saturationOpenLight);
909 EXPECT_EQ(SIDEBAR_DEFAULT_BRIGHTNESS_LIGHT, brightnessOpenLight);
910 EXPECT_EQ(SIDEBAR_DEFAULT_MASKCOLOR_LIGHT, colorOpenLight.AsArgbInt());
911 }
912
913 /**
914 * @tc.name: SetSidebarBlur01
915 * @tc.desc: SetSidebarBlur01
916 * @tc.type: FUNC
917 */
918 HWTEST_F(SceneSessionTest3, SetSidebarBlur01, Function | SmallTest | Level2)
919 {
920 SessionInfo info;
921 info.abilityName_ = "SetSidebarBlur01";
922 info.bundleName_ = "SetSidebarBlur01";
923 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
924 EXPECT_NE(session, nullptr);
925
926 struct RSSurfaceNodeConfig surfaceNodeConfig;
927 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig);
928 EXPECT_EQ(nullptr, session->GetSurfaceNode());
929
930 session->AddSidebarBlur();
931 EXPECT_EQ(nullptr, session->blurRadiusValue_);
932 EXPECT_EQ(nullptr, session->blurSaturationValue_);
933 EXPECT_EQ(nullptr, session->blurBrightnessValue_);
934 EXPECT_EQ(nullptr, session->blurMaskColorValue_);
935
936 session->surfaceNode_ = surfaceNode;
937 EXPECT_NE(nullptr, session->GetSurfaceNode());
938
939 AbilityRuntime::Context::applicationContext_ = std::make_shared<
940 AbilityRuntime::ApplicationContext>();
941 std::shared_ptr<AbilityRuntime::ApplicationContext> appContext =
942 AbilityRuntime::Context::GetApplicationContext();
943 EXPECT_NE(nullptr, appContext);
944
945 appContext->contextImpl_ = std::make_shared<AbilityRuntime::ContextImpl>();
946 appContext->contextImpl_->config_ = std::make_shared<AppExecFwk::Configuration>();
947 std::shared_ptr<AppExecFwk::Configuration> appContextConfig = appContext->GetConfiguration();
948 EXPECT_NE(nullptr, appContextConfig);
949
950 appContextConfig->AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE,
951 AppExecFwk::ConfigurationInner::COLOR_MODE_DARK);
952
953 session->AddSidebarBlur();
954 EXPECT_NE(nullptr, session->blurRadiusValue_);
955 EXPECT_NE(nullptr, session->blurSaturationValue_);
956 EXPECT_NE(nullptr, session->blurBrightnessValue_);
957 EXPECT_NE(nullptr, session->blurMaskColorValue_);
958 }
959
960 /**
961 * @tc.name: SetSidebarBlur02
962 * @tc.desc: SetSidebarBlur02
963 * @tc.type: FUNC
964 */
965 HWTEST_F(SceneSessionTest3, SetSidebarBlur02, Function | SmallTest | Level2)
966 {
967 SessionInfo info;
968 info.abilityName_ = "SetSidebarBlur02";
969 info.bundleName_ = "SetSidebarBlur02";
970 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
971 EXPECT_NE(session, nullptr);
972
973 struct RSSurfaceNodeConfig surfaceNodeConfig;
974 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig);
975 EXPECT_EQ(nullptr, session->GetSurfaceNode());
976
977 session->AddSidebarBlur();
978 EXPECT_EQ(nullptr, session->blurRadiusValue_);
979 EXPECT_EQ(nullptr, session->blurSaturationValue_);
980 EXPECT_EQ(nullptr, session->blurBrightnessValue_);
981 EXPECT_EQ(nullptr, session->blurMaskColorValue_);
982
983 session->surfaceNode_ = surfaceNode;
984 EXPECT_NE(nullptr, session->GetSurfaceNode());
985
986 AbilityRuntime::Context::applicationContext_ = std::make_shared<
987 AbilityRuntime::ApplicationContext>();
988 std::shared_ptr<AbilityRuntime::ApplicationContext> appContext =
989 AbilityRuntime::Context::GetApplicationContext();
990 EXPECT_NE(nullptr, appContext);
991
992 appContext->contextImpl_ = std::make_shared<AbilityRuntime::ContextImpl>();
993 appContext->contextImpl_->config_ = std::make_shared<AppExecFwk::Configuration>();
994 std::shared_ptr<AppExecFwk::Configuration> appContextConfig = appContext->GetConfiguration();
995 EXPECT_NE(nullptr, appContextConfig);
996
997 appContextConfig->AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE,
998 AppExecFwk::ConfigurationInner::COLOR_MODE_LIGHT);
999
1000 session->AddSidebarBlur();
1001 EXPECT_NE(nullptr, session->blurRadiusValue_);
1002 EXPECT_NE(nullptr, session->blurSaturationValue_);
1003 EXPECT_NE(nullptr, session->blurBrightnessValue_);
1004 EXPECT_NE(nullptr, session->blurMaskColorValue_);
1005 }
1006
1007 /**
1008 * @tc.name: SetSidebarBlur03
1009 * @tc.desc: SetSidebarBlur03
1010 * @tc.type: FUNC
1011 */
1012 HWTEST_F(SceneSessionTest3, SetSidebarBlur03, Function | SmallTest | Level2)
1013 {
1014 SessionInfo info;
1015 info.abilityName_ = "SetSidebarBlur03";
1016 info.bundleName_ = "SetSidebarBlur03";
1017 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1018 EXPECT_NE(session, nullptr);
1019
1020 struct RSSurfaceNodeConfig surfaceNodeConfig;
1021 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig);
1022 EXPECT_EQ(nullptr, session->GetSurfaceNode());
1023 session->surfaceNode_ = surfaceNode;
1024 EXPECT_NE(nullptr, session->GetSurfaceNode());
1025
1026 AbilityRuntime::Context::applicationContext_ = std::make_shared<
1027 AbilityRuntime::ApplicationContext>();
1028 std::shared_ptr<AbilityRuntime::ApplicationContext> appContext =
1029 AbilityRuntime::Context::GetApplicationContext();
1030 EXPECT_NE(nullptr, appContext);
1031
1032 appContext->contextImpl_ = std::make_shared<AbilityRuntime::ContextImpl>();
1033 appContext->contextImpl_->config_ = std::make_shared<AppExecFwk::Configuration>();
1034 std::shared_ptr<AppExecFwk::Configuration> appContextConfig = appContext->GetConfiguration();
1035 EXPECT_NE(nullptr, appContextConfig);
1036
1037 appContextConfig->AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE,
1038 AppExecFwk::ConfigurationInner::COLOR_MODE_DARK);
1039
1040 session->AddSidebarBlur();
1041 session->SetSidebarBlur(false);
1042 float radiusCloseDark = session->blurRadiusValue_->Get();
1043 float saturationCloseDark = session->blurSaturationValue_->Get();
1044 float brightnessCloseDark = session->blurBrightnessValue_->Get();
1045 Rosen::RSColor colorCloseDark = session->blurMaskColorValue_->Get();
1046 EXPECT_EQ(SIDEBAR_BLUR_NUMBER_ZERO, radiusCloseDark);
1047 EXPECT_EQ(SIDEBAR_BLUR_NUMBER_ZERO, saturationCloseDark);
1048 EXPECT_EQ(SIDEBAR_BLUR_NUMBER_ZERO, brightnessCloseDark);
1049 EXPECT_EQ(SIDEBAR_SNAPSHOT_MASKCOLOR_DARK, colorCloseDark.AsArgbInt());
1050
1051 session->SetSidebarBlur(true);
1052 float radiusOpenDark = session->blurRadiusValue_->Get();
1053 float saturationOpenDark = session->blurSaturationValue_->Get();
1054 float brightnessOpenDark = session->blurBrightnessValue_->Get();
1055 Rosen::RSColor colorOpenDark = session->blurMaskColorValue_->Get();
1056 EXPECT_EQ(SIDEBAR_DEFAULT_RADIUS_DARK, radiusOpenDark);
1057 EXPECT_EQ(SIDEBAR_DEFAULT_SATURATION_DARK, saturationOpenDark);
1058 EXPECT_EQ(SIDEBAR_DEFAULT_BRIGHTNESS_DARK, brightnessOpenDark);
1059 EXPECT_EQ(SIDEBAR_DEFAULT_MASKCOLOR_DARK, colorOpenDark.AsArgbInt());
1060 }
1061
1062 /**
1063 * @tc.name: SetSidebarBlur04
1064 * @tc.desc: SetSidebarBlur04
1065 * @tc.type: FUNC
1066 */
1067 HWTEST_F(SceneSessionTest3, SetSidebarBlur04, Function | SmallTest | Level2)
1068 {
1069 SessionInfo info;
1070 info.abilityName_ = "SetSidebarBlur04";
1071 info.bundleName_ = "SetSidebarBlur04";
1072 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1073 EXPECT_NE(session, nullptr);
1074
1075 struct RSSurfaceNodeConfig surfaceNodeConfig;
1076 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig);
1077 EXPECT_EQ(nullptr, session->GetSurfaceNode());
1078 session->surfaceNode_ = surfaceNode;
1079 EXPECT_NE(nullptr, session->GetSurfaceNode());
1080
1081 AbilityRuntime::Context::applicationContext_ = std::make_shared<
1082 AbilityRuntime::ApplicationContext>();
1083 std::shared_ptr<AbilityRuntime::ApplicationContext> appContext =
1084 AbilityRuntime::Context::GetApplicationContext();
1085 EXPECT_NE(nullptr, appContext);
1086
1087 appContext->contextImpl_ = std::make_shared<AbilityRuntime::ContextImpl>();
1088 appContext->contextImpl_->config_ = std::make_shared<AppExecFwk::Configuration>();
1089 std::shared_ptr<AppExecFwk::Configuration> appContextConfig = appContext->GetConfiguration();
1090 EXPECT_NE(nullptr, appContextConfig);
1091
1092 appContextConfig->AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE,
1093 AppExecFwk::ConfigurationInner::COLOR_MODE_LIGHT);
1094
1095 session->AddSidebarBlur();
1096 session->SetSidebarBlur(false);
1097 float radiusCloseLight = session->blurRadiusValue_->Get();
1098 float saturationCloseLight = session->blurSaturationValue_->Get();
1099 float brightnessCloseLight = session->blurBrightnessValue_->Get();
1100 Rosen::RSColor colorCloseLight = session->blurMaskColorValue_->Get();
1101 EXPECT_EQ(SIDEBAR_BLUR_NUMBER_ZERO, radiusCloseLight);
1102 EXPECT_EQ(SIDEBAR_BLUR_NUMBER_ZERO, saturationCloseLight);
1103 EXPECT_EQ(SIDEBAR_BLUR_NUMBER_ZERO, brightnessCloseLight);
1104 EXPECT_EQ(SIDEBAR_SNAPSHOT_MASKCOLOR_LIGHT, colorCloseLight.AsArgbInt());
1105
1106 session->SetSidebarBlur(true);
1107 float radiusOpenLight = session->blurRadiusValue_->Get();
1108 float saturationOpenLight = session->blurSaturationValue_->Get();
1109 float brightnessOpenLight = session->blurBrightnessValue_->Get();
1110 Rosen::RSColor colorOpenLight = session->blurMaskColorValue_->Get();
1111 EXPECT_EQ(SIDEBAR_DEFAULT_RADIUS_LIGHT, radiusOpenLight);
1112 EXPECT_EQ(SIDEBAR_DEFAULT_SATURATION_LIGHT, saturationOpenLight);
1113 EXPECT_EQ(SIDEBAR_DEFAULT_BRIGHTNESS_LIGHT, brightnessOpenLight);
1114 EXPECT_EQ(SIDEBAR_DEFAULT_MASKCOLOR_LIGHT, colorOpenLight.AsArgbInt());
1115 }
1116
1117 /**
1118 * @tc.name: AddExtensionTokenInfo
1119 * @tc.desc: AddExtensionTokenInfo
1120 * @tc.type: FUNC
1121 */
1122 HWTEST_F(SceneSessionTest3, AddExtensionTokenInfo, Function | SmallTest | Level2)
1123 {
1124 UIExtensionTokenInfo tokenInfo;
1125 tokenInfo.abilityToken = nullptr;
1126 SessionInfo info;
1127 info.abilityName_ = "AddExtensionTokenInfo";
1128 info.bundleName_ = "AddExtensionTokenInfo";
1129 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1130
1131 sceneSession->AddExtensionTokenInfo(tokenInfo);
1132 EXPECT_NE(sceneSession, nullptr);
1133 }
1134
1135 /**
1136 * @tc.name: RemoveExtensionTokenInfo
1137 * @tc.desc: RemoveExtensionTokenInfo
1138 * @tc.type: FUNC
1139 */
1140 HWTEST_F(SceneSessionTest3, RemoveExtensionTokenInfo, Function | SmallTest | Level2)
1141 {
1142 UIExtensionTokenInfo tokenInfo;
1143 tokenInfo.abilityToken = nullptr;
1144 SessionInfo info;
1145 info.abilityName_ = "RemoveExtensionTokenInfo";
1146 info.bundleName_ = "RemoveExtensionTokenInfo";
1147 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1148
1149 auto res = sceneSession->extensionTokenInfos_.size();
1150 sceneSession->RemoveExtensionTokenInfo(tokenInfo.abilityToken);
1151 EXPECT_EQ(sceneSession->extensionTokenInfos_.size() <= res, true);
1152 }
1153
1154 /**
1155 * @tc.name: OnNotifyAboveLockScreen
1156 * @tc.desc: OnNotifyAboveLockScreen
1157 * @tc.type: FUNC
1158 */
1159 HWTEST_F(SceneSessionTest3, OnNotifyAboveLockScreen, Function | SmallTest | Level2)
1160 {
1161 SessionInfo info;
1162 info.abilityName_ = "OnNotifyAboveLockScreen";
1163 info.bundleName_ = "OnNotifyAboveLockScreen";
1164 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1165
1166 sceneSession->OnNotifyAboveLockScreen();
1167 EXPECT_NE(sceneSession, nullptr);
1168 sceneSession->CheckExtensionOnLockScreenToClose();
1169 EXPECT_NE(sceneSession, nullptr);
1170 }
1171
1172 /**
1173 * @tc.name: CloseExtensionSync
1174 * @tc.desc: CloseExtensionSync
1175 * @tc.type: FUNC
1176 */
1177 HWTEST_F(SceneSessionTest3, CloseExtensionSync, Function | SmallTest | Level2)
1178 {
1179 UIExtensionTokenInfo tokenInfo;
1180 tokenInfo.abilityToken = nullptr;
1181 SessionInfo info;
1182 info.abilityName_ = "CloseExtensionSync";
1183 info.bundleName_ = "CloseExtensionSync";
1184 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1185
1186 sceneSession->CloseExtensionSync(tokenInfo);
1187 EXPECT_NE(sceneSession, nullptr);
1188 }
1189
1190 /**
1191 * @tc.name: SetIsStatusBarVisible
1192 * @tc.desc: SetIsStatusBarVisible
1193 * @tc.type: FUNC
1194 */
1195 HWTEST_F(SceneSessionTest3, SetIsStatusBarVisible, Function | SmallTest | Level2)
1196 {
1197 bool isVisible = true;
1198 SessionInfo info;
1199 info.abilityName_ = "SetIsStatusBarVisible";
1200 info.bundleName_ = "SetIsStatusBarVisible";
1201 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1202
1203 sceneSession->SetIsStatusBarVisible(isVisible);
1204 EXPECT_NE(sceneSession, nullptr);
1205 }
1206
1207 /**
1208 * @tc.name: GetAllAvoidAreas
1209 * @tc.desc: GetAllAvoidAreas
1210 * @tc.type: FUNC
1211 */
1212 HWTEST_F(SceneSessionTest3, GetAllAvoidAreas, Function | SmallTest | Level2)
1213 {
1214 std::map<AvoidAreaType, AvoidArea> avoidAreas;
1215 SessionInfo info;
1216 info.abilityName_ = "GetAllAvoidAreas";
1217 info.bundleName_ = "GetAllAvoidAreas";
1218 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1219
1220 auto res = sceneSession->GetAllAvoidAreas(avoidAreas);
1221 EXPECT_EQ(res, WSError::WS_OK);
1222 }
1223
1224 /**
1225 * @tc.name: NotifyPipWindowSizeChange
1226 * @tc.desc: NotifyPipWindowSizeChange
1227 * @tc.type: FUNC
1228 */
1229 HWTEST_F(SceneSessionTest3, NotifyPipWindowSizeChange, Function | SmallTest | Level2)
1230 {
1231 double width = 10;
1232 double height = 10;
1233 double scale = 10;
1234 SessionInfo info;
1235 info.abilityName_ = "NotifyPipWindowSizeChange";
1236 info.bundleName_ = "NotifyPipWindowSizeChange";
1237 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1238
1239 auto res = sceneSession->NotifyPipWindowSizeChange(width, height, scale);
1240 EXPECT_EQ(res, WSError::WS_ERROR_NULLPTR);
1241 }
1242
1243 /**
1244 * @tc.name: SendPointEventForMoveDrag
1245 * @tc.desc: SendPointEventForMoveDrag
1246 * @tc.type: FUNC
1247 */
1248 HWTEST_F(SceneSessionTest3, SendPointEventForMoveDrag, Function | SmallTest | Level2)
1249 {
1250 std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
1251 bool isExecuteDelayRaise = true;
1252 SessionInfo info;
1253 info.abilityName_ = "SendPointEventForMoveDrag";
1254 info.bundleName_ = "SendPointEventForMoveDrag";
1255 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1256
1257 auto res = sceneSession->SendPointEventForMoveDrag(pointerEvent, isExecuteDelayRaise);
1258 EXPECT_EQ(res, WSError::WS_OK);
1259 }
1260
1261 /**
1262 * @tc.name: DisallowActivationFromPendingBackground
1263 * @tc.desc: DisallowActivationFromPendingBackground
1264 * @tc.type: FUNC
1265 */
1266 HWTEST_F(SceneSessionTest3, DisallowActivationFromPendingBackground, Function | SmallTest | Level2)
1267 {
1268 SessionInfo info;
1269 info.abilityName_ = "DisallowActivationFromPendingBackground";
1270 info.bundleName_ = "DisallowActivationFromPendingBackground";
1271 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1272
1273 auto res = sceneSession->DisallowActivationFromPendingBackground(true, true, true, true);
1274 EXPECT_EQ(res, false);
1275 }
1276
1277 /**
1278 * @tc.name: UpdateFullScreenWaterfallMode
1279 * @tc.desc: UpdateFullScreenWaterfallMode
1280 * @tc.type: FUNC
1281 */
1282 HWTEST_F(SceneSessionTest3, UpdateFullScreenWaterfallMode, Function | SmallTest | Level2)
1283 {
1284 bool isWaterfallMode = true;
1285 SessionInfo info;
1286 info.abilityName_ = "UpdateFullScreenWaterfallMode";
1287 info.bundleName_ = "UpdateFullScreenWaterfallMode";
1288 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1289
1290 sceneSession->UpdateFullScreenWaterfallMode(isWaterfallMode);
1291 EXPECT_NE(sceneSession, nullptr);
1292 }
1293
1294 /**
1295 * @tc.name: RegisterFullScreenWaterfallModeChangeCallback
1296 * @tc.desc: RegisterFullScreenWaterfallModeChangeCallback
1297 * @tc.type: FUNC
1298 */
1299 HWTEST_F(SceneSessionTest3, RegisterFullScreenWaterfallModeChangeCallback, Function | SmallTest | Level2)
1300 {
1301 SessionInfo info;
1302 info.abilityName_ = "RegisterFullScreenWaterfallModeChangeCallback";
1303 info.bundleName_ = "RegisterFullScreenWaterfallModeChangeCallback";
1304 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1305
__anon690b1d5d1002(bool isWaterfallMode) 1306 std::function<void(bool isWaterfallMode)> func = [](bool isWaterfallMode) {
1307 return;
1308 };
1309 sceneSession->RegisterFullScreenWaterfallModeChangeCallback(std::move(func));
1310 EXPECT_NE(sceneSession, nullptr);
1311 }
1312
1313 /**
1314 * @tc.name: RegisterThrowSlipAnimationStateChangeCallback
1315 * @tc.desc: RegisterThrowSlipAnimationStateChangeCallback
1316 * @tc.type: FUNC
1317 */
1318 HWTEST_F(SceneSessionTest3, RegisterThrowSlipAnimationStateChangeCallback, Function | SmallTest | Level2)
1319 {
1320 SessionInfo info;
1321 info.abilityName_ = "RegisterThrowSlipAnimationStateChangeCallback";
1322 info.bundleName_ = "RegisterThrowSlipAnimationStateChangeCallback";
1323 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1324
__anon690b1d5d1102(bool isAnimating) 1325 std::function<void(bool isAnimating)> func = [](bool isAnimating) {
1326 return;
1327 };
1328 sceneSession->RegisterThrowSlipAnimationStateChangeCallback(std::move(func));
1329 EXPECT_NE(sceneSession, nullptr);
1330 }
1331
1332 /**
1333 * @tc.name: MaskSupportEnterWaterfallMode
1334 * @tc.desc: MaskSupportEnterWaterfallMode
1335 * @tc.type: FUNC
1336 */
1337 HWTEST_F(SceneSessionTest3, MaskSupportEnterWaterfallMode, Function | SmallTest | Level2)
1338 {
1339 SessionInfo info;
1340 info.abilityName_ = "MaskSupportEnterWaterfallMode";
1341 info.bundleName_ = "MaskSupportEnterWaterfallMode";
1342 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1343
1344 sceneSession->MaskSupportEnterWaterfallMode();
1345 EXPECT_NE(sceneSession, nullptr);
1346 sceneSession->pcFoldScreenController_ = nullptr;
1347 sceneSession->MaskSupportEnterWaterfallMode();
1348 EXPECT_NE(sceneSession, nullptr);
1349 }
1350
1351 /**
1352 * @tc.name: HandleActionUpdateMainWindowTopmost
1353 * @tc.desc: HandleActionUpdateMainWindowTopmost
1354 * @tc.type: FUNC
1355 */
1356 HWTEST_F(SceneSessionTest3, HandleActionUpdateMainWindowTopmost, Function | SmallTest | Level2)
1357 {
1358 WSPropertyChangeAction action = WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS;
1359 SessionInfo info;
1360 info.abilityName_ = "HandleActionUpdateMainWindowTopmost";
1361 info.bundleName_ = "HandleActionUpdateMainWindowTopmost";
1362 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1363 sptr<WindowSessionProperty> windowSessionProperty = sptr<WindowSessionProperty>::MakeSptr();
1364 sceneSession->property_ = windowSessionProperty;
1365
1366 auto res = sceneSession->HandleActionUpdateMainWindowTopmost(windowSessionProperty, action);
1367 EXPECT_EQ(res, WMError::WM_OK);
1368 }
1369
1370 /**
1371 * @tc.name: HandleActionUpdateSubWindowZLevel
1372 * @tc.desc: HandleActionUpdateSubWindowZLevel
1373 * @tc.type: FUNC
1374 */
1375 HWTEST_F(SceneSessionTest3, HandleActionUpdateSubWindowZLevel, Function | SmallTest | Level2)
1376 {
1377 WSPropertyChangeAction action = WSPropertyChangeAction::ACTION_UPDATE_SUB_WINDOW_Z_LEVEL;
1378 SessionInfo info;
1379 info.abilityName_ = "HandleActionUpdateSubWindowZLevel";
1380 info.bundleName_ = "HandleActionUpdateSubWindowZLevel";
1381 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1382 sptr<WindowSessionProperty> windowSessionProperty = sptr<WindowSessionProperty>::MakeSptr();
1383 sceneSession->property_ = windowSessionProperty;
1384
1385 auto res = sceneSession->HandleActionUpdateSubWindowZLevel(windowSessionProperty, action);
1386 EXPECT_EQ(res, WMError::WM_OK);
1387 }
1388
1389 /**
1390 * @tc.name: HandleBackgroundAlpha
1391 * @tc.desc: HandleBackgroundAlpha
1392 * @tc.type: FUNC
1393 */
1394 HWTEST_F(SceneSessionTest3, HandleBackgroundAlpha, Function | SmallTest | Level2)
1395 {
1396 WSPropertyChangeAction action = WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS;
1397 SessionInfo info;
1398 info.abilityName_ = "HandleBackgroundAlpha";
1399 info.bundleName_ = "HandleBackgroundAlpha";
1400 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1401 sptr<WindowSessionProperty> windowSessionProperty = sptr<WindowSessionProperty>::MakeSptr();
1402 sceneSession->property_ = windowSessionProperty;
1403
1404 auto res = sceneSession->HandleBackgroundAlpha(windowSessionProperty, action);
1405 EXPECT_EQ(res, WMError::WM_OK);
1406 }
1407
1408 /**
1409 * @tc.name: SendContainerModalEvent
1410 * @tc.desc: SendContainerModalEvent
1411 * @tc.type: FUNC
1412 */
1413 HWTEST_F(SceneSessionTest3, SendContainerModalEvent, Function | SmallTest | Level2)
1414 {
1415 string eventName = "test";
1416 string eventValue = "test";
1417 SessionInfo info;
1418 info.abilityName_ = "SendContainerModalEvent";
1419 info.bundleName_ = "SendContainerModalEvent";
1420 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1421 sceneSession->sessionStage_ = sptr<SessionStageMocker>::MakeSptr();
1422
1423 auto res = sceneSession->SendContainerModalEvent(eventName, eventValue);
1424 EXPECT_EQ(res, sceneSession->sessionStage_->SendContainerModalEvent(eventName, eventValue));
1425 }
1426
1427 /**
1428 * @tc.name: RegisterSetLandscapeMultiWindowFunc
1429 * @tc.desc: RegisterSetLandscapeMultiWindowFunc
1430 * @tc.type: FUNC
1431 */
1432 HWTEST_F(SceneSessionTest3, RegisterSetLandscapeMultiWindowFunc, Function | SmallTest | Level2)
1433 {
1434 SessionInfo info;
1435 info.abilityName_ = "RegisterSetLandscapeMultiWindowFunc";
1436 info.bundleName_ = "RegisterSetLandscapeMultiWindowFunc";
1437 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1438
__anon690b1d5d1202(bool isLandscapeMultiWindow) 1439 std::function<void(bool isLandscapeMultiWindow)> func = [](bool isLandscapeMultiWindow) {
1440 return;
1441 };
1442 sceneSession->RegisterSetLandscapeMultiWindowFunc(std::move(func));
1443 EXPECT_NE(sceneSession, nullptr);
1444 }
1445
1446 /**
1447 * @tc.name: IsDirtyDragWindow
1448 * @tc.desc: IsDirtyDragWindow
1449 * @tc.type: FUNC
1450 */
1451 HWTEST_F(SceneSessionTest3, IsDirtyDragWindow, Function | SmallTest | Level2)
1452 {
1453 SessionInfo info;
1454 info.abilityName_ = "IsDirtyDragWindow";
1455 info.bundleName_ = "IsDirtyDragWindow";
1456 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1457 sceneSession->dirtyFlags_ = 0;
1458
1459 auto res = sceneSession->IsDirtyDragWindow();
1460 EXPECT_EQ(res, sceneSession->dirtyFlags_
1461 & static_cast<uint32_t>(SessionUIDirtyFlag::DRAG_RECT) || sceneSession->isDragging_);
1462 }
1463
1464 /**
1465 * @tc.name: RequestHideKeyboard
1466 * @tc.desc: RequestHideKeyboard
1467 * @tc.type: FUNC
1468 */
1469 HWTEST_F(SceneSessionTest3, RequestHideKeyboard, Function | SmallTest | Level2)
1470 {
1471 bool isAppColdStart = true;
1472 SessionInfo info;
1473 info.abilityName_ = "RequestHideKeyboard";
1474 info.bundleName_ = "RequestHideKeyboard";
1475 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1476
1477 sceneSession->RequestHideKeyboard(isAppColdStart);
1478 EXPECT_NE(sceneSession, nullptr);
1479 }
1480
1481 /**
1482 * @tc.name: SetStartingWindowExitAnimationFlag
1483 * @tc.desc: SetStartingWindowExitAnimationFlag
1484 * @tc.type: FUNC
1485 */
1486 HWTEST_F(SceneSessionTest3, SetStartingWindowExitAnimationFlag, Function | SmallTest | Level2)
1487 {
1488 bool enable = true;
1489 SessionInfo info;
1490 info.abilityName_ = "SetStartingWindowExitAnimationFlag";
1491 info.bundleName_ = "SetStartingWindowExitAnimationFlag";
1492 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1493
1494 sceneSession->SetStartingWindowExitAnimationFlag(enable);
1495 EXPECT_NE(sceneSession, nullptr);
1496 }
1497
1498 /**
1499 * @tc.name: SetSkipSelfWhenShowOnVirtualScreen
1500 * @tc.desc: SetSkipSelfWhenShowOnVirtualScreen
1501 * @tc.type: FUNC
1502 */
1503 HWTEST_F(SceneSessionTest3, SetSkipSelfWhenShowOnVirtualScreen, Function | SmallTest | Level2)
1504 {
1505 bool isSkip = true;
1506 SessionInfo info;
1507 info.abilityName_ = "SetSkipSelfWhenShowOnVirtualScreen";
1508 info.bundleName_ = "SetSkipSelfWhenShowOnVirtualScreen";
1509 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1510
1511 sceneSession->SetSkipSelfWhenShowOnVirtualScreen(isSkip);
1512 EXPECT_NE(sceneSession, nullptr);
1513 }
1514
1515 /**
1516 * @tc.name: RegisterRequestedOrientationChangeCallback
1517 * @tc.desc: RegisterRequestedOrientationChangeCallback
1518 * @tc.type: FUNC
1519 */
1520 HWTEST_F(SceneSessionTest3, RegisterRequestedOrientationChangeCallback, Function | SmallTest | Level2)
1521 {
1522 SessionInfo info;
1523 info.abilityName_ = "RegisterRequestedOrientationChangeCallback";
1524 info.bundleName_ = "RegisterRequestedOrientationChangeCallback";
1525 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1526
__anon690b1d5d1302(uint32_t orientation) 1527 std::function<void(uint32_t orientation)> func = [](uint32_t orientation) {
1528 return;
1529 };
1530 sceneSession->RegisterRequestedOrientationChangeCallback(std::move(func));
1531 EXPECT_NE(sceneSession, nullptr);
1532 }
1533
1534 /**
1535 * @tc.name: IsShowOnLockScreen
1536 * @tc.desc: IsShowOnLockScreen
1537 * @tc.type: FUNC
1538 */
1539 HWTEST_F(SceneSessionTest3, IsShowOnLockScreen, Function | SmallTest | Level2)
1540 {
1541 SessionInfo info;
1542 info.abilityName_ = "IsShowOnLockScreen";
1543 info.bundleName_ = "IsShowOnLockScreen";
1544 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1545 sceneSession->SetZOrder(2005);
1546 sceneSession->GetSessionProperty()->SetDisplayId(-2);
1547 EXPECT_FALSE(sceneSession->IsShowOnLockScreen(2000));
1548 sceneSession->GetSessionProperty()->SetDisplayId(-1);
1549 EXPECT_TRUE(sceneSession->IsShowOnLockScreen(2000));
1550
1551 sceneSession->SetZOrder(0);
1552 sceneSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1553 EXPECT_FALSE(sceneSession->IsShowOnLockScreen(2000));
1554
1555 sptr<SceneSession> parentSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1556 parentSession->SetZOrder(2004);
1557 sceneSession->parentSession_ = parentSession;
1558 EXPECT_TRUE(sceneSession->IsShowOnLockScreen(2000));
1559
1560 sceneSession->SetZOrder(1000);
1561 EXPECT_FALSE(sceneSession->IsShowOnLockScreen(2000));
1562
1563 sceneSession->property_ = nullptr;
1564 EXPECT_FALSE(sceneSession->IsShowOnLockScreen(2000));
1565 }
1566
1567 /**
1568 * @tc.name: NotifySetParentSession
1569 * @tc.desc: NotifySetParentSession
1570 * @tc.type: FUNC
1571 */
1572 HWTEST_F(SceneSessionTest3, NotifySetParentSession, Function | SmallTest | Level2)
1573 {
1574 SessionInfo info;
1575 info.abilityName_ = "NotifySetParentSession";
1576 info.bundleName_ = "NotifySetParentSession";
1577 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1578 int32_t oldParentWindowId = 1;
1579 int32_t newParentWindowId = 2;
1580 auto res = sceneSession->NotifySetParentSession(oldParentWindowId, newParentWindowId);
1581 EXPECT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW);
1582 }
1583
1584 /**
1585 * @tc.name: UpdateSubWindowLevel
1586 * @tc.desc: UpdateSubWindowLevel
1587 * @tc.type: FUNC
1588 */
1589 HWTEST_F(SceneSessionTest3, UpdateSubWindowLevel, Function | SmallTest | Level2)
1590 {
1591 SessionInfo info;
1592 info.abilityName_ = "UpdateSubWindowLevel";
1593 info.bundleName_ = "UpdateSubWindowLevel";
1594 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1595 uint32_t subWindowLevel = 10;
1596 EXPECT_NE(subWindowLevel, sceneSession->GetSessionProperty()->GetSubWindowLevel());
1597 sceneSession->UpdateSubWindowLevel(subWindowLevel);
1598 EXPECT_EQ(subWindowLevel, sceneSession->GetSessionProperty()->GetSubWindowLevel());
1599 }
1600
1601 /**
1602 * @tc.name: GetMaxSubWindowLevel
1603 * @tc.desc: GetMaxSubWindowLevel
1604 * @tc.type: FUNC
1605 */
1606 HWTEST_F(SceneSessionTest3, GetMaxSubWindowLevel, Function | SmallTest | Level2)
1607 {
1608 SessionInfo info;
1609 info.abilityName_ = "GetMaxSubWindowLevel";
1610 info.bundleName_ = "GetMaxSubWindowLevel";
1611 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1612 EXPECT_EQ(1, sceneSession->GetMaxSubWindowLevel());
1613 }
1614
1615 /**
1616 * @tc.name: NotifyUpdateFlagCallback
1617 * @tc.desc: NotifyUpdateFlagCallback
1618 * @tc.type: FUNC
1619 */
1620 HWTEST_F(SceneSessionTest3, NotifyUpdateFlagCallback, Function | SmallTest | Level2)
1621 {
1622 SessionInfo info;
1623 info.abilityName_ = "NotifyUpdateFlagCallback";
1624 info.bundleName_ = "NotifyUpdateFlagCallback";
1625 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1626
__anon690b1d5d1402(const std::string& flag) 1627 NotifyUpdateFlagFunc func1 = [](const std::string& flag) {
1628 return;
1629 };
1630 sceneSession->NotifyUpdateFlagCallback(std::move(func1));
1631 ASSERT_NE(nullptr, sceneSession->onUpdateFlagFunc_);
1632 }
1633 }
1634 }
1635 }