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