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 "display_manager.h"
19 #include "input_event.h"
20 #include "key_event.h"
21 #include "mock/mock_session_stage.h"
22 #include "pointer_event.h"
23
24 #include "session/host/include/main_session.h"
25 #include "session/host/include/scene_session.h"
26 #include "session/host/include/sub_session.h"
27 #include "session/host/include/system_session.h"
28 #include "screen_session_manager_client/include/screen_session_manager_client.h"
29 #include "window_helper.h"
30 #include "wm_common.h"
31 #include "ui/rs_surface_node.h"
32
33
34 using namespace testing;
35 using namespace testing::ext;
36 namespace OHOS {
37 namespace Rosen {
38 class SceneSessionTest4 : public testing::Test {
39 public:
40 static void SetUpTestCase();
41 static void TearDownTestCase();
42 void SetUp() override;
43 void TearDown() override;
44 sptr<SceneSession> sceneSession;
45 sptr<WindowSessionProperty> property;
46 SessionInfo info;
47 WSPropertyChangeAction action;
48 private:
49 std::shared_ptr<AppExecFwk::EventHandler> handler_ = nullptr;
50 static constexpr uint32_t WAIT_SYNC_IN_NS = 200000;
51 };
52
SetUpTestCase()53 void SceneSessionTest4::SetUpTestCase()
54 {
55 }
56
TearDownTestCase()57 void SceneSessionTest4::TearDownTestCase()
58 {
59 }
60
SetUp()61 void SceneSessionTest4::SetUp()
62 {
63 sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
64 property = sptr<WindowSessionProperty>::MakeSptr();
65 action = WSPropertyChangeAction::ACTION_UPDATE_ASPECT_RATIO;
66 if (!handler_) {
67 auto runner = AppExecFwk::EventRunner::Create("SceneSessionTest");
68 handler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
69 }
70 sceneSession->SetEventHandler(handler_, nullptr);
71 }
72
TearDown()73 void SceneSessionTest4::TearDown()
74 {
75 }
76
77 namespace {
78 /**
79 * @tc.name: HandleActionUpdateFlags
80 * @tc.desc: normal function
81 * @tc.type: FUNC
82 */
83 HWTEST_F(SceneSessionTest4, HandleActionUpdateFlags, TestSize.Level1)
84 {
85 SessionInfo info;
86 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
87 ASSERT_NE(nullptr, sceneSession);
88 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
89 ASSERT_NE(nullptr, property);
90 WSPropertyChangeAction action = WSPropertyChangeAction::ACTION_UPDATE_ASPECT_RATIO;
91 WMError ret = sceneSession->HandleActionUpdateStatusProps(property, action);
92 ASSERT_EQ(WMError::WM_OK, ret);
93 ret = sceneSession->HandleActionUpdateNavigationProps(property, action);
94 ASSERT_EQ(WMError::WM_OK, ret);
95 ret = sceneSession->HandleActionUpdateNavigationIndicatorProps(property, action);
96 ASSERT_EQ(WMError::WM_OK, ret);
97 ret = sceneSession->HandleActionUpdateFlags(property, action);
98 ASSERT_EQ(WMError::WM_OK, ret);
99 }
100
101 /**
102 * @tc.name: HandleActionUpdateTouchHotArea
103 * @tc.desc: normal function
104 * @tc.type: FUNC
105 */
106 HWTEST_F(SceneSessionTest4, HandleActionUpdateTouchHotArea, TestSize.Level1)
107 {
108 SessionInfo info;
109 auto specificCb = sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
__anonbd7f17800202(int32_t persistentId, WindowUpdateType type) 110 specificCb->onWindowInfoUpdate_ = [](int32_t persistentId, WindowUpdateType type) {};
111 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, specificCb);
112 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
113 std::vector<Rect> hotAreas;
114 hotAreas.push_back({1, 2, 3, 4});
115 property->SetTouchHotAreas(hotAreas);
116 WSPropertyChangeAction action = WSPropertyChangeAction::ACTION_UPDATE_ASPECT_RATIO;
117 WMError ret = sceneSession->HandleActionUpdateTouchHotArea(property, action);
118 ASSERT_EQ(WMError::WM_OK, ret);
119 }
120
121 /**
122 * @tc.name: HandleActionUpdateKeyboardTouchHotArea01
123 * @tc.desc: normal function
124 * @tc.type: FUNC
125 */
126 HWTEST_F(SceneSessionTest4, HandleActionUpdateKeyboardTouchHotArea01, TestSize.Level1)
127 {
128 SessionInfo info;
129 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
130 sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
131 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
132 WSPropertyChangeAction action = WSPropertyChangeAction::ACTION_UPDATE_ASPECT_RATIO;
133 WMError ret = sceneSession->HandleActionUpdateKeyboardTouchHotArea(property, action);
134 ASSERT_EQ(WMError::WM_OK, ret);
135 }
136
137 /**
138 * @tc.name: HandleActionUpdateKeyboardTouchHotArea02
139 * @tc.desc: normal function
140 * @tc.type: FUNC
141 */
142 HWTEST_F(SceneSessionTest4, HandleActionUpdateKeyboardTouchHotArea02, TestSize.Level1)
143 {
144 SessionInfo info;
145 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
146 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
147 sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
148 WSPropertyChangeAction action = WSPropertyChangeAction::ACTION_UPDATE_ASPECT_RATIO;
149 WMError ret = sceneSession->HandleActionUpdateKeyboardTouchHotArea(property, action);
150 ASSERT_EQ(WMError::WM_ERROR_INVALID_TYPE, ret);
151 }
152
153 /**
154 * @tc.name: HandleActionUpdateDecorEnable
155 * @tc.desc: normal function
156 * @tc.type: FUNC
157 */
158 HWTEST_F(SceneSessionTest4, HandleActionUpdateDecorEnable, TestSize.Level1)
159 {
160 SessionInfo info;
161 info.abilityName_ = "HandleActionUpdateDecorEnable";
162 info.bundleName_ = "HandleActionUpdateDecorEnable";
163 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
164 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
165 property->isSystemCalling_ = true;
166 sceneSession->SetSessionProperty(property);
167 WSPropertyChangeAction action = WSPropertyChangeAction::ACTION_UPDATE_ASPECT_RATIO;
168
169 auto ret = sceneSession->HandleActionUpdateDecorEnable(property, action);
170 ASSERT_EQ(WMError::WM_OK, ret);
171 }
172
173 /**
174 * @tc.name: HandleActionUpdateDecorEnableTest001
175 * @tc.desc: normal function
176 * @tc.type: FUNC
177 */
178 HWTEST_F(SceneSessionTest4, HandleActionUpdateDecorEnableTest001, TestSize.Level1)
179 {
180 SessionInfo info;
181 info.abilityName_ = "HandleActionUpdateDecorEnableTest001";
182 info.bundleName_ = "HandleActionUpdateDecorEnableTest001";
183 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
184 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
185 property->isSystemCalling_ = false;
186 sceneSession->SetSessionProperty(property);
187 WSPropertyChangeAction action = WSPropertyChangeAction::ACTION_UPDATE_ASPECT_RATIO;
188
189 auto ret = sceneSession->HandleActionUpdateDecorEnable(property, action);
190 ASSERT_EQ(WMError::WM_ERROR_NOT_SYSTEM_APP, ret);
191 }
192
193 /**
194 * @tc.name: HandleActionUpdateDragenabled
195 * @tc.desc: normal function
196 * @tc.type: FUNC
197 */
198 HWTEST_F(SceneSessionTest4, HandleActionUpdateDragenabled, TestSize.Level1)
199 {
200 SessionInfo info;
201 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
202 WSPropertyChangeAction action = WSPropertyChangeAction::ACTION_UPDATE_ASPECT_RATIO;
203 OHOS::Rosen::Session session(info);
204 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
205 session.property_ = property;
206
207 WMError res = sceneSession->HandleActionUpdateDragenabled(property, action);
208 ASSERT_EQ(WMError::WM_OK, res);
209 }
210
211 /**
212 * @tc.name: HandleActionUpdateRaiseenabled
213 * @tc.desc: normal function
214 * @tc.type: FUNC
215 */
216 HWTEST_F(SceneSessionTest4, HandleActionUpdateRaiseenabled, TestSize.Level1)
217 {
218 ASSERT_NE(nullptr, sceneSession);
219 ASSERT_NE(nullptr, property);
220 WSPropertyChangeAction action = WSPropertyChangeAction::ACTION_UPDATE_ANIMATION_FLAG;
221 sceneSession->HandleActionUpdateRaiseenabled(property, action);
222
223 OHOS::Rosen::WindowSessionProperty windowSessionProperty;
224 windowSessionProperty.isSystemCalling_ = {true};
225 sceneSession->HandleActionUpdateRaiseenabled(property, action);
226
227 windowSessionProperty.isSystemCalling_ = {true};
228 OHOS::Rosen::Session session(info);
229 session.property_ = sptr<WindowSessionProperty>::MakeSptr();
230 sceneSession->HandleActionUpdateRaiseenabled(property, action);
231
232 sceneSession->HandleActionUpdateHideNonSystemFloatingWindows(property, action);
233 }
234
235 /**
236 * @tc.name: HandleActionUpdateTextfieldAvoidInfo
237 * @tc.desc: normal function
238 * @tc.type: FUNC
239 */
240 HWTEST_F(SceneSessionTest4, HandleActionUpdateTextfieldAvoidInfo, TestSize.Level1)
241 {
242 ASSERT_NE(nullptr, sceneSession);
243 ASSERT_NE(nullptr, property);
244 sceneSession->HandleActionUpdateTextfieldAvoidInfo(property, action);
245 sceneSession->HandleActionUpdateWindowMask(property, action);
246
247 OHOS::Rosen::Session session(info);
248 session.property_ = sptr<WindowSessionProperty>::MakeSptr();
249 sceneSession->HandleActionUpdateTextfieldAvoidInfo(property, action);
250 sceneSession->HandleActionUpdateWindowMask(property, action);
251 sceneSession->HandleActionUpdateTopmost(property, action);
252
253 SessionInfo info;
254 sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(info, nullptr);
255 ASSERT_NE(nullptr, sceneSession1);
256 sceneSession1->HandleActionUpdateTextfieldAvoidInfo(property, action);
257 sceneSession1->HandleActionUpdateWindowMask(property, action);
258 }
259
260 /**
261 * @tc.name: SetWindowFlags
262 * @tc.desc: normal function
263 * @tc.type: FUNC
264 */
265 HWTEST_F(SceneSessionTest4, SetWindowFlags, TestSize.Level1)
266 {
267 ASSERT_NE(nullptr, sceneSession);
268 ASSERT_NE(nullptr, property);
269 sceneSession->SetWindowFlags(property);
270
271 OHOS::Rosen::Session session(info);
272 session.property_ = sptr<WindowSessionProperty>::MakeSptr();
273 sceneSession->SetWindowFlags(property);
274 sceneSession->NotifySessionChangeByActionNotifyManager(property, action);
275
276 session.property_ = nullptr;
277 sceneSession->SetWindowFlags(property);
278 sceneSession->sessionChangeByActionNotifyManagerFunc_ = [](
279 const sptr<SceneSession>& sceneSession,
280 const sptr<WindowSessionProperty>& property, WSPropertyChangeAction action
__anonbd7f17800302( const sptr<SceneSession>& sceneSession, const sptr<WindowSessionProperty>& property, WSPropertyChangeAction action )281 ){};
282 sceneSession->NotifySessionChangeByActionNotifyManager(property, action);
283 }
284
285 /**
286 * @tc.name: SetSkipDraw
287 * @tc.desc: SetSkipDraw function
288 * @tc.type: FUNC
289 */
290 HWTEST_F(SceneSessionTest4, SetSkipDraw, TestSize.Level1)
291 {
292 SessionInfo info;
293 info.abilityName_ = "SetSkipDraw";
294 info.bundleName_ = "SetSkipDraw";
295 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
296 EXPECT_NE(nullptr, session);
297 struct RSSurfaceNodeConfig config;
298 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
299 session->surfaceNode_ = surfaceNode;
300 session->SetLeashWinSurfaceNode(nullptr);
301 session->SetSkipDraw(true);
302 session->SetLeashWinSurfaceNode(surfaceNode);
303 EXPECT_EQ(surfaceNode, session->GetLeashWinSurfaceNode());
304 session->SetSkipDraw(true);
305 }
306
307 /**
308 * @tc.name: SetScale
309 * @tc.desc: SetScale function
310 * @tc.type: FUNC
311 */
312 HWTEST_F(SceneSessionTest4, SetScale, TestSize.Level1)
313 {
314 SessionInfo info;
315 info.abilityName_ = "SetScale";
316 info.bundleName_ = "SetScale";
317 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
318 EXPECT_NE(nullptr, session);
319 session->Session::SetScale(1.0f, 2.0f, 3.0f, 4.0f);
320 session->sessionStage_ = nullptr;
321 session->SetScale(5.0f, 2.0f, 3.0f, 4.0f);
322 sptr<SceneSession::SpecificSessionCallback> specificCallback =
323 sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
__anonbd7f17800402(int32_t persistentId, WindowUpdateType type) 324 NotifyWindowInfoUpdateCallback func = [](int32_t persistentId, WindowUpdateType type) {
325 return;
326 };
327 specificCallback->onWindowInfoUpdate_ = func;
328 session->specificCallback_ = specificCallback;
329 session->SetScale(5.0f, 5.0f, 3.0f, 4.0f);
330 session->SetScale(5.0f, 5.0f, 5.0f, 4.0f);
331 session->SetScale(5.0f, 5.0f, 5.0f, 5.0f);
332 session->SetScale(5.0f, 5.0f, 5.0f, 5.0f);
333 EXPECT_EQ(5.0f, session->GetScaleX());
334 EXPECT_EQ(5.0f, session->GetScaleY());
335 EXPECT_EQ(5.0f, session->GetPivotX());
336 EXPECT_EQ(5.0f, session->GetPivotY());
337
338 session->sessionStage_ = sptr<SessionStageMocker>::MakeSptr();
339 EXPECT_NE(nullptr, session->sessionStage_);
340 session->SetScale(5.0f, 5.0f, 5.0f, 5.0f);
341 EXPECT_EQ(5.0f, session->GetPivotY());
342 }
343
344 /**
345 * @tc.name: RequestSessionBack
346 * @tc.desc: RequestSessionBack function
347 * @tc.type: FUNC
348 */
349 HWTEST_F(SceneSessionTest4, RequestSessionBack, TestSize.Level1)
350 {
351 SessionInfo info;
352 info.abilityName_ = "RequestSessionBack";
353 info.bundleName_ = "RequestSessionBack";
354 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
355 EXPECT_NE(nullptr, session);
__anonbd7f17800502(const bool needMoveToBackground) 356 NotifyBackPressedFunc func = [](const bool needMoveToBackground) {
357 return;
358 };
359 session->backPressedFunc_ = func;
360 EXPECT_EQ(WSError::WS_OK, session->RequestSessionBack(true));
361
362 struct RSSurfaceNodeConfig config;
363 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
364 EXPECT_NE(nullptr, surfaceNode);
365 session->SetLeashWinSurfaceNode(surfaceNode);
366 ASSERT_EQ(WSError::WS_OK, session->RequestSessionBack(true));
367 }
368
369 /**
370 * @tc.name: SetSurfaceBounds
371 * @tc.desc: SetSurfaceBounds function
372 * @tc.type: FUNC
373 */
374 HWTEST_F(SceneSessionTest4, SetSurfaceBounds, TestSize.Level1)
375 {
376 SessionInfo info;
377 info.abilityName_ = "SetSurfaceBounds";
378 info.bundleName_ = "SetSurfaceBounds";
379 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
380 EXPECT_NE(nullptr, session);
381 WSRect rect;
382 struct RSSurfaceNodeConfig config;
383 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
384 session->surfaceNode_ = surfaceNode;
385 session->SetSurfaceBounds(rect, false);
386 session->SetLeashWinSurfaceNode(surfaceNode);
387 session->SetSurfaceBounds(rect, false);
388 EXPECT_NE(nullptr, session->GetLeashWinSurfaceNode());
389 }
390
391 /**
392 * @tc.name: SetFloatingScale
393 * @tc.desc: SetFloatingScale function
394 * @tc.type: FUNC
395 */
396 HWTEST_F(SceneSessionTest4, SetFloatingScale, TestSize.Level1)
397 {
398 SessionInfo info;
399 info.abilityName_ = "SetFloatingScale";
400 info.bundleName_ = "SetFloatingScale";
401 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
402 EXPECT_NE(nullptr, session);
403 session->floatingScale_ = 3.14f;
404 session->SetFloatingScale(2.176f);
405 session->SetFloatingScale(3.14f);
406 EXPECT_EQ(nullptr, session->specificCallback_);
407 }
408
409 /**
410 * @tc.name: SetRequestedOrientation
411 * @tc.desc: SetRequestedOrientation function
412 * @tc.type: FUNC
413 */
414 HWTEST_F(SceneSessionTest4, SetRequestedOrientation, TestSize.Level1)
415 {
416 SessionInfo info;
417 info.abilityName_ = "SetRequestedOrientation";
418 info.bundleName_ = "SetRequestedOrientation";
419 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
420 Orientation orientation { Orientation::BEGIN };
421 session->SetRequestedOrientation(orientation);
422 session->onRequestedOrientationChange_ = nullptr;
423 session->SetRequestedOrientation(orientation);
__anonbd7f17800602(uint32_t orientation, bool needAnimation) 424 NotifyReqOrientationChangeFunc func = [](uint32_t orientation, bool needAnimation) {
425 return;
426 };
427 session->onRequestedOrientationChange_ = func;
428 session->SetRequestedOrientation(orientation);
429 EXPECT_NE(nullptr, session->onRequestedOrientationChange_);
430 }
431
432 /**
433 * @tc.name: UpdateSessionPropertyByAction
434 * @tc.desc: UpdateSessionPropertyByAction function
435 * @tc.type: FUNC
436 */
437 HWTEST_F(SceneSessionTest4, UpdateSessionPropertyByAction, TestSize.Level1)
438 {
439 SessionInfo info;
440 info.abilityName_ = "UpdateSessionPropertyByAction";
441 info.bundleName_ = "UpdateSessionPropertyByAction";
442 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
443 ASSERT_NE(nullptr, sceneSession);
444 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
445 ASSERT_NE(nullptr, property);
446 WSPropertyChangeAction action = WSPropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE;
447 EXPECT_EQ(WMError::WM_ERROR_NULLPTR, sceneSession->UpdateSessionPropertyByAction(nullptr, action));
448
449 sceneSession->SetSessionProperty(property);
450 EXPECT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, sceneSession->UpdateSessionPropertyByAction(property, action));
451
452 action = WSPropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON;
453 EXPECT_EQ(WMError::WM_OK, sceneSession->UpdateSessionPropertyByAction(property, action));
454 }
455
456 /**
457 * @tc.name: ProcessUpdatePropertyByAction1
458 * @tc.desc: ProcessUpdatePropertyByAction1 function
459 * @tc.type: FUNC
460 */
461 HWTEST_F(SceneSessionTest4, ProcessUpdatePropertyByAction1, TestSize.Level1)
462 {
463 SessionInfo info;
464 info.abilityName_ = "ProcessUpdatePropertyByAction1";
465 info.bundleName_ = "ProcessUpdatePropertyByAction1";
466 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
467 ASSERT_NE(nullptr, sceneSession);
468 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
469 ASSERT_NE(nullptr, property);
470
471 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
472 WSPropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON));
473
474 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
475 WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON));
476
477 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
478 WSPropertyChangeAction::ACTION_UPDATE_FOCUSABLE));
479
480 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
481 WSPropertyChangeAction::ACTION_UPDATE_TOUCHABLE));
482
483 sceneSession->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
484 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
485 WSPropertyChangeAction::ACTION_UPDATE_SET_BRIGHTNESS));
486
487 sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
488 sceneSession->state_ = SessionState::STATE_END;
489 EXPECT_EQ(WMError::WM_ERROR_INVALID_SESSION, sceneSession->ProcessUpdatePropertyByAction(property,
490 WSPropertyChangeAction::ACTION_UPDATE_SET_BRIGHTNESS));
491
492 sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
493 sceneSession->state_ = SessionState::STATE_ACTIVE;
494 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
495 WSPropertyChangeAction::ACTION_UPDATE_SET_BRIGHTNESS));
496
497 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
498 WSPropertyChangeAction::ACTION_UPDATE_ORIENTATION));
499
500 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
501 WSPropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE));
502
503 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
504 WSPropertyChangeAction::ACTION_UPDATE_SYSTEM_PRIVACY_MODE));
505
506 struct RSSurfaceNodeConfig config;
507 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
508 sceneSession->surfaceNode_ = surfaceNode;
509 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
510 WSPropertyChangeAction::ACTION_UPDATE_SNAPSHOT_SKIP));
511 }
512
513 /**
514 * @tc.name: ProcessUpdatePropertyByAction2
515 * @tc.desc: ProcessUpdatePropertyByAction2 function
516 * @tc.type: FUNC
517 */
518 HWTEST_F(SceneSessionTest4, ProcessUpdatePropertyByAction2, TestSize.Level1)
519 {
520 SessionInfo info;
521 info.abilityName_ = "ProcessUpdatePropertyByAction2";
522 info.bundleName_ = "ProcessUpdatePropertyByAction2";
523 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
524 ASSERT_NE(nullptr, sceneSession);
525 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
526 ASSERT_NE(nullptr, property);
527
528 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
529 WSPropertyChangeAction::ACTION_UPDATE_MAXIMIZE_STATE));
530
531 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
532 WSPropertyChangeAction::ACTION_UPDATE_OTHER_PROPS));
533
534 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
535 WSPropertyChangeAction::ACTION_UPDATE_STATUS_PROPS));
536
537 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
538 WSPropertyChangeAction::ACTION_UPDATE_NAVIGATION_PROPS));
539
540 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
541 WSPropertyChangeAction::ACTION_UPDATE_NAVIGATION_INDICATOR_PROPS));
542
543 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
544 WSPropertyChangeAction::ACTION_UPDATE_FLAGS));
545
546 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
547 WSPropertyChangeAction::ACTION_UPDATE_MODE));
548
549 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
550 WSPropertyChangeAction::ACTION_UPDATE_ANIMATION_FLAG));
551
552 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
553 WSPropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA));
554
555 property->SetSystemCalling(false);
556 EXPECT_EQ(WMError::WM_ERROR_NOT_SYSTEM_APP, sceneSession->ProcessUpdatePropertyByAction(property,
557 WSPropertyChangeAction::ACTION_UPDATE_DECOR_ENABLE));
558
559 property->SetSystemCalling(true);
560 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
561 WSPropertyChangeAction::ACTION_UPDATE_DECOR_ENABLE));
562 }
563
564 /**
565 * @tc.name: ProcessUpdatePropertyByAction3
566 * @tc.desc: ProcessUpdatePropertyByAction3 function
567 * @tc.type: FUNC
568 */
569 HWTEST_F(SceneSessionTest4, ProcessUpdatePropertyByAction3, TestSize.Level1)
570 {
571 SessionInfo info;
572 info.abilityName_ = "ProcessUpdatePropertyByAction3";
573 info.bundleName_ = "ProcessUpdatePropertyByAction3";
574 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
575 ASSERT_NE(nullptr, sceneSession);
576 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
577 ASSERT_NE(nullptr, property);
578
579 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
580 WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS));
581
582 property->SetSystemCalling(false);
583 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
584 WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED));
585
586 property->SetSystemCalling(true);
587 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
588 WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED));
589
590 sceneSession->property_ = property;
591 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
592 WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED));
593
594 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
595 WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED));
596
597 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
598 WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS));
599
600 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
601 WSPropertyChangeAction::ACTION_UPDATE_TEXTFIELD_AVOID_INFO));
602
603 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
604 WSPropertyChangeAction::ACTION_UPDATE_WINDOW_MASK));
605
606 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
607 WSPropertyChangeAction::ACTION_UPDATE_TOPMOST));
608
609 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
610 WSPropertyChangeAction::ACTION_UPDATE_SUB_WINDOW_Z_LEVEL));
611
612 property->SetSystemCalling(false);
613 EXPECT_EQ(WMError::WM_ERROR_NOT_SYSTEM_APP, sceneSession->ProcessUpdatePropertyByAction(property,
614 WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO));
615
616 property->SetSystemCalling(true);
617 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
618 WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO));
619
620 EXPECT_EQ(WMError::WM_DO_NOTHING, sceneSession->ProcessUpdatePropertyByAction(property,
621 WSPropertyChangeAction::ACTION_UPDATE_RECT));
622
623 property->SetWindowType(WindowType::WINDOW_TYPE_SYSTEM_FLOAT);
624 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
625 WSPropertyChangeAction::ACTION_UPDATE_AVOID_AREA_OPTION));
626 }
627
628 /**
629 * @tc.name: ProcessUpdatePropertyByAction4
630 * @tc.desc: ProcessUpdatePropertyByAction4 function
631 * @tc.type: FUNC
632 */
633 HWTEST_F(SceneSessionTest4, ProcessUpdatePropertyByAction4, TestSize.Level1)
634 {
635 SessionInfo info;
636 info.abilityName_ = "ProcessUpdatePropertyByAction4";
637 info.bundleName_ = "ProcessUpdatePropertyByAction4";
638 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
639 ASSERT_NE(nullptr, sceneSession);
640 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
641 ASSERT_NE(nullptr, property);
642 property->SetSystemCalling(true);
643 sceneSession->property_ = property;
644 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
645 WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS));
646
647 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
648 WSPropertyChangeAction::ACTION_UPDATE_DECOR_ENABLE));
649
650 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
651 WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS));
652
653 sceneSession->property_ = nullptr;
654 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
655 WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED));
656
657 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
658 WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED));
659
660 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
661 WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS));
662
663 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
664 WSPropertyChangeAction::ACTION_UPDATE_DECOR_ENABLE));
665
666 EXPECT_EQ(WMError::WM_OK, sceneSession->ProcessUpdatePropertyByAction(property,
667 WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS));
668 }
669
670 /**
671 * @tc.name: HandleSpecificSystemBarProperty
672 * @tc.desc: HandleSpecificSystemBarProperty
673 * @tc.type: FUNC
674 */
675 HWTEST_F(SceneSessionTest4, HandleSpecificSystemBarProperty, TestSize.Level1)
676 {
677 SessionInfo info;
678 info.abilityName_ = "HandleSpecificSystemBarProperty";
679 info.bundleName_ = "HandleSpecificSystemBarProperty";
680 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
681 ASSERT_NE(nullptr, sceneSession);
682 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
683 ASSERT_NE(nullptr, property);
684 WindowType type = WindowType::WINDOW_TYPE_STATUS_BAR;
685 sceneSession->HandleSpecificSystemBarProperty(type, property);
686
687 sceneSession->isDisplayStatusBarTemporarily_.store(true);
688 sceneSession->HandleSpecificSystemBarProperty(type, property);
689
690 sceneSession->specificCallback_ = nullptr;
691 sceneSession->HandleSpecificSystemBarProperty(type, property);
692
693 sptr<SceneSession::SpecificSessionCallback> specificCallback =
694 sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
695 ASSERT_NE(nullptr, specificCallback);
696 sceneSession->specificCallback_ = specificCallback;
697 sceneSession->HandleSpecificSystemBarProperty(type, property);
698
699 sceneSession->specificCallback_->onUpdateAvoidArea_ = nullptr;
700 sceneSession->HandleSpecificSystemBarProperty(type, property);
701
702 UpdateAvoidAreaCallback onUpdateAvoidArea;
703 sceneSession->specificCallback_->onUpdateAvoidArea_ = onUpdateAvoidArea;
704 sceneSession->HandleSpecificSystemBarProperty(type, property);
705 }
706
707 /**
708 * @tc.name: HandleLayoutAvoidAreaUpdate
709 * @tc.desc: HandleLayoutAvoidAreaUpdate
710 * @tc.type: FUNC
711 */
712 HWTEST_F(SceneSessionTest4, HandleLayoutAvoidAreaUpdate, TestSize.Level1)
713 {
714 SessionInfo info;
715 info.abilityName_ = "HandleLayoutAvoidAreaUpdate";
716 info.bundleName_ = "HandleLayoutAvoidAreaUpdate";
717 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
718
719 session->isLastFrameLayoutFinishedFunc_ = nullptr;
720 session->isAINavigationBarAvoidAreaValid_ = nullptr;
721 EXPECT_EQ(WSError::WS_ERROR_NULLPTR, session->HandleLayoutAvoidAreaUpdate(AvoidAreaType::TYPE_END));
722
__anonbd7f17800702(bool& isLayoutFinished) 723 session->isLastFrameLayoutFinishedFunc_ = [](bool& isLayoutFinished) {
724 isLayoutFinished = false;
725 return WSError::WS_ERROR_NULLPTR;
726 };
727 EXPECT_EQ(WSError::WS_ERROR_NULLPTR, session->HandleLayoutAvoidAreaUpdate(AvoidAreaType::TYPE_END));
728
__anonbd7f17800802(bool& isLayoutFinished) 729 session->isLastFrameLayoutFinishedFunc_ = [](bool& isLayoutFinished) {
730 isLayoutFinished = true;
731 return WSError::WS_OK;
732 };
733 EXPECT_EQ(WSError::WS_OK, session->HandleLayoutAvoidAreaUpdate(AvoidAreaType::TYPE_END));
734 EXPECT_EQ(WSError::WS_OK, session->HandleLayoutAvoidAreaUpdate(AvoidAreaType::TYPE_SYSTEM));
735 EXPECT_EQ(WSError::WS_OK, session->HandleLayoutAvoidAreaUpdate(AvoidAreaType::TYPE_NAVIGATION_INDICATOR));
736
__anonbd7f17800902(const AvoidArea& avoidArea, int32_t sessionBottom) 737 session->isAINavigationBarAvoidAreaValid_ = [](const AvoidArea& avoidArea, int32_t sessionBottom) {
738 return true;
739 };
740 EXPECT_EQ(WSError::WS_OK, session->HandleLayoutAvoidAreaUpdate(AvoidAreaType::TYPE_END));
741 EXPECT_EQ(WSError::WS_OK, session->HandleLayoutAvoidAreaUpdate(AvoidAreaType::TYPE_NAVIGATION_INDICATOR));
742
__anonbd7f17800a02(const AvoidArea& avoidArea, int32_t sessionBottom) 743 session->isAINavigationBarAvoidAreaValid_ = [](const AvoidArea& avoidArea, int32_t sessionBottom) {
744 return false;
745 };
746 EXPECT_EQ(WSError::WS_OK, session->HandleLayoutAvoidAreaUpdate(AvoidAreaType::TYPE_END));
747 EXPECT_EQ(WSError::WS_OK, session->HandleLayoutAvoidAreaUpdate(AvoidAreaType::TYPE_NAVIGATION_INDICATOR));
748 }
749
750 /**
751 * @tc.name: SetWindowFlags1
752 * @tc.desc: SetWindowFlags1
753 * @tc.type: FUNC
754 */
755 HWTEST_F(SceneSessionTest4, SetWindowFlags1, TestSize.Level1)
756 {
757 SessionInfo info;
758 info.abilityName_ = "SetWindowFlags1";
759 info.bundleName_ = "SetWindowFlags1";
760 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
761 ASSERT_NE(nullptr, sceneSession);
762 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
763 ASSERT_NE(nullptr, property);
764 sptr<WindowSessionProperty> sessionProperty = sptr<WindowSessionProperty>::MakeSptr();
765 ASSERT_NE(nullptr, sessionProperty);
766 sceneSession->SetWindowFlags(property);
767 sceneSession->property_ = sessionProperty;
768 property->SetWindowFlags(static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_PARENT_LIMIT));
769 sceneSession->property_->SetWindowFlags(static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_NEED_AVOID));
770 sceneSession->SetWindowFlags(property);
771 property->SetWindowFlags(static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_FORBID_SPLIT_MOVE));
772 sceneSession->property_->SetWindowFlags(static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_WATER_MARK));
773 sceneSession->SetWindowFlags(property);
774 }
775
776 /**
777 * @tc.name: SetGestureBackEnabled
778 * @tc.desc: SetGestureBackEnabled
779 * @tc.type: FUNC
780 */
781 HWTEST_F(SceneSessionTest4, SetGestureBackEnabled, TestSize.Level1)
782 {
783 SessionInfo info;
784 info.abilityName_ = "SetGestureBackEnabled";
785 info.bundleName_ = "SetGestureBackEnabled";
786 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
787 ASSERT_NE(nullptr, sceneSession);
788 sceneSession->isEnableGestureBack_ = false;
789 EXPECT_EQ(WMError::WM_OK, sceneSession->SetGestureBackEnabled(false));
790 sceneSession->specificCallback_ = sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
791 EXPECT_NE(nullptr, sceneSession->specificCallback_);
__anonbd7f17800b02(int32_t persistentId) 792 auto func = [sceneSession](int32_t persistentId) {
793 return;
794 };
795 sceneSession->specificCallback_->onUpdateGestureBackEnabled_ = func;
796 EXPECT_EQ(WMError::WM_OK, sceneSession->SetGestureBackEnabled(true));
797 EXPECT_EQ(true, sceneSession->GetGestureBackEnabled());
798 }
799
800 /**
801 * @tc.name: GetCustomDecorHeight02
802 * @tc.desc: GetCustomDecorHeight
803 * @tc.type: FUNC
804 */
805 HWTEST_F(SceneSessionTest4, GetCustomDecorHeight02, TestSize.Level1)
806 {
807 SessionInfo info;
808 info.abilityName_ = "GetCustomDecorHeight";
809 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
810 sceneSession->SetCustomDecorHeight(50);
811 sceneSession->SetCustomDecorHeight(20);
812 ASSERT_EQ(50, sceneSession->customDecorHeight_);
813
814 sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(info, nullptr);
815 sceneSession2->SetCustomDecorHeight(50);
816 sceneSession2->SetCustomDecorHeight(150);
817 ASSERT_EQ(50, sceneSession2->customDecorHeight_);
818 }
819
820 /**
821 * @tc.name: SetDefaultDisplayIdIfNeed03
822 * @tc.desc: SetDefaultDisplayIdIfNeed
823 * @tc.type: FUNC
824 */
825 HWTEST_F(SceneSessionTest4, SetDefaultDisplayIdIfNeed03, TestSize.Level1)
826 {
827 SessionInfo info;
828 info.abilityName_ = "SetDefaultDisplayIdIfNeed03";
829 info.bundleName_ = "SetDefaultDisplayIdIfNeed03";
830 info.screenId_ = 20;
831 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
832 sceneSession->SetDefaultDisplayIdIfNeed();
833 ASSERT_EQ(20, sceneSession->GetSessionInfo().screenId_);
834 }
835
836 /**
837 * @tc.name: NotifyServerToUpdateRect01
838 * @tc.desc: NotifyServerToUpdateRect
839 * @tc.type: FUNC
840 */
841 HWTEST_F(SceneSessionTest4, NotifyServerToUpdateRect01, TestSize.Level1)
842 {
843 SessionInfo info;
844 info.abilityName_ = "NotifyServerToUpdateRect";
845 info.bundleName_ = "NotifyServerToUpdateRect";
846 info.screenId_ = 20;
847 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
848 SessionUIParam uiParam;
849 SizeChangeReason reason = SizeChangeReason::UNDEFINED;
850 sceneSession->SetForegroundInteractiveStatus(false);
851 sceneSession->NotifyServerToUpdateRect(uiParam, reason);
852 ASSERT_EQ(false, sceneSession->NotifyServerToUpdateRect(uiParam, reason));
853
854 sceneSession->SetForegroundInteractiveStatus(true);
855 ASSERT_EQ(false, sceneSession->NotifyServerToUpdateRect(uiParam, reason));
856
857 uiParam.needSync_ = false;
858 ASSERT_EQ(false, sceneSession->NotifyServerToUpdateRect(uiParam, reason));
859
860 uiParam.needSync_ = true;
861 uiParam.rect_ = {0, 0, 1, 1};
862
863 sceneSession->GetLayoutController()->SetSessionRect({0, 0, 1, 1});
864 sceneSession->SetClientRect({0, 0, 1, 1});
865 ASSERT_FALSE(sceneSession->NotifyServerToUpdateRect(uiParam, reason));
866
867 sceneSession->GetLayoutController()->SetSessionRect({1, 1, 1, 1});
868 ASSERT_TRUE(sceneSession->NotifyServerToUpdateRect(uiParam, reason));
869
870 sceneSession->GetLayoutController()->SetSessionRect({0, 0, 1, 1});
871 sceneSession->SetClientRect({1, 1, 1, 1});
872 ASSERT_FALSE(sceneSession->NotifyServerToUpdateRect(uiParam, reason));
873
874 sceneSession->sessionStage_ = sptr<SessionStageMocker>::MakeSptr();
875 ASSERT_TRUE(sceneSession->NotifyServerToUpdateRect(uiParam, reason));
876
877 sceneSession->GetLayoutController()->SetSessionRect({1, 1, 1, 1});
878 sceneSession->SetClientRect({1, 1, 1, 1});
879 ASSERT_TRUE(sceneSession->NotifyServerToUpdateRect(uiParam, reason));
880
881 uiParam.rect_ = {0, 0, 1, 0};
882 ASSERT_EQ(false, sceneSession->NotifyServerToUpdateRect(uiParam, reason));
883 }
884
885 /**
886 * @tc.name: UpdateVisibilityInner
887 * @tc.desc: UpdateVisibilityInner
888 * @tc.type: FUNC
889 */
890 HWTEST_F(SceneSessionTest4, UpdateVisibilityInner01, TestSize.Level1)
891 {
892 SessionInfo info;
893 info.abilityName_ = "UpdateVisibilityInner01";
894 info.bundleName_ = "UpdateVisibilityInner01";
895 info.screenId_ = 20;
896 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
897 sceneSession->isVisible_ = false;
898 ASSERT_EQ(false, sceneSession->UpdateVisibilityInner(false));
899
900 ASSERT_EQ(true, sceneSession->UpdateVisibilityInner(true));
901 }
902
903 /**
904 * @tc.name: UnregisterSessionChangeListeners
905 * @tc.desc: UnregisterSessionChangeListeners
906 * @tc.type: FUNC
907 */
908 HWTEST_F(SceneSessionTest4, UnregisterSessionChangeListeners01, TestSize.Level1)
909 {
910 SessionInfo info;
911 info.abilityName_ = "UnregisterSessionChangeListeners01";
912 info.bundleName_ = "UnregisterSessionChangeListeners01";
913 info.screenId_ = 20;
914 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
915 sceneSession->UnregisterSessionChangeListeners();
916
917 sceneSession->UnregisterSessionChangeListeners();
918 NotifyPendingSessionToBackgroundForDelegatorFunc func =[sceneSession](const SessionInfo& info,
__anonbd7f17800c02(const SessionInfo& info, bool shouldBackToCaller) 919 bool shouldBackToCaller) { return; };
920 sceneSession->pendingSessionToBackgroundForDelegatorFunc_ = func;
921 ASSERT_EQ(WSError::WS_OK, sceneSession->PendingSessionToBackgroundForDelegator(true));
922 }
923
924 /**
925 * @tc.name: IsPcOrPadEnableActivation01
926 * @tc.desc: IsPcOrPadEnableActivation
927 * @tc.type: FUNC
928 */
929 HWTEST_F(SceneSessionTest4, IsPcOrPadEnableActivation01, TestSize.Level1)
930 {
931 SessionInfo info;
932 info.abilityName_ = "IsPcOrPadEnableActivation01";
933 info.bundleName_ = "IsPcOrPadEnableActivation01";
934 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
935
936 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
937 sceneSession->SetSessionProperty(property);
938 sceneSession->SetIsPcAppInPad(true);
939 ASSERT_EQ(true, sceneSession->IsPcOrPadEnableActivation());
940 }
941
942 /**
943 * @tc.name: SetSystemWindowEnableDrag01
944 * @tc.desc: SetSystemWindowEnableDrag function01
945 * @tc.type: FUNC
946 */
947 HWTEST_F(SceneSessionTest4, SetSystemWindowEnableDrag01, TestSize.Level1)
948 {
949 SessionInfo info;
950 info.abilityName_ = "SetSystemWindowEnableDrag01";
951 info.bundleName_ = "SetSystemWindowEnableDrag01";
952 info.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
953 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
954
955 session->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
956 auto ret = session->SetSystemWindowEnableDrag(true);
957 ASSERT_EQ(WMError::WM_ERROR_INVALID_CALLING, ret);
958
959 session->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
960 ret = session->SetSystemWindowEnableDrag(true);
961 ASSERT_EQ(WMError::WM_OK, ret);
962 }
963
964 /**
965 * @tc.name: OnTitleAndDockHoverShowChange01
966 * @tc.desc: normal function
967 * @tc.type: FUNC
968 */
969 HWTEST_F(SceneSessionTest4, OnTitleAndDockHoverShowChange01, TestSize.Level1)
970 {
971 SessionInfo info;
972 info.abilityName_ = "OnTitleAndDockHoverShowChange01";
973 info.bundleName_ = "OnTitleAndDockHoverShowChange01";
974 sptr<SceneSession> sceneSession = sptr<MainSession>::MakeSptr(info, nullptr);
975
976 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
977 property->SetWindowType(WindowType::WINDOW_TYPE_GLOBAL_SEARCH);
978 sceneSession->SetSessionProperty(property);
979 auto result = sceneSession->OnTitleAndDockHoverShowChange(true, true);
980 ASSERT_EQ(result, WSError::WS_OK);
981 }
982
983 /**
984 * @tc.name: SetAutoStartPiP01
985 * @tc.desc: SetAutoStartPiP
986 * @tc.type: FUNC
987 */
988 HWTEST_F(SceneSessionTest4, SetAutoStartPiP01, TestSize.Level1)
989 {
990 SessionInfo info;
991 info.abilityName_ = "SetAutoStartPiP01";
992 info.bundleName_ = "SetAutoStartPiP01";
993 sptr<SceneSession> sceneSession = sptr<MainSession>::MakeSptr(info, nullptr);
994
995 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
996 property->SetWindowType(WindowType::WINDOW_TYPE_GLOBAL_SEARCH);
997 sceneSession->SetSessionProperty(property);
998 sceneSession->isTerminating_ = false;
999 auto result = sceneSession->SetAutoStartPiP(true, 0, 1, 1);
1000 ASSERT_EQ(result, WSError::WS_OK);
1001 }
1002
1003 /**
1004 * @tc.name: SetAutoStartPiP02
1005 * @tc.desc: SetAutoStartPiP
1006 * @tc.type: FUNC
1007 */
1008 HWTEST_F(SceneSessionTest4, SetAutoStartPiP02, TestSize.Level1)
1009 {
1010 SessionInfo info;
1011 info.abilityName_ = "SetAutoStartPiP02";
1012 info.bundleName_ = "SetAutoStartPiP02";
1013 sptr<SceneSession> sceneSession = sptr<MainSession>::MakeSptr(info, nullptr);
1014
1015 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1016 property->SetWindowType(WindowType::WINDOW_TYPE_GLOBAL_SEARCH);
1017 sceneSession->SetSessionProperty(property);
1018 sceneSession->isTerminating_ = true;
__anonbd7f17800d02(bool flag, uint32_t status, uint32_t width, uint32_t height) 1019 NotifyAutoStartPiPStatusChangeFunc func = [](bool flag, uint32_t status, uint32_t width, uint32_t height) {
1020 return;
1021 };
1022 sceneSession->autoStartPiPStatusChangeFunc_ = func;
1023 auto result = sceneSession->SetAutoStartPiP(true, 1, 1, 1);
1024 ASSERT_EQ(result, WSError::WS_OK);
1025 }
1026
1027 /**
1028 * @tc.name: SetAutoStartPiP03
1029 * @tc.desc: SetAutoStartPiP
1030 * @tc.type: FUNC
1031 */
1032 HWTEST_F(SceneSessionTest4, SetAutoStartPiP03, TestSize.Level1)
1033 {
1034 SessionInfo info;
1035 info.abilityName_ = "SetAutoStartPiP03";
1036 info.bundleName_ = "SetAutoStartPiP03";
1037 sptr<SceneSession> sceneSession = sptr<MainSession>::MakeSptr(info, nullptr);
1038
1039 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1040 property->SetWindowType(WindowType::WINDOW_TYPE_GLOBAL_SEARCH);
1041 sceneSession->SetSessionProperty(property);
1042 sceneSession->isTerminating_ = true;
1043 auto result = sceneSession->SetAutoStartPiP(true, 0, 1, 1);
1044 ASSERT_EQ(result, WSError::WS_OK);
1045 }
1046
1047 /**
1048 * @tc.name: UpdatePiPControlStatus
1049 * @tc.desc: UpdatePiPControlStatus
1050 * @tc.type: FUNC
1051 */
1052 HWTEST_F(SceneSessionTest4, UpdatePiPControlStatus, TestSize.Level1)
1053 {
1054 SessionInfo info;
1055 info.abilityName_ = "UpdatePiPControlStatus";
1056 info.bundleName_ = "UpdatePiPControlStatus";
1057 auto sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1058 ASSERT_NE(sceneSession, nullptr);
1059 sceneSession->isActive_ = true;
1060
1061 auto property = sptr<WindowSessionProperty>::MakeSptr();
1062 ASSERT_NE(property, nullptr);
1063 property->SetWindowType(WindowType::WINDOW_TYPE_PIP);
1064 sceneSession->SetSessionProperty(property);
1065
1066 auto controlType = WsPiPControlType::VIDEO_PLAY_PAUSE;
1067 auto status = WsPiPControlStatus::PLAY;
1068 sceneSession->isTerminating_ = false;
1069 WSError result = sceneSession->UpdatePiPControlStatus(controlType, status);
1070 ASSERT_EQ(result, WSError::WS_OK);
1071
1072 sceneSession->isTerminating_ = true;
1073 result = sceneSession->UpdatePiPControlStatus(controlType, status);
1074 ASSERT_EQ(result, WSError::WS_OK);
1075 }
1076
1077 /**
1078 * @tc.name: SetSplitButtonVisible01
1079 * @tc.desc: SetSplitButtonVisible
1080 * @tc.type: FUNC
1081 */
1082 HWTEST_F(SceneSessionTest4, SetSplitButtonVisible01, TestSize.Level1)
1083 {
1084 SessionInfo info;
1085 info.abilityName_ = "SetSplitButtonVisible01";
1086 info.bundleName_ = "SetSplitButtonVisible01";
1087 sptr<SceneSession> sceneSession = sptr<MainSession>::MakeSptr(info, nullptr);
1088
1089 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1090 property->SetWindowType(WindowType::WINDOW_TYPE_GLOBAL_SEARCH);
1091 sceneSession->SetSessionProperty(property);
1092 sceneSession->sessionStage_ = nullptr;
1093 auto result = sceneSession->SetSplitButtonVisible(true);
1094 EXPECT_EQ(result, WSError::WS_ERROR_NULLPTR);
1095 }
1096
1097 /**
1098 * @tc.name: SetSplitButtonVisible02
1099 * @tc.desc: SetSplitButtonVisible
1100 * @tc.type: FUNC
1101 */
1102 HWTEST_F(SceneSessionTest4, SetSplitButtonVisible02, TestSize.Level1)
1103 {
1104 SessionInfo info;
1105 info.abilityName_ = "SetSplitButtonVisible02";
1106 info.bundleName_ = "SetSplitButtonVisible02";
1107 sptr<SceneSession> sceneSession = sptr<MainSession>::MakeSptr(info, nullptr);
1108
1109 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1110 property->SetWindowType(WindowType::WINDOW_TYPE_GLOBAL_SEARCH);
1111 sceneSession->SetSessionProperty(property);
1112 sptr<SessionStageMocker> mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
1113 sceneSession->sessionStage_ = mockSessionStage;
1114 auto result = sceneSession->SetSplitButtonVisible(true);
1115 EXPECT_EQ(result, WSError::WS_OK);
1116 }
1117
1118 /**
1119 * @tc.name: SetMovable01
1120 * @tc.desc: SetMovable
1121 * @tc.type: FUNC
1122 */
1123 HWTEST_F(SceneSessionTest4, SetMovable01, TestSize.Level1)
1124 {
1125 SessionInfo info;
1126 info.abilityName_ = "SetMovable01";
1127 info.bundleName_ = "SetMovable01";
1128
1129 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1130
1131 sceneSession->SetMovable(true);
1132 sceneSession->leashWinSurfaceNode_ = nullptr;
1133 SessionEvent event = SessionEvent::EVENT_START_MOVE;
1134 sceneSession->moveDragController_ = sptr<MoveDragController>::MakeSptr(1, WindowType::WINDOW_TYPE_FLOAT);
1135 sceneSession->SetMovable(true);
1136 sceneSession->OnSessionEvent(event);
1137 sceneSession->moveDragController_->isStartDrag_ = true;
1138 auto result = sceneSession->OnSessionEvent(event);
1139 ASSERT_EQ(result, WSError::WS_OK);
1140 }
1141
1142 /**
1143 * @tc.name: SetWindowFlags01
1144 * @tc.desc: SetWindowFlags
1145 * @tc.type: FUNC
1146 */
1147 HWTEST_F(SceneSessionTest4, SetWindowFlags01, TestSize.Level1)
1148 {
1149 SessionInfo info;
1150 info.abilityName_ = "SetWindowFlags01";
1151 info.bundleName_ = "SetWindowFlags01";
1152
1153 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1154 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1155 sceneSession->SetWindowFlags(property);
1156 ASSERT_EQ(0, property->GetWindowFlags());
1157 }
1158
1159 /**
1160 * @tc.name: SetWindowFlags02
1161 * @tc.desc: SetWindowFlags
1162 * @tc.type: FUNC
1163 */
1164 HWTEST_F(SceneSessionTest4, SetWindowFlags02, TestSize.Level1)
1165 {
1166 SessionInfo info;
1167 info.abilityName_ = "SetWindowFlags02";
1168 info.bundleName_ = "SetWindowFlags02";
1169
1170 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1171 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1172 property->SetWindowFlags(2);
1173 sceneSession->SetSessionProperty(property);
1174
1175 sptr<WindowSessionProperty> property2 = sptr<WindowSessionProperty>::MakeSptr();
1176 property2->SetWindowFlags(2);
1177 property2->SetSystemCalling(false);
1178
1179 sceneSession->SetWindowFlags(property2);
1180 ASSERT_EQ(2, sceneSession->GetSessionProperty()->GetWindowFlags());
1181 }
1182
1183 /**
1184 * @tc.name: SetWindowFlags03
1185 * @tc.desc: SetWindowFlags
1186 * @tc.type: FUNC
1187 */
1188 HWTEST_F(SceneSessionTest4, SetWindowFlags03, TestSize.Level1)
1189 {
1190 SessionInfo info;
1191 info.abilityName_ = "SetWindowFlags03";
1192 info.bundleName_ = "SetWindowFlags03";
1193
1194 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1195 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1196 property->SetWindowFlags(2);
1197 sceneSession->SetSessionProperty(property);
1198
1199 sptr<WindowSessionProperty> property2 = sptr<WindowSessionProperty>::MakeSptr();
1200 property2->SetWindowFlags(2);
1201 property2->SetSystemCalling(true);
1202
1203 sceneSession->SetWindowFlags(property2);
1204 ASSERT_EQ(2, sceneSession->GetSessionProperty()->GetWindowFlags());
1205 }
1206
1207 /**
1208 * @tc.name: UpdateSessionPropertyByAction02
1209 * @tc.desc: UpdateSessionPropertyByAction function
1210 * @tc.type: FUNC
1211 */
1212 HWTEST_F(SceneSessionTest4, UpdateSessionPropertyByAction02, TestSize.Level1)
1213 {
1214 SessionInfo info;
1215 info.abilityName_ = "UpdateSessionPropertyByAction02";
1216 info.bundleName_ = "UpdateSessionPropertyByAction02";
1217 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1218
1219 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1220 sceneSession->SetSessionProperty(property);
1221 WSPropertyChangeAction action = WSPropertyChangeAction::ACTION_UPDATE_MAIN_WINDOW_TOPMOST;
1222 ASSERT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, sceneSession->UpdateSessionPropertyByAction(property, action));
1223 }
1224
1225 /**
1226 * @tc.name: IsMovable01
1227 * @tc.desc: IsMovable
1228 * @tc.type: FUNC
1229 */
1230 HWTEST_F(SceneSessionTest4, isMovable01, TestSize.Level1)
1231 {
1232 SessionInfo info;
1233 info.abilityName_ = "isMovable01";
1234 info.bundleName_ = "isMovable01";
1235 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1236 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1237 sceneSession->SetSessionProperty(property);
1238 ASSERT_EQ(false, sceneSession->IsMovable());
1239 }
1240
1241 /**
1242 * @tc.name: IsMovable02
1243 * @tc.desc: IsMovable
1244 * @tc.type: FUNC
1245 */
1246 HWTEST_F(SceneSessionTest4, IsMovable02, TestSize.Level1)
1247 {
1248 SessionInfo info;
1249 info.abilityName_ = "IsMovable02";
1250 info.bundleName_ = "IsMovable02";
1251 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1252 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1253 sceneSession->SetSessionProperty(property);
1254 sceneSession->moveDragController_ = sptr<MoveDragController>::MakeSptr(2024, WindowType::WINDOW_TYPE_FLOAT);
1255 ASSERT_EQ(WSError::WS_DO_NOTHING, sceneSession->UpdateFocus(false));
1256 ASSERT_EQ(false, sceneSession->IsMovable());
1257 ASSERT_EQ(WSError::WS_OK, sceneSession->UpdateFocus(true));
1258 }
1259
1260 /**
1261 * @tc.name: IsMovable03
1262 * @tc.desc: IsMovable
1263 * @tc.type: FUNC
1264 */
1265 HWTEST_F(SceneSessionTest4, IsMovable03, TestSize.Level1)
1266 {
1267 SessionInfo info;
1268 info.abilityName_ = "IsMovable03";
1269 info.bundleName_ = "IsMovable03";
1270 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1271 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1272 sceneSession->moveDragController_ = sptr<MoveDragController>::MakeSptr(2024, WindowType::WINDOW_TYPE_FLOAT);
1273 ASSERT_EQ(WSError::WS_OK, sceneSession->UpdateFocus(true));
1274 ASSERT_EQ(false, sceneSession->IsMovable());
1275 }
1276
1277 /**
1278 * @tc.name: SetFrameGravity
1279 * @tc.desc: SetFrameGravity Test
1280 * @tc.type: FUNC
1281 */
1282 HWTEST_F(SceneSessionTest4, SetFrameGravity, TestSize.Level1)
1283 {
1284 SessionInfo info;
1285 info.abilityName_ = "SetFrameGravity";
1286 info.bundleName_ = "SetFrameGravity";
1287 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1288 EXPECT_NE(session, nullptr);
1289
1290 struct RSSurfaceNodeConfig config;
1291 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
1292 session->surfaceNode_ = surfaceNode;
1293 ASSERT_EQ(true, session->SetFrameGravity(Gravity::RESIZE));
1294 session->surfaceNode_ = nullptr;
1295 ASSERT_EQ(false, session->SetFrameGravity(Gravity::TOP_LEFT));
1296 }
1297
1298 /**
1299 * @tc.name: SetIsLayoutFullScreen
1300 * @tc.desc: SetIsLayoutFullScreen Test
1301 * @tc.type: FUNC
1302 */
1303 HWTEST_F(SceneSessionTest4, SetIsLayoutFullScreen, TestSize.Level1)
1304 {
1305 SessionInfo info;
1306 info.abilityName_ = "SetIsLayoutFullScreen";
1307 info.bundleName_ = "SetIsLayoutFullScreen";
1308 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1309 ASSERT_NE(session, nullptr);
1310 session->SetIsLayoutFullScreen(true);
1311 EXPECT_EQ(session->IsLayoutFullScreen(), true);
1312 }
1313
1314 /**
1315 * @tc.name: IsLayoutFullScreen
1316 * @tc.desc: IsLayoutFullScreen Test
1317 * @tc.type: FUNC
1318 */
1319 HWTEST_F(SceneSessionTest4, IsLayoutFullScreen, TestSize.Level1)
1320 {
1321 SessionInfo info;
1322 info.abilityName_ = "IsLayoutFullScreen";
1323 info.bundleName_ = "IsLayoutFullScreen";
1324 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1325 ASSERT_NE(session, nullptr);
1326 EXPECT_EQ(session->IsLayoutFullScreen(), false);
1327 }
1328
1329 /**
1330 * @tc.name: UpdateAllModalUIExtensions
1331 * @tc.desc: UpdateAllModalUIExtensions Test
1332 * @tc.type: FUNC
1333 */
1334 HWTEST_F(SceneSessionTest4, UpdateAllModalUIExtensions, TestSize.Level1)
1335 {
1336 WSRect globalRect = { 100, 100, 100, 100 };
1337 sceneSession->SetSessionGlobalRect(globalRect);
1338
1339 WSRect newGlobalRect = { 150, 150, 100, 100 };
1340 sceneSession->UpdateAllModalUIExtensions(newGlobalRect);
1341
1342 Rect windowRect = { 100, 100, 100, 100 };
1343 Rect uiExtRect = { 0, 0, 100, 100 };
1344 ExtensionWindowEventInfo extensionInfo { 1, 1, windowRect, uiExtRect, false };
1345 ExtensionWindowEventInfo extensionInfo2 { 2, 2, windowRect, uiExtRect, true };
1346 sceneSession->modalUIExtensionInfoList_.push_back(extensionInfo);
1347 sceneSession->modalUIExtensionInfoList_.push_back(extensionInfo2);
1348 sceneSession->UpdateAllModalUIExtensions(newGlobalRect);
1349 usleep(WAIT_SYNC_IN_NS);
1350 EXPECT_EQ(sceneSession->modalUIExtensionInfoList_[1].windowRect.posX_, 150);
1351 EXPECT_EQ(sceneSession->modalUIExtensionInfoList_[1].windowRect.posY_, 150);
1352 }
1353
1354 /**
1355 * @tc.name: HandleActionUpdateSubWindowZLevel
1356 * @tc.desc: HandleActionUpdateSubWindowZLevel Test
1357 * @tc.type: FUNC
1358 */
1359 HWTEST_F(SceneSessionTest4, HandleActionUpdateSubWindowZLevel, TestSize.Level1)
1360 {
1361 SessionInfo info;
1362 info.abilityName_ = "HandleActionUpdateSubWindowZLevel";
1363 info.bundleName_ = "HandleActionUpdateSubWindowZLevel";
1364 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1365 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1366 sptr<WindowSessionProperty> sessionProperty = sptr<WindowSessionProperty>::MakeSptr();
1367 sessionProperty->zLevel_ = 0;
1368 sceneSession->property_ = sessionProperty;
1369 ASSERT_EQ(0, sceneSession->GetSubWindowZLevel());
1370 property->zLevel_ = 1;
1371 WMError ret = sceneSession->HandleActionUpdateSubWindowZLevel(property,
1372 WSPropertyChangeAction::ACTION_UPDATE_SUB_WINDOW_Z_LEVEL);
1373 sceneSession->SetSubWindowZLevel(1);
1374 ASSERT_EQ(WMError::WM_OK, ret);
1375 }
1376
1377 /**
1378 * @tc.name: HandleActionUpdateAvoidAreaOption
1379 * @tc.desc: normal function
1380 * @tc.type: FUNC
1381 */
1382 HWTEST_F(SceneSessionTest4, HandleActionUpdateAvoidAreaOption, TestSize.Level1)
1383 {
1384 SessionInfo info;
1385 info.abilityName_ = "HandleActionUpdateAvoidAreaOption";
1386 info.bundleName_ = "HandleActionUpdateAvoidAreaOption";
1387 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1388 sptr<WindowSessionProperty> sessionProperty = session->GetSessionProperty();
1389
1390 sessionProperty->SetAvoidAreaOption(1);
1391 sessionProperty->SetWindowType(WindowType::WINDOW_TYPE_SYSTEM_FLOAT);
1392 WMError ret = session->HandleActionUpdateAvoidAreaOption(sessionProperty, action);
1393 ASSERT_EQ(WMError::WM_OK, ret);
1394
1395 sessionProperty->SetAvoidAreaOption(2);
1396 sessionProperty->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1397 ret = session->HandleActionUpdateAvoidAreaOption(sessionProperty, action);
1398 ASSERT_EQ(WMError::WM_OK, ret);
1399
1400 sessionProperty->SetAvoidAreaOption(3);
1401 sessionProperty->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION);
1402 ret = session->HandleActionUpdateAvoidAreaOption(sessionProperty, action);
1403 ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, ret);
1404 }
1405
1406 /**
1407 * @tc.name: GetSystemAvoidArea
1408 * @tc.desc: normal function
1409 * @tc.type: FUNC
1410 */
1411 HWTEST_F(SceneSessionTest4, GetSystemAvoidArea, TestSize.Level1)
1412 {
1413 SessionInfo info;
1414 info.abilityName_ = "GetSystemAvoidArea";
1415 info.bundleName_ = "GetSystemAvoidArea";
1416 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1417 auto specificCallback = sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
1418 sceneSession->isActive_ = true;
1419 SystemSessionConfig systemConfig;
1420 systemConfig.windowUIType_ = WindowUIType::PHONE_WINDOW;
1421 sceneSession->SetSystemConfig(systemConfig);
1422 ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear();
1423 sceneSession->GetSessionProperty()->SetDisplayId(2024);
1424 sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr();
1425 ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(2024, screenSession));
1426 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1427 property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1428 property->SetWindowFlags(static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_NEED_AVOID));
1429 sceneSession->SetSessionProperty(property);
1430
1431 WSRect rect1({0, 0, 10, 10});
1432 AvoidArea avoidArea;
1433 sceneSession->GetSystemAvoidArea(rect1, avoidArea);
1434 WSRect rect2({0, 0, 10, 10});
1435 property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1436 sceneSession->SetSessionProperty(property);
1437 sceneSession->GetSystemAvoidArea(rect2, avoidArea);
1438 ASSERT_EQ(avoidArea.topRect_.posX_, 0);
1439
1440 property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1441 property->SetWindowFlags(static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_NEED_AVOID));
1442 sceneSession->SetSessionProperty(property);
1443 ASSERT_EQ(avoidArea.topRect_.posX_, 0);
1444 }
1445
1446 /**
1447 * @tc.name: CheckGetAvoidAreaAvailable
1448 * @tc.desc: normal function
1449 * @tc.type: FUNC
1450 */
1451 HWTEST_F(SceneSessionTest4, CheckGetAvoidAreaAvailable, TestSize.Level1)
1452 {
1453 SessionInfo info;
1454 info.abilityName_ = "CheckGetAvoidAreaAvailable";
1455 info.bundleName_ = "CheckGetAvoidAreaAvailable";
1456 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1457
1458 SystemSessionConfig systemConfig;
1459 systemConfig.windowUIType_ = WindowUIType::PHONE_WINDOW;
1460 session->SetSystemConfig(systemConfig);
1461 sptr<WindowSessionProperty> property = session->GetSessionProperty();
1462
1463 // main window
1464 property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1465 property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1466 session->SetSessionProperty(property);
1467 EXPECT_EQ(false, session->CheckGetAvoidAreaAvailable(AvoidAreaType::TYPE_NAVIGATION_INDICATOR));
1468
1469 // pad free multi window mode
1470 systemConfig.windowUIType_ = WindowUIType::PAD_WINDOW;
1471 systemConfig.freeMultiWindowEnable_ = true;
1472 systemConfig.freeMultiWindowSupport_ = true;
1473 session->SetSystemConfig(systemConfig);
1474 EXPECT_EQ(false, session->CheckGetAvoidAreaAvailable(AvoidAreaType::TYPE_SYSTEM));
1475
1476 // phone
1477 systemConfig.windowUIType_ = WindowUIType::PHONE_WINDOW;
1478 systemConfig.freeMultiWindowEnable_ = false;
1479 systemConfig.freeMultiWindowSupport_ = false;
1480 session->SetSystemConfig(systemConfig);
1481 property->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
1482 session->SetSessionProperty(property);
1483 EXPECT_EQ(true, session->CheckGetAvoidAreaAvailable(AvoidAreaType::TYPE_SYSTEM));
1484
1485 // PC
1486 property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1487 session->SetSessionProperty(property);
1488 systemConfig.windowUIType_ = WindowUIType::PC_WINDOW;
1489 session->SetSystemConfig(systemConfig);
1490 EXPECT_EQ(false, session->CheckGetAvoidAreaAvailable(AvoidAreaType::TYPE_SYSTEM));
1491 }
1492
1493 /**
1494 * @tc.name: CheckGetAvoidAreaAvailable02
1495 * @tc.desc: normal function
1496 * @tc.type: FUNC
1497 */
1498 HWTEST_F(SceneSessionTest4, CheckGetAvoidAreaAvailable02, TestSize.Level1)
1499 {
1500 SessionInfo info;
1501 info.abilityName_ = "CheckGetAvoidAreaAvailable02";
1502 info.bundleName_ = "CheckGetAvoidAreaAvailable02";
1503 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1504
1505 SystemSessionConfig systemConfig;
1506 sptr<WindowSessionProperty> property = session->GetSessionProperty();
1507 // system window
1508 property->SetWindowType(WindowType::WINDOW_TYPE_SYSTEM_FLOAT);
1509 systemConfig.windowUIType_ = WindowUIType::PHONE_WINDOW;
1510 session->SetSystemConfig(systemConfig);
1511 property->SetAvoidAreaOption(static_cast<uint32_t>(AvoidAreaOption::ENABLE_SYSTEM_WINDOW));
1512 session->SetSessionProperty(property);
1513 EXPECT_EQ(true, session->CheckGetAvoidAreaAvailable(AvoidAreaType::TYPE_SYSTEM));
1514
1515 property->SetAvoidAreaOption(0);
1516 session->SetSessionProperty(property);
1517 EXPECT_EQ(false, session->CheckGetAvoidAreaAvailable(AvoidAreaType::TYPE_SYSTEM));
1518
1519 // sub window
1520 property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1521 systemConfig.windowUIType_ = WindowUIType::PHONE_WINDOW;
1522 session->SetSystemConfig(systemConfig);
1523 property->SetAvoidAreaOption(static_cast<uint32_t>(AvoidAreaOption::ENABLE_APP_SUB_WINDOW));
1524 session->SetSessionProperty(property);
1525 EXPECT_EQ(true, session->CheckGetAvoidAreaAvailable(AvoidAreaType::TYPE_SYSTEM));
1526
1527 property->SetAvoidAreaOption(0);
1528 session->SetSessionProperty(property);
1529 EXPECT_EQ(false, session->CheckGetAvoidAreaAvailable(AvoidAreaType::TYPE_SYSTEM));
1530
1531 // UIExtension
1532 property->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION);
1533 session->SetSessionProperty(property);
1534 EXPECT_EQ(false, session->CheckGetAvoidAreaAvailable(AvoidAreaType::TYPE_SYSTEM));
1535 }
1536
1537 /**
1538 * @tc.name: CheckGetMainWindowAvoidAreaAvailable
1539 * @tc.desc: normal function
1540 * @tc.type: FUNC
1541 */
1542 HWTEST_F(SceneSessionTest4, CheckGetMainWindowAvoidAreaAvailable, TestSize.Level1)
1543 {
1544 SessionInfo info;
1545 info.abilityName_ = "CheckGetMainWindowAvoidAreaAvailable";
1546 info.bundleName_ = "CheckGetMainWindowAvoidAreaAvailable";
1547 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1548 sptr<WindowSessionProperty> property = session->GetSessionProperty();
1549
1550 SystemSessionConfig systemConfig;
1551 systemConfig.windowUIType_ = WindowUIType::PHONE_WINDOW;
1552 session->SetSystemConfig(systemConfig);
1553 EXPECT_EQ(false, session->CheckGetMainWindowAvoidAreaAvailable(WindowMode::WINDOW_MODE_FLOATING,
1554 AvoidAreaType::TYPE_NAVIGATION_INDICATOR));
1555
1556 // pad free multi window mode
1557 systemConfig.windowUIType_ = WindowUIType::PAD_WINDOW;
1558 systemConfig.freeMultiWindowEnable_ = true;
1559 systemConfig.freeMultiWindowSupport_ = true;
1560 session->SetSystemConfig(systemConfig);
1561 EXPECT_EQ(false, session->CheckGetMainWindowAvoidAreaAvailable(WindowMode::WINDOW_MODE_FLOATING,
1562 AvoidAreaType::TYPE_SYSTEM));
1563
1564 // phone
1565 systemConfig.windowUIType_ = WindowUIType::PHONE_WINDOW;
1566 systemConfig.freeMultiWindowEnable_ = false;
1567 systemConfig.freeMultiWindowSupport_ = false;
1568 session->SetSystemConfig(systemConfig);
1569 property->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
1570 session->SetSessionProperty(property);
1571 EXPECT_EQ(true, session->CheckGetMainWindowAvoidAreaAvailable(WindowMode::WINDOW_MODE_FULLSCREEN,
1572 AvoidAreaType::TYPE_SYSTEM));
1573 property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1574 session->SetSessionProperty(property);
1575 EXPECT_EQ(true, session->CheckGetMainWindowAvoidAreaAvailable(WindowMode::WINDOW_MODE_FLOATING,
1576 AvoidAreaType::TYPE_SYSTEM));
1577 }
1578
1579
1580 /**
1581 * @tc.name: CheckGetMainWindowAvoidAreaAvailable02
1582 * @tc.desc: normal function
1583 * @tc.type: FUNC
1584 */
1585 HWTEST_F(SceneSessionTest4, CheckGetMainWindowAvoidAreaAvailable02, TestSize.Level1)
1586 {
1587 SessionInfo info;
1588 info.abilityName_ = "CheckGetMainWindowAvoidAreaAvailable";
1589 info.bundleName_ = "CheckGetMainWindowAvoidAreaAvailable";
1590 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1591 sptr<WindowSessionProperty> property = session->GetSessionProperty();
1592
1593 SystemSessionConfig systemConfig;
1594 // pad
1595 systemConfig.windowUIType_ = WindowUIType::PAD_WINDOW;
1596 systemConfig.freeMultiWindowEnable_ = false;
1597 systemConfig.freeMultiWindowSupport_ = false;
1598 session->SetSystemConfig(systemConfig);
1599 property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1600 session->SetSessionProperty(property);
1601 EXPECT_EQ(true, session->CheckGetMainWindowAvoidAreaAvailable(WindowMode::WINDOW_MODE_FLOATING,
1602 AvoidAreaType::TYPE_SYSTEM));
1603
1604 // PC
1605 property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1606 session->SetSessionProperty(property);
1607 systemConfig.windowUIType_ = WindowUIType::PC_WINDOW;
1608 session->SetSystemConfig(systemConfig);
1609 EXPECT_EQ(false, session->CheckGetMainWindowAvoidAreaAvailable(WindowMode::WINDOW_MODE_FLOATING,
1610 AvoidAreaType::TYPE_SYSTEM));
1611
1612 sptr<CompatibleModeProperty> compatibleModeProperty = sptr<CompatibleModeProperty>::MakeSptr();
1613 compatibleModeProperty->SetIsAdaptToImmersive(true);
1614 property->SetCompatibleModeProperty(compatibleModeProperty);
1615 session->SetSessionProperty(property);
1616 EXPECT_EQ(true, session->CheckGetMainWindowAvoidAreaAvailable(WindowMode::WINDOW_MODE_FLOATING,
1617 AvoidAreaType::TYPE_SYSTEM));
1618 }
1619
1620 /**
1621 * @tc.name: CheckGetSubWindowAvoidAreaAvailable
1622 * @tc.desc: normal function
1623 * @tc.type: FUNC
1624 */
1625 HWTEST_F(SceneSessionTest4, CheckGetSubWindowAvoidAreaAvailable, TestSize.Level1)
1626 {
1627 SessionInfo info;
1628 info.abilityName_ = "CheckGetSubWindowAvoidAreaAvailable";
1629 info.bundleName_ = "CheckGetSubWindowAvoidAreaAvailable";
1630 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1631
1632 SystemSessionConfig systemConfig;
1633 systemConfig.windowUIType_ = WindowUIType::PHONE_WINDOW;
1634 session->SetSystemConfig(systemConfig);
1635
1636 sptr<WindowSessionProperty> property = session->GetSessionProperty();
1637 property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1638 property->SetAvoidAreaOption(static_cast<uint32_t>(AvoidAreaOption::ENABLE_APP_SUB_WINDOW));
1639 session->SetSessionProperty(property);
1640 EXPECT_EQ(true, session->CheckGetSubWindowAvoidAreaAvailable(WindowMode::WINDOW_MODE_FLOATING,
1641 AvoidAreaType::TYPE_SYSTEM));
1642
1643 property->SetAvoidAreaOption(0);
1644 session->SetSessionProperty(property);
1645 EXPECT_EQ(false, session->CheckGetSubWindowAvoidAreaAvailable(WindowMode::WINDOW_MODE_FLOATING,
1646 AvoidAreaType::TYPE_SYSTEM));
1647
1648 systemConfig.windowUIType_ = WindowUIType::PAD_WINDOW;
1649 systemConfig.freeMultiWindowEnable_ = true;
1650 systemConfig.freeMultiWindowSupport_ = true;
1651 session->SetSystemConfig(systemConfig);
1652 property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1653 session->SetSessionProperty(property);
1654 EXPECT_EQ(false, session->CheckGetSubWindowAvoidAreaAvailable(WindowMode::WINDOW_MODE_FLOATING,
1655 AvoidAreaType::TYPE_SYSTEM));
1656
1657 systemConfig.freeMultiWindowEnable_ = false;
1658 systemConfig.freeMultiWindowSupport_ = false;
1659 systemConfig.windowUIType_ = WindowUIType::PHONE_WINDOW;
1660 session->SetSystemConfig(systemConfig);
1661
1662 sptr<SceneSession> parentSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1663 SystemSessionConfig parentSystemConfig;
1664 parentSystemConfig.windowUIType_ = WindowUIType::PHONE_WINDOW;
1665 parentSession->SetSystemConfig(parentSystemConfig);
1666 sptr<WindowSessionProperty> parentProperty = parentSession->GetSessionProperty();
1667 parentProperty->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1668 parentProperty->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1669 parentSession->SetSessionProperty(parentProperty);
1670 session->SetParentSession(parentSession);
1671 EXPECT_EQ(false, session->CheckGetSubWindowAvoidAreaAvailable(WindowMode::WINDOW_MODE_FLOATING,
1672 AvoidAreaType::TYPE_NAVIGATION_INDICATOR));
1673
1674 WSRect sessionRect({0, 0, 10, 10});
1675 WSRect parentSessionRect({0, 0, 100, 100});
1676 session->SetSessionRect(sessionRect);
1677 parentSession->SetSessionRect(parentSessionRect);
1678 EXPECT_EQ(false, session->CheckGetSubWindowAvoidAreaAvailable(WindowMode::WINDOW_MODE_FLOATING,
1679 AvoidAreaType::TYPE_NAVIGATION_INDICATOR));
1680 }
1681
1682 /**
1683 * @tc.name: CheckGetSystemWindowAvoidAreaAvailable
1684 * @tc.desc: normal function
1685 * @tc.type: FUNC
1686 */
1687 HWTEST_F(SceneSessionTest4, CheckGetSystemWindowAvoidAreaAvailable, TestSize.Level1)
1688 {
1689 SessionInfo info;
1690 info.abilityName_ = "CheckGetSystemWindowAvoidAreaAvailable";
1691 info.bundleName_ = "CheckGetSystemWindowAvoidAreaAvailable";
1692 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1693
1694 SystemSessionConfig systemConfig;
1695 systemConfig.windowUIType_ = WindowUIType::PHONE_WINDOW;
1696 session->SetSystemConfig(systemConfig);
1697
1698 sptr<WindowSessionProperty> property = session->GetSessionProperty();
1699 property->SetAvoidAreaOption(static_cast<uint32_t>(AvoidAreaOption::ENABLE_SYSTEM_WINDOW));
1700 session->SetSessionProperty(property);
1701 EXPECT_EQ(true, session->CheckGetSystemWindowAvoidAreaAvailable());
1702
1703 property->SetAvoidAreaOption(0);
1704 session->SetSessionProperty(property);
1705 EXPECT_EQ(false, session->CheckGetSystemWindowAvoidAreaAvailable());
1706 }
1707
1708 /**
1709 * @tc.name: GetAvoidAreaBytype
1710 * @tc.desc: normal function
1711 * @tc.type: FUNC
1712 */
1713 HWTEST_F(SceneSessionTest4, GetAvoidAreaBytype, TestSize.Level1)
1714 {
1715 SessionInfo info;
1716 info.abilityName_ = "GetAvoidAreaBytype";
1717 info.bundleName_ = "GetAvoidAreaBytype";
1718 WSRect rect({0, 0, 10, 10});
1719 AvoidArea avoidArea;
1720 std::vector<sptr<SceneSession>> sessionVector;
1721 for (int i = 0; i < 1000; i++) {
1722 sessionVector.push_back(sptr<SceneSession>::MakeSptr(info, nullptr));
1723 sessionVector[i]->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_SYSTEM_FLOAT);
1724 sessionVector[i]->GetSessionProperty()->SetAvoidAreaOption(
1725 static_cast<uint32_t>(AvoidAreaOption::ENABLE_SYSTEM_WINDOW));
1726 }
1727 for (int i = 0; i < 1000; i++) {
1728 avoidArea = sessionVector[i]->GetAvoidAreaByType(AvoidAreaType::TYPE_SYSTEM, rect);
1729 ASSERT_EQ(avoidArea.topRect_.posX_, 0);
1730 }
1731 }
1732
1733 /**
1734 * @tc.name: NotifyFrameLayoutFinishFromAppTest
1735 * @tc.desc: NotifyFrameLayoutFinishFromApp test
1736 * @tc.type: FUNC
1737 */
1738 HWTEST_F(SceneSessionTest4, NotifyFrameLayoutFinishFromAppTest, TestSize.Level1)
1739 {
1740 SessionInfo info;
1741 info.abilityName_ = "NotifyFrameLayoutFinishFromAppTest";
1742 info.bundleName_ = "NotifyFrameLayoutFinishFromAppTest";
1743 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1744
1745 bool notifyListener = true;
1746 NotifySessionExceptionFunc func = [](const OHOS::Rosen::SessionInfo &sessionInfo,
1747 const OHOS::Rosen::ExceptionInfo &exceptionInfo,
__anonbd7f17800e02(const OHOS::Rosen::SessionInfo &sessionInfo, const OHOS::Rosen::ExceptionInfo &exceptionInfo, bool needRecover) 1748 bool needRecover) {};
1749 session->sessionExceptionFunc_ = func;
1750 WSRect rect = { 200, 200, 200, 200 };
1751 WSError res = session->NotifyFrameLayoutFinishFromApp(notifyListener, rect);
1752 ASSERT_EQ(res, WSError::WS_OK);
1753 }
1754
1755 /**
1756 * @tc.name: NotifyFrameLayoutFinishFromAppTest001
1757 * @tc.desc: NotifyFrameLayoutFinishFromApp test
1758 * @tc.type: FUNC
1759 */
1760 HWTEST_F(SceneSessionTest4, NotifyFrameLayoutFinishFromAppTest001, TestSize.Level1)
1761 {
1762 SessionInfo info;
1763 info.abilityName_ = "NotifyFrameLayoutFinishFromAppTest001";
1764 info.bundleName_ = "NotifyFrameLayoutFinishFromAppTest001";
1765 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1766
1767 bool notifyListener = true;
1768 NotifySessionExceptionFunc func = nullptr;
1769 session->sessionExceptionFunc_ = func;
1770 WSRect rect = { 200, 200, 200, 200 };
1771 WSError res = session->NotifyFrameLayoutFinishFromApp(notifyListener, rect);
1772 ASSERT_EQ(res, WSError::WS_OK);
1773 }
1774
1775 /**
1776 * @tc.name: NotifyFrameLayoutFinishFromAppTest002
1777 * @tc.desc: NotifyFrameLayoutFinishFromApp test
1778 * @tc.type: FUNC
1779 */
1780 HWTEST_F(SceneSessionTest4, NotifyFrameLayoutFinishFromAppTest002, TestSize.Level1)
1781 {
1782 SessionInfo info;
1783 info.abilityName_ = "NotifyFrameLayoutFinishFromAppTest002";
1784 info.bundleName_ = "NotifyFrameLayoutFinishFromAppTest002";
1785 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1786
1787 bool notifyListener = false;
1788 NotifySessionExceptionFunc func = nullptr;
1789 session->sessionExceptionFunc_ = func;
1790 WSRect rect = { 200, 200, 200, 200 };
1791 WSError res = session->NotifyFrameLayoutFinishFromApp(notifyListener, rect);
1792 ASSERT_EQ(res, WSError::WS_OK);
1793 }
1794
1795 /**
1796 * @tc.name: UpdateWaterfallModeTest
1797 * @tc.desc: UpdateWaterfallMode test
1798 * @tc.type: FUNC
1799 */
1800 HWTEST_F(SceneSessionTest4, UpdateWaterfallModeTest, TestSize.Level1)
1801 {
1802 SessionInfo info;
1803 info.abilityName_ = "UpdateWaterfallModeTest";
1804 info.bundleName_ = "UpdateWaterfallModeTest";
1805 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1806 session->pcFoldScreenController_ = nullptr;
1807 SessionEvent event = SessionEvent::EVENT_MAXIMIZE_WATERFALL;
1808 session->UpdateWaterfallMode(event);
1809
1810 session->pcFoldScreenController_ = sptr<PcFoldScreenController>::MakeSptr(wptr(session),
1811 session->GetPersistentId());
1812 event = SessionEvent::EVENT_MAXIMIZE_WATERFALL;
1813 session->UpdateWaterfallMode(event);
1814
1815 event = SessionEvent::EVENT_WATERFALL_TO_MAXIMIZE;
1816 session->UpdateWaterfallMode(event);
1817 ASSERT_EQ(session->pcFoldScreenController_->isFullScreenWaterfallMode_, false);
1818
1819 event = SessionEvent::EVENT_END;
1820 session->UpdateWaterfallMode(event);
1821 ASSERT_NE(session->pcFoldScreenController_, nullptr);
1822 }
1823
1824 /**
1825 * @tc.name: SyncSessionEventTest
1826 * @tc.desc: SyncSessionEvent function test
1827 * @tc.type: FUNC
1828 */
1829 HWTEST_F(SceneSessionTest4, SyncSessionEventTest, TestSize.Level1)
1830 {
1831 SessionInfo info;
1832 info.abilityName_ = "SyncSessionEventTest";
1833 info.bundleName_ = "SyncSessionEventTest";
1834 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1835 SessionEvent event = SessionEvent::EVENT_END;
1836 auto result = sceneSession->SyncSessionEvent(event);
1837 ASSERT_EQ(result, WSError::WS_ERROR_NULLPTR);
1838 }
1839
1840 /**
1841 * @tc.name: SyncSessionEventTest001
1842 * @tc.desc: SyncSessionEvent function test
1843 * @tc.type: FUNC
1844 */
1845 HWTEST_F(SceneSessionTest4, SyncSessionEventTest001, TestSize.Level1)
1846 {
1847 SessionInfo info;
1848 info.abilityName_ = "SyncSessionEventTest001";
1849 info.bundleName_ = "SyncSessionEventTest001";
1850 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1851 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1852 property->SetWindowType(WindowType::WINDOW_TYPE_GLOBAL_SEARCH);
1853 property->isSystemCalling_ = true;
1854 sceneSession->SetSessionProperty(property);
1855 sceneSession->isActive_ = false;
1856 sceneSession->moveDragController_ = nullptr;
1857
1858 SessionEvent event = SessionEvent::EVENT_START_MOVE;
1859 auto result = sceneSession->SyncSessionEvent(event);
1860 ASSERT_EQ(result, WSError::WS_ERROR_NULLPTR);
1861 }
1862
1863 /**
1864 * @tc.name: SyncSessionEventTest002
1865 * @tc.desc: SyncSessionEvent function test
1866 * @tc.type: FUNC
1867 */
1868 HWTEST_F(SceneSessionTest4, SyncSessionEventTest002, TestSize.Level1)
1869 {
1870 SessionInfo info;
1871 info.abilityName_ = "SyncSessionEventTest002";
1872 info.bundleName_ = "SyncSessionEventTest002";
1873 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1874 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1875 property->SetWindowType(WindowType::WINDOW_TYPE_GLOBAL_SEARCH);
1876 property->isSystemCalling_ = true;
1877 sceneSession->SetSessionProperty(property);
1878 sceneSession->isActive_ = false;
1879 sceneSession->moveDragController_ = sptr<MoveDragController>::MakeSptr(2024, sceneSession->GetWindowType());
1880
1881 SessionEvent event = SessionEvent::EVENT_END_MOVE;
1882 sceneSession->moveDragController_->isStartMove_ = true;
1883 auto result = sceneSession->SyncSessionEvent(event);
1884 ASSERT_EQ(result, WSError::WS_OK);
1885 }
1886
1887 /**
1888 * @tc.name: SyncSessionEventTest003
1889 * @tc.desc: SyncSessionEvent function test
1890 * @tc.type: FUNC
1891 */
1892 HWTEST_F(SceneSessionTest4, SyncSessionEventTest003, TestSize.Level1)
1893 {
1894 SessionInfo info;
1895 info.abilityName_ = "SyncSessionEventTest003";
1896 info.bundleName_ = "SyncSessionEventTest003";
1897 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1898 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1899 property->SetWindowType(WindowType::WINDOW_TYPE_GLOBAL_SEARCH);
1900 property->isSystemCalling_ = true;
1901 sceneSession->SetSessionProperty(property);
1902 sceneSession->isActive_ = false;
1903 sceneSession->moveDragController_ = sptr<MoveDragController>::MakeSptr(2024, sceneSession->GetWindowType());
1904
1905 SessionEvent event = SessionEvent::EVENT_END_MOVE;
1906 sceneSession->moveDragController_->isStartMove_ = false;
1907 auto result = sceneSession->SyncSessionEvent(event);
1908 ASSERT_EQ(result, WSError::WS_OK);
1909 }
1910
1911 /**
1912 * @tc.name: SyncSessionEventTest004
1913 * @tc.desc: SyncSessionEvent function test
1914 * @tc.type: FUNC
1915 */
1916 HWTEST_F(SceneSessionTest4, SyncSessionEventTest004, TestSize.Level1)
1917 {
1918 SessionInfo info;
1919 info.abilityName_ = "SyncSessionEventTest004";
1920 info.bundleName_ = "SyncSessionEventTest004";
1921 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1922 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1923 property->SetWindowType(WindowType::WINDOW_TYPE_GLOBAL_SEARCH);
1924 property->isSystemCalling_ = true;
1925 sceneSession->SetSessionProperty(property);
1926 sceneSession->isActive_ = false;
1927 sceneSession->moveDragController_ = sptr<MoveDragController>::MakeSptr(2024, sceneSession->GetWindowType());
1928
1929 SessionEvent event = SessionEvent::EVENT_START_MOVE;
1930 sceneSession->moveDragController_->isStartMove_ = false;
1931 auto result = sceneSession->SyncSessionEvent(event);
1932 ASSERT_EQ(result, WSError::WS_OK);
1933 }
1934
1935 /**
1936 * @tc.name: SyncSessionEventTest005
1937 * @tc.desc: SyncSessionEvent function test
1938 * @tc.type: FUNC
1939 */
1940 HWTEST_F(SceneSessionTest4, SyncSessionEventTest005, TestSize.Level1)
1941 {
1942 SessionInfo info;
1943 info.abilityName_ = "SyncSessionEventTest005";
1944 info.bundleName_ = "SyncSessionEventTest005";
1945 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1946 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1947 property->SetWindowType(WindowType::WINDOW_TYPE_GLOBAL_SEARCH);
1948 property->isSystemCalling_ = true;
1949 sceneSession->SetSessionProperty(property);
1950 sceneSession->isActive_ = false;
1951 sceneSession->moveDragController_ = sptr<MoveDragController>::MakeSptr(2024, sceneSession->GetWindowType());
1952
1953 SessionEvent event = SessionEvent::EVENT_START_MOVE;
1954 sceneSession->moveDragController_->isStartMove_ = true;
1955 auto result = sceneSession->SyncSessionEvent(event);
1956 ASSERT_EQ(result, WSError::WS_ERROR_REPEAT_OPERATION);
1957 }
1958
1959 /**
1960 * @tc.name: SetWinRectWhenUpdateRectTest
1961 * @tc.desc: SetWinRectWhenUpdateRect function test
1962 * @tc.type: FUNC
1963 */
1964 HWTEST_F(SceneSessionTest4, SetWinRectWhenUpdateRectTest, TestSize.Level1)
1965 {
1966 SessionInfo info;
1967 info.abilityName_ = "SetWinRectWhenUpdateRectTest";
1968 info.bundleName_ = "SetWinRectWhenUpdateRectTest";
1969 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1970 WSRect rect = { 10, 10, 200, 200 };
1971 sceneSession->isMidScene_ = false;
1972 sceneSession->SetWinRectWhenUpdateRect(rect);
1973 EXPECT_EQ(sceneSession->GetSessionRect().posX_, rect.posX_);
1974 EXPECT_EQ(sceneSession->GetSessionRect().posY_, rect.posY_);
1975 }
1976
1977 /**
1978 * @tc.name: SetWinRectWhenUpdateRectTest001
1979 * @tc.desc: SetWinRectWhenUpdateRect function test
1980 * @tc.type: FUNC
1981 */
1982 HWTEST_F(SceneSessionTest4, SetWinRectWhenUpdateRectTest001, TestSize.Level1)
1983 {
1984 SessionInfo info;
1985 info.abilityName_ = "SetWinRectWhenUpdateRectTest001";
1986 info.bundleName_ = "SetWinRectWhenUpdateRectTest001";
1987 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1988 WSRect rect = { 10, 10, 200, 200 };
1989 sceneSession->isMidScene_ = true;
1990 sceneSession->SetWinRectWhenUpdateRect(rect);
1991 EXPECT_EQ(sceneSession->GetSessionRect().posX_, rect.posX_);
1992 EXPECT_EQ(sceneSession->GetSessionRect().posY_, rect.posY_);
1993 }
1994
1995 /**
1996 * @tc.name: SetWinRectWhenUpdateRectTest002
1997 * @tc.desc: SetWinRectWhenUpdateRect function test
1998 * @tc.type: FUNC
1999 */
2000 HWTEST_F(SceneSessionTest4, SetWinRectWhenUpdateRectTest002, TestSize.Level1)
2001 {
2002 SessionInfo info;
2003 info.abilityName_ = "SetWinRectWhenUpdateRectTest002";
2004 info.bundleName_ = "SetWinRectWhenUpdateRectTest002";
2005 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
2006 WSRect rect = { 0, 10, 200, 200 };
2007 sceneSession->isMidScene_ = true;
2008 sceneSession->SetWinRectWhenUpdateRect(rect);
2009 EXPECT_EQ(sceneSession->GetSessionRect().posX_, rect.posX_);
2010 EXPECT_EQ(sceneSession->GetSessionRect().posY_, rect.posY_);
2011 }
2012
2013 /**
2014 * @tc.name: SetWinRectWhenUpdateRectTest003
2015 * @tc.desc: SetWinRectWhenUpdateRect function test
2016 * @tc.type: FUNC
2017 */
2018 HWTEST_F(SceneSessionTest4, SetWinRectWhenUpdateRectTest003, TestSize.Level1)
2019 {
2020 SessionInfo info;
2021 info.abilityName_ = "SetWinRectWhenUpdateRectTest003";
2022 info.bundleName_ = "SetWinRectWhenUpdateRectTest003";
2023 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
2024 WSRect rect = { 0, 0, 200, 200 };
2025 sceneSession->isMidScene_ = true;
2026 sceneSession->SetWinRectWhenUpdateRect(rect);
2027 EXPECT_EQ(sceneSession->GetSessionRect().width_, rect.width_);
2028 EXPECT_EQ(sceneSession->GetSessionRect().height_, rect.height_);
2029 }
2030
2031 /**
2032 * @tc.name: UpdatePiPTemplateInfoTest
2033 * @tc.desc: UpdatePiPTemplateInfo function test
2034 * @tc.type: FUNC
2035 */
2036 HWTEST_F(SceneSessionTest4, UpdatePiPTemplateInfoTest, Function | SmallTest | Level2)
2037 {
2038 SessionInfo info;
2039 info.abilityName_ = "UpdatePiPTemplateInfo";
2040 info.bundleName_ = "UpdatePiPTemplateInfo";
2041 sptr<SceneSession> sceneSession = sptr<MainSession>::MakeSptr(info, nullptr);
2042 sceneSession->isTerminating_ = false;
2043 PiPTemplateInfo templateInfo;
2044 auto result = sceneSession->UpdatePiPTemplateInfo(templateInfo);
2045 ASSERT_EQ(result, WSError::WS_OK);
2046 }
2047 }
2048 }
2049 }