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 #include <pointer_event.h>
18
19 #include "common/include/session_permission.h"
20 #include "display_manager.h"
21 #include "input_event.h"
22 #include "key_event.h"
23
24 #include "mock/mock_session_stage.h"
25 #include "mock/mock_scene_session.h"
26 #include "pointer_event.h"
27
28 #include "screen_manager.h"
29 #include "session/host/include/sub_session.h"
30 #include "session/host/include/main_session.h"
31 #include "session/host/include/scene_session.h"
32 #include "session/host/include/system_session.h"
33 #include "session/screen/include/screen_session.h"
34 #include "screen_session_manager_client/include/screen_session_manager_client.h"
35 #include "wm_common.h"
36 #include "window_helper.h"
37 #include "ui/rs_surface_node.h"
38
39 using namespace testing;
40 using namespace testing::ext;
41 namespace OHOS {
42 namespace Rosen {
43
44 class GetKeyboardGravitySceneSession : public SceneSession {
45 public:
GetKeyboardGravitySceneSession(const SessionInfo & info,const sptr<SpecificSessionCallback> & specificCallback)46 GetKeyboardGravitySceneSession(const SessionInfo& info, const sptr<SpecificSessionCallback>& specificCallback)
47 : SceneSession(info, specificCallback)
48 {
49 }
50
GetKeyboardGravity() const51 SessionGravity GetKeyboardGravity() const override
52 {
53 return SessionGravity::SESSION_GRAVITY_FLOAT;
54 }
55 };
56
57 class SceneSessionTest5 : public testing::Test {
58 public:
59 static void SetUpTestCase();
60 static void TearDownTestCase();
61 void SetUp() override;
62 void TearDown() override;
63 };
64
SetUpTestCase()65 void SceneSessionTest5::SetUpTestCase()
66 {
67 }
68
TearDownTestCase()69 void SceneSessionTest5::TearDownTestCase()
70 {
71 }
72
SetUp()73 void SceneSessionTest5::SetUp()
74 {
75 }
76
TearDown()77 void SceneSessionTest5::TearDown()
78 {
79 }
80
81 namespace {
82
83 /**
84 * @tc.name: GetSystemAvoidArea
85 * @tc.desc: GetSystemAvoidArea function
86 * @tc.type: FUNC
87 */
88 HWTEST_F(SceneSessionTest5, GetSystemAvoidArea, Function | SmallTest | Level2)
89 {
90 SessionInfo info;
91 info.abilityName_ = "GetSystemAvoidArea";
92 info.bundleName_ = "GetSystemAvoidArea";
93
94 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
95 EXPECT_NE(session, nullptr);
96 WSRect rect;
97 AvoidArea avoidArea;
98 session->property_->SetWindowFlags(0);
99 session->property_->SetWindowMode(WindowMode::WINDOW_MODE_UNDEFINED);
100 session->isDisplayStatusBarTemporarily_.store(true);
101 session->GetSystemAvoidArea(rect, avoidArea);
102 ASSERT_NE(session->GetSessionProperty(), nullptr);
103 EXPECT_EQ(WindowMode::WINDOW_MODE_UNDEFINED, session->GetSessionProperty()->GetWindowMode());
104
105 session->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
106 info.windowType_ = static_cast<uint32_t>(WindowType::APP_MAIN_WINDOW_END);
107 session->isDisplayStatusBarTemporarily_.store(false);
108 session->GetSystemAvoidArea(rect, avoidArea);
109
110 info.windowType_ = static_cast<uint32_t>(WindowType::APP_MAIN_WINDOW_BASE);
111 SystemSessionConfig systemConfig;
112 systemConfig.windowUIType_ = WindowUIType::PC_WINDOW;
113 session->SetSystemConfig(systemConfig);
114 sptr<SceneSession::SpecificSessionCallback> specificCallback =
115 sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
116 session->specificCallback_ = specificCallback;
117 session->specificCallback_->onGetSceneSessionVectorByTypeAndDisplayId_ = nullptr;
118 session->GetSystemAvoidArea(rect, avoidArea);
119
120 systemConfig.windowUIType_ = WindowUIType::PHONE_WINDOW;
__anon692f4e5f0202(WindowType type, uint64_t displayId) 121 GetSceneSessionVectorByTypeAndDisplayIdCallback func = [&session](WindowType type, uint64_t displayId) {
122 std::vector<sptr<SceneSession>> vSession;
123 vSession.push_back(session);
124 return vSession;
125 };
126 session->property_->SetDisplayId(2024);
127 sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr();
128 ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear();
129 ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(2024, screenSession));
130 session->specificCallback_->onGetSceneSessionVectorByTypeAndDisplayId_ = func;
131 session->GetSystemAvoidArea(rect, avoidArea);
132 ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear();
133 }
134
135 /**
136 * @tc.name: HookAvoidAreaInCompatibleMode
137 * @tc.desc: HookAvoidAreaInCompatibleMode function
138 * @tc.type: FUNC
139 */
140 HWTEST_F(SceneSessionTest5, HookAvoidAreaInCompatibleMode, Function | SmallTest | Level2)
141 {
142 SessionInfo info;
143 info.abilityName_ = "HookAvoidAreaInCompatibleMode";
144 info.bundleName_ = "HookAvoidAreaInCompatibleMode";
145
146 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
147 EXPECT_NE(session, nullptr);
148 WSRect rect = {800, 100, 1000, 1000};
149 AvoidArea avoidArea;
150 avoidArea.topRect_ = {-1, -1, -1, -1};
151 avoidArea.bottomRect_ = {-1, -1, -1, -1};
152 Rect invalidRect = {-1, -1, -1, -1};
153 // hook Func only support compatibleMode
154 session->SetCompatibleModeInPc(false, true);
155 session->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
156 session->HookAvoidAreaInCompatibleMode(rect, avoidArea, AvoidAreaType::TYPE_SYSTEM);
157 EXPECT_TRUE(avoidArea.topRect_ == invalidRect);
158 session->SetCompatibleModeInPc(true, true);
159 session->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
160 session->HookAvoidAreaInCompatibleMode(rect, avoidArea, AvoidAreaType::TYPE_SYSTEM);
161 EXPECT_TRUE(avoidArea.topRect_ == invalidRect);
162
163 // test top system avoidArea
164 session->SetCompatibleModeInPc(true, true);
165 session->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
166 session->HookAvoidAreaInCompatibleMode(rect, avoidArea, AvoidAreaType::TYPE_SYSTEM);
167 auto vpr = 3.5f;
168 Rect targetRect = {rect.posX_, rect.posY_, 40 * vpr, rect.width_};
169 EXPECT_FALSE(avoidArea.topRect_ == targetRect);
170
171 // test buttom aiBar avoidArea
172 session->HookAvoidAreaInCompatibleMode(rect, avoidArea, AvoidAreaType::TYPE_NAVIGATION_INDICATOR);
173 targetRect = {rect.posX_, rect.posY_ + rect.height_ - 28 * vpr, rect.width_, 28 * vpr};
174 EXPECT_TRUE(avoidArea.bottomRect_ == targetRect);
175 }
176
177 /**
178 * @tc.name: GetSystemAvoidArea01
179 * @tc.desc: GetSystemAvoidArea01 function
180 * @tc.type: FUNC
181 */
182 HWTEST_F(SceneSessionTest5, GetSystemAvoidArea01, Function | SmallTest | Level2)
183 {
184 SessionInfo info;
185 info.abilityName_ = "GetSystemAvoidArea01";
186 info.bundleName_ = "GetSystemAvoidArea01";
187
188 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
189 EXPECT_NE(session, nullptr);
190 WSRect rect;
191 AvoidArea avoidArea;
192 session->property_->SetWindowFlags(0);
193
194 session->isDisplayStatusBarTemporarily_.store(false);
195
196 info.windowType_ = static_cast<uint32_t>(WindowType::APP_MAIN_WINDOW_BASE);
197 SystemSessionConfig systemConfig;
198
199 session->SetSystemConfig(systemConfig);
200 sptr<SceneSession::SpecificSessionCallback> specificCallback =
201 sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
202 session->specificCallback_ = specificCallback;
203
204 systemConfig.windowUIType_ = WindowUIType::PHONE_WINDOW;
__anon692f4e5f0302(WindowType type, uint64_t displayId) 205 GetSceneSessionVectorByTypeAndDisplayIdCallback func = [&session](WindowType type, uint64_t displayId) {
206 std::vector<sptr<SceneSession>> vSession;
207 vSession.push_back(session);
208 return vSession;
209 };
210 session->property_->SetDisplayId(2024);
211 sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr();
212 ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear();
213 ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(2024, screenSession));
214 session->specificCallback_->onGetSceneSessionVectorByTypeAndDisplayId_ = func;
215 ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear();
216
217 session->property_->SetDisplayId(1024);
218 session->Session::SetFloatingScale(0.0f);
219
220 session->Session::SetFloatingScale(0.5f);
221 EXPECT_EQ(0.5f, session->Session::GetFloatingScale());
222 session->property_->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY);
223 session->GetSystemAvoidArea(rect, avoidArea);
224 session->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
225 session->GetSystemAvoidArea(rect, avoidArea);
226 rect.height_ = 3;
227 rect.width_ =4;
228 session->GetSystemAvoidArea(rect, avoidArea);
229
230 session->isVisible_ = true;
231 session->property_->SetWindowMode(WindowMode::WINDOW_MODE_UNDEFINED);
232 session->GetSystemAvoidArea(rect, avoidArea);
233 }
234
235 /**
236 * @tc.name: NotifyOutsideDownEvent
237 * @tc.desc: NotifyOutsideDownEvent function
238 * @tc.type: FUNC
239 */
240 HWTEST_F(SceneSessionTest5, NotifyOutsideDownEvent, Function | SmallTest | Level2)
241 {
242 SessionInfo info;
243 info.abilityName_ = "NotifyOutsideDownEvent";
244 info.bundleName_ = "NotifyOutsideDownEvent";
245
246 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
247 EXPECT_NE(session, nullptr);
248 std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
249 pointerEvent->SetPointerAction(2);
250 pointerEvent->RemoveAllPointerItems();
251 session->NotifyOutsideDownEvent(pointerEvent);
252 pointerEvent->SetPointerAction(8);
253 MMI::PointerEvent::PointerItem pointerItem;
254 pointerItem.SetPointerId(2024);
255 pointerEvent->AddPointerItem(pointerItem);
256 pointerEvent->SetPointerId(2024);
257 session->NotifyOutsideDownEvent(pointerEvent);
258 sptr<SceneSession::SpecificSessionCallback> specificCallback =
259 sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
260 session->specificCallback_ = specificCallback;
261 session->specificCallback_->onOutsideDownEvent_ = nullptr;
262 session->NotifyOutsideDownEvent(pointerEvent);
__anon692f4e5f0402(int32_t x, int32_t y) 263 OnOutsideDownEvent func = [](int32_t x, int32_t y) {
264 return;
265 };
266 session->specificCallback_->onOutsideDownEvent_ = func;
267 session->NotifyOutsideDownEvent(pointerEvent);
268 auto res = pointerEvent->GetPointerItem(2024, pointerItem);
269 EXPECT_EQ(true, res);
270
271 pointerEvent->SetPointerAction(5);
272 session->NotifyOutsideDownEvent(pointerEvent);
273 pointerEvent->RemoveAllPointerItems();
274 }
275
276 /**
277 * @tc.name: TransferPointerEventInnerTest
278 * @tc.desc: TransferPointerEventInner function
279 * @tc.type: FUNC
280 */
281 HWTEST_F(SceneSessionTest5, TransferPointerEventInner, Function | SmallTest | Level2)
282 {
283 SessionInfo info;
284 info.abilityName_ = "TransferPointerEventInner";
285 info.bundleName_ = "TransferPointerEventInner";
286
287 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
288 EXPECT_NE(session, nullptr);
289 std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
290
291 info.isSystem_ = false;
292 pointerEvent->SetPointerAction(9);
293
294 sptr<SceneSession::SpecificSessionCallback> specificCallback =
295 sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
296 session->specificCallback_ = specificCallback;
297 session->specificCallback_->onSessionTouchOutside_ = nullptr;
298 EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, session->TransferPointerEventInner(pointerEvent, false));
299
__anon692f4e5f0502(int32_t persistentId) 300 NotifySessionTouchOutsideCallback func = [](int32_t persistentId) {
301 return;
302 };
303 session->specificCallback_->onSessionTouchOutside_ = func;
304 EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, session->TransferPointerEventInner(pointerEvent, false));
305 pointerEvent->SetPointerAction(2);
306 EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, session->TransferPointerEventInner(pointerEvent, false));
307 }
308
309 /**
310 * @tc.name: TransferPointerEventInnerTest001
311 * @tc.desc: TransferPointerEventInner function
312 * @tc.type: FUNC
313 */
314 HWTEST_F(SceneSessionTest5, TransferPointerEventInnerTest001, Function | SmallTest | Level2)
315 {
316 SessionInfo info;
317 info.abilityName_ = "TransferPointerEventInnerTest001";
318 info.bundleName_ = "TransferPointerEventInnerTest001";
319 info.windowType_ = static_cast<uint32_t>(WindowType::APP_MAIN_WINDOW_BASE);
320 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
321 EXPECT_NE(session, nullptr);
322 std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
323 session->property_->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY);
324 session->property_->SetMaximizeMode(MaximizeMode::MODE_RECOVER);
325 session->ClearDialogVector();
326 session->moveDragController_ = sptr<MoveDragController>::MakeSptr(2024, session->GetWindowType());
327 SystemSessionConfig systemConfig;
328 systemConfig.isSystemDecorEnable_ = false;
329 systemConfig.decorWindowModeSupportType_ = 2;
330 session->SetSystemConfig(systemConfig);
331 EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, session->TransferPointerEventInner(pointerEvent, false));
332
333 session->BindDialogToParentSession(session);
334 session->SetSessionState(SessionState::STATE_ACTIVE);
335 pointerEvent->SetPointerAction(5);
336 session->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
337 session->property_->SetDragEnabled(false);
338 systemConfig.isSystemDecorEnable_ = true;
339
340 session->moveDragController_->isStartDrag_ = false;
341 EXPECT_EQ(WSError::WS_ERROR_NULLPTR, session->TransferPointerEventInner(pointerEvent, false));
342
343 pointerEvent->SetPointerAction(2);
344 EXPECT_EQ(WSError::WS_OK, session->TransferPointerEventInner(pointerEvent, false));
345
346 session->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
347 session->property_->SetDecorEnable(false);
348 EXPECT_EQ(WSError::WS_OK, session->TransferPointerEventInner(pointerEvent, false));
349
350 pointerEvent->SetPointerAction(5);
351 session->property_->SetDragEnabled(true);
352 systemConfig.windowUIType_ = WindowUIType::PHONE_WINDOW;
353 systemConfig.freeMultiWindowSupport_ = false;
354 session->moveDragController_->isStartDrag_ = true;
355 EXPECT_EQ(WSError::WS_ERROR_NULLPTR, session->TransferPointerEventInner(pointerEvent, false));
356
357 systemConfig.windowUIType_ = WindowUIType::PC_WINDOW;
358 EXPECT_EQ(WSError::WS_ERROR_NULLPTR, session->TransferPointerEventInner(pointerEvent, false));
359 session->ClearDialogVector();
360 }
361
362 /**
363 * @tc.name: SetSurfaceBounds01
364 * @tc.desc: SetSurfaceBounds function
365 * @tc.type: FUNC
366 */
367 HWTEST_F(SceneSessionTest5, SetSurfaceBounds01, Function | SmallTest | Level2)
368 {
369 SessionInfo info;
370 info.abilityName_ = "SetSurfaceBounds01";
371 info.bundleName_ = "SetSurfaceBounds01";
372 info.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_FLOAT);
373 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
374 struct RSSurfaceNodeConfig config;
375 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
376 session->surfaceNode_ = nullptr;
377 WSRect preRect = { 20, 20, 800, 800 };
378 WSRect rect = { 30, 30, 900, 900 };
379 session->SetSessionRect(preRect);
380 session->SetSurfaceBounds(rect, false);
381
382 session->surfaceNode_ = surfaceNode;
383 session->SetSurfaceBounds(rect, false);
384 EXPECT_EQ(preRect, session->GetSessionRect());
385 }
386
387 /**
388 * @tc.name: OnLayoutFullScreenChange
389 * @tc.desc: OnLayoutFullScreenChange function
390 * @tc.type: FUNC
391 */
392 HWTEST_F(SceneSessionTest5, OnLayoutFullScreenChange, Function | SmallTest | Level2)
393 {
394 SessionInfo info;
395 info.abilityName_ = "OnLayoutFullScreenChange";
396 info.bundleName_ = "OnLayoutFullScreenChange";
397 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
398 EXPECT_NE(session, nullptr);
__anon692f4e5f0602(bool isLayoutFullScreen) 399 NotifyLayoutFullScreenChangeFunc func = [](bool isLayoutFullScreen) {};
400 session->onLayoutFullScreenChangeFunc_ = func;
401 EXPECT_EQ(WSError::WS_OK, session->OnLayoutFullScreenChange(true));
402 }
403
404 /**
405 * @tc.name: RegisterLayoutFullScreenChangeCallback
406 * @tc.desc: test RegisterLayoutFullScreenChangeCallback
407 * @tc.type: FUNC
408 */
409 HWTEST_F(SceneSessionTest5, RegisterLayoutFullScreenChangeCallback, Function | SmallTest | Level2)
410 {
411 SessionInfo info;
412 info.abilityName_ = "RegisterLayoutFullScreenChangeCallback";
413 info.bundleName_ = "RegisterLayoutFullScreenChangeCallback";
414 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
415 sceneSession->onLayoutFullScreenChangeFunc_ = nullptr;
__anon692f4e5f0702(bool isLayoutFullScreen) 416 NotifyLayoutFullScreenChangeFunc func = [](bool isLayoutFullScreen) {};
417
418 sceneSession->RegisterLayoutFullScreenChangeCallback(std::move(func));
419 ASSERT_NE(sceneSession->onLayoutFullScreenChangeFunc_, nullptr);
420 }
421
422 /**
423 * @tc.name: OnDefaultDensityEnabled
424 * @tc.desc: OnDefaultDensityEnabled function
425 * @tc.type: FUNC
426 */
427 HWTEST_F(SceneSessionTest5, OnDefaultDensityEnabled, Function | SmallTest | Level2)
428 {
429 SessionInfo info;
430 info.abilityName_ = "OnDefaultDensityEnabled";
431 info.bundleName_ = "OnDefaultDensityEnabled";
432 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
433 EXPECT_NE(session, nullptr);
434 EXPECT_EQ(WSError::WS_OK, session->OnDefaultDensityEnabled(true));
435
436 session->onDefaultDensityEnabledFunc_ = nullptr;
437 EXPECT_EQ(WSError::WS_OK, session->OnDefaultDensityEnabled(true));
438
__anon692f4e5f0802(bool isLDefaultDensityEnabled) 439 NotifyDefaultDensityEnabledFunc func = [](bool isLDefaultDensityEnabled) {};
440 session->onDefaultDensityEnabledFunc_ = func;
441 EXPECT_EQ(WSError::WS_OK, session->OnDefaultDensityEnabled(true));
442 }
443
444 /**
445 * @tc.name: UpdateSessionPropertyByAction
446 * @tc.desc: UpdateSessionPropertyByAction function01
447 * @tc.type: FUNC
448 */
449 HWTEST_F(SceneSessionTest5, UpdateSessionPropertyByAction, Function | SmallTest | Level2)
450 {
451 SessionInfo info;
452 info.abilityName_ = "UpdateSessionPropertyByAction";
453 info.bundleName_ = "UpdateSessionPropertyByAction";
454 info.windowType_ = static_cast<uint32_t>(WindowType::APP_MAIN_WINDOW_BASE);
455 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
456 EXPECT_NE(session, nullptr);
457 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
458 EXPECT_EQ(WMError::WM_ERROR_NULLPTR, session->UpdateSessionPropertyByAction
459 (nullptr, WSPropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE));
460 EXPECT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, session->UpdateSessionPropertyByAction
461 (property, WSPropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE));
462 }
463
464 /**
465 * @tc.name: SetSessionRectChangeCallback
466 * @tc.desc: SetSessionRectChangeCallback function01
467 * @tc.type: FUNC
468 */
469 HWTEST_F(SceneSessionTest5, SetSessionRectChangeCallback, Function | SmallTest | Level2)
470 {
471 SessionInfo info;
472 info.abilityName_ = "SetSessionRectChangeCallback";
473 info.bundleName_ = "SetSessionRectChangeCallback";
474 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
475 EXPECT_NE(session, nullptr);
476 WSRect rec = { 1, 1, 1, 1 };
477 NotifySessionRectChangeFunc func = [](const WSRect& rect, SizeChangeReason reason,
__anon692f4e5f0902(const WSRect& rect, SizeChangeReason reason, DisplayId displayId, const RectAnimationConfig& rectAnimationConfig) 478 DisplayId displayId, const RectAnimationConfig& rectAnimationConfig) {
479 return;
480 };
481 session->SetSessionRectChangeCallback(nullptr);
482 info.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
483 session->SetSessionRectChangeCallback(func);
484 info.windowType_ = static_cast<uint32_t>(WindowType::APP_MAIN_WINDOW_BASE);
485 session->SetSessionRectChangeCallback(func);
486 rec.width_ = 0;
487 session->SetSessionRectChangeCallback(func);
488 rec.height_ = 0;
489 session->SetSessionRectChangeCallback(func);
490 EXPECT_EQ(WindowType::APP_MAIN_WINDOW_BASE, session->GetWindowType());
491 }
492
493 /**
494 * @tc.name: SetSessionRectChangeCallback02
495 * @tc.desc: SetSessionRectChangeCallback02 function01
496 * @tc.type: FUNC
497 */
498 HWTEST_F(SceneSessionTest5, SetSessionRectChangeCallback02, Function | SmallTest | Level2)
499 {
500 SessionInfo info;
501 info.abilityName_ = "SetSessionRectChangeCallback02";
502 info.bundleName_ = "SetSessionRectChangeCallback02";
503 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
504 EXPECT_NE(session, nullptr);
505 WSRect rec = { 1, 1, 1, 1 };
506 NotifySessionRectChangeFunc func = [](const WSRect& rect, SizeChangeReason reason,
__anon692f4e5f0a02(const WSRect& rect, SizeChangeReason reason, DisplayId displayId, const RectAnimationConfig& rectAnimationConfig) 507 DisplayId displayId, const RectAnimationConfig& rectAnimationConfig) {
508 return;
509 };
510 session->SetSessionRectChangeCallback(nullptr);
511
512 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
513 EXPECT_NE(property, nullptr);
514 property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
515 session->SetSessionProperty(property);
516 session->SetSessionRectChangeCallback(func);
517
518 property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
519 session->SetSessionProperty(property);
520 session->SetSessionRequestRect(rec);
521 session->SetSessionRectChangeCallback(func);
522
523 rec.width_ = 0;
524 session->SetSessionRequestRect(rec);
525 session->SetSessionRectChangeCallback(func);
526
527 rec.height_ = 0;
528 session->SetSessionRequestRect(rec);
529 session->SetSessionRectChangeCallback(func);
530 EXPECT_EQ(WindowType::APP_MAIN_WINDOW_BASE, session->GetWindowType());
531 }
532
533 /**
534 * @tc.name: SetSessionRectChangeCallback03
535 * @tc.desc: SetSessionRectChangeCallback
536 * @tc.type: FUNC
537 */
538 HWTEST_F(SceneSessionTest5, SetSessionRectChangeCallback03, Function | SmallTest | Level2)
539 {
540 SessionInfo info;
541 info.abilityName_ = "SetSessionRectChangeCallback03";
542 info.bundleName_ = "SetSessionRectChangeCallback03";
543 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
544 property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
545 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
546 session->SetSessionProperty(property);
547 WSRect rec = { 1, 1, 1, 1 };
548 NotifySessionRectChangeFunc func = [](const WSRect& rect, const SizeChangeReason reason,
__anon692f4e5f0b02(const WSRect& rect, const SizeChangeReason reason, DisplayId displayId, const RectAnimationConfig& rectAnimationConfig) 549 DisplayId displayId, const RectAnimationConfig& rectAnimationConfig) {
550 return;
551 };
552 session->SetSessionRequestRect(rec);
553 session->SetSessionRectChangeCallback(nullptr);
554
555 rec.width_ = 0;
556 session->SetSessionRequestRect(rec);
557 session->SetSessionRectChangeCallback(nullptr);
558
559 rec.height_ = 0;
560 rec.width_ = 1;
561 session->SetSessionRequestRect(rec);
562 session->SetSessionRectChangeCallback(nullptr);
563
564 rec.height_ = 0;
565 rec.width_ = 0;
566 session->SetSessionRequestRect(rec);
567 session->SetSessionRectChangeCallback(nullptr);
568 EXPECT_EQ(WindowType::APP_MAIN_WINDOW_BASE, session->GetWindowType());
569 }
570
571 /**
572 * @tc.name: GetSystemAvoidArea02
573 * @tc.desc: GetSystemAvoidArea02 function
574 * @tc.type: FUNC
575 */
576 HWTEST_F(SceneSessionTest5, GetSystemAvoidArea02, Function | SmallTest | Level2)
577 {
578 SessionInfo info;
579 info.abilityName_ = "GetSystemAvoidArea02";
580 info.bundleName_ = "GetSystemAvoidArea02";
581
582 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
583 EXPECT_NE(session, nullptr);
584 ASSERT_NE(session->GetSessionProperty(), nullptr);
585 session->GetSessionProperty()->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
586 info.windowType_ = static_cast<uint32_t>(WindowType::APP_MAIN_WINDOW_BASE);
587
588 SystemSessionConfig systemConfig;
589 systemConfig.windowUIType_ = WindowUIType::PHONE_WINDOW;
590 session->SetSystemConfig(systemConfig);
591 ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear();
592 session->GetSessionProperty()->SetDisplayId(1664);
593 session->Session::SetFloatingScale(0.02f);
594 WSRect rect;
595 AvoidArea avoidArea;
596 session->GetSystemAvoidArea(rect, avoidArea);
597 EXPECT_EQ(0.02f, session->Session::GetFloatingScale());
598
599 session->Session::SetFloatingScale(0.5f);
600 session->property_->SetWindowMode(WindowMode::WINDOW_MODE_UNDEFINED);
601 session->GetSystemAvoidArea(rect, avoidArea);
602 session->GetSessionProperty()->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
603 rect.height_ = 2;
604 rect.width_ =1 ;
605 session->GetSystemAvoidArea(rect, avoidArea);
606 rect.height_ = 1;
607 session->GetSystemAvoidArea(rect, avoidArea);
608 }
609
610 /**
611 * @tc.name: AdjustRectByAspectRatio
612 * @tc.desc: AdjustRectByAspectRatio function01
613 * @tc.type: FUNC
614 */
615 HWTEST_F(SceneSessionTest5, AdjustRectByAspectRatio, Function | SmallTest | Level2)
616 {
617 SessionInfo info;
618 info.abilityName_ = "AdjustRectByAspectRatio";
619 info.bundleName_ = "AdjustRectByAspectRatio";
620 info.isSystem_ = false;
621 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
622 EXPECT_NE(session, nullptr);
623 WSRect rect;
624 EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect));
625 session->property_->SetWindowMode(WindowMode::WINDOW_MODE_UNDEFINED);
626 EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect));
627 session->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
628 session->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
629 EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect));
630 session->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
631 EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect));
632 }
633
634 /**
635 * @tc.name: AdjustRectByAspectRatio01
636 * @tc.desc: AdjustRectByAspectRatio function01
637 * @tc.type: FUNC
638 */
639 HWTEST_F(SceneSessionTest5, AdjustRectByAspectRatio01, Function | SmallTest | Level2)
640 {
641 SessionInfo info;
642 info.abilityName_ = "AdjustRectByAspectRatio01";
643 info.bundleName_ = "AdjustRectByAspectRatio01";
644 info.isSystem_ = false;
645 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
646 EXPECT_NE(session, nullptr);
647 WSRect rect;
648 session->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
649 info.windowType_ = static_cast<uint32_t>(WindowType::APP_MAIN_WINDOW_BASE);
650 session->aspectRatio_ = 0.5f;
651 EXPECT_NE(nullptr, DisplayManager::GetInstance().GetDefaultDisplay());
652
653 SystemSessionConfig systemConfig;
654 systemConfig.isSystemDecorEnable_ = true;
655 systemConfig.decorWindowModeSupportType_ = 2;
656 session->SetSystemConfig(systemConfig);
657 EXPECT_EQ(true, session->AdjustRectByAspectRatio(rect));
658
659 systemConfig.isSystemDecorEnable_ = false;
660 EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect));
661 }
662
663 /**
664 * @tc.name: OnMoveDragCallback
665 * @tc.desc: OnMoveDragCallback function01
666 * @tc.type: FUNC
667 */
668 HWTEST_F(SceneSessionTest5, OnMoveDragCallback, Function | SmallTest | Level2)
669 {
670 SessionInfo info;
671 info.abilityName_ = "OnMoveDragCallback";
672 info.bundleName_ = "OnMoveDragCallback";
673 info.isSystem_ = false;
674 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
__anon692f4e5f0c02(const std::shared_ptr<VsyncCallback>& callback) 675 session->SetRequestNextVsyncFunc([](const std::shared_ptr<VsyncCallback>& callback) {});
676 EXPECT_NE(nullptr, session->requestNextVsyncFunc_);
677 session->moveDragController_ = nullptr;
678 SizeChangeReason reason = { SizeChangeReason::DRAG };
679 session->OnMoveDragCallback(reason);
680 session->moveDragController_ = sptr<MoveDragController>::MakeSptr(2024, session->GetWindowType());
681 session->OnMoveDragCallback(reason);
682
683 reason = SizeChangeReason::DRAG_END;
684 session->OnMoveDragCallback(reason);
685
686 reason = SizeChangeReason::DRAG_MOVE;
687 session->OnMoveDragCallback(reason);
688
689 reason = SizeChangeReason::DRAG_START;
690 session->OnMoveDragCallback(reason);
691 EXPECT_EQ(WSError::WS_OK, session->UpdateSizeChangeReason(reason));
692
693 session->moveDragController_ = sptr<MoveDragController>::MakeSptr(2024, session->GetWindowType());
694 EXPECT_NE(session->moveDragController_, nullptr);
695 session->property_->compatibleModeInPc_ = true;
696 session->OnMoveDragCallback(reason);
697 EXPECT_EQ(WSError::WS_OK, session->UpdateSizeChangeReason(reason));
698 }
699
700 /**
701 * @tc.name: UpdateWinRectForSystemBar
702 * @tc.desc: UpdateWinRectForSystemBar function01
703 * @tc.type: FUNC
704 */
705 HWTEST_F(SceneSessionTest5, UpdateWinRectForSystemBar, Function | SmallTest | Level2)
706 {
707 SessionInfo info;
708 info.abilityName_ = "UpdateWinRectForSystemBar";
709 info.bundleName_ = "UpdateWinRectForSystemBar";
710 info.isSystem_ = false;
711 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
712 EXPECT_NE(session, nullptr);
713 sptr<SceneSession::SpecificSessionCallback> specificCallback =
714 sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
715 specificCallback->onGetSceneSessionVectorByTypeAndDisplayId_ = nullptr;
716 session->specificCallback_ = specificCallback;
717 WSRect rect = { 1, 10, 3, 4 };
718 session->UpdateWinRectForSystemBar(rect);
719 GetSceneSessionVectorByTypeAndDisplayIdCallback func = [session](WindowType type, uint64_t displayId)->
720 std::vector<sptr<SceneSession>>
__anon692f4e5f0d02(WindowType type, uint64_t displayId)721 {
722 std::vector<sptr<SceneSession>> vSession;
723 vSession.push_back(session);
724 return vSession;
725 };
726 specificCallback->onGetSceneSessionVectorByTypeAndDisplayId_ = func;
727 session->UpdateWinRectForSystemBar(rect);
728
729 session->isVisible_ = true;
730 session->winRect_ = rect;
731 session->UpdateWinRectForSystemBar(rect);
732
733 WSRect rect1 = { 1, 2, 10, 4 };
734 session->winRect_ = rect1;
735 session->UpdateWinRectForSystemBar(rect);
736 EXPECT_EQ(4, session->GetSessionRect().height_);
737
738 WSRect rect2 = { 1, 2, 10, 8 };
739 session->winRect_ = rect2;
740 session->UpdateWinRectForSystemBar(rect);
741 }
742
743 /**
744 * @tc.name: UpdateNativeVisibility
745 * @tc.desc: UpdateNativeVisibility function01
746 * @tc.type: FUNC
747 */
748 HWTEST_F(SceneSessionTest5, UpdateNativeVisibility, Function | SmallTest | Level2)
749 {
750 SessionInfo info;
751 info.abilityName_ = "UpdateNativeVisibility";
752 info.bundleName_ = "UpdateNativeVisibility";
753 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
754 EXPECT_NE(session, nullptr);
755 sptr<SceneSession::SpecificSessionCallback> specificCallback =
756 sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
__anon692f4e5f0e02(int32_t persistentId, WindowUpdateType type) 757 NotifyWindowInfoUpdateCallback dateFunc = [](int32_t persistentId, WindowUpdateType type) {
758 return;
759 };
__anon692f4e5f0f02(const int32_t persistentId) 760 UpdateAvoidAreaCallback areaFunc = [](const int32_t persistentId) {
761 return;
762 };
763 specificCallback->onWindowInfoUpdate_ = dateFunc;
764 specificCallback->onUpdateAvoidArea_ = areaFunc;
765 session->specificCallback_ = specificCallback;
766 session->UpdateNativeVisibility(true);
767 session->UpdateNativeVisibility(false);
768 }
769
770 /**
771 * @tc.name: SetPrivacyMode
772 * @tc.desc: SetPrivacyMode function01
773 * @tc.type: FUNC
774 */
775 HWTEST_F(SceneSessionTest5, SetPrivacyMode, Function | SmallTest | Level2)
776 {
777 SessionInfo info;
778 info.abilityName_ = "SetPrivacyMode";
779 info.bundleName_ = "SetPrivacyMode";
780 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
781 EXPECT_NE(session, nullptr);
782 struct RSSurfaceNodeConfig config;
783 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
784 session->surfaceNode_ = surfaceNode;
785 ASSERT_NE(session->GetSessionProperty(), nullptr);
786 session->GetSessionProperty()->SetPrivacyMode(true);
787 EXPECT_EQ(true, session->GetSessionProperty()->GetPrivacyMode());
788 session->leashWinSurfaceNode_ = nullptr;
789 session->SetPrivacyMode(false);
790 session->leashWinSurfaceNode_ = surfaceNode;
791 session->SetPrivacyMode(true);
792
793 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
794 EXPECT_NE(property, nullptr);
795 property->SetPrivacyMode(true);
796 session->SetSessionProperty(property);
797 session->SetPrivacyMode(true);
798 }
799
800 /**
801 * @tc.name: SetSnapshotSkip
802 * @tc.desc: SetSnapshotSkip function01
803 * @tc.type: FUNC
804 */
805 HWTEST_F(SceneSessionTest5, SetSnapshotSkip, Function | SmallTest | Level2)
806 {
807 SessionInfo info;
808 info.abilityName_ = "SetSnapshotSkip";
809 info.bundleName_ = "SetSnapshotSkip";
810 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
811 EXPECT_NE(session, nullptr);
812 struct RSSurfaceNodeConfig config;
813 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
814 session->surfaceNode_ = surfaceNode;
815 ASSERT_NE(session->GetSessionProperty(), nullptr);
816 session->GetSessionProperty()->SetSnapshotSkip(true);
817 EXPECT_EQ(true, session->GetSessionProperty()->GetSnapshotSkip());
818 session->leashWinSurfaceNode_ = nullptr;
819 session->SetSnapshotSkip(false);
820 session->leashWinSurfaceNode_ = surfaceNode;
821 session->SetSnapshotSkip(false);
822 session->SetSnapshotSkip(true);
823 session->surfaceNode_ = nullptr;
824 EXPECT_NE(nullptr, session->GetLeashWinSurfaceNode());
825 session->SetSnapshotSkip(true);
826 }
827
828 /**
829 * @tc.name: SetWatermarkEnabled
830 * @tc.desc: SetWatermarkEnabled function01
831 * @tc.type: FUNC
832 */
833 HWTEST_F(SceneSessionTest5, SetWatermarkEnabled, Function | SmallTest | Level2)
834 {
835 SessionInfo info;
836 info.abilityName_ = "SetWatermarkEnabled";
837 info.bundleName_ = "SetWatermarkEnabled";
838 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
839 EXPECT_NE(session, nullptr);
840
841 std::string watermarkName = "watermarkNameTest";
842 session->SetWatermarkEnabled(watermarkName, true);
843
844 struct RSSurfaceNodeConfig config;
845 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
846 session->surfaceNode_ = surfaceNode;
847 session->SetWatermarkEnabled(watermarkName, true);
848 }
849
850 /**
851 * @tc.name: UIExtSurfaceNodeIdCache
852 * @tc.desc: UIExtSurfaceNodeIdCache
853 * @tc.type: FUNC
854 */
855 HWTEST_F(SceneSessionTest5, UIExtSurfaceNodeIdCache, Function | SmallTest | Level2)
856 {
857 SessionInfo info;
858 info.abilityName_ = "UIExtSurfaceNodeIdCache";
859 info.bundleName_ = "UIExtSurfaceNodeIdCache";
860 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
861 EXPECT_NE(session, nullptr);
862
863 session->AddUIExtSurfaceNodeId(1, 2);
864 EXPECT_EQ(session->GetUIExtPersistentIdBySurfaceNodeId(1), 2);
865
866 session->RemoveUIExtSurfaceNodeId(2);
867 EXPECT_EQ(session->GetUIExtPersistentIdBySurfaceNodeId(1), 0);
868 }
869
870 /**
871 * @tc.name: SetSystemSceneOcclusionAlpha
872 * @tc.desc: SetSystemSceneOcclusionAlpha function01
873 * @tc.type: FUNC
874 */
875 HWTEST_F(SceneSessionTest5, SetSystemSceneOcclusionAlpha, Function | SmallTest | Level2)
876 {
877 SessionInfo info;
878 info.abilityName_ = "SetSystemSceneOcclusionAlpha";
879 info.bundleName_ = "SetSystemSceneOcclusionAlpha";
880 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
881 EXPECT_NE(session, nullptr);
882 session->SetSystemSceneOcclusionAlpha(-0.325);
883 session->SetSystemSceneOcclusionAlpha(3.14125);
884
885 struct RSSurfaceNodeConfig config;
886 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
887 session->surfaceNode_ = surfaceNode;
888 session->leashWinSurfaceNode_ = nullptr;
889 session->SetSystemSceneOcclusionAlpha(0.14125);
890 session->leashWinSurfaceNode_ = surfaceNode;
891 session->SetSystemSceneOcclusionAlpha(0.14125);
892 EXPECT_NE(nullptr, session->GetLeashWinSurfaceNode());
893 }
894
895 /**
896 * @tc.name: ResetOcclusionAlpha
897 * @tc.desc: ResetOcclusionAlpha function01
898 * @tc.type: FUNC
899 */
900 HWTEST_F(SceneSessionTest5, ResetOcclusionAlpha, Function | SmallTest | Level2)
901 {
902 SessionInfo info;
903 info.abilityName_ = "ResetOcclusionAlpha";
904 info.bundleName_ = "ResetOcclusionAlpha";
905 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
906 EXPECT_NE(session, nullptr);
907
908 struct RSSurfaceNodeConfig config;
909 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
910 session->surfaceNode_ = surfaceNode;
911 session->leashWinSurfaceNode_ = nullptr;
912 session->ResetOcclusionAlpha();
913 EXPECT_EQ(nullptr, session->GetLeashWinSurfaceNode());
914 session->leashWinSurfaceNode_ = surfaceNode;
915 session->ResetOcclusionAlpha();
916 EXPECT_NE(nullptr, session->GetLeashWinSurfaceNode());
917 }
918
919 /**
920 * @tc.name: SetSystemSceneForceUIFirst
921 * @tc.desc: SetSystemSceneForceUIFirst function01
922 * @tc.type: FUNC
923 */
924 HWTEST_F(SceneSessionTest5, SetSystemSceneForceUIFirst, Function | SmallTest | Level2)
925 {
926 SessionInfo info;
927 info.abilityName_ = "SetSystemSceneForceUIFirst";
928 info.bundleName_ = "SetSystemSceneForceUIFirst";
929 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
930 EXPECT_NE(session, nullptr);
931 session->SetSystemSceneForceUIFirst(true);
932
933 struct RSSurfaceNodeConfig config;
934 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
935 session->surfaceNode_ = surfaceNode;
936 session->leashWinSurfaceNode_ = nullptr;
937 session->SetSystemSceneForceUIFirst(true);
938 session->leashWinSurfaceNode_ = surfaceNode;
939 session->SetSystemSceneForceUIFirst(true);
940 EXPECT_NE(nullptr, session->GetLeashWinSurfaceNode());
941 }
942
943 /**
944 * @tc.name: UpdateWindowAnimationFlag
945 * @tc.desc: UpdateWindowAnimationFlag function01
946 * @tc.type: FUNC
947 */
948 HWTEST_F(SceneSessionTest5, UpdateWindowAnimationFlag, Function | SmallTest | Level2)
949 {
950 SessionInfo info;
951 info.abilityName_ = "UpdateWindowAnimationFlag";
952 info.bundleName_ = "UpdateWindowAnimationFlag";
953 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
954 EXPECT_NE(session, nullptr);
955
956 EXPECT_EQ(WSError::WS_OK, session->UpdateWindowAnimationFlag(true));
957
958 session->onWindowAnimationFlagChange_ = nullptr;
959 EXPECT_EQ(WSError::WS_OK, session->UpdateWindowAnimationFlag(true));
960
__anon692f4e5f1002(const bool flag) 961 NotifyWindowAnimationFlagChangeFunc func = [](const bool flag) {
962 return;
963 };
964 session->onWindowAnimationFlagChange_ = func;
965 EXPECT_EQ(WSError::WS_OK, session->UpdateWindowAnimationFlag(true));
966 }
967
968 /**
969 * @tc.name: SetForegroundInteractiveStatus
970 * @tc.desc: SetForegroundInteractiveStatus function01
971 * @tc.type: FUNC
972 */
973 HWTEST_F(SceneSessionTest5, SetForegroundInteractiveStatus, Function | SmallTest | Level2)
974 {
975 SessionInfo info;
976 info.abilityName_ = "SetForegroundInteractiveStatus";
977 info.bundleName_ = "SetForegroundInteractiveStatus";
978 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
979 session->SetSessionState(SessionState::STATE_FOREGROUND);
980 EXPECT_NE(session, nullptr);
981 session->toastSession_.clear();
982 session->toastSession_.push_back(session);
983 session->SetForegroundInteractiveStatus(false);
984 session->toastSession_.clear();
985 session->SetSessionState(SessionState::STATE_ACTIVE);
986 session->toastSession_.push_back(session);
987 session->SetForegroundInteractiveStatus(false);
988 session->toastSession_.clear();
989 session->SetSessionState(SessionState::STATE_CONNECT);
990 session->toastSession_.push_back(session);
991 session->SetForegroundInteractiveStatus(false);
992 session->toastSession_.clear();
993 session->SetSessionState(SessionState::STATE_ACTIVE);
994 session->toastSession_.push_back(nullptr);
995 session->SetForegroundInteractiveStatus(false);
996 session->toastSession_.clear();
997 }
998
999 /**
1000 * @tc.name: HandleUpdatePropertyByAction
1001 * @tc.desc: HandleUpdatePropertyByAction function01
1002 * @tc.type: FUNC
1003 */
1004 HWTEST_F(SceneSessionTest5, HandleUpdatePropertyByAction, Function | SmallTest | Level2)
1005 {
1006 SessionInfo info;
1007 info.abilityName_ = "HandleUpdatePropertyByAction";
1008 info.bundleName_ = "HandleUpdatePropertyByAction";
1009 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1010 ASSERT_NE(nullptr, session);
1011 WSPropertyChangeAction action = WSPropertyChangeAction::ACTION_UPDATE_RECT;
1012 auto res = session->HandleUpdatePropertyByAction(nullptr, action);
1013 EXPECT_EQ(WMError::WM_ERROR_NULLPTR, res);
1014 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1015 ASSERT_NE(nullptr, property);
1016 res = session->HandleUpdatePropertyByAction(property, action);
1017 EXPECT_EQ(WMError::WM_DO_NOTHING, res);
1018 action = WSPropertyChangeAction::ACTION_UPDATE_FLAGS;
1019 res = session->HandleUpdatePropertyByAction(property, action);
1020 EXPECT_EQ(WMError::WM_OK, res);
1021 auto prop = session->GetSessionProperty();
1022 EXPECT_EQ(prop->GetSystemBarProperty(), property->GetSystemBarProperty());
1023 }
1024
1025 /**
1026 * @tc.name: SetSystemWindowEnableDrag
1027 * @tc.desc: SetSystemWindowEnableDrag function01
1028 * @tc.type: FUNC
1029 */
1030 HWTEST_F(SceneSessionTest5, SetSystemWindowEnableDrag, Function | SmallTest | Level2)
1031 {
1032 SessionInfo info;
1033 info.abilityName_ = "SetSystemWindowEnableDrag";
1034 info.bundleName_ = "SetSystemWindowEnableDrag";
1035 info.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_DESKTOP);
1036 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1037 auto ret = session->SetWindowEnableDragBySystem(true);
1038 EXPECT_EQ(WMError::WM_OK, ret);
1039 }
1040
1041 /**
1042 * @tc.name: SetWindowEnableDragBySystem
1043 * @tc.desc: SetWindowEnableDragBySystem function
1044 * @tc.type: FUNC
1045 */
1046 HWTEST_F(SceneSessionTest5, SetWindowEnableDragBySystem, Function | SmallTest | Level2)
1047 {
1048 SessionInfo info;
1049 info.abilityName_ = "SetWindowEnableDrag";
1050 info.bundleName_ = "SetWindowEnableDrag";
1051 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1052 auto ret = session->SetWindowEnableDragBySystem(true);
1053 EXPECT_EQ(WMError::WM_OK, ret);
1054 }
1055
1056 /**
1057 * @tc.name: HandleActionUpdateSetBrightness
1058 * @tc.desc: HandleActionUpdateSetBrightness function01
1059 * @tc.type: FUNC
1060 */
1061 HWTEST_F(SceneSessionTest5, HandleActionUpdateSetBrightness, Function | SmallTest | Level2)
1062 {
1063 SessionInfo info;
1064 info.abilityName_ = "HandleActionUpdateSetBrightness";
1065 info.bundleName_ = "HandleActionUpdateSetBrightness";
1066 info.windowType_ = static_cast<uint32_t>(WindowType::ABOVE_APP_SYSTEM_WINDOW_BASE);
1067 info.isSystem_ = true;
1068 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1069 ASSERT_NE(nullptr, session);
1070 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1071 ASSERT_NE(nullptr, property);
1072 WSPropertyChangeAction action = WSPropertyChangeAction::ACTION_UPDATE_RECT;
1073 auto res = session->HandleActionUpdateSetBrightness(property, action);
1074 EXPECT_EQ(WMError::WM_OK, res);
1075
1076 info.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1077 sptr<SceneSession> session1 = sptr<SceneSession>::MakeSptr(info, nullptr);
1078 res = session1->HandleActionUpdateSetBrightness(property, action);
1079 EXPECT_EQ(WMError::WM_ERROR_INVALID_SESSION, res);
1080
1081 info.isSystem_ = false;
1082 sptr<SceneSession> session2 = sptr<SceneSession>::MakeSptr(info, nullptr);
1083 session2->SetSessionState(SessionState::STATE_CONNECT);
1084 res = session2->HandleActionUpdateSetBrightness(property, action);
1085 EXPECT_EQ(WMError::WM_OK, res);
1086
1087 sptr<SceneSession> session3 = sptr<SceneSession>::MakeSptr(info, nullptr);
1088 session3->SetSessionState(SessionState::STATE_CONNECT);
1089 float brightness = 1.0;
1090 property->SetBrightness(brightness);
1091 EXPECT_EQ(brightness, property->GetBrightness());
1092 EXPECT_EQ(WSError::WS_OK, session3->SetBrightness(brightness));
1093 res = session3->HandleActionUpdateSetBrightness(property, action);
1094 EXPECT_EQ(WMError::WM_OK, res);
1095 EXPECT_EQ(brightness, session3->GetBrightness());
1096
1097 sptr<SceneSession> session4 = sptr<SceneSession>::MakeSptr(info, nullptr);
1098 session4->SetSessionState(SessionState::STATE_CONNECT);
1099 brightness = 0.8;
1100 property->SetBrightness(brightness);
1101 EXPECT_EQ(brightness, property->GetBrightness());
1102 res = session4->HandleActionUpdateSetBrightness(property, action);
1103 EXPECT_EQ(WMError::WM_OK, res);
1104 EXPECT_EQ(brightness, session4->GetBrightness());
1105 brightness = 1.0;
1106 EXPECT_EQ(WSError::WS_OK, session4->SetBrightness(brightness));
1107 EXPECT_EQ(brightness, session4->GetBrightness());
1108 }
1109
1110 /**
1111 * @tc.name: HandleActionUpdateMaximizeState
1112 * @tc.desc: HandleActionUpdateMaximizeState function01
1113 * @tc.type: FUNC
1114 */
1115 HWTEST_F(SceneSessionTest5, HandleActionUpdateMaximizeState, Function | SmallTest | Level2)
1116 {
1117 SessionInfo info;
1118 info.abilityName_ = "HandleActionUpdateMaximizeState";
1119 info.bundleName_ = "HandleActionUpdateMaximizeState";
1120 info.windowType_ = static_cast<uint32_t>(WindowType::ABOVE_APP_SYSTEM_WINDOW_BASE);
1121 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1122 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1123 WSPropertyChangeAction action = WSPropertyChangeAction::ACTION_UPDATE_RECT;
1124
1125 auto res = session->HandleActionUpdateMaximizeState(property, action);
1126 EXPECT_EQ(WMError::WM_OK, res);
1127 res = session->HandleActionUpdateMode(property, action);
1128 EXPECT_EQ(WMError::WM_OK, res);
1129 res = session->HandleActionUpdateAnimationFlag(property, action);
1130 EXPECT_EQ(WMError::WM_OK, res);
1131 }
1132
1133 /**
1134 * @tc.name: SetUniqueDensityDpi
1135 * @tc.desc: SetUniqueDensityDpi function01
1136 * @tc.type: FUNC
1137 */
1138 HWTEST_F(SceneSessionTest5, SetUniqueDensityDpi, Function | SmallTest | Level2)
1139 {
1140 SessionInfo info;
1141 info.abilityName_ = "SetUniqueDensityDpi";
1142 info.bundleName_ = "SetUniqueDensityDpi";
1143 info.windowType_ = static_cast<uint32_t>(WindowType::ABOVE_APP_SYSTEM_WINDOW_BASE);
1144 info.isSystem_ = true;
1145 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1146 EXPECT_NE(session, nullptr);
1147 session->sessionStage_ = nullptr;
1148 EXPECT_EQ(WMError::WM_ERROR_INVALID_SESSION, session->SetUniqueDensityDpi(true, 520));
1149 session->sessionInfo_.isSystem_ = false;
1150 session->state_ = SessionState::STATE_DISCONNECT;
1151 EXPECT_EQ(WMError::WM_ERROR_INVALID_SESSION, session->SetUniqueDensityDpi(true, 520));
1152 session->state_ = SessionState::STATE_CONNECT;
1153 EXPECT_EQ(WMError::WM_ERROR_NULLPTR, session->SetUniqueDensityDpi(true, 520));
1154 EXPECT_EQ(WMError::WM_ERROR_INVALID_PARAM, session->SetUniqueDensityDpi(true, 79));
1155 EXPECT_EQ(WMError::WM_ERROR_NULLPTR, session->SetUniqueDensityDpi(false, 79));
1156
1157 session->sessionStage_ = sptr<SessionStageMocker>::MakeSptr();
1158 EXPECT_NE(nullptr, session->sessionStage_);
1159 }
1160
1161 /**
1162 * @tc.name: HandleActionUpdateWindowModeSupportType
1163 * @tc.desc: HandleActionUpdateWindowModeSupportType function01
1164 * @tc.type: FUNC
1165 */
1166 HWTEST_F(SceneSessionTest5, HandleActionUpdateWindowModeSupportType, Function | SmallTest | Level2)
1167 {
1168 SessionInfo info;
1169 info.abilityName_ = "HandleActionUpdateWindowModeSupportType";
1170 info.bundleName_ = "HandleActionUpdateWindowModeSupportType";
1171 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1172 ASSERT_NE(session, nullptr);
1173 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1174
1175 property->isSystemCalling_ = false;
1176 session->SetSessionProperty(property);
1177 ASSERT_EQ(WMError::WM_ERROR_NOT_SYSTEM_APP, session->HandleActionUpdateWindowModeSupportType(property,
1178 WSPropertyChangeAction::ACTION_UPDATE_RECT));
1179 }
1180
1181 /**
1182 * @tc.name: UpdateUIParam
1183 * @tc.desc: UpdateUIParam function01
1184 * @tc.type: FUNC
1185 */
1186 HWTEST_F(SceneSessionTest5, UpdateUIParam, Function | SmallTest | Level2)
1187 {
1188 SessionInfo info;
1189 info.abilityName_ = "UpdateUIParam";
1190 info.bundleName_ = "UpdateUIParam";
1191 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1192 ASSERT_NE(session, nullptr);
1193 session->isFocused_ = true;
1194 session->isVisible_ = false;
1195 uint32_t res = session->UpdateUIParam();
1196 ASSERT_EQ(0, res);
1197 ASSERT_EQ(false, session->postProcessFocusState_.enabled_);
1198
1199 session->isFocused_ = true;
1200 session->isVisible_ = true;
1201 uint32_t res1 = session->UpdateUIParam();
1202 ASSERT_EQ(1, res1);
1203 ASSERT_EQ(true, session->postProcessFocusState_.enabled_);
1204 }
1205
1206 /**
1207 * @tc.name: UpdateVisibilityInner
1208 * @tc.desc: UpdateVisibilityInner function01
1209 * @tc.type: FUNC
1210 */
1211 HWTEST_F(SceneSessionTest5, UpdateVisibilityInner, Function | SmallTest | Level2)
1212 {
1213 SessionInfo info;
1214 info.abilityName_ = "UpdateVisibilityInner";
1215 info.bundleName_ = "UpdateVisibilityInner";
1216 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1217 ASSERT_NE(session, nullptr);
1218 session->isVisible_ = true;
1219 ASSERT_EQ(false, session->UpdateVisibilityInner(true));
1220 }
1221
1222 /**
1223 * @tc.name: UpdateInteractiveInner
1224 * @tc.desc: UpdateInteractiveInner function01
1225 * @tc.type: FUNC
1226 */
1227 HWTEST_F(SceneSessionTest5, UpdateInteractiveInner, Function | SmallTest | Level2)
1228 {
1229 SessionInfo info;
1230 info.abilityName_ = "UpdateInteractiveInner";
1231 info.bundleName_ = "UpdateInteractiveInner";
1232 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1233 ASSERT_NE(session, nullptr);
1234 session->foregroundInteractiveStatus_.store(true);
1235 ASSERT_EQ(false, session->UpdateInteractiveInner(true));
1236 ASSERT_EQ(true, session->UpdateInteractiveInner(false));
1237 }
1238
1239 /**
1240 * @tc.name: IsAnco
1241 * @tc.desc: IsAnco function01
1242 * @tc.type: FUNC
1243 */
1244 HWTEST_F(SceneSessionTest5, IsAnco, Function | SmallTest | Level2)
1245 {
1246 SessionInfo info;
1247 info.abilityName_ = "IsAnco";
1248 info.bundleName_ = "IsAnco";
1249 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1250 EXPECT_NE(session, nullptr);
1251 bool res = session->IsAnco();
1252 EXPECT_EQ(res, false);
1253
1254 session->collaboratorType_ = CollaboratorType::RESERVE_TYPE;
1255 res = session->IsAnco();
1256 EXPECT_EQ(res, true);
1257 }
1258
1259 /**
1260 * @tc.name: ProcessUpdatePropertyByAction
1261 * @tc.desc: ProcessUpdatePropertyByAction function01
1262 * @tc.type: FUNC
1263 */
1264 HWTEST_F(SceneSessionTest5, ProcessUpdatePropertyByAction, Function | SmallTest | Level2)
1265 {
1266 SessionInfo info;
1267 info.abilityName_ = "ProcessUpdatePropertyByAction";
1268 info.bundleName_ = "ProcessUpdatePropertyByAction";
1269 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1270 EXPECT_NE(session, nullptr);
1271
1272 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1273 EXPECT_NE(property, nullptr);
1274
1275 session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON);
1276 session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_FOCUSABLE);
1277 session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_TOUCHABLE);
1278 session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_SET_BRIGHTNESS);
1279 session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_ORIENTATION);
1280 session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE);
1281 session->ProcessUpdatePropertyByAction(
1282 property, WSPropertyChangeAction::ACTION_UPDATE_SYSTEM_PRIVACY_MODE);
1283 session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_SNAPSHOT_SKIP);
1284 session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_MAXIMIZE_STATE);
1285 session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_OTHER_PROPS);
1286 session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_STATUS_PROPS);
1287 session->ProcessUpdatePropertyByAction(
1288 property, WSPropertyChangeAction::ACTION_UPDATE_NAVIGATION_INDICATOR_PROPS);
1289 session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_FLAGS);
1290 session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_MODE);
1291 session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_ANIMATION_FLAG);
1292 session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA);
1293 session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_DECOR_ENABLE);
1294 session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS);
1295 session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED);
1296 session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED);
1297 session->ProcessUpdatePropertyByAction(
1298 property, WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS);
1299 session->ProcessUpdatePropertyByAction(
1300 property, WSPropertyChangeAction::ACTION_UPDATE_TEXTFIELD_AVOID_INFO);
1301 session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_WINDOW_MASK);
1302 session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_TOPMOST);
1303 session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO);
1304 }
1305
1306 /**
1307 * @tc.name: HandleActionUpdateTurnScreenOn
1308 * @tc.desc: HandleActionUpdateTurnScreenOn function01
1309 * @tc.type: FUNC
1310 */
1311 HWTEST_F(SceneSessionTest5, HandleActionUpdateTurnScreenOn, Function | SmallTest | Level2)
1312 {
1313 SessionInfo info;
1314 info.abilityName_ = "HandleActionUpdateTurnScreenOn";
1315 info.bundleName_ = "HandleActionUpdateTurnScreenOn";
1316 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1317 EXPECT_NE(session, nullptr);
1318
1319 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1320 EXPECT_NE(property, nullptr);
1321
1322 auto res = session->HandleActionUpdateTurnScreenOn(
1323 property, WSPropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON);
1324 EXPECT_EQ(res, WMError::WM_OK);
1325
1326 property->SetTurnScreenOn(true);
1327 res = session->HandleActionUpdateTurnScreenOn(
1328 property, WSPropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON);
1329 EXPECT_EQ(res, WMError::WM_OK);
1330 }
1331
1332 /**
1333 * @tc.name: HandleActionUpdatePrivacyMode1
1334 * @tc.desc: HandleActionUpdatePrivacyMode1
1335 * @tc.type: FUNC
1336 */
1337 HWTEST_F(SceneSessionTest5, HandleActionUpdatePrivacyMode1, Function | SmallTest | Level2)
1338 {
1339 SessionInfo info;
1340 info.abilityName_ = "HandleActionUpdatePrivacyMode1";
1341 info.bundleName_ = "HandleActionUpdatePrivacyMode1";
1342 info.windowType_ = static_cast<uint32_t>(WindowType::APP_MAIN_WINDOW_BASE);
1343 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1344 EXPECT_NE(session, nullptr);
1345 EXPECT_NE(session->property_, nullptr);
1346 struct RSSurfaceNodeConfig config;
1347 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
1348 session->surfaceNode_ = surfaceNode;
1349 session->property_->SetPrivacyMode(false);
1350 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1351 property->SetPrivacyMode(true);
1352 auto res =
1353 session->HandleActionUpdatePrivacyMode(property, WSPropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE);
1354 EXPECT_EQ(WMError::WM_OK, res);
1355 EXPECT_EQ(true, session->property_->GetPrivacyMode());
1356 }
1357
1358 /**
1359 * @tc.name: HandleActionUpdatePrivacyMode2
1360 * @tc.desc: HandleActionUpdatePrivacyMode2
1361 * @tc.type: FUNC
1362 */
1363 HWTEST_F(SceneSessionTest5, HandleActionUpdatePrivacyMode2, Function | SmallTest | Level2)
1364 {
1365 SessionInfo info;
1366 info.abilityName_ = "HandleActionUpdatePrivacyMode2";
1367 info.bundleName_ = "HandleActionUpdatePrivacyMode2";
1368 info.windowType_ = static_cast<uint32_t>(WindowType::APP_MAIN_WINDOW_BASE);
1369 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1370 EXPECT_NE(session, nullptr);
1371 EXPECT_NE(session->property_, nullptr);
1372 struct RSSurfaceNodeConfig config;
1373 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
1374 session->surfaceNode_ = surfaceNode;
1375 session->property_->SetPrivacyMode(true);
1376 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1377 property->SetPrivacyMode(false);
1378 auto res =
1379 session->HandleActionUpdatePrivacyMode(property, WSPropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE);
1380 EXPECT_EQ(WMError::WM_OK, res);
1381 EXPECT_EQ(false, session->property_->GetPrivacyMode());
1382 }
1383
1384 /**
1385 * @tc.name: UpdateClientRect01
1386 * @tc.desc: UpdateClientRect
1387 * @tc.type: FUNC
1388 */
1389 HWTEST_F(SceneSessionTest5, UpdateClientRect01, Function | SmallTest | Level2)
1390 {
1391 SessionInfo info;
1392 info.abilityName_ = "UpdateClientRect01";
1393 info.bundleName_ = "UpdateClientRect01";
1394 info.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1395 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1396
1397 WSRect rect = { 0, 0, 0, 0 };
1398 EXPECT_EQ(session->UpdateClientRect(rect), WSError::WS_OK);
1399
1400 session->SetClientRect(rect);
1401 rect.posX_ = 100;
1402 rect.posY_ = 100;
1403 rect.width_ = 800;
1404 rect.height_ = 800;
1405 EXPECT_EQ(session->UpdateClientRect(rect), WSError::WS_OK);
1406
1407 session->SetClientRect(rect);
1408 EXPECT_EQ(session->UpdateClientRect(rect), WSError::WS_OK);
1409 }
1410
1411 /**
1412 * @tc.name: ResetSizeChangeReasonIfDirty
1413 * @tc.desc: ResetSizeChangeReasonIfDirty
1414 * @tc.type: FUNC
1415 */
1416 HWTEST_F(SceneSessionTest5, ResetSizeChangeReasonIfDirty, Function | SmallTest | Level2)
1417 {
1418 SessionInfo info;
1419 info.abilityName_ = "ResetSizeChangeReasonIfDirty";
1420 info.bundleName_ = "ResetSizeChangeReasonIfDirty";
1421 info.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1422 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1423
1424 session->UpdateSizeChangeReason(SizeChangeReason::DRAG);
1425 session->ResetDirtyFlags();
1426 session->ResetSizeChangeReasonIfDirty();
1427 EXPECT_EQ(session->GetSizeChangeReason(), SizeChangeReason::DRAG);
1428
1429 session->dirtyFlags_ |= static_cast<uint32_t>(SessionUIDirtyFlag::RECT);
1430 session->ResetSizeChangeReasonIfDirty();
1431 EXPECT_EQ(session->GetSizeChangeReason(), SizeChangeReason::DRAG);
1432
1433 session->UpdateSizeChangeReason(SizeChangeReason::MOVE);
1434 session->ResetSizeChangeReasonIfDirty();
1435 EXPECT_EQ(session->GetSizeChangeReason(), SizeChangeReason::UNDEFINED);
1436 }
1437
1438 /**
1439 * @tc.name: HandleMoveDragSurfaceNode
1440 * @tc.desc: HandleMoveDragSurfaceNode Test
1441 * @tc.type: FUNC
1442 */
1443 HWTEST_F(SceneSessionTest5, HandleMoveDragSurfaceNode, Function | SmallTest | Level2)
1444 {
1445 SessionInfo info;
1446 info.abilityName_ = "HandleMoveDragSurfaceNode";
1447 info.bundleName_ = "HandleMoveDragSurfaceNode";
1448 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1449 EXPECT_NE(session, nullptr);
1450
1451 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1452 EXPECT_NE(property, nullptr);
1453
1454 session->moveDragController_ = sptr<MoveDragController>::MakeSptr(2024, session->GetWindowType());
1455 EXPECT_NE(session->moveDragController_, nullptr);
1456
1457 session->HandleMoveDragSurfaceNode(SizeChangeReason::DRAG_START);
1458 session->HandleMoveDragSurfaceNode(SizeChangeReason::DRAG);
1459 session->HandleMoveDragSurfaceNode(SizeChangeReason::DRAG_MOVE);
1460 session->HandleMoveDragSurfaceNode(SizeChangeReason::DRAG_END);
1461 }
1462
1463 /**
1464 * @tc.name: SetNotifyVisibleChangeFunc
1465 * @tc.desc: SetNotifyVisibleChangeFunc Test
1466 * @tc.type: FUNC
1467 */
1468 HWTEST_F(SceneSessionTest5, SetNotifyVisibleChangeFunc, Function | SmallTest | Level2)
1469 {
1470 SessionInfo info;
1471 info.abilityName_ = "test";
1472 info.bundleName_ = "test";
1473 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1474 EXPECT_NE(session, nullptr);
1475
__anon692f4e5f1102(int32_t persistentId) 1476 session->SetNotifyVisibleChangeFunc([](int32_t persistentId) {});
1477 EXPECT_NE(session->notifyVisibleChangeFunc_, nullptr);
1478 }
1479
1480 /**
1481 * @tc.name: SetRequestNextVsyncFunc
1482 * @tc.desc: SetRequestNextVsyncFunc01 Test
1483 * @tc.type: FUNC
1484 */
1485 HWTEST_F(SceneSessionTest5, SetRequestNextVsyncFunc01, Function | SmallTest | Level2)
1486 {
1487 SessionInfo info;
1488 info.abilityName_ = "test1";
1489 info.bundleName_ = "test1";
1490 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1491
1492 session->SetRequestNextVsyncFunc(nullptr);
1493 ASSERT_EQ(nullptr, session->requestNextVsyncFunc_);
1494
__anon692f4e5f1202(const std::shared_ptr<VsyncCallback>& callback) 1495 session->SetRequestNextVsyncFunc([](const std::shared_ptr<VsyncCallback>& callback) {
1496 SessionInfo info1;
1497 info1.abilityName_ = "test2";
1498 info1.bundleName_ = "test2";
1499 });
1500 ASSERT_NE(nullptr, session->requestNextVsyncFunc_);
1501 }
1502
1503 /**
1504 * @tc.name: NotifyServerToUpdateRect01
1505 * @tc.desc: NotifyServerToUpdateRect01 Test
1506 * @tc.type: FUNC
1507 */
1508 HWTEST_F(SceneSessionTest5, NotifyServerToUpdateRect01, Function | SmallTest | Level2)
1509 {
1510 SessionInfo info;
1511 info.abilityName_ = "NotifyServerToUpdateRect01";
1512 info.bundleName_ = "NotifyServerToUpdateRect01";
1513 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1514 EXPECT_NE(session, nullptr);
1515
1516 session->foregroundInteractiveStatus_.store(true);
1517 EXPECT_EQ(session->GetForegroundInteractiveStatus(), true);
1518
1519 SessionUIParam uiParam;
1520 EXPECT_EQ(session->NotifyServerToUpdateRect(uiParam, SizeChangeReason::UNDEFINED), false);
1521
1522 uiParam.rect_ = { 100, 100, 200, 200 };
1523 session->SetNeedSyncSessionRect(false);
1524 EXPECT_EQ(session->NotifyServerToUpdateRect(uiParam, SizeChangeReason::UNDEFINED), false); // not sync
1525 EXPECT_NE(session->GetSessionRect(), uiParam.rect_);
1526
1527 uiParam.needSync_ = false;
1528 EXPECT_EQ(session->NotifyServerToUpdateRect(uiParam, SizeChangeReason::UNDEFINED), false); // not sync
1529 EXPECT_NE(session->GetSessionRect(), uiParam.rect_);
1530
1531 uiParam.needSync_ = true;
1532 session->SetNeedSyncSessionRect(true); // sync first
1533 EXPECT_EQ(session->NotifyServerToUpdateRect(uiParam, SizeChangeReason::UNDEFINED), true);
1534 EXPECT_EQ(session->GetSessionRect(), uiParam.rect_);
1535
1536 session->clientRect_ = session->winRect_;
1537 EXPECT_EQ(session->NotifyServerToUpdateRect(uiParam, SizeChangeReason::UNDEFINED), false); // skip same rect
1538 }
1539
1540 /**
1541 * @tc.name: MoveUnderInteriaAndNotifyRectChange
1542 * @tc.desc: test func: MoveUnderInteriaAndNotifyRectChange
1543 * @tc.type: FUNC
1544 */
1545 HWTEST_F(SceneSessionTest5, MoveUnderInteriaAndNotifyRectChange, Function | SmallTest | Level2)
1546 {
1547 SessionInfo info;
1548 info.abilityName_ = "MoveUnderInteriaAndNotifyRectChange";
1549 info.bundleName_ = "MoveUnderInteriaAndNotifyRectChange";
1550 info.screenId_ = 0;
1551 sptr<MainSession> mainSession = sptr<MainSession>::MakeSptr(info, nullptr);
1552 ASSERT_NE(mainSession->pcFoldScreenController_, nullptr);
1553 auto controller = mainSession->pcFoldScreenController_;
1554 WSRect rect = { 0, 0, 100, 100 };
1555 EXPECT_FALSE(mainSession->MoveUnderInteriaAndNotifyRectChange(rect, SizeChangeReason::DRAG_END));
1556 PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::HALF_FOLDED,
1557 { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 });
1558 PcFoldScreenManager::GetInstance().vpr_ = 1.7f;
1559
1560 WSRect rect0 = { 100, 100, 400, 400 };
1561 WSRect rect1 = { 100, 500, 400, 400 };
1562
1563 // throw
1564 controller->RecordStartMoveRect(rect0, false);
1565 controller->RecordMoveRects(rect0);
1566 usleep(10000);
1567 rect = rect1;
1568 controller->RecordMoveRects(rect);
1569 EXPECT_TRUE(mainSession->MoveUnderInteriaAndNotifyRectChange(rect, SizeChangeReason::DRAG_END));
1570
1571 // throw full screen
1572 usleep(100000);
1573 controller->RecordStartMoveRect(rect0, true);
1574 controller->RecordMoveRects(rect0);
1575 usleep(10000);
1576 rect = rect1;
1577 controller->RecordMoveRects(rect);
1578 EXPECT_TRUE(mainSession->MoveUnderInteriaAndNotifyRectChange(rect, SizeChangeReason::DRAG_END));
1579 }
1580
1581 /**
1582 * @tc.name: ThrowSlipDirectly
1583 * @tc.desc: ThrowSlipDirectly
1584 * @tc.type: FUNC
1585 */
1586 HWTEST_F(SceneSessionTest5, ThrowSlipDirectly, Function | SmallTest | Level2)
1587 {
1588 SessionInfo info;
1589 info.abilityName_ = "ThrowSlipDirectly";
1590 info.bundleName_ = "ThrowSlipDirectly";
1591 info.screenId_ = 0;
1592 sptr<MainSession> mainSession = sptr<MainSession>::MakeSptr(info, nullptr);
1593 WSRect rect = { 100, 100, 400, 400 };
1594 mainSession->winRect_ = rect;
1595 mainSession->ThrowSlipDirectly(WSRectF { 0.0f, 0.0f, 0.0f, 0.0f });
1596 EXPECT_EQ(mainSession->winRect_, rect);
1597 }
1598
1599 /**
1600 * @tc.name: SetBehindWindowFilterEnabled
1601 * @tc.desc: SetBehindWindowFilterEnabled test
1602 * @tc.type: FUNC
1603 */
1604 HWTEST_F(SceneSessionTest5, SetBehindWindowFilterEnabled, Function | SmallTest | Level2)
1605 {
1606 SessionInfo info;
1607 info.abilityName_ = "SetBehindWindowFilterEnabled";
1608 info.bundleName_ = "SetBehindWindowFilterEnabled";
1609 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1610 EXPECT_NE(session, nullptr);
1611
1612 session->SetBehindWindowFilterEnabled(false);
1613 session->SetBehindWindowFilterEnabled(true);
1614 }
1615
1616 /**
1617 * @tc.name: MarkSystemSceneUIFirst
1618 * @tc.desc: MarkSystemSceneUIFirst function01
1619 * @tc.type: FUNC
1620 */
1621 HWTEST_F(SceneSessionTest5, MarkSystemSceneUIFirst, Function | SmallTest | Level2)
1622 {
1623 SessionInfo info;
1624 info.abilityName_ = "MarkSystemSceneUIFirst";
1625 info.bundleName_ = "MarkSystemSceneUIFirst";
1626 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1627 EXPECT_NE(session, nullptr);
1628 session->MarkSystemSceneUIFirst(true, true);
1629
1630 struct RSSurfaceNodeConfig config;
1631 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
1632 session->surfaceNode_ = surfaceNode;
1633 session->leashWinSurfaceNode_ = nullptr;
1634 session->MarkSystemSceneUIFirst(true, true);
1635 session->leashWinSurfaceNode_ = surfaceNode;
1636 session->MarkSystemSceneUIFirst(true, true);
1637 EXPECT_NE(nullptr, session->GetLeashWinSurfaceNode());
1638 }
1639
1640 /**
1641 * @tc.name: IsMissionHighlighted
1642 * @tc.desc: IsMissionHighlighted
1643 * @tc.type: FUNC
1644 */
1645 HWTEST_F(SceneSessionTest5, IsMissionHighlighted, Function | SmallTest | Level2)
1646 {
1647 SessionInfo info;
1648 info.abilityName_ = "IsMissionHighlighted";
1649 info.bundleName_ = "IsMissionHighlighted";
1650 sptr<MainSession> mainSession = sptr<MainSession>::MakeSptr(info, nullptr);
1651 mainSession->isFocused_ = true;
1652 EXPECT_TRUE(mainSession->IsMissionHighlighted());
1653 mainSession->isFocused_ = false;
1654
1655 SessionInfo subInfo;
1656 subInfo.abilityName_ = "IsMissionHighlightedSub";
1657 subInfo.bundleName_ = "IsMissionHighlightedSub";
1658 sptr<SceneSession> subSession = sptr<SceneSession>::MakeSptr(subInfo, nullptr);
1659 mainSession->subSession_.push_back(subSession);
1660 subSession->isFocused_ = true;
1661 EXPECT_TRUE(mainSession->IsMissionHighlighted());
1662 subSession->isFocused_ = false;
1663 EXPECT_FALSE(mainSession->IsMissionHighlighted());
1664 }
1665
1666 /**
1667 * @tc.name: SetSessionDisplayIdChangeCallback
1668 * @tc.desc: SetSessionDisplayIdChangeCallback
1669 * @tc.type: FUNC
1670 */
1671 HWTEST_F(SceneSessionTest5, SetSessionDisplayIdChangeCallback, Function | SmallTest | Level2)
1672 {
1673 const SessionInfo info;
1674 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
__anon692f4e5f1302(uint64_t displayId) 1675 sceneSession->SetSessionDisplayIdChangeCallback([] (uint64_t displayId) {
1676 return;
1677 });
1678 ASSERT_NE(sceneSession->sessionDisplayIdChangeFunc_, nullptr);
1679 }
1680
1681 /**
1682 * @tc.name: NotifySessionDisplayIdChange
1683 * @tc.desc: NotifySessionDisplayIdChange
1684 * @tc.type: FUNC
1685 */
1686 HWTEST_F(SceneSessionTest5, NotifySessionDisplayIdChange, Function | SmallTest | Level2)
1687 {
1688 const SessionInfo info;
1689 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1690 uint64_t checkDisplayId = 345;
1691 uint64_t moveDisplayId = 456;
__anon692f4e5f1402(uint64_t displayId) 1692 sceneSession->sessionDisplayIdChangeFunc_ = [&checkDisplayId] (uint64_t displayId) {
1693 checkDisplayId = displayId;
1694 };
1695 sceneSession->NotifySessionDisplayIdChange(moveDisplayId);
1696 ASSERT_EQ(moveDisplayId, checkDisplayId);
1697 }
1698
1699 /**
1700 * @tc.name: CheckAndMoveDisplayIdRecursively
1701 * @tc.desc: CheckAndMoveDisplayIdRecursively
1702 * @tc.type: FUNC
1703 */
1704 HWTEST_F(SceneSessionTest5, CheckAndMoveDisplayIdRecursively, Function | SmallTest | Level2)
1705 {
1706 const SessionInfo info;
1707 sptr<SceneSessionMocker> sceneSession = sptr<SceneSessionMocker>::MakeSptr(info, nullptr);
1708 uint64_t displayId = 234;
1709 sptr<SceneSessionMocker> subSession = sptr<SceneSessionMocker>::MakeSptr(info, nullptr);
1710 sceneSession->subSession_.push_back(subSession);
1711 EXPECT_CALL(*sceneSession, CheckAndMoveDisplayIdRecursively(displayId))
__anon692f4e5f1502(uint64_t displayId) 1712 .WillRepeatedly([weakThis = wptr(sceneSession)](uint64_t displayId) {
1713 auto session = weakThis.promote();
1714 if (session) {
1715 return weakThis->SceneSession::CheckAndMoveDisplayIdRecursively(displayId);
1716 } else {
1717 GTEST_LOG_(INFO) << "SceneSessionMocker:NULL";
1718 return;
1719 }
1720 });
1721 sceneSession->property_->SetDisplayId(displayId);
1722 sceneSession->shouldFollowParentWhenShow_ = true;
1723 EXPECT_CALL(*sceneSession, SetScreenId(displayId)).Times(0);
1724 sceneSession->CheckAndMoveDisplayIdRecursively(displayId);
1725 sceneSession->property_->SetDisplayId(123);
1726 sceneSession->shouldFollowParentWhenShow_ = false;
1727 EXPECT_CALL(*sceneSession, SetScreenId(displayId)).Times(0);
1728 sceneSession->CheckAndMoveDisplayIdRecursively(displayId);
1729 sceneSession->property_->SetDisplayId(123);
1730 sceneSession->shouldFollowParentWhenShow_ = true;
1731 EXPECT_CALL(*sceneSession, SetScreenId(displayId)).Times(1);
1732 EXPECT_CALL(*subSession, CheckAndMoveDisplayIdRecursively(displayId)).Times(1);
1733 sceneSession->CheckAndMoveDisplayIdRecursively(displayId);
1734 ASSERT_EQ(sceneSession->property_->GetDisplayId(), displayId);
1735 }
1736
1737 /**
1738 * @tc.name: SetShouldFollowParentWhenShow
1739 * @tc.desc: SetShouldFollowParentWhenShow
1740 * @tc.type: FUNC
1741 */
1742 HWTEST_F(SceneSessionTest5, SetShouldFollowParentWhenShow, Function | SmallTest | Level2)
1743 {
1744 const SessionInfo info;
1745 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1746 sceneSession->SetShouldFollowParentWhenShow(false);
1747 ASSERT_EQ(sceneSession->shouldFollowParentWhenShow_, false);
1748 }
1749
1750 HWTEST_F(SceneSessionTest5, CheckSubSessionShouldFollowParent, Function | SmallTest | Level2)
1751 {
1752 const SessionInfo info;
1753 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1754 sptr<SceneSession> subSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1755 sceneSession->subSession_.push_back(subSession);
1756 subSession->state_ = SessionState::STATE_ACTIVE;
1757 uint64_t displayIdBase = 123;
1758 uint64_t displayIdDiff = 345;
1759 subSession->property_->SetDisplayId(displayIdBase);
1760 sceneSession->CheckSubSessionShouldFollowParent(displayIdBase);
1761 sceneSession->CheckSubSessionShouldFollowParent(displayIdBase);
1762 EXPECT_EQ(subSession->shouldFollowParentWhenShow_, true);
1763 sceneSession->CheckSubSessionShouldFollowParent(displayIdDiff);
1764 EXPECT_EQ(subSession->shouldFollowParentWhenShow_, false);
1765 }
1766
1767 /**
1768 * @tc.name: ActivateKeyboardAvoidArea01
1769 * @tc.desc: test ActivateKeyboardAvoidArea
1770 * @tc.type: FUNC
1771 */
1772 HWTEST_F(SceneSessionTest5, ActivateKeyboardAvoidArea01, Function | SmallTest | Level2)
1773 {
1774 SessionInfo info;
1775 info.bundleName_ = "ActivateKeyboardAvoidArea01";
1776 info.abilityName_ = "ActivateKeyboardAvoidArea01";
1777 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1778 ASSERT_EQ(true, sceneSession->IsKeyboardAvoidAreaActive());
1779 sceneSession->ActivateKeyboardAvoidArea(false, true);
1780 ASSERT_EQ(false, sceneSession->IsKeyboardAvoidAreaActive());
1781 sceneSession->ActivateKeyboardAvoidArea(false, false);
1782 ASSERT_EQ(false, sceneSession->IsKeyboardAvoidAreaActive());
1783 sceneSession->ActivateKeyboardAvoidArea(true, true);
1784 ASSERT_EQ(true, sceneSession->IsKeyboardAvoidAreaActive());
1785 sceneSession->ActivateKeyboardAvoidArea(true, false);
1786 ASSERT_EQ(true, sceneSession->IsKeyboardAvoidAreaActive());
1787 }
1788
1789 /**
1790 * @tc.name: IsSameMainSession
1791 * @tc.desc: test IsSameMainSession
1792 * @tc.type: FUNC
1793 */
1794 HWTEST_F(SceneSessionTest5, IsSameMainSession, Function | SmallTest | Level2)
1795 {
1796 SessionInfo info1;
1797 info1.abilityName_ = "abilityName_test1";
1798 info1.bundleName_ = "bundleName_test1";
1799 SessionInfo info2;
1800 info2.abilityName_ = "abilityName_test2";
1801 info2.bundleName_ = "bundleName_test2";
1802 sptr<SceneSession> preSceneSession = sptr<SceneSession>::MakeSptr(info1, nullptr);
1803 sptr<SceneSession> currSceneSession = sptr<SceneSession>::MakeSptr(info2, nullptr);
1804 preSceneSession->persistentId_ = 1;
1805 currSceneSession->persistentId_ = 1;
1806 ASSERT_EQ(true, currSceneSession->IsSameMainSession(preSceneSession));
1807 currSceneSession->persistentId_ = 2;
1808 ASSERT_EQ(false, currSceneSession->IsSameMainSession(preSceneSession));
1809
1810 sptr<SceneSession> subSession1 = sptr<SceneSession>::MakeSptr(info1, nullptr);
1811 sptr<SceneSession> subSession2 = sptr<SceneSession>::MakeSptr(info2, nullptr);
1812 subSession1->SetParentSession(preSceneSession);
1813 subSession2->SetParentSession(currSceneSession);
1814 currSceneSession->persistentId_ = 1;
1815 subSession1->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1816 subSession2->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1817 ASSERT_EQ(true, subSession1->IsSameMainSession(subSession1));
1818 currSceneSession->persistentId_ = 2;
1819 ASSERT_EQ(false, subSession1->IsSameMainSession(subSession2));
1820 }
1821
1822 /**
1823 * @tc.name: HandleActionUpdateExclusivelyHighlighted
1824 * @tc.desc: test HandleActionUpdateExclusivelyHighlighted
1825 * @tc.type: FUNC
1826 */
1827 HWTEST_F(SceneSessionTest5, HandleActionUpdateExclusivelyHighlighted, Function | SmallTest | Level2)
1828 {
1829 SessionInfo info;
1830 info.abilityName_ = "HandleActionUpdateExclusivelyHighlighted";
1831 info.bundleName_ = "HandleActionUpdateExclusivelyHighlighted";
1832 info.isSystem_ = true;
1833 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1834 ASSERT_NE(nullptr, session);
1835 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1836 ASSERT_NE(nullptr, property);
1837 property->SetExclusivelyHighlighted(true);
1838 WSPropertyChangeAction action = WSPropertyChangeAction::ACTION_UPDATE_EXCLUSIVE_HIGHLIGHTED;
1839 auto res = session->HandleActionUpdateExclusivelyHighlighted(property, action);
1840 EXPECT_EQ(WMError::WM_OK, res);
1841 }
1842
1843 /**
1844 * @tc.name: SetHighlightChangeNotifyFunc
1845 * @tc.desc: SetHighlightChangeNotifyFunc Test
1846 * @tc.type: FUNC
1847 */
1848 HWTEST_F(SceneSessionTest5, SetHighlightChangeNotifyFunc, Function | SmallTest | Level2)
1849 {
1850 SessionInfo info;
1851 info.abilityName_ = "test";
1852 info.bundleName_ = "test";
1853 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1854 EXPECT_NE(session, nullptr);
__anon692f4e5f1602(int32_t persistentId) 1855 session->SetHighlightChangeNotifyFunc([](int32_t persistentId) {});
1856 EXPECT_NE(session->highlightChangeFunc_, nullptr);
1857 }
1858
1859 /**
1860 * @tc.name: StartMovingWithCoordinate_01
1861 * @tc.desc: StartMovingWithCoordinate
1862 * @tc.type: FUNC
1863 */
1864 HWTEST_F(SceneSessionTest5, StartMovingWithCoordinate_01, Function | SmallTest | Level2)
1865 {
1866 const SessionInfo info;
1867 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1868 sceneSession->moveDragController_ = nullptr;
1869 WSError result = sceneSession->StartMovingWithCoordinate(100, 50, 300, 500);
1870 EXPECT_EQ(result, WSError::WS_ERROR_NULLPTR);
1871 }
1872
1873 /**
1874 * @tc.name: StartMovingWithCoordinate_02
1875 * @tc.desc: StartMovingWithCoordinate
1876 * @tc.type: FUNC
1877 */
1878 HWTEST_F(SceneSessionTest5, StartMovingWithCoordinate_02, Function | SmallTest | Level2)
1879 {
1880 const SessionInfo info;
1881 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1882 sceneSession->moveDragController_ = sptr<MoveDragController>::MakeSptr(2024, sceneSession->GetWindowType());
1883 sceneSession->moveDragController_->isStartMove_ = true;
1884 WSError result = sceneSession->StartMovingWithCoordinate(100, 50, 300, 500);
1885 EXPECT_EQ(result, WSError::WS_ERROR_REPEAT_OPERATION);
1886 }
1887
1888 /**
1889 * @tc.name: StartMovingWithCoordinate_03
1890 * @tc.desc: StartMovingWithCoordinate
1891 * @tc.type: FUNC
1892 */
1893 HWTEST_F(SceneSessionTest5, StartMovingWithCoordinate_03, Function | SmallTest | Level2)
1894 {
1895 const SessionInfo info;
1896 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1897 sceneSession->moveDragController_ = sptr<MoveDragController>::MakeSptr(2024, sceneSession->GetWindowType());
1898 sceneSession->moveDragController_->isStartMove_ = false;
1899 WSError result = sceneSession->StartMovingWithCoordinate(100, 50, 300, 500);
1900 EXPECT_EQ(result, WSError::WS_OK);
1901 }
1902
1903 /**
1904 * @tc.name: SetColorSpace
1905 * @tc.desc: SetColorSpace function01
1906 * @tc.type: FUNC
1907 */
1908 HWTEST_F(SceneSessionTest5, SetColorSpace, Function | SmallTest | Level2)
1909 {
1910 SessionInfo info;
1911 info.abilityName_ = "SetColorSpace";
1912 info.bundleName_ = "SetColorSpace";
1913 sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
1914 EXPECT_NE(session, nullptr);
1915
1916 struct RSSurfaceNodeConfig config;
1917 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
1918 session->SetColorSpace(ColorSpace::COLOR_SPACE_WIDE_GAMUT);
1919 EXPECT_EQ(nullptr, session->GetSurfaceNode());
1920 session->surfaceNode_ = surfaceNode;
1921 session->SetColorSpace(ColorSpace::COLOR_SPACE_WIDE_GAMUT);
1922 EXPECT_NE(nullptr, session->GetSurfaceNode());
1923 }
1924
1925 /**
1926 * @tc.name: UpdateCrossAxisOfLayout
1927 * @tc.desc: UpdateCrossAxisOfLayout
1928 * @tc.type: FUNC
1929 */
1930 HWTEST_F(SceneSessionTest5, UpdateCrossAxisOfLayout, Function | SmallTest | Level2)
1931 {
1932 const SessionInfo info;
1933 sptr<SceneSessionMocker> sceneSession = sptr<SceneSessionMocker>::MakeSptr(info, nullptr);
1934 WSRect rect;
1935 EXPECT_CALL(*sceneSession, UpdateCrossAxis()).Times(1);
1936 sceneSession->SceneSession::UpdateCrossAxisOfLayout(rect);
1937 }
1938
1939 /**
1940 * @tc.name: UpdateCrossAxis
1941 * @tc.desc: UpdateCrossAxis
1942 * @tc.type: FUNC
1943 */
1944 HWTEST_F(SceneSessionTest5, UpdateCrossAxis, Function | SmallTest | Level2)
1945 {
1946 const SessionInfo info;
1947 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1948 auto sessionStageMocker = sptr<SessionStageMocker>::MakeSptr();
1949 sceneSession->sessionStage_ = sessionStageMocker;
1950 // always have ovelap with axis
1951 sceneSession->isCrossAxisOfLayout_ = true;
1952 // not fold screen
1953 PcFoldScreenManager::GetInstance().displayId_ = SCREEN_ID_INVALID;
1954 EXPECT_CALL(*sessionStageMocker, NotifyWindowCrossAxisChange(_)).Times(0);
1955 sceneSession->UpdateCrossAxis();
1956 // fold screen, but fold status unknown
1957 PcFoldScreenManager::GetInstance().displayId_ = 0;
1958 sceneSession->GetSessionProperty()->displayId_ = 0;
1959 PcFoldScreenManager::GetInstance().screenFoldStatus_ = SuperFoldStatus::UNKNOWN;
1960 sceneSession->crossAxisState_ = 100;
1961 EXPECT_CALL(*sessionStageMocker, NotifyWindowCrossAxisChange(CrossAxisState::STATE_INVALID)).Times(1);
1962 sceneSession->UpdateCrossAxis();
1963 // state: half folded
1964 sceneSession->crossAxisState_ = 100;
1965 PcFoldScreenManager::GetInstance().screenFoldStatus_ = SuperFoldStatus::HALF_FOLDED;
1966 EXPECT_CALL(*sessionStageMocker, NotifyWindowCrossAxisChange(CrossAxisState::STATE_CROSS)).Times(1);
1967 sceneSession->UpdateCrossAxis();
1968 // state: other
1969 sceneSession->crossAxisState_ = 100;
1970 PcFoldScreenManager::GetInstance().screenFoldStatus_ = SuperFoldStatus::EXPANDED;
1971 EXPECT_CALL(*sessionStageMocker, NotifyWindowCrossAxisChange(CrossAxisState::STATE_NO_CROSS)).Times(1);
1972 sceneSession->UpdateCrossAxis();
1973 // sessionStage is nullptr
1974 sceneSession->crossAxisState_ = 100;
1975 sceneSession->sessionStage_ = nullptr;
1976 EXPECT_CALL(*sessionStageMocker, NotifyWindowCrossAxisChange(_)).Times(0);
1977 sceneSession->UpdateCrossAxis();
1978 }
1979
1980 /**
1981 * @tc.name: GetCrossAxisState
1982 * @tc.desc: GetCrossAxisState
1983 * @tc.type: FUNC
1984 */
1985 HWTEST_F(SceneSessionTest5, GetCrossAxisState, Function | SmallTest | Level2)
1986 {
1987 const SessionInfo info;
1988 sptr<SceneSessionMocker> sceneSession = sptr<SceneSessionMocker>::MakeSptr(info, nullptr);
1989 sceneSession->crossAxisState_ = 1;
1990 CrossAxisState state = CrossAxisState::STATE_INVALID;
1991 sceneSession->GetCrossAxisState(state);
1992 EXPECT_EQ(state, CrossAxisState::STATE_CROSS);
1993 }
1994 }
1995 } // namespace Rosen
1996 } // namespace OHOS