1 /*
2 * Copyright (c) 2025 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 <bundle_mgr_interface.h>
17 #include <bundlemgr/launcher_service.h>
18 #include <gtest/gtest.h>
19
20 #include "interfaces/include/ws_common.h"
21 #include "iremote_object_mocker.h"
22 #include "screen_session_manager_client/include/screen_session_manager_client.h"
23 #include "session_manager/include/scene_session_manager.h"
24 #include "session_info.h"
25 #include "session/host/include/scene_session.h"
26
27 using namespace testing;
28 using namespace testing::ext;
29
30 namespace OHOS {
31 namespace Rosen {
32 namespace {
33 const std::string EMPTY_DEVICE_ID = "";
34 constexpr float SINGLE_HAND_SCALE = 0.75f;
35 constexpr float SINGLE_HAND_DEFAULT_SCALE = 1.0f;
36 } // namespace
37 class SceneSessionManagerLayoutTest : public testing::Test {
38 public:
39 static void SetUpTestCase();
40 static void TearDownTestCase();
41 void SetUp() override;
42 void TearDown() override;
43 static sptr<SceneSessionManager> ssm_;
44
45 private:
46 static constexpr uint32_t WAIT_SYNC_IN_NS = 200000;
47 };
48
49 sptr<SceneSessionManager> SceneSessionManagerLayoutTest::ssm_ = nullptr;
50
SetUpTestCase()51 void SceneSessionManagerLayoutTest::SetUpTestCase()
52 {
53 ssm_ = &SceneSessionManager::GetInstance();
54 }
55
TearDownTestCase()56 void SceneSessionManagerLayoutTest::TearDownTestCase()
57 {
58 ssm_ = nullptr;
59 }
60
SetUp()61 void SceneSessionManagerLayoutTest::SetUp()
62 {
63 ssm_->sceneSessionMap_.clear();
64 }
65
TearDown()66 void SceneSessionManagerLayoutTest::TearDown()
67 {
68 usleep(WAIT_SYNC_IN_NS);
69 ssm_->sceneSessionMap_.clear();
70 }
71
72 namespace {
73 /**
74 * @tc.name: GetNormalSingleHandTransform
75 * @tc.desc: test function : GetNormalSingleHandTransform
76 * @tc.type: FUNC
77 */
78 HWTEST_F(SceneSessionManagerLayoutTest, GetNormalSingleHandTransform, TestSize.Level1)
79 {
80 SingleHandTransform preTransform = ssm_->singleHandTransform_;
81 ssm_->singleHandTransform_.posX = 100;
82 EXPECT_EQ(100, ssm_->GetNormalSingleHandTransform().posX);
83 ssm_->singleHandTransform_ = preTransform;
84 }
85
86 /**
87 * @tc.name: NotifySingleHandInfoChange_TestUIType
88 * @tc.desc: test function : NotifySingleHandInfoChange
89 * @tc.type: FUNC
90 */
91 HWTEST_F(SceneSessionManagerLayoutTest, NotifySingleHandInfoChange_TestUIType, TestSize.Level1)
92 {
93 SingleHandTransform singleHandTransform;
94 ssm_->singleHandTransform_ = singleHandTransform;
95 SingleHandScreenInfo singleHandScreenInfo;
96 WSRect originRect, singleHandRect;
97 singleHandScreenInfo.scaleRatio = SINGLE_HAND_SCALE;
98 singleHandScreenInfo.mode = SingleHandMode::LEFT;
99 originRect = { 0, 0, 400, 600 };
100 singleHandRect = { 0, 100, 200, 300 };
101 ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear();
102 sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr();
103 ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(0, screenSession));
104
105 ssm_->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
106 ssm_->NotifySingleHandInfoChange(singleHandScreenInfo, originRect, singleHandRect);
107 usleep(WAIT_SYNC_IN_NS);
108 EXPECT_NE(singleHandScreenInfo.scaleRatio, ssm_->singleHandTransform_.scaleX);
109
110 ssm_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
111 ssm_->NotifySingleHandInfoChange(singleHandScreenInfo, originRect, singleHandRect);
112 usleep(WAIT_SYNC_IN_NS);
113 EXPECT_EQ(singleHandScreenInfo.scaleRatio, ssm_->singleHandTransform_.scaleX);
114 ssm_->singleHandTransform_ = singleHandTransform;
115 }
116
117 /**
118 * @tc.name: NotifySingleHandInfoChange_TestWindowName
119 * @tc.desc: test function : NotifySingleHandInfoChange
120 * @tc.type: FUNC
121 */
122 HWTEST_F(SceneSessionManagerLayoutTest, NotifySingleHandInfoChange_TestWindowName, TestSize.Level1)
123 {
124 SingleHandTransform singleHandTransform;
125 ssm_->singleHandTransform_ = singleHandTransform;
126 SessionInfo sessionInfo;
127 sessionInfo.bundleName_ = "OneHandModeBackground_testWindow";
128 sessionInfo.abilityName_ = "OneHandModeBackground_testWindow";
129 sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
130 EXPECT_NE(sceneSession, nullptr);
131 sceneSession->property_->SetWindowName("OneHandModeBackground_testWindow");
132 ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession });
133 ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear();
134 sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr();
135 ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(0, screenSession));
136 SingleHandScreenInfo singleHandScreenInfo;
137 WSRect originRect, singleHandRect;
138 originRect = { 0, 0, 400, 600 };
139 singleHandRect = { 0, 100, 200, 300 };
140 singleHandScreenInfo.scaleRatio = SINGLE_HAND_SCALE;
141 singleHandScreenInfo.mode = SingleHandMode::LEFT;
142 ssm_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
143 ssm_->NotifySingleHandInfoChange(singleHandScreenInfo, originRect, singleHandRect);
144 usleep(WAIT_SYNC_IN_NS);
145 EXPECT_NE(singleHandScreenInfo.scaleRatio, sceneSession->singleHandTransform_.scaleX);
146 }
147
148 /**
149 * @tc.name: NotifySingleHandInfoChange_TestDisplayId
150 * @tc.desc: test function : NotifySingleHandInfoChange
151 * @tc.type: FUNC
152 */
153 HWTEST_F(SceneSessionManagerLayoutTest, NotifySingleHandInfoChange_TestDisplayId, TestSize.Level1)
154 {
155 SingleHandTransform singleHandTransform;
156 ssm_->singleHandTransform_ = singleHandTransform;
157 SingleHandScreenInfo singleHandScreenInfo;
158 WSRect originRect, singleHandRect;
159 originRect = { 0, 0, 400, 600 };
160 singleHandRect = { 0, 100, 200, 300 };
161 singleHandScreenInfo.scaleRatio = SINGLE_HAND_SCALE;
162 singleHandScreenInfo.mode = SingleHandMode::LEFT;
163 ssm_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
164 ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear();
165 sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr();
166 ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(0, screenSession));
167 SessionInfo sessionInfo;
168 sessionInfo.bundleName_ = "NotifySingleHandInfoChange_TestDisplayId";
169 sessionInfo.abilityName_ = "NotifySingleHandInfoChange_TestDisplayId";
170 sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
171 EXPECT_NE(sceneSession, nullptr);
172
173 sceneSession->GetSessionProperty()->SetDisplayId(2025);
174 ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession });
175 ssm_->NotifySingleHandInfoChange(singleHandScreenInfo, originRect, singleHandRect);
176 usleep(WAIT_SYNC_IN_NS);
177 EXPECT_NE(singleHandScreenInfo.scaleRatio, sceneSession->singleHandTransform_.scaleX);
178
179 sceneSession->GetSessionProperty()->SetDisplayId(0);
180 ssm_->NotifySingleHandInfoChange(singleHandScreenInfo, originRect, singleHandRect);
181 usleep(WAIT_SYNC_IN_NS);
182 EXPECT_EQ(singleHandScreenInfo.scaleRatio, sceneSession->singleHandTransform_.scaleY);
183 ssm_->singleHandTransform_ = singleHandTransform;
184 }
185
186 /**
187 * @tc.name: NotifySingleHandInfoChange_TestMode
188 * @tc.desc: test function : NotifySingleHandInfoChange
189 * @tc.type: FUNC
190 */
191 HWTEST_F(SceneSessionManagerLayoutTest, NotifySingleHandInfoChange_TestMode, TestSize.Level1)
192 {
193 SingleHandTransform singleHandTransform;
194 ssm_->singleHandTransform_ = singleHandTransform;
195 ssm_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
196 ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear();
197 sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr();
198 ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(0, screenSession));
199
200 SingleHandScreenInfo singleHandScreenInfo;
201 WSRect originRect, singleHandRect;
202 originRect = { 0, 0, 400, 600 };
203 singleHandRect = { 0, 100, 200, 300 };
204 singleHandScreenInfo.scaleRatio = SINGLE_HAND_SCALE;
205 singleHandScreenInfo.mode = SingleHandMode::LEFT;
206 ssm_->NotifySingleHandInfoChange(singleHandScreenInfo, originRect, singleHandRect);
207 usleep(WAIT_SYNC_IN_NS);
208 EXPECT_EQ(100, ssm_->singleHandTransform_.posY);
209 EXPECT_EQ(0, ssm_->singleHandTransform_.posX);
210 ssm_->singleHandTransform_ = singleHandTransform;
211
212 singleHandScreenInfo.mode = SingleHandMode::RIGHT;
213 singleHandRect = { 50, 100, 200, 300 };
214 ssm_->NotifySingleHandInfoChange(singleHandScreenInfo, originRect, singleHandRect);
215 usleep(WAIT_SYNC_IN_NS);
216 EXPECT_EQ(100, ssm_->singleHandTransform_.posY);
217 EXPECT_EQ(50, ssm_->singleHandTransform_.posX);
218 ssm_->singleHandTransform_ = singleHandTransform;
219
220 singleHandScreenInfo.scaleRatio = SINGLE_HAND_DEFAULT_SCALE;
221 singleHandScreenInfo.mode = SingleHandMode::MIDDLE;
222 singleHandRect = { 0, 0, 200, 300 };
223 ssm_->NotifySingleHandInfoChange(singleHandScreenInfo, originRect, singleHandRect);
224 usleep(WAIT_SYNC_IN_NS);
225 EXPECT_EQ(0, ssm_->singleHandTransform_.posY);
226 EXPECT_EQ(0, ssm_->singleHandTransform_.posX);
227 ssm_->singleHandTransform_ = singleHandTransform;
228 }
229
230 /**
231 * @tc.name: SetHasRootSceneRequestedVsyncFunc
232 * @tc.desc: SetHasRootSceneRequestedVsyncFunc
233 * @tc.type: FUNC
234 */
235 HWTEST_F(SceneSessionManagerLayoutTest, SetHasRootSceneRequestedVsyncFunc, TestSize.Level1)
236 {
237 ssm_->SetHasRootSceneRequestedVsyncFunc(nullptr);
238 ASSERT_EQ(nullptr, ssm_->hasRootSceneRequestedVsyncFunc_);
__anon6e4fa7900302null239 ssm_->SetHasRootSceneRequestedVsyncFunc([] {
240 bool tempBool = false;
241 return tempBool;
242 });
243 ASSERT_NE(nullptr, ssm_->hasRootSceneRequestedVsyncFunc_);
244 }
245
246 /**
247 * @tc.name: HasRootSceneRequestedVsync
248 * @tc.desc: HasRootSceneRequestedVsync
249 * @tc.type: FUNC
250 */
251 HWTEST_F(SceneSessionManagerLayoutTest, HasRootSceneRequestedVsync, TestSize.Level1)
252 {
253 bool tempBool = false;
254 ssm_->hasRootSceneRequestedVsyncFunc_ = nullptr;
255 EXPECT_EQ(WSError::WS_ERROR_NULLPTR, ssm_->HasRootSceneRequestedVsync(tempBool));
256 EXPECT_EQ(false, tempBool);
257
__anon6e4fa7900402null258 ssm_->SetHasRootSceneRequestedVsyncFunc([] {
259 bool tempInnerBool = true;
260 return tempInnerBool;
261 });
262 EXPECT_EQ(WSError::WS_OK, ssm_->HasRootSceneRequestedVsync(tempBool));
263 EXPECT_EQ(true, tempBool);
264 }
265
266 /**
267 * @tc.name: SetRequestVsyncByRootSceneWhenModeChangeFunc
268 * @tc.desc: SetRequestVsyncByRootSceneWhenModeChangeFunc
269 * @tc.type: FUNC
270 */
271 HWTEST_F(SceneSessionManagerLayoutTest, SetRequestVsyncByRootSceneWhenModeChangeFunc, TestSize.Level1)
272 {
273 ssm_->SetRequestVsyncByRootSceneWhenModeChangeFunc(nullptr);
274 ASSERT_EQ(nullptr, ssm_->requestVsyncByRootSceneWhenModeChangeFunc_);
__anon6e4fa7900502(const std::shared_ptr<VsyncCallback>& vsyncCallback) 275 ssm_->SetRequestVsyncByRootSceneWhenModeChangeFunc([](const std::shared_ptr<VsyncCallback>& vsyncCallback) {
276 auto tempCallback = vsyncCallback;
277 });
278 ASSERT_NE(nullptr, ssm_->requestVsyncByRootSceneWhenModeChangeFunc_);
279 }
280
281 /**
282 * @tc.name: RequestVsyncByRootSceneWhenModeChange
283 * @tc.desc: RequestVsyncByRootSceneWhenModeChange
284 * @tc.type: FUNC
285 */
286 HWTEST_F(SceneSessionManagerLayoutTest, RequestVsyncByRootSceneWhenModeChange, TestSize.Level1)
287 {
288 std::shared_ptr<VsyncCallback> nextVsyncCallback = std::make_shared<VsyncCallback>();
289 ssm_->requestVsyncByRootSceneWhenModeChangeFunc_ = nullptr;
290 EXPECT_EQ(WSError::WS_ERROR_NULLPTR, ssm_->RequestVsyncByRootSceneWhenModeChange(nextVsyncCallback));
__anon6e4fa7900602(const std::shared_ptr<VsyncCallback>& vsyncCallback) 291 ssm_->SetRequestVsyncByRootSceneWhenModeChangeFunc([](const std::shared_ptr<VsyncCallback>& vsyncCallback) {
292 auto tempCallback = vsyncCallback;
293 });
294 EXPECT_EQ(WSError::WS_OK, ssm_->RequestVsyncByRootSceneWhenModeChange(nextVsyncCallback));
295 }
296
297 /**
298 * @tc.name: GetDisplaySizeById_TestDisplayId
299 * @tc.desc: test function : GetDisplaySizeById
300 * @tc.type: FUNC
301 */
302 HWTEST_F(SceneSessionManagerLayoutTest, GetDisplaySizeById_TestDisplayId, TestSize.Level1)
303 {
304 DisplayId displayId = 2025;
305 int32_t displayWidth = 0;
306 int32_t displayHeight = 0;
307 EXPECT_EQ(false, ssm_->GetDisplaySizeById(displayId, displayWidth, displayHeight));
308
309 displayId = 0;
310 EXPECT_EQ(true, ssm_->GetDisplaySizeById(displayId, displayWidth, displayHeight));
311 }
312
313 /**
314 * @tc.name: UpdateWindowModeByIdForUITest01
315 * @tc.desc: test function : UpdateWindowModeByIdForUITest
316 * @tc.type: FUNC
317 */
318 HWTEST_F(SceneSessionManagerLayoutTest, UpdateWindowModeByIdForUITest01, TestSize.Level1)
319 {
320 const int32_t windowId = 0;
321 const int32_t updateMode = 1;
322 EXPECT_EQ(ssm_->UpdateWindowModeByIdForUITest(windowId, updateMode), WMError::WM_ERROR_INVALID_PERMISSION);
323 }
324
325 /**
326 * @tc.name: GetAppHookWindowInfo
327 * @tc.desc: test function : GetAppHookWindowInfo
328 * @tc.type: FUNC
329 */
330 HWTEST_F(SceneSessionManagerLayoutTest, GetAppHookWindowInfo, TestSize.Level1)
331 {
332 ASSERT_TRUE(ssm_ != nullptr);
333
334 // Case 1: empty bundleName
335 std::string bundleName = "";
336 HookWindowInfo hookWindowInfo = ssm_->GetAppHookWindowInfo(bundleName);
337 EXPECT_EQ(hookWindowInfo.enableHookWindow, false);
338
339 // Case 2: bundleName not found
340 bundleName = "GetAppHookWindowInfo_Test";
341 hookWindowInfo = ssm_->GetAppHookWindowInfo(bundleName);
342 EXPECT_EQ(hookWindowInfo.enableHookWindow, false);
343
344 // Case 3: success
345 HookWindowInfo hookWindowInfo2;
346 hookWindowInfo2.enableHookWindow = true;
347 hookWindowInfo2.widthHookRatio = 0.5f;
348 ssm_->appHookWindowInfoMap_[bundleName] = hookWindowInfo2;
349 hookWindowInfo = ssm_->GetAppHookWindowInfo(bundleName);
350 EXPECT_EQ(hookWindowInfo.enableHookWindow, true);
351 }
352
353 /**
354 * @tc.name: UpdateAppHookWindowInfo
355 * @tc.desc: test function : UpdateAppHookWindowInfo
356 * @tc.type: FUNC
357 */
358 HWTEST_F(SceneSessionManagerLayoutTest, UpdateAppHookWindowInfo, TestSize.Level1)
359 {
360 ASSERT_TRUE(ssm_ != nullptr);
361
362 // Case 1: empty bundleName
363 std::string bundleName = "";
364 HookWindowInfo hookWindowInfo;
365 WMError errCode = ssm_->UpdateAppHookWindowInfo(bundleName, hookWindowInfo);
366 EXPECT_EQ(errCode, WMError::WM_ERROR_NULLPTR);
367
368 // Case 2: Invalid hook window parameters
369 bundleName = "UpdateAppHookWindowInfo_Test";
370 hookWindowInfo.widthHookRatio = -0.5f;
371 errCode = ssm_->UpdateAppHookWindowInfo(bundleName, hookWindowInfo);
372 EXPECT_EQ(errCode, WMError::WM_ERROR_INVALID_PARAM);
373
374 // Case 3: not found session
375 hookWindowInfo.enableHookWindow = true;
376 hookWindowInfo.widthHookRatio = 0.5f;
377 ssm_->sceneSessionMap_.insert({ 999, nullptr });
378 errCode = ssm_->UpdateAppHookWindowInfo(bundleName, hookWindowInfo);
379 EXPECT_EQ(errCode, WMError::WM_OK);
380 ssm_->appHookWindowInfoMap_.clear();
381
382 // Case 4: bundleName not found
383 SessionInfo sessionInfo;
384 sessionInfo.bundleName_ = bundleName;
385 sessionInfo.abilityName_ = bundleName;
386 sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
387 sceneSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
388 ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession });
389 errCode = ssm_->UpdateAppHookWindowInfo("randomBundleName", hookWindowInfo);
390 EXPECT_EQ(errCode, WMError::WM_OK);
391 ssm_->appHookWindowInfoMap_.clear();
392
393 // Case 5: success
394 errCode = ssm_->UpdateAppHookWindowInfo(bundleName, hookWindowInfo);
395 EXPECT_EQ(errCode, WMError::WM_OK);
396 EXPECT_NE(0, ssm_->appHookWindowInfoMap_.count(bundleName));
397
398 // Case 6: Repeat update
399 errCode = ssm_->UpdateAppHookWindowInfo(bundleName, hookWindowInfo);
400 EXPECT_EQ(errCode, WMError::WM_OK);
401 EXPECT_NE(0, ssm_->appHookWindowInfoMap_.count(bundleName));
402 }
403
404 /**
405 * @tc.name: UpdateAppHookWindowInfoWhenSwitchFreeMultiWindow
406 * @tc.desc: test function : UpdateAppHookWindowInfoWhenSwitchFreeMultiWindow
407 * @tc.type: FUNC
408 */
409 HWTEST_F(SceneSessionManagerLayoutTest, UpdateAppHookWindowInfoWhenSwitchFreeMultiWindow, TestSize.Level1)
410 {
411 ASSERT_TRUE(ssm_ != nullptr);
412 std::string bundleName = "UpdateAppHookWindowInfoWhenSwitchFreeMultiWindow_Test";
413 SessionInfo sessionInfo;
414 sessionInfo.bundleName_ = bundleName;
415 sessionInfo.abilityName_ = bundleName;
416 sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
417 sceneSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
418 ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession });
419 ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId() + 1, nullptr });
420 HookWindowInfo hookWindowInfo;
421 hookWindowInfo.enableHookWindow = true;
422 hookWindowInfo.widthHookRatio = 0.5f;
423 ssm_->appHookWindowInfoMap_[bundleName] = hookWindowInfo;
424
425 // Case 1: open freeMultiWindow
426 ssm_->UpdateAppHookWindowInfoWhenSwitchFreeMultiWindow(true);
427 EXPECT_EQ(ssm_->appHookWindowInfoMap_[bundleName].enableHookWindow, false);
428
429 // Case 2: close freeMultiWindow
430 ssm_->UpdateAppHookWindowInfoWhenSwitchFreeMultiWindow(false);
431 EXPECT_EQ(ssm_->appHookWindowInfoMap_[bundleName].enableHookWindow, true);
432 }
433
434 /**
435 * @tc.name: GetAllWindowLayoutInfo
436 * @tc.desc: test function : GetAllWindowLayoutInfo
437 * @tc.type: FUNC
438 */
439 HWTEST_F(SceneSessionManagerLayoutTest, GetAllWindowLayoutInfo, TestSize.Level1)
440 {
441 ASSERT_TRUE(ssm_ != nullptr);
442 std::string bundleName = "GetAllWindowLayoutInfo_Test";
443 SessionInfo sessionInfo;
444 sessionInfo.bundleName_ = bundleName;
445 sessionInfo.abilityName_ = bundleName;
446 sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
447 sceneSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
448 constexpr DisplayId TEST_DISPLAY_ID = 200;
449 sceneSession->GetSessionProperty()->SetDisplayId(TEST_DISPLAY_ID);
450 sceneSession->SetVisibilityState(WINDOW_VISIBILITY_STATE_NO_OCCLUSION);
451 sceneSession->SetSessionGlobalRect({ 0, 0, 800, 800 });
452 ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession });
453 HookWindowInfo hookWindowInfo;
454 hookWindowInfo.enableHookWindow = true;
455 hookWindowInfo.widthHookRatio = 1.0f;
456 ssm_->appHookWindowInfoMap_[bundleName] = hookWindowInfo;
457
458 std::vector<sptr<WindowLayoutInfo>> info;
459 ssm_->GetAllWindowLayoutInfo(TEST_DISPLAY_ID, info);
460 ASSERT_NE(info.size(), 0);
461 EXPECT_EQ(800, info[0]->rect.width_);
462
463 hookWindowInfo.widthHookRatio = 0.5f;
464 ssm_->appHookWindowInfoMap_[bundleName] = hookWindowInfo;
465 info.clear();
466 ssm_->GetAllWindowLayoutInfo(TEST_DISPLAY_ID, info);
467 ASSERT_NE(info.size(), 0);
468 EXPECT_NE(800, info[0]->rect.width_);
469 }
470 } // namespace
471 } // namespace Rosen
472 } // namespace OHOS
473