• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <gtest/gtest.h>
17 
18 #include <bundlemgr/launcher_service.h>
19 #include "interfaces/include/ws_common.h"
20 #include "session_manager/include/scene_session_manager.h"
21 #include "session_info.h"
22 #include "session/host/include/scene_session.h"
23 #include "session_manager.h"
24 #include "session/host/include/scene_session.h"
25 #include "mock/mock_ibundle_mgr.h"
26 #include "common/include/task_scheduler.h"
27 #include "session/host/include/multi_instance_manager.h"
28 
29 using namespace testing;
30 using namespace testing::ext;
31 
32 namespace OHOS {
33 namespace Rosen {
34 namespace {
35     const std::string BUNDLE_NAME = "bundleName";
36     const int32_t USER_ID { 100 };
37     const int32_t SLEEP_TIME { 10000 };
38 }
39 class SceneSessionManagerTest11 : public testing::Test {
40 public:
41     static void SetUpTestCase();
42     static void TearDownTestCase();
43     void SetUp() override;
44     void TearDown() override;
45 
46     static sptr<SceneSessionManager> ssm_;
47 private:
48     sptr<SceneSession> GetSceneSession(const std::string& instanceKey = "");
49     void Init(AppExecFwk::MultiAppModeType modeType, uint32_t maxCount);
50     std::shared_ptr<TaskScheduler> GetTaskScheduler();
51 };
52 
53 sptr<SceneSessionManager> SceneSessionManagerTest11::ssm_ = nullptr;
54 
SetUpTestCase()55 void SceneSessionManagerTest11::SetUpTestCase()
56 {
57     ssm_ = &SceneSessionManager::GetInstance();
58     ssm_->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
59 }
60 
TearDownTestCase()61 void SceneSessionManagerTest11::TearDownTestCase()
62 {
63     ssm_ = nullptr;
64 }
65 
SetUp()66 void SceneSessionManagerTest11::SetUp()
67 {
68 }
69 
TearDown()70 void SceneSessionManagerTest11::TearDown()
71 {
72     sptr<IBundleMgrMocker> bundleMgrMocker = sptr<IBundleMgrMocker>::MakeSptr();
73     EXPECT_CALL(*bundleMgrMocker, GetApplicationInfo(_, _, _, _)).WillOnce(Return(false));
74     MultiInstanceManager::GetInstance().Init(bundleMgrMocker, GetTaskScheduler());
75     ssm_->RefreshAppInfo(BUNDLE_NAME);
76     usleep(SLEEP_TIME);
77 }
78 
GetSceneSession(const std::string & instanceKey)79 sptr<SceneSession> SceneSessionManagerTest11::GetSceneSession(const std::string& instanceKey)
80 {
81     SessionInfo info;
82     info.bundleName_ = BUNDLE_NAME;
83     info.appInstanceKey_ = instanceKey;
84     info.isNewAppInstance_ = true;
85     sptr<SceneSession::SpecificSessionCallback> specificCb = sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
86     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, specificCb);
87     return sceneSession;
88 }
89 
Init(AppExecFwk::MultiAppModeType modeType,uint32_t maxCount)90 void SceneSessionManagerTest11::Init(AppExecFwk::MultiAppModeType modeType, uint32_t maxCount)
91 {
92     sptr<IBundleMgrMocker> bundleMgrMocker = sptr<IBundleMgrMocker>::MakeSptr();
93     EXPECT_CALL(*bundleMgrMocker, GetApplicationInfos(_, _, _)).WillOnce([modeType, maxCount](
94         const AppExecFwk::ApplicationFlag flag, const int32_t userId,
95         std::vector<AppExecFwk::ApplicationInfo>& appInfos) {
96         AppExecFwk::ApplicationInfo appInfo;
97         appInfo.bundleName = BUNDLE_NAME;
98         appInfo.multiAppMode.multiAppModeType = modeType;
99         appInfo.multiAppMode.maxCount = maxCount;
100         appInfos.push_back(appInfo);
101         return true;
102     });
103     MultiInstanceManager::GetInstance().Init(bundleMgrMocker, GetTaskScheduler());
104     MultiInstanceManager::GetInstance().SetCurrentUserId(USER_ID);
105     usleep(SLEEP_TIME);
106 }
107 
GetTaskScheduler()108 std::shared_ptr<TaskScheduler> SceneSessionManagerTest11::GetTaskScheduler()
109 {
110     std::string threadName = "threadName";
111     std::shared_ptr<TaskScheduler> taskScheduler = std::make_shared<TaskScheduler>(threadName);
112     return taskScheduler;
113 }
114 
115 namespace {
116 /**
117  * @tc.name: GetMainWindowStatesByPid
118  * @tc.desc: SceneSesionManager get main window states by pid
119  * @tc.type: FUNC
120  */
121 HWTEST_F(SceneSessionManagerTest11, GetMainWindowStatesByPid, Function | SmallTest | Level3)
122 {
123     int32_t pid = 100;
124     std::vector<MainWindowState> windowStates;
125     WSError result = ssm_->GetMainWindowStatesByPid(pid, windowStates);
126     EXPECT_EQ(result, WSError::WS_OK);
127 }
128 
129 /**
130  * @tc.name: GetMainWindowStatesByPid02
131  * @tc.desc: SceneSesionManager get main window states by pid
132  * @tc.type: FUNC
133  */
134 HWTEST_F(SceneSessionManagerTest11, GetMainWindowStatesByPid02, Function | SmallTest | Level3)
135 {
136     int32_t invalidPid = -1;
137     std::vector<MainWindowState> windowStates;
138     WSError result = ssm_->GetMainWindowStatesByPid(invalidPid, windowStates);
139     EXPECT_EQ(result, WSError::WS_ERROR_INVALID_PARAM);
140 }
141 
142 /**
143  * @tc.name: GetMainWindowStatesByPid03
144  * @tc.desc: SceneSesionManager get main window states by pid
145  * @tc.type: FUNC
146  */
147 HWTEST_F(SceneSessionManagerTest11, GetMainWindowStatesByPid03, Function | SmallTest | Level3)
148 {
149     SessionState sessionState = SessionState::STATE_FOREGROUND;
150     bool isVisible = true;
151     bool isForegroundInteractive = true;
152     bool isPcOrPadEnableActivation = true;
153     int32_t callingPid = 1001;
154     SessionInfo sessionInfo;
155     int32_t persistentId = 1005;
156     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
157     EXPECT_NE(sceneSession, nullptr);
158     sceneSession->SetSessionState(sessionState);
159     sceneSession->SetRSVisible(isVisible);
160     sceneSession->SetForegroundInteractiveStatus(isForegroundInteractive);
161     sceneSession->GetSessionProperty()->SetIsPcAppInPad(isPcOrPadEnableActivation);
162     sceneSession->SetCallingPid(callingPid);
163     ssm_->sceneSessionMap_.insert({ persistentId, sceneSession });
164     std::vector<MainWindowState> windowStates;
165     WSError result = ssm_->GetMainWindowStatesByPid(callingPid, windowStates);
166     EXPECT_EQ(result, WSError::WS_OK);
167     EXPECT_EQ(windowStates.size(), 1);
168     EXPECT_EQ(windowStates[0].state_, static_cast<int32_t>(sessionState));
169     EXPECT_EQ(windowStates[0].isVisible_, isVisible);
170     EXPECT_EQ(windowStates[0].isForegroundInteractive_, isForegroundInteractive);
171     EXPECT_EQ(windowStates[0].isPcOrPadEnableActivation_, isPcOrPadEnableActivation);
172 }
173 
174 /**
175  * @tc.name: GetMaxInstanceCount
176  * @tc.desc: test function : GetMaxInstanceCount
177  * @tc.type: FUNC
178  */
179 HWTEST_F(SceneSessionManagerTest11, GetMaxInstanceCount, Function | SmallTest | Level1)
180 {
181     AppExecFwk::MultiAppModeType modeType = AppExecFwk::MultiAppModeType::MULTI_INSTANCE;
182     uint32_t maxCount = 5;
183     Init(modeType, maxCount);
184     ASSERT_EQ(ssm_->GetMaxInstanceCount(BUNDLE_NAME), maxCount);
185 }
186 
187 /**
188  * @tc.name: GetInstanceCount
189  * @tc.desc: test function : GetInstanceCount
190  * @tc.type: FUNC
191  */
192 HWTEST_F(SceneSessionManagerTest11, GetInstanceCount, Function | SmallTest | Level1)
193 {
194     AppExecFwk::MultiAppModeType modeType = AppExecFwk::MultiAppModeType::MULTI_INSTANCE;
195     uint32_t maxCount = 5;
196     Init(modeType, maxCount);
197     ASSERT_EQ(ssm_->GetInstanceCount(BUNDLE_NAME), 0);
198     std::string instanceKey0 = "app_instance_0";
199     sptr<SceneSession> sceneSession = GetSceneSession(instanceKey0);
200     ASSERT_EQ(MultiInstanceManager::GetInstance().CreateNewInstanceKey(BUNDLE_NAME), instanceKey0);
201     MultiInstanceManager::GetInstance().IncreaseInstanceKeyRefCount(sceneSession);
202     ASSERT_EQ(ssm_->GetInstanceCount(BUNDLE_NAME), 1);
203     MultiInstanceManager::GetInstance().DecreaseInstanceKeyRefCount(sceneSession);
204     ASSERT_EQ(ssm_->GetInstanceCount(BUNDLE_NAME), 0);
205 }
206 
207 /**
208  * @tc.name: GetLastInstanceKey
209  * @tc.desc: test function : GetLastInstanceKey
210  * @tc.type: FUNC
211  */
212 HWTEST_F(SceneSessionManagerTest11, GetLastInstanceKey, Function | SmallTest | Level1)
213 {
214     AppExecFwk::MultiAppModeType modeType = AppExecFwk::MultiAppModeType::MULTI_INSTANCE;
215     uint32_t maxCount = 5;
216     Init(modeType, maxCount);
217     ASSERT_EQ(ssm_->GetLastInstanceKey(BUNDLE_NAME), "");
218     std::string instanceKey0 = "app_instance_0";
219     sptr<SceneSession> sceneSession = GetSceneSession(instanceKey0);
220     ASSERT_EQ(MultiInstanceManager::GetInstance().CreateNewInstanceKey(BUNDLE_NAME), instanceKey0);
221     MultiInstanceManager::GetInstance().IncreaseInstanceKeyRefCount(sceneSession);
222     ASSERT_EQ(ssm_->GetLastInstanceKey(BUNDLE_NAME), instanceKey0);
223     MultiInstanceManager::GetInstance().DecreaseInstanceKeyRefCount(sceneSession);
224     ASSERT_EQ(ssm_->GetLastInstanceKey(BUNDLE_NAME), "");
225 }
226 
227 /**
228  * @tc.name: UpdateOccupiedAreaIfNeed
229  * @tc.desc: SceneSesionManager update occupiedArea
230  * @tc.type: FUNC
231  */
232 HWTEST_F(SceneSessionManagerTest11, UpdateOccupiedAreaIfNeed, Function | SmallTest | Level1)
233 {
234     int ret = 0;
235     int32_t persistentId = 0;
236     SessionInfo info;
237     info.abilityName_ = "test1";
238     info.bundleName_ = "test2";
239     info.moduleName_ = "test3";
240     info.persistentId_ = 1;
241     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
242     ASSERT_NE(nullptr, sceneSession);
243     ssm_->sceneSessionMap_.insert({1, sceneSession});
244     ssm_->UpdateOccupiedAreaIfNeed(persistentId);
245 
246     sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
247     ssm_->UpdateOccupiedAreaIfNeed(persistentId);
248 
249     persistentId = 1;
250     ssm_->UpdateOccupiedAreaIfNeed(persistentId);
251 
252     ssm_->sceneSessionMap_.erase(1);
253     ASSERT_EQ(ret, 0);
254 }
255 
256 /**
257  * @tc.name: GetAllSessionDumpDetailInfo
258  * @tc.desc: SceneSesionManager test GetAllSessionDumpDetailInfo
259  * @tc.type: FUNC
260  */
261 HWTEST_F(SceneSessionManagerTest11, GetAllSessionDumpDetailInfo, Function | SmallTest | Level1)
262 {
263     SessionInfo info1;
264     info1.abilityName_ = "GetAllSessionDumpDetailInfo1";
265     info1.bundleName_ = "GetAllSessionDumpDetailInfo1";
266     info1.persistentId_ = 1;
267     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(info1, nullptr);
268     ASSERT_NE(sceneSession1, nullptr);
269     sceneSession1->UpdateNativeVisibility(true);
270 
271     SessionInfo info2;
272     info2.abilityName_ = "GetAllSessionDumpDetailInfo2";
273     info2.bundleName_ = "GetAllSessionDumpDetailInfo2";
274     info2.persistentId_ = 2;
275     sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(info2, nullptr);
276     ASSERT_NE(sceneSession2, nullptr);
277     sceneSession2->UpdateNativeVisibility(false);
278 
279     ssm_->sceneSessionMap_.insert({0, nullptr});
280     ssm_->sceneSessionMap_.insert({1, sceneSession1});
281     ssm_->sceneSessionMap_.insert({2, sceneSession2});
282     std::string dumpInfo;
283     ASSERT_EQ(ssm_->GetAllSessionDumpDetailInfo(dumpInfo), WSError::WS_OK);
284 }
285 
286 /**
287  * @tc.name: GetAbilityInfo
288  * @tc.desc: SceneSesionManager test GetAbilityInfo
289  * @tc.type: FUNC
290  */
291 HWTEST_F(SceneSessionManagerTest11, GetAbilityInfo, Function | SmallTest | Level1)
292 {
293     ssm_->bundleMgr_ = nullptr;
294     std::string bundleName = "bundleName";
295     std::string moduleName = "moduleName";
296     std::string abilityName = "abilityName";
297     int32_t userId = 100;
298     SCBAbilityInfo scbAbilityInfo;
299     WSError ret = ssm_->GetAbilityInfo(bundleName, moduleName, abilityName, userId, scbAbilityInfo);
300     ASSERT_EQ(ret, WSError::WS_ERROR_NULLPTR);
301 }
302 
303 /**
304  * @tc.name: GetAbilityInfo02
305  * @tc.desc: SceneSesionManager test GetAbilityInfo
306  * @tc.type: FUNC
307  */
308 HWTEST_F(SceneSessionManagerTest11, GetAbilityInfo02, Function | SmallTest | Level1)
309 {
310     sptr<IBundleMgrMocker> bundleMgrMocker = sptr<IBundleMgrMocker>::MakeSptr();
311     EXPECT_CALL(*bundleMgrMocker, GetBundleInfoV9(_, _, _, _)).WillOnce(Return(1));
312     ssm_->bundleMgr_ = bundleMgrMocker;
313     std::string bundleName = "bundleName";
314     std::string moduleName = "moduleName";
315     std::string abilityName = "abilityName";
316     int32_t userId = 100;
317     SCBAbilityInfo scbAbilityInfo;
318     WSError ret = ssm_->GetAbilityInfo(bundleName, moduleName, abilityName, userId, scbAbilityInfo);
319     ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_PARAM);
320 }
321 
322 /**
323  * @tc.name: GetAbilityInfo03
324  * @tc.desc: SceneSesionManager test GetAbilityInfo
325  * @tc.type: FUNC
326  */
327 HWTEST_F(SceneSessionManagerTest11, GetAbilityInfo03, Function | SmallTest | Level1)
328 {
329     sptr<IBundleMgrMocker> bundleMgrMocker = sptr<IBundleMgrMocker>::MakeSptr();
330     EXPECT_CALL(*bundleMgrMocker, GetBundleInfoV9(_, _, _, _)).WillOnce([](
__anonde01b2860402( const std::string& bundleName, int32_t flags, AppExecFwk::BundleInfo& bundleInfo, int32_t userId) 331         const std::string& bundleName, int32_t flags, AppExecFwk::BundleInfo& bundleInfo, int32_t userId) {
332         bundleInfo.hapModuleInfos = {};
333         return 0;
334     });
335     ssm_->bundleMgr_ = bundleMgrMocker;
336     std::string bundleName = "bundleName";
337     std::string moduleName = "moduleName";
338     std::string abilityName = "abilityName";
339     int32_t userId = 100;
340     SCBAbilityInfo scbAbilityInfo;
341     WSError ret = ssm_->GetAbilityInfo(bundleName, moduleName, abilityName, userId, scbAbilityInfo);
342     ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_PARAM);
343 }
344 
345 /**
346  * @tc.name: GetAbilityInfo04
347  * @tc.desc: SceneSesionManager test GetAbilityInfo
348  * @tc.type: FUNC
349  */
350 HWTEST_F(SceneSessionManagerTest11, GetAbilityInfo04, Function | SmallTest | Level1)
351 {
352     sptr<IBundleMgrMocker> bundleMgrMocker = sptr<IBundleMgrMocker>::MakeSptr();
353     EXPECT_CALL(*bundleMgrMocker, GetBundleInfoV9(_, _, _, _)).WillOnce([](
__anonde01b2860502( const std::string& bundleName, int32_t flags, AppExecFwk::BundleInfo& bundleInfo, int32_t userId) 354         const std::string& bundleName, int32_t flags, AppExecFwk::BundleInfo& bundleInfo, int32_t userId) {
355         AppExecFwk::AbilityInfo abilityInfo;
356         abilityInfo.moduleName = "moduleName";
357         abilityInfo.name = "abilityName";
358         AppExecFwk::HapModuleInfo hapModuleInfo;
359         hapModuleInfo.abilityInfos = { abilityInfo };
360         bundleInfo.hapModuleInfos = { hapModuleInfo };
361         bundleInfo.applicationInfo.codePath = "testCodePath";
362         return 0;
363     });
364     ssm_->bundleMgr_ = bundleMgrMocker;
365     std::string bundleName = "bundleName";
366     std::string moduleName = "moduleName";
367     std::string abilityName = "abilityName";
368     int32_t userId = 100;
369     SCBAbilityInfo scbAbilityInfo;
370     WSError ret = ssm_->GetAbilityInfo(bundleName, moduleName, abilityName, userId, scbAbilityInfo);
371     ASSERT_EQ(ret, WSError::WS_OK);
372     ASSERT_EQ(scbAbilityInfo.codePath_, "testCodePath");
373 }
374 
375 /**
376  * @tc.name: GetAbilityInfo05
377  * @tc.desc: SceneSesionManager test GetAbilityInfo
378  * @tc.type: FUNC
379  */
380 HWTEST_F(SceneSessionManagerTest11, GetAbilityInfo05, Function | SmallTest | Level1)
381 {
382     sptr<IBundleMgrMocker> bundleMgrMocker = sptr<IBundleMgrMocker>::MakeSptr();
383     EXPECT_CALL(*bundleMgrMocker, GetBundleInfoV9(_, _, _, _)).WillOnce([](
__anonde01b2860602( const std::string& bundleName, int32_t flags, AppExecFwk::BundleInfo& bundleInfo, int32_t userId) 384         const std::string& bundleName, int32_t flags, AppExecFwk::BundleInfo& bundleInfo, int32_t userId) {
385         AppExecFwk::AbilityInfo abilityInfo;
386         abilityInfo.moduleName = "moduleName2";
387         abilityInfo.name = "abilityName2";
388         AppExecFwk::HapModuleInfo hapModuleInfo;
389         hapModuleInfo.abilityInfos = { abilityInfo };
390         bundleInfo.hapModuleInfos = { hapModuleInfo };
391         return 0;
392     });
393     ssm_->bundleMgr_ = bundleMgrMocker;
394     std::string bundleName = "bundleName";
395     std::string moduleName = "moduleName";
396     std::string abilityName = "abilityName";
397     int32_t userId = 100;
398     SCBAbilityInfo scbAbilityInfo;
399     WSError ret = ssm_->GetAbilityInfo(bundleName, moduleName, abilityName, userId, scbAbilityInfo);
400     ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_PARAM);
401 }
402 
403 /**
404  * @tc.name: LockSessionByAbilityInfo
405  * @tc.desc: SceneSesionManager test LockSessionByAbilityInfo
406  * @tc.type: FUNC
407  */
408 HWTEST_F(SceneSessionManagerTest11, LockSessionByAbilityInfo, Function | SmallTest | Level1)
409 {
410     ASSERT_NE(ssm_, nullptr);
411     AbilityInfoBase abilityInfo;
412     abilityInfo.bundleName = "LockSessionByAbilityInfoBundle";
413     abilityInfo.moduleName = "LockSessionByAbilityInfoModule";
414     abilityInfo.abilityName = "LockSessionByAbilityInfoAbility";
415     abilityInfo.appIndex = 0;
416 
417     auto result = ssm_->LockSessionByAbilityInfo(abilityInfo, true);
418     ASSERT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, result);
419 }
420 
421 /**
422  * @tc.name: NotifyWatchGestureConsumeResult
423  * @tc.desc: SceneSesionManager test NotifyWatchGestureConsumeResult
424  * @tc.type: FUNC
425  */
426 HWTEST_F(SceneSessionManagerTest11, NotifyWatchGestureConsumeResult, Function | SmallTest | Level1)
427 {
428     ASSERT_NE(ssm_, nullptr);
429     int32_t keyCode = 0;
430     bool isConsumed = true;
__anonde01b2860702(int32_t keyCode, bool isConsumed) 431     ssm_->onWatchGestureConsumeResultFunc_ = [](int32_t keyCode, bool isConsumed) {};
432     auto ret = ssm_->NotifyWatchGestureConsumeResult(keyCode, isConsumed);
433     ASSERT_EQ(ret, WMError::WM_OK);
434 
435     ssm_->onWatchGestureConsumeResultFunc_ = nullptr;
436     ret = ssm_->NotifyWatchGestureConsumeResult(keyCode, isConsumed);
437     ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_PARAM);
438 }
439 
440 /**
441  * @tc.name: NotifyWatchFocusActiveChange
442  * @tc.desc: SceneSesionManager test NotifyWatchFocusActiveChange
443  * @tc.type: FUNC
444  */
445 HWTEST_F(SceneSessionManagerTest11, NotifyWatchFocusActiveChange, Function | SmallTest | Level1)
446 {
447     ASSERT_NE(ssm_, nullptr);
448     bool isActive = true;
__anonde01b2860802(bool isActive) 449     ssm_->onWatchFocusActiveChangeFunc_ = [](bool isActive) {};
450     auto ret = ssm_->NotifyWatchFocusActiveChange(isActive);
451     ASSERT_EQ(ret, WMError::WM_OK);
452 
453     ssm_->onWatchFocusActiveChangeFunc_ = nullptr;
454     ret = ssm_->NotifyWatchFocusActiveChange(isActive);
455     ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_PARAM);
456 }
457 
458 /**
459  * @tc.name: DestroyUIServiceExtensionSubWindow
460  * @tc.desc: SceneSesionManager test DestroyUIServiceExtensionSubWindow
461  * @tc.type: FUNC
462  */
463 HWTEST_F(SceneSessionManagerTest11, DestroyUIServiceExtensionSubWindow, Function | SmallTest | Level1)
464 {
465     ASSERT_NE(ssm_, nullptr);
466     sptr<SceneSession> sceneSession = nullptr;
467     ssm_->DestroyUIServiceExtensionSubWindow(sceneSession);
468     SessionInfo sessionInfo = { "bundleName", "moduleName", "abilityName" };
469     sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
470     ssm_->DestroyUIServiceExtensionSubWindow(sceneSession);
471 
472     sptr<WindowSessionProperty> property_ = sptr<WindowSessionProperty>::MakeSptr();
473     property_->isUIExtFirstSubWindow_ = true;
474     ASSERT_EQ(property_->isUIExtAnySubWindow_, false);
475     ssm_->DestroyUIServiceExtensionSubWindow(sceneSession);
476 }
477 
478 /**
479  * @tc.name: FilterForGetAllWindowLayoutInfo
480  * @tc.desc: SceneSesionManager test FilterForGetAllWindowLayoutInfo
481  * @tc.type: FUNC
482  */
483 HWTEST_F(SceneSessionManagerTest11, FilterForGetAllWindowLayoutInfo, Function | SmallTest | Level1)
484 {
485     ASSERT_NE(ssm_, nullptr);
486     DisplayId displayId = 0;
487     bool isVirtualDisplay = true;
488     std::vector<sptr<SceneSession>> filteredSessions{};
489     SessionInfo info;
490     info.bundleName_ = BUNDLE_NAME;
491     info.appInstanceKey_ = "instanceKey";
492     info.isNewAppInstance_ = true;
493     sptr<SceneSession::SpecificSessionCallback> specificCb = sptr<SceneSession::SpecificSessionCallback>::MakeSptr();
494     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, specificCb);
495     ssm_->sceneSessionMap_.clear();
496     auto ret = ssm_->sceneSessionMap_.size();
497     ASSERT_EQ(ret, 0);
498     ssm_->FilterForGetAllWindowLayoutInfo(displayId, isVirtualDisplay, filteredSessions);
499     ssm_->sceneSessionMap_.insert({ 1, sceneSession });
500     ssm_->FilterForGetAllWindowLayoutInfo(displayId, isVirtualDisplay, filteredSessions);
501 }
502 
503 /**
504  * @tc.name: ShiftAppWindowPointerEvent
505  * @tc.desc: SceneSesionManager test ShiftAppWindowPointerEvent
506  * @tc.type: FUNC
507  */
508 HWTEST_F(SceneSessionManagerTest11, ShiftAppWindowPointerEvent, Function | SmallTest | Level1)
509 {
510     ASSERT_NE(ssm_, nullptr);
511     int32_t sourcePersistentId = 0;
512     int32_t targetPersistentId = 0;
513     ssm_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
514     auto ret = ssm_->systemConfig_.IsPcWindow();
515     ASSERT_EQ(ret, false);
516 
517     auto res = ssm_->ShiftAppWindowPointerEvent(sourcePersistentId, targetPersistentId);
518     ASSERT_EQ(res, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
519 
520     ssm_->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
521     ssm_->systemConfig_.freeMultiWindowEnable_ = true;
522     ssm_->systemConfig_.freeMultiWindowSupport_ = true;
523     res = ssm_->ShiftAppWindowPointerEvent(sourcePersistentId, targetPersistentId);
524     ASSERT_EQ(res, WMError::WM_ERROR_INVALID_CALLING);
525 
526     sourcePersistentId = 1;
527     ssm_->sceneSessionMap_.clear();
528     res = ssm_->ShiftAppWindowPointerEvent(sourcePersistentId, targetPersistentId);
529     ASSERT_EQ(res, WMError::WM_ERROR_INVALID_SESSION);
530 }
531 
532 /**
533  * @tc.name: HasFloatingWindowForeground
534  * @tc.desc: SceneSesionManager test HasFloatingWindowForeground
535  * @tc.type: FUNC
536  */
537 HWTEST_F(SceneSessionManagerTest11, HasFloatingWindowForeground, Function | SmallTest | Level1)
538 {
539     ASSERT_NE(ssm_, nullptr);
540     sptr<IRemoteObject> abilityToken = nullptr;
541     bool hasOrNot = true;
542     auto ret = ssm_->HasFloatingWindowForeground(abilityToken, hasOrNot);
543     ASSERT_EQ(ret, WMError::WM_ERROR_NULLPTR);
544 }
545 
546 /**
547  * @tc.name: SetParentWindow
548  * @tc.desc: SceneSesionManager test SetParentWindow
549  * @tc.type: FUNC
550  */
551 HWTEST_F(SceneSessionManagerTest11, SetParentWindow, Function | SmallTest | Level1)
552 {
553     ASSERT_NE(ssm_, nullptr);
554     int32_t subWindowId = 1;
555     int32_t newParentWindowId = 3;
556     auto res = ssm_->SetParentWindow(subWindowId, newParentWindowId);
557     EXPECT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW);
558     SessionInfo info;
559     info.abilityName_ = "SetParentWindow";
560     info.bundleName_ = "SetParentWindow";
561     sptr<SceneSession> subSession = sptr<SceneSession>::MakeSptr(info, nullptr);
562     subSession->property_->SetPersistentId(1);
563     subSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
564     ssm_->sceneSessionMap_.insert({ subSession->property_->GetPersistentId(), subSession });
565     res = ssm_->SetParentWindow(subWindowId, newParentWindowId);
566     EXPECT_EQ(res, WMError::WM_ERROR_INVALID_PARENT);
567 
568     sptr<SceneSession> oldParentSession = sptr<SceneSession>::MakeSptr(info, nullptr);
569     oldParentSession->property_->SetPersistentId(2);
570     oldParentSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
571     ssm_->sceneSessionMap_.insert({ oldParentSession->property_->GetPersistentId(), oldParentSession });
572     subSession->property_->SetParentPersistentId(2);
573     subSession->SetParentSession(oldParentSession);
574     res = ssm_->SetParentWindow(subWindowId, newParentWindowId);
575     EXPECT_EQ(res, WMError::WM_ERROR_INVALID_PARENT);
576 
577     sptr<SceneSession> newParentSession = sptr<SceneSession>::MakeSptr(info, nullptr);
578     newParentSession->property_->SetPersistentId(3);
579     newParentSession->property_->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
580     ssm_->sceneSessionMap_.insert({ newParentSession->property_->GetPersistentId(), newParentSession });
581     res = ssm_->SetParentWindow(subWindowId, newParentWindowId);
582     EXPECT_EQ(res, WMError::WM_ERROR_INVALID_PARENT);
583 
584     newParentSession->property_->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
585     res = ssm_->SetParentWindow(subWindowId, newParentWindowId);
586     EXPECT_EQ(res, WMError::WM_OK);
587 }
588 }  // namespace
589 }
590 }