• 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 "window_session_impl.h"
17 
18 #include <gtest/gtest.h>
19 
20 #include "ability_context_impl.h"
21 #include "display_info.h"
22 #include "mock_session.h"
23 #include "mock_uicontent.h"
24 #include "mock_window.h"
25 #include "parameters.h"
26 #include "wm_common.h"
27 
28 using namespace testing;
29 using namespace testing::ext;
30 
31 namespace OHOS {
32 namespace Rosen {
33 class WindowSessionImplTest2 : public testing::Test {
34 public:
35     static void SetUpTestCase();
36     static void TearDownTestCase();
37     void SetUp() override;
38     void TearDown() override;
39     sptr<WindowSessionImpl> window_;
40 
41 private:
42     static constexpr uint32_t WAIT_SYNC_IN_NS = 50000;
43 };
44 
SetUpTestCase()45 void WindowSessionImplTest2::SetUpTestCase() {}
46 
TearDownTestCase()47 void WindowSessionImplTest2::TearDownTestCase() {}
48 
SetUp()49 void WindowSessionImplTest2::SetUp() {}
50 
TearDown()51 void WindowSessionImplTest2::TearDown()
52 {
53     usleep(WAIT_SYNC_IN_NS);
54     if (window_ != nullptr) {
55         window_->Destroy();
56     }
57 }
58 
59 namespace {
GetTestWindowImpl(const std::string & name)60 sptr<WindowSessionImpl> GetTestWindowImpl(const std::string& name)
61 {
62     sptr<WindowOption> option = new (std::nothrow) WindowOption();
63     if (option == nullptr) {
64         return nullptr;
65     }
66     option->SetWindowName(name);
67     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
68     if (window == nullptr) {
69         return nullptr;
70     }
71 
72     SessionInfo sessionInfo = { name, name, name };
73     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
74     if (session == nullptr) {
75         return nullptr;
76     }
77 
78     window->hostSession_ = session;
79     return window;
80 }
81 
GetListenerList()82 template <typename TListener, typename MockListener> std::vector<sptr<TListener>> GetListenerList()
83 {
84     std::vector<sptr<TListener>> listeners;
85     sptr<TListener> listener = new (std::nothrow) MockListener();
86     if (listener == nullptr) {
87         return listeners;
88     }
89 
90     listeners.insert(listeners.begin(), listener);
91     return listeners;
92 }
93 
94 /**
95  * @tc.name: GetTitleButtonVisible
96  * @tc.desc: GetTitleButtonVisible
97  * @tc.type: FUNC
98  */
99 HWTEST_F(WindowSessionImplTest2, GetTitleButtonVisible, Function | SmallTest | Level2)
100 {
101     auto window = GetTestWindowImpl("GetTitleButtonVisible");
102     ASSERT_NE(window, nullptr);
103     window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
104     bool isMaximizeVisible = false;
105     bool isMinimizeVisible = false;
106     bool isSplitVisible = false;
107     bool isCloseVisible = false;
108     window->GetTitleButtonVisible(isMaximizeVisible, isMinimizeVisible, isSplitVisible, isCloseVisible);
109     ASSERT_FALSE(isSplitVisible);
110 
111     window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
112     window->windowTitleVisibleFlags_.isSplitVisible = false;
113     window->windowTitleVisibleFlags_.isMaximizeVisible = false;
114     window->windowTitleVisibleFlags_.isMinimizeVisible = false;
115     window->windowTitleVisibleFlags_.isCloseVisible = false;
116     window->GetTitleButtonVisible(isMaximizeVisible, isMinimizeVisible, isSplitVisible, isCloseVisible);
117     ASSERT_TRUE(isSplitVisible);
118     ASSERT_TRUE(isMaximizeVisible);
119     ASSERT_TRUE(isMinimizeVisible);
120     ASSERT_TRUE(isCloseVisible);
121 
122     window->windowTitleVisibleFlags_.isSplitVisible = true;
123     window->windowTitleVisibleFlags_.isMaximizeVisible = true;
124     window->windowTitleVisibleFlags_.isMinimizeVisible = true;
125     window->windowTitleVisibleFlags_.isCloseVisible = true;
126     window->GetTitleButtonVisible(isMaximizeVisible, isMinimizeVisible, isSplitVisible, isCloseVisible);
127     ASSERT_TRUE(isSplitVisible);
128     ASSERT_TRUE(isMaximizeVisible);
129     ASSERT_TRUE(isMinimizeVisible);
130     ASSERT_TRUE(isCloseVisible);
131 }
132 
133 /**
134  * @tc.name: GetSystemSessionConfig
135  * @tc.desc: GetSystemSessionConfig
136  * @tc.type: FUNC
137  */
138 HWTEST_F(WindowSessionImplTest2, GetSystemSessionConfig, Function | SmallTest | Level2)
139 {
140     auto window = GetTestWindowImpl("GetSystemSessionConfig");
141     ASSERT_NE(window, nullptr);
142     window->GetSystemSessionConfig();
143     window->Destroy();
144 }
145 
146 /**
147  * @tc.name: GetColorSpaceFromSurfaceGamut
148  * @tc.desc: GetColorSpaceFromSurfaceGamut
149  * @tc.type: FUNC
150  */
151 HWTEST_F(WindowSessionImplTest2, GetColorSpaceFromSurfaceGamut, Function | SmallTest | Level2)
152 {
153     auto window = GetTestWindowImpl("GetColorSpaceFromSurfaceGamut");
154     ASSERT_NE(window, nullptr);
155     ASSERT_EQ(window->GetColorSpaceFromSurfaceGamut(GraphicColorGamut::GRAPHIC_COLOR_GAMUT_SRGB),
156               ColorSpace::COLOR_SPACE_DEFAULT);
157     ASSERT_EQ(window->GetColorSpaceFromSurfaceGamut(GraphicColorGamut::GRAPHIC_COLOR_GAMUT_DCI_P3),
158               ColorSpace::COLOR_SPACE_WIDE_GAMUT);
159     ASSERT_EQ(window->GetColorSpaceFromSurfaceGamut(GraphicColorGamut::GRAPHIC_COLOR_GAMUT_INVALID),
160               ColorSpace::COLOR_SPACE_DEFAULT);
161     window->Destroy();
162 }
163 
164 /**
165  * @tc.name: GetSurfaceGamutFromColorSpace
166  * @tc.desc: GetSurfaceGamutFromColorSpace
167  * @tc.type: FUNC
168  */
169 HWTEST_F(WindowSessionImplTest2, GetSurfaceGamutFromColorSpace, Function | SmallTest | Level2)
170 {
171     auto window = GetTestWindowImpl("GetSurfaceGamutFromColorSpace");
172     ASSERT_NE(window, nullptr);
173     ASSERT_EQ(window->GetSurfaceGamutFromColorSpace(ColorSpace::COLOR_SPACE_DEFAULT),
174               GraphicColorGamut::GRAPHIC_COLOR_GAMUT_SRGB);
175     ASSERT_EQ(window->GetSurfaceGamutFromColorSpace(ColorSpace::COLOR_SPACE_WIDE_GAMUT),
176               GraphicColorGamut::GRAPHIC_COLOR_GAMUT_DCI_P3);
177     ASSERT_EQ(window->GetSurfaceGamutFromColorSpace(ColorSpace(uint32_t(3))),
178               GraphicColorGamut::GRAPHIC_COLOR_GAMUT_SRGB);
179     window->Destroy();
180 }
181 
182 /**
183  * @tc.name: Create
184  * @tc.desc: Create
185  * @tc.type: FUNC
186  */
187 HWTEST_F(WindowSessionImplTest2, Create, Function | SmallTest | Level2)
188 {
189     auto window = GetTestWindowImpl("Create");
190     ASSERT_NE(window, nullptr);
191     std::shared_ptr<AbilityRuntime::Context> context;
192     sptr<Rosen::ISession> ISession;
193     ASSERT_EQ(window->Create(context, ISession), WMError::WM_OK);
194     window->Destroy();
195 }
196 
197 /**
198  * @tc.name: Destroy
199  * @tc.desc: Destroy
200  * @tc.type: FUNC
201  */
202 HWTEST_F(WindowSessionImplTest2, Destroy, Function | SmallTest | Level2)
203 {
204     auto window = GetTestWindowImpl("Destroy");
205     ASSERT_NE(window, nullptr);
206 
207     window->property_->SetPersistentId(INVALID_SESSION_ID);
208     ASSERT_EQ(window->Destroy(true, true), WMError::WM_ERROR_INVALID_WINDOW);
209 
210     window->property_->SetPersistentId(1);
211     window->state_ = WindowState::STATE_DESTROYED;
212     ASSERT_EQ(window->Destroy(true, true), WMError::WM_ERROR_INVALID_WINDOW);
213 
214     window->state_ = WindowState::STATE_INITIAL;
215     ASSERT_EQ(window->Destroy(true, true), WMError::WM_OK);
216 
217     window = GetTestWindowImpl("Destroy");
218     ASSERT_NE(window, nullptr);
219     window->state_ = WindowState::STATE_INITIAL;
220     window->property_->SetPersistentId(1);
221     ASSERT_EQ(window->Destroy(true, false), WMError::WM_OK);
222 
223     window->hostSession_ = nullptr;
224     ASSERT_EQ(window->Destroy(true, true), WMError::WM_ERROR_INVALID_WINDOW);
225 
226     window = GetTestWindowImpl("Destroy");
227     ASSERT_NE(window, nullptr);
228     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
229     sptr<SessionMocker> hostSession = sptr<SessionMocker>::MakeSptr(sessionInfo);
230     window->hostSession_ = hostSession;
231     ASSERT_EQ(window->Destroy(true, true), WMError::WM_ERROR_INVALID_WINDOW);
232 
233     window = GetTestWindowImpl("Destroy");
234     ASSERT_NE(window, nullptr);
235     window->hostSession_ = hostSession;
236     window->state_ = WindowState::STATE_INITIAL;
237     window->property_->SetPersistentId(1);
238     ASSERT_FALSE(window->IsWindowSessionInvalid());
239     window->context_ = std::make_shared<AbilityRuntime::AbilityContextImpl>();
240     ASSERT_EQ(window->Destroy(true, true), WMError::WM_OK);
241 }
242 
243 /**
244  * @tc.name: GetWindowState
245  * @tc.desc: GetWindowState
246  * @tc.type: FUNC
247  */
248 HWTEST_F(WindowSessionImplTest2, GetWindowState, Function | SmallTest | Level2)
249 {
250     auto window = GetTestWindowImpl("GetWindowState");
251     ASSERT_NE(window, nullptr);
252     window->state_ = WindowState::STATE_DESTROYED;
253     ASSERT_EQ(window->GetWindowState(), WindowState::STATE_DESTROYED);
254     window->Destroy();
255 }
256 
257 /**
258  * @tc.name: RecoverSessionListener
259  * @tc.desc: RecoverSessionListener
260  * @tc.type: FUNC
261  */
262 HWTEST_F(WindowSessionImplTest2, RecoverSessionListener, Function | SmallTest | Level2)
263 {
264     auto window = GetTestWindowImpl("RecoverSessionListener");
265     ASSERT_NE(window, nullptr);
266     int32_t id = 1;
267     window->property_->SetPersistentId(id);
268     window->RecoverSessionListener();
269 
270     std::vector<sptr<IAvoidAreaChangedListener>> iAvoidAreaChangedListeners;
271     std::vector<sptr<ITouchOutsideListener>> iTouchOutsideListeners;
272     window->avoidAreaChangeListeners_.insert({ id, iAvoidAreaChangedListeners });
273     window->touchOutsideListeners_.insert({ id, iTouchOutsideListeners });
274     window->RecoverSessionListener();
275 
276     window->avoidAreaChangeListeners_.clear();
277     window->touchOutsideListeners_.clear();
278     sptr<MockAvoidAreaChangedListener> changedListener = sptr<MockAvoidAreaChangedListener>::MakeSptr();
279     sptr<MockTouchOutsideListener> touchOutsideListener = sptr<MockTouchOutsideListener>::MakeSptr();
280     iAvoidAreaChangedListeners.insert(iAvoidAreaChangedListeners.begin(), changedListener);
281     iTouchOutsideListeners.insert(iTouchOutsideListeners.begin(), touchOutsideListener);
282     window->avoidAreaChangeListeners_.insert({ id, iAvoidAreaChangedListeners });
283     window->touchOutsideListeners_.insert({ id, iTouchOutsideListeners });
284     window->RecoverSessionListener();
285     ASSERT_TRUE(window->avoidAreaChangeListeners_.find(id) != window->avoidAreaChangeListeners_.end() &&
286                 !window->avoidAreaChangeListeners_[id].empty());
287     ASSERT_TRUE(window->touchOutsideListeners_.find(id) != window->touchOutsideListeners_.end() &&
288                 !window->touchOutsideListeners_[id].empty());
289     window->Destroy();
290 }
291 
292 /**
293  * @tc.name: NotifyUIContentFocusStatus
294  * @tc.desc: NotifyUIContentFocusStatus
295  * @tc.type: FUNC
296  */
297 HWTEST_F(WindowSessionImplTest2, NotifyUIContentFocusStatus, Function | SmallTest | Level2)
298 {
299     auto window = GetTestWindowImpl("NotifyUIContentFocusStatus");
300     ASSERT_NE(window, nullptr);
301     window->isFocused_ = false;
302     window->NotifyUIContentFocusStatus();
303 
304     window->isFocused_ = true;
305     window->NotifyUIContentFocusStatus();
306 
307     window->uiContent_ = std::make_unique<Ace::UIContentMocker>();
308     window->NotifyUIContentFocusStatus();
309     window->Destroy();
310 }
311 
312 /**
313  * @tc.name: NotifyAfterFocused
314  * @tc.desc: NotifyAfterFocused
315  * @tc.type: FUNC
316  */
317 HWTEST_F(WindowSessionImplTest2, NotifyAfterFocused, Function | SmallTest | Level2)
318 {
319     auto window = GetTestWindowImpl("NotifyAfterFocused");
320     ASSERT_NE(window, nullptr);
321     window->NotifyAfterFocused();
322     ASSERT_TRUE(window->shouldReNotifyFocus_);
323 
324     window->shouldReNotifyFocus_ = false;
325     window->uiContent_ = std::make_unique<Ace::UIContentMocker>();
326     window->NotifyAfterFocused();
327     ASSERT_FALSE(window->shouldReNotifyFocus_);
328     window->Destroy();
329 }
330 
331 /**
332  * @tc.name: NotifyForegroundFailed
333  * @tc.desc: NotifyForegroundFailed
334  * @tc.type: FUNC
335  */
336 HWTEST_F(WindowSessionImplTest2, NotifyForegroundFailed, Function | SmallTest | Level2)
337 {
338     auto window = GetTestWindowImpl("NotifyForegroundFailed");
339     ASSERT_NE(window, nullptr);
340     window->NotifyForegroundFailed(WMError::WM_OK);
341     window->Destroy();
342 }
343 
344 /**
345  * @tc.name: NotifyTransferComponentDataSync
346  * @tc.desc: NotifyTransferComponentDataSync
347  * @tc.type: FUNC
348  */
349 HWTEST_F(WindowSessionImplTest2, NotifyTransferComponentDataSync, Function | SmallTest | Level2)
350 {
351     auto window = GetTestWindowImpl("NotifyTransferComponentDataSync");
352     ASSERT_NE(window, nullptr);
353     AAFwk::WantParams wantParams;
354     AAFwk::WantParams reWantParams;
355     ASSERT_EQ(WSErrorCode::WS_OK, window->NotifyTransferComponentDataSync(wantParams, reWantParams));
356     window->Destroy();
357 }
358 
359 /**
360  * @tc.name: UpdateAvoidArea
361  * @tc.desc: UpdateAvoidArea
362  * @tc.type: FUNC
363  */
364 HWTEST_F(WindowSessionImplTest2, UpdateAvoidArea, Function | SmallTest | Level2)
365 {
366     auto window = GetTestWindowImpl("UpdateAvoidArea");
367     ASSERT_NE(window, nullptr);
368     sptr<AvoidArea> avoidArea = sptr<AvoidArea>::MakeSptr();
369     avoidArea->topRect_ = { 1, 0, 0, 0 };
370     avoidArea->leftRect_ = { 0, 1, 0, 0 };
371     avoidArea->rightRect_ = { 0, 0, 1, 0 };
372     avoidArea->bottomRect_ = { 0, 0, 0, 1 };
373     AvoidAreaType type = AvoidAreaType::TYPE_SYSTEM;
374     ASSERT_EQ(WSError::WS_OK, window->UpdateAvoidArea(avoidArea, type));
375     window->Destroy();
376 }
377 
378 /**
379  * @tc.name: DispatchKeyEventCallback
380  * @tc.desc: DispatchKeyEventCallback
381  * @tc.type: FUNC
382  */
383 HWTEST_F(WindowSessionImplTest2, DispatchKeyEventCallback, Function | SmallTest | Level2)
384 {
385     auto window = GetTestWindowImpl("DispatchKeyEventCallback");
386     ASSERT_NE(window, nullptr);
387 
388     std::shared_ptr<MMI::KeyEvent> keyEvent = MMI::KeyEvent::Create();
389     keyEvent->SetKeyCode(MMI::KeyEvent::KEYCODE_VIRTUAL_MULTITASK);
390     bool isConsumed = false;
391     window->DispatchKeyEventCallback(keyEvent, isConsumed);
392     ASSERT_FALSE(isConsumed);
393 
394     std::shared_ptr<MockInputEventConsumer> inputEventConsumer = std::make_shared<MockInputEventConsumer>();
395     window->inputEventConsumer_ = inputEventConsumer;
396     keyEvent->SetKeyCode(MMI::KeyEvent::KEYCODE_BACK);
397     keyEvent->SetKeyAction(MMI::KeyEvent::KEY_ACTION_DOWN);
398     window->DispatchKeyEventCallback(keyEvent, isConsumed);
399 
400     keyEvent->SetKeyAction(MMI::KeyEvent::KEY_ACTION_UP);
401     window->DispatchKeyEventCallback(keyEvent, isConsumed);
402 
403     keyEvent->SetKeyAction(MMI::KeyEvent::KEY_ACTION_UP);
404     window->inputEventConsumer_ = nullptr;
405     window->uiContent_ = std::make_unique<Ace::UIContentMocker>();
406     window->DispatchKeyEventCallback(keyEvent, isConsumed);
407 
408     keyEvent->SetKeyAction(MMI::KeyEvent::KEYCODE_ESCAPE);
409     window->DispatchKeyEventCallback(keyEvent, isConsumed);
410     window->Destroy();
411 }
412 
413 /**
414  * @tc.name: HandleBackEvent01
415  * @tc.desc: HandleBackEvent
416  * @tc.type: FUNC
417  */
418 HWTEST_F(WindowSessionImplTest2, HandleBackEvent01, Function | SmallTest | Level3)
419 {
420     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
421     option->SetWindowName("HandleBackEvent01");
422     sptr<WindowSessionImpl> windowSession = sptr<WindowSessionImpl>::MakeSptr(option);
423 
424     windowSession->uiContent_ = std::make_unique<Ace::UIContentMocker>();
425     ASSERT_EQ(WSError::WS_OK, windowSession->HandleBackEvent());
426 }
427 
428 /**
429  * @tc.name: IsKeyboardEvent
430  * @tc.desc: IsKeyboardEvent
431  * @tc.type: FUNC
432  */
433 HWTEST_F(WindowSessionImplTest2, IsKeyboardEvent, Function | SmallTest | Level2)
434 {
435     auto window = GetTestWindowImpl("IsKeyboardEvent");
436     ASSERT_NE(window, nullptr);
437 
438     std::shared_ptr<MMI::KeyEvent> keyEvent = MMI::KeyEvent::Create();
439     keyEvent->SetKeyCode(MMI::KeyEvent::KEYCODE_VIRTUAL_MULTITASK);
440     ASSERT_FALSE(window->IsKeyboardEvent(keyEvent));
441 
442     keyEvent->SetKeyCode(MMI::KeyEvent::KEYCODE_NUMPAD_RIGHT_PAREN);
443     ASSERT_TRUE(window->IsKeyboardEvent(keyEvent));
444 
445     keyEvent->SetKeyCode(MMI::KeyEvent::KEYCODE_BACK);
446     ASSERT_TRUE(window->IsKeyboardEvent(keyEvent));
447 
448     keyEvent->SetKeyCode(MMI::KeyEvent::KEYCODE_FN);
449     ASSERT_TRUE(window->IsKeyboardEvent(keyEvent));
450 
451     window->Destroy();
452 }
453 
454 /**
455  * @tc.name: GetVSyncPeriod
456  * @tc.desc: GetVSyncPeriod
457  * @tc.type: FUNC
458  */
459 HWTEST_F(WindowSessionImplTest2, GetVSyncPeriod, Function | SmallTest | Level2)
460 {
461     auto window = GetTestWindowImpl("GetVSyncPeriod");
462     ASSERT_NE(window, nullptr);
463 
464     auto vsyncStation = window->vsyncStation_;
465     if (vsyncStation == nullptr) {
466         vsyncStation = std::make_shared<VsyncStation>(DisplayId(0));
467     }
468     window->vsyncStation_ = nullptr;
469     ASSERT_EQ(window->GetVSyncPeriod(), 0);
470 
471     window->vsyncStation_ = vsyncStation;
472     window->GetVSyncPeriod();
473     window->Destroy();
474 }
475 
476 /**
477  * @tc.name: FlushFrameRate
478  * @tc.desc: FlushFrameRate
479  * @tc.type: FUNC
480  */
481 HWTEST_F(WindowSessionImplTest2, FlushFrameRate, Function | SmallTest | Level2)
482 {
483     auto window = GetTestWindowImpl("FlushFrameRate");
484     ASSERT_NE(window, nullptr);
485 
486     auto vsyncStation = window->vsyncStation_;
487     if (vsyncStation == nullptr) {
488         vsyncStation = std::make_shared<VsyncStation>(DisplayId(0));
489     }
490     window->vsyncStation_ = nullptr;
491     window->FlushFrameRate(1, -1);
492 
493     window->vsyncStation_ = vsyncStation;
494     window->FlushFrameRate(1, -1);
495     window->Destroy();
496 }
497 
498 /**
499  * @tc.name: FindWindowById
500  * @tc.desc: FindWindowById
501  * @tc.type: FUNC
502  */
503 HWTEST_F(WindowSessionImplTest2, FindWindowById, Function | SmallTest | Level2)
504 {
505     auto window = GetTestWindowImpl("FindWindowById");
506     ASSERT_NE(window, nullptr);
507     window->windowSessionMap_.clear();
508     ASSERT_EQ(window->FindWindowById(0), nullptr);
509 
510     window->windowSessionMap_.insert({ "test1", std::pair<int32_t, sptr<WindowSessionImpl>>(1, window) });
511     window->windowSessionMap_.insert({ "test2", std::pair<int32_t, sptr<WindowSessionImpl>>(2, window) });
512     ASSERT_EQ(window->FindWindowById(0), nullptr);
513 
514     window->windowSessionMap_.insert({ "test0", std::pair<int32_t, sptr<WindowSessionImpl>>(0, window) });
515     ASSERT_NE(window->FindWindowById(0), nullptr);
516     window->Destroy();
517 }
518 
519 /**
520  * @tc.name: SetLayoutFullScreenByApiVersion
521  * @tc.desc: SetLayoutFullScreenByApiVersion
522  * @tc.type: FUNC
523  */
524 HWTEST_F(WindowSessionImplTest2, SetLayoutFullScreenByApiVersion, Function | SmallTest | Level2)
525 {
526     auto window = GetTestWindowImpl("SetLayoutFullScreenByApiVersion");
527     ASSERT_NE(window, nullptr);
528     window->windowSessionMap_.clear();
529     ASSERT_EQ(window->SetLayoutFullScreenByApiVersion(true), WMError::WM_OK);
530     window->Destroy();
531 }
532 
533 /**
534  * @tc.name: SetSystemBarProperty
535  * @tc.desc: SetSystemBarProperty
536  * @tc.type: FUNC
537  */
538 HWTEST_F(WindowSessionImplTest2, SetSystemBarProperty, Function | SmallTest | Level2)
539 {
540     auto window = GetTestWindowImpl("SetSystemBarProperty");
541     ASSERT_NE(window, nullptr);
542     window->windowSessionMap_.clear();
543     SystemBarProperty property;
544     ASSERT_EQ(window->SetSystemBarProperty(WindowType::APP_MAIN_WINDOW_END, property), WMError::WM_OK);
545     window->Destroy();
546 }
547 
548 /**
549  * @tc.name: SetSpecificBarProperty
550  * @tc.desc: SetSpecificBarProperty
551  * @tc.type: FUNC
552  */
553 HWTEST_F(WindowSessionImplTest2, SetSpecificBarProperty, Function | SmallTest | Level2)
554 {
555     auto window = GetTestWindowImpl("SetSpecificBarProperty");
556     ASSERT_NE(window, nullptr);
557     window->windowSessionMap_.clear();
558     SystemBarProperty property;
559     ASSERT_EQ(window->SetSpecificBarProperty(WindowType::APP_MAIN_WINDOW_END, property), WMError::WM_OK);
560     window->Destroy();
561 }
562 
563 /**
564  * @tc.name: NotifyOccupiedAreaChangeInfo
565  * @tc.desc: NotifyOccupiedAreaChangeInfo
566  * @tc.type: FUNC
567  */
568 HWTEST_F(WindowSessionImplTest2, NotifyOccupiedAreaChangeInfo, Function | SmallTest | Level2)
569 {
570     auto window = GetTestWindowImpl("NotifyOccupiedAreaChangeInfo");
571     ASSERT_NE(window, nullptr);
572 
573     auto listeners = GetListenerList<IOccupiedAreaChangeListener, MockIOccupiedAreaChangeListener>();
574     ASSERT_NE(listeners.size(), 0);
575     listeners.insert(listeners.begin(), nullptr);
576     window->occupiedAreaChangeListeners_.insert({ window->GetPersistentId(), listeners });
577 
578     sptr<OccupiedAreaChangeInfo> info = sptr<OccupiedAreaChangeInfo>::MakeSptr();
579     window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
580     window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
581     window->NotifyOccupiedAreaChangeInfo(info);
582 
583     window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
584     window->NotifyOccupiedAreaChangeInfo(info);
585 
586     window->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
587     window->windowSessionMap_.insert(
588         { "test1", std::pair<int32_t, sptr<WindowSessionImpl>>(window->GetPersistentId(), nullptr) });
589     window->NotifyOccupiedAreaChangeInfo(info);
590     window->windowSessionMap_.clear();
591 
592     window->windowSessionMap_.insert(
593         { "test1", std::pair<int32_t, sptr<WindowSessionImpl>>(window->GetPersistentId(), window) });
594     window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
595     window->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
596     window->NotifyOccupiedAreaChangeInfo(info);
597 
598     window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
599     window->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
600     window->NotifyOccupiedAreaChangeInfo(info);
601 
602     window->handler_ = nullptr;
603     window->NotifyOccupiedAreaChangeInfo(info);
604     window->Destroy();
605 }
606 
607 /**
608  * @tc.name: NotifyOccupiedAreaChangeInfoInner
609  * @tc.desc: NotifyOccupiedAreaChangeInfoInner
610  * @tc.type: FUNC
611  */
612 HWTEST_F(WindowSessionImplTest2, NotifyOccupiedAreaChangeInfoInner, Function | SmallTest | Level2)
613 {
614     auto window = GetTestWindowImpl("NotifyOccupiedAreaChangeInfoInner");
615     ASSERT_NE(window, nullptr);
616 
617     auto listeners = GetListenerList<IOccupiedAreaChangeListener, MockIOccupiedAreaChangeListener>();
618     ASSERT_NE(listeners.size(), 0);
619     listeners.insert(listeners.begin(), nullptr);
620     window->occupiedAreaChangeListeners_.insert({ window->GetPersistentId(), listeners });
621 
622     window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
623     sptr<OccupiedAreaChangeInfo> info = sptr<OccupiedAreaChangeInfo>::MakeSptr();
624     window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
625     window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
626     window->NotifyOccupiedAreaChangeInfoInner(info);
627 
628     window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
629     window->NotifyOccupiedAreaChangeInfoInner(info);
630 
631     window->windowSystemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW;
632     window->windowSystemConfig_.freeMultiWindowEnable_ = false;
633     window->NotifyOccupiedAreaChangeInfoInner(info);
634 
635     window->windowSystemConfig_.freeMultiWindowEnable_ = true;
636     window->windowSystemConfig_.freeMultiWindowSupport_ = true;
637     window->NotifyOccupiedAreaChangeInfoInner(info);
638 
639     window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
640     window->NotifyOccupiedAreaChangeInfoInner(info);
641 
642     window->Destroy();
643 }
644 
645 /**
646  * @tc.name: NotifyWindowStatusChange
647  * @tc.desc: NotifyWindowStatusChange
648  * @tc.type: FUNC
649  */
650 HWTEST_F(WindowSessionImplTest2, NotifyWindowStatusChange, Function | SmallTest | Level2)
651 {
652     auto window = GetTestWindowImpl("NotifyWindowStatusChange");
653     ASSERT_NE(window, nullptr);
654 
655     auto listeners = GetListenerList<IWindowStatusChangeListener, MockWindowStatusChangeListener>();
656     ASSERT_NE(listeners.size(), 0);
657     listeners.insert(listeners.begin(), nullptr);
658     window->windowStatusChangeListeners_.insert({ window->GetPersistentId(), listeners });
659 
660     WindowMode mode = WindowMode::WINDOW_MODE_FLOATING;
661     window->state_ = WindowState::STATE_HIDDEN;
662     window->property_->SetMaximizeMode(MaximizeMode::MODE_AVOID_SYSTEM_BAR);
663     window->NotifyWindowStatusChange(mode);
664 
665     window->state_ = WindowState::STATE_FROZEN;
666     window->property_->SetMaximizeMode(MaximizeMode::MODE_FULL_FILL);
667     window->NotifyWindowStatusChange(mode);
668 
669     mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY;
670     window->NotifyWindowStatusChange(mode);
671 
672     mode = WindowMode::WINDOW_MODE_SPLIT_SECONDARY;
673     window->NotifyWindowStatusChange(mode);
674 
675     mode = WindowMode::WINDOW_MODE_PIP;
676     window->NotifyWindowStatusChange(mode);
677     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
678 }
679 
680 /**
681  * @tc.name: UpdatePiPRect
682  * @tc.desc: UpdatePiPRect
683  * @tc.type: FUNC
684  */
685 HWTEST_F(WindowSessionImplTest2, UpdatePiPRect, Function | SmallTest | Level2)
686 {
687     auto window = GetTestWindowImpl("UpdatePiPRect");
688     ASSERT_NE(window, nullptr);
689 
690     window->property_->SetPersistentId(1);
691     window->state_ = WindowState::STATE_FROZEN;
692     Rect rect;
693     window->UpdatePiPRect(rect, WindowSizeChangeReason::PIP_RATIO_CHANGE);
694 
695     window->hostSession_ = nullptr;
696     window->UpdatePiPRect(rect, WindowSizeChangeReason::PIP_RATIO_CHANGE);
697     window->Destroy();
698 }
699 
700 /**
701  * @tc.name: NotifyTransformChange
702  * @tc.desc: NotifyTransformChange
703  * @tc.type: FUNC
704  */
705 HWTEST_F(WindowSessionImplTest2, NotifyTransformChange, Function | SmallTest | Level2)
706 {
707     auto window = GetTestWindowImpl("NotifyTransformChange");
708     ASSERT_NE(window, nullptr);
709 
710     Transform transform;
711     window->NotifyTransformChange(transform);
712 
713     window->uiContent_ = std::make_unique<Ace::UIContentMocker>();
714     window->NotifyTransformChange(transform);
715     window->Destroy();
716 }
717 
718 /**
719  * @tc.name: SubmitNoInteractionMonitorTask
720  * @tc.desc: SubmitNoInteractionMonitorTask
721  * @tc.type: FUNC
722  */
723 HWTEST_F(WindowSessionImplTest2, SubmitNoInteractionMonitorTask, Function | SmallTest | Level2)
724 {
725     auto window = GetTestWindowImpl("SubmitNoInteractionMonitorTask");
726     ASSERT_NE(window, nullptr);
727 
728     IWindowNoInteractionListenerSptr listener = sptr<MockWindowNoInteractionListener>::MakeSptr();
729     window->SubmitNoInteractionMonitorTask(window->lastInteractionEventId_.load() + 1, listener);
730 
731     window->state_ = WindowState::STATE_SHOWN;
732     window->SubmitNoInteractionMonitorTask(window->lastInteractionEventId_.load(), listener);
733 
734     window->state_ = WindowState::STATE_FROZEN;
735     window->SubmitNoInteractionMonitorTask(window->lastInteractionEventId_.load(), listener);
736     window->Destroy();
737 }
738 
739 /**
740  * @tc.name: RefreshNoInteractionTimeoutMonitor
741  * @tc.desc: RefreshNoInteractionTimeoutMonitor
742  * @tc.type: FUNC
743  */
744 HWTEST_F(WindowSessionImplTest2, RefreshNoInteractionTimeoutMonitor, Function | SmallTest | Level2)
745 {
746     auto window = GetTestWindowImpl("RefreshNoInteractionTimeoutMonitor");
747     ASSERT_NE(window, nullptr);
748     window->RefreshNoInteractionTimeoutMonitor();
749     ASSERT_TRUE(window->windowNoInteractionListeners_[window->GetPersistentId()].empty());
750     ASSERT_NE(window->property_, nullptr);
751     window->property_->SetPersistentId(1);
752     sptr<IWindowNoInteractionListener> listener = sptr<MockWindowNoInteractionListener>::MakeSptr();
753     ASSERT_EQ(window->RegisterWindowNoInteractionListener(listener), WMError::WM_OK);
754     window->RefreshNoInteractionTimeoutMonitor();
755     ASSERT_EQ(window->GetPersistentId(), 1);
756     ASSERT_FALSE(window->windowNoInteractionListeners_[window->GetPersistentId()].empty());
757     window->Destroy();
758 }
759 
760 /**
761  * @tc.name: IsUserOrientation
762  * @tc.desc: IsUserOrientation
763  * @tc.type: FUNC
764  */
765 HWTEST_F(WindowSessionImplTest2, IsUserOrientation, Function | SmallTest | Level2)
766 {
767     auto window = GetTestWindowImpl("IsUserOrientation");
768     ASSERT_NE(window, nullptr);
769 
770     ASSERT_FALSE(window->IsUserOrientation(Orientation::FOLLOW_DESKTOP));
771     ASSERT_TRUE(window->IsUserOrientation(Orientation::USER_ROTATION_PORTRAIT));
772     ASSERT_TRUE(window->IsUserOrientation(Orientation::USER_ROTATION_LANDSCAPE));
773     ASSERT_TRUE(window->IsUserOrientation(Orientation::USER_ROTATION_PORTRAIT_INVERTED));
774     ASSERT_TRUE(window->IsUserOrientation(Orientation::USER_ROTATION_LANDSCAPE_INVERTED));
775     window->Destroy();
776 }
777 
778 /**
779  * @tc.name: WindowSessionCreateCheck
780  * @tc.desc: WindowSessionCreateCheck
781  * @tc.type: FUNC
782  */
783 HWTEST_F(WindowSessionImplTest2, WindowSessionCreateCheck, Function | SmallTest | Level2)
784 {
785     auto window = GetTestWindowImpl("WindowSessionCreateCheck");
786     ASSERT_NE(window, nullptr);
787 
788     int32_t nullWindowTestId = 1001;
789     int32_t displayId = 1003;
790     int32_t cameraId = 1004;
791 
792     window->windowSessionMap_.clear();
793     window->property_->SetWindowType(WindowType::WINDOW_TYPE_FLOAT_CAMERA);
794     window->windowSessionMap_.insert(std::make_pair<std::string, std::pair<int32_t, sptr<WindowSessionImpl>>>(
795         "nullWindow", std::pair<int32_t, sptr<WindowSessionImpl>>(nullWindowTestId, nullptr)));
796 
797     auto displayWindow = GetTestWindowImpl("displayWindow");
798     ASSERT_NE(displayWindow, nullptr);
799     displayWindow->property_->SetWindowType(WindowType::WINDOW_TYPE_FREEZE_DISPLAY);
800     window->windowSessionMap_.insert(std::make_pair<std::string, std::pair<int32_t, sptr<WindowSessionImpl>>>(
801         "displayWindow", std::pair<int32_t, sptr<WindowSessionImpl>>(displayId, displayWindow)));
802     ASSERT_EQ(window->WindowSessionCreateCheck(), WMError::WM_OK);
803 
804     window->windowSessionMap_.clear();
805     auto cameraWindow = GetTestWindowImpl("cameraWindow");
806     ASSERT_NE(cameraWindow, nullptr);
807     cameraWindow->property_->SetWindowType(WindowType::WINDOW_TYPE_FLOAT_CAMERA);
808     window->windowSessionMap_.insert(std::make_pair<std::string, std::pair<int32_t, sptr<WindowSessionImpl>>>(
809         "cameraWindow", std::pair<int32_t, sptr<WindowSessionImpl>>(cameraId, cameraWindow)));
810     ASSERT_EQ(window->WindowSessionCreateCheck(), WMError::WM_ERROR_REPEAT_OPERATION);
811     window->Destroy();
812     displayWindow->Destroy();
813     cameraWindow->Destroy();
814 }
815 
816 /**
817  * @tc.name: NotifyForegroundInteractiveStatus
818  * @tc.desc: NotifyForegroundInteractiveStatus
819  * @tc.type: FUNC
820  */
821 HWTEST_F(WindowSessionImplTest2, NotifyForegroundInteractiveStatus, Function | SmallTest | Level2)
822 {
823     auto window = GetTestWindowImpl("NotifyForegroundInteractiveStatus");
824     ASSERT_NE(window, nullptr);
825 
826     window->property_->SetPersistentId(1);
827     window->state_ = WindowState::STATE_SHOWN;
828     window->NotifyForegroundInteractiveStatus(true);
829     window->NotifyForegroundInteractiveStatus(false);
830 
831     window->state_ = WindowState::STATE_DESTROYED;
832     window->NotifyForegroundInteractiveStatus(true);
833     window->state_ = WindowState::STATE_FROZEN;
834     window->NotifyForegroundInteractiveStatus(true);
835     window->Destroy();
836 }
837 
838 /**
839  * @tc.name: UpdateDecorEnableToAce
840  * @tc.desc: UpdateDecorEnableToAce
841  * @tc.type: FUNC
842  */
843 HWTEST_F(WindowSessionImplTest2, UpdateDecorEnableToAce, Function | SmallTest | Level2)
844 {
845     auto window = GetTestWindowImpl("UpdateDecorEnableToAce");
846     ASSERT_NE(window, nullptr);
847     window->uiContent_ = std::make_unique<Ace::UIContentMocker>();
848     auto listeners = GetListenerList<IWindowChangeListener, MockWindowChangeListener>();
849     sptr<MockWindowChangeListener> nullListener;
850     listeners.insert(listeners.begin(), nullListener);
851     window->windowChangeListeners_.insert({ window->GetPersistentId(), listeners });
852     window->windowSystemConfig_.freeMultiWindowSupport_ = false;
853     window->UpdateDecorEnableToAce(false);
854 
855     window->uiContent_ = nullptr;
856     window->UpdateDecorEnableToAce(false);
857     EXPECT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
858 }
859 
860 /**
861  * @tc.name: UpdateDecorEnable
862  * @tc.desc: UpdateDecorEnable
863  * @tc.type: FUNC
864  */
865 HWTEST_F(WindowSessionImplTest2, UpdateDecorEnable, Function | SmallTest | Level2)
866 {
867     auto window = GetTestWindowImpl("UpdateDecorEnable");
868     ASSERT_NE(window, nullptr);
869     window->uiContent_ = std::make_unique<Ace::UIContentMocker>();
870     window->windowSystemConfig_.freeMultiWindowSupport_ = true;
871     window->UpdateDecorEnable(true, WindowMode::WINDOW_MODE_UNDEFINED);
872 
873     window->windowSystemConfig_.freeMultiWindowSupport_ = false;
874     window->UpdateDecorEnable(true, WindowMode::WINDOW_MODE_FULLSCREEN);
875 
876     window->uiContent_ = nullptr;
877     window->UpdateDecorEnable(true, WindowMode::WINDOW_MODE_FULLSCREEN);
878     window->UpdateDecorEnable(false, WindowMode::WINDOW_MODE_FULLSCREEN);
879     window->Destroy();
880 }
881 
882 /**
883  * @tc.name: NotifyModeChange
884  * @tc.desc: NotifyModeChange
885  * @tc.type: FUNC
886  */
887 HWTEST_F(WindowSessionImplTest2, NotifyModeChange, Function | SmallTest | Level2)
888 {
889     auto window = GetTestWindowImpl("NotifyModeChange");
890     ASSERT_NE(window, nullptr);
891     auto listeners = GetListenerList<IWindowChangeListener, MockWindowChangeListener>();
892     sptr<MockWindowChangeListener> nullListener;
893     listeners.insert(listeners.begin(), nullListener);
894     window->windowChangeListeners_.insert({ window->GetPersistentId(), listeners });
895 
896     window->NotifyModeChange(WindowMode::WINDOW_MODE_FULLSCREEN, true);
897     window->Destroy();
898 }
899 
900 /**
901  * @tc.name: SetRequestedOrientation
902  * @tc.desc: SetRequestedOrientation
903  * @tc.type: FUNC
904  */
905 HWTEST_F(WindowSessionImplTest2, SetRequestedOrientation, Function | SmallTest | Level2)
906 {
907     auto window = GetTestWindowImpl("SetRequestedOrientation");
908     ASSERT_NE(window, nullptr);
909     window->property_->SetRequestedOrientation(Orientation::BEGIN);
910     window->SetRequestedOrientation(Orientation::END);
911 
912     window->property_->SetRequestedOrientation(Orientation::USER_ROTATION_PORTRAIT);
913     window->SetRequestedOrientation(Orientation::USER_ROTATION_PORTRAIT);
914 
915     window->property_->SetRequestedOrientation(Orientation::BEGIN);
916     window->SetRequestedOrientation(Orientation::BEGIN);
917     window->Destroy();
918 }
919 
920 /**
921  * @tc.name: GetContentInfo
922  * @tc.desc: GetContentInfo
923  * @tc.type: FUNC
924  */
925 HWTEST_F(WindowSessionImplTest2, GetContentInfo, Function | SmallTest | Level2)
926 {
927     auto window = GetTestWindowImpl("GetContentInfo");
928     ASSERT_NE(window, nullptr);
929 
930     ASSERT_EQ(window->GetContentInfo(BackupAndRestoreType::CONTINUATION), "");
931     ASSERT_EQ(window->GetContentInfo(BackupAndRestoreType::APP_RECOVERY), "");
932     ASSERT_EQ(window->GetContentInfo(BackupAndRestoreType::NONE), "");
933     window->uiContent_ = std::make_unique<Ace::UIContentMocker>();
934     window->GetContentInfo(BackupAndRestoreType::NONE);
935     window->Destroy();
936 }
937 
938 /**
939  * @tc.name: SetDecorHeight
940  * @tc.desc: SetDecorHeight
941  * @tc.type: FUNC
942  */
943 HWTEST_F(WindowSessionImplTest2, SetDecorHeight, Function | SmallTest | Level2)
944 {
945     auto window = GetTestWindowImpl("SetDecorHeight");
946     ASSERT_NE(window, nullptr);
947     int32_t height = 50;
948     EXPECT_EQ(window->SetDecorHeight(height), WMError::WM_ERROR_INVALID_WINDOW);
949     window->property_->SetPersistentId(1);
950     window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
951     EXPECT_EQ(window->SetDecorHeight(height), WMError::WM_ERROR_NULLPTR);
952 
953     window->property_->SetDisplayId(0);
954     auto uiContent = std::make_unique<Ace::UIContentMocker>();
955     window->uiContent_ = std::move(uiContent);
956     EXPECT_EQ(window->SetDecorHeight(height), WMError::WM_OK);
957     window->property_->SetDisplayId(-1);
958     EXPECT_EQ(window->SetDecorHeight(height), WMError::WM_ERROR_NULLPTR);
959     window->property_->SetDisplayId(0);
960     EXPECT_EQ(window->SetDecorHeight(height), WMError::WM_OK);
961     window->Destroy();
962 }
963 
964 /**
965  * @tc.name: GetDecorHeight01
966  * @tc.desc: GetDecorHeight
967  * @tc.type: FUNC
968  */
969 HWTEST_F(WindowSessionImplTest2, GetDecorHeight01, Function | SmallTest | Level2)
970 {
971     auto window = GetTestWindowImpl("GetDecorHeight01");
972     ASSERT_NE(window, nullptr);
973     int32_t height = -1;
974     EXPECT_EQ(window->GetDecorHeight(height), WMError::WM_ERROR_INVALID_WINDOW);
975     window->property_->SetPersistentId(1);
976     window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
977     EXPECT_EQ(window->GetDecorHeight(height), WMError::WM_ERROR_NULLPTR);
978 
979     auto uiContent = std::make_unique<Ace::UIContentMocker>();
980     EXPECT_CALL(*uiContent, GetContainerModalTitleHeight()).WillRepeatedly(Return(-1));
981     window->uiContent_ = std::move(uiContent);
982     EXPECT_EQ(window->GetDecorHeight(height), WMError::WM_OK);
983     window->Destroy();
984 }
985 
986 /**
987  * @tc.name: GetDecorHeight02
988  * @tc.desc: GetDecorHeight
989  * @tc.type: FUNC
990  */
991 HWTEST_F(WindowSessionImplTest2, GetDecorHeight02, Function | SmallTest | Level2)
992 {
993     auto window = GetTestWindowImpl("GetDecorHeight02");
994     ASSERT_NE(window, nullptr);
995     int32_t height = -1;
996     EXPECT_EQ(window->GetDecorHeight(height), WMError::WM_ERROR_INVALID_WINDOW);
997     window->property_->SetPersistentId(1);
998     window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
999     EXPECT_EQ(window->GetDecorHeight(height), WMError::WM_ERROR_NULLPTR);
1000 
1001     auto uiContent = std::make_unique<Ace::UIContentMocker>();
1002     EXPECT_CALL(*uiContent, GetContainerModalTitleHeight()).WillRepeatedly(Return(1));
1003     window->uiContent_ = std::move(uiContent);
1004     window->property_->SetDisplayId(-1);
1005     EXPECT_EQ(window->GetDecorHeight(height), WMError::WM_ERROR_NULLPTR);
1006     window->property_->SetDisplayId(0);
1007     EXPECT_EQ(window->GetDecorHeight(height), WMError::WM_OK);
1008     height = 1;
1009     EXPECT_EQ(window->GetDecorHeight(height), WMError::WM_OK);
1010     window->Destroy();
1011 }
1012 
1013 /**
1014  * @tc.name: GetDecorHeight03
1015  * @tc.desc: GetDecorHeight version isolation test cases
1016  * @tc.type: FUNC
1017  */
1018 HWTEST_F(WindowSessionImplTest2, GetDecorHeight03, Function | SmallTest | Level2)
1019 {
1020     auto window = GetTestWindowImpl("GetDecorHeight03");
1021     ASSERT_NE(window, nullptr);
1022     window->property_->SetPersistentId(1);
1023     window->property_->SetDisplayId(0);
1024     window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
1025     window->useUniqueDensity_ = true;
1026     window->virtualPixelRatio_ = 1.9f;
1027     auto uiContent = std::make_unique<Ace::UIContentMocker>();
1028     EXPECT_CALL(*uiContent, GetContainerModalTitleHeight()).WillRepeatedly(Return(72));
1029     window->uiContent_ = std::move(uiContent);
1030     int32_t decorHeight = 38;
1031     window->SetDecorHeight(decorHeight);
1032     EXPECT_EQ(window->decorHeight_, decorHeight);
1033 
1034     window->SetTargetAPIVersion(14);
1035     int32_t height = -1;
1036     EXPECT_EQ(window->GetDecorHeight(height), WMError::WM_OK);
1037     EXPECT_EQ(height, 37);
1038     window->SetTargetAPIVersion(18);
1039     EXPECT_EQ(window->GetDecorHeight(height), WMError::WM_OK);
1040     EXPECT_NE(height, 37);
1041     window->Destroy();
1042 }
1043 
1044 /**
1045  * @tc.name: GetTitleButtonArea01
1046  * @tc.desc: GetTitleButtonArea
1047  * @tc.type: FUNC
1048  */
1049 HWTEST_F(WindowSessionImplTest2, GetTitleButtonArea01, Function | SmallTest | Level2)
1050 {
1051     auto window = GetTestWindowImpl("GetTitleButtonArea01");
1052     ASSERT_NE(window, nullptr);
1053     TitleButtonRect titleButtonRect;
1054     EXPECT_EQ(window->GetTitleButtonArea(titleButtonRect), WMError::WM_ERROR_INVALID_WINDOW);
1055     window->property_->SetPersistentId(1);
1056     window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
1057 
1058     window->uiContent_ = nullptr;
1059     EXPECT_EQ(window->GetTitleButtonArea(titleButtonRect), WMError::WM_ERROR_NULLPTR);
1060     auto uiContent = std::make_unique<Ace::UIContentMocker>();
1061     EXPECT_CALL(*uiContent, GetContainerModalButtonsRect(testing::_, testing::_)).WillRepeatedly(Return(false));
1062     window->uiContent_ = std::move(uiContent);
1063     ASSERT_EQ(window->GetTitleButtonArea(titleButtonRect), WMError::WM_OK);
1064     window->Destroy();
1065 }
1066 
1067 /**
1068  * @tc.name: GetTitleButtonArea02
1069  * @tc.desc: GetTitleButtonArea
1070  * @tc.type: FUNC
1071  */
1072 HWTEST_F(WindowSessionImplTest2, GetTitleButtonArea02, Function | SmallTest | Level2)
1073 {
1074     auto window = GetTestWindowImpl("GetTitleButtonArea02");
1075     ASSERT_NE(window, nullptr);
1076     TitleButtonRect titleButtonRect;
1077     EXPECT_EQ(window->GetTitleButtonArea(titleButtonRect), WMError::WM_ERROR_INVALID_WINDOW);
1078     window->property_->SetPersistentId(1);
1079     window->property_->SetDisplayId(0);
1080     window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
1081 
1082     EXPECT_EQ(window->GetTitleButtonArea(titleButtonRect), WMError::WM_ERROR_NULLPTR);
1083     auto uiContent = std::make_unique<Ace::UIContentMocker>();
1084     EXPECT_CALL(*uiContent, GetContainerModalButtonsRect(testing::_, testing::_)).WillRepeatedly(Return(true));
1085     window->uiContent_ = std::move(uiContent);
1086     EXPECT_EQ(window->GetTitleButtonArea(titleButtonRect), WMError::WM_OK);
1087     window->property_->SetDisplayId(-1);
1088     EXPECT_EQ(window->GetTitleButtonArea(titleButtonRect), WMError::WM_ERROR_NULLPTR);
1089     window->property_->SetDisplayId(0);
1090     EXPECT_EQ(window->GetTitleButtonArea(titleButtonRect), WMError::WM_OK);
1091     window->Destroy();
1092 }
1093 
1094 /**
1095  * @tc.name: GetTitleButtonArea03
1096  * @tc.desc: GetTitleButtonArea
1097  * @tc.type: FUNC
1098  */
1099 HWTEST_F(WindowSessionImplTest2, GetTitleButtonArea03, Function | SmallTest | Level2)
1100 {
1101     auto window = GetTestWindowImpl("GetTitleButtonArea03");
1102     ASSERT_NE(window, nullptr);
1103     TitleButtonRect titleButtonRect = { 1400, 0, 0, 0 };
1104     window->property_->SetPersistentId(1);
1105     window->property_->SetDisplayId(0);
1106     window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
1107     auto uiContent = std::make_unique<Ace::UIContentMocker>();
1108     EXPECT_CALL(*uiContent, GetContainerModalButtonsRect(testing::_, testing::_)).WillRepeatedly(Return(false));
1109     window->uiContent_ = std::move(uiContent);
1110     window->SetTargetAPIVersion(14);
1111     EXPECT_EQ(window->GetTitleButtonArea(titleButtonRect), WMError::WM_OK);
1112     EXPECT_EQ(titleButtonRect.IsUninitializedRect(), false);
1113 
1114     window->SetTargetAPIVersion(18);
1115     EXPECT_EQ(window->GetTitleButtonArea(titleButtonRect), WMError::WM_OK);
1116     EXPECT_EQ(titleButtonRect.IsUninitializedRect(), false);
1117     window->Destroy();
1118 }
1119 
1120 /**
1121  * @tc.name: RegisterWindowTitleButtonRectChangeListener
1122  * @tc.desc: RegisterWindowTitleButtonRectChangeListener
1123  * @tc.type: FUNC
1124  */
1125 HWTEST_F(WindowSessionImplTest2, RegisterWindowTitleButtonRectChangeListener, Function | SmallTest | Level2)
1126 {
1127     auto window = GetTestWindowImpl("RegisterWindowTitleButtonRectChangeListener");
1128     ASSERT_NE(window, nullptr);
1129     window->uiContent_ = std::make_unique<Ace::UIContentMocker>();
1130     sptr<IWindowTitleButtonRectChangedListener> listener = sptr<MockWindowTitleButtonRectChangedListener>::MakeSptr();
1131     window->RegisterWindowTitleButtonRectChangeListener(listener);
1132     window->Destroy();
1133 }
1134 
1135 /**
1136  * @tc.name: UnregisterWindowTitleButtonRectChangeListener
1137  * @tc.desc: UnregisterWindowTitleButtonRectChangeListener
1138  * @tc.type: FUNC
1139  */
1140 HWTEST_F(WindowSessionImplTest2, UnregisterWindowTitleButtonRectChangeListener, Function | SmallTest | Level2)
1141 {
1142     auto window = GetTestWindowImpl("UnregisterWindowTitleButtonRectChangeListener");
1143     ASSERT_NE(window, nullptr);
1144     sptr<IWindowTitleButtonRectChangedListener> listener = sptr<MockWindowTitleButtonRectChangedListener>::MakeSptr();
1145     ASSERT_NE(listener, nullptr);
1146     window->UnregisterWindowTitleButtonRectChangeListener(listener);
1147 
1148     window->uiContent_ = std::make_unique<Ace::UIContentMocker>();
1149     window->UnregisterWindowTitleButtonRectChangeListener(listener);
1150     window->Destroy();
1151 }
1152 
1153 /**
1154  * @tc.name: NotifyWindowTitleButtonRectChange
1155  * @tc.desc: NotifyWindowTitleButtonRectChange
1156  * @tc.type: FUNC
1157  */
1158 HWTEST_F(WindowSessionImplTest2, NotifyWindowTitleButtonRectChange, Function | SmallTest | Level2)
1159 {
1160     auto window = GetTestWindowImpl("NotifyWindowTitleButtonRectChange");
1161     ASSERT_NE(window, nullptr);
1162     auto listeners = GetListenerList<IWindowTitleButtonRectChangedListener, MockWindowTitleButtonRectChangedListener>();
1163     listeners.insert(listeners.begin(), nullptr);
1164     window->windowTitleButtonRectChangeListeners_.insert({ window->GetPersistentId(), listeners });
1165     TitleButtonRect titleButtonRect;
1166     window->NotifyWindowTitleButtonRectChange(titleButtonRect);
1167     window->Destroy();
1168 }
1169 
1170 /**
1171  * @tc.name: RegisterWindowRectChangeListener
1172  * @tc.desc: RegisterWindowRectChangeListener
1173  * @tc.type: FUNC
1174  */
1175 HWTEST_F(WindowSessionImplTest2, RegisterWindowRectChangeListener, Function | SmallTest | Level2)
1176 {
1177     auto window = GetTestWindowImpl("RegisterWindowRectChangeListener");
1178     ASSERT_NE(window, nullptr);
1179     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->RegisterWindowRectChangeListener(nullptr));
1180 
1181     sptr<IWindowRectChangeListener> listener = sptr<MockWindowRectChangeListener>::MakeSptr();
1182     ASSERT_NE(listener, nullptr);
1183     ASSERT_EQ(WMError::WM_OK, window->RegisterWindowRectChangeListener(listener));
1184 
1185     window->hostSession_ = nullptr;
1186     ASSERT_EQ(WMError::WM_OK, window->RegisterWindowRectChangeListener(listener));
1187     window->Destroy();
1188 }
1189 
1190 /**
1191  * @tc.name: UnregisterWindowRectChangeListener
1192  * @tc.desc: UnregisterWindowRectChangeListener01
1193  * @tc.type: FUNC
1194  */
1195 HWTEST_F(WindowSessionImplTest2, UnregisterWindowRectChangeListener01, Function | SmallTest | Level2)
1196 {
1197     GTEST_LOG_(INFO) << "WindowSessionImplTest2: UnregisterWindowRectChangeListener01 start";
1198     auto window = GetTestWindowImpl("UnregisterWindowRectChangeListener01");
1199     ASSERT_NE(window, nullptr);
1200     window->hostSession_ = nullptr;
1201     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->RegisterWindowRectChangeListener(nullptr));
1202     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->UnregisterWindowRectChangeListener(nullptr));
1203 
1204     sptr<IWindowRectChangeListener> listener = sptr<MockWindowRectChangeListener>::MakeSptr();
1205     ASSERT_NE(listener, nullptr);
1206     ASSERT_EQ(WMError::WM_OK, window->RegisterWindowRectChangeListener(listener));
1207     ASSERT_EQ(WMError::WM_OK, window->UnregisterWindowRectChangeListener(listener));
1208 
1209     SessionInfo sessionInfo = { "CreateTestBunble", "CreateTestModule", "CreateTestAbility" };
1210     sptr<SessionMocker> hostSession = sptr<SessionMocker>::MakeSptr(sessionInfo);
1211     window->hostSession_ = hostSession;
1212     ASSERT_EQ(WMError::WM_OK, window->RegisterWindowRectChangeListener(listener));
1213     ASSERT_EQ(WMError::WM_OK, window->UnregisterWindowRectChangeListener(listener));
1214     window->Destroy();
1215     GTEST_LOG_(INFO) << "WindowSessionImplTest2: UnregisterWindowRectChangeListener01 end";
1216 }
1217 
1218 /**
1219  * @tc.name: GetVirtualPixelRatio
1220  * @tc.desc: GetVirtualPixelRatio
1221  * @tc.type: FUNC
1222  */
1223 HWTEST_F(WindowSessionImplTest2, GetVirtualPixelRatio, Function | SmallTest | Level2)
1224 {
1225     GTEST_LOG_(INFO) << "WindowSessionImplTest2: GetVirtualPixelRatio start";
1226     auto window = GetTestWindowImpl("GetVirtualPixelRatio");
1227     ASSERT_NE(nullptr, window);
1228     sptr<DisplayInfo> displayInfo = sptr<DisplayInfo>::MakeSptr();
1229     float density = 2.0f;
1230     displayInfo->SetVirtualPixelRatio(density);
1231     float vpr = window->GetVirtualPixelRatio(displayInfo);
1232     ASSERT_EQ(density, vpr);
1233 
1234     window->useUniqueDensity_ = true;
1235     vpr = window->GetVirtualPixelRatio(displayInfo);
1236     ASSERT_EQ(window->virtualPixelRatio_, vpr);
1237     GTEST_LOG_(INFO) << "WindowSessionImplTest2: GetVirtualPixelRatio end";
1238 }
1239 
1240 /**
1241  * @tc.name: NotifyScreenshot
1242  * @tc.desc: NotifyScreenshot01 listener==nullptr
1243  * @tc.type: FUNC
1244  */
1245 HWTEST_F(WindowSessionImplTest2, NotifyScreenshot01, Function | SmallTest | Level2)
1246 {
1247     GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifyScreenshot01 start";
1248     class MockIScrenshotListener : public IScreenshotListener {
1249     public:
1250         MOCK_METHOD0(OnScreenshot, void());
1251     };
1252     window_ = GetTestWindowImpl("NotifyScreenshot01");
1253     auto listeners = GetListenerList<IScreenshotListener, MockIScrenshotListener>();
1254     listeners[0] = nullptr;
1255     ASSERT_EQ(listeners.size(), 1);
1256     window_->screenshotListeners_.insert({ window_->GetPersistentId(), listeners });
1257     window_->NotifyScreenshot();
1258     std::vector<sptr<IScreenshotListener>> screenshotListeners =
1259         window_->screenshotListeners_[window_->GetPersistentId()];
1260     ASSERT_NE(std::find(screenshotListeners.begin(), screenshotListeners.end(), nullptr), screenshotListeners.end());
1261     GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifyScreenshot01 end";
1262 }
1263 
1264 /**
1265  * @tc.name: NotifyScreenshot
1266  * @tc.desc: NotifyScreenshot02 listener!=nullptr
1267  * @tc.type: FUNC
1268  */
1269 HWTEST_F(WindowSessionImplTest2, NotifyScreenshot02, Function | SmallTest | Level2)
1270 {
1271     GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifyScreenshot02 start";
1272     class ScreenshotListener : public IScreenshotListener {
1273     public:
OnScreenshot()1274         void OnScreenshot()
1275         {
1276             GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifyScreenshot02 OnScreenshot";
1277             SUCCEED();
1278         }
1279     };
1280     window_ = GetTestWindowImpl("NotifyScreenshot02");
1281     sptr<IScreenshotListener> listener = new (std::nothrow) ScreenshotListener();
1282     window_->RegisterScreenshotListener(listener);
1283     window_->NotifyScreenshot();
1284     window_->UnregisterScreenshotListener(listener);
1285     GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifyScreenshot02 end";
1286 }
1287 
1288 /**
1289  * @tc.name: NotifyTouchDialogTarget
1290  * @tc.desc: NotifyTouchDialogTarget01 hostSession_==nullptr
1291  * @tc.type: FUNC
1292  */
1293 HWTEST_F(WindowSessionImplTest2, NotifyTouchDialogTarget01, Function | SmallTest | Level2)
1294 {
1295     GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifyTouchDialogTarget01 start";
1296     window_ = GetTestWindowImpl("NotifyTouchDialogTarget01");
1297     int32_t posX = 100;
1298     int32_t posY = 100;
1299     window_->hostSession_ = nullptr;
1300     window_->NotifyTouchDialogTarget(posX, posY);
1301     sptr<ISession> hostSession = window_->GetHostSession();
1302     ASSERT_EQ(nullptr, hostSession);
1303     GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifyTouchDialogTarget01 end";
1304 }
1305 
1306 /**
1307  * @tc.name: NotifyTouchDialogTarget
1308  * @tc.desc: NotifyTouchDialogTarget02 hostSession_!=nullptr
1309  * @tc.type: FUNC
1310  */
1311 HWTEST_F(WindowSessionImplTest2, NotifyTouchDialogTarget02, Function | SmallTest | Level2)
1312 {
1313     GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifyTouchDialogTarget02 start";
1314     window_ = GetTestWindowImpl("NotifyTouchDialogTarget02");
1315     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1316     sptr<SessionMocker> hostSession = sptr<SessionMocker>::MakeSptr(sessionInfo);
1317     window_->hostSession_ = hostSession;
1318     int32_t posX = 100;
1319     int32_t posY = 100;
1320     window_->NotifyTouchDialogTarget(posX, posY);
1321     sptr<ISession> hostSession1 = window_->GetHostSession();
1322     ASSERT_NE(nullptr, hostSession1);
1323     GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifyTouchDialogTarget02 end";
1324 }
1325 
1326 /**
1327  * @tc.name: NotifyTouchDialogTarget
1328  * @tc.desc: NotifyTouchDialogTarget03 hostSession_==nullptr listener==nullptr
1329  * @tc.type: FUNC
1330  */
1331 HWTEST_F(WindowSessionImplTest2, NotifyTouchDialogTarget03, Function | SmallTest | Level2)
1332 {
1333     GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifyTouchDialogTarget03 start";
1334     class MockIDialogTargetTouchListener : public IDialogTargetTouchListener {
1335     public:
1336         MOCK_CONST_METHOD0(OnDialogTargetTouch, void());
1337     };
1338     window_ = GetTestWindowImpl("NotifyTouchDialogTarget03");
1339     window_->hostSession_ = nullptr;
1340     auto listeners = GetListenerList<IDialogTargetTouchListener, MockIDialogTargetTouchListener>();
1341     listeners[0] = nullptr;
1342     (window_->dialogTargetTouchListener_)[window_->GetPersistentId()] = listeners;
1343     int32_t posX = 100;
1344     int32_t posY = 100;
1345     window_->NotifyTouchDialogTarget(posX, posY);
1346     std::vector<sptr<IDialogTargetTouchListener>> dialogTargetTouchListeners =
1347         (window_->dialogTargetTouchListener_)[window_->GetPersistentId()];
1348     ASSERT_NE(std::find(dialogTargetTouchListeners.begin(), dialogTargetTouchListeners.end(), nullptr),
1349               dialogTargetTouchListeners.end());
1350     GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifyTouchDialogTarget03 end";
1351 }
1352 
1353 /**
1354  * @tc.name: NotifyTouchDialogTarget
1355  * @tc.desc: NotifyTouchDialogTarget04 hostSession_==nullptr listener!=nullptr
1356  * @tc.type: FUNC
1357  */
1358 HWTEST_F(WindowSessionImplTest2, NotifyTouchDialogTarget04, Function | SmallTest | Level2)
1359 {
1360     GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifyTouchDialogTarget04 start";
1361     class MockIDialogTargetTouchListener : public IDialogTargetTouchListener {
1362     public:
OnDialogTargetTouch() const1363         void OnDialogTargetTouch() const
1364         {
1365             GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifyTouchDialogTarget04 OnDialogTargetTouch";
1366             SUCCEED();
1367         }
1368     };
1369     window_ = GetTestWindowImpl("NotifyTouchDialogTarget04");
1370     window_->hostSession_ = nullptr;
1371     sptr<IDialogTargetTouchListener> dialogTargetTouchListener = new (std::nothrow) MockIDialogTargetTouchListener();
1372     window_->RegisterDialogTargetTouchListener(dialogTargetTouchListener);
1373     int32_t posX = 100;
1374     int32_t posY = 100;
1375     window_->NotifyTouchDialogTarget(posX, posY);
1376     window_->UnregisterDialogTargetTouchListener(dialogTargetTouchListener);
1377     GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifyTouchDialogTarget04 end";
1378 }
1379 
1380 /**
1381  * @tc.name: NotifyDisplayMove
1382  * @tc.desc: NotifyDisplayMove01 listener==nullptr
1383  * @tc.type: FUNC
1384  */
1385 HWTEST_F(WindowSessionImplTest2, NotifyDisplayMove01, Function | SmallTest | Level2)
1386 {
1387     GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifyDisplayMove01 start";
1388     class MockIDisplayMoveListener : public IDisplayMoveListener {
1389     public:
1390         MOCK_METHOD2(OnDisplayMove, void(DisplayId from, DisplayId to));
1391     };
1392     window_ = GetTestWindowImpl("NotifyDisplayMove01");
1393     auto listeners = GetListenerList<IDisplayMoveListener, MockIDisplayMoveListener>();
1394     listeners[0] = nullptr;
1395     (window_->displayMoveListeners_)[window_->GetPersistentId()] = listeners;
1396     int32_t posX = 100;
1397     int32_t posY = 100;
1398     window_->NotifyTouchDialogTarget(posX, posY);
1399     std::vector<sptr<IDisplayMoveListener>> displayMoveListeners =
1400         (window_->displayMoveListeners_)[window_->GetPersistentId()];
1401     ASSERT_NE(std::find(displayMoveListeners.begin(), displayMoveListeners.end(), nullptr), displayMoveListeners.end());
1402     GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifyDisplayMove01 end";
1403 }
1404 
1405 /**
1406  * @tc.name: NotifyDisplayMove
1407  * @tc.desc: NotifyDisplayMove02 listener!=nullptr
1408  * @tc.type: FUNC
1409  */
1410 HWTEST_F(WindowSessionImplTest2, NotifyDisplayMove02, Function | SmallTest | Level2)
1411 {
1412     GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifyDisplayMove02 start";
1413     class MockIDisplayMoveListener : public IDisplayMoveListener {
1414     public:
OnDisplayMove(DisplayId from,DisplayId to)1415         void OnDisplayMove(DisplayId from, DisplayId to)
1416         {
1417             GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifyDisplayMove02 OnDisplayMove";
1418             SUCCEED();
1419         }
1420     };
1421     window_ = GetTestWindowImpl("NotifyDisplayMove02");
1422     sptr<IDisplayMoveListener> displayMoveListener = sptr<MockIDisplayMoveListener>::MakeSptr();
1423     EXPECT_EQ(window_->RegisterDisplayMoveListener(displayMoveListener), WMError::WM_OK);
1424     int32_t posX = 100;
1425     int32_t posY = 100;
1426     window_->NotifyTouchDialogTarget(posX, posY);
1427     EXPECT_EQ(window_->UnregisterDisplayMoveListener(displayMoveListener), WMError::WM_OK);
1428     GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifyDisplayMove02 end";
1429 }
1430 
1431 /**
1432  * @tc.name: NotifyDestroy
1433  * @tc.desc: NotifyDestroy01 listener==nullptr
1434  * @tc.type: FUNC
1435  */
1436 HWTEST_F(WindowSessionImplTest2, NotifyDestroy01, Function | SmallTest | Level2)
1437 {
1438     GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifyDestroy01 start";
1439     class MockIDialogDeathRecipientListener : public IDialogDeathRecipientListener {
1440     public:
1441         MOCK_CONST_METHOD0(OnDialogDeathRecipient, void());
1442     };
1443     window_ = GetTestWindowImpl("NotifyDestroy01");
1444     auto listeners = GetListenerList<IDialogDeathRecipientListener, MockIDialogDeathRecipientListener>();
1445     listeners[0] = nullptr;
1446     (window_->dialogDeathRecipientListeners_)[window_->GetPersistentId()] = listeners;
1447     window_->NotifyDestroy();
1448     std::vector<sptr<IDialogDeathRecipientListener>> dialogDeathRecipientListeners =
1449         (window_->dialogDeathRecipientListeners_)[window_->GetPersistentId()];
1450     ASSERT_NE(std::find(dialogDeathRecipientListeners.begin(), dialogDeathRecipientListeners.end(), nullptr),
1451               dialogDeathRecipientListeners.end());
1452     GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifyDestroy01 end";
1453 }
1454 
1455 /**
1456  * @tc.name: NotifyDestroy
1457  * @tc.desc: NotifyDestroy02 listener!=nullptr
1458  * @tc.type: FUNC
1459  */
1460 HWTEST_F(WindowSessionImplTest2, NotifyDestroy02, Function | SmallTest | Level2)
1461 {
1462     GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifyDestroy02 start";
1463     class MockIDialogDeathRecipientListener : public IDialogDeathRecipientListener {
1464     public:
OnDialogDeathRecipient() const1465         void OnDialogDeathRecipient() const
1466         {
1467             GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifyDestroy02 OnDialogDeathRecipient";
1468             SUCCEED();
1469         }
1470     };
1471     window_ = GetTestWindowImpl("NotifyDestroy02");
1472     sptr<IDialogDeathRecipientListener> listener = new (std::nothrow) MockIDialogDeathRecipientListener();
1473     window_->RegisterDialogDeathRecipientListener(listener);
1474     window_->NotifyDestroy();
1475     window_->UnregisterDialogDeathRecipientListener(listener);
1476     GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifyDestroy02 end";
1477 }
1478 
1479 /**
1480  * @tc.name: RegisterDialogTargetTouchListener
1481  * @tc.desc: RegisterDialogTargetTouchListener01 listener!=nullptr
1482  * @tc.type: FUNC
1483  */
1484 HWTEST_F(WindowSessionImplTest2, RegisterDialogTargetTouchListener01, Function | SmallTest | Level2)
1485 {
1486     GTEST_LOG_(INFO) << "WindowSessionImplTest2: RegisterDialogTargetTouchListener01 start";
1487     class MockIDialogTargetTouchListener : public IDialogTargetTouchListener {
1488     public:
OnDialogTargetTouch() const1489         void OnDialogTargetTouch() const {}
1490     };
1491     window_ = GetTestWindowImpl("RegisterDialogTargetTouchListener01");
1492     sptr<IDialogTargetTouchListener> listener = sptr<MockIDialogTargetTouchListener>::MakeSptr();
1493     WMError res = window_->RegisterDialogTargetTouchListener(listener);
1494     ASSERT_EQ(WMError::WM_OK, res);
1495     window_->UnregisterDialogTargetTouchListener(listener);
1496     GTEST_LOG_(INFO) << "WindowSessionImplTest2: RegisterDialogTargetTouchListener01 end";
1497 }
1498 
1499 /**
1500  * @tc.name: RegisterDialogDeathRecipientListener
1501  * @tc.desc: RegisterDialogDeathRecipientListener01 listener!=nullptr
1502  * @tc.type: FUNC
1503  */
1504 HWTEST_F(WindowSessionImplTest2, RegisterDialogDeathRecipientListener01, Function | SmallTest | Level2)
1505 {
1506     GTEST_LOG_(INFO) << "WindowSessionImplTest2: RegisterDialogDeathRecipientListener01 start";
1507     class MockIDialogDeathRecipientListener : public IDialogDeathRecipientListener {
1508     public:
OnDialogDeathRecipient() const1509         void OnDialogDeathRecipient() const {}
1510     };
1511     window_ = GetTestWindowImpl("RegisterDialogDeathRecipientListener01");
1512     sptr<IDialogDeathRecipientListener> listener = sptr<MockIDialogDeathRecipientListener>::MakeSptr();
1513     int32_t count = (window_->dialogDeathRecipientListeners_)[window_->GetPersistentId()].size();
1514     window_->RegisterDialogDeathRecipientListener(listener);
1515     std::vector<sptr<IDialogDeathRecipientListener>> dialogDeathRecipientListeners =
1516         (window_->dialogDeathRecipientListeners_)[window_->GetPersistentId()];
1517     ASSERT_EQ(++count, dialogDeathRecipientListeners.size());
1518     window_->UnregisterDialogDeathRecipientListener(listener);
1519     GTEST_LOG_(INFO) << "WindowSessionImplTest2: RegisterDialogDeathRecipientListener01 end";
1520 }
1521 
1522 /**
1523  * @tc.name: RegisterSubWindowCloseListeners
1524  * @tc.desc: RegisterSubWindowCloseListeners01
1525  * @tc.type: FUNC
1526  */
1527 HWTEST_F(WindowSessionImplTest2, RegisterSubWindowCloseListeners01, Function | SmallTest | Level2)
1528 {
1529     GTEST_LOG_(INFO) << "WindowSessionImplTest2: RegisterSubWindowCloseListeners01 start";
1530     class MockISubWindowCloseListener : public ISubWindowCloseListener {
1531     public:
OnSubWindowClose(bool & terminateCloseProcess)1532         void OnSubWindowClose(bool& terminateCloseProcess) {}
1533     };
1534     window_ = GetTestWindowImpl("RegisterSubWindowCloseListeners01");
1535     ASSERT_NE(window_, nullptr);
1536     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window_->RegisterSubWindowCloseListeners(nullptr));
1537     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window_->UnregisterSubWindowCloseListeners(nullptr));
1538 
1539     sptr<ISubWindowCloseListener> listener = sptr<MockISubWindowCloseListener>::MakeSptr();
1540     window_->property_->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION);
1541     ASSERT_EQ(WMError::WM_ERROR_INVALID_CALLING, window_->RegisterSubWindowCloseListeners(listener));
1542     ASSERT_EQ(WMError::WM_ERROR_INVALID_CALLING, window_->UnregisterSubWindowCloseListeners(listener));
1543 
1544     window_->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1545     ASSERT_EQ(WMError::WM_OK, window_->RegisterSubWindowCloseListeners(listener));
1546     ASSERT_EQ(WMError::WM_OK, window_->UnregisterSubWindowCloseListeners(listener));
1547     window_->Destroy();
1548     GTEST_LOG_(INFO) << "WindowSessionImplTest2: RegisterSubWindowCloseListeners01 end";
1549 }
1550 
1551 /**
1552  * @tc.name: GetListeners
1553  * @tc.desc: GetListeners01 IWindowLifeCycle
1554  * @tc.type: FUNC
1555  */
1556 HWTEST_F(WindowSessionImplTest2, GetListeners01, Function | SmallTest | Level2)
1557 {
1558     GTEST_LOG_(INFO) << "WindowSessionImplTest2: GetListeners01 start";
1559     window_ = GetTestWindowImpl("GetListeners01");
1560     ASSERT_NE(window_, nullptr);
1561     window_->lifecycleListeners_.clear();
1562     window_->NotifyWindowAfterFocused();
1563     ASSERT_TRUE(window_->lifecycleListeners_[window_->GetPersistentId()].empty());
1564     sptr<IWindowLifeCycle> listener = sptr<MockWindowLifeCycleListener>::MakeSptr();
1565     window_->RegisterLifeCycleListener(listener);
1566     window_->NotifyWindowAfterFocused();
1567     ASSERT_FALSE(window_->lifecycleListeners_[window_->GetPersistentId()].empty());
1568     window_->Destroy();
1569     GTEST_LOG_(INFO) << "WindowSessionImplTest2: GetListeners01 end";
1570 }
1571 
1572 /**
1573  * @tc.name: GetListeners
1574  * @tc.desc: GetListeners02 IOccupiedAreaChangeListener
1575  * @tc.type: FUNC
1576  */
1577 HWTEST_F(WindowSessionImplTest2, GetListeners02, Function | SmallTest | Level2)
1578 {
1579     GTEST_LOG_(INFO) << "WindowSessionImplTest2: GetListeners02 start";
1580     window_ = GetTestWindowImpl("GetListeners02");
1581     ASSERT_NE(window_, nullptr);
1582     window_->occupiedAreaChangeListeners_.clear();
1583     sptr<OccupiedAreaChangeInfo> occupiedAreaChangeInfo = sptr<OccupiedAreaChangeInfo>::MakeSptr();
1584     window_->NotifyOccupiedAreaChangeInfo(occupiedAreaChangeInfo, nullptr);
1585     ASSERT_TRUE(window_->occupiedAreaChangeListeners_[window_->GetPersistentId()].empty());
1586     sptr<IOccupiedAreaChangeListener> listener = sptr<MockIOccupiedAreaChangeListener>::MakeSptr();
1587     window_->RegisterOccupiedAreaChangeListener(listener);
1588     window_->NotifyOccupiedAreaChangeInfo(occupiedAreaChangeInfo, nullptr);
1589     ASSERT_FALSE(window_->occupiedAreaChangeListeners_[window_->GetPersistentId()].empty());
1590     window_->Destroy();
1591     GTEST_LOG_(INFO) << "WindowSessionImplTest2: GetListeners02 end";
1592 }
1593 
1594 /**
1595  * @tc.name: GetListeners
1596  * @tc.desc: GetListeners03 IKeyboardDidShowListener IKeyboardDidHideListener
1597  * @tc.type: FUNC
1598  */
1599 HWTEST_F(WindowSessionImplTest2, GetListeners03, Function | SmallTest | Level2)
1600 {
1601     GTEST_LOG_(INFO) << "WindowSessionImplTest2: GetListeners03 start";
1602     window_ = GetTestWindowImpl("GetListeners03");
1603     ASSERT_NE(window_, nullptr);
1604     KeyboardPanelInfo keyboardPanelInfo;
1605     window_->NotifyKeyboardAnimationCompleted(keyboardPanelInfo);
1606     keyboardPanelInfo.isShowing_ = true;
1607     window_->NotifyKeyboardAnimationCompleted(keyboardPanelInfo);
1608     ASSERT_TRUE(window_->keyboardDidShowListeners_[window_->GetPersistentId()].empty());
1609     ASSERT_TRUE(window_->keyboardDidHideListeners_[window_->GetPersistentId()].empty());
1610     sptr<IKeyboardDidShowListener> listener = sptr<MockIKeyboardDidShowListener>::MakeSptr();
1611     window_->RegisterKeyboardDidShowListener(listener);
1612     keyboardPanelInfo.isShowing_ = true;
1613     window_->NotifyKeyboardAnimationCompleted(keyboardPanelInfo);
1614     ASSERT_FALSE(window_->keyboardDidShowListeners_[window_->GetPersistentId()].empty());
1615     window_->UnregisterKeyboardDidShowListener(listener);
1616 
1617     sptr<IKeyboardDidHideListener> listener1 = sptr<MockIKeyboardDidHideListener>::MakeSptr();
1618     window_->RegisterKeyboardDidHideListener(listener1);
1619     keyboardPanelInfo.isShowing_ = false;
1620     window_->NotifyKeyboardAnimationCompleted(keyboardPanelInfo);
1621     ASSERT_FALSE(window_->keyboardDidHideListeners_[window_->GetPersistentId()].empty());
1622     window_->UnregisterKeyboardDidHideListener(listener1);
1623     window_->Destroy();
1624     GTEST_LOG_(INFO) << "WindowSessionImplTest2: GetListeners03 end";
1625 }
1626 
1627 /**
1628  * @tc.name: GetUIContent
1629  * @tc.desc: GetUIContent
1630  * @tc.type: FUNC
1631  */
1632 HWTEST_F(WindowSessionImplTest2, GetUIContent, Function | SmallTest | Level2)
1633 {
1634     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1635     option->SetWindowName("GetUIContent");
1636     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1637     Ace::UIContent* res = window->GetUIContent();
1638     ASSERT_EQ(res, nullptr);
1639     ASSERT_EQ(window->Destroy(), WMError::WM_ERROR_INVALID_WINDOW);
1640 }
1641 
1642 /**
1643  * @tc.name: NotifySizeChange
1644  * @tc.desc: NotifySizeChange
1645  * @tc.type: FUNC
1646  */
1647 HWTEST_F(WindowSessionImplTest2, NotifySizeChange, Function | SmallTest | Level2)
1648 {
1649     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1650     option->SetWindowName("NotifySizeChange");
1651     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1652     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1653     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1654     EXPECT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1655 
1656     Rect rect;
1657     sptr<IWindowChangeListener> listener = sptr<MockWindowChangeListener>::MakeSptr();
1658     window->RegisterWindowChangeListener(listener);
1659     window->NotifySizeChange(rect, WindowSizeChangeReason::PIP_RATIO_CHANGE);
1660 
1661     sptr<IWindowRectChangeListener> listener1 = sptr<MockWindowRectChangeListener>::MakeSptr();
1662     window->RegisterWindowRectChangeListener(listener1);
1663     window->NotifySizeChange(rect, WindowSizeChangeReason::PIP_RATIO_CHANGE);
1664     window->Destroy(true);
1665 }
1666 
1667 /**
1668  * @tc.name: AvoidAreaChangeListener
1669  * @tc.desc: AvoidAreaChangeListener
1670  * @tc.type: FUNC
1671  */
1672 HWTEST_F(WindowSessionImplTest2, AvoidAreaChangeListener, Function | SmallTest | Level2)
1673 {
1674     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1675     option->SetWindowName("AvoidAreaChangeListener");
1676     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1677     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1678     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1679     EXPECT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1680 
1681     sptr<IAvoidAreaChangedListener> nullListener = nullptr;
1682     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->UnregisterAvoidAreaChangeListener(nullListener));
1683 
1684     sptr<IAvoidAreaChangedListener> listener = sptr<MockAvoidAreaChangedListener>::MakeSptr();
1685     window->UnregisterAvoidAreaChangeListener(listener);
1686 
1687     window->RegisterAvoidAreaChangeListener(nullListener);
1688     window->RegisterAvoidAreaChangeListener(listener);
1689 
1690     sptr<IAvoidAreaChangedListener> listener1 = sptr<MockAvoidAreaChangedListener>::MakeSptr();
1691     window->RegisterAvoidAreaChangeListener(listener1);
1692 
1693     window->UnregisterAvoidAreaChangeListener(listener);
1694     window->UnregisterAvoidAreaChangeListener(listener1);
1695 }
1696 
1697 /**
1698  * @tc.name: TouchOutsideListener
1699  * @tc.desc: TouchOutsideListener
1700  * @tc.type: FUNC
1701  */
1702 HWTEST_F(WindowSessionImplTest2, TouchOutsideListener, Function | SmallTest | Level2)
1703 {
1704     sptr<WindowOption> option = new (std::nothrow) WindowOption();
1705     ASSERT_NE(option, nullptr);
1706     option->SetWindowName("TouchOutsideListener");
1707     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
1708     ASSERT_NE(window, nullptr);
1709     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1710     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
1711     ASSERT_NE(nullptr, session);
1712     EXPECT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1713 
1714     sptr<ITouchOutsideListener> nullListener = nullptr;
1715     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->UnregisterTouchOutsideListener(nullListener));
1716 
1717     sptr<ITouchOutsideListener> listener = new (std::nothrow) MockTouchOutsideListener();
1718     ASSERT_NE(nullptr, listener);
1719     window->UnregisterTouchOutsideListener(listener);
1720 
1721     window->RegisterTouchOutsideListener(nullListener);
1722     window->RegisterTouchOutsideListener(listener);
1723 
1724     sptr<ITouchOutsideListener> listener1 = new (std::nothrow) MockTouchOutsideListener();
1725     ASSERT_NE(nullptr, listener1);
1726     window->RegisterTouchOutsideListener(listener1);
1727 
1728     window->UnregisterTouchOutsideListener(listener);
1729     window->UnregisterTouchOutsideListener(listener1);
1730 }
1731 
1732 /**
1733  * @tc.name: NotifyDialogStateChange
1734  * @tc.desc: NotifyDialogStateChange
1735  * @tc.type: FUNC
1736  */
1737 HWTEST_F(WindowSessionImplTest2, NotifyDialogStateChange, Function | SmallTest | Level2)
1738 {
1739     GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifyDialogStateChange start";
1740     window_ = GetTestWindowImpl("NotifyDialogStateChange");
1741     ASSERT_NE(window_, nullptr);
1742     ASSERT_EQ(window_->NotifyDialogStateChange(true), WSError::WS_OK);
1743     GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifyDialogStateChange end";
1744 }
1745 
1746 /**
1747  * @tc.name: SwitchFreeMultiWindow
1748  * @tc.desc: SwitchFreeMultiWindow
1749  * @tc.type: FUNC
1750  */
1751 HWTEST_F(WindowSessionImplTest2, SwitchFreeMultiWindow, Function | SmallTest | Level2)
1752 {
1753     GTEST_LOG_(INFO) << "WindowSessionImplTest2: SwitchFreeMultiWindow start";
1754     window_ = GetTestWindowImpl("SwitchFreeMultiWindow");
1755     ASSERT_NE(window_, nullptr);
1756     ASSERT_EQ(window_->SwitchFreeMultiWindow(true), WSError::WS_OK);
1757     GTEST_LOG_(INFO) << "WindowSessionImplTest2: SwitchFreeMultiWindow end";
1758 }
1759 
1760 /**
1761  * @tc.name: UpdateTitleInTargetPos
1762  * @tc.desc: UpdateTitleInTargetPos
1763  * @tc.type: FUNC
1764  */
1765 HWTEST_F(WindowSessionImplTest2, UpdateTitleInTargetPos, Function | SmallTest | Level2)
1766 {
1767     GTEST_LOG_(INFO) << "WindowSessionImplTest2: UpdateTitleInTargetPos start";
1768     window_ = GetTestWindowImpl("UpdateTitleInTargetPos");
1769     ASSERT_NE(window_, nullptr);
1770     ASSERT_EQ(window_->UpdateTitleInTargetPos(true, 100), WSError::WS_OK);
1771     GTEST_LOG_(INFO) << "WindowSessionImplTest2: UpdateTitleInTargetPos end";
1772 }
1773 
1774 /**
1775  * @tc.name: NotifySessionBackground
1776  * @tc.desc: NotifySessionBackground
1777  * @tc.type: FUNC
1778  */
1779 HWTEST_F(WindowSessionImplTest2, NotifySessionBackground, Function | SmallTest | Level2)
1780 {
1781     GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifySessionBackground start";
1782     window_ = GetTestWindowImpl("NotifySessionBackground");
1783     ASSERT_NE(window_, nullptr);
1784     window_->NotifySessionBackground(true, true, true);
1785     GTEST_LOG_(INFO) << "WindowSessionImplTest2: NotifySessionBackground end";
1786 }
1787 
1788 /**
1789  * @tc.name: UpdateMaximizeMode
1790  * @tc.desc: UpdateMaximizeMode
1791  * @tc.type: FUNC
1792  */
1793 HWTEST_F(WindowSessionImplTest2, UpdateMaximizeMode, Function | SmallTest | Level2)
1794 {
1795     GTEST_LOG_(INFO) << "WindowSessionImplTest2: UpdateMaximizeMode start";
1796     window_ = GetTestWindowImpl("UpdateMaximizeMode");
1797     ASSERT_NE(window_, nullptr);
1798     ASSERT_EQ(window_->UpdateMaximizeMode(MaximizeMode::MODE_AVOID_SYSTEM_BAR), WSError::WS_OK);
1799     GTEST_LOG_(INFO) << "WindowSessionImplTest2: UpdateMaximizeMode end";
1800 }
1801 
1802 /**
1803  * @tc.name: DumpSessionElementInfo
1804  * @tc.desc: DumpSessionElementInfo
1805  * @tc.type: FUNC
1806  */
1807 HWTEST_F(WindowSessionImplTest2, DumpSessionElementInfo, Function | SmallTest | Level2)
1808 {
1809     GTEST_LOG_(INFO) << "WindowSessionImplTest2: DumpSessionElementInfo start";
1810     window_ = GetTestWindowImpl("DumpSessionElementInfo");
1811     ASSERT_NE(window_, nullptr);
1812     std::vector<std::string> params;
1813     params.push_back("test");
1814     window_->DumpSessionElementInfo(params);
1815     GTEST_LOG_(INFO) << "WindowSessionImplTest2: DumpSessionElementInfo end";
1816 }
1817 
1818 /**
1819  * @tc.name: GetKeyboardAnimationConfig
1820  * @tc.desc: GetKeyboardAnimationConfig
1821  * @tc.type: FUNC
1822  */
1823 HWTEST_F(WindowSessionImplTest2, GetKeyboardAnimationConfig, Function | SmallTest | Level2)
1824 {
1825     GTEST_LOG_(INFO) << "WindowSessionImplTest2: GetKeyboardAnimationConfig start";
1826     window_ = GetTestWindowImpl("GetKeyboardAnimationConfig");
1827     ASSERT_NE(window_, nullptr);
1828     window_->GetKeyboardAnimationConfig();
1829     GTEST_LOG_(INFO) << "WindowSessionImplTest2: GetKeyboardAnimationConfig end";
1830 }
1831 
1832 /**
1833  * @tc.name: GetSubWindow
1834  * @tc.desc: GetSubWindow
1835  * @tc.type: FUNC
1836  */
1837 HWTEST_F(WindowSessionImplTest2, GetSubWindow, Function | SmallTest | Level2)
1838 {
1839     GTEST_LOG_(INFO) << "WindowSessionImplTest2: GetSubWindow start";
1840     window_ = GetTestWindowImpl("GetSubWindow");
1841     ASSERT_NE(window_, nullptr);
1842     ASSERT_TRUE(window_->subWindowSessionMap_.empty());
1843     std::vector<sptr<WindowSessionImpl>> vec;
1844     vec.push_back(window_);
1845     int32_t parentId = 111;
1846     window_->subWindowSessionMap_.insert(std::pair<int32_t, std::vector<sptr<WindowSessionImpl>>>(parentId, vec));
1847     std::vector<sptr<Window>> subWindows = window_->GetSubWindow(parentId);
1848     ASSERT_EQ(subWindows.size(), 1);
1849     GTEST_LOG_(INFO) << "WindowSessionImplTest2: GetSubWindow end";
1850 }
1851 
1852 /**
1853  * @tc.name: SetRestoredRouterStack_0200
1854  * @tc.desc: basic function test of set or get restored router stack.
1855  * @tc.type: FUNC
1856  * @tc.require: issue
1857  */
1858 HWTEST_F(WindowSessionImplTest2, SetRestoredRouterStack_0200, Function | SmallTest | Level3)
1859 {
1860     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1861     ASSERT_NE(option, nullptr);
1862     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1863     ASSERT_NE(window, nullptr);
1864     std::string routerStack = "stackInfo:{}";
1865     EXPECT_EQ(window->SetRestoredRouterStack(routerStack), WMError::WM_OK);
1866     std::string gettedStack = window->GetRestoredRouterStack();
1867     EXPECT_EQ(gettedStack, routerStack);
1868     EXPECT_TRUE(window->GetRestoredRouterStack().empty());
1869 }
1870 
1871 /**
1872  * @tc.name: SetUiDvsyncSwitch
1873  * @tc.desc: SetUiDvsyncSwitch
1874  * @tc.type: FUNC
1875  */
1876 HWTEST_F(WindowSessionImplTest2, SetUiDvsyncSwitch, Function | SmallTest | Level2)
1877 {
1878     sptr<WindowOption> option = new (std::nothrow) WindowOption();
1879     ASSERT_NE(option, nullptr);
1880     option->SetWindowName("SetUiDvsyncSwitch");
1881     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
1882     ASSERT_NE(window, nullptr);
1883     window->SetUiDvsyncSwitch(true);
1884     window->vsyncStation_ = nullptr;
1885     window->SetUiDvsyncSwitch(true);
1886 }
1887 
1888 /**
1889  * @tc.name: SetUiDvsyncSwitchSucc
1890  * @tc.desc: SetUiDvsyncSwitch Test Succ
1891  * @tc.type: FUNC
1892  */
1893 HWTEST_F(WindowSessionImplTest2, SetUiDvsyncSwitchSucc, Function | SmallTest | Level2)
1894 {
1895     sptr<WindowOption> option = new (std::nothrow) WindowOption();
1896     option->SetWindowName("SetUiDvsyncSwitchSucc");
1897     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
1898     ASSERT_NE(window, nullptr);
1899     window->SetUiDvsyncSwitch(true);
1900     window->SetUiDvsyncSwitch(false);
1901 }
1902 
1903 /**
1904  * @tc.name: SetUiDvsyncSwitchErr
1905  * @tc.desc: SetUiDvsyncSwitch Test Err
1906  * @tc.type: FUNC
1907  */
1908 HWTEST_F(WindowSessionImplTest2, SetUiDvsyncSwitchErr, Function | SmallTest | Level2)
1909 {
1910     sptr<WindowOption> option = new (std::nothrow) WindowOption();
1911     option->SetWindowName("SetUiDvsyncSwitchErr");
1912     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
1913     ASSERT_NE(window, nullptr);
1914     window->vsyncStation_ = nullptr;
1915     window->SetUiDvsyncSwitch(true);
1916     window->SetUiDvsyncSwitch(false);
1917 }
1918 
1919 /**
1920  * @tc.name: SetRestoredRouterStack_0100
1921  * @tc.desc: basic function test of set or get restored router stack.
1922  * @tc.type: FUNC
1923  * @tc.require: issue
1924  */
1925 HWTEST_F(WindowSessionImplTest2, SetRestoredRouterStack_0100, Function | SmallTest | Level3)
1926 {
1927     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1928     ASSERT_NE(option, nullptr);
1929     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1930     ASSERT_NE(window, nullptr);
1931     std::string routerStack = "stackInfo:{}";
1932     EXPECT_EQ(window->SetRestoredRouterStack(routerStack), WMError::WM_OK);
1933     EXPECT_EQ(window->NapiSetUIContent("info", nullptr, nullptr, BackupAndRestoreType::NONE, nullptr, nullptr),
1934               WMError::WM_ERROR_INVALID_WINDOW);
1935 }
1936 } // namespace
1937 } // namespace Rosen
1938 } // namespace OHOS
1939