1 /*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include "transaction/rs_uiextension_data.h"
16 #include "input_manager.h"
17 #include "session_manager/include/scene_session_dirty_manager.h"
18 #include <gtest/gtest.h>
19 #include <parameter.h>
20 #include <parameters.h>
21 #include "screen_session_manager/include/screen_session_manager_client.h"
22 #include "session/host/include/scene_session.h"
23 #include "session/host/include/sub_session.h"
24 #include "session_manager/include/scene_session_manager.h"
25 #include "transaction/rs_uiextension_data.h"
26
27
28 using namespace testing;
29 using namespace testing::ext;
30
31 namespace OHOS {
32 namespace Rosen {
33 constexpr int POINTER_CHANGE_AREA_SIXTEEN = 16;
34 constexpr int POINTER_CHANGE_AREA_DEFAULT = 0;
35 constexpr int POINTER_CHANGE_AREA_FIVE = 5;
36 static int32_t g_screenRotationOffset = system::GetIntParameter<int32_t>("const.fold.screen_rotation.offset", 0);
37 class SceneSessionDirtyManagerTest : public testing::Test {
38 public:
39 static void SetUpTestCase();
40 static void TearDownTestCase();
41 void SetUp() override;
42 void TearDown() override;
43 static constexpr uint32_t WAIT_SYNC_IN_NS = 500000;
44 };
45 SceneSessionDirtyManager *manager_;
46 SceneSessionManager *ssm_;
SetUpTestCase()47 void SceneSessionDirtyManagerTest::SetUpTestCase()
48 {
49 ssm_ = &SceneSessionManager::GetInstance();
50 ssm_->sceneSessionMap_.clear();
51 }
52
TearDownTestCase()53 void SceneSessionDirtyManagerTest::TearDownTestCase()
54 {
55 ssm_ = nullptr;
56 }
57
SetUp()58 void SceneSessionDirtyManagerTest::SetUp()
59 {
60 manager_ = new SceneSessionDirtyManager();
61 }
62
TearDown()63 void SceneSessionDirtyManagerTest::TearDown()
64 {
65 usleep(WAIT_SYNC_IN_NS);
66 delete manager_;
67 manager_ = nullptr;
68 }
69 namespace {
70
71 /**
72 * @tc.name: NotifyWindowInfoChange
73 * @tc.desc: NotifyWindowInfoChange
74 * @tc.type: FUNC
75 */
76 HWTEST_F(SceneSessionDirtyManagerTest, NotifyWindowInfoChange, Function | SmallTest | Level2)
77 {
78 int ret = 0;
79 manager_->NotifyWindowInfoChange(nullptr, WindowUpdateType::WINDOW_UPDATE_ADDED, true);
80 SessionInfo info;
81 info.abilityName_ = "TestAbilityName";
82 info.bundleName_ = "TestBundleName";
83 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
84 if (sceneSession == nullptr) {
85 return;
86 }
87 manager_->NotifyWindowInfoChange(sceneSession, WindowUpdateType::WINDOW_UPDATE_ADDED, true);
88 manager_->NotifyWindowInfoChange(sceneSession, WindowUpdateType::WINDOW_UPDATE_REMOVED, true);
89 manager_->NotifyWindowInfoChange(sceneSession, WindowUpdateType::WINDOW_UPDATE_ACTIVE, true);
90 manager_->NotifyWindowInfoChange(sceneSession, WindowUpdateType::WINDOW_UPDATE_FOCUSED, true);
91 ASSERT_EQ(ret, 0);
92 }
93
94 /**
95 * @tc.name: GetFullWindowInfoList
96 * @tc.desc: GetFullWindowInfoList
97 * @tc.type: FUNC
98 */
99 HWTEST_F(SceneSessionDirtyManagerTest, GetFullWindowInfoList, Function | SmallTest | Level2)
100 {
101 int ret = 0;
102 SessionInfo info;
103 info.abilityName_ = "TestAbilityName";
104 info.bundleName_ = "TestBundleName";
105 {
106 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
107 if (sceneSession == nullptr) {
108 return;
109 }
110 ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
111 }
112 {
113 ssm_->sceneSessionMap_.insert({111, nullptr});
114 }
115 {
116 sptr<SceneSession> sceneSessionDialog1 = new (std::nothrow) SceneSession(info, nullptr);
117 if (sceneSessionDialog1 == nullptr) {
118 return;
119 }
120 sptr<WindowSessionProperty> propertyDialog1 = sceneSessionDialog1->GetSessionProperty();
121 propertyDialog1->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
122 ssm_->sceneSessionMap_.insert({sceneSessionDialog1->GetPersistentId(), sceneSessionDialog1});
123 }
124 {
125 sptr<SceneSession> sceneSessionModal1 = new (std::nothrow) SceneSession(info, nullptr);
126 if (sceneSessionModal1 == nullptr) {
127 return;
128 }
129 sptr<WindowSessionProperty> propertyModal1 = sceneSessionModal1->GetSessionProperty();
130 propertyModal1->SetWindowFlags(static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_IS_MODAL));
131 ssm_->sceneSessionMap_.insert({sceneSessionModal1->GetPersistentId(), sceneSessionModal1});
132 }
133 manager_->GetFullWindowInfoList();
134 ASSERT_EQ(ret, 0);
135 }
136
137 /**
138 * @tc.name: IsFilterSession
139 * @tc.desc: IsFilterSession
140 * @tc.type: FUNC
141 */
142 HWTEST_F(SceneSessionDirtyManagerTest, IsFilterSession, Function | SmallTest | Level2)
143 {
144 int ret = 0;
145 manager_->IsFilterSession(nullptr);
146 SessionInfo info;
147 info.abilityName_ = "test1";
148 info.bundleName_ = "test2";
149 info.sceneType_ = SceneType::INPUT_SCENE;
150 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
151 if (sceneSession == nullptr) {
152 return;
153 }
154 sptr<WindowSessionProperty> property = sceneSession->GetSessionProperty();
155 info.sceneType_ = SceneType::INPUT_SCENE;
156 manager_->IsFilterSession(sceneSession);
157 info.sceneType_ = SceneType::WINDOW_SCENE;
158 info.isSystem_ = false;
159 sceneSession->isVisible_ = false;
160 sceneSession->isSystemActive_ = false;
161 manager_->IsFilterSession(sceneSession);
162 info.isSystem_ = true;
163 manager_->IsFilterSession(sceneSession);
164 sceneSession->isVisible_ = true;
165 manager_->IsFilterSession(sceneSession);
166 sceneSession->isSystemActive_ = true;
167 manager_->IsFilterSession(sceneSession);
168 info.isSystem_ = true;
169 sceneSession->isVisible_ = true;
170 sceneSession->SetSystemActive(true);
171 manager_->IsFilterSession(sceneSession);
172 info.isSystem_ = false;
173 sceneSession->isVisible_ = false;
174 sceneSession->SetSystemActive(false);
175 manager_->IsFilterSession(sceneSession);
176 sceneSession->isVisible_ = false;
177 manager_->IsFilterSession(sceneSession);
178 ASSERT_EQ(ret, 0);
179 }
180
181 /**
182 * @tc.name: GetWindowInfo
183 * @tc.desc: GetWindowInfo
184 * @tc.type: FUNC
185 */
186 HWTEST_F(SceneSessionDirtyManagerTest, GetWindowInfo, Function | SmallTest | Level2)
187 {
188 int ret = 0;
189 manager_->GetWindowInfo(nullptr, SceneSessionDirtyManager::WindowAction::WINDOW_ADD);
190 SessionInfo info;
191 info.abilityName_ = "111";
192 info.bundleName_ = "111";
193 sptr<SceneSession> session = new (std::nothrow) SceneSession(info, nullptr);
194 if (session == nullptr) {
195 return;
196 }
197 manager_->GetWindowInfo(session, SceneSessionDirtyManager::WindowAction::WINDOW_ADD);
198 session = new (std::nothrow) SceneSession(info, nullptr);
199 if (session == nullptr) {
200 return;
201 }
202 sptr<WindowSessionProperty> windowSessionProperty = session->GetSessionProperty();
203 manager_->GetWindowInfo(session, SceneSessionDirtyManager::WindowAction::WINDOW_ADD);
204 windowSessionProperty->SetWindowMode(Rosen::WindowMode::WINDOW_MODE_FLOATING);
205 manager_->GetWindowInfo(session, SceneSessionDirtyManager::WindowAction::WINDOW_ADD);
206 windowSessionProperty->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
207 manager_->GetWindowInfo(session, SceneSessionDirtyManager::WindowAction::WINDOW_ADD);
208 windowSessionProperty->SetMaximizeMode(Rosen::MaximizeMode::MODE_AVOID_SYSTEM_BAR);
209 manager_->GetWindowInfo(session, SceneSessionDirtyManager::WindowAction::WINDOW_ADD);
210 info.isSetPointerAreas_ = true;
211 manager_->GetWindowInfo(session, SceneSessionDirtyManager::WindowAction::WINDOW_ADD);
212 windowSessionProperty->SetWindowFlags(static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_HANDWRITING));
213 manager_->GetWindowInfo(session, SceneSessionDirtyManager::WindowAction::WINDOW_ADD);
214 windowSessionProperty->SetWindowFlags(static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_IS_MODAL));
215 manager_->GetWindowInfo(session, SceneSessionDirtyManager::WindowAction::WINDOW_ADD);
216 session->SetSessionProperty(nullptr);
217 manager_->GetWindowInfo(session, SceneSessionDirtyManager::WindowAction::WINDOW_ADD);
218 ASSERT_EQ(ret, 0);
219 }
220
221 /**
222 * @tc.name: CalNotRotateTransform
223 * @tc.desc: CalNotRotateTransform
224 * @tc.type: FUNC
225 */
226 HWTEST_F(SceneSessionDirtyManagerTest, CalNotRotateTransform, Function | SmallTest | Level2)
227 {
228 int ret = 0;
229 SessionInfo sessionInfo;
230 sessionInfo.bundleName_ = "CalNotRotateTransform";
231 sessionInfo.moduleName_ = "sessionInfo";
232 SingleHandData testSingleHandData;
233 Matrix3f transform;
234 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(sessionInfo, nullptr);
235 ASSERT_NE(sceneSession, nullptr);
236 manager_->CalNotRotateTransform(nullptr, transform, testSingleHandData);
237 auto screenId = 0;
238 sceneSession->GetSessionProperty()->SetDisplayId(screenId);
239 manager_->CalNotRotateTransform(sceneSession, transform, testSingleHandData);
240 ScreenProperty screenProperty0;
241 screenProperty0.SetRotation(0.0f);
242 ScreenSessionConfig config;
243 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_CLIENT);
244 ASSERT_NE(screenSession, nullptr);
245 Rosen::ScreenSessionManagerClient::GetInstance().OnUpdateFoldDisplayMode(FoldDisplayMode::UNKNOWN);
246 ScreenPropertyChangeReason reason = ScreenPropertyChangeReason::UNDEFINED;
247 Rosen::ScreenSessionManagerClient::GetInstance().screenSessionMap_.emplace(screenId, screenSession);
248 Rosen::ScreenSessionManagerClient::GetInstance().OnPropertyChanged(screenId, screenProperty0, reason);
249 manager_->CalNotRotateTransform(sceneSession, transform, testSingleHandData);
250
251 screenProperty0.SetRotation(90.0f);
252 Rosen::ScreenSessionManagerClient::GetInstance().OnPropertyChanged(screenId, screenProperty0, reason);
253 manager_->CalNotRotateTransform(sceneSession, transform, testSingleHandData);
254
255 screenProperty0.SetRotation(180.0f);
256 Rosen::ScreenSessionManagerClient::GetInstance().OnPropertyChanged(screenId, screenProperty0, reason);
257 manager_->CalNotRotateTransform(sceneSession, transform, testSingleHandData);
258
259 screenProperty0.SetRotation(270.0f);
260 Rosen::ScreenSessionManagerClient::GetInstance().OnPropertyChanged(screenId, screenProperty0, reason);
261 manager_->CalNotRotateTransform(sceneSession, transform, testSingleHandData);
262 ASSERT_EQ(ret, 0);
263
264 sptr<SceneSession> sceneSessionWithNullProperty = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
265 sceneSessionWithNullProperty->SetSessionProperty(nullptr);
266 manager_->CalNotRotateTransform(sceneSessionWithNullProperty, transform, testSingleHandData);
267 ASSERT_EQ(ret, 0);
268 }
269
270 /**
271 * @tc.name: CalTransform
272 * @tc.desc: CalTransform
273 * @tc.type: FUNC
274 */
275 HWTEST_F(SceneSessionDirtyManagerTest, CalTransform, Function | SmallTest | Level2)
276 {
277 int ret = 0;
278 SessionInfo sessionInfo;
279 sessionInfo.bundleName_ = "CalTransform";
280 sessionInfo.moduleName_ = "CalTransform";
281 SingleHandData testSingleHandData;
282 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(sessionInfo, nullptr);
283 if (sceneSession == nullptr) {
284 return;
285 }
286 Matrix3f transform;
287 manager_->CalTransform(nullptr, transform, testSingleHandData);
288 sessionInfo.isRotable_ = true;
289 manager_->CalTransform(sceneSession, transform, testSingleHandData);
290 sessionInfo.isSystem_ = true;
291 manager_->CalTransform(sceneSession, transform, testSingleHandData);
292 sessionInfo.isRotable_ = false;
293 manager_->CalTransform(sceneSession, transform, testSingleHandData);
294 sessionInfo.isRotable_ = true;
295 sessionInfo.isSystem_ = false;
296 manager_->CalTransform(sceneSession, transform, testSingleHandData);
297 sessionInfo.isSystem_ = true;
298 auto preScreenSessionManager = Rosen::ScreenSessionManagerClient::GetInstance().screenSessionManager_;
299 Rosen::ScreenSessionManagerClient::GetInstance().screenSessionManager_ = nullptr;
300 manager_->CalTransform(sceneSession, transform, testSingleHandData);
301 Rosen::ScreenSessionManagerClient::GetInstance().screenSessionManager_ = preScreenSessionManager;
302 manager_->CalTransform(sceneSession, transform, testSingleHandData);
303 ASSERT_EQ(ret, 0);
304 }
305
306 /**
307 * @tc.name: UpdateHotAreas
308 * @tc.desc: UpdateHotAreas
309 * @tc.type: FUNC
310 */
311 HWTEST_F(SceneSessionDirtyManagerTest, UpdateHotAreas, Function | SmallTest | Level2)
312 {
313 int ret = 0;
314 std::vector<MMI::Rect> empty(0);
315 manager_->UpdateHotAreas(nullptr, empty, empty);
316 SessionInfo sessionInfo;
317 sessionInfo.bundleName_ = "UpdateHotAreas";
318 sessionInfo.moduleName_ = "UpdateHotAreas";
319 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(sessionInfo, nullptr);
320 if (sceneSession == nullptr) {
321 return;
322 }
323 std::vector<MMI::Rect> touchHotAreas(0);
324 std::vector<MMI::Rect> pointerHotAreas(0);
325 std::vector<OHOS::Rosen::Rect> touchHotAreasInSceneSession(0);
326 sceneSession->GetSessionProperty()->SetTouchHotAreas(touchHotAreasInSceneSession);
327 sceneSession->persistentId_ = 1;
328 for (int i = 0; i < 2 ; i++) {
329 OHOS::Rosen::Rect area;
330 area.posX_ = i * 10;
331 area.posY_ = i * 10;
332 area.width_ = 10;
333 area.height_ = 10;
334 touchHotAreasInSceneSession.emplace_back(area);
335 }
336 sceneSession->GetSessionProperty()->SetTouchHotAreas(touchHotAreasInSceneSession);
337 manager_->UpdateHotAreas(sceneSession, touchHotAreas, pointerHotAreas);
338 for (int i = 2; i < 10 ; i++) {
339 OHOS::Rosen::Rect area;
340 area.posX_ = i * 10;
341 area.posY_ = i * 10;
342 area.width_ = 10;
343 area.height_ = 10;
344 touchHotAreasInSceneSession.emplace_back(area);
345 }
346 sceneSession->GetSessionProperty()->SetTouchHotAreas(touchHotAreasInSceneSession);
347 manager_->UpdateHotAreas(sceneSession, touchHotAreas, pointerHotAreas);
348 std::vector<OHOS::Rosen::Rect> fullSceneSession(static_cast<uint32_t>(MMI::WindowInfo::MAX_HOTAREA_COUNT));
349 sceneSession->GetSessionProperty()->SetTouchHotAreas(fullSceneSession);
350 manager_->UpdateHotAreas(sceneSession, touchHotAreas, pointerHotAreas);
351 ASSERT_EQ(ret, 0);
352 }
353
354 /**
355 * @tc.name: UpdateDefaultHotAreas
356 * @tc.desc: UpdateDefaultHotAreas
357 * @tc.type: FUNC
358 */
359 HWTEST_F(SceneSessionDirtyManagerTest, UpdateDefaultHotAreas, Function | SmallTest | Level2)
360 {
361 int ret = 0;
362 std::vector<MMI::Rect> empty(0);
363 manager_->UpdateDefaultHotAreas(nullptr, empty, empty);
364 SessionInfo sessionInfo;
365 sessionInfo.bundleName_ = "UpdateDefaultHotAreas";
366 sessionInfo.moduleName_ = "UpdateDefaultHotAreas";
367 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(sessionInfo, nullptr);
368 if (sceneSession == nullptr) {
369 return;
370 }
371 WSRect rect = {0, 0, 320, 240};
372 sceneSession->SetSessionRect(rect);
373 manager_->UpdateDefaultHotAreas(sceneSession, empty, empty);
374 sceneSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
375 manager_->UpdateDefaultHotAreas(sceneSession, empty, empty);
376 sceneSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_PIP);
377 manager_->UpdateDefaultHotAreas(sceneSession, empty, empty);
378 sceneSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_SCENE_BOARD);
379 manager_->UpdateDefaultHotAreas(sceneSession, empty, empty);
380 sceneSession->SetSessionProperty(nullptr);
381 manager_->UpdateDefaultHotAreas(sceneSession, empty, empty);
382 ASSERT_EQ(ret, 0);
383 }
384
385 /**
386 * @tc.name: ConvertDegreeToMMIRotation
387 * @tc.desc: ConvertDegreeToMMIRotation
388 * @tc.type: FUNC
389 */
390 HWTEST_F(SceneSessionDirtyManagerTest, ConvertDegreeToMMIRotation, Function | SmallTest | Level2)
391 {
392 MMI::Direction dirction = MMI::DIRECTION0;
393 dirction = ConvertDegreeToMMIRotation(0.0);
394 ASSERT_EQ(dirction, MMI::DIRECTION0);
395 dirction = ConvertDegreeToMMIRotation(90.0);
396 ASSERT_EQ(dirction, MMI::DIRECTION90);
397 dirction = ConvertDegreeToMMIRotation(180.0);
398 ASSERT_EQ(dirction, MMI::DIRECTION180);
399 dirction = ConvertDegreeToMMIRotation(270.0);
400 ASSERT_EQ(dirction, MMI::DIRECTION270);
401 dirction = ConvertDegreeToMMIRotation(30.0);
402 ASSERT_EQ(dirction, MMI::DIRECTION0);
403 }
404
405 /**
406 * @tc.name: GetDialogSessionMap
407 * @tc.desc: GetDialogSessionMap
408 * @tc.type: FUNC
409 */
410 HWTEST_F(SceneSessionDirtyManagerTest, GetDialogSessionMap, Function | SmallTest | Level2)
411 {
412 std::map<int32_t, sptr<SceneSession>> sessionMap;
413 SessionInfo info;
414 info.abilityName_ = "TestAbilityName";
415 info.bundleName_ = "TestBundleName";
416 sessionMap.emplace(1, nullptr);
417 auto sessionList = manager_->GetDialogSessionMap(sessionMap);
418 ASSERT_EQ(0, sessionList.size());
419 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
420 if (!sceneSession) {
421 GTEST_LOG_(INFO) << "sceneSession is nullptr";
422 return;
423 }
424 sessionMap.emplace(2, sceneSession);
425 auto sessionList2 = manager_->GetDialogSessionMap(sessionMap);
426 ASSERT_EQ(0, sessionList2.size());
427 sptr<WindowSessionProperty> property = new WindowSessionProperty();
428 if (!property) {
429 GTEST_LOG_(INFO) << "property is nullptr";
430 return;
431 }
432 property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
433 sceneSession->SetSessionProperty(property);
434 sptr<Session> session = new (std::nothrow) Session(info);
435 if (!session) {
436 GTEST_LOG_(INFO) << "session is nullptr";
437 return;
438 }
439 sceneSession->SetParentSession(session);
440 auto sessionList3 = manager_->GetDialogSessionMap(sessionMap);
441 ASSERT_EQ(1, sessionList3.size());
442 sceneSession->SetForceHideState(ForceHideState::NOT_HIDDEN);
443 auto sessionList4 = manager_->GetDialogSessionMap(sessionMap);
444 ASSERT_EQ(1, sessionList4.size());
445 sceneSession->SetForceHideState(ForceHideState::HIDDEN_WHEN_FOCUSED);
446 sceneSession->SetSessionProperty(nullptr);
447 sceneSession->SetParentSession(nullptr);
448 auto sessionList5 = manager_->GetDialogSessionMap(sessionMap);
449 ASSERT_EQ(0, sessionList5.size());
450 }
451
452 /**
453 * @tc.name: GetDialogSessionMap02
454 * @tc.desc: GetDialogSessionMap
455 * @tc.type: FUNC
456 */
457 HWTEST_F(SceneSessionDirtyManagerTest, GetDialogSessionMap02, Function | SmallTest | Level2)
458 {
459 SessionInfo info;
460 info.abilityName_ = "TestAbilityName";
461 info.bundleName_ = "TestBundleName";
462 sptr<SubSession> sceneSession = sptr<SubSession>::MakeSptr(info, nullptr);
463 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
464 property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
465 property->AddWindowFlag(WindowFlag::WINDOW_FLAG_IS_MODAL);
466 property->AddWindowFlag(WindowFlag::WINDOW_FLAG_IS_APPLICATION_MODAL);
467 sceneSession->SetSessionProperty(property);
468 sptr<Session> session = sptr<Session>::MakeSptr(info);
469 sceneSession->SetParentSession(session);
470 std::map<int32_t, sptr<SceneSession>> sessionMap;
471 sessionMap.emplace(1, sceneSession);
472 auto sessionList = manager_->GetDialogSessionMap(sessionMap);
473 ASSERT_EQ(2, sessionList.size());
474 }
475
476 /**
477 * @tc.name: UpdatePointerAreas
478 * @tc.desc: UpdatePointerAreas
479 * @tc.type: FUNC
480 */
481 HWTEST_F(SceneSessionDirtyManagerTest, UpdatePointerAreas, Function | SmallTest | Level2)
482 {
483 std::vector<int32_t> pointerChangeAreas;
484 SessionInfo info;
485 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
486 sptr<WindowSessionProperty> property = new WindowSessionProperty();
487 if (!sceneSession || !property) {
488 return;
489 }
490 property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
491 property->SetDragEnabled(false);
492 sceneSession->SetSessionProperty(property);
493 manager_->UpdatePointerAreas(sceneSession, pointerChangeAreas);
494 ASSERT_EQ(0, pointerChangeAreas.size());
495 property->SetDragEnabled(true);
496 float vpr = 1.5f;
497 property->SetDisplayId(100);
498 int32_t pointerAreaFivePx = static_cast<int32_t>(POINTER_CHANGE_AREA_FIVE * vpr);
499 int32_t pointerAreaSixteenPx = static_cast<int32_t>(POINTER_CHANGE_AREA_SIXTEEN * vpr);
500 WindowLimits limits;
501 limits.maxHeight_ = 1;
502 limits.minHeight_ = 0;
503 limits.maxWidth_ = 0;
504 limits.minWidth_ = 0;
505 property->SetWindowLimits(limits);
506 manager_->UpdatePointerAreas(sceneSession, pointerChangeAreas);
507 std::vector<int32_t> compare2 = {POINTER_CHANGE_AREA_DEFAULT, pointerAreaFivePx,
508 POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT,
509 pointerAreaFivePx, POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT};
510 ASSERT_EQ(compare2, pointerChangeAreas);
511 limits.maxHeight_ = 0;
512 limits.maxWidth_ = 1;
513 property->SetWindowLimits(limits);
514 manager_->UpdatePointerAreas(sceneSession, pointerChangeAreas);
515 std::vector<int32_t> compare3 = {POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT,
516 POINTER_CHANGE_AREA_DEFAULT, pointerAreaFivePx, POINTER_CHANGE_AREA_DEFAULT,
517 POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT, pointerAreaFivePx};
518 ASSERT_EQ(compare3, pointerChangeAreas);
519 limits.maxHeight_ = 1;
520 property->SetWindowLimits(limits);
521 manager_->UpdatePointerAreas(sceneSession, pointerChangeAreas);
522 std::vector<int32_t> compare4 = pointerChangeAreas = {pointerAreaSixteenPx, pointerAreaFivePx,
523 pointerAreaSixteenPx, pointerAreaFivePx, pointerAreaSixteenPx,
524 pointerAreaFivePx, pointerAreaSixteenPx, pointerAreaFivePx};
525 ASSERT_EQ(compare4, pointerChangeAreas);
526 manager_->UpdatePointerAreas(nullptr, pointerChangeAreas);
527 sceneSession->SetSessionProperty(nullptr);
528 manager_->UpdatePointerAreas(nullptr, pointerChangeAreas);
529 }
530
531 /**
532 * @tc.name: UpdatePrivacyMode
533 * @tc.desc: UpdatePrivacyMode
534 * @tc.type: FUNC
535 */
536 HWTEST_F(SceneSessionDirtyManagerTest, UpdatePrivacyMode, Function | SmallTest | Level2)
537 {
538 SessionInfo info;
539 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
540 ASSERT_NE(sceneSession, nullptr);
541 MMI::WindowInfo windowinfo;
542 auto tempProperty = sceneSession->GetSessionProperty();
543 sceneSession->property_ = nullptr;
544 manager_->UpdatePrivacyMode(sceneSession, windowinfo);
545
546 sceneSession->property_ = tempProperty;
547 sceneSession->property_->isPrivacyMode_ = true;
548 sceneSession->property_->isSystemPrivacyMode_ = false;
549 manager_->UpdatePrivacyMode(sceneSession, windowinfo);
550
551 sceneSession->property_->isPrivacyMode_ = false;
552 sceneSession->property_->isSystemPrivacyMode_ = true;
553 manager_->UpdatePrivacyMode(sceneSession, windowinfo);
554
555 sceneSession->property_->isPrivacyMode_ = false;
556 sceneSession->property_->isSystemPrivacyMode_ = false;
557 manager_->UpdatePrivacyMode(sceneSession, windowinfo);
558
559 manager_->UpdatePrivacyMode(nullptr, windowinfo);
560 }
561
562 /**
563 * @tc.name: UpdateWindowFlags
564 * @tc.desc: UpdateWindowFlags
565 * @tc.type: FUNC
566 */
567 HWTEST_F(SceneSessionDirtyManagerTest, UpdateWindowFlags, Function | SmallTest | Level2)
568 {
569 SessionInfo info;
570 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
571 ASSERT_NE(sceneSession, nullptr);
572 MMI::WindowInfo windowinfo;
573 auto screenId = 0;
574 manager_->UpdateWindowFlags(screenId, sceneSession, windowinfo);
575
576 ScreenProperty screenProperty0;
577 screenProperty0.SetRotation(0.0f);
578 ScreenSessionConfig config;
579 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_CLIENT);
580 ASSERT_NE(screenSession, nullptr);
581 screenSession->SetTouchEnabledFromJs(true);
582 Rosen::ScreenSessionManagerClient::GetInstance().OnUpdateFoldDisplayMode(FoldDisplayMode::UNKNOWN);
583 ScreenPropertyChangeReason reason = ScreenPropertyChangeReason::UNDEFINED;
584 Rosen::ScreenSessionManagerClient::GetInstance().screenSessionMap_.emplace(screenId, screenSession);
585 Rosen::ScreenSessionManagerClient::GetInstance().OnPropertyChanged(screenId, screenProperty0, reason);
586 manager_->UpdateWindowFlags(screenId, sceneSession, windowinfo);
587
588 screenSession->SetTouchEnabledFromJs(false);
589 Rosen::ScreenSessionManagerClient::GetInstance().screenSessionMap_.emplace(screenId, screenSession);
590 Rosen::ScreenSessionManagerClient::GetInstance().OnPropertyChanged(screenId, screenProperty0, reason);
591 manager_->UpdateWindowFlags(screenId, sceneSession, windowinfo);
592 }
593
594 /**
595 * @tc.name: AddModalExtensionWindowInfo
596 * @tc.desc: AddModalExtensionWindowInfo
597 * @tc.type: FUNC
598 */
599 HWTEST_F(SceneSessionDirtyManagerTest, AddModalExtensionWindowInfo, Function | SmallTest | Level2)
600 {
601 SessionInfo info;
602 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
603 ASSERT_NE(sceneSession, nullptr);
604
605 std::vector<MMI::WindowInfo> windowInfoList;
606 MMI::WindowInfo windowInfo;
607 windowInfoList.emplace_back(windowInfo);
608 ExtensionWindowEventInfo extensionInfo = {
609 .persistentId = 12345,
610 .pid = 1234
611 };
612 manager_->AddModalExtensionWindowInfo(windowInfoList, windowInfo, nullptr, extensionInfo);
613 EXPECT_EQ(windowInfoList.size(), 1);
614
615 sceneSession->AddNormalModalUIExtension(extensionInfo);
616 manager_->AddModalExtensionWindowInfo(windowInfoList, windowInfo, sceneSession, extensionInfo);
617 ASSERT_EQ(windowInfoList.size(), 2);
618 EXPECT_TRUE(windowInfoList[1].defaultHotAreas.empty());
619
620 Rect windowRect {1, 1, 7, 8};
621 extensionInfo.windowRect = windowRect;
622 sceneSession->UpdateNormalModalUIExtension(extensionInfo);
623 manager_->AddModalExtensionWindowInfo(windowInfoList, windowInfo, sceneSession, extensionInfo);
624 ASSERT_EQ(windowInfoList.size(), 3);
625 EXPECT_EQ(windowInfoList[2].defaultHotAreas.size(), 1);
626 }
627
628 /**
629 * @tc.name: GetHostComponentWindowInfo
630 * @tc.desc: GetHostComponentWindowInfo
631 * @tc.type: FUNC
632 */
633 HWTEST_F(SceneSessionDirtyManagerTest, GetHostComponentWindowInfo, Function | SmallTest | Level2)
634 {
635 MMI::WindowInfo hostWindowinfo;
636 SecSurfaceInfo secSurfaceInfo;
637 Matrix3f transform;
638 MMI::WindowInfo ret;
639 MMI::WindowInfo windowInfo;
640 ret = manager_->GetHostComponentWindowInfo(secSurfaceInfo, hostWindowinfo, transform);
641 ASSERT_EQ(ret.id, windowInfo.id);
642
643 SecRectInfo secRectInfo;
644 secSurfaceInfo.upperNodes.emplace_back(secRectInfo);
645 secSurfaceInfo.hostPid = 1;
646 windowInfo.pid = 1;
647 ret = manager_->GetHostComponentWindowInfo(secSurfaceInfo, hostWindowinfo, transform);
648 ASSERT_EQ(ret.pid, windowInfo.pid);
649
650 ret = manager_->GetHostComponentWindowInfo(secSurfaceInfo, hostWindowinfo, transform);
651 ASSERT_EQ(ret.defaultHotAreas.size(), 1);
652 }
653
654 /**
655 * @tc.name: GetSecComponentWindowInfo
656 * @tc.desc: GetSecComponentWindowInfo
657 * @tc.type: FUNC
658 */
659 HWTEST_F(SceneSessionDirtyManagerTest, GetSecComponentWindowInfo, Function | SmallTest | Level2)
660 {
661 MMI::WindowInfo hostWindowinfo;
662 SecSurfaceInfo secSurfaceInfo;
663 Matrix3f transform;
664 MMI::WindowInfo ret;
665 MMI::WindowInfo windowInfo;
666 ret = manager_->GetSecComponentWindowInfo(secSurfaceInfo, hostWindowinfo, nullptr, transform);
667 ASSERT_EQ(ret.id, windowInfo.id);
668
669 SessionInfo info;
670 info.abilityName_ = "TestAbilityName";
671 info.bundleName_ = "TestBundleName";
672 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
673 ASSERT_NE(sceneSession, nullptr);
674
675 ret = manager_->GetSecComponentWindowInfo(secSurfaceInfo, hostWindowinfo, sceneSession, transform);
676 ASSERT_EQ(ret.id, windowInfo.id);
677
678 secSurfaceInfo.uiExtensionNodeId = 1;
679 sceneSession->AddUIExtSurfaceNodeId(1, 1);
680 windowInfo.privacyUIFlag = true;
681 ret = manager_->GetSecComponentWindowInfo(secSurfaceInfo, hostWindowinfo, sceneSession, transform);
682 ASSERT_EQ(ret.privacyUIFlag, windowInfo.privacyUIFlag);
683
684 windowInfo.id = 1;
685 ret = manager_->GetSecComponentWindowInfo(secSurfaceInfo, hostWindowinfo, sceneSession, transform);
686 ASSERT_EQ(ret.id, windowInfo.id);
687 }
688
689 /**
690 * To test UpdatePointerAreas with different drag activated settings
691 * To expect pointerChangeAreas changes when dragActivated and dragEnable both are true
692 *
693 * @tc.name: CheckDragActivatedInUpdatePointerAreas
694 * @tc.desc: CheckDragActivatedInUpdatePointerAreas
695 * @tc.type: FUNC
696 */
697 HWTEST_F(SceneSessionDirtyManagerTest, CheckDragActivatedInUpdatePointerAreas, Function | SmallTest | Level2)
698 {
699 std::vector<int32_t> pointerChangeAreas;
700 SessionInfo info;
701 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
702 sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
703
704 sceneSession->property_->SetDragEnabled(true);
705 sceneSession->SetDragActivated(false);
706 manager_->UpdatePointerAreas(sceneSession, pointerChangeAreas);
707 ASSERT_EQ(0, pointerChangeAreas.size());
708
709 sceneSession->property_->SetDragEnabled(false);
710 sceneSession->SetDragActivated(true);
711 manager_->UpdatePointerAreas(sceneSession, pointerChangeAreas);
712 ASSERT_EQ(0, pointerChangeAreas.size());
713
714 sceneSession->property_->SetDragEnabled(false);
715 sceneSession->SetDragActivated(false);
716 manager_->UpdatePointerAreas(sceneSession, pointerChangeAreas);
717 ASSERT_EQ(0, pointerChangeAreas.size());
718
719 sceneSession->property_->SetDragEnabled(true);
720 sceneSession->SetDragActivated(true);
721 float vpr = 1.5f;
722 sceneSession->property_->SetDisplayId(100);
723 int32_t pointerAreaFivePx = static_cast<int32_t>(POINTER_CHANGE_AREA_FIVE * vpr);
724 WindowLimits limits;
725 limits.maxHeight_ = 1;
726 limits.minHeight_ = 0;
727 limits.maxWidth_ = 0;
728 limits.minWidth_ = 0;
729 sceneSession->property_->SetWindowLimits(limits);
730 manager_->UpdatePointerAreas(sceneSession, pointerChangeAreas);
731 std::vector<int32_t> compare = {POINTER_CHANGE_AREA_DEFAULT, pointerAreaFivePx,
732 POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT,
733 pointerAreaFivePx, POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT};
734 ASSERT_EQ(compare, pointerChangeAreas);
735 }
736
737 /**
738 * @tc.name: GetSecSurfaceWindowinfoList
739 * @tc.desc: GetSecSurfaceWindowinfoList
740 * @tc.type: FUNC
741 */
742 HWTEST_F(SceneSessionDirtyManagerTest, GetSecSurfaceWindowinfoList, Function | SmallTest | Level2)
743 {
744 MMI::WindowInfo hostWindowinfo;
745 SecSurfaceInfo secSurfaceInfo;
746 Matrix3f transform;
747 MMI::WindowInfo windowInfo;
748 auto ret = manager_->GetSecSurfaceWindowinfoList(nullptr, hostWindowinfo, transform);
749 ASSERT_EQ(ret.size(), 0);
750
751 std::vector<SecSurfaceInfo> secSurfaceInfoList;
752 secSurfaceInfoList.emplace_back(secSurfaceInfo);
753 manager_->secSurfaceInfoMap_.emplace(1, secSurfaceInfoList);
754 ret = manager_->GetSecSurfaceWindowinfoList(nullptr, hostWindowinfo, transform);
755 ASSERT_EQ(ret.size(), 0);
756
757 SessionInfo info;
758 info.abilityName_ = "TestAbilityName";
759 info.bundleName_ = "TestBundleName";
760 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
761 ASSERT_NE(sceneSession, nullptr);
762 struct RSSurfaceNodeConfig config;
763 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
764 surfaceNode->id_ = 1;
765 sceneSession->surfaceNode_ = surfaceNode;
766 ret = manager_->GetSecSurfaceWindowinfoList(sceneSession, hostWindowinfo, transform);
767 ASSERT_EQ(ret.size(), 2);
768
769 manager_->secSurfaceInfoMap_.emplace(0, secSurfaceInfoList);
770 ret = manager_->GetSecSurfaceWindowinfoList(sceneSession, hostWindowinfo, transform);
771 ASSERT_EQ(ret.size(), 2);
772
773 manager_->secSurfaceInfoMap_.clear();
774 manager_->secSurfaceInfoMap_.emplace(1, secSurfaceInfoList);
775 ret = manager_->GetSecSurfaceWindowinfoList(sceneSession, hostWindowinfo, transform);
776 ASSERT_EQ(ret.size(), 2);
777
778 sceneSession->surfaceNode_ = nullptr;
779 ret = manager_->GetSecSurfaceWindowinfoList(sceneSession, hostWindowinfo, transform);
780 ASSERT_EQ(ret.size(), 0);
781 }
782
783 /**
784 * @tc.name: UpdateSecSurfaceInfo
785 * @tc.desc: UpdateSecSurfaceInfo
786 * @tc.type: FUNC
787 */
788 HWTEST_F(SceneSessionDirtyManagerTest, UpdateSecSurfaceInfo, Function | SmallTest | Level2)
789 {
790 std::map<uint64_t, std::vector<SecSurfaceInfo>> secSurfaceInfoMap;
791 SecRectInfo secRectInfo1;
792 SecRectInfo secRectInfo2;
793 SecSurfaceInfo secSurfaceInfo1;
794 secSurfaceInfo1.upperNodes.emplace_back(secRectInfo1);
795 SecSurfaceInfo secSurfaceInfo2;
796 secSurfaceInfo2.upperNodes.emplace_back(secRectInfo2);
797 std::vector<SecSurfaceInfo> secSurfaceInfoList1;
798 std::vector<SecSurfaceInfo> secSurfaceInfoList2;
799 secSurfaceInfoList1.emplace_back(secSurfaceInfo1);
800 secSurfaceInfoList2.emplace_back(secSurfaceInfo2);
801 manager_->secSurfaceInfoMap_.emplace(1, secSurfaceInfoList1);
802 secSurfaceInfoMap.emplace(1, secSurfaceInfoList2);
803 manager_->UpdateSecSurfaceInfo(secSurfaceInfoMap);
804 ASSERT_EQ(secSurfaceInfoMap.size(), manager_->secSurfaceInfoMap_.size());
805
806 secSurfaceInfoMap.emplace(2, secSurfaceInfoList2);
807 manager_->UpdateSecSurfaceInfo(secSurfaceInfoMap);
808 ASSERT_EQ(secSurfaceInfoMap.size(), manager_->secSurfaceInfoMap_.size());
809
810 secSurfaceInfoMap.clear();
811 manager_->secSurfaceInfoMap_.clear();
812 secSurfaceInfoList1.clear();
813 secSurfaceInfoList2.clear();
814 secSurfaceInfo1.uiExtensionRectInfo.scale[0] = 1;
815 secSurfaceInfoList1.emplace_back(secSurfaceInfo1);
816 secSurfaceInfoList2.emplace_back(secSurfaceInfo2);
817 secSurfaceInfoMap.emplace(1, secSurfaceInfoList1);
818 manager_->secSurfaceInfoMap_.emplace(1, secSurfaceInfoList2);
819 manager_->UpdateSecSurfaceInfo(secSurfaceInfoMap);
820 ASSERT_EQ(secSurfaceInfoMap.size(), manager_->secSurfaceInfoMap_.size());
821 }
822
823 /**
824 * @tc.name: GetLastConstrainedModalUIExtInfo
825 * @tc.desc: GetLastConstrainedModalUIExtInfo
826 * @tc.type: FUNC
827 */
828 HWTEST_F(SceneSessionDirtyManagerTest, GetLastConstrainedModalUIExtInfo, Function | SmallTest | Level2)
829 {
830 SecSurfaceInfo constrainedModalUIExtInfo;
831 bool ret = manager_->GetLastConstrainedModalUIExtInfo(nullptr, constrainedModalUIExtInfo);
832 ASSERT_EQ(ret, false);
833
834 std::vector<SecSurfaceInfo> surfaceInfoList;
835 SecSurfaceInfo secSurfaceInfo;
836 manager_->constrainedModalUIExtInfoMap_.clear();
837 manager_->constrainedModalUIExtInfoMap_[0] = surfaceInfoList;
838 SessionInfo info;
839 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
840 ret = manager_->GetLastConstrainedModalUIExtInfo(sceneSession, constrainedModalUIExtInfo);
841 ASSERT_EQ(ret, false);
842
843 struct RSSurfaceNodeConfig config;
844 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
845 surfaceNode->SetId(1);
846 sceneSession->surfaceNode_ = surfaceNode;
847 ret = manager_->GetLastConstrainedModalUIExtInfo(sceneSession, constrainedModalUIExtInfo);
848 ASSERT_EQ(ret, false);
849
850 sceneSession->surfaceNode_->SetId(0);
851 ret = manager_->GetLastConstrainedModalUIExtInfo(sceneSession, constrainedModalUIExtInfo);
852 ASSERT_EQ(ret, false);
853
854 manager_->constrainedModalUIExtInfoMap_[0].emplace_back(secSurfaceInfo);
855 ret = manager_->GetLastConstrainedModalUIExtInfo(sceneSession, constrainedModalUIExtInfo);
856 ASSERT_EQ(ret, true);
857 manager_->constrainedModalUIExtInfoMap_.clear();
858 }
859
860 /**
861 * @tc.name: GetModalUIExtensionInfo
862 * @tc.desc: GetModalUIExtensionInfo
863 * @tc.type: FUNC
864 */
865 HWTEST_F(SceneSessionDirtyManagerTest, GetModalUIExtensionInfo, Function | SmallTest | Level2)
866 {
867 std::vector<MMI::WindowInfo> windowInfoList;
868 MMI::WindowInfo windowInfo;
869
870 // normal modal UIExt
871 SessionInfo info;
872 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
873 int len = windowInfoList.size();
874 manager_->GetModalUIExtensionInfo(windowInfoList, sceneSession, windowInfo);
875 ASSERT_EQ(len, windowInfoList.size());
876
877 ExtensionWindowEventInfo extensionInfo;
878 extensionInfo.persistentId = 12345;
879 extensionInfo.pid = 1234;
880 extensionInfo.windowRect = { 1, 2, 3, 4 };
881 sceneSession->AddNormalModalUIExtension(extensionInfo);
882 manager_->GetModalUIExtensionInfo(windowInfoList, sceneSession, windowInfo);
883 ASSERT_EQ(len + 1, windowInfoList.size());
884
885 // constrained modal UIExt
886 struct RSSurfaceNodeConfig config;
887 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
888 surfaceNode->SetId(0);
889 sceneSession->surfaceNode_ = surfaceNode;
890 SecSurfaceInfo secSurfaceInfo;
891 manager_->constrainedModalUIExtInfoMap_.clear();
892 manager_->constrainedModalUIExtInfoMap_[0].emplace_back(secSurfaceInfo);
893 manager_->GetModalUIExtensionInfo(windowInfoList, sceneSession, windowInfo);
894 ASSERT_EQ(len + 2, windowInfoList.size());
895 manager_->constrainedModalUIExtInfoMap_.clear();
896 }
897
898 /**
899 * @tc.name: ResetFlushWindowInfoTask
900 * @tc.desc: ResetFlushWindowInfoTask
901 * @tc.type: FUNC
902 */
903 HWTEST_F(SceneSessionDirtyManagerTest, ResetFlushWindowInfoTask, Function | SmallTest | Level2)
904 {
905 int ret = 0;
906 auto preFlushWindowInfoCallback = manager_->flushWindowInfoCallback_;
907 manager_->flushWindowInfoCallback_ = nullptr;
908 manager_->ResetFlushWindowInfoTask();
909 manager_->flushWindowInfoCallback_ = preFlushWindowInfoCallback;
910 ASSERT_EQ(ret, 0);
911 }
912
913 /**
914 * @tc.name: DumpRect
915 * @tc.desc: DumpRect
916 * @tc.type: FUNC
917 */
918 HWTEST_F(SceneSessionDirtyManagerTest, DumpRect, Function | SmallTest | Level2)
919 {
920 int ret = 0;
921 std::vector<MMI::Rect> rects(0);
922 for (int i = 0; i < 2 ; i++) {
923 MMI::Rect rect = {
924 .x = i * 10,
925 .y = i * 10,
926 .width = i * 10,
927 .height = i * 10
928 };
929 rects.emplace_back(rect);
930 }
931 DumpRect(rects);
932 ASSERT_EQ(ret, 0);
933 }
934
935 /**
936 * @tc.name: GetSingleHandData
937 * @tc.desc: get session data in single hand mode
938 * @tc.type: FUNC
939 */
940 HWTEST_F(SceneSessionDirtyManagerTest, GetSingleHandData, Function | SmallTest | Level2)
941 {
942 SingleHandData testSingleHandData;
943 SessionInfo mainWindowInfo;
944 mainWindowInfo.abilityName_ = "TestMainWithType";
945 mainWindowInfo.bundleName_ = "TestMainWithType";
946 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(mainWindowInfo, nullptr);
947 sceneSession->property_->SetDisplayId(2000);
948 SingleHandData res = manager_->GetSingleHandData(sceneSession);
949 ASSERT_EQ(testSingleHandData.singleHandY, res.singleHandY);
950 sceneSession->property_->SetDisplayId(0);
951 res = manager_->GetSingleHandData(sceneSession);
952 ASSERT_EQ(testSingleHandData.singleHandY, res.singleHandY);
953 }
954 } // namespace
955 } // namespace Rosen
956 } // namespace OHOS
957