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
16 #include <gtest/gtest.h>
17 #include <regex>
18 #include <bundle_mgr_interface.h>
19 #include <bundlemgr/launcher_service.h>
20 #include "interfaces/include/ws_common.h"
21 #include "iremote_object_mocker.h"
22 #include "screen_fold_data.h"
23 #include "session_manager/include/scene_session_manager.h"
24 #include "session_info.h"
25 #include "session/host/include/scene_session.h"
26 #include "session/host/include/main_session.h"
27 #include "window_manager_agent.h"
28 #include "session_manager.h"
29 #include "zidl/window_manager_agent_interface.h"
30 #include "mock/mock_session_stage.h"
31 #include "mock/mock_window_event_channel.h"
32 #include "application_info.h"
33 #include "context.h"
34
35 using namespace testing;
36 using namespace testing::ext;
37
38 namespace OHOS {
39 namespace Rosen {
40 namespace {
41 const std::string EMPTY_DEVICE_ID = "";
42 }
43 class SceneSessionManagerTest : public testing::Test {
44 public:
45 static void SetUpTestCase();
46
47 static void TearDownTestCase();
48
49 void SetUp() override;
50
51 void TearDown() override;
52
53 static void SetVisibleForAccessibility(sptr<SceneSession>& sceneSession);
54 int32_t GetTaskCount(sptr<SceneSession>& session);
55 static sptr<SceneSessionManager> ssm_;
56 private:
57 static constexpr uint32_t WAIT_SYNC_IN_NS = 200000;
58 };
59
60 sptr<SceneSessionManager> SceneSessionManagerTest::ssm_ = nullptr;
61
WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type)62 void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type)
63 {
64 }
65
ProcessStatusBarEnabledChangeFuncTest(bool enable)66 void ProcessStatusBarEnabledChangeFuncTest(bool enable)
67 {
68 }
69
DumpRootSceneElementInfoFuncTest(const std::vector<std::string>& params, std::vector<std::string>& infos)70 void DumpRootSceneElementInfoFuncTest(const std::vector<std::string>& params, std::vector<std::string>& infos)
71 {
72 }
73
SetUpTestCase()74 void SceneSessionManagerTest::SetUpTestCase()
75 {
76 ssm_ = &SceneSessionManager::GetInstance();
77 }
78
TearDownTestCase()79 void SceneSessionManagerTest::TearDownTestCase()
80 {
81 ssm_ = nullptr;
82 }
83
SetUp()84 void SceneSessionManagerTest::SetUp()
85 {
86 ssm_->sceneSessionMap_.clear();
87 }
88
TearDown()89 void SceneSessionManagerTest::TearDown()
90 {
91 usleep(WAIT_SYNC_IN_NS);
92 ssm_->sceneSessionMap_.clear();
93 }
94
SetVisibleForAccessibility(sptr<SceneSession>& sceneSession)95 void SceneSessionManagerTest::SetVisibleForAccessibility(sptr<SceneSession>& sceneSession)
96 {
97 sceneSession->SetTouchable(true);
98 sceneSession->forceTouchable_ = true;
99 sceneSession->systemTouchable_ = true;
100 sceneSession->state_ = SessionState::STATE_FOREGROUND;
101 sceneSession->foregroundInteractiveStatus_.store(true);
102 sceneSession->isVisible_ = true;
103 }
104
GetTaskCount(sptr<SceneSession>& session)105 int32_t SceneSessionManagerTest::GetTaskCount(sptr<SceneSession>& session)
106 {
107 std::string dumpInfo = session->handler_->GetEventRunner()->GetEventQueue()->DumpCurrentQueueSize();
108 std::regex pattern("\\d+");
109 std::smatch matches;
110 int32_t taskNum = 0;
111 while (std::regex_search(dumpInfo, matches, pattern)) {
112 taskNum += std::stoi(matches.str());
113 dumpInfo = matches.suffix();
114 }
115 return taskNum;
116 }
117
118 namespace {
119 /**
120 * @tc.name: SetBrightness
121 * @tc.desc: ScreenSesionManager set session brightness
122 * @tc.type: FUNC
123 */
HWTEST_F(SceneSessionManagerTest, SetBrightness, Function | SmallTest | Level3)124 HWTEST_F(SceneSessionManagerTest, SetBrightness, Function | SmallTest | Level3)
125 {
126 SessionInfo info;
127 info.abilityName_ = "SetBrightness";
128 info.bundleName_ = "SetBrightness1";
129 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
130 ASSERT_NE(nullptr, sceneSession);
131 float brightness = 0.5;
132 WSError result = ssm_->SetBrightness(sceneSession, brightness);
133 ASSERT_EQ(result, WSError::WS_OK);
134 ASSERT_NE(brightness, ssm_->GetDisplayBrightness());
135 }
136
137 /**
138 * @tc.name: GerPrivacyBundleListTwoWindow
139 * @tc.desc: get privacy bundle list when two windows exist.
140 * @tc.type: FUNC
141 */
HWTEST_F(SceneSessionManagerTest, GerPrivacyBundleListTwoWindow, Function | SmallTest | Level3)142 HWTEST_F(SceneSessionManagerTest, GerPrivacyBundleListTwoWindow, Function | SmallTest | Level3)
143 {
144 SessionInfo sessionInfoFirst;
145 sessionInfoFirst.bundleName_ = "privacy.test.first";
146 sessionInfoFirst.abilityName_ = "privacyAbilityName";
147 sptr<SceneSession> sceneSessionFirst = ssm_->CreateSceneSession(sessionInfoFirst, nullptr);
148 ASSERT_NE(sceneSessionFirst, nullptr);
149 ssm_->sceneSessionMap_.insert({sceneSessionFirst->GetPersistentId(), sceneSessionFirst});
150
151 SessionInfo sessionInfoSecond;
152 sessionInfoSecond.bundleName_ = "privacy.test.second";
153 sessionInfoSecond.abilityName_ = "privacyAbilityName";
154 sptr<SceneSession> sceneSessionSecond = ssm_->CreateSceneSession(sessionInfoSecond, nullptr);
155 ASSERT_NE(sceneSessionSecond, nullptr);
156 ssm_->sceneSessionMap_.insert({sceneSessionSecond->GetPersistentId(), sceneSessionSecond});
157
158 sceneSessionFirst->GetSessionProperty()->displayId_ = 0;
159 sceneSessionFirst->GetSessionProperty()->isPrivacyMode_ = true;
160 sceneSessionFirst->state_ = SessionState::STATE_FOREGROUND;
161
162 sceneSessionSecond->GetSessionProperty()->displayId_ = 0;
163 sceneSessionSecond->GetSessionProperty()->isPrivacyMode_ = true;
164 sceneSessionSecond->state_ = SessionState::STATE_FOREGROUND;
165
166 std::unordered_set<std::string> privacyBundleList;
167 ssm_->GetSceneSessionPrivacyModeBundles(0, privacyBundleList);
168 EXPECT_EQ(privacyBundleList.size(), 2);
169
170 sceneSessionSecond->GetSessionProperty()->displayId_ = 1;
171 privacyBundleList.clear();
172 ssm_->GetSceneSessionPrivacyModeBundles(0, privacyBundleList);
173 EXPECT_EQ(privacyBundleList.size(), 1);
174
175 privacyBundleList.clear();
176 ssm_->GetSceneSessionPrivacyModeBundles(1, privacyBundleList);
177 EXPECT_EQ(privacyBundleList.size(), 1);
178 }
179
180 /**
181 * @tc.name: SetWindowFlags
182 * @tc.desc: SceneSesionManager set window flags
183 * @tc.type: FUNC
184 */
HWTEST_F(SceneSessionManagerTest, SetWindowFlags, Function | SmallTest | Level3)185 HWTEST_F(SceneSessionManagerTest, SetWindowFlags, Function | SmallTest | Level3)
186 {
187 SessionInfo info;
188 info.bundleName_ = "bundleName";
189 sptr<WindowSessionProperty> property = new WindowSessionProperty();
190 uint32_t flags = static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_SHOW_WHEN_LOCKED);
191 property->SetWindowFlags(flags);
192 sptr<SceneSession> scensession = nullptr;
193 WSError result01 = ssm_->SetWindowFlags(scensession, property);
194 EXPECT_EQ(result01, WSError::WS_ERROR_NULLPTR);
195 scensession = new (std::nothrow) SceneSession(info, nullptr);
196 WSError result02 = ssm_->SetWindowFlags(scensession, property);
197 EXPECT_EQ(result02, WSError::WS_ERROR_NOT_SYSTEM_APP);
198 property->SetSystemCalling(true);
199 WSError result03 = ssm_->SetWindowFlags(scensession, property);
200 ASSERT_EQ(result03, WSError::WS_OK);
201 }
202
203 /**
204 * @tc.name: NotifyWaterMarkFlagChangedResult
205 * @tc.desc: SceneSesionManager notify water mark flag changed result
206 * @tc.type: FUNC
207 */
HWTEST_F(SceneSessionManagerTest, NotifyWaterMarkFlagChangedResult, Function | SmallTest | Level3)208 HWTEST_F(SceneSessionManagerTest, NotifyWaterMarkFlagChangedResult, Function | SmallTest | Level3)
209 {
210 int32_t persistentId = 10086;
211 ssm_->NotifyCompleteFirstFrameDrawing(persistentId);
212 bool hasWaterMark = true;
213 AppExecFwk::AbilityInfo abilityInfo;
214 WSError result01 = ssm_->NotifyWaterMarkFlagChangedResult(hasWaterMark);
215 EXPECT_EQ(result01, WSError::WS_OK);
216 ssm_->CheckAndNotifyWaterMarkChangedResult();
217 ssm_->ProcessPreload(abilityInfo);
218 }
219
220 /**
221 * @tc.name: IsValidSessionIds
222 * @tc.desc: SceneSesionManager is valid session id
223 * @tc.type: FUNC
224 */
HWTEST_F(SceneSessionManagerTest, IsValidSessionIds, Function | SmallTest | Level3)225 HWTEST_F(SceneSessionManagerTest, IsValidSessionIds, Function | SmallTest | Level3)
226 {
227 std::vector<int32_t> sessionIds = {0, 1, 2, 3, 4, 5, 24, 10086};
228 std::vector<bool> results = {};
229 WSError result = ssm_->IsValidSessionIds(sessionIds, results);
230 EXPECT_EQ(result, WSError::WS_OK);
231 }
232
233 /**
234 * @tc.name: UnRegisterSessionListener
235 * @tc.desc: SceneSesionManager un register session listener
236 * @tc.type: FUNC
237 */
HWTEST_F(SceneSessionManagerTest, UnRegisterSessionListener, Function | SmallTest | Level3)238 HWTEST_F(SceneSessionManagerTest, UnRegisterSessionListener, Function | SmallTest | Level3)
239 {
240 OHOS::MessageParcel data;
241 sptr<ISessionListener> listener = iface_cast<ISessionListener>(data.ReadRemoteObject());
242 WSError result = ssm_->UnRegisterSessionListener(listener);
243 EXPECT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
244 }
245
246 /**
247 * @tc.name: GetSessionInfos
248 * @tc.desc: SceneSesionManager get session infos
249 * @tc.type: FUNC
250 */
HWTEST_F(SceneSessionManagerTest, GetSessionInfos, Function | SmallTest | Level3)251 HWTEST_F(SceneSessionManagerTest, GetSessionInfos, Function | SmallTest | Level3)
252 {
253 std::string deviceId = "1245";
254 int32_t numMax = 1024;
255 AAFwk::MissionInfo infoFrist;
256 infoFrist.label = "fristBundleName";
257 AAFwk::MissionInfo infoSecond;
258 infoSecond.label = "secondBundleName";
259 std::vector<SessionInfoBean> sessionInfos = {infoFrist, infoSecond};
260 WSError result = ssm_->GetSessionInfos(deviceId, numMax, sessionInfos);
261 EXPECT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
262 int32_t persistentId = 24;
263 SessionInfoBean sessionInfo;
264 int result01 = ssm_->GetRemoteSessionInfo(deviceId, persistentId, sessionInfo);
265 ASSERT_NE(result01, ERR_OK);
266 }
267
268 /**
269 * @tc.name: GetMainWindowStatesByPid
270 * @tc.desc: SceneSesionManager get main window states
271 * @tc.type: FUNC
272 */
HWTEST_F(SceneSessionManagerTest, GetMainWindowStatesByPid, Function | SmallTest | Level3)273 HWTEST_F(SceneSessionManagerTest, GetMainWindowStatesByPid, Function | SmallTest | Level3)
274 {
275 int32_t pid = 100;
276 std::vector<MainWindowState> windowStates;
277 WSError result = ssm_->GetMainWindowStatesByPid(pid, windowStates);
278 EXPECT_EQ(result, WSError::WS_OK);
279 }
280
281 /**
282 * @tc.name: CheckIsRemote01
283 * @tc.desc: DeviceId is empty
284 * @tc.type: FUNC
285 */
HWTEST_F(SceneSessionManagerTest, CheckIsRemote01, Function | SmallTest | Level3)286 HWTEST_F(SceneSessionManagerTest, CheckIsRemote01, Function | SmallTest | Level3)
287 {
288 std::string deviceId;
289 EXPECT_EQ(deviceId.empty(), true);
290 bool result = ssm_->CheckIsRemote(deviceId);
291 EXPECT_FALSE(result);
292 }
293
294 /**
295 * @tc.name: CheckIsRemote02
296 * @tc.desc: SceneSesionManager check is remote
297 * @tc.type: FUNC
298 */
HWTEST_F(SceneSessionManagerTest, CheckIsRemote02, Function | SmallTest | Level3)299 HWTEST_F(SceneSessionManagerTest, CheckIsRemote02, Function | SmallTest | Level3)
300 {
301 std::string deviceId = "abc";
302 EXPECT_EQ(deviceId.empty(), false);
303 bool result = ssm_->CheckIsRemote(deviceId);
304 EXPECT_FALSE(result);
305 }
306
307 /**
308 * @tc.name: AnonymizeDeviceId
309 * @tc.desc: SceneSesionManager anonymize deviceId
310 * @tc.type: FUNC
311 */
HWTEST_F(SceneSessionManagerTest, AnonymizeDeviceId, Function | SmallTest | Level3)312 HWTEST_F(SceneSessionManagerTest, AnonymizeDeviceId, Function | SmallTest | Level3)
313 {
314 std::string deviceId;
315 std::string result(ssm_->AnonymizeDeviceId(deviceId));
316 EXPECT_EQ(result, EMPTY_DEVICE_ID);
317 deviceId.assign("100964857");
318 std::string result01 = "100964******";
319 ASSERT_EQ(ssm_->AnonymizeDeviceId(deviceId), result01);
320 }
321
322 /**
323 * @tc.name: TerminateSessionNew
324 * @tc.desc: SceneSesionManager terminate session new
325 * @tc.type: FUNC
326 */
HWTEST_F(SceneSessionManagerTest, TerminateSessionNew, Function | SmallTest | Level3)327 HWTEST_F(SceneSessionManagerTest, TerminateSessionNew, Function | SmallTest | Level3)
328 {
329 sptr<AAFwk::SessionInfo> info = nullptr;
330 bool needStartCaller = true;
331 WSError result01 = ssm_->TerminateSessionNew(info, needStartCaller);
332 EXPECT_EQ(WSError::WS_ERROR_INVALID_PARAM, result01);
333 info = new (std::nothrow) AAFwk::SessionInfo();
334 WSError result02 = ssm_->TerminateSessionNew(info, needStartCaller);
335 EXPECT_EQ(WSError::WS_ERROR_INVALID_PARAM, result02);
336 }
337
338 /**
339 * @tc.name: RegisterSessionListener01
340 * @tc.desc: SceneSesionManager register session listener
341 * @tc.type: FUNC
342 */
HWTEST_F(SceneSessionManagerTest, RegisterSessionListener01, Function | SmallTest | Level3)343 HWTEST_F(SceneSessionManagerTest, RegisterSessionListener01, Function | SmallTest | Level3)
344 {
345 OHOS::MessageParcel data;
346 sptr<ISessionListener> listener = iface_cast<ISessionListener>(data.ReadRemoteObject());
347 WSError result = ssm_->RegisterSessionListener(listener);
348 EXPECT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
349 }
350
351 /**
352 * @tc.name: ClearDisplayStatusBarTemporarilyFlags
353 * @tc.desc: check ClearDisplayStatusBarTemporarilyFlags
354 * @tc.type: FUNC
355 */
HWTEST_F(SceneSessionManagerTest, ClearDisplayStatusBarTemporarilyFlags, Function | SmallTest | Level3)356 HWTEST_F(SceneSessionManagerTest, ClearDisplayStatusBarTemporarilyFlags, Function | SmallTest | Level3)
357 {
358 SessionInfo sessionInfo;
359 sessionInfo.bundleName_ = "ClearDisplayStatusBarTemporarilyFlags";
360 sessionInfo.abilityName_ = "ClearDisplayStatusBarTemporarilyFlags";
361 sessionInfo.windowType_ = static_cast<uint32_t>(WindowType::APP_MAIN_WINDOW_BASE);
362 sptr<SceneSession> sceneSession = ssm_->RequestSceneSession(sessionInfo, nullptr);
363 ASSERT_NE(nullptr, sceneSession);
364 sceneSession->SetIsDisplayStatusBarTemporarily(true);
365 ASSERT_EQ(true, sceneSession->GetIsDisplayStatusBarTemporarily());
366 ssm_->ClearDisplayStatusBarTemporarilyFlags();
367 ASSERT_EQ(true, sceneSession->GetIsDisplayStatusBarTemporarily());
368 }
369
370 /**
371 * @tc.name: RequestSceneSessionByCall
372 * @tc.desc: SceneSesionManager request scene session by call
373 * @tc.type: FUNC
374 */
HWTEST_F(SceneSessionManagerTest, RequestSceneSessionByCall, Function | SmallTest | Level3)375 HWTEST_F(SceneSessionManagerTest, RequestSceneSessionByCall, Function | SmallTest | Level3)
376 {
377 sptr<SceneSession> scensession = nullptr;
378 WSError result01 = ssm_->RequestSceneSessionByCall(nullptr);
379 EXPECT_EQ(result01, WSError::WS_OK);
380 SessionInfo info;
381 info.bundleName_ = "bundleName";
382 scensession = new (std::nothrow) SceneSession(info, nullptr);
383 WSError result02 = ssm_->RequestSceneSessionByCall(scensession);
384 ASSERT_EQ(result02, WSError::WS_OK);
385 }
386
387 /**
388 * @tc.name: StartAbilityBySpecified
389 * @tc.desc: SceneSesionManager start ability by specified
390 * @tc.type: FUNC
391 */
HWTEST_F(SceneSessionManagerTest, StartAbilityBySpecified, Function | SmallTest | Level3)392 HWTEST_F(SceneSessionManagerTest, StartAbilityBySpecified, Function | SmallTest | Level3)
393 {
394 int ret = 0;
395 SessionInfo info;
396 ssm_->StartAbilityBySpecified(info);
397
398 std::shared_ptr<AAFwk::Want> want = std::make_shared<AAFwk::Want>();
399 AAFwk::WantParams wantParams;
400 want->SetParams(wantParams);
401 info.want = want;
402 ssm_->StartAbilityBySpecified(info);
403 ASSERT_EQ(ret, 0);
404 }
405
406 /**
407 * @tc.name: FindMainWindowWithToken
408 * @tc.desc: SceneSesionManager find main window with token
409 * @tc.type: FUNC
410 */
HWTEST_F(SceneSessionManagerTest, FindMainWindowWithToken, Function | SmallTest | Level3)411 HWTEST_F(SceneSessionManagerTest, FindMainWindowWithToken, Function | SmallTest | Level3)
412 {
413 sptr<IRemoteObject> targetToken = nullptr;
414 sptr<SceneSession> result = ssm_->FindMainWindowWithToken(targetToken);
415 EXPECT_EQ(result, nullptr);
416
417 uint64_t persistentId = 1423;
418 WSError result01 = ssm_->BindDialogSessionTarget(persistentId, targetToken);
419 EXPECT_EQ(result01, WSError::WS_ERROR_NULLPTR);
420
421 targetToken = new(std::nothrow) IRemoteObjectMocker();
422 SessionInfo info;
423 info.abilityName_ = "test1";
424 info.bundleName_ = "test2";
425 info.moduleName_ = "test3";
426 info.persistentId_ = 1;
427 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
428 ASSERT_NE(nullptr, sceneSession);
429 sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
430 ASSERT_NE(nullptr, property);
431 sceneSession->SetSessionProperty(property);
432 ssm_->sceneSessionMap_.insert({1, sceneSession});
433 persistentId = 1;
434 WSError result02 = ssm_->BindDialogSessionTarget(persistentId, targetToken);
435 EXPECT_EQ(result02, WSError::WS_OK);
436
437 property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
438 WSError result03 = ssm_->BindDialogSessionTarget(persistentId, targetToken);
439 EXPECT_EQ(result03, WSError::WS_ERROR_INVALID_PARAM);
440 }
441
442 /**
443 * @tc.name: UpdateParentSessionForDialog001
444 * @tc.desc: SceneSesionManager update parent session for dialog
445 * @tc.type: FUNC
446 */
HWTEST_F(SceneSessionManagerTest, UpdateParentSessionForDialog001, Function | SmallTest | Level3)447 HWTEST_F(SceneSessionManagerTest, UpdateParentSessionForDialog001, Function | SmallTest | Level3)
448 {
449 SessionInfo dialogInfo;
450 dialogInfo.abilityName_ = "DialogWindows";
451 dialogInfo.bundleName_ = "DialogWindows";
452 SessionInfo parentInfo;
453 parentInfo.abilityName_ = "ParentWindows";
454 parentInfo.bundleName_ = "ParentWindows";
455
456 int32_t persistentId = 1005;
457 sptr<SceneSession> parentSession = new (std::nothrow) MainSession(parentInfo, nullptr);
458 EXPECT_NE(parentSession, nullptr);
459 ssm_->sceneSessionMap_.insert({ persistentId, parentSession });
460
461 sptr<SceneSession> dialogSession = new (std::nothrow) SystemSession(dialogInfo, nullptr);
462 EXPECT_NE(dialogSession, nullptr);
463
464 sptr<WindowSessionProperty> property = new WindowSessionProperty();
465 property->SetParentPersistentId(persistentId);
466 property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
467
468 WSError result = ssm_->UpdateParentSessionForDialog(dialogSession, property);
469 EXPECT_EQ(dialogSession->GetParentPersistentId(), persistentId);
470 EXPECT_NE(dialogSession->GetParentSession(), nullptr);
471 EXPECT_EQ(result, WSError::WS_OK);
472 }
473
474 /**
475 * @tc.name: MoveSessionsToBackground
476 * @tc.desc: SceneSesionManager move sessions to background
477 * @tc.type: FUNC
478 */
HWTEST_F(SceneSessionManagerTest, MoveSessionsToBackground, Function | SmallTest | Level3)479 HWTEST_F(SceneSessionManagerTest, MoveSessionsToBackground, Function | SmallTest | Level3)
480 {
481 int32_t type = CollaboratorType::RESERVE_TYPE;
482 WSError result01 = ssm_->UnregisterIAbilityManagerCollaborator(type);
483 EXPECT_EQ(result01, WSError::WS_ERROR_INVALID_PERMISSION);
484 std::vector<std::int32_t> sessionIds = {1, 2, 3, 15, 1423};
485 std::vector<int32_t> res = {1, 2, 3, 15, 1423};
486 WSError result03 = ssm_->MoveSessionsToBackground(sessionIds, res);
487 ASSERT_EQ(result03, WSError::WS_ERROR_INVALID_PERMISSION);
488 }
489
490 /**
491 * @tc.name: ClearAllCollaboratorSessions
492 * @tc.desc: SceneSesionManager clear all collaborator sessions
493 * @tc.type: FUNC
494 */
HWTEST_F(SceneSessionManagerTest, ClearAllCollaboratorSessions, Function | SmallTest | Level3)495 HWTEST_F(SceneSessionManagerTest, ClearAllCollaboratorSessions, Function | SmallTest | Level3)
496 {
497 std::string bundleName = "bundleName";
498 std::string abilityName = "abilityName";
499 int32_t persistentId = 1200;
500 SessionInfo info;
501 info.bundleName_ = bundleName;
502 info.abilityName_ = abilityName;
503 info.persistentId_ = persistentId;
504 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
505 ASSERT_NE(sceneSession, nullptr);
506 sceneSession->SetCollaboratorType(CollaboratorType::DEFAULT_TYPE);
507 NotifyTerminateSessionFuncNew callback = [](const SessionInfo& info, bool needStartCaller, bool isFromBroker) {
508 ssm_->sceneSessionMap_.erase(info.persistentId_);
509 };
510 sceneSession->SetTerminateSessionListenerNew(callback);
511 ssm_->sceneSessionMap_.insert({persistentId, sceneSession});
512 ssm_->ClearAllCollaboratorSessions();
513 ASSERT_EQ(ssm_->sceneSessionMap_[persistentId], sceneSession);
514 }
515
516 /**
517 * @tc.name: ClearAllCollaboratorSessions02
518 * @tc.desc: SceneSesionManager clear all collaborator sessions
519 * @tc.type: FUNC
520 */
HWTEST_F(SceneSessionManagerTest, ClearAllCollaboratorSessions02, Function | SmallTest | Level3)521 HWTEST_F(SceneSessionManagerTest, ClearAllCollaboratorSessions02, Function | SmallTest | Level3)
522 {
523 std::string bundleName = "bundleName";
524 std::string abilityName = "abilityName";
525 int32_t persistentId = 1201;
526 SessionInfo info;
527 info.bundleName_ = bundleName;
528 info.abilityName_ = abilityName;
529 info.persistentId_ = persistentId;
530 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
531 ASSERT_NE(sceneSession, nullptr);
532 sceneSession->SetCollaboratorType(CollaboratorType::RESERVE_TYPE);
533 NotifyTerminateSessionFuncNew callback = [](const SessionInfo& info, bool needStartCaller, bool isFromBroker) {
534 ssm_->sceneSessionMap_.erase(info.persistentId_);
535 };
536 sceneSession->SetTerminateSessionListenerNew(callback);
537 ssm_->sceneSessionMap_.insert({persistentId, sceneSession});
538 ssm_->ClearAllCollaboratorSessions();
539 ASSERT_EQ(ssm_->sceneSessionMap_[persistentId], nullptr);
540 }
541
542 /**
543 * @tc.name: ClearAllCollaboratorSessions03
544 * @tc.desc: SceneSesionManager clear all collaborator sessions
545 * @tc.type: FUNC
546 */
HWTEST_F(SceneSessionManagerTest, ClearAllCollaboratorSessions03, Function | SmallTest | Level3)547 HWTEST_F(SceneSessionManagerTest, ClearAllCollaboratorSessions03, Function | SmallTest | Level3)
548 {
549 std::string bundleName = "bundleName";
550 std::string abilityName = "abilityName";
551 int32_t persistentId = 1202;
552 SessionInfo info;
553 info.bundleName_ = bundleName;
554 info.abilityName_ = abilityName;
555 info.persistentId_ = persistentId;
556 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
557 ASSERT_NE(sceneSession, nullptr);
558 sceneSession->SetCollaboratorType(CollaboratorType::OTHERS_TYPE);
559 NotifyTerminateSessionFuncNew callback = [](const SessionInfo& info, bool needStartCaller, bool isFromBroker) {
560 ssm_->sceneSessionMap_.erase(info.persistentId_);
561 };
562 sceneSession->SetTerminateSessionListenerNew(callback);
563 ssm_->sceneSessionMap_.insert({persistentId, sceneSession});
564 ssm_->ClearAllCollaboratorSessions();
565 ASSERT_EQ(ssm_->sceneSessionMap_[persistentId], nullptr);
566 }
567
568 /**
569 * @tc.name: MoveSessionsToForeground
570 * @tc.desc: SceneSesionManager move sessions to foreground
571 * @tc.type: FUNC
572 */
HWTEST_F(SceneSessionManagerTest, MoveSessionsToForeground, Function | SmallTest | Level3)573 HWTEST_F(SceneSessionManagerTest, MoveSessionsToForeground, Function | SmallTest | Level3)
574 {
575 std::vector<std::int32_t> sessionIds = {1, 2, 3, 15, 1423};
576 int32_t topSessionId = 1;
577 WSError result = ssm_->MoveSessionsToForeground(sessionIds, topSessionId);
578 ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
579 }
580
581 /**
582 * @tc.name: UnlockSession
583 * @tc.desc: SceneSesionManager unlock session
584 * @tc.type: FUNC
585 */
HWTEST_F(SceneSessionManagerTest, UnlockSession, Function | SmallTest | Level3)586 HWTEST_F(SceneSessionManagerTest, UnlockSession, Function | SmallTest | Level3)
587 {
588 int32_t sessionId = 1;
589 WSError result = ssm_->UnlockSession(sessionId);
590 EXPECT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
591 result = ssm_->LockSession(sessionId);
592 EXPECT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
593 }
594
595 /**
596 * @tc.name: GetImmersiveState
597 * @tc.desc: test GetImmersiveState
598 * @tc.type: FUNC
599 */
HWTEST_F(SceneSessionManagerTest, GetImmersiveState, Function | SmallTest | Level3)600 HWTEST_F(SceneSessionManagerTest, GetImmersiveState, Function | SmallTest | Level3)
601 {
602 int ret = 0;
603 ssm_->GetImmersiveState(0u);
604 ASSERT_EQ(ret, 0);
605 }
606
607 /**
608 * @tc.name: NotifyAINavigationBarShowStatus
609 * @tc.desc: test NotifyAINavigationBarShowStatus
610 * @tc.type: FUNC
611 */
HWTEST_F(SceneSessionManagerTest, NotifyAINavigationBarShowStatus, Function | SmallTest | Level3)612 HWTEST_F(SceneSessionManagerTest, NotifyAINavigationBarShowStatus, Function | SmallTest | Level3)
613 {
614 bool isVisible = false;
615 WSRect barArea = { 0, 0, 320, 240}; // width: 320, height: 240
616 uint64_t displayId = 0;
617 WSError result = ssm_->NotifyAINavigationBarShowStatus(isVisible, barArea, displayId);
618 ASSERT_EQ(result, WSError::WS_OK);
619 }
620
621 /**
622 * @tc.name: NotifyWindowExtensionVisibilityChange
623 * @tc.desc: test NotifyWindowExtensionVisibilityChange
624 * @tc.type: FUNC
625 */
HWTEST_F(SceneSessionManagerTest, NotifyWindowExtensionVisibilityChange, Function | SmallTest | Level3)626 HWTEST_F(SceneSessionManagerTest, NotifyWindowExtensionVisibilityChange, Function | SmallTest | Level3)
627 {
628 int32_t pid = getprocpid();
629 int32_t uid = getuid();
630 bool isVisible = false;
631 WSError result = ssm_->NotifyWindowExtensionVisibilityChange(pid, uid, isVisible);
632 ASSERT_EQ(result, WSError::WS_OK);
633
634 pid = INVALID_PID;
635 uid = INVALID_USER_ID;
636 result = ssm_->NotifyWindowExtensionVisibilityChange(pid, uid, isVisible);
637 ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
638 }
639
640 /**
641 * @tc.name: UpdateTopmostProperty
642 * @tc.desc: test UpdateTopmostProperty
643 * @tc.type: FUNC
644 */
HWTEST_F(SceneSessionManagerTest, UpdateTopmostProperty, Function | SmallTest | Level3)645 HWTEST_F(SceneSessionManagerTest, UpdateTopmostProperty, Function | SmallTest | Level3)
646 {
647 SessionInfo info;
648 info.abilityName_ = "UpdateTopmostProperty";
649 info.bundleName_ = "UpdateTopmostProperty";
650 sptr<WindowSessionProperty> property = new WindowSessionProperty();
651 property->SetTopmost(true);
652 property->SetSystemCalling(true);
653 sptr<SceneSession> scenesession = new (std::nothrow) MainSession(info, nullptr);
654 scenesession->SetSessionProperty(property);
655 WMError result = ssm_->UpdateTopmostProperty(property, scenesession);
656 ASSERT_EQ(WMError::WM_OK, result);
657 }
658
659 /**
660 * @tc.name: UpdateSessionWindowVisibilityListener
661 * @tc.desc: SceneSesionManager update window visibility listener
662 * @tc.type: FUNC
663 */
HWTEST_F(SceneSessionManagerTest, UpdateSessionWindowVisibilityListener, Function | SmallTest | Level3)664 HWTEST_F(SceneSessionManagerTest, UpdateSessionWindowVisibilityListener, Function | SmallTest | Level3)
665 {
666 int32_t persistentId = 10086;
667 bool haveListener = true;
668 WSError result = ssm_->UpdateSessionWindowVisibilityListener(persistentId, haveListener);
669 ASSERT_EQ(result, WSError::WS_DO_NOTHING);
670 }
671
672 /**
673 * @tc.name: GetSessionSnapshotPixelMap
674 * @tc.desc: SceneSesionManager get session snapshot pixelmap
675 * @tc.type: FUNC
676 */
HWTEST_F(SceneSessionManagerTest, GetSessionSnapshotPixelMap, Function | SmallTest | Level3)677 HWTEST_F(SceneSessionManagerTest, GetSessionSnapshotPixelMap, Function | SmallTest | Level3)
678 {
679 SessionInfo info;
680 info.abilityName_ = "GetPixelMap";
681 info.bundleName_ = "GetPixelMap1";
682 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
683 sceneSession->SetSessionState(SessionState::STATE_ACTIVE);
684
685 int32_t persistentId = 65535;
686 float scaleValue = 0.5f;
687 auto pixelMap = ssm_->GetSessionSnapshotPixelMap(persistentId, scaleValue);
688 EXPECT_EQ(pixelMap, nullptr);
689
690 persistentId = 1;
691 pixelMap = ssm_->GetSessionSnapshotPixelMap(persistentId, scaleValue);
692 EXPECT_EQ(pixelMap, nullptr);
693 }
694
695 /**
696 * @tc.name: GetSessionSnapshotById
697 * @tc.desc: test GetSessionSnapshotById
698 * @tc.type: FUNC
699 */
HWTEST_F(SceneSessionManagerTest, GetSessionSnapshotById, Function | SmallTest | Level3)700 HWTEST_F(SceneSessionManagerTest, GetSessionSnapshotById, Function | SmallTest | Level3)
701 {
702 int32_t persistentId = -1;
703 SessionSnapshot snapshot;
704 WMError ret = ssm_->GetSessionSnapshotById(persistentId, snapshot);
705 EXPECT_EQ(WMError::WM_ERROR_INVALID_PARAM, ret);
706 }
707
708 /**
709 * @tc.name: GetUIContentRemoteObj
710 * @tc.desc: SceneSesionManager GetUIContentRemoteObj
711 * @tc.type: FUNC
712 */
HWTEST_F(SceneSessionManagerTest, GetUIContentRemoteObj, Function | SmallTest | Level3)713 HWTEST_F(SceneSessionManagerTest, GetUIContentRemoteObj, Function | SmallTest | Level3)
714 {
715 sptr<IRemoteObject> remoteObj;
716 EXPECT_EQ(ssm_->GetUIContentRemoteObj(65535, remoteObj), WSError::WS_ERROR_INVALID_PERMISSION);
717 SessionInfo info;
718 info.abilityName_ = "GetUIContentRemoteObj";
719 info.bundleName_ = "GetUIContentRemoteObj";
720 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
721 ASSERT_NE(sceneSession, nullptr);
722 ssm_->sceneSessionMap_.insert({65535, sceneSession});
723 EXPECT_EQ(ssm_->GetUIContentRemoteObj(65535, remoteObj), WSError::WS_ERROR_INVALID_PERMISSION);
724 }
725
726 /**
727 * @tc.name: CalculateCombinedExtWindowFlags
728 * @tc.desc: SceneSesionManager calculate combined extension window flags
729 * @tc.type: FUNC
730 */
HWTEST_F(SceneSessionManagerTest, CalculateCombinedExtWindowFlags, Function | SmallTest | Level3)731 HWTEST_F(SceneSessionManagerTest, CalculateCombinedExtWindowFlags, Function | SmallTest | Level3)
732 {
733 EXPECT_EQ(ssm_->combinedExtWindowFlags_.bitData, 0);
734 ssm_->UpdateSpecialExtWindowFlags(1234, ExtensionWindowFlags(3), ExtensionWindowFlags(3));
735 ssm_->UpdateSpecialExtWindowFlags(5678, ExtensionWindowFlags(4), ExtensionWindowFlags(4));
736 ssm_->CalculateCombinedExtWindowFlags();
737 EXPECT_EQ(ssm_->combinedExtWindowFlags_.bitData, 7);
738 ssm_->extWindowFlagsMap_.clear();
739 }
740
741 /**
742 * @tc.name: UpdateSpecialExtWindowFlags
743 * @tc.desc: SceneSesionManager update special extension window flags
744 * @tc.type: FUNC
745 */
HWTEST_F(SceneSessionManagerTest, UpdateSpecialExtWindowFlags, Function | SmallTest | Level3)746 HWTEST_F(SceneSessionManagerTest, UpdateSpecialExtWindowFlags, Function | SmallTest | Level3)
747 {
748 int32_t persistentId = 12345;
749 EXPECT_TRUE(ssm_->extWindowFlagsMap_.empty());
750 ssm_->UpdateSpecialExtWindowFlags(persistentId, 3, 3);
751 EXPECT_EQ(ssm_->extWindowFlagsMap_.size(), 1);
752 EXPECT_EQ(ssm_->extWindowFlagsMap_.begin()->first, persistentId);
753 EXPECT_EQ(ssm_->extWindowFlagsMap_.begin()->second.bitData, 3);
754 ssm_->UpdateSpecialExtWindowFlags(persistentId, 0, 3);
755 EXPECT_TRUE(ssm_->extWindowFlagsMap_.empty());
756 ssm_->extWindowFlagsMap_.clear();
757 }
758
759 /**
760 * @tc.name: HideNonSecureFloatingWindows
761 * @tc.desc: SceneSesionManager hide non-secure floating windows
762 * @tc.type: FUNC
763 */
HWTEST_F(SceneSessionManagerTest, HideNonSecureFloatingWindows, Function | SmallTest | Level3)764 HWTEST_F(SceneSessionManagerTest, HideNonSecureFloatingWindows, Function | SmallTest | Level3)
765 {
766 SessionInfo info;
767 info.abilityName_ = "HideNonSecureFloatingWindows";
768 info.bundleName_ = "HideNonSecureFloatingWindows";
769
770 sptr<SceneSession> sceneSession;
771 sceneSession = new (std::nothrow) SceneSession(info, nullptr);
772 EXPECT_NE(sceneSession, nullptr);
773 sceneSession->state_ = SessionState::STATE_FOREGROUND;
774 ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession->GetPersistentId(), sceneSession));
775
776 sptr<SceneSession> floatSession;
777 floatSession = new (std::nothrow) SceneSession(info, nullptr);
778 EXPECT_NE(floatSession, nullptr);
779 floatSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
780 ssm_->nonSystemFloatSceneSessionMap_.insert(std::make_pair(floatSession->GetPersistentId(), floatSession));
781
782 EXPECT_FALSE(ssm_->shouldHideNonSecureFloatingWindows_.load());
783 EXPECT_FALSE(floatSession->GetSessionProperty()->GetForceHide());
784 sceneSession->combinedExtWindowFlags_.hideNonSecureWindowsFlag = true;
785 ssm_->HideNonSecureFloatingWindows();
786 EXPECT_TRUE(floatSession->GetSessionProperty()->GetForceHide());
787 sceneSession->combinedExtWindowFlags_.hideNonSecureWindowsFlag = false;
788 ssm_->combinedExtWindowFlags_.hideNonSecureWindowsFlag = true;
789 ssm_->HideNonSecureFloatingWindows();
790 EXPECT_TRUE(floatSession->GetSessionProperty()->GetForceHide());
791 ssm_->shouldHideNonSecureFloatingWindows_.store(false);
792 ssm_->sceneSessionMap_.clear();
793 ssm_->nonSystemFloatSceneSessionMap_.clear();
794 }
795
796 /**
797 * @tc.name: HideNonSecureSubWindows
798 * @tc.desc: SceneSesionManager hide non-secure sub windows
799 * @tc.type: FUNC
800 */
HWTEST_F(SceneSessionManagerTest, HideNonSecureSubWindows, Function | SmallTest | Level3)801 HWTEST_F(SceneSessionManagerTest, HideNonSecureSubWindows, Function | SmallTest | Level3)
802 {
803 SessionInfo info;
804 info.abilityName_ = "HideNonSecureSubWindows";
805 info.bundleName_ = "HideNonSecureSubWindows";
806
807 sptr<SceneSession> sceneSession;
808 sceneSession = new (std::nothrow) SceneSession(info, nullptr);
809 ASSERT_NE(sceneSession, nullptr);
810 sceneSession->state_ = SessionState::STATE_FOREGROUND;
811 sceneSession->combinedExtWindowFlags_.hideNonSecureWindowsFlag = true;
812
813 sptr<SceneSession> subSession;
814 subSession = new (std::nothrow) SceneSession(info, nullptr);
815 ASSERT_NE(subSession, nullptr);
816 ASSERT_NE(subSession->GetSessionProperty(), nullptr);
817 sceneSession->AddSubSession(subSession);
818 subSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
819 subSession->GetSessionProperty()->SetParentPersistentId(sceneSession->GetPersistentId());
820 ssm_->sceneSessionMap_.insert(std::make_pair(subSession->GetPersistentId(), subSession));
821
822 EXPECT_FALSE(subSession->GetSessionProperty()->GetForceHide());
823 sceneSession->combinedExtWindowFlags_.hideNonSecureWindowsFlag = true;
824 ssm_->HideNonSecureSubWindows(sceneSession);
825 EXPECT_TRUE(subSession->GetSessionProperty()->GetForceHide());
826 ssm_->sceneSessionMap_.clear();
827 }
828
829 /**
830 * @tc.name: HandleSecureSessionShouldHide
831 * @tc.desc: SceneSesionManager handle secure session should hide
832 * @tc.type: FUNC
833 */
HWTEST_F(SceneSessionManagerTest, HandleSecureSessionShouldHide, Function | SmallTest | Level3)834 HWTEST_F(SceneSessionManagerTest, HandleSecureSessionShouldHide, Function | SmallTest | Level3)
835 {
836 SessionInfo info;
837 info.abilityName_ = "HandleSecureSessionShouldHide";
838 info.bundleName_ = "HandleSecureSessionShouldHide";
839
840 sptr<SceneSession> sceneSession;
841 sceneSession = new (std::nothrow) SceneSession(info, nullptr);
842 ASSERT_NE(sceneSession, nullptr);
843 sceneSession->state_ = SessionState::STATE_FOREGROUND;
844 sceneSession->combinedExtWindowFlags_.hideNonSecureWindowsFlag = true;
845
846 sptr<SceneSession> subSession;
847 subSession = new (std::nothrow) SceneSession(info, nullptr);
848 ASSERT_NE(subSession, nullptr);
849 ASSERT_NE(subSession->GetSessionProperty(), nullptr);
850 sceneSession->AddSubSession(subSession);
851 subSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
852 subSession->GetSessionProperty()->SetParentPersistentId(sceneSession->GetPersistentId());
853 ssm_->sceneSessionMap_.insert(std::make_pair(subSession->GetPersistentId(), subSession));
854
855 sptr<SceneSession> floatSession;
856 floatSession = new (std::nothrow) SceneSession(info, nullptr);
857 ASSERT_NE(floatSession, nullptr);
858 ASSERT_NE(floatSession->GetSessionProperty(), nullptr);
859 floatSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
860 ssm_->nonSystemFloatSceneSessionMap_.insert(std::make_pair(floatSession->GetPersistentId(), floatSession));
861
862 sceneSession->SetShouldHideNonSecureWindows(true);
863 auto ret = ssm_->HandleSecureSessionShouldHide(sceneSession);
864 EXPECT_EQ(ret, WSError::WS_OK);
865 EXPECT_TRUE(subSession->GetSessionProperty()->GetForceHide());
866 EXPECT_TRUE(floatSession->GetSessionProperty()->GetForceHide());
867 EXPECT_TRUE(ssm_->shouldHideNonSecureFloatingWindows_.load());
868 ssm_->sceneSessionMap_.clear();
869 ssm_->nonSystemFloatSceneSessionMap_.clear();
870 }
871
872 /**
873 * @tc.name: HandleSpecialExtWindowFlagsChange
874 * @tc.desc: SceneSesionManager handle special uiextension window flags change
875 * @tc.type: FUNC
876 */
HWTEST_F(SceneSessionManagerTest, HandleSpecialExtWindowFlagsChange, Function | SmallTest | Level3)877 HWTEST_F(SceneSessionManagerTest, HandleSpecialExtWindowFlagsChange, Function | SmallTest | Level3)
878 {
879 int32_t persistentId = 12345;
880 EXPECT_TRUE(ssm_->extWindowFlagsMap_.empty());
881 ssm_->HandleSpecialExtWindowFlagsChange(persistentId, 3, 3);
882 EXPECT_EQ(ssm_->extWindowFlagsMap_.size(), 1);
883 EXPECT_EQ(ssm_->extWindowFlagsMap_.begin()->first, persistentId);
884 EXPECT_EQ(ssm_->extWindowFlagsMap_.begin()->second.bitData, 3);
885 ssm_->HandleSpecialExtWindowFlagsChange(persistentId, 0, 3);
886 EXPECT_TRUE(ssm_->extWindowFlagsMap_.empty());
887 ssm_->extWindowFlagsMap_.clear();
888 }
889
890 /**
891 * @tc.name: UpdateModalExtensionRect
892 * @tc.desc: SceneSesionManager update modal extension rect
893 * @tc.type: FUNC
894 */
HWTEST_F(SceneSessionManagerTest, UpdateModalExtensionRect, Function | SmallTest | Level3)895 HWTEST_F(SceneSessionManagerTest, UpdateModalExtensionRect, Function | SmallTest | Level3)
896 {
897 SessionInfo info;
898 info.abilityName_ = "UpdateModalExtensionRect";
899 info.bundleName_ = "UpdateModalExtensionRect";
900 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
901 ASSERT_NE(sceneSession, nullptr);
902 Rect rect { 1, 2, 3, 4 };
903 ssm_->UpdateModalExtensionRect(nullptr, rect);
904 EXPECT_FALSE(sceneSession->HasModalUIExtension());
905 }
906
907 /**
908 * @tc.name: ProcessModalExtensionPointDown
909 * @tc.desc: SceneSesionManager process modal extension point down
910 * @tc.type: FUNC
911 */
HWTEST_F(SceneSessionManagerTest, ProcessModalExtensionPointDown, Function | SmallTest | Level3)912 HWTEST_F(SceneSessionManagerTest, ProcessModalExtensionPointDown, Function | SmallTest | Level3)
913 {
914 SessionInfo info;
915 info.abilityName_ = "ProcessModalExtensionPointDown";
916 info.bundleName_ = "ProcessModalExtensionPointDown";
917 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
918 ASSERT_NE(sceneSession, nullptr);
919
920 ssm_->ProcessModalExtensionPointDown(nullptr, 0, 0);
921 EXPECT_FALSE(sceneSession->HasModalUIExtension());
922 }
923
924 /**
925 * @tc.name: GetExtensionWindowIds
926 * @tc.desc: SceneSesionManager get extension window ids
927 * @tc.type: FUNC
928 */
HWTEST_F(SceneSessionManagerTest, GetExtensionWindowIds, Function | SmallTest | Level3)929 HWTEST_F(SceneSessionManagerTest, GetExtensionWindowIds, Function | SmallTest | Level3)
930 {
931 SessionInfo info;
932 info.abilityName_ = "GetExtensionWindowIds";
933 info.bundleName_ = "GetExtensionWindowIds";
934 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
935 ASSERT_NE(sceneSession, nullptr);
936
937 int32_t persistentId = 0;
938 int32_t parentId = 0;
939 EXPECT_FALSE(ssm_->GetExtensionWindowIds(nullptr, persistentId, parentId));
940 }
941
942 /**
943 * @tc.name: AddOrRemoveSecureSession
944 * @tc.desc: SceneSesionManager hide non-secure windows by scene session
945 * @tc.type: FUNC
946 */
HWTEST_F(SceneSessionManagerTest, AddOrRemoveSecureSession, Function | SmallTest | Level3)947 HWTEST_F(SceneSessionManagerTest, AddOrRemoveSecureSession, Function | SmallTest | Level3)
948 {
949 SessionInfo info;
950 info.abilityName_ = "AddOrRemoveSecureSession";
951 info.bundleName_ = "AddOrRemoveSecureSession1";
952
953 int32_t persistentId = 12345;
954 auto ret = ssm_->AddOrRemoveSecureSession(persistentId, true);
955 EXPECT_EQ(ret, WSError::WS_OK);
956 }
957
958 /**
959 * @tc.name: UpdateExtWindowFlags
960 * @tc.desc: SceneSesionManager update uiextension window flags
961 * @tc.type: FUNC
962 */
HWTEST_F(SceneSessionManagerTest, UpdateExtWindowFlags, Function | SmallTest | Level3)963 HWTEST_F(SceneSessionManagerTest, UpdateExtWindowFlags, Function | SmallTest | Level3)
964 {
965 SessionInfo info;
966 info.abilityName_ = "UpdateExtWindowFlags";
967 info.bundleName_ = "UpdateExtWindowFlags";
968
969 auto ret = ssm_->UpdateExtWindowFlags(nullptr, 7, 7);
970 EXPECT_EQ(ret, WSError::WS_ERROR_INVALID_PERMISSION);
971 }
972
973 /**
974 * @tc.name: SetScreenLocked001
975 * @tc.desc: SetScreenLocked001
976 * @tc.type: FUNC
977 */
HWTEST_F(SceneSessionManagerTest, SetScreenLocked001, Function | SmallTest | Level3)978 HWTEST_F(SceneSessionManagerTest, SetScreenLocked001, Function | SmallTest | Level3)
979 {
980 sptr<SceneSession> sceneSession = nullptr;
981 SessionInfo info;
982 info.bundleName_ = "bundleName";
983 sceneSession = new (std::nothrow) SceneSession(info, nullptr);
984 ASSERT_NE(nullptr, sceneSession);
985 sceneSession->SetEventHandler(ssm_->taskScheduler_->GetEventHandler(), ssm_->eventHandler_);
986 ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession->GetPersistentId(), sceneSession));
987 DetectTaskInfo detectTaskInfo;
988 detectTaskInfo.taskState = DetectTaskState::ATTACH_TASK;
989 detectTaskInfo.taskWindowMode = WindowMode::WINDOW_MODE_UNDEFINED;
990 sceneSession->SetDetectTaskInfo(detectTaskInfo);
991 std::string taskName = "wms:WindowStateDetect" + std::to_string(sceneSession->persistentId_);
992 auto task = [](){};
993 int64_t delayTime = 3000;
994 sceneSession->handler_->PostTask(task, taskName, delayTime);
995 int32_t beforeTaskNum = GetTaskCount(sceneSession);
996 ssm_->SetScreenLocked(true);
997 ASSERT_EQ(beforeTaskNum - 1, GetTaskCount(sceneSession));
998 ASSERT_EQ(DetectTaskState::NO_TASK, sceneSession->detectTaskInfo_.taskState);
999 ASSERT_EQ(WindowMode::WINDOW_MODE_UNDEFINED, sceneSession->detectTaskInfo_.taskWindowMode);
1000 }
1001
1002 /**
1003 * @tc.name: AccessibilityFillEmptySceneSessionListToNotifyList
1004 * @tc.desc: SceneSesionManager fill empty scene session list to accessibilityList;
1005 * @tc.type: FUNC
1006 */
HWTEST_F(SceneSessionManagerTest, AccessibilityFillEmptySceneSessionListToNotifyList, Function | SmallTest | Level3)1007 HWTEST_F(SceneSessionManagerTest, AccessibilityFillEmptySceneSessionListToNotifyList, Function | SmallTest | Level3)
1008 {
1009 std::vector<sptr<SceneSession>> sceneSessionList;
1010 std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1011
1012 ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1013 EXPECT_EQ(accessibilityInfo.size(), 0);
1014 }
1015
1016 /**
1017 * @tc.name: AccessibilityFillOneSceneSessionListToNotifyList
1018 * @tc.desc: SceneSesionManager fill one sceneSession to accessibilityList;
1019 * @tc.type: FUNC
1020 */
HWTEST_F(SceneSessionManagerTest, AccessibilityFillOneSceneSessionListToNotifyList, Function | SmallTest | Level3)1021 HWTEST_F(SceneSessionManagerTest, AccessibilityFillOneSceneSessionListToNotifyList, Function | SmallTest | Level3)
1022 {
1023 SessionInfo sessionInfo;
1024 sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
1025 sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1026
1027 sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
1028 ASSERT_NE(sceneSession, nullptr);
1029 SetVisibleForAccessibility(sceneSession);
1030 ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1031
1032 std::vector<sptr<SceneSession>> sceneSessionList;
1033 ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1034 ASSERT_EQ(sceneSessionList.size(), 1);
1035
1036 std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1037 ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1038 ASSERT_EQ(accessibilityInfo.size(), 1);
1039 }
1040
1041 /**
1042 * @tc.name: AccessibilityFillTwoSceneSessionListToNotifyList
1043 * @tc.desc: SceneSesionManager fill two sceneSessions to accessibilityList;
1044 * @tc.type: FUNC
1045 */
HWTEST_F(SceneSessionManagerTest, AccessibilityFillTwoSceneSessionListToNotifyList, Function | SmallTest | Level3)1046 HWTEST_F(SceneSessionManagerTest, AccessibilityFillTwoSceneSessionListToNotifyList, Function | SmallTest | Level3)
1047 {
1048 SessionInfo sessionInfo;
1049 sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
1050 sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1051
1052 sptr<SceneSession> sceneSessionFirst = ssm_->CreateSceneSession(sessionInfo, nullptr);
1053 ASSERT_NE(sceneSessionFirst, nullptr);
1054 SetVisibleForAccessibility(sceneSessionFirst);
1055
1056 sptr<SceneSession> sceneSessionSecond = ssm_->CreateSceneSession(sessionInfo, nullptr);
1057 ASSERT_NE(sceneSessionSecond, nullptr);
1058 SetVisibleForAccessibility(sceneSessionSecond);
1059
1060 ssm_->sceneSessionMap_.insert({sceneSessionFirst->GetPersistentId(), sceneSessionFirst});
1061 ssm_->sceneSessionMap_.insert({sceneSessionSecond->GetPersistentId(), sceneSessionSecond});
1062
1063 std::vector<sptr<SceneSession>> sceneSessionList;
1064 ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1065 ASSERT_EQ(sceneSessionList.size(), 2);
1066
1067 std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1068 ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1069 ASSERT_EQ(accessibilityInfo.size(), 2);
1070 }
1071
1072 /**
1073 * @tc.name: AccessibilityFillEmptyBundleName
1074 * @tc.desc: SceneSesionManager fill empty bundle name to accessibilityInfo;
1075 * @tc.type: FUNC
1076 */
HWTEST_F(SceneSessionManagerTest, AccessibilityFillEmptyBundleName, Function | SmallTest | Level3)1077 HWTEST_F(SceneSessionManagerTest, AccessibilityFillEmptyBundleName, Function | SmallTest | Level3)
1078 {
1079 SessionInfo sessionInfo;
1080 sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1081
1082 sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
1083 ASSERT_NE(sceneSession, nullptr);
1084 SetVisibleForAccessibility(sceneSession);
1085 ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1086
1087 std::vector<sptr<SceneSession>> sceneSessionList;
1088 ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1089 ASSERT_EQ(sceneSessionList.size(), 1);
1090
1091 std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1092 ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1093 ASSERT_EQ(accessibilityInfo.size(), 1);
1094
1095 ASSERT_EQ(accessibilityInfo.at(0)->bundleName_, "");
1096 ASSERT_EQ(sceneSessionList.at(0)->GetSessionInfo().bundleName_, "");
1097 ASSERT_EQ(accessibilityInfo.at(0)->bundleName_, sceneSessionList.at(0)->GetSessionInfo().bundleName_);
1098 }
1099
1100 /**
1101 * @tc.name: AccessibilityFillBundleName
1102 * @tc.desc: SceneSesionManager fill bundle name to accessibilityInfo;
1103 * @tc.type: FUNC
1104 */
HWTEST_F(SceneSessionManagerTest, AccessibilityFillBundleName, Function | SmallTest | Level3)1105 HWTEST_F(SceneSessionManagerTest, AccessibilityFillBundleName, Function | SmallTest | Level3)
1106 {
1107 SessionInfo sessionInfo;
1108 sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
1109 sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1110
1111 sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
1112 ASSERT_NE(sceneSession, nullptr);
1113 SetVisibleForAccessibility(sceneSession);
1114 ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1115
1116 std::vector<sptr<SceneSession>> sceneSessionList;
1117 ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1118 ASSERT_EQ(sceneSessionList.size(), 1);
1119
1120 std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1121 ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1122 ASSERT_EQ(accessibilityInfo.size(), 1);
1123
1124 ASSERT_EQ(accessibilityInfo.at(0)->bundleName_, "accessibilityNotifyTesterBundleName");
1125 ASSERT_EQ(sceneSessionList.at(0)->GetSessionInfo().bundleName_, "accessibilityNotifyTesterBundleName");
1126 ASSERT_EQ(accessibilityInfo.at(0)->bundleName_, sceneSessionList.at(0)->GetSessionInfo().bundleName_);
1127 }
1128
1129 /**
1130 * @tc.name: AccessibilityFillFilterBundleName
1131 * @tc.desc: SceneSesionManager fill filter bundle name to accessibilityInfo;
1132 * @tc.type: FUNC
1133 */
HWTEST_F(SceneSessionManagerTest, AccessibilityFillFilterBundleName, Function | SmallTest | Level3)1134 HWTEST_F(SceneSessionManagerTest, AccessibilityFillFilterBundleName, Function | SmallTest | Level3)
1135 {
1136 SessionInfo sessionInfo;
1137 sessionInfo.bundleName_ = "SCBGestureTopBar";
1138 sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1139
1140 sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
1141 ASSERT_NE(sceneSession, nullptr);
1142 SetVisibleForAccessibility(sceneSession);
1143 ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1144
1145 std::vector<sptr<SceneSession>> sceneSessionList;
1146 ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1147 ASSERT_EQ(sceneSessionList.size(), 0);
1148
1149 std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1150 ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1151 ASSERT_EQ(accessibilityInfo.size(), 0);
1152 }
1153
1154 /**
1155 * @tc.name: AccessibilityFillEmptyHotAreas
1156 * @tc.desc: SceneSesionManager fill empty hot areas to accessibilityInfo;
1157 * @tc.type: FUNC
1158 */
HWTEST_F(SceneSessionManagerTest, AccessibilityFillEmptyHotAreas, Function | SmallTest | Level3)1159 HWTEST_F(SceneSessionManagerTest, AccessibilityFillEmptyHotAreas, Function | SmallTest | Level3)
1160 {
1161 SessionInfo sessionInfo;
1162 sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
1163 sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1164
1165 sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
1166 ASSERT_NE(sceneSession, nullptr);
1167 SetVisibleForAccessibility(sceneSession);
1168 ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1169
1170 std::vector<sptr<SceneSession>> sceneSessionList;
1171 std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1172
1173 ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1174 ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1175 ASSERT_EQ(accessibilityInfo.size(), 1);
1176
1177 ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.size(), sceneSessionList.at(0)->GetTouchHotAreas().size());
1178 ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.size(), 0);
1179 }
1180
1181 /**
1182 * @tc.name: AccessibilityFillOneHotAreas
1183 * @tc.desc: SceneSesionManager fill one hot areas to accessibilityInfo;
1184 * @tc.type: FUNC
1185 */
HWTEST_F(SceneSessionManagerTest, AccessibilityFillOneHotAreas, Function | SmallTest | Level3)1186 HWTEST_F(SceneSessionManagerTest, AccessibilityFillOneHotAreas, Function | SmallTest | Level3)
1187 {
1188 SessionInfo sessionInfo;
1189 sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
1190 sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1191
1192 Rect rect = {100, 200, 100, 200};
1193 std::vector<Rect> hotAreas;
1194 hotAreas.push_back(rect);
1195 sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
1196 ASSERT_NE(sceneSession, nullptr);
1197 sceneSession->SetTouchHotAreas(hotAreas);
1198 SetVisibleForAccessibility(sceneSession);
1199 ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1200
1201 std::vector<sptr<SceneSession>> sceneSessionList;
1202 std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1203
1204 ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1205 ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1206 ASSERT_EQ(accessibilityInfo.size(), 1);
1207
1208 ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.size(), sceneSessionList.at(0)->GetTouchHotAreas().size());
1209 ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.size(), 1);
1210
1211 ASSERT_EQ(rect.posX_, sceneSessionList.at(0)->GetTouchHotAreas().at(0).posX_);
1212 ASSERT_EQ(rect.posY_, sceneSessionList.at(0)->GetTouchHotAreas().at(0).posY_);
1213 ASSERT_EQ(rect.width_, sceneSessionList.at(0)->GetTouchHotAreas().at(0).width_);
1214 ASSERT_EQ(rect.height_, sceneSessionList.at(0)->GetTouchHotAreas().at(0).height_);
1215
1216 ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(0).posX_, rect.posX_);
1217 ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(0).posY_, rect.posY_);
1218 ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(0).width_, rect.width_);
1219 ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(0).height_, rect.height_);
1220 }
1221
1222 /**
1223 * @tc.name: AccessibilityFillTwoHotAreas
1224 * @tc.desc: SceneSesionManager fill two hot areas to accessibilityInfo;
1225 * @tc.type: FUNC
1226 */
HWTEST_F(SceneSessionManagerTest, AccessibilityFillTwoHotAreas, Function | SmallTest | Level3)1227 HWTEST_F(SceneSessionManagerTest, AccessibilityFillTwoHotAreas, Function | SmallTest | Level3)
1228 {
1229 SessionInfo sessionInfo;
1230 sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
1231 sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1232
1233 sptr<WindowSessionProperty> property = new WindowSessionProperty();
1234 std::vector<Rect> hotAreas;
1235 Rect rectFitst = {100, 200, 100, 200};
1236 Rect rectSecond = {50, 50, 20, 30};
1237 hotAreas.push_back(rectFitst);
1238 hotAreas.push_back(rectSecond);
1239 sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
1240 ASSERT_NE(sceneSession, nullptr);
1241 sceneSession->SetTouchHotAreas(hotAreas);
1242 SetVisibleForAccessibility(sceneSession);
1243 ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1244
1245 std::vector<sptr<SceneSession>> sceneSessionList;
1246 std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1247
1248 ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1249 ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1250 ASSERT_EQ(accessibilityInfo.size(), 1);
1251
1252 ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.size(), sceneSessionList.at(0)->GetTouchHotAreas().size());
1253 ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.size(), 2);
1254
1255 ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(0).posX_, rectFitst.posX_);
1256 ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(0).posY_, rectFitst.posY_);
1257 ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(0).width_, rectFitst.width_);
1258 ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(0).height_, rectFitst.height_);
1259
1260 ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(1).posX_, rectSecond.posX_);
1261 ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(1).posY_, rectSecond.posY_);
1262 ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(1).width_, rectSecond.width_);
1263 ASSERT_EQ(accessibilityInfo.at(0)->touchHotAreas_.at(1).height_, rectSecond.height_);
1264 }
1265
1266 /**
1267 * @tc.name: AccessibilityFilterEmptySceneSessionList
1268 * @tc.desc: SceneSesionManager filter empty scene session list;
1269 * @tc.type: FUNC
1270 */
HWTEST_F(SceneSessionManagerTest, AccessibilityFilterEmptySceneSessionList, Function | SmallTest | Level3)1271 HWTEST_F(SceneSessionManagerTest, AccessibilityFilterEmptySceneSessionList, Function | SmallTest | Level3)
1272 {
1273 std::vector<sptr<SceneSession>> sceneSessionList;
1274
1275 ssm_->FilterSceneSessionCovered(sceneSessionList);
1276 ASSERT_EQ(sceneSessionList.size(), 0);
1277 }
1278
1279 /**
1280 * @tc.name: AccessibilityFilterOneWindow
1281 * @tc.desc: SceneSesionManager filter one window;
1282 * @tc.type: FUNC
1283 */
HWTEST_F(SceneSessionManagerTest, AccessibilityFilterOneWindow, Function | SmallTest | Level3)1284 HWTEST_F(SceneSessionManagerTest, AccessibilityFilterOneWindow, Function | SmallTest | Level3)
1285 {
1286 SessionInfo sessionInfo;
1287 sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
1288 sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1289
1290 sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr);
1291 ASSERT_NE(sceneSession, nullptr);
1292 sceneSession->SetSessionRect({100, 100, 200, 200});
1293 SetVisibleForAccessibility(sceneSession);
1294 ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1295
1296 std::vector<sptr<SceneSession>> sceneSessionList;
1297 std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1298 ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1299 ssm_->FilterSceneSessionCovered(sceneSessionList);
1300 ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1301 ASSERT_EQ(accessibilityInfo.size(), 1);
1302 }
1303
1304 /**
1305 * @tc.name: AccessibilityFilterTwoWindowNotCovered
1306 * @tc.desc: SceneSesionManager filter two windows that not covered each other;
1307 * @tc.type: FUNC
1308 */
HWTEST_F(SceneSessionManagerTest, AccessibilityFilterTwoWindowNotCovered, Function | SmallTest | Level3)1309 HWTEST_F(SceneSessionManagerTest, AccessibilityFilterTwoWindowNotCovered, Function | SmallTest | Level3)
1310 {
1311 SessionInfo sessionInfo;
1312 sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
1313 sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1314
1315 sptr<SceneSession> sceneSessionFirst = ssm_->CreateSceneSession(sessionInfo, nullptr);
1316 ASSERT_NE(sceneSessionFirst, nullptr);
1317 sceneSessionFirst->SetSessionRect({0, 0, 200, 200});
1318 SetVisibleForAccessibility(sceneSessionFirst);
1319 ssm_->sceneSessionMap_.insert({sceneSessionFirst->GetPersistentId(), sceneSessionFirst});
1320
1321 sptr<SceneSession> sceneSessionSecond = ssm_->CreateSceneSession(sessionInfo, nullptr);
1322 ASSERT_NE(sceneSessionSecond, nullptr);
1323 sceneSessionSecond->SetSessionRect({300, 300, 200, 200});
1324 SetVisibleForAccessibility(sceneSessionSecond);
1325 ssm_->sceneSessionMap_.insert({sceneSessionSecond->GetPersistentId(), sceneSessionSecond});
1326
1327 std::vector<sptr<SceneSession>> sceneSessionList;
1328 std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1329 ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1330 ssm_->FilterSceneSessionCovered(sceneSessionList);
1331 ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1332 ASSERT_EQ(accessibilityInfo.size(), 2);
1333 }
1334
1335 /**
1336 * @tc.name: AccessibilityFilterTwoWindowCovered
1337 * @tc.desc: SceneSesionManager filter two windows that covered each other;
1338 * @tc.type: FUNC
1339 */
HWTEST_F(SceneSessionManagerTest, AccessibilityFilterTwoWindowCovered, Function | SmallTest | Level3)1340 HWTEST_F(SceneSessionManagerTest, AccessibilityFilterTwoWindowCovered, Function | SmallTest | Level3)
1341 {
1342 SessionInfo sessionInfo;
1343 sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName";
1344 sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName";
1345
1346 sptr<SceneSession> sceneSessionFirst = ssm_->CreateSceneSession(sessionInfo, nullptr);
1347 ASSERT_NE(sceneSessionFirst, nullptr);
1348 sceneSessionFirst->SetSessionRect({0, 0, 200, 200});
1349 SetVisibleForAccessibility(sceneSessionFirst);
1350 sceneSessionFirst->SetZOrder(20);
1351 ssm_->sceneSessionMap_.insert({sceneSessionFirst->GetPersistentId(), sceneSessionFirst});
1352
1353 sptr<SceneSession> sceneSessionSecond = ssm_->CreateSceneSession(sessionInfo, nullptr);
1354 ASSERT_NE(sceneSessionSecond, nullptr);
1355 sceneSessionSecond->SetSessionRect({50, 50, 50, 50});
1356 SetVisibleForAccessibility(sceneSessionSecond);
1357 sceneSessionSecond->SetZOrder(10);
1358 ssm_->sceneSessionMap_.insert({sceneSessionSecond->GetPersistentId(), sceneSessionSecond});
1359
1360 std::vector<sptr<SceneSession>> sceneSessionList;
1361 std::vector<sptr<AccessibilityWindowInfo>> accessibilityInfo;
1362 ssm_->GetAllSceneSessionForAccessibility(sceneSessionList);
1363 ssm_->FilterSceneSessionCovered(sceneSessionList);
1364 ssm_->FillAccessibilityInfo(sceneSessionList, accessibilityInfo);
1365 ASSERT_EQ(accessibilityInfo.size(), 1);
1366 }
1367
1368 /**
1369 * @tc.name: GetMainWindowInfos
1370 * @tc.desc: SceneSesionManager get topN main window infos;
1371 * @tc.type: FUNC
1372 */
HWTEST_F(SceneSessionManagerTest, GetMainWindowInfos, Function | SmallTest | Level3)1373 HWTEST_F(SceneSessionManagerTest, GetMainWindowInfos, Function | SmallTest | Level3)
1374 {
1375 int32_t topNum = 1024;
1376 std::vector<MainWindowInfo> topNInfos;
1377 auto result = ssm_->GetMainWindowInfos(topNum, topNInfos);
1378 EXPECT_EQ(result, WMError::WM_OK);
1379
1380 topNum = 0;
1381 ssm_->GetMainWindowInfos(topNum, topNInfos);
1382
1383 topNum = 1000;
1384 MainWindowInfo info;
1385 topNInfos.push_back(info);
1386 ssm_->GetMainWindowInfos(topNum, topNInfos);
1387 }
1388
1389 /**
1390 * @tc.name: GetAllWindowVisibilityInfos
1391 * @tc.desc: SceneSesionManager get all window visibility infos;
1392 * @tc.type: FUNC
1393 */
HWTEST_F(SceneSessionManagerTest, GetAllWindowVisibilityInfos, Function | SmallTest | Level3)1394 HWTEST_F(SceneSessionManagerTest, GetAllWindowVisibilityInfos, Function | SmallTest | Level3)
1395 {
1396 ASSERT_NE(ssm_, nullptr);
1397 ssm_->sceneSessionMap_.clear();
1398 SessionInfo info;
1399 sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, nullptr);
1400 ASSERT_NE(nullptr, sceneSession);
1401 ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1402 std::vector<std::pair<int32_t, uint32_t>> windowVisibilityInfos;
1403 ssm_->GetAllWindowVisibilityInfos(windowVisibilityInfos);
1404 EXPECT_NE(windowVisibilityInfos.size(), 0);
1405 }
1406
1407 /**
1408 * @tc.name: TestNotifyEnterRecentTask
1409 * @tc.desc: Test whether the enterRecent_ is set correctly;
1410 * @tc.type: FUNC
1411 */
HWTEST_F(SceneSessionManagerTest, TestNotifyEnterRecentTask, Function | SmallTest | Level3)1412 HWTEST_F(SceneSessionManagerTest, TestNotifyEnterRecentTask, Function | SmallTest | Level3)
1413 {
1414 GTEST_LOG_(INFO) << "SceneSessionManagerTest: TestNotifyEnterRecentTask start";
1415 sptr<SceneSessionManager> sceneSessionManager = new SceneSessionManager();
1416 ASSERT_NE(nullptr, sceneSessionManager);
1417
1418 ASSERT_EQ(sceneSessionManager->NotifyEnterRecentTask(true), WSError::WS_OK);
1419 ASSERT_EQ(sceneSessionManager->enterRecent_.load(), true);
1420 }
1421
1422 /**
1423 * @tc.name: TestIsEnablePiPCreate
1424 * @tc.desc: Test if pip window can be created;
1425 * @tc.type: FUNC
1426 */
HWTEST_F(SceneSessionManagerTest, TestIsEnablePiPCreate, Function | SmallTest | Level3)1427 HWTEST_F(SceneSessionManagerTest, TestIsEnablePiPCreate, Function | SmallTest | Level3)
1428 {
1429 GTEST_LOG_(INFO) << "SceneSessionManagerTest: TestIsEnablePiPCreate start";
1430 ssm_->isScreenLocked_ = true;
1431 sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
1432 ASSERT_TRUE(!ssm_->isEnablePiPCreate(property));
1433
1434 ssm_->isScreenLocked_ = false;
1435 Rect reqRect = { 0, 0, 0, 0 };
1436 property->SetRequestRect(reqRect);
1437 ASSERT_TRUE(!ssm_->isEnablePiPCreate(property));
1438
1439 reqRect = { 0, 0, 10, 0 };
1440 property->SetRequestRect(reqRect);
1441 ASSERT_TRUE(!ssm_->isEnablePiPCreate(property));
1442
1443 reqRect = { 0, 0, 10, 10 };
1444 property->SetRequestRect(reqRect);
1445 PiPTemplateInfo info = {0, 0, {}};
1446 property->SetPiPTemplateInfo(info);
1447 SessionInfo info1;
1448 info1.abilityName_ = "test1";
1449 info1.bundleName_ = "test2";
1450 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info1, nullptr);
1451 ASSERT_NE(nullptr, sceneSession);
1452 property->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
1453 sceneSession->pipTemplateInfo_ = {0, 100, {}};
1454 ssm_->sceneSessionMap_.insert({0, sceneSession});
1455 ASSERT_TRUE(!ssm_->isEnablePiPCreate(property));
1456 ssm_->sceneSessionMap_.clear();
1457 ASSERT_TRUE(!ssm_->isEnablePiPCreate(property));
1458
1459 property->SetParentPersistentId(100);
1460 ASSERT_TRUE(!ssm_->isEnablePiPCreate(property));
1461
1462 ssm_->sceneSessionMap_.insert({100, sceneSession});
1463 ASSERT_TRUE(!ssm_->isEnablePiPCreate(property));
1464
1465 ssm_->sceneSessionMap_.clear();
1466 sceneSession->SetSessionState(SessionState::STATE_FOREGROUND);
1467 ssm_->sceneSessionMap_.insert({100, sceneSession});
1468 ASSERT_TRUE(ssm_->isEnablePiPCreate(property));
1469 }
1470
1471 /**
1472 * @tc.name: GetAllMainWindowInfos001
1473 * @tc.desc: SceneSessionManager get all main window infos.
1474 * @tc.type: FUNC
1475 */
HWTEST_F(SceneSessionManagerTest, GetAllMainWindowInfos001, Function | SmallTest | Level3)1476 HWTEST_F(SceneSessionManagerTest, GetAllMainWindowInfos001, Function | SmallTest | Level3)
1477 {
1478 SessionInfo info;
1479 info.abilityName_ = "test1";
1480 info.bundleName_ = "test1";
1481 info.windowType_ = static_cast<uint32_t>(WindowType::APP_WINDOW_BASE);
1482 info.persistentId_ = 1;
1483 std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
1484 AppExecFwk::ApplicationInfo applicationInfo;
1485 applicationInfo.bundleType = AppExecFwk::BundleType::ATOMIC_SERVICE;
1486 abilityInfo->applicationInfo = applicationInfo;
1487 info.abilityInfo = abilityInfo;
1488 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
1489 if (sceneSession == nullptr) {
1490 return;
1491 }
1492 ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1493 std::vector<MainWindowInfo> infos;
1494 WMError result = ssm_->GetAllMainWindowInfos(infos);
1495 EXPECT_EQ(result, WMError::WM_OK);
1496 ssm_->sceneSessionMap_.erase(sceneSession->GetPersistentId());
1497 }
1498
1499 /**
1500 * @tc.name: GetAllMainWindowInfos002
1501 * @tc.desc: SceneSessionManager get all main window infos, input params are not empty.
1502 * @tc.type: FUNC
1503 */
HWTEST_F(SceneSessionManagerTest, GetAllMainWindowInfos002, Function | SmallTest | Level3)1504 HWTEST_F(SceneSessionManagerTest, GetAllMainWindowInfos002, Function | SmallTest | Level3)
1505 {
1506 std::vector<MainWindowInfo> infos;
1507 MainWindowInfo info;
1508 info.pid_ = 1000;
1509 info.bundleName_ = "test";
1510 infos.push_back(info);
1511 WMError result = ssm_->GetAllMainWindowInfos(infos);
1512 EXPECT_EQ(result, WMError::WM_ERROR_INVALID_PARAM);
1513 }
1514
1515 /**
1516 * @tc.name: GetUnreliableWindowInfo01
1517 * @tc.desc: SceneSesionManager get unreliable window info, windowId correct
1518 * @tc.type: FUNC
1519 */
HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo01, Function | SmallTest | Level3)1520 HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo01, Function | SmallTest | Level3)
1521 {
1522 ssm_->sceneSessionMap_.clear();
1523 SessionInfo info;
1524 sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, nullptr);
1525 ASSERT_NE(nullptr, sceneSession);
1526 ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1527
1528 int32_t windowId = sceneSession->GetPersistentId();
1529 std::vector<sptr<UnreliableWindowInfo>> infos;
1530 WMError result = ssm_->GetUnreliableWindowInfo(windowId, infos);
1531 EXPECT_EQ(WMError::WM_OK, result);
1532 EXPECT_EQ(1, infos.size());
1533 }
1534
1535 /**
1536 * @tc.name: GetUnreliableWindowInfo02
1537 * @tc.desc: SceneSesionManager get unreliable window info, toast window
1538 * @tc.type: FUNC
1539 */
HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo02, Function | SmallTest | Level3)1540 HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo02, Function | SmallTest | Level3)
1541 {
1542 ssm_->sceneSessionMap_.clear();
1543 SessionInfo info;
1544 info.windowType_ = 2107;
1545 sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
1546 ASSERT_NE(nullptr, property);
1547 property->SetWindowType(WindowType::WINDOW_TYPE_TOAST);
1548 sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, property);
1549 ASSERT_NE(nullptr, sceneSession);
1550 sceneSession->SetRSVisible(true);
1551 ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1552
1553 int32_t windowId = 0;
1554 std::vector<sptr<UnreliableWindowInfo>> infos;
1555 WMError result = ssm_->GetUnreliableWindowInfo(windowId, infos);
1556 EXPECT_EQ(WMError::WM_OK, result);
1557 EXPECT_EQ(1, infos.size());
1558 }
1559
1560 /**
1561 * @tc.name: GetUnreliableWindowInfo03
1562 * @tc.desc: SceneSesionManager get unreliable window info, app sub window
1563 * @tc.type: FUNC
1564 */
HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo03, Function | SmallTest | Level3)1565 HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo03, Function | SmallTest | Level3)
1566 {
1567 ssm_->sceneSessionMap_.clear();
1568 SessionInfo info;
1569 info.windowType_ = 1000;
1570 sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
1571 ASSERT_NE(nullptr, property);
1572 property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1573 sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, property);
1574 ASSERT_NE(nullptr, sceneSession);
1575 ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1576
1577 SessionInfo info2;
1578 info2.windowType_ = 1001;
1579 sptr<WindowSessionProperty> property2 = new (std::nothrow) WindowSessionProperty();
1580 ASSERT_NE(nullptr, property2);
1581 property2->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1582 property2->SetParentId(sceneSession->GetPersistentId());
1583 sptr<SceneSession> sceneSession2 = ssm_->CreateSceneSession(info2, property2);
1584 ASSERT_NE(nullptr, sceneSession2);
1585 sceneSession2->SetRSVisible(true);
1586 ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2});
1587
1588 int32_t windowId = 0;
1589 std::vector<sptr<UnreliableWindowInfo>> infos;
1590 WMError result = ssm_->GetUnreliableWindowInfo(windowId, infos);
1591 EXPECT_EQ(WMError::WM_OK, result);
1592 EXPECT_EQ(1, infos.size());
1593 }
1594
1595 /**
1596 * @tc.name: GetUnreliableWindowInfo04
1597 * @tc.desc: SceneSesionManager get unreliable window info, input method window
1598 * @tc.type: FUNC
1599 */
HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo04, Function | SmallTest | Level3)1600 HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo04, Function | SmallTest | Level3)
1601 {
1602 ssm_->sceneSessionMap_.clear();
1603 SessionInfo info;
1604 info.windowType_ = 2105;
1605 sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
1606 ASSERT_NE(nullptr, property);
1607 property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1608 sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, property);
1609 ASSERT_NE(nullptr, sceneSession);
1610 sceneSession->SetRSVisible(true);
1611 ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1612
1613 int32_t windowId = 0;
1614 std::vector<sptr<UnreliableWindowInfo>> infos;
1615 WMError result = ssm_->GetUnreliableWindowInfo(windowId, infos);
1616 EXPECT_EQ(WMError::WM_OK, result);
1617 EXPECT_EQ(1, infos.size());
1618 }
1619
1620 /**
1621 * @tc.name: GetUnreliableWindowInfo05
1622 * @tc.desc: SceneSesionManager get unreliable window info, not correct window type, not visible
1623 * @tc.type: FUNC
1624 */
HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo05, Function | SmallTest | Level3)1625 HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo05, Function | SmallTest | Level3)
1626 {
1627 ssm_->sceneSessionMap_.clear();
1628 SessionInfo info;
1629 info.windowType_ = 2122;
1630 sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
1631 ASSERT_NE(nullptr, property);
1632 property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
1633 sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, property);
1634 ASSERT_NE(nullptr, sceneSession);
1635 sceneSession->SetRSVisible(true);
1636 ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession});
1637 ssm_->sceneSessionMap_.insert({0, nullptr});
1638
1639 int32_t windowId = 0;
1640 std::vector<sptr<UnreliableWindowInfo>> infos;
1641 WMError result = ssm_->GetUnreliableWindowInfo(windowId, infos);
1642 EXPECT_EQ(WMError::WM_OK, result);
1643 sceneSession->SetRSVisible(false);
1644 result = ssm_->GetUnreliableWindowInfo(windowId, infos);
1645 EXPECT_EQ(WMError::WM_OK, result);
1646 EXPECT_EQ(0, infos.size());
1647 }
1648
1649 /**
1650 * @tc.name: GetUnreliableWindowInfo06
1651 * @tc.desc: SceneSesionManager satisfy FillUnreliableWindowInfo branches coverage
1652 * @tc.type: FUNC
1653 */
HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo06, Function | SmallTest | Level3)1654 HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo06, Function | SmallTest | Level3)
1655 {
1656 ssm_->sceneSessionMap_.clear();
1657 SessionInfo info1;
1658 info1.bundleName_ = "SCBGestureBack";
1659 sptr<SceneSession> sceneSession1 = ssm_->CreateSceneSession(info1, nullptr);
1660 ASSERT_NE(nullptr, sceneSession1);
1661 ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1});
1662
1663 SessionInfo info2;
1664 info2.bundleName_ = "SCBGestureNavBar";
1665 sptr<SceneSession> sceneSession2 = ssm_->CreateSceneSession(info2, nullptr);
1666 ASSERT_NE(nullptr, sceneSession2);
1667 ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2});
1668
1669 SessionInfo info3;
1670 info3.bundleName_ = "SCBGestureTopBar";
1671 sptr<SceneSession> sceneSession3 = ssm_->CreateSceneSession(info3, nullptr);
1672 ASSERT_NE(nullptr, sceneSession3);
1673 ssm_->sceneSessionMap_.insert({sceneSession3->GetPersistentId(), sceneSession3});
1674
1675 std::vector<sptr<UnreliableWindowInfo>> infos;
1676 ssm_->GetUnreliableWindowInfo(sceneSession1->GetPersistentId(), infos);
1677 ssm_->GetUnreliableWindowInfo(sceneSession2->GetPersistentId(), infos);
1678 ssm_->GetUnreliableWindowInfo(sceneSession3->GetPersistentId(), infos);
1679 EXPECT_EQ(0, infos.size());
1680 }
1681
1682 /**
1683 * @tc.name: SkipSnapshotForAppProcess
1684 * @tc.desc: add or cancel snapshot skip for app process
1685 * @tc.type: FUNC
1686 */
HWTEST_F(SceneSessionManagerTest, SkipSnapshotForAppProcess, Function | SmallTest | Level3)1687 HWTEST_F(SceneSessionManagerTest, SkipSnapshotForAppProcess, Function | SmallTest | Level3)
1688 {
1689 int32_t pid = 1000;
1690 bool skip = true;
1691 auto result = ssm_->SkipSnapshotForAppProcess(pid, skip);
1692 ASSERT_EQ(result, WMError::WM_OK);
1693 constexpr uint32_t WAIT_SYNC_IN_NS_ZERO = 500000;
1694 usleep(WAIT_SYNC_IN_NS_ZERO);
1695 ASSERT_NE(ssm_->snapshotSkipPidSet_.find(pid), ssm_->snapshotSkipPidSet_.end());
1696
1697 skip = false;
1698 result = ssm_->SkipSnapshotForAppProcess(pid, skip);
1699 ASSERT_EQ(result, WMError::WM_OK);
1700 constexpr uint32_t WAIT_SYNC_IN_NS_ONE = 500000;
1701 usleep(WAIT_SYNC_IN_NS_ONE);
1702 ASSERT_EQ(ssm_->snapshotSkipPidSet_.find(pid), ssm_->snapshotSkipPidSet_.end());
1703
1704 SessionInfo info;
1705 sptr<SceneSession> sceneSession1 = ssm_->CreateSceneSession(info, nullptr);
1706 sptr<SceneSession> sceneSession2 = ssm_->CreateSceneSession(info, nullptr);
1707 ASSERT_NE(nullptr, sceneSession1);
1708 ASSERT_NE(nullptr, sceneSession2);
1709 sceneSession1->SetCallingPid(1000);
1710 sceneSession2->SetCallingPid(1001);
1711 ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1});
1712 ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2});
1713 ssm_->sceneSessionMap_.insert({-1, nullptr});
1714 skip = true;
1715 result = ssm_->SkipSnapshotForAppProcess(pid, skip);
1716 ASSERT_EQ(result, WMError::WM_OK);
1717 skip = false;
1718 result = ssm_->SkipSnapshotForAppProcess(pid, skip);
1719 ASSERT_EQ(result, WMError::WM_OK);
1720 ssm_->sceneSessionMap_.erase(sceneSession1->GetPersistentId());
1721 ssm_->sceneSessionMap_.erase(sceneSession2->GetPersistentId());
1722 ssm_->sceneSessionMap_.erase(-1);
1723 constexpr uint32_t WAIT_SYNC_IN_NS_TWO = 1000000;
1724 usleep(WAIT_SYNC_IN_NS_TWO);
1725 }
1726
1727 /**
1728 * @tc.name: RemoveProcessSnapshotSkip
1729 * @tc.desc: SceneSesionManager RemoveProcessSnapshotSkip
1730 * @tc.type: FUNC
1731 */
HWTEST_F(SceneSessionManagerTest, RemoveProcessSnapshotSkip, Function | SmallTest | Level3)1732 HWTEST_F(SceneSessionManagerTest, RemoveProcessSnapshotSkip, Function | SmallTest | Level3)
1733 {
1734 ssm_->snapshotSkipPidSet_.insert(1);
1735 ssm_->RemoveProcessSnapshotSkip(1);
1736 ASSERT_EQ(ssm_->snapshotSkipPidSet_.find(1), ssm_->snapshotSkipPidSet_.end());
1737 }
1738
1739 /**
1740 * @tc.name: SetSessionSnapshotSkipForAppProcess
1741 * @tc.desc: SceneSesionManager SetSessionSnapshotSkipForAppProcess
1742 * @tc.type: FUNC
1743 */
HWTEST_F(SceneSessionManagerTest, SetSessionSnapshotSkipForAppProcess, Function | SmallTest | Level3)1744 HWTEST_F(SceneSessionManagerTest, SetSessionSnapshotSkipForAppProcess, Function | SmallTest | Level3)
1745 {
1746 SessionInfo info;
1747 sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, nullptr);
1748 sceneSession->SetCallingPid(1000);
1749 struct RSSurfaceNodeConfig config;
1750 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
1751 sceneSession->surfaceNode_ = surfaceNode;
1752 ssm_->SetSessionSnapshotSkipForAppProcess(sceneSession);
1753 ASSERT_EQ(sceneSession->GetSessionProperty()->GetSnapshotSkip(), false);
1754
1755 ssm_->snapshotSkipPidSet_.insert(1000);
1756 ssm_->SetSessionSnapshotSkipForAppProcess(sceneSession);
1757 ASSERT_EQ(sceneSession->GetSessionProperty()->GetSnapshotSkip(), true);
1758 ssm_->snapshotSkipPidSet_.erase(1000);
1759 }
1760
1761 /**
1762 * @tc.name: TestReportCorrectScreenFoldStatusChangeEvent
1763 * @tc.desc: Test whether report the correct screen fold status events
1764 * @tc.type: FUNC
1765 */
HWTEST_F(SceneSessionManagerTest, TestReportCorrectScreenFoldStatusChangeEvent, Function | SmallTest | Level3)1766 HWTEST_F(SceneSessionManagerTest, TestReportCorrectScreenFoldStatusChangeEvent, Function | SmallTest | Level3)
1767 {
1768 GTEST_LOG_(INFO) << "SceneSessionManagerTest: TestReportCorrectScreenFoldStatusChangeEvent start";
1769 ScreenFoldData screenFoldData1;
1770 screenFoldData1.currentScreenFoldStatus_ = 1; // 1: current screen fold status
1771 screenFoldData1.nextScreenFoldStatus_ = 3; // 3: next screen fold status
1772 screenFoldData1.currentScreenFoldStatusDuration_ = 18; // 18: current duration
1773 screenFoldData1.postureAngle_ = 47.1f; // 47.1: posture angle (type: float)
1774 screenFoldData1.screenRotation_ = 1; // 1: screen rotation
1775 screenFoldData1.typeCThermal_ = 3000; // 3000: typec port thermal
1776 screenFoldData1.focusedPackageName_ = "Developer Test: (1, 3, 18, 47.1, 1, 3000)";
1777 WMError result = ssm_->CheckAndReportScreenFoldStatus(screenFoldData1);
1778 ASSERT_EQ(result, WMError::WM_DO_NOTHING); // not report half-fold event until next change
1779
1780 ScreenFoldData screenFoldData2;
1781 screenFoldData2.currentScreenFoldStatus_ = 3; // 3: current screen fold status
1782 screenFoldData2.nextScreenFoldStatus_ = 2; // 2: next screen fold status
1783 screenFoldData2.currentScreenFoldStatusDuration_ = 20; // 20: current duration
1784 screenFoldData2.postureAngle_ = 143.7f; // 143.7: posture angle (type: float)
1785 screenFoldData2.screenRotation_ = 2; // 2: screen rotation
1786 screenFoldData2.typeCThermal_ = 3005; // 3005: typec port thermal
1787 screenFoldData2.focusedPackageName_ = "Developer Test: (3, 2, 20, 143.7, 2, 3005)";
1788 result = ssm_->CheckAndReportScreenFoldStatus(screenFoldData2);
1789 ASSERT_EQ(result, WMError::WM_OK);
1790 }
1791
1792 /**
1793 * @tc.name: TestReportIncompleteScreenFoldStatusChangeEvent
1794 * @tc.desc: Test whether block the incomplete screen fold status events
1795 * @tc.type: FUNC
1796 */
HWTEST_F(SceneSessionManagerTest, TestReportIncompleteScreenFoldStatusChangeEvent, Function | SmallTest | Level3)1797 HWTEST_F(SceneSessionManagerTest, TestReportIncompleteScreenFoldStatusChangeEvent, Function | SmallTest | Level3)
1798 {
1799 GTEST_LOG_(INFO) << "SceneSessionManagerTest: TestReportIncompleteScreenFoldStatusChangeEvent start";
1800 // screen fold status changes from -1: invalid to 3: half_fold, duration = 0, angle = 67.0, rotation = 0
1801 std::vector<std::string> screenFoldInfo {"-1", "3", "0", "67.0", "0"};
1802 WMError result = ssm_->ReportScreenFoldStatusChange(screenFoldInfo);
1803 ASSERT_EQ(result, WMError::WM_DO_NOTHING);
1804
1805 screenFoldInfo.clear();
1806 result = ssm_->ReportScreenFoldStatusChange(screenFoldInfo);
1807 ASSERT_EQ(result, WMError::WM_DO_NOTHING);
1808
1809 // screen fold status changes from 2: folded to 3: half_fold, duration = 0, angle = 67.0, rotation = 0
1810 screenFoldInfo = {"2", "3", "0", "67.0", "0"};
1811 result = ssm_->ReportScreenFoldStatusChange(screenFoldInfo);
1812 ASSERT_EQ(result, WMError::WM_DO_NOTHING);
1813
1814 // screen fold status changes from 3: half_fold to 1: expand, duration = 18, angle = 147.3, rotation = 2
1815 screenFoldInfo = {"3", "1", "18", "147.3", "2"};
1816 result = ssm_->ReportScreenFoldStatusChange(screenFoldInfo);
1817 ASSERT_EQ(result, WMError::WM_DO_NOTHING);
1818 }
1819
1820 /**
1821 * @tc.name: SetAppForceLandscapeConfig
1822 * @tc.desc: SceneSesionManager SetAppForceLandscapeConfig
1823 * @tc.type: FUNC
1824 */
HWTEST_F(SceneSessionManagerTest, SetAppForceLandscapeConfig, Function | SmallTest | Level3)1825 HWTEST_F(SceneSessionManagerTest, SetAppForceLandscapeConfig, Function | SmallTest | Level3)
1826 {
1827 std::string bundleName = "SetAppForceLandscapeConfig";
1828 AppForceLandscapeConfig config = { 0, "MainPage" };
1829 WSError result = ssm_->SetAppForceLandscapeConfig(bundleName, config);
1830 ASSERT_EQ(result, WSError::WS_OK);
1831 }
1832
1833 /**
1834 * @tc.name: GetAppForceLandscapeConfig
1835 * @tc.desc: SceneSesionManager GetAppForceLandscapeConfig
1836 * @tc.type: FUNC
1837 */
HWTEST_F(SceneSessionManagerTest, GetAppForceLandscapeConfig, Function | SmallTest | Level3)1838 HWTEST_F(SceneSessionManagerTest, GetAppForceLandscapeConfig, Function | SmallTest | Level3)
1839 {
1840 std::string bundleName = "GetAppForceLandscapeConfig";
1841 AppForceLandscapeConfig config = ssm_->GetAppForceLandscapeConfig(bundleName);
1842 ASSERT_EQ(config.mode_, 0);
1843 ASSERT_EQ(config.homePage_, "");
1844 }
1845
1846 /**
1847 * @tc.name: RemoveProcessWatermarkPid
1848 * @tc.desc: SceneSesionManager RemoveProcessWatermarkPid
1849 * @tc.type: FUNC
1850 */
HWTEST_F(SceneSessionManagerTest, RemoveProcessWatermarkPid, Function | SmallTest | Level3)1851 HWTEST_F(SceneSessionManagerTest, RemoveProcessWatermarkPid, Function | SmallTest | Level3)
1852 {
1853 ssm_->processWatermarkPidMap_.insert({1, "test"});
1854 ssm_->RemoveProcessWatermarkPid(1);
1855 ASSERT_EQ(ssm_->processWatermarkPidMap_.find(1), ssm_->processWatermarkPidMap_.end());
1856 }
1857
1858 /**
1859 * @tc.name: SetSessionWatermarkForAppProcess
1860 * @tc.desc: SceneSesionManager SetSessionWatermarkForAppProcess
1861 * @tc.type: FUNC
1862 */
HWTEST_F(SceneSessionManagerTest, SetSessionWatermarkForAppProcess, Function | SmallTest | Level3)1863 HWTEST_F(SceneSessionManagerTest, SetSessionWatermarkForAppProcess, Function | SmallTest | Level3)
1864 {
1865 SessionInfo info;
1866 sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, nullptr);
1867 sceneSession->SetCallingPid(1);
1868 ASSERT_FALSE(ssm_->SetSessionWatermarkForAppProcess(sceneSession));
1869 ssm_->processWatermarkPidMap_.insert({1, "test"});
1870 ASSERT_TRUE(ssm_->SetSessionWatermarkForAppProcess(sceneSession));
1871 ssm_->processWatermarkPidMap_.erase(1);
1872 }
1873
1874 /**
1875 * @tc.name: CloseTargetFloatWindow
1876 * @tc.desc: SceneSesionManager CloseTargetFloatWindow
1877 * @tc.type: FUNC
1878 */
HWTEST_F(SceneSessionManagerTest, CloseTargetFloatWindow, Function | SmallTest | Level3)1879 HWTEST_F(SceneSessionManagerTest, CloseTargetFloatWindow, Function | SmallTest | Level3)
1880 {
1881 std::string bundleName = "testClose";
1882 auto result = ssm_->CloseTargetFloatWindow(bundleName);
1883 ASSERT_EQ(result, WMError::WM_OK);
1884 }
1885
1886 /**
1887 * @tc.name: CloseTargetPiPWindow
1888 * @tc.desc: SceneSesionManager CloseTargetPiPWindow
1889 * @tc.type: FUNC
1890 */
HWTEST_F(SceneSessionManagerTest, CloseTargetPiPWindow, Function | SmallTest | Level3)1891 HWTEST_F(SceneSessionManagerTest, CloseTargetPiPWindow, Function | SmallTest | Level3)
1892 {
1893 std::string bundleName = "CloseTargetPiPWindow";
1894 auto result = ssm_->CloseTargetPiPWindow(bundleName);
1895 ASSERT_EQ(result, WMError::WM_OK);
1896 }
1897
1898 /**
1899 * @tc.name: GetCurrentPiPWindowInfo01
1900 * @tc.desc: SceneSesionManager GetCurrentPiPWindowInfo
1901 * @tc.type: FUNC
1902 */
HWTEST_F(SceneSessionManagerTest, GetCurrentPiPWindowInfo01, Function | SmallTest | Level3)1903 HWTEST_F(SceneSessionManagerTest, GetCurrentPiPWindowInfo01, Function | SmallTest | Level3)
1904 {
1905 std::string bundleName;
1906 auto result = ssm_->GetCurrentPiPWindowInfo(bundleName);
1907 ASSERT_EQ(result, WMError::WM_OK);
1908 ASSERT_EQ("", bundleName);
1909 }
1910
1911 /**
1912 * @tc.name: GetCurrentPiPWindowInfo02
1913 * @tc.desc: SceneSesionManager GetCurrentPiPWindowInfo
1914 * @tc.type: FUNC
1915 */
HWTEST_F(SceneSessionManagerTest, GetCurrentPiPWindowInfo02, Function | SmallTest | Level3)1916 HWTEST_F(SceneSessionManagerTest, GetCurrentPiPWindowInfo02, Function | SmallTest | Level3)
1917 {
1918 SessionInfo info1;
1919 info1.abilityName_ = "test1";
1920 info1.bundleName_ = "test1";
1921 info1.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_PIP);
1922 sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(info1, nullptr);
1923 ASSERT_NE(nullptr, sceneSession1);
1924 SessionInfo info2;
1925 info2.abilityName_ = "test2";
1926 info2.bundleName_ = "test2";
1927 info2.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_DIALOG);
1928 sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(info2, nullptr);
1929 ASSERT_NE(nullptr, sceneSession2);
1930
1931 ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1});
1932 ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2});
1933 std::string bundleName;
1934 auto result = ssm_->GetCurrentPiPWindowInfo(bundleName);
1935 ASSERT_EQ(result, WMError::WM_OK);
1936 ASSERT_EQ(info1.abilityName_, bundleName);
1937 }
1938
1939 /**
1940 * @tc.name: SkipSnapshotByUserIdAndBundleNames
1941 * @tc.desc: SkipSnapshotByUserIdAndBundleNames
1942 * @tc.type: FUNC
1943 */
HWTEST_F(SceneSessionManagerTest, SkipSnapshotByUserIdAndBundleNames, Function | SmallTest | Level3)1944 HWTEST_F(SceneSessionManagerTest, SkipSnapshotByUserIdAndBundleNames, Function | SmallTest | Level3)
1945 {
1946 ASSERT_NE(nullptr, ssm_);
1947 auto result = ssm_->SkipSnapshotByUserIdAndBundleNames(100, {"TestName"});
1948 ASSERT_EQ(result, WMError::WM_OK);
1949 constexpr uint32_t WAIT_SYNC_IN_NS_ZERO = 500000;
1950 usleep(WAIT_SYNC_IN_NS_ZERO);
1951 ASSERT_NE(ssm_->snapshotSkipBundleNameSet_.find("TestName"), ssm_->snapshotSkipBundleNameSet_.end());
1952
1953 result = ssm_->SkipSnapshotByUserIdAndBundleNames(100, {});
1954 ASSERT_EQ(result, WMError::WM_OK);
1955 constexpr uint32_t WAIT_SYNC_IN_NS_ONE = 500000;
1956 usleep(WAIT_SYNC_IN_NS_ONE);
1957 ASSERT_EQ(ssm_->snapshotSkipBundleNameSet_.find("TestName"), ssm_->snapshotSkipBundleNameSet_.end());
1958
1959 SessionInfo info1;
1960 info1.bundleName_ = "TestName1";
1961 sptr<SceneSession> sceneSession1 = ssm_->CreateSceneSession(info1, nullptr);
1962 SessionInfo info2;
1963 info1.bundleName_ = "TestName2";
1964 sptr<SceneSession> sceneSession2 = ssm_->CreateSceneSession(info2, nullptr);
1965 ASSERT_NE(nullptr, sceneSession1);
1966 ASSERT_NE(nullptr, sceneSession2);
1967 sceneSession1->SetCallingPid(1000);
1968 sceneSession2->SetCallingPid(1001);
1969 ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1});
1970 ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2});
1971 ssm_->sceneSessionMap_.insert({-1, nullptr});
1972 result = ssm_->SkipSnapshotByUserIdAndBundleNames(100, {"TestName1"});
1973 ASSERT_EQ(result, WMError::WM_OK);
1974 ssm_->sceneSessionMap_.erase(sceneSession1->GetPersistentId());
1975 ssm_->sceneSessionMap_.erase(sceneSession2->GetPersistentId());
1976 ssm_->sceneSessionMap_.erase(-1);
1977 constexpr uint32_t WAIT_SYNC_IN_NS_TWO = 1000000;
1978 usleep(WAIT_SYNC_IN_NS_TWO);
1979 }
1980
1981 /**
1982 * @tc.name: SetSessionSnapshotSkipForAppBundleName
1983 * @tc.desc: SceneSesionManager SetSessionSnapshotSkipForAppBundleName
1984 * @tc.type: FUNC
1985 */
HWTEST_F(SceneSessionManagerTest, SetSessionSnapshotSkipForAppBundleName, Function | SmallTest | Level3)1986 HWTEST_F(SceneSessionManagerTest, SetSessionSnapshotSkipForAppBundleName, Function | SmallTest | Level3)
1987 {
1988 SessionInfo info;
1989 info.bundleName_ = "TestName";
1990 sptr<SceneSession> sceneSession = ssm_->CreateSceneSession(info, nullptr);
1991 struct RSSurfaceNodeConfig config;
1992 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
1993 sceneSession->surfaceNode_ = surfaceNode;
1994 ssm_->SetSessionSnapshotSkipForAppBundleName(sceneSession);
1995 ASSERT_EQ(sceneSession->GetSessionProperty()->GetSnapshotSkip(), false);
1996
1997 ssm_->snapshotSkipBundleNameSet_.insert("TestName");
1998 ssm_->SetSessionSnapshotSkipForAppBundleName(sceneSession);
1999 ASSERT_EQ(sceneSession->GetSessionProperty()->GetSnapshotSkip(), true);
2000 ssm_->snapshotSkipBundleNameSet_.erase("TestName");
2001 }
2002
2003 /**
2004 * @tc.name: GetRootMainWindowId
2005 * @tc.desc: SceneSesionManager GetRootMainWindowId
2006 * @tc.type: FUNC
2007 */
HWTEST_F(SceneSessionManagerTest, GetRootMainWindowId, Function | SmallTest | Level3)2008 HWTEST_F(SceneSessionManagerTest, GetRootMainWindowId, Function | SmallTest | Level3)
2009 {
2010 SessionInfo info1;
2011 info1.abilityName_ = "test1";
2012 info1.bundleName_ = "test1";
2013 info1.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
2014 sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(info1, nullptr);
2015 ASSERT_NE(nullptr, sceneSession1);
2016 SessionInfo info2;
2017 info2.abilityName_ = "test2";
2018 info2.bundleName_ = "test2";
2019 info2.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
2020 sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(info2, nullptr);
2021 ASSERT_NE(nullptr, sceneSession2);
2022 sceneSession2->SetParentSession(sceneSession1);
2023
2024 ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1});
2025 ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2});
2026 int32_t hostWindowId = -1;
2027 auto result = ssm_->GetRootMainWindowId(sceneSession2->GetPersistentId(), hostWindowId);
2028 ASSERT_EQ(result, WMError::WM_OK);
2029 ASSERT_EQ(hostWindowId, sceneSession1->GetPersistentId());
2030 }
2031
2032 /**
2033 * @tc.name: ReleaseForegroundSessionScreenLock
2034 * @tc.desc: release screen lock of foreground session
2035 * @tc.type: FUNC
2036 */
HWTEST_F(SceneSessionManagerTest, ReleaseForegroundSessionScreenLock, Function | SmallTest | Level3)2037 HWTEST_F(SceneSessionManagerTest, ReleaseForegroundSessionScreenLock, Function | SmallTest | Level3)
2038 {
2039 auto result = ssm_->ReleaseForegroundSessionScreenLock();
2040 ASSERT_EQ(result, WMError::WM_OK);
2041 }
2042
2043 /**
2044 * @tc.name: UpdateAppHookDisplayInfo001
2045 * @tc.desc: Test delete HookDisplayInfo
2046 * @tc.type: FUNC
2047 */
HWTEST_F(SceneSessionManagerTest, UpdateAppHookDisplayInfo001, Function | SmallTest | Level3)2048 HWTEST_F(SceneSessionManagerTest, UpdateAppHookDisplayInfo001, Function | SmallTest | Level3)
2049 {
2050 int32_t uid = 0;
2051 bool enable = false;
2052 HookInfo hookInfo;
2053 hookInfo.width_ = 100;
2054 hookInfo.height_ = 100;
2055 hookInfo.density_ = 2.25;
2056 hookInfo.rotation_ = 0;
2057 hookInfo.enableHookRotation_ = false;
2058 auto result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
2059 ASSERT_EQ(result, WMError::WM_OK);
2060
2061 uid = 20221524;
2062 hookInfo.width_ = 0;
2063 result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
2064 ASSERT_EQ(result, WMError::WM_OK);
2065
2066 hookInfo.width_ = 100;
2067 hookInfo.height_ = 0;
2068 result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
2069 ASSERT_EQ(result, WMError::WM_OK);
2070
2071 hookInfo.height_ = 100;
2072 hookInfo.density_ = 0;
2073 result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
2074 ASSERT_EQ(result, WMError::WM_OK);
2075
2076 hookInfo.density_ = 2.25;
2077 result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
2078 ASSERT_EQ(result, WMError::WM_OK);
2079 }
2080
2081 /**
2082 * @tc.name: UpdateAppHookDisplayInfo002
2083 * @tc.desc: Test add HookDisplayInfo
2084 * @tc.type: FUNC
2085 */
HWTEST_F(SceneSessionManagerTest, UpdateAppHookDisplayInfo002, Function | SmallTest | Level3)2086 HWTEST_F(SceneSessionManagerTest, UpdateAppHookDisplayInfo002, Function | SmallTest | Level3)
2087 {
2088 int32_t uid = 0;
2089 bool enable = true;
2090 HookInfo hookInfo;
2091 hookInfo.width_ = 100;
2092 hookInfo.height_ = 100;
2093 hookInfo.density_ = 2.25;
2094 hookInfo.rotation_ = 0;
2095 hookInfo.enableHookRotation_ = false;
2096 auto result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
2097 ASSERT_EQ(result, WMError::WM_ERROR_INVALID_PARAM);
2098
2099 uid = 20221524;
2100 hookInfo.width_ = 0;
2101 result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
2102 ASSERT_EQ(result, WMError::WM_ERROR_INVALID_PARAM);
2103
2104 hookInfo.width_ = 100;
2105 hookInfo.height_ = 0;
2106 result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
2107 ASSERT_EQ(result, WMError::WM_ERROR_INVALID_PARAM);
2108
2109 hookInfo.height_ = 100;
2110 hookInfo.density_ = 0;
2111 result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
2112 ASSERT_EQ(result, WMError::WM_ERROR_INVALID_PARAM);
2113
2114 hookInfo.density_ = 2.25;
2115 result = ssm_->UpdateAppHookDisplayInfo(uid, hookInfo, enable);
2116 ASSERT_EQ(result, WMError::WM_OK);
2117 }
2118
2119 /**
2120 * @tc.name: IsPcOrPadFreeMultiWindowMode
2121 * @tc.desc: IsPcOrPadFreeMultiWindowMode
2122 * @tc.type: FUNC
2123 */
HWTEST_F(SceneSessionManagerTest, IsPcOrPadFreeMultiWindowMode, Function | SmallTest | Level3)2124 HWTEST_F(SceneSessionManagerTest, IsPcOrPadFreeMultiWindowMode, Function | SmallTest | Level3)
2125 {
2126 bool isPcOrPadFreeMultiWindowMode = false;
2127 auto result = ssm_->IsPcOrPadFreeMultiWindowMode(isPcOrPadFreeMultiWindowMode);
2128 ASSERT_EQ(result, WMError::WM_OK);
2129 }
2130 }
2131 } // namespace Rosen
2132 } // namespace OHOS
2133