• 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 "iremote_object_mocker.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 
25 using namespace testing;
26 using namespace testing::ext;
27 
28 namespace OHOS {
29 namespace Rosen {
30 
31 class SceneSessionManagerTest8 : public testing::Test {
32 public:
33     static void SetUpTestCase();
34     static void TearDownTestCase();
35     void SetUp();
36     void TearDown();
37 private:
38     sptr<SceneSessionManager> ssm_;
39     static constexpr uint32_t WAIT_SYNC_IN_NS = 500000;
40 };
41 
SetUpTestCase()42 void SceneSessionManagerTest8::SetUpTestCase()
43 {
44 }
45 
TearDownTestCase()46 void SceneSessionManagerTest8::TearDownTestCase()
47 {
48 }
49 
SetUp()50 void SceneSessionManagerTest8::SetUp()
51 {
52     ssm_ = sptr<SceneSessionManager>::MakeSptr();
53     EXPECT_NE(nullptr, ssm_);
54     ssm_->sceneSessionMap_.clear();
55 }
56 
TearDown()57 void SceneSessionManagerTest8::TearDown()
58 {
59     ssm_->sceneSessionMap_.clear();
60     usleep(WAIT_SYNC_IN_NS);
61     ssm_ = nullptr;
62 }
63 
64 namespace {
65 /**
66  * @tc.name: GetTotalUITreeInfo
67  * @tc.desc: GetTotalUITreeInfo set gesture navigation enabled
68  * @tc.type: FUNC
69  */
70 HWTEST_F(SceneSessionManagerTest8, GetTotalUITreeInfo, Function | SmallTest | Level3)
71 {
72     std::string dumpInfo = "dumpInfo";
73     ssm_->SetDumpUITreeFunc(nullptr);
74     EXPECT_EQ(WSError::WS_OK, ssm_->GetTotalUITreeInfo(dumpInfo));
__anon795a559e0202(std::string& dumpInfo) 75     DumpUITreeFunc func = [](std::string& dumpInfo) {
76         return;
77     };
78     ssm_->SetDumpUITreeFunc(func);
79     EXPECT_EQ(WSError::WS_OK, ssm_->GetTotalUITreeInfo(dumpInfo));
80 }
81 
82 /**
83  * @tc.name: RequestFocusStatusBySCB
84  * @tc.desc: RequestFocusStatusBySCB set gesture navigation enabled
85  * @tc.type: FUNC
86  */
87 HWTEST_F(SceneSessionManagerTest8, RequestFocusStatusBySCB, Function | SmallTest | Level3)
88 {
89     SessionInfo sessionInfo;
90     sessionInfo.bundleName_ = "RequestFocusStatusBySCB";
91     sessionInfo.abilityName_ = "RequestFocusStatusBySCB";
92     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
93     EXPECT_NE(nullptr, sceneSession);
94     sceneSession->SetFocusable(true);
95 
96     FocusChangeReason reason = FocusChangeReason::DEFAULT;
97     WMError res = ssm_->RequestFocusStatusBySCB(8, false, false, reason);
98     EXPECT_EQ(WMError::WM_OK, res);
99 
100     reason = FocusChangeReason::FOREGROUND;
101     res = ssm_->RequestFocusStatusBySCB(8, true, false, reason);
102     EXPECT_EQ(WMError::WM_OK, res);
103 
104     reason = FocusChangeReason::MOVE_UP;
105     ssm_->sceneSessionMap_.insert({ 5, sceneSession });
106     res = ssm_->RequestFocusStatusBySCB(5, true, false, reason);
107     EXPECT_EQ(WMError::WM_OK, res);
108 
109     res = ssm_->RequestFocusStatusBySCB(8, true, false, reason);
110     EXPECT_EQ(WMError::WM_OK, res);
111 
112     reason = FocusChangeReason::DEFAULT;
113     res = ssm_->RequestFocusStatusBySCB(8, true, true, reason);
114     EXPECT_EQ(WMError::WM_OK, res);
115 
116     res = ssm_->RequestFocusStatusBySCB(5, true, true, reason);
117     EXPECT_EQ(WMError::WM_OK, res);
118 }
119 
120 /**
121  * @tc.name: GetRemoteSessionSnapshotInfo
122  * @tc.desc: GetRemoteSessionSnapshotInfo set gesture navigation enabled
123  * @tc.type: FUNC
124  */
125 HWTEST_F(SceneSessionManagerTest8, GetRemoteSessionSnapshotInfo, Function | SmallTest | Level3)
126 {
127     AAFwk::MissionSnapshot sessionSnapshot;
128     std::string deviceId = "";
129     int res = ssm_->GetRemoteSessionSnapshotInfo(deviceId, 8, sessionSnapshot);
130     EXPECT_EQ(ERR_NULL_OBJECT, res);
131 }
132 
133 /**
134  * @tc.name: WindowLayerInfoChangeCallback
135  * @tc.desc: test function : WindowLayerInfoChangeCallback
136  * @tc.type: FUNC
137  */
138 HWTEST_F(SceneSessionManagerTest8, WindowLayerInfoChangeCallback, Function | SmallTest | Level3)
139 {
140     std::shared_ptr<RSOcclusionData> rsData = nullptr;
141     ssm_->WindowLayerInfoChangeCallback(rsData);
142 
143     rsData = std::make_shared<RSOcclusionData>();
144     ASSERT_NE(nullptr, rsData);
145     ssm_->WindowLayerInfoChangeCallback(rsData);
146 
147     VisibleData visibleData;
148     visibleData.push_back(std::make_pair(0, WINDOW_LAYER_INFO_TYPE::ALL_VISIBLE));
149     visibleData.push_back(std::make_pair(1, WINDOW_LAYER_INFO_TYPE::SEMI_VISIBLE));
150     visibleData.push_back(std::make_pair(2, WINDOW_LAYER_INFO_TYPE::INVISIBLE));
151     visibleData.push_back(std::make_pair(3, WINDOW_LAYER_INFO_TYPE::WINDOW_LAYER_DYNAMIC_STATUS));
152     visibleData.push_back(std::make_pair(4, WINDOW_LAYER_INFO_TYPE::WINDOW_LAYER_STATIC_STATUS));
153     visibleData.push_back(std::make_pair(5, WINDOW_LAYER_INFO_TYPE::WINDOW_LAYER_UNKNOWN_TYPE));
154     rsData = std::make_shared<RSOcclusionData>(visibleData);
155     ASSERT_NE(nullptr, rsData);
156     ssm_->WindowLayerInfoChangeCallback(rsData);
157 }
158 
159 /**
160  * @tc.name: DealwithVisibilityChange
161  * @tc.desc: test function : DealwithVisibilityChange
162  * @tc.type: FUNC
163  */
164 HWTEST_F(SceneSessionManagerTest8, DealwithVisibilityChange, Function | SmallTest | Level3)
165 {
166     std::vector<std::pair<uint64_t, WindowVisibilityState>> visibilityChangeInfo;
167     std::vector<std::pair<uint64_t, WindowVisibilityState>> currVisibleData;
168     ssm_->DealwithVisibilityChange(visibilityChangeInfo, currVisibleData);
169 
170     visibilityChangeInfo.push_back(std::make_pair(0, WindowVisibilityState::WINDOW_VISIBILITY_STATE_NO_OCCLUSION));
171     currVisibleData.push_back(std::make_pair(0, WindowVisibilityState::WINDOW_VISIBILITY_STATE_NO_OCCLUSION));
172     ssm_->DealwithVisibilityChange(visibilityChangeInfo, currVisibleData);
173 
174     visibilityChangeInfo.push_back(std::make_pair(2, WindowVisibilityState::WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION));
175 
176     SessionInfo sessionInfo;
177     sessionInfo.windowType_ = static_cast<uint32_t>(WindowType::APP_SUB_WINDOW_END);
178     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
179     ASSERT_NE(nullptr, sceneSession);
180     struct RSSurfaceNodeConfig rsSurfaceNodeConfig;
181     sceneSession->surfaceNode_ = std::make_shared<RSSurfaceNode>(rsSurfaceNodeConfig, true, 0);
182     EXPECT_EQ(WindowType::APP_SUB_WINDOW_END, sceneSession->GetWindowType());
183     ssm_->sceneSessionMap_.emplace(0, sceneSession);
184 
185     SessionInfo sessionInfo1;
186     sessionInfo1.windowType_ = static_cast<uint32_t>(WindowType::APP_SUB_WINDOW_BASE);
187     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo1, nullptr);
188     ASSERT_NE(nullptr, sceneSession1);
189     sceneSession1->surfaceNode_ = std::make_shared<RSSurfaceNode>(rsSurfaceNodeConfig, true, 2);
190     EXPECT_EQ(WindowType::APP_SUB_WINDOW_BASE, sceneSession1->GetWindowType());
191     ssm_->sceneSessionMap_.emplace(2, sceneSession);
192     ssm_->DealwithVisibilityChange(visibilityChangeInfo, currVisibleData);
193 }
194 
195 /**
196  * @tc.name: DealwithVisibilityChange1
197  * @tc.desc: test function : DealwithVisibilityChange1
198  * @tc.type: FUNC
199  */
200 HWTEST_F(SceneSessionManagerTest8, DealwithVisibilityChange1, Function | SmallTest | Level3)
201 {
202     std::vector<std::pair<uint64_t, WindowVisibilityState>> visibilityChangeInfo;
203     std::vector<std::pair<uint64_t, WindowVisibilityState>> currVisibleData;
204     visibilityChangeInfo.push_back(std::make_pair(0, WindowVisibilityState::WINDOW_VISIBILITY_STATE_NO_OCCLUSION));
205     visibilityChangeInfo.push_back(std::make_pair(1,
206         WindowVisibilityState::WINDOW_VISIBILITY_STATE_PARTICALLY_OCCLUSION));
207     currVisibleData.push_back(std::make_pair(1, WindowVisibilityState::WINDOW_VISIBILITY_STATE_PARTICALLY_OCCLUSION));
208 
209     SessionInfo sessionInfo;
210     sessionInfo.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_DIALOG);
211     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
212     ASSERT_NE(nullptr, sceneSession);
213     struct RSSurfaceNodeConfig rsSurfaceNodeConfig;
214     sceneSession->surfaceNode_ = std::make_shared<RSSurfaceNode>(rsSurfaceNodeConfig, true, 0);
215     EXPECT_EQ(WindowType::WINDOW_TYPE_DIALOG, sceneSession->GetWindowType());
216     sceneSession->SetParentSession(nullptr);
217     ssm_->sceneSessionMap_.emplace(0, sceneSession);
218 
219     SessionInfo sessionInfo1;
220     sessionInfo1.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_DIALOG);
221     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
222     ASSERT_NE(nullptr, sceneSession1);
223     sceneSession1->surfaceNode_ = std::make_shared<RSSurfaceNode>(rsSurfaceNodeConfig, true, 1);
224     sceneSession1->SetParentSession(sceneSession1);
225     ssm_->sceneSessionMap_.emplace(1, sceneSession);
226     ssm_->DealwithVisibilityChange(visibilityChangeInfo, currVisibleData);
227 }
228 
229 /**
230  * @tc.name: PostProcessFocus
231  * @tc.desc: test function : PostProcessFocus
232  * @tc.type: FUNC
233  */
234 HWTEST_F(SceneSessionManagerTest8, PostProcessFocus, Function | SmallTest | Level3)
235 {
236     ssm_->sceneSessionMap_.emplace(0, nullptr);
237     ssm_->PostProcessFocus();
238     ssm_->sceneSessionMap_.clear();
239 
240     SessionInfo sessionInfo;
241     sessionInfo.bundleName_ = "PostProcessFocus";
242     sessionInfo.abilityName_ = "PostProcessFocus";
243     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
244     ASSERT_NE(nullptr, sceneSession);
245     PostProcessFocusState state;
246     EXPECT_EQ(false, state.enabled_);
247     sceneSession->SetPostProcessFocusState(state);
248     ssm_->sceneSessionMap_.emplace(0, sceneSession);
249     ssm_->PostProcessFocus();
250 
251     state.enabled_ = true;
252     state.isFocused_ = false;
253     sceneSession->SetPostProcessFocusState(state);
254     ssm_->PostProcessFocus();
255 
256     state.isFocused_ = true;
257     state.reason_ = FocusChangeReason::SCB_START_APP;
258     sceneSession->SetPostProcessFocusState(state);
259     ssm_->PostProcessFocus();
260 
261     sceneSession->SetPostProcessFocusState(state);
262     state.reason_ = FocusChangeReason::DEFAULT;
263     ssm_->PostProcessFocus();
264 }
265 
266 /**
267  * @tc.name: PostProcessFocus01
268  * @tc.desc: test function : PostProcessFocus with focusableOnShow
269  * @tc.type: FUNC
270  */
271 HWTEST_F(SceneSessionManagerTest8, PostProcessFocus01, Function | SmallTest | Level3)
272 {
273     ssm_->sceneSessionMap_.clear();
274     ssm_->focusedSessionId_ = 0;
275 
276     SessionInfo sessionInfo;
277     sessionInfo.bundleName_ = "PostProcessFocus01";
278     sessionInfo.abilityName_ = "PostProcessFocus01";
279     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
280     sceneSession->persistentId_ = 1;
281     sceneSession->state_ = SessionState::STATE_FOREGROUND;
282     sceneSession->isVisible_ = true;
283 
284     PostProcessFocusState state = {true, true, FocusChangeReason::FOREGROUND};
285     sceneSession->SetPostProcessFocusState(state);
286     sceneSession->SetFocusableOnShow(false);
287     ssm_->sceneSessionMap_.emplace(1, sceneSession);
288     ssm_->PostProcessFocus();
289 
290     EXPECT_NE(1, ssm_->focusedSessionId_);
291 }
292 
293 /**
294  * @tc.name: PostProcessProperty
295  * @tc.desc: test function : PostProcessProperty
296  * @tc.type: FUNC
297  */
298 HWTEST_F(SceneSessionManagerTest8, PostProcessProperty, Function | SmallTest | Level3)
299 {
300     ssm_->sceneSessionMap_.emplace(0, nullptr);
301     ssm_->PostProcessProperty(static_cast<uint32_t>(SessionUIDirtyFlag::AVOID_AREA));
302     ssm_->PostProcessProperty(~static_cast<uint32_t>(SessionUIDirtyFlag::AVOID_AREA));
303     ssm_->sceneSessionMap_.clear();
304 
305     SessionInfo sessionInfo;
306     sessionInfo.bundleName_ = "PostProcessProperty";
307     sessionInfo.abilityName_ = "PostProcessProperty";
308     sessionInfo.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_DIALOG);
309     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
310     ASSERT_NE(nullptr, sceneSession);
311     PostProcessFocusState state;
312     EXPECT_EQ(false, state.enabled_);
313     sceneSession->SetPostProcessFocusState(state);
314     ssm_->sceneSessionMap_.emplace(0, sceneSession);
315     ssm_->PostProcessFocus();
316 
317     state.enabled_ = true;
318     sceneSession->SetPostProcessFocusState(state);
319     ssm_->PostProcessFocus();
320 
321     sessionInfo.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
322     ssm_->PostProcessFocus();
323 }
324 
325 /**
326  * @tc.name: NotifyUpdateRectAfterLayout
327  * @tc.desc: test function : NotifyUpdateRectAfterLayout
328  * @tc.type: FUNC
329  */
330 HWTEST_F(SceneSessionManagerTest8, NotifyUpdateRectAfterLayout, Function | SmallTest | Level3)
331 {
332     ssm_->sceneSessionMap_.emplace(0, nullptr);
333     ssm_->NotifyUpdateRectAfterLayout();
334     ssm_->sceneSessionMap_.clear();
335 
336     SessionInfo sessionInfo;
337     sessionInfo.bundleName_ = "NotifyUpdateRectAfterLayout";
338     sessionInfo.abilityName_ = "NotifyUpdateRectAfterLayout";
339     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
340     ASSERT_NE(nullptr, sceneSession);
341     ssm_->sceneSessionMap_.emplace(0, sceneSession);
342     ssm_->NotifyUpdateRectAfterLayout();
343     constexpr uint32_t NOT_WAIT_SYNC_IN_NS = 500000;
344     usleep(NOT_WAIT_SYNC_IN_NS);
345 }
346 
347 /**
348  * @tc.name: DestroyExtensionSession
349  * @tc.desc: test function : DestroyExtensionSession
350  * @tc.type: FUNC
351  */
352 HWTEST_F(SceneSessionManagerTest8, DestroyExtensionSession, Function | SmallTest | Level3)
353 {
354     ssm_->remoteExtSessionMap_.clear();
355     sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker();
356     sptr<IRemoteObject> token = new IRemoteObjectMocker();
357     EXPECT_NE(nullptr, iRemoteObjectMocker);
358     ssm_->DestroyExtensionSession(iRemoteObjectMocker);
359     ssm_->remoteExtSessionMap_.emplace(iRemoteObjectMocker, token);
360 
361     ssm_->extSessionInfoMap_.clear();
362     ssm_->DestroyExtensionSession(iRemoteObjectMocker);
363 
364     ExtensionWindowAbilityInfo extensionWindowAbilituInfo;
365     ssm_->extSessionInfoMap_.emplace(token, extensionWindowAbilituInfo);
366 
367     ssm_->sceneSessionMap_.emplace(0, nullptr);
368     ssm_->DestroyExtensionSession(iRemoteObjectMocker);
369     ssm_->sceneSessionMap_.clear();
370 
371     SessionInfo sessionInfo;
372     sessionInfo.bundleName_ = "DestroyExtensionSession";
373     sessionInfo.abilityName_ = "DestroyExtensionSession";
374     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
375     ASSERT_NE(nullptr, sceneSession);
376     ssm_->sceneSessionMap_.emplace(0, sceneSession);
377 
378     ExtensionWindowFlags extensionWindowFlags;
379     sceneSession->combinedExtWindowFlags_ = extensionWindowFlags;
380     ssm_->DestroyExtensionSession(iRemoteObjectMocker);
381 
382     extensionWindowFlags.waterMarkFlag = false;
383     extensionWindowFlags.privacyModeFlag = false;
384     sceneSession->combinedExtWindowFlags_ = extensionWindowFlags;
385     EXPECT_EQ(false, sceneSession->combinedExtWindowFlags_.privacyModeFlag);
386     int len = sceneSession->modalUIExtensionInfoList_.size();
387     ssm_->DestroyExtensionSession(iRemoteObjectMocker, true);
388     constexpr uint32_t DES_WAIT_SYNC_IN_NS = 500000;
389     usleep(DES_WAIT_SYNC_IN_NS);
390     EXPECT_EQ(len, sceneSession->modalUIExtensionInfoList_.size());
391     ssm_->DestroyExtensionSession(iRemoteObjectMocker, false);
392     usleep(DES_WAIT_SYNC_IN_NS);
393     EXPECT_EQ(len, sceneSession->modalUIExtensionInfoList_.size());
394 }
395 
396 /**
397  * @tc.name: FilterSceneSessionCovered
398  * @tc.desc: test function : FilterSceneSessionCovered
399  * @tc.type: FUNC
400  */
401 HWTEST_F(SceneSessionManagerTest8, FilterSceneSessionCovered, Function | SmallTest | Level3)
402 {
403     std::vector<sptr<SceneSession>> sceneSessionList;
404     sptr<SceneSession> sceneSession = nullptr;
405     sceneSessionList.emplace_back(sceneSession);
406     EXPECT_EQ(1, sceneSessionList.size());
407     ssm_->FilterSceneSessionCovered(sceneSessionList);
408 
409     SessionInfo sessionInfo;
410     sceneSessionList.clear();
411     sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
412     EXPECT_NE(nullptr, sceneSession);
413     EXPECT_EQ(WSError::WS_OK, sceneSession->SetSessionProperty(nullptr));
414     sceneSessionList.emplace_back(sceneSession);
415     ssm_->FilterSceneSessionCovered(sceneSessionList);
416 }
417 
418 /**
419  * @tc.name: WindowDestroyNotifyVisibility
420  * @tc.desc: test function : WindowDestroyNotifyVisibility
421  * @tc.type: FUNC
422  */
423 HWTEST_F(SceneSessionManagerTest8, WindowDestroyNotifyVisibility, Function | SmallTest | Level3)
424 {
425     sptr<SceneSession> sceneSession = nullptr;
426     ssm_->WindowDestroyNotifyVisibility(sceneSession);
427 
428     SessionInfo sessionInfo;
429     sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
430     EXPECT_NE(nullptr, sceneSession);
431     EXPECT_EQ(WSError::WS_OK, sceneSession->SetRSVisible(true));
432     ssm_->WindowDestroyNotifyVisibility(sceneSession);
433 }
434 
435 /**
436  * @tc.name: UpdateSubWindowVisibility
437  * @tc.desc: test function : UpdateSubWindowVisibility
438  * @tc.type: FUNC
439  */
440 HWTEST_F(SceneSessionManagerTest8, UpdateSubWindowVisibility, Function | SmallTest | Level3)
441 {
442     SessionInfo sessionInfo;
443     sessionInfo.bundleName_ = "UpdateSubWindowVisibility";
444     sessionInfo.abilityName_ = "UpdateSubWindowVisibility";
445     sessionInfo.windowType_ = static_cast<uint32_t>(WindowType::APP_SUB_WINDOW_BASE);
446     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
447     EXPECT_NE(nullptr, sceneSession);
448     WindowVisibilityState visibleState = WindowVisibilityState::WINDOW_VISIBILITY_STATE_NO_OCCLUSION;
449     std::vector<std::pair<uint64_t, WindowVisibilityState>> visibilityChangeInfo;
450     std::vector<sptr<WindowVisibilityInfo>> windowVisibilityInfos;
451     std::string visibilityInfo = "";
452     std::vector<std::pair<uint64_t, WindowVisibilityState>> currVisibleData;
453     sceneSession->persistentId_ = 1998;
454     sceneSession->SetCallingUid(1998);
455     SessionState state = SessionState::STATE_CONNECT;
456     sceneSession->SetSessionState(state);
457     sceneSession->SetParentSession(sceneSession);
458     EXPECT_EQ(1998, sceneSession->GetParentSession()->GetWindowId());
459     ssm_->sceneSessionMap_.emplace(0, sceneSession);
460 
461     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
462     EXPECT_NE(nullptr, sceneSession1);
463     sceneSession1->persistentId_ = 1998;
464     sceneSession1->SetCallingUid(1024);
465     SessionState state1 = SessionState::STATE_CONNECT;
466     sceneSession1->SetSessionState(state1);
467     sceneSession1->SetParentSession(sceneSession1);
468     EXPECT_EQ(1998, sceneSession1->GetParentSession()->GetWindowId());
469     ssm_->sceneSessionMap_.emplace(0, sceneSession1);
470 
471     sptr<SceneSession> sceneSession2 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
472     EXPECT_NE(nullptr, sceneSession2);
473     sceneSession2->persistentId_ = 1998;
474     sceneSession2->SetCallingUid(1998);
475     SessionState state2 = SessionState::STATE_FOREGROUND;
476     sceneSession2->SetSessionState(state2);
477     sceneSession2->SetParentSession(sceneSession2);
478     EXPECT_EQ(1998, sceneSession2->GetParentSession()->GetWindowId());
479     ssm_->sceneSessionMap_.emplace(0, sceneSession2);
480     ssm_->UpdateSubWindowVisibility(sceneSession,
481         visibleState, visibilityChangeInfo, windowVisibilityInfos, visibilityInfo, currVisibleData);
482 }
483 
484 /**
485  * @tc.name: RegisterSessionChangeByActionNotifyManagerFunc
486  * @tc.desc: test function : RegisterSessionChangeByActionNotifyManagerFunc
487  * @tc.type: FUNC
488  */
489 HWTEST_F(SceneSessionManagerTest8, RegisterSessionChangeByActionNotifyManagerFunc, Function | SmallTest | Level3)
490 {
491     sptr<SceneSession> sceneSession = nullptr;
492     ssm_->RegisterSessionChangeByActionNotifyManagerFunc(sceneSession);
493     SessionInfo sessionInfo;
494     sessionInfo.bundleName_ = "RegisterSessionChangeByActionNotifyManagerFunc";
495     sessionInfo.abilityName_ = "RegisterSessionChangeByActionNotifyManagerFunc";
496     sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
497     EXPECT_NE(nullptr, sceneSession);
498     ssm_->RegisterSessionChangeByActionNotifyManagerFunc(sceneSession);
499     EXPECT_NE(nullptr, sceneSession->sessionChangeByActionNotifyManagerFunc_);
500 
501     sptr<SceneSession> sceneSession1 = nullptr;
502     sptr<WindowSessionProperty> property = nullptr;
503 
504     sceneSession->NotifySessionChangeByActionNotifyManager(sceneSession1, property,
505         WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON);
506 
507     sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
508     EXPECT_NE(nullptr, sceneSession1);
509     sceneSession->NotifySessionChangeByActionNotifyManager(sceneSession1, property,
510         WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON);
511 
512     property = sptr<WindowSessionProperty>::MakeSptr();
513     EXPECT_NE(nullptr, property);
514 
515     sceneSession->NotifySessionChangeByActionNotifyManager(sceneSession1, property,
516         WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON);
517 }
518 
519 /**
520  * @tc.name: RegisterSessionChangeByActionNotifyManagerFunc1
521  * @tc.desc: test function : RegisterSessionChangeByActionNotifyManagerFunc1
522  * @tc.type: FUNC
523  */
524 HWTEST_F(SceneSessionManagerTest8, RegisterSessionChangeByActionNotifyManagerFunc1, Function | SmallTest | Level3)
525 {
526     SessionInfo sessionInfo;
527     sessionInfo.bundleName_ = "RegisterSessionChangeByActionNotifyManagerFunc1";
528     sessionInfo.abilityName_ = "RegisterSessionChangeByActionNotifyManagerFunc1";
529     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
530     EXPECT_NE(nullptr, sceneSession);
531 
532     ssm_->RegisterSessionChangeByActionNotifyManagerFunc(sceneSession);
533     EXPECT_NE(nullptr, sceneSession->sessionChangeByActionNotifyManagerFunc_);
534 
535     sptr<SceneSession> sceneSession1 = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
536     EXPECT_NE(nullptr, sceneSession1);
537 
538     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
539     EXPECT_NE(nullptr, property);
540 
541     sceneSession->NotifySessionChangeByActionNotifyManager(sceneSession1, property,
542         WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON);
543 
544     sceneSession->NotifySessionChangeByActionNotifyManager(sceneSession1, property,
545         WSPropertyChangeAction::ACTION_UPDATE_NAVIGATION_INDICATOR_PROPS);
546 
547     sceneSession->NotifySessionChangeByActionNotifyManager(sceneSession1, property,
548         WSPropertyChangeAction::ACTION_UPDATE_SET_BRIGHTNESS);
549 
550     sceneSession->NotifySessionChangeByActionNotifyManager(sceneSession1, property,
551         WSPropertyChangeAction::ACTION_UPDATE_SYSTEM_PRIVACY_MODE);
552 
553     sceneSession->NotifySessionChangeByActionNotifyManager(sceneSession1, property,
554         WSPropertyChangeAction::ACTION_UPDATE_FLAGS);
555 
556     sceneSession->NotifySessionChangeByActionNotifyManager(sceneSession1, property,
557         WSPropertyChangeAction::ACTION_UPDATE_MODE);
558 
559     sceneSession->NotifySessionChangeByActionNotifyManager(sceneSession1, property,
560         WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS);
561 
562     sceneSession->NotifySessionChangeByActionNotifyManager(sceneSession1, property,
563         WSPropertyChangeAction::ACTION_UPDATE_WINDOW_MASK);
564 
565     sceneSession->NotifySessionChangeByActionNotifyManager(sceneSession1, property,
566         WSPropertyChangeAction::ACTION_UPDATE_TOPMOST);
567 }
568 
569 /**
570  * @tc.name: RegisterRequestFocusStatusNotifyManagerFunc
571  * @tc.desc: test function : RegisterRequestFocusStatusNotifyManagerFunc
572  * @tc.type: FUNC
573  */
574 HWTEST_F(SceneSessionManagerTest8, RegisterRequestFocusStatusNotifyManagerFunc, Function | SmallTest | Level3)
575 {
576     sptr<SceneSession> sceneSession = nullptr;
577     ssm_->RegisterRequestFocusStatusNotifyManagerFunc(sceneSession);
578     EXPECT_EQ(nullptr, sceneSession);
579 }
580 
581 /**
582  * @tc.name: CheckRequestFocusImmdediately
583  * @tc.desc: test function : CheckRequestFocusImmdediately
584  * @tc.type: FUNC
585  */
586 HWTEST_F(SceneSessionManagerTest8, CheckRequestFocusImmdediately, Function | SmallTest | Level3)
587 {
588     SessionInfo sessionInfo;
589     sessionInfo.bundleName_ = "CheckRequestFocusImmdediately";
590     sessionInfo.abilityName_ = "CheckRequestFocusImmdediately";
591     sessionInfo.windowType_ = static_cast<uint32_t>(WindowType::APP_SUB_WINDOW_BASE);
592     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
593     EXPECT_NE(nullptr, sceneSession);
594     EXPECT_EQ(WindowType::APP_SUB_WINDOW_BASE, sceneSession->GetWindowType());
595     ssm_->CheckRequestFocusImmdediately(sceneSession);
596 }
597 
598 /**
599  * @tc.name: HandleTurnScreenOn
600  * @tc.desc: test function : HandleTurnScreenOn
601  * @tc.type: FUNC
602  */
603 HWTEST_F(SceneSessionManagerTest8, HandleTurnScreenOn, Function | SmallTest | Level3)
604 {
605     sptr<SceneSession> sceneSession = nullptr;
606     ssm_->HandleTurnScreenOn(sceneSession);
607     SessionInfo sessionInfo;
608     sessionInfo.bundleName_ = "HandleTurnScreenOn";
609     sessionInfo.abilityName_ = "HandleTurnScreenOn";
610     sessionInfo.windowType_ = static_cast<uint32_t>(WindowType::APP_SUB_WINDOW_BASE);
611     sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
612     EXPECT_NE(nullptr, sceneSession);
613     sceneSession->GetSessionProperty()->SetTurnScreenOn(false);
614     ssm_->HandleTurnScreenOn(sceneSession);
615     EXPECT_EQ(false, sceneSession->GetSessionProperty()->IsTurnScreenOn());
616     sceneSession->GetSessionProperty()->SetTurnScreenOn(true);
617     ssm_->HandleTurnScreenOn(sceneSession);
618     constexpr uint32_t NOT_WAIT_SYNC_IN_NS = 500000;
619     usleep(NOT_WAIT_SYNC_IN_NS);
620 }
621 /**
622  * @tc.name: HandleKeepScreenOn
623  * @tc.desc: test function : HandleKeepScreenOn
624  * @tc.type: FUNC
625  */
626 HWTEST_F(SceneSessionManagerTest8, HandleKeepScreenOn, Function | SmallTest | Level3)
627 {
628     SessionInfo sessionInfo;
629     sessionInfo.bundleName_ = "HandleTurnScreenOn";
630     sessionInfo.abilityName_ = "HandleTurnScreenOn";
631     sessionInfo.windowType_ = static_cast<uint32_t>(WindowType::APP_SUB_WINDOW_BASE);
632     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
633     EXPECT_NE(nullptr, sceneSession);
634 
635     ssm_->HandleKeepScreenOn(sceneSession, false);
636     sceneSession->keepScreenLock_ = nullptr;
637     ssm_->HandleKeepScreenOn(sceneSession, true);
638     bool enable = true;
639     EXPECT_EQ(WSError::WS_OK, ssm_->GetFreeMultiWindowEnableState(enable));
640 }
641 
642 /**
643  * @tc.name: SetBrightness
644  * @tc.desc: test function : SetBrightness
645  * @tc.type: FUNC
646  */
647 HWTEST_F(SceneSessionManagerTest8, SetBrightness, Function | SmallTest | Level3)
648 {
649     SessionInfo sessionInfo;
650     sessionInfo.bundleName_ = "SetBrightness";
651     sessionInfo.abilityName_ = "SetBrightness";
652     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(sessionInfo, nullptr);
653     EXPECT_NE(nullptr, sceneSession);
654     sceneSession->persistentId_ = 2024;
655 
656     ssm_->SetDisplayBrightness(3.14f);
657     std::shared_ptr<AppExecFwk::EventHandler> pipeEventHandler = nullptr;
658     ssm_->eventHandler_ = pipeEventHandler;
659     EXPECT_EQ(nullptr, ssm_->eventHandler_);
660     ssm_->SetBrightness(sceneSession, 3.15f);
661 
662     ssm_->Init();
663     EXPECT_NE(nullptr, ssm_->eventHandler_);
664 
665     ssm_->SetFocusedSessionId(2024);
666     EXPECT_EQ(2024, ssm_->GetFocusedSessionId());
667     ssm_->SetBrightness(sceneSession, 3.15f);
668 }
669 
670 /**
671  * @tc.name: TerminateSessionNew
672  * @tc.desc: test function : TerminateSessionNew
673  * @tc.type: FUNC
674  */
675 HWTEST_F(SceneSessionManagerTest8, TerminateSessionNew, Function | SmallTest | Level3)
676 {
677     sptr<AAFwk::SessionInfo> sessionInfo = sptr<AAFwk::SessionInfo>::MakeSptr();
678     EXPECT_NE(nullptr, sessionInfo);
679     sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr();
680     EXPECT_NE(nullptr, iRemoteObjectMocker);
681     sessionInfo->sessionToken = iRemoteObjectMocker;
682 
683     SessionInfo info;
684     info.bundleName_ = "TerminateSessionNew";
685     info.abilityName_ = "TerminateSessionNew";
686     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
687     EXPECT_NE(nullptr, sceneSession);
688     sceneSession->SetAbilityToken(iRemoteObjectMocker);
689     ssm_->sceneSessionMap_.emplace(0, sceneSession);
690     ssm_->TerminateSessionNew(sessionInfo, true, true);
691 }
692 
693 }
694 } // namespace Rosen
695 } // namespace OHOS