• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <gtest/gtest.h>
17 #include <parameters.h>
18 
19 #include "ability_context_impl.h"
20 #include "display_info.h"
21 #include "mock_session.h"
22 #include "mock_uicontent.h"
23 #include "mock_window_adapter.h"
24 #include "scene_board_judgement.h"
25 #include "session/host/include/scene_session.h"
26 #include "singleton_mocker.h"
27 #include "window_scene_session_impl.h"
28 #include "window_session_impl.h"
29 
30 using namespace testing;
31 using namespace testing::ext;
32 
33 namespace OHOS {
34 namespace Rosen {
35 namespace {
36     std::string g_logMsg;
LogCallback(const LogType type,const LogLevel level,const unsigned int domain,const char * tag,const char * msg)37     void LogCallback(const LogType type, const LogLevel level, const unsigned int domain, const char* tag,
38         const char* msg)
39     {
40         g_logMsg += msg;
41     }
42 }
43 using Mocker = SingletonMocker<WindowAdapter, MockWindowAdapter>;
44 
45 class MockWindowChangeListener : public IWindowChangeListener {
46 public:
47     MOCK_METHOD3(OnSizeChange,
48                  void(Rect rect, WindowSizeChangeReason reason, const std::shared_ptr<RSTransaction>& rsTransaction));
49 };
50 
51 class MockWindowLifeCycleListener : public IWindowLifeCycle {
52 public:
53     MOCK_METHOD0(AfterForeground, void(void));
54     MOCK_METHOD0(AfterBackground, void(void));
55     MOCK_METHOD0(AfterFocused, void(void));
56     MOCK_METHOD0(AfterUnfocused, void(void));
57     MOCK_METHOD1(ForegroundFailed, void(int32_t));
58     MOCK_METHOD0(AfterActive, void(void));
59     MOCK_METHOD0(AfterInactive, void(void));
60     MOCK_METHOD0(AfterResumed, void(void));
61     MOCK_METHOD0(AfterPaused, void(void));
62 };
63 
64 class WindowSceneSessionImplTest : public testing::Test {
65 public:
66     static void SetUpTestCase();
67     static void TearDownTestCase();
68     void SetUp() override;
69     void TearDown() override;
70 
71     std::shared_ptr<AbilityRuntime::AbilityContext> abilityContext_;
72     std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
73 
74 private:
75     RSSurfaceNode::SharedPtr CreateRSSurfaceNode();
76     static constexpr uint32_t WAIT_SYNC_IN_NS = 200000;
77 };
78 
SetUpTestCase()79 void WindowSceneSessionImplTest::SetUpTestCase() {}
80 
TearDownTestCase()81 void WindowSceneSessionImplTest::TearDownTestCase() {}
82 
SetUp()83 void WindowSceneSessionImplTest::SetUp()
84 {
85     abilityContext_ = std::make_shared<AbilityRuntime::AbilityContextImpl>();
86 }
87 
TearDown()88 void WindowSceneSessionImplTest::TearDown()
89 {
90     usleep(WAIT_SYNC_IN_NS);
91     abilityContext_ = nullptr;
92 }
93 
CreateRSSurfaceNode()94 RSSurfaceNode::SharedPtr WindowSceneSessionImplTest::CreateRSSurfaceNode()
95 {
96     struct RSSurfaceNodeConfig rsSurfaceNodeConfig;
97     rsSurfaceNodeConfig.SurfaceNodeName = "startingWindowTestSurfaceNode";
98     auto surfaceNode = RSSurfaceNode::Create(rsSurfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
99     return surfaceNode;
100 }
101 
CreateWindow(std::string windowName,WindowType type,int32_t id)102 static sptr<WindowSceneSessionImpl> CreateWindow(std::string windowName, WindowType type, int32_t id)
103 {
104     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
105     option->SetWindowName(windowName);
106     option->SetWindowType(type);
107     auto window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
108     window->property_->SetPersistentId(id);
109     return window;
110 }
111 
112 namespace {
113 /**
114  * @tc.name: CreateWindowAndDestroy01
115  * @tc.desc: Create window and destroy window
116  * @tc.type: FUNC
117  */
118 HWTEST_F(WindowSceneSessionImplTest, CreateWindowAndDestroy01, TestSize.Level0)
119 {
120     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
121     option->SetWindowName("CreateWindowAndDestroy01");
122     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
123     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
124     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
125 
126     ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, session));
127     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy(false));
128     ASSERT_EQ(WMError::WM_ERROR_REPEAT_OPERATION, window->Create(abilityContext_, session));
129     window->property_->SetPersistentId(1);
130     ASSERT_EQ(WMError::WM_OK, window->Destroy(false));
131     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->Create(abilityContext_, session));
132     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy(true));
133 }
134 
135 /**
136  * @tc.name: CreateWindowAndDestroy02
137  * @tc.desc: Create window and destroy window
138  * @tc.type: FUNC
139  */
140 HWTEST_F(WindowSceneSessionImplTest, CreateWindowAndDestroy02, TestSize.Level0)
141 {
142     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
143     option->SetWindowName("CreateWindowAndDestroy02");
144     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
145     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
146     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
147     std::string identityToken = "testToken";
148     window->Create(abilityContext_, session);
149     ASSERT_EQ(WMError::WM_ERROR_REPEAT_OPERATION, window->Create(abilityContext_, session, identityToken));
150     window->property_->SetPersistentId(1);
151     window->Destroy(false);
152     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->Create(abilityContext_, session, identityToken));
153     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy(false));
154 }
155 
156 /**
157  * @tc.name: SetPcAppInpadSpecificSystemBarInvisible
158  * @tc.desc: SetPcAppInpadSpecificSystemBarInvisible
159  * @tc.type: FUNC
160  */
161 HWTEST_F(WindowSceneSessionImplTest, SetPcAppInpadSpecificSystemBarInvisible, TestSize.Level0)
162 {
163     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
164     option->SetWindowName("SetPcAppInpadSpecificSystemBarInvisible");
165     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
166     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
167     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
168     EXPECT_EQ(WMError::WM_ERROR_INVALID_CALLING, window->SetPcAppInpadSpecificSystemBarInvisible());
169     window->windowSystemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW;
170     window->property_->SetIsPcAppInPad(true);
171     window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
172     window->windowSystemConfig_.freeMultiWindowEnable_ = false;
173     window->property_->SetPcAppInpadSpecificSystemBarInvisible(true);
174     window->property_->SetPcAppInpadCompatibleMode(true);
175     EXPECT_EQ(WMError::WM_OK, window->SetPcAppInpadSpecificSystemBarInvisible());
176     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy(false));
177 }
178 
179 /**
180  * @tc.name: SetPcAppInpadOrientationLandscape
181  * @tc.desc: SetPcAppInpadOrientationLandscape
182  * @tc.type: FUNC
183  */
184 HWTEST_F(WindowSceneSessionImplTest, SetPcAppInpadOrientationLandscape, TestSize.Level0)
185 {
186     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
187     option->SetWindowName("SetPcAppInpadOrientationLandscape");
188     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
189     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
190     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
191     EXPECT_EQ(WMError::WM_ERROR_INVALID_CALLING, window->SetPcAppInpadOrientationLandscape());
192     window->windowSystemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW;
193     window->property_->SetIsPcAppInPad(true);
194     window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
195     window->windowSystemConfig_.freeMultiWindowEnable_ = false;
196     window->property_->SetPcAppInpadOrientationLandscape(true);
197     window->property_->SetPcAppInpadCompatibleMode(true);
198     EXPECT_EQ(WMError::WM_OK, window->SetPcAppInpadOrientationLandscape());
199     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy(false));
200 }
201 
202 /**
203  * @tc.name: CreateAndConnectSpecificSession01
204  * @tc.desc: CreateAndConnectSpecificSession
205  * @tc.type: FUNC
206  */
207 HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession01, TestSize.Level0)
208 {
209     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
210         GTEST_SKIP() << "SceneBoard is not enabled, skipping test.";
211     }
212     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
213     option->SetWindowName("CreateAndConnectSpecificSession01");
214     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
215 
216     windowSceneSession->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
217     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowSceneSession->CreateAndConnectSpecificSession());
218     windowSceneSession->property_->SetPersistentId(102);
219     windowSceneSession->property_->SetParentPersistentId(100);
220     windowSceneSession->property_->SetParentId(100);
221     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
222     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
223 
224     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Create(abilityContext_, session));
225     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Destroy(true));
226 }
227 
228 /**
229  * @tc.name: CreateAndConnectSpecificSession02
230  * @tc.desc: CreateAndConnectSpecificSession
231  * @tc.type: FUNC
232  */
233 HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession02, TestSize.Level1)
234 {
235     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
236         GTEST_SKIP() << "SceneBoard is not enabled, skipping test.";
237     }
238     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
239     option->SetWindowTag(WindowTag::SUB_WINDOW);
240     option->SetWindowName("CreateAndConnectSpecificSession02");
241     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
242 
243     SessionInfo sessionInfo = { "CreateTestBundle0", "CreateTestModule0", "CreateTestAbility0" };
244     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
245     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Create(abilityContext_, session));
246     windowSceneSession->property_->SetPersistentId(103);
247     windowSceneSession->property_->SetParentPersistentId(102);
248     windowSceneSession->property_->SetParentId(102);
249     windowSceneSession->hostSession_ = session;
250 
251     windowSceneSession->property_->type_ = WindowType::APP_SUB_WINDOW_BASE;
252     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowSceneSession->CreateAndConnectSpecificSession());
253     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Destroy(true));
254 }
255 
256 /**
257  * @tc.name: CreateAndConnectSpecificSession03
258  * @tc.desc: CreateAndConnectSpecificSession
259  * @tc.type: FUNC
260  */
261 HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession03, TestSize.Level1)
262 {
263     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
264         GTEST_SKIP() << "SceneBoard is not enabled, skipping test.";
265     }
266     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
267     option->SetWindowTag(WindowTag::SUB_WINDOW);
268     option->SetWindowName("CreateAndConnectSpecificSession03");
269     option->SetIsUIExtFirstSubWindow(true);
270     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
271 
272     SessionInfo sessionInfo = { "CreateTestBundle0", "CreateTestModule0", "CreateTestAbility0" };
273     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
274     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Create(abilityContext_, session));
275 
276     windowSceneSession->property_->SetParentPersistentId(102);
277     windowSceneSession->property_->SetParentId(102);
278     windowSceneSession->hostSession_ = session;
279 
280     windowSceneSession->property_->type_ = WindowType::APP_SUB_WINDOW_BASE;
281     ASSERT_EQ(WMError::WM_OK, windowSceneSession->CreateAndConnectSpecificSession());
282     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Destroy(true));
283 }
284 
285 /**
286  * @tc.name: CreateAndConnectSpecificSession04
287  * @tc.desc: CreateAndConnectSpecificSession
288  * @tc.type: FUNC
289  */
290 HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession04, TestSize.Level1)
291 {
292     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
293         GTEST_SKIP() << "SceneBoard is not enabled, skipping test.";
294     }
295     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
296     option->SetWindowTag(WindowTag::SUB_WINDOW);
297     option->SetWindowName("CreateAndConnectSpecificSession04");
298     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
299 
300     SessionInfo sessionInfo = { "CreateTestBundle4", "CreateTestModule4", "CreateTestAbility4" };
301     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
302     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Create(abilityContext_, session));
303 
304     windowSceneSession->property_->SetPersistentId(104);
305     windowSceneSession->property_->SetParentPersistentId(103);
306     windowSceneSession->property_->SetParentId(103);
307     windowSceneSession->property_->type_ = WindowType::APP_MAIN_WINDOW_BASE;
308     windowSceneSession->hostSession_ = session;
309 
310     windowSceneSession->property_->type_ = WindowType::APP_SUB_WINDOW_BASE;
311     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowSceneSession->CreateAndConnectSpecificSession());
312     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Destroy(true));
313 }
314 
315 /**
316  * @tc.name: CreateAndConnectSpecificSession05
317  * @tc.desc: CreateAndConnectSpecificSession
318  * @tc.type: FUNC
319  */
320 HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession05, TestSize.Level1)
321 {
322     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
323         GTEST_SKIP() << "SceneBoard is not enabled, skipping test.";
324     }
325     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
326     option->SetWindowTag(WindowTag::SUB_WINDOW);
327     option->SetWindowName("CreateAndConnectSpecificSession05");
328     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
329 
330     SessionInfo sessionInfo = { "CreateTestBundle5", "CreateTestModule5", "CreateTestAbility5" };
331     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
332     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Create(abilityContext_, session));
333 
334     windowSceneSession->property_->SetParentPersistentId(104);
335     windowSceneSession->property_->SetParentId(104);
336     windowSceneSession->hostSession_ = session;
337 
338     windowSceneSession->property_->type_ = WindowType::APP_SUB_WINDOW_BASE;
339     ASSERT_NE(WMError::WM_ERROR_INVALID_TYPE, windowSceneSession->CreateAndConnectSpecificSession());
340     ASSERT_NE(WMError::WM_OK, windowSceneSession->Destroy(true));
341 }
342 
343 /**
344  * @tc.name: CreateAndConnectSpecificSession06
345  * @tc.desc: CreateAndConnectSpecificSession
346  * @tc.type: FUNC
347  */
348 HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession06, TestSize.Level1)
349 {
350     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
351         GTEST_SKIP() << "SceneBoard is not enabled, skipping test.";
352     }
353     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
354     option->SetWindowTag(WindowTag::SYSTEM_WINDOW);
355     option->SetWindowName("CreateAndConnectSpecificSession06");
356     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
357 
358     SessionInfo sessionInfo = { "CreateTestBundle6", "CreateTestModule6", "CreateTestAbility6" };
359     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
360     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Create(abilityContext_, session));
361 
362     windowSceneSession->property_->SetPersistentId(105);
363     windowSceneSession->property_->SetParentPersistentId(102);
364     windowSceneSession->property_->SetParentId(102);
365     windowSceneSession->hostSession_ = session;
366 
367     windowSceneSession->property_->type_ = WindowType::SYSTEM_WINDOW_BASE;
368     ASSERT_EQ(WMError::WM_OK, windowSceneSession->CreateAndConnectSpecificSession());
369     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Destroy(true));
370 }
371 
372 /**
373  * @tc.name: CreateAndConnectSpecificSession07
374  * @tc.desc: CreateAndConnectSpecificSession
375  * @tc.type: FUNC
376  */
377 HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession07, TestSize.Level1)
378 {
379     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
380         GTEST_SKIP() << "SceneBoard is not enabled, skipping test.";
381     }
382     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
383     option->SetWindowTag(WindowTag::SYSTEM_WINDOW);
384     option->SetWindowName("CreateAndConnectSpecificSession07");
385     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
386 
387     SessionInfo sessionInfo = { "CreateTestBundle7", "CreateTestModule7", "CreateTestAbility7" };
388     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
389     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Create(abilityContext_, session));
390 
391     windowSceneSession->property_->SetPersistentId(106);
392     windowSceneSession->property_->SetParentPersistentId(105);
393     windowSceneSession->property_->SetParentId(105);
394     windowSceneSession->hostSession_ = session;
395 
396     windowSceneSession->property_->type_ = WindowType::SYSTEM_SUB_WINDOW_BASE;
397     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowSceneSession->CreateAndConnectSpecificSession());
398     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Destroy(true));
399 }
400 
401 /**
402  * @tc.name: CreateAndConnectSpecificSession08
403  * @tc.desc: CreateAndConnectSpecificSession
404  * @tc.type: FUNC
405  */
406 HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession08, TestSize.Level0)
407 {
408     constexpr int parentId = 10000;
409     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
410     option->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
411     option->SetWindowName("CreateAndConnectSpecificSession08");
412     option->SetParentId(parentId);
413 
414     // scene session manager processing
415     option->SetIsUIExtFirstSubWindow(true);
416     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
417     windowSceneSession->Create(abilityContext_, nullptr);
418     ASSERT_EQ(windowSceneSession->property_->GetParentPersistentId(), option->GetParentId());
419     // scene session manager processing
420     option->SetIsUIExtFirstSubWindow(false);
421     option->SetIsUIExtAnySubWindow(true);
422     option->AddWindowFlag(WindowFlag::WINDOW_FLAG_IS_TOAST);
423     windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
424     ASSERT_NE(nullptr, windowSceneSession);
425     windowSceneSession->Create(abilityContext_, nullptr);
426     ASSERT_EQ(windowSceneSession->property_->GetParentPersistentId(), option->GetParentId());
427 
428     sptr<WindowSceneSessionImpl> mainWindow = sptr<WindowSceneSessionImpl>::MakeSptr(option);
429     windowSceneSession->property_->SetPersistentId(parentId);
430     // window processing
431     option->SetIsUIExtFirstSubWindow(false);
432     option->SetIsUIExtAnySubWindow(true);
433     option->RemoveWindowFlag(WindowFlag::WINDOW_FLAG_IS_TOAST);
434     windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
435     windowSceneSession->windowSessionMap_["mainWindow"] = { parentId, mainWindow };
436     windowSceneSession->Create(abilityContext_, nullptr);
437     ASSERT_EQ(windowSceneSession->property_->GetDisplayId(), mainWindow->property_->GetDisplayId());
438     // window processing
439     option->SetIsUIExtAnySubWindow(false);
440     windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
441     windowSceneSession->windowSessionMap_["mainWindow"] = { parentId, mainWindow };
442     windowSceneSession->Create(abilityContext_, nullptr);
443     ASSERT_EQ(windowSceneSession->property_->GetDisplayId(), mainWindow->property_->GetDisplayId());
444 }
445 
446 /**
447  * @tc.name: CreateAndConnectSpecificSession09
448  * @tc.desc: CreateAndConnectSpecificSession
449  * @tc.type: FUNC
450  */
451 HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession09, TestSize.Level0)
452 {
453     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
454         GTEST_SKIP() << "SceneBoard is not enabled, skipping test.";
455     }
456     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
457     option->SetWindowName("CreateAndConnectSpecificSession09");
458     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
459 
460     windowSceneSession->SetWindowType(WindowType::WINDOW_TYPE_WALLET_SWIPE_CARD);
461     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowSceneSession->CreateAndConnectSpecificSession());
462     windowSceneSession->property_->SetPersistentId(102);
463     windowSceneSession->property_->SetParentPersistentId(100);
464     windowSceneSession->property_->SetParentId(100);
465     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
466     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
467 
468     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Create(abilityContext_, session));
469     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Destroy(true));
470 }
471 
472 /**
473  * @tc.name: CreateAndConnectSpecificSession10
474  * @tc.desc: CreateAndConnectSpecificSession
475  * @tc.type: FUNC
476  */
477 HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession10, TestSize.Level1)
478 {
479     constexpr int parentId = 1000;
480     constexpr int displayId = 100;
481     sptr<WindowOption> parentOption = sptr<WindowOption>::MakeSptr();
482     parentOption->SetWindowTag(WindowTag::MAIN_WINDOW);
483     parentOption->SetWindowName("MainWindow");
484     parentOption->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
485     parentOption->SetDisplayId(displayId);
486     sptr<WindowSceneSessionImpl> parentWindow = sptr<WindowSceneSessionImpl>::MakeSptr(parentOption);
487     ASSERT_NE(nullptr, parentWindow);
488 
489     parentWindow->property_->SetPersistentId(parentId);
490     SessionInfo sessionInfo = {"TextMenuTestBundle", "TextMenuTestModule", "TextMenuTestAbility"};
491     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
492     WMError error = parentWindow->Create(abilityContext_, session);
493     ASSERT_EQ(error, WMError::WM_OK);
494 
495     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
496     ASSERT_NE(nullptr, option);
497     option->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
498     option->AddWindowFlag(WindowFlag::WINDOW_FLAG_IS_TEXT_MENU);
499     option->SetWindowName("TextMenu");
500     option->SetParentId(parentId);
501     sptr<WindowSceneSessionImpl> textMenuWindow = sptr<WindowSceneSessionImpl>::MakeSptr(option);
502     ASSERT_NE(nullptr, textMenuWindow);
503     error = textMenuWindow->Create(abilityContext_, nullptr);
504     ASSERT_EQ(error, WMError::WM_OK);
505     ASSERT_EQ(WMError::WM_OK, textMenuWindow->Destroy(true));
506     ASSERT_EQ(WMError::WM_OK, parentWindow->Destroy(true));
507 }
508 
509 /**
510  * @tc.name: CreateAndConnectSpecificSession11
511  * @tc.desc: CreateAndConnectSpecificSession
512  * @tc.type: FUNC
513  */
514 HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession11, TestSize.Level0)
515 {
516     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
517         GTEST_SKIP() << "SceneBoard is not enabled, skipping test.";
518     }
519     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
520     option->SetWindowName("CreateAndConnectSpecificSession10");
521     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
522 
523     windowSceneSession->SetWindowType(WindowType::WINDOW_TYPE_FLOAT_NAVIGATION);
524     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowSceneSession->CreateAndConnectSpecificSession());
525     windowSceneSession->property_->SetPersistentId(102);
526     windowSceneSession->property_->SetParentPersistentId(100);
527     windowSceneSession->property_->SetParentId(100);
528     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
529     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
530 
531     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Create(abilityContext_, session));
532     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Destroy(true));
533 }
534 
535 /**
536  * @tc.name: CreateAndConnectSpecificSession12
537  * @tc.desc: CreateAndConnectSpecificSession
538  * @tc.type: FUNC
539  */
540 HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession12, TestSize.Level1)
541 {
542     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
543         GTEST_SKIP() << "SceneBoard is not enabled, skipping test.";
544     }
545     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
546     option->SetWindowTag(WindowTag::SYSTEM_WINDOW);
547     option->SetWindowName("CreateAndConnectSpecificSession12");
548     option->SetDisplayId(999);
549     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
550 
551     SessionInfo sessionInfo = { "CreateTestBundle6", "CreateTestModule612", "CreateTestAbility12" };
552     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
553     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Create(abilityContext_, session));
554 
555     windowSceneSession->property_->SetPersistentId(105);
556     windowSceneSession->property_->SetParentPersistentId(102);
557     windowSceneSession->property_->SetParentId(102);
558     windowSceneSession->hostSession_ = session;
559 
560     windowSceneSession->property_->type_ = WindowType::SYSTEM_WINDOW_BASE;
561     ASSERT_EQ(WMError::WM_OK, windowSceneSession->CreateAndConnectSpecificSession());
562     ASSERT_EQ(999, windowSceneSession->property_->GetDisplayId());
563     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Destroy(true));
564 }
565 
566 /**
567  * @tc.name: CreateAndConnectSpecificSession13
568  * @tc.desc: CreateAndConnectSpecificSession
569  * @tc.type: FUNC
570  */
571 HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession13, TestSize.Level1)
572 {
573     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
574         GTEST_SKIP() << "SceneBoard is not enabled, skipping test.";
575     }
576     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
577     option->SetWindowName("CreateAndConnectSpecificSession13");
578     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
579 
580     windowSceneSession->SetWindowType(WindowType::WINDOW_TYPE_MUTISCREEN_COLLABORATION);
581     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowSceneSession->CreateAndConnectSpecificSession());
582     windowSceneSession->property_->SetPersistentId(102);
583     windowSceneSession->property_->SetParentPersistentId(100);
584     windowSceneSession->property_->SetParentId(100);
585     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
586     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
587 
588     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Create(abilityContext_, session));
589     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Destroy(true));
590 }
591 
592 /**
593  * @tc.name: CreateAndConnectSpecificSession14
594  * @tc.desc: CreateAndConnectSpecificSession
595  * @tc.type: FUNC
596  */
597 HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession14, TestSize.Level0)
598 {
599     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
600         GTEST_SKIP() << "SceneBoard is not enabled, skipping test.";
601     }
602     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
603     option->SetWindowName("CreateAndConnectSpecificSession14");
604     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
605 
606     windowSceneSession->SetWindowType(WindowType::WINDOW_TYPE_MAGNIFICATION);
607     EXPECT_EQ(WMError::WM_ERROR_NULLPTR, windowSceneSession->CreateAndConnectSpecificSession());
608     windowSceneSession->property_->SetPersistentId(102);
609     windowSceneSession->property_->SetParentPersistentId(100);
610     windowSceneSession->property_->SetParentId(100);
611     windowSceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
612     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
613     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
614 
615     EXPECT_EQ(WMError::WM_OK, windowSceneSession->Create(abilityContext_, session));
616     EXPECT_EQ(WMError::WM_OK, windowSceneSession->Show());
617     EXPECT_EQ(WMError::WM_OK, windowSceneSession->Destroy(true));
618 }
619 
620 /**
621  * @tc.name: CreateAndConnectSpecificSession15
622  * @tc.desc: CreateAndConnectSpecificSession
623  * @tc.type: FUNC
624  */
625 HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession15, TestSize.Level0)
626 {
627     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
628         GTEST_SKIP() << "SceneBoard is not enabled, skipping test.";
629     }
630     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
631     option->SetWindowName("CreateAndConnectSpecificSession15");
632     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
633 
634     windowSceneSession->SetWindowType(WindowType::WINDOW_TYPE_MAGNIFICATION_MENU);
635     EXPECT_EQ(WMError::WM_ERROR_NULLPTR, windowSceneSession->CreateAndConnectSpecificSession());
636     windowSceneSession->property_->SetPersistentId(102);
637     windowSceneSession->property_->SetParentPersistentId(100);
638     windowSceneSession->property_->SetParentId(100);
639     windowSceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
640     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
641     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
642 
643     EXPECT_EQ(WMError::WM_OK, windowSceneSession->Create(abilityContext_, session));
644     EXPECT_EQ(WMError::WM_OK, windowSceneSession->Show());
645     EXPECT_EQ(WMError::WM_OK, windowSceneSession->Destroy(true));
646 }
647 
648 /**
649  * @tc.name: CreateAndConnectSpecificSession16
650  * @tc.desc: CreateAndConnectSpecificSession
651  * @tc.type: FUNC
652  */
653 HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession16, TestSize.Level0)
654 {
655     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
656         GTEST_SKIP() << "SceneBoard is not enabled, skipping test.";
657     }
658     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
659     option->SetWindowName("CreateAndConnectSpecificSession16");
660     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
661 
662     windowSceneSession->SetWindowType(WindowType::WINDOW_TYPE_SELECTION);
663     EXPECT_EQ(WMError::WM_ERROR_NULLPTR, windowSceneSession->CreateAndConnectSpecificSession());
664     windowSceneSession->property_->SetPersistentId(102); // 102 is persistentId
665     windowSceneSession->property_->SetParentPersistentId(100); // 100 is parentPersistentId
666     windowSceneSession->property_->SetParentId(100); // 100 is parentId
667     windowSceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
668     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
669     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
670 
671     EXPECT_EQ(WMError::WM_OK, windowSceneSession->Create(abilityContext_, session));
672     EXPECT_EQ(WMError::WM_OK, windowSceneSession->Show());
673     EXPECT_EQ(WMError::WM_OK, windowSceneSession->Destroy(true));
674 }
675 
676 /**
677  * @tc.name: IsValidSystemWindowType01
678  * @tc.desc: IsValidSystemWindowType
679  * @tc.type: FUNC
680  */
681 HWTEST_F(WindowSceneSessionImplTest, IsValidSystemWindowType01, TestSize.Level1)
682 {
683     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
684     option->SetWindowName("IsValidSystemWindowType01");
685     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
686     ASSERT_NE(nullptr, windowSceneSession);
687     ASSERT_FALSE(!windowSceneSession->IsValidSystemWindowType(WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW));
688     ASSERT_FALSE(!windowSceneSession->IsValidSystemWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT));
689     ASSERT_FALSE(!windowSceneSession->IsValidSystemWindowType(WindowType::WINDOW_TYPE_FLOAT_CAMERA));
690     ASSERT_FALSE(!windowSceneSession->IsValidSystemWindowType(WindowType::WINDOW_TYPE_DIALOG));
691     ASSERT_FALSE(!windowSceneSession->IsValidSystemWindowType(WindowType::WINDOW_TYPE_FLOAT));
692     ASSERT_FALSE(!windowSceneSession->IsValidSystemWindowType(WindowType::WINDOW_TYPE_SCREENSHOT));
693     ASSERT_FALSE(!windowSceneSession->IsValidSystemWindowType(WindowType::WINDOW_TYPE_GLOBAL_SEARCH));
694     ASSERT_FALSE(!windowSceneSession->IsValidSystemWindowType(WindowType::WINDOW_TYPE_VOICE_INTERACTION));
695     ASSERT_FALSE(!windowSceneSession->IsValidSystemWindowType(WindowType::WINDOW_TYPE_POINTER));
696     ASSERT_FALSE(!windowSceneSession->IsValidSystemWindowType(WindowType::WINDOW_TYPE_TOAST));
697     ASSERT_FALSE(!windowSceneSession->IsValidSystemWindowType(WindowType::WINDOW_TYPE_DOCK_SLICE));
698     ASSERT_TRUE(!windowSceneSession->IsValidSystemWindowType(WindowType::WINDOW_TYPE_APP_LAUNCHING));
699 }
700 
701 /**
702  * @tc.name: InvalidWindow
703  * @tc.desc: InvalidWindow test
704  * @tc.type: FUNC
705  */
706 HWTEST_F(WindowSceneSessionImplTest, InvalidWindow, TestSize.Level1)
707 {
708     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
709     option->SetWindowName("InvalidWindow");
710     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
711     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->MoveTo(0, 0));
712     ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, window->Resize(0, 0));
713     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetBackgroundColor(std::string("???")));
714     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetTransparent(false));
715     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Show(2, false));
716     ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, window->Resize(2, 2));
717     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Minimize());
718     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Maximize());
719     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->MaximizeFloating());
720     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Recover());
721     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->MaximizeFloating());
722     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetGlobalMaximizeMode(MaximizeMode::MODE_AVOID_SYSTEM_BAR));
723 }
724 
725 /**
726  * @tc.name: FindParentSessionByParentId01
727  * @tc.desc: FindParentSessionByParentId
728  * @tc.type: FUNC
729  */
730 HWTEST_F(WindowSceneSessionImplTest, FindParentSessionByParentId01, TestSize.Level1)
731 {
732     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
733     option->SetWindowTag(WindowTag::MAIN_WINDOW);
734     option->SetWindowName("FindParentSessionByParentId01");
735     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
736     ASSERT_NE(nullptr, windowSceneSession);
737 
738     windowSceneSession->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
739     ASSERT_TRUE(windowSceneSession->FindMainWindowWithContext() == nullptr);
740     windowSceneSession->SetWindowType(WindowType::ABOVE_APP_SYSTEM_WINDOW_END);
741     ASSERT_TRUE(windowSceneSession->FindMainWindowWithContext() == nullptr);
742 
743     windowSceneSession->property_->SetPersistentId(1112);
744     windowSceneSession->property_->SetParentId(1000);
745     windowSceneSession->property_->SetParentPersistentId(1000);
746     windowSceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
747     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
748     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
749     ASSERT_NE(nullptr, session);
750 
751     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Create(abilityContext_, session));
752     windowSceneSession->hostSession_ = session;
753     ASSERT_TRUE(nullptr != windowSceneSession->FindParentSessionByParentId(1112));
754     windowSceneSession->Destroy(true);
755 }
756 
757 /**
758  * @tc.name: DisableAppWindowDecor01
759  * @tc.desc: DisableAppWindowDecor
760  * @tc.type: FUNC
761  */
762 HWTEST_F(WindowSceneSessionImplTest, DisableAppWindowDecor01, TestSize.Level1)
763 {
764     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
765     option->SetWindowName("DisableAppWindowDecor01");
766     sptr<WindowSceneSessionImpl> windowSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
767     ASSERT_NE(nullptr, windowSession);
768 
769     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
770     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
771 
772     std::shared_ptr<AbilityRuntime::Context> context;
773     ASSERT_EQ(WMError::WM_OK, windowSession->Create(context, session));
774     windowSession->property_->SetPersistentId(1);
775 
776     windowSession->UpdateDecorEnable(false);
777     windowSession->windowSystemConfig_.isSystemDecorEnable_ = false;
778 
779     windowSession->property_->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
780     windowSession->DisableAppWindowDecor();
781     ASSERT_FALSE(windowSession->IsDecorEnable());
782     windowSession->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
783     windowSession->DisableAppWindowDecor();
784     windowSession->Destroy(true);
785 }
786 
787 /**
788  * @tc.name: DisableAppWindowDecor02
789  * @tc.desc: DisableAppWindowDecor
790  * @tc.type: FUNC
791  */
792 HWTEST_F(WindowSceneSessionImplTest, DisableAppWindowDecor02, TestSize.Level1)
793 {
794     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
795     option->SetWindowName("DisableAppWindowDecor02");
796     sptr<WindowSceneSessionImpl> windowSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
797 
798     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
799     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
800 
801     std::shared_ptr<AbilityRuntime::Context> context;
802     ASSERT_EQ(WMError::WM_OK, windowSession->Create(context, session));
803     windowSession->property_->SetPersistentId(0);
804 
805     windowSession->UpdateDecorEnable(false);
806     windowSession->windowSystemConfig_.isSystemDecorEnable_ = true;
807 
808     windowSession->property_->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
809     EXPECT_EQ(WMError::WM_ERROR_INVALID_WINDOW, windowSession->DisableAppWindowDecor());
810     windowSession->Destroy(true);
811 }
812 
813 /**
814  * @tc.name: DisableAppWindowDecor03
815  * @tc.desc: DisableAppWindowDecor
816  * @tc.type: FUNC
817  */
818 HWTEST_F(WindowSceneSessionImplTest, DisableAppWindowDecor03, TestSize.Level1)
819 {
820     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
821     option->SetWindowName("DisableAppWindowDecor03");
822     sptr<WindowSceneSessionImpl> windowSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
823 
824     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
825     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
826 
827     std::shared_ptr<AbilityRuntime::Context> context;
828     ASSERT_EQ(WMError::WM_OK, windowSession->Create(context, session));
829     windowSession->property_->SetPersistentId(1);
830 
831     windowSession->UpdateDecorEnable(false);
832     windowSession->windowSystemConfig_.isSystemDecorEnable_ = true;
833 
834     windowSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
835     EXPECT_EQ(WMError::WM_ERROR_INVALID_OPERATION, windowSession->DisableAppWindowDecor());
836     windowSession->Destroy(true);
837 }
838 
839 /**
840  * @tc.name: RaiseToAppTop01
841  * @tc.desc: RaiseToAppTop
842  * @tc.type: FUNC
843  */
844 HWTEST_F(WindowSceneSessionImplTest, RaiseToAppTop01, TestSize.Level1)
845 {
846     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
847     option->SetWindowName("RaiseToAppTop01");
848     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
849     ASSERT_NE(nullptr, windowSceneSession);
850 
851     windowSceneSession->property_->SetPersistentId(6);
852     windowSceneSession->property_->SetParentPersistentId(6);
853     windowSceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
854     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, windowSceneSession->RaiseToAppTop());
855 
856     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
857     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
858     windowSceneSession->hostSession_ = session;
859     ASSERT_EQ(WMError::WM_ERROR_INVALID_CALLING, windowSceneSession->RaiseToAppTop());
860 
861     windowSceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
862     windowSceneSession->state_ = WindowState::STATE_HIDDEN;
863     ASSERT_EQ(WMError::WM_DO_NOTHING, windowSceneSession->RaiseToAppTop());
864 
865     windowSceneSession->state_ = WindowState::STATE_SHOWN;
866     ASSERT_EQ(WMError::WM_OK, windowSceneSession->RaiseToAppTop());
867 }
868 
869 /**
870  * @tc.name: GetGlobalScaledRect
871  * @tc.desc: GetGlobalScaledRect
872  * @tc.type: FUNC
873  */
874 HWTEST_F(WindowSceneSessionImplTest, GetGlobalScaledRect, TestSize.Level1)
875 {
876     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
877     option->SetWindowName("GetGlobalScaledRect");
878     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
879     Rect globalScaledRect;
880     windowSceneSession->property_->SetPersistentId(6);
881     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, windowSceneSession->GetGlobalScaledRect(globalScaledRect));
882 
883     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
884     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
885     windowSceneSession->hostSession_ = session;
886     ASSERT_EQ(WMError::WM_OK, windowSceneSession->GetGlobalScaledRect(globalScaledRect));
887 }
888 
889 /**
890  * @tc.name: Minimize01
891  * @tc.desc: Minimize
892  * @tc.type: FUNC
893  */
894 HWTEST_F(WindowSceneSessionImplTest, Minimize01, TestSize.Level1)
895 {
896     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
897     option->SetWindowName("Minimize01");
898     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
899 
900     windowSceneSession->property_->SetPersistentId(1);
901     windowSceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
902     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
903     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
904 
905     windowSceneSession->hostSession_ = session;
906     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Minimize());
907 }
908 
909 /**
910  * @tc.name: Minimize02
911  * @tc.desc: Minimize
912  * @tc.type: FUNC
913  */
914 HWTEST_F(WindowSceneSessionImplTest, Minimize02, TestSize.Level1)
915 {
916     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
917     option->SetWindowName("Minimize02");
918     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
919     windowSceneSession->property_->SetPersistentId(0);
920     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, windowSceneSession->Minimize());
921 }
922 
923 /**
924  * @tc.name: Minimize03
925  * @tc.desc: Minimize
926  * @tc.type: FUNC
927  */
928 HWTEST_F(WindowSceneSessionImplTest, Minimize03, TestSize.Level1)
929 {
930     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
931     option->SetWindowName("Minimize03");
932     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
933 
934     windowSceneSession->property_->SetPersistentId(1);
935     windowSceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
936     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
937     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
938 
939     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, windowSceneSession->Minimize());
940 }
941 
942 /**
943  * @tc.name: Minimize04
944  * @tc.desc: Minimize
945  * @tc.type: FUNC
946  */
947 HWTEST_F(WindowSceneSessionImplTest, Minimize04, TestSize.Level1)
948 {
949     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
950     option->SetWindowName("Minimize04");
951     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
952 
953     windowSceneSession->property_->SetPersistentId(1);
954     windowSceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
955     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
956     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
957     windowSceneSession->hostSession_ = session;
958     windowSceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
959     ASSERT_EQ(WMError::WM_DO_NOTHING, windowSceneSession->Minimize());
960 }
961 
962 /**
963  * @tc.name: StartMove01
964  * @tc.desc: StartMove
965  * @tc.type: FUNC
966  */
967 HWTEST_F(WindowSceneSessionImplTest, StartMove01, TestSize.Level1)
968 {
969     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
970     option->SetWindowName("StartMove01");
971     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
972     windowSceneSession->property_->SetPersistentId(1);
973     // show with null session
974 
975     windowSceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
976     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
977     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
978     windowSceneSession->hostSession_ = session;
979     windowSceneSession->StartMove();
980     ASSERT_NE(nullptr, session);
981 }
982 
983 /**
984  * @tc.name: StartMoveWindow_IsDeviceSupportOrNot
985  * @tc.desc: StartMoveWindow Test, is device support or not
986  * @tc.type: FUNC
987  */
988 HWTEST_F(WindowSceneSessionImplTest, StartMoveWindow_IsDeviceSupportOrNot, TestSize.Level1)
989 {
990     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
991     option->SetWindowName("StartMoveWindow_IsDeviceSupportOrNot");
992     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
993     window->property_->SetPersistentId(1);
994     window->property_->SetWindowType(WindowType::WINDOW_TYPE_GLOBAL_SEARCH);
995     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
996     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
997     window->hostSession_ = session;
998 
999     window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
1000     window->property_->type_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW;
1001     ASSERT_EQ(window->StartMoveWindow(), WmErrorCode::WM_ERROR_INVALID_CALLING);
1002 
1003     window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
1004     ASSERT_NE(window->StartMoveWindow(), WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT);
1005 
1006     window->windowSystemConfig_.windowUIType_ = WindowUIType::INVALID_WINDOW;
1007     ASSERT_EQ(window->StartMoveWindow(), WmErrorCode::WM_ERROR_INVALID_CALLING);
1008 
1009     window->windowSystemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW;
1010     window->windowSystemConfig_.freeMultiWindowEnable_ = false;
1011     window->windowSystemConfig_.freeMultiWindowSupport_ = false;
1012     window->property_->SetIsPcAppInPad(false);
1013     ASSERT_EQ(window->StartMoveWindow(), WmErrorCode::WM_ERROR_INVALID_CALLING);
1014 }
1015 
1016 /**
1017  * @tc.name: StartMoveWindow_02
1018  * @tc.desc: StartMoveWindow Test
1019  * @tc.type: FUNC
1020  */
1021 HWTEST_F(WindowSceneSessionImplTest, StartMoveWindow_02, TestSize.Level1)
1022 {
1023     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1024     option->SetWindowName("StartMoveWindow_02");
1025     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1026     window->property_->SetPersistentId(1);
1027     window->property_->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION);
1028     ASSERT_EQ(window->StartMoveWindow(), WmErrorCode::WM_ERROR_INVALID_CALLING);
1029 
1030     window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1031     window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
1032     ASSERT_EQ(window->StartMoveWindow(), WmErrorCode::WM_ERROR_INVALID_CALLING);
1033 
1034     window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
1035     ASSERT_EQ(window->StartMoveWindow(), WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY);
1036 
1037     SessionInfo info = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1038     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1039     window->hostSession_ = sceneSession;
1040     ASSERT_EQ(window->StartMoveWindow(), WmErrorCode::WM_ERROR_STATE_ABNORMALLY);
1041 
1042     sceneSession->moveDragController_ = sptr<MoveDragController>::MakeSptr(1, WindowType::WINDOW_TYPE_FLOAT);
1043     ASSERT_EQ(window->StartMoveWindow(), WmErrorCode::WM_OK);
1044     sceneSession->moveDragController_->hasPointDown_ = true;
1045     sceneSession->moveDragController_->SetStartMoveFlag(true);
1046     ASSERT_EQ(window->StartMoveWindow(), WmErrorCode::WM_ERROR_REPEAT_OPERATION);
1047 }
1048 
1049 /**
1050  * @tc.name: StartMoveWindowWithCoordinate_03
1051  * @tc.desc: StartMoveWindowWithCoordinate Test
1052  * @tc.type: FUNC
1053  */
1054 HWTEST_F(WindowSceneSessionImplTest, StartMoveWindowWithCoordinate_03, TestSize.Level1)
1055 {
1056     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1057     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1058     window->property_->SetPersistentId(1);
1059     Rect windowRect = { 200, 200, 1000, 1000};
1060     window->property_->SetWindowRect(windowRect);
1061     window->property_->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION);
1062     ASSERT_EQ(window->StartMoveWindowWithCoordinate(-1, 50), WmErrorCode::WM_ERROR_INVALID_CALLING);
1063 
1064     window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1065     window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
1066     ASSERT_EQ(window->StartMoveWindowWithCoordinate(-1, 50), WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT);
1067 
1068     window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
1069     ASSERT_EQ(window->StartMoveWindowWithCoordinate(-1, 50), WmErrorCode::WM_ERROR_STATE_ABNORMALLY);
1070 
1071     SessionInfo info = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1072     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1073     window->hostSession_ = sceneSession;
1074     ASSERT_EQ(window->StartMoveWindowWithCoordinate(-1, 50), WmErrorCode::WM_ERROR_INVALID_PARAM);
1075 
1076     sceneSession->moveDragController_ = sptr<MoveDragController>::MakeSptr(1, WindowType::WINDOW_TYPE_FLOAT);
1077     ASSERT_EQ(window->StartMoveWindowWithCoordinate(500, 500), WmErrorCode::WM_OK);
1078     sceneSession->moveDragController_->hasPointDown_ = true;
1079     sceneSession->moveDragController_->SetStartMoveFlag(true);
1080     ASSERT_EQ(window->StartMoveWindowWithCoordinate(500, 500), WmErrorCode::WM_ERROR_REPEAT_OPERATION);
1081 }
1082 
1083 /**
1084  * @tc.name: StopMoveWindow
1085  * @tc.desc: StopMoveWindow Test
1086  * @tc.type: FUNC
1087  */
1088 HWTEST_F(WindowSceneSessionImplTest, StopMoveWindow, TestSize.Level1)
1089 {
1090     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1091     option->SetWindowName("StopMoveWindow");
1092     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1093     window->property_->SetPersistentId(1);
1094     window->property_->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION);
1095     ASSERT_EQ(window->StopMoveWindow(), WmErrorCode::WM_ERROR_INVALID_CALLING);
1096 
1097     window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1098     window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
1099     ASSERT_EQ(window->StopMoveWindow(), WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT);
1100 
1101     window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
1102     ASSERT_EQ(window->StopMoveWindow(), WmErrorCode::WM_ERROR_STATE_ABNORMALLY);
1103 
1104     SessionInfo info = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1105     sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
1106     window->hostSession_ = sceneSession;
1107     ASSERT_EQ(window->StopMoveWindow(), WmErrorCode::WM_ERROR_STATE_ABNORMALLY);
1108 
1109     sceneSession->moveDragController_ = sptr<MoveDragController>::MakeSptr(1, WindowType::WINDOW_TYPE_FLOAT);
1110     ASSERT_EQ(window->StopMoveWindow(), WmErrorCode::WM_OK);
1111 }
1112 /**
1113  * @tc.name: Close01
1114  * @tc.desc: Close
1115  * @tc.type: FUNC
1116  */
1117 HWTEST_F(WindowSceneSessionImplTest, Close01, TestSize.Level1)
1118 {
1119     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1120     option->SetWindowName("Close01");
1121     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1122     windowSceneSession->property_->SetPersistentId(1);
1123     windowSceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1124     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1125     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1126     windowSceneSession->hostSession_ = session;
1127 
1128     sptr<IWindowWillCloseListener> listener = sptr<IWindowWillCloseListener>::MakeSptr();
1129     windowSceneSession->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
1130     auto res = windowSceneSession->RegisterWindowWillCloseListeners(listener);
1131     ASSERT_EQ(WMError::WM_OK, res);
1132     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Close());
1133     res = windowSceneSession->UnRegisterWindowWillCloseListeners(listener);
1134     ASSERT_EQ(WMError::WM_OK, res);
1135     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Close());
1136 }
1137 
1138 /**
1139  * @tc.name: CloseDirectly
1140  * @tc.desc: CloseDirectly
1141  * @tc.type: FUNC
1142  */
1143 HWTEST_F(WindowSceneSessionImplTest, CloseDirectly, TestSize.Level1)
1144 {
1145     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1146     option->SetWindowName("CloseDirectly");
1147     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1148     auto res = window->CloseDirectly();
1149     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, res);
1150 
1151     window->property_->SetPersistentId(1);
1152     window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1153     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1154     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1155     window->hostSession_ = session;
1156     res = window->CloseDirectly();
1157     ASSERT_EQ(WMError::WM_OK, res);
1158 
1159     window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1160     res = window->CloseDirectly();
1161     ASSERT_EQ(WMError::WM_OK, res);
1162 }
1163 
1164 /**
1165  * @tc.name: SetActive01
1166  * @tc.desc: SetActive
1167  * @tc.type: FUNC
1168  */
1169 HWTEST_F(WindowSceneSessionImplTest, SetActive01, TestSize.Level1)
1170 {
1171     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1172     option->SetWindowName("SetActive01");
1173     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1174 
1175     windowSceneSession->property_->SetPersistentId(1);
1176     windowSceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1177     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1178     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1179 
1180     windowSceneSession->hostSession_ = session;
1181     ASSERT_EQ(WSError::WS_OK, windowSceneSession->SetActive(false));
1182     ASSERT_EQ(WSError::WS_OK, windowSceneSession->SetActive(true));
1183 }
1184 
1185 /**
1186  * @tc.name: Recover01
1187  * @tc.desc: Recover
1188  * @tc.type: FUNC
1189  */
1190 HWTEST_F(WindowSceneSessionImplTest, Recover01, TestSize.Level1)
1191 {
1192     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1193     option->SetWindowName("Recover01");
1194     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1195 
1196     windowSceneSession->property_->SetPersistentId(1);
1197     windowSceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1198     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1199     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1200 
1201     windowSceneSession->hostSession_ = session;
1202     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Recover());
1203 }
1204 
1205 /**
1206  * @tc.name: Recover02
1207  * @tc.desc: Recover02
1208  * @tc.type: FUNC
1209  */
1210 HWTEST_F(WindowSceneSessionImplTest, Recover02, Function | SmallTest | Level2)
1211 {
1212     sptr<WindowOption> subWindowOption = sptr<WindowOption>::MakeSptr();
1213     subWindowOption->SetWindowName("Recover02");
1214     subWindowOption->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1215     subWindowOption->SetSubWindowMaximizeSupported(true);
1216     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(subWindowOption);
1217     window->property_->SetPersistentId(1);
1218     window->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1219     window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1220     window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
1221     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1222     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1223 
1224     window->hostSession_ = session;
1225     ASSERT_EQ(WMError::WM_ERROR_REPEAT_OPERATION, window->Recover());
1226     window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
1227     ASSERT_EQ(WMError::WM_OK, window->Recover());
1228 }
1229 
1230 /**
1231  * @tc.name: Maximize01
1232  * @tc.desc: Maximize
1233  * @tc.type: FUNC
1234  */
1235 HWTEST_F(WindowSceneSessionImplTest, Maximize01, TestSize.Level1)
1236 {
1237     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1238     option->SetWindowName("Maximize01");
1239     option->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1240     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1241     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, windowSceneSession->Maximize());
1242 
1243     windowSceneSession->property_->SetPersistentId(1);
1244     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1245     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1246 
1247     windowSceneSession->hostSession_ = session;
1248     ASSERT_EQ(WMError::WM_OK, windowSceneSession->Maximize());
1249 }
1250 
1251 /**
1252  * @tc.name: MaximizeForCompatibleMode
1253  * @tc.desc: MaximizeForCompatibleMode
1254  * @tc.type: FUNC
1255  */
1256 HWTEST_F(WindowSceneSessionImplTest, MaximizeForCompatibleMode, Function | SmallTest | Level2)
1257 {
1258     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1259     option->SetWindowName("MaximizeForCompatibleMode");
1260     option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1261     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1262     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, windowSceneSession->MaximizeForCompatibleMode());
1263 
1264     windowSceneSession->property_->SetPersistentId(1);
1265     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1266     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1267 
1268     windowSceneSession->hostSession_ = session;
1269     ASSERT_EQ(WMError::WM_OK, windowSceneSession->MaximizeForCompatibleMode());
1270 }
1271 
1272 /**
1273  * @tc.name: RecoverForCompatibleMode
1274  * @tc.desc: RecoverForCompatibleMode
1275  * @tc.type: FUNC
1276  */
1277 HWTEST_F(WindowSceneSessionImplTest, RecoverForCompatibleMode, Function | SmallTest | Level2)
1278 {
1279     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1280     option->SetWindowName("RecoverForCompatibleMode");
1281     option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1282     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1283     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, windowSceneSession->RecoverForCompatibleMode());
1284 
1285     windowSceneSession->property_->SetPersistentId(1);
1286     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1287     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1288 
1289     windowSceneSession->hostSession_ = session;
1290     ASSERT_EQ(WMError::WM_OK, windowSceneSession->RecoverForCompatibleMode());
1291 }
1292 
1293 /**
1294  * @tc.name: Hide01
1295  * @tc.desc: Hide session
1296  * @tc.type: FUNC
1297  */
1298 HWTEST_F(WindowSceneSessionImplTest, Hide01, TestSize.Level0)
1299 {
1300     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1301     option->SetWindowName("Hide01");
1302     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1303 
1304     window->property_->SetPersistentId(1);
1305     // show with null session
1306     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Hide(2, false, false));
1307 
1308     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1309     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1310 
1311     window->hostSession_ = session;
1312     ASSERT_EQ(WMError::WM_OK, window->Hide(2, false, false));
1313     ASSERT_EQ(WMError::WM_OK, window->Hide(2, false, false));
1314 
1315     window->state_ = WindowState::STATE_CREATED;
1316     ASSERT_EQ(WMError::WM_OK, window->Hide(2, false, false));
1317     window->state_ = WindowState::STATE_SHOWN;
1318     window->property_->type_ = WindowType::APP_SUB_WINDOW_BASE;
1319     ASSERT_EQ(WMError::WM_OK, window->Hide(2, false, false));
1320 
1321     window->property_->type_ = WindowType::APP_SUB_WINDOW_BASE;
1322     ASSERT_EQ(WMError::WM_OK, window->Destroy(false));
1323 }
1324 
1325 /**
1326  * @tc.name: Hide02
1327  * @tc.desc: Hide session
1328  * @tc.type: FUNC
1329  */
1330 HWTEST_F(WindowSceneSessionImplTest, Hide02, TestSize.Level0)
1331 {
1332     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1333     option->SetWindowName("Hide02");
1334     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1335 
1336     window->property_->SetPersistentId(1);
1337     window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1338     // show with null session
1339     EXPECT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Hide(2, false, false));
1340 
1341     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1342     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1343 
1344     window->hostSession_ = session;
1345     EXPECT_EQ(WMError::WM_OK, window->Hide(0, false, false, true));
1346     EXPECT_EQ(WMError::WM_OK, window->Destroy(false));
1347 }
1348 
1349 /**
1350  * @tc.name: Hide03
1351  * @tc.desc: Hide session
1352  * @tc.type: FUNC
1353  */
1354 HWTEST_F(WindowSceneSessionImplTest, Hide03, TestSize.Level0)
1355 {
1356     g_logMsg.clear();
1357     LOG_SetCallback(LogCallback);
1358     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1359     option->SetWindowName("Hide03");
1360     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1361 
1362     window->property_->SetPersistentId(1);
1363     window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1364     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1365     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1366     window->hostSession_ = session;
1367 
1368     window->NotifyWindowAttachStateChange(false);
1369     EXPECT_TRUE(g_logMsg.find("notifyAttachState id") == std::string::npos);
1370 
1371     EXPECT_EQ(WMError::WM_OK, window->Hide(0, false, false, false));
1372     EXPECT_TRUE(g_logMsg.find("init lifecycleCallback") == std::string::npos);
1373     EXPECT_EQ(WMError::WM_OK, window->Show(0, false, true, false));
1374 
1375     window->property_->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1376     EXPECT_EQ(WMError::WM_OK, window->Hide(0, false, false, true));
1377     EXPECT_TRUE(g_logMsg.find("init lifecycleCallback") == std::string::npos);
1378     EXPECT_EQ(WMError::WM_OK, window->Show(0, false, true, true));
1379 
1380     window->property_->SetWindowType(WindowType::WINDOW_TYPE_KEYBOARD_PANEL);
1381     EXPECT_EQ(WMError::WM_OK, window->Hide(0, false, false, true));
1382     EXPECT_TRUE(g_logMsg.find("init lifecycleCallback") == std::string::npos);
1383     EXPECT_EQ(WMError::WM_OK, window->Show(0, false, true, true));
1384 
1385     window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1386     window->lifecycleCallback_ = sptr<LifecycleFutureCallback>::MakeSptr();
1387     EXPECT_EQ(WMError::WM_OK, window->Hide(0, false, false, true));
1388     EXPECT_TRUE(g_logMsg.find("init lifecycleCallback") == std::string::npos);
1389     EXPECT_EQ(WMError::WM_OK, window->Show(0, false, true, true));
1390 
1391     window->NotifyWindowAttachStateChange(false);
1392     EXPECT_TRUE(g_logMsg.find("notifyAttachState id") != std::string::npos);
1393     EXPECT_EQ(WMError::WM_OK, window->Hide(0, false, false, true));
1394     EXPECT_TRUE(g_logMsg.find("Window hide") != std::string::npos);
1395     EXPECT_TRUE(g_logMsg.find("get attach state sync result") != std::string::npos);
1396 
1397     window->lifecycleCallback_ = nullptr;
1398     EXPECT_EQ(WMError::WM_OK, window->Show(0, false, true, true));
1399     EXPECT_EQ(WMError::WM_OK, window->Hide(0, false, false, true));
1400     EXPECT_TRUE(g_logMsg.find("init lifecycleCallback") != std::string::npos);
1401     EXPECT_EQ(WMError::WM_OK, window->Destroy(false));
1402 }
1403 
1404 /**
1405  * @tc.name: Show01
1406  * @tc.desc: Show session
1407  * @tc.type: FUNC
1408  */
1409 HWTEST_F(WindowSceneSessionImplTest, Show01, TestSize.Level0)
1410 {
1411     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1412     option->SetWindowName("Show01");
1413     option->SetDisplayId(0);
1414     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1415     window->property_->SetPersistentId(1);
1416 
1417     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1418     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1419 
1420     window->hostSession_ = session;
1421     ASSERT_EQ(WMError::WM_OK, window->Show(2, false));
1422 
1423     window->state_ = WindowState::STATE_CREATED;
1424     ASSERT_EQ(WMError::WM_OK, window->Show(2, false));
1425     ASSERT_EQ(WMError::WM_OK, window->Destroy(false));
1426 }
1427 
1428 /**
1429  * @tc.name: Show02
1430  * @tc.desc: Show session
1431  * @tc.type: FUNC
1432  */
1433 HWTEST_F(WindowSceneSessionImplTest, Show02, TestSize.Level0)
1434 {
1435     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1436     option->SetWindowName("Show02");
1437     option->SetDisplayId(0);
1438     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1439     window->property_->SetPersistentId(1);
1440     window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1441 
1442     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1443     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1444 
1445     window->hostSession_ = session;
1446     ASSERT_EQ(WMError::WM_OK, window->Show(0, false, true, true));
1447     ASSERT_EQ(WMError::WM_OK, window->Destroy(false));
1448 }
1449 
1450 /**
1451  * @tc.name: Show03
1452  * @tc.desc: Show session
1453  * @tc.type: FUNC
1454  */
1455 HWTEST_F(WindowSceneSessionImplTest, Show03, TestSize.Level0)
1456 {
1457     g_logMsg.clear();
1458     LOG_SetCallback(LogCallback);
1459     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1460     option->SetWindowName("Show03");
1461     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1462 
1463     window->property_->SetPersistentId(1);
1464     window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1465     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1466     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1467     window->hostSession_ = session;
1468 
1469     window->NotifyWindowAttachStateChange(true);
1470     EXPECT_TRUE(g_logMsg.find("notifyAttachState id") == std::string::npos);
1471 
1472     EXPECT_EQ(WMError::WM_OK, window->Show(0, false, true, false));
1473     EXPECT_TRUE(g_logMsg.find("init lifecycleCallback") == std::string::npos);
1474     EXPECT_EQ(WMError::WM_OK, window->Hide(0, false, false, false));
1475 
1476     window->property_->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1477     EXPECT_EQ(WMError::WM_OK, window->Show(0, false, true, true));
1478     EXPECT_TRUE(g_logMsg.find("init lifecycleCallback") == std::string::npos);
1479     EXPECT_EQ(WMError::WM_OK, window->Hide(0, false, false, true));
1480 
1481     window->property_->SetWindowType(WindowType::WINDOW_TYPE_KEYBOARD_PANEL);
1482     EXPECT_EQ(WMError::WM_OK, window->Show(0, false, true, true));
1483     EXPECT_TRUE(g_logMsg.find("init lifecycleCallback") == std::string::npos);
1484     EXPECT_EQ(WMError::WM_OK, window->Hide(0, false, false, true));
1485 
1486     window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1487     window->lifecycleCallback_ = sptr<LifecycleFutureCallback>::MakeSptr();
1488     EXPECT_EQ(WMError::WM_OK, window->Show(0, false, true, true));
1489     EXPECT_TRUE(g_logMsg.find("init lifecycleCallback") == std::string::npos);
1490     EXPECT_EQ(WMError::WM_OK, window->Hide(0, false, false, true));
1491 
1492     window->NotifyWindowAttachStateChange(true);
1493     EXPECT_TRUE(g_logMsg.find("notifyAttachState id") != std::string::npos);
1494     EXPECT_EQ(WMError::WM_OK, window->Show(0, false, true, true));
1495     EXPECT_TRUE(g_logMsg.find("Window show") != std::string::npos);
1496     EXPECT_TRUE(g_logMsg.find("get attach state sync result") != std::string::npos);
1497 
1498     window->lifecycleCallback_ = nullptr;
1499     EXPECT_EQ(WMError::WM_OK, window->Hide(0, false, false, true));
1500     EXPECT_EQ(WMError::WM_OK, window->Show(0, false, true, true));
1501     EXPECT_TRUE(g_logMsg.find("init lifecycleCallback") != std::string::npos);
1502     EXPECT_EQ(WMError::WM_OK, window->Destroy(false));
1503 }
1504 
1505 /**
1506  * @tc.name: GetDisplayInfo
1507  * @tc.desc: get DisplayInfo
1508  * @tc.type: FUNC
1509  */
1510 HWTEST_F(WindowSceneSessionImplTest, GetDisplayInfo, TestSize.Level0)
1511 {
1512     g_logMsg.clear();
1513     LOG_SetCallback(LogCallback);
1514     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1515     option->SetWindowName("GetDisplayInfo");
1516     option->SetDisplayId(10);
1517     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1518     window->property_->SetPersistentId(1);
1519 
1520     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1521     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1522     window->hostSession_ = session;
1523 
1524     window->property_->SetWindowType(WindowType::SYSTEM_WINDOW_BASE);
1525     EXPECT_TRUE(g_logMsg.find("use default display id") == std::string::npos);
1526     EXPECT_EQ(true, window->GetDisplayInfo() == nullptr);
1527 
1528     window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1529     EXPECT_EQ(true, window->GetDisplayInfo() != nullptr);
1530     EXPECT_TRUE(g_logMsg.find("use default display id") != std::string::npos);
1531     EXPECT_EQ(WSError::WS_OK, window->UpdateDisplayId(0));
1532     EXPECT_EQ(true, window->GetDisplayInfo() != nullptr);
1533 
1534     EXPECT_EQ(WMError::WM_OK, window->Destroy(false));
1535 }
1536 
1537 /**
1538  * @tc.name: NotifyDrawingCompleted
1539  * @tc.desc: NotifyDrawingCompleted session
1540  * @tc.type: FUNC
1541  */
1542 HWTEST_F(WindowSceneSessionImplTest, NotifyDrawingCompleted, TestSize.Level1)
1543 {
1544     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1545     ASSERT_NE(nullptr, option);
1546     option->SetWindowName("NotifyDrawingCompleted");
1547     option->SetDisplayId(0);
1548     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1549     ASSERT_NE(nullptr, window->property_);
1550     window->property_->SetPersistentId(1);
1551 
1552     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1553     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1554 
1555     window->hostSession_ = session;
1556     auto ret = window->NotifyDrawingCompleted();
1557     ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_PERMISSION);
1558 }
1559 
1560 /**
1561  * @tc.name: NotifyRemoveStartingWindow
1562  * @tc.desc: NotifyRemoveStartingWindow session
1563  * @tc.type: FUNC
1564  */
1565 HWTEST_F(WindowSceneSessionImplTest, NotifyRemoveStartingWindow, TestSize.Level1)
1566 {
1567     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1568     option->SetWindowName("NotifyRemoveStartingWindow");
1569     option->SetDisplayId(0);
1570     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1571     auto ret = window->NotifyRemoveStartingWindow();
1572     ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_WINDOW);
1573     window->property_->SetPersistentId(1);
1574     window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
1575 
1576     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1577     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1578     window->hostSession_ = session;
1579     window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1580     ret = window->NotifyRemoveStartingWindow();
1581     ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_WINDOW);
1582     window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1583     EXPECT_CALL(*(session), RemoveStartingWindow()).WillOnce(Return(WSError::WS_OK));
1584     ret = window->NotifyRemoveStartingWindow();
1585     ASSERT_EQ(ret, WMError::WM_OK);
1586 }
1587 
1588 /**
1589  * @tc.name: SetTransparent
1590  * @tc.desc: SetTransparent test
1591  * @tc.type: FUNC
1592  */
1593 HWTEST_F(WindowSceneSessionImplTest, SetTransparent, TestSize.Level1)
1594 {
1595     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1596     option->SetWindowName("SetTransparent");
1597     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1598     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetTransparent(true));
1599     window->property_->SetPersistentId(1);
1600     window->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1601     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1602     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1603     ASSERT_NE(nullptr, session);
1604     window->hostSession_ = session;
1605     window->uiContent_ = std::make_unique<Ace::UIContentMocker>();
1606     window->SetBackgroundColor(333);
1607 
1608     auto ret = window->SetTransparent(true);
1609     ASSERT_EQ(ret, WMError::WM_OK);
1610 }
1611 
1612 /**
1613  * @tc.name: GetTopwindowWithId
1614  * @tc.desc: GetTopwindowWithId test
1615  * @tc.type: FUNC
1616  */
1617 HWTEST_F(WindowSceneSessionImplTest, GetTopwindowWithId, TestSize.Level1)
1618 {
1619     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1620     option->SetWindowName("GetTopwindowWithId");
1621     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1622     sptr<WindowSessionImpl> session = sptr<WindowSessionImpl>::MakeSptr(option);
1623     uint32_t windowId = 1;
1624     string winName = "test";
1625     WindowSessionImpl::windowSessionMap_.insert(
1626         std::make_pair(winName, std::pair<int32_t, sptr<WindowSessionImpl>>(windowId, session)));
1627     EXPECT_CALL(m->Mock(), GetTopWindowId(_, _)).Times(1).WillOnce(Return(WMError::WM_DO_NOTHING));
1628     uint32_t mainWinId = 1;
1629     ASSERT_EQ(nullptr, window->GetTopWindowWithId(mainWinId));
1630 
1631     EXPECT_CALL(m->Mock(), GetTopWindowId(_, _))
1632         .Times(1)
1633         .WillOnce(DoAll(SetArgReferee<1>(windowId), Return(WMError::WM_OK)));
1634     ASSERT_NE(nullptr, window->GetTopWindowWithId(mainWinId));
1635 
1636     int32_t tempWinId = 3;
1637     EXPECT_CALL(m->Mock(), GetTopWindowId(_, _))
1638         .Times(1)
1639         .WillOnce(DoAll(SetArgReferee<1>(tempWinId), Return(WMError::WM_OK)));
1640     ASSERT_EQ(nullptr, window->GetTopWindowWithId(mainWinId));
1641 
1642     WindowSessionImpl::windowSessionMap_.erase(winName);
1643 }
1644 
1645 /**
1646  * @tc.name: GetAvoidAreaByType
1647  * @tc.desc: GetAvoidAreaByType test
1648  * @tc.type: FUNC
1649  */
1650 HWTEST_F(WindowSceneSessionImplTest, GetAvoidAreaByType, TestSize.Level1)
1651 {
1652     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1653     option->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
1654     option->SetWindowName("GetAvoidAreaByType");
1655     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1656 
1657     window->property_->SetPersistentId(1);
1658     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1659     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1660     AvoidArea avoidarea;
1661     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->GetAvoidAreaByType(AvoidAreaType::TYPE_CUTOUT, avoidarea));
1662     window->hostSession_ = session;
1663     ASSERT_EQ(WMError::WM_OK, window->GetAvoidAreaByType(AvoidAreaType::TYPE_CUTOUT, avoidarea));
1664     window->property_->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
1665     Rect rect;
1666     ASSERT_EQ(WMError::WM_OK, window->GetAvoidAreaByType(AvoidAreaType::TYPE_CUTOUT, avoidarea, rect, 15));
1667     ASSERT_EQ(WMError::WM_OK, window->GetAvoidAreaByType(AvoidAreaType::TYPE_CUTOUT, avoidarea, rect, 16));
1668 }
1669 
1670 /**
1671  * @tc.name: Immersive
1672  * @tc.desc: Immersive01 test
1673  * @tc.type: FUNC
1674  */
1675 HWTEST_F(WindowSceneSessionImplTest, Immersive, TestSize.Level1)
1676 {
1677     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1678     option->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
1679     option->SetWindowName("Immersive");
1680     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1681 
1682     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetLayoutFullScreen(false));
1683     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetFullScreen(false));
1684     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1685     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1686     window->hostSession_ = session;
1687 
1688     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetFullScreen(false));
1689     ASSERT_EQ(false, window->IsLayoutFullScreen());
1690     ASSERT_EQ(false, window->IsFullScreen());
1691 }
1692 
1693 /**
1694  * @tc.name: SystemBarProperty
1695  * @tc.desc: SystemBarProperty01 test
1696  * @tc.type: FUNC
1697  */
1698 HWTEST_F(WindowSceneSessionImplTest, SystemBarProperty, TestSize.Level1)
1699 {
1700     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1701     option->SetWindowName("SystemBarProperty");
1702     option->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
1703     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1704 
1705     SystemBarProperty property = SystemBarProperty();
1706     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW,
1707               window->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, property));
1708 }
1709 
1710 /**
1711  * @tc.name: SystemBarProperty02
1712  * @tc.desc: SystemBarProperty02 test
1713  * @tc.type: FUNC
1714  */
1715 HWTEST_F(WindowSceneSessionImplTest, SystemBarProperty02, TestSize.Level1)
1716 {
1717     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1718     option->SetWindowName("SystemBarProperty02");
1719     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1720 
1721     window->state_ = WindowState::STATE_SHOWN;
1722     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1723     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1724     window->property_->SetPersistentId(1);
1725     window->hostSession_ = session;
1726 
1727     SystemBarProperty property;
1728     ASSERT_EQ(WMError::WM_OK, window->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, property));
1729     ASSERT_FALSE(window->property_->GetSystemBarProperty()[WindowType::WINDOW_TYPE_STATUS_BAR].enableAnimation_);
1730 
1731     property.enableAnimation_ = false;
1732     ASSERT_EQ(WMError::WM_OK, window->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, property));
1733     ASSERT_FALSE(window->property_->GetSystemBarProperty()[WindowType::WINDOW_TYPE_STATUS_BAR].enableAnimation_);
1734 }
1735 
1736 /**
1737  * @tc.name: SystemBarProperty03
1738  * @tc.desc: SystemBarProperty03 test
1739  * @tc.type: FUNC
1740  */
1741 HWTEST_F(WindowSceneSessionImplTest, SystemBarProperty03, TestSize.Level1)
1742 {
1743     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1744     option->SetWindowName("SystemBarProperty03");
1745     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1746 
1747     window->state_ = WindowState::STATE_SHOWN;
1748     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1749     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1750     window->property_->SetPersistentId(1);
1751     window->hostSession_ = session;
1752 
1753     SystemBarProperty property;
1754     property.enableAnimation_ = true;
1755     ASSERT_EQ(WMError::WM_OK, window->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, property));
1756     ASSERT_TRUE(window->property_->GetSystemBarProperty()[WindowType::WINDOW_TYPE_STATUS_BAR].enableAnimation_);
1757 }
1758 
1759 /**
1760  * @tc.name: SystemBarProperty04
1761  * @tc.desc: SystemBarProperty04 test
1762  * @tc.type: FUNC
1763  */
1764 HWTEST_F(WindowSceneSessionImplTest, SystemBarProperty04, TestSize.Level1)
1765 {
1766     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1767     option->SetWindowName("SystemBarProperty04");
1768     option->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
1769     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1770 
1771     SystemBarProperty property;
1772     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW,
1773               window->SetSpecificBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, property));
1774 }
1775 
1776 /**
1777  * @tc.name: SystemBarProperty05
1778  * @tc.desc: SystemBarProperty05 test
1779  * @tc.type: FUNC
1780  */
1781 HWTEST_F(WindowSceneSessionImplTest, SystemBarProperty05, TestSize.Level1)
1782 {
1783     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1784     option->SetWindowName("SystemBarProperty05");
1785     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1786 
1787     window->state_ = WindowState::STATE_SHOWN;
1788     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1789     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1790     window->property_->SetPersistentId(1);
1791     window->hostSession_ = session;
1792 
1793     SystemBarProperty property;
1794     ASSERT_EQ(WMError::WM_OK, window->SetSpecificBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, property));
1795     ASSERT_FALSE(window->property_->GetSystemBarProperty()[WindowType::WINDOW_TYPE_STATUS_BAR].enableAnimation_);
1796 
1797     property.enableAnimation_ = false;
1798     ASSERT_EQ(WMError::WM_OK, window->SetSpecificBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, property));
1799     ASSERT_FALSE(window->property_->GetSystemBarProperty()[WindowType::WINDOW_TYPE_STATUS_BAR].enableAnimation_);
1800 }
1801 
1802 /**
1803  * @tc.name: SystemBarProperty06
1804  * @tc.desc: SystemBarProperty06 test
1805  * @tc.type: FUNC
1806  */
1807 HWTEST_F(WindowSceneSessionImplTest, SystemBarProperty06, TestSize.Level1)
1808 {
1809     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1810     option->SetWindowName("SystemBarProperty06");
1811     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1812 
1813     window->state_ = WindowState::STATE_SHOWN;
1814     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1815     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1816     window->property_->SetPersistentId(1);
1817     window->hostSession_ = session;
1818 
1819     SystemBarProperty property;
1820     property.enableAnimation_ = true;
1821     ASSERT_EQ(WMError::WM_OK, window->SetSpecificBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, property));
1822     ASSERT_TRUE(window->property_->GetSystemBarProperty()[WindowType::WINDOW_TYPE_STATUS_BAR].enableAnimation_);
1823 }
1824 
1825 /**
1826  * @tc.name: SystemBarProperty07
1827  * @tc.desc: SystemBarProperty07 test
1828  * @tc.type: FUNC
1829  */
1830 HWTEST_F(WindowSceneSessionImplTest, SystemBarProperty07, TestSize.Level1)
1831 {
1832     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1833     option->SetWindowName("SystemBarProperty07");
1834     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1835 
1836     window->state_ = WindowState::STATE_SHOWN;
1837     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1838     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1839     window->property_->SetPersistentId(1);
1840     ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, session));
1841     window->hostSession_ = session;
1842 
1843     SystemBarProperty property;
1844     ASSERT_EQ(WMError::WM_OK, window->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, property));
1845     ASSERT_EQ(SystemBarSettingFlag::DEFAULT_SETTING,
1846               window->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_STATUS_BAR).settingFlag_);
1847 
1848     property.enable_ = false;
1849     property.settingFlag_ = SystemBarSettingFlag::ENABLE_SETTING;
1850     ASSERT_EQ(WMError::WM_OK, window->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, property));
1851     ASSERT_EQ(SystemBarSettingFlag::ENABLE_SETTING,
1852               window->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_STATUS_BAR).settingFlag_);
1853 
1854     property.backgroundColor_ = 0xB3000000;
1855     property.settingFlag_ = SystemBarSettingFlag::COLOR_SETTING;
1856     ASSERT_EQ(WMError::WM_OK, window->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, property));
1857     ASSERT_EQ(SystemBarSettingFlag::COLOR_SETTING,
1858               window->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_STATUS_BAR).settingFlag_);
1859 
1860     property.enable_ = true;
1861     property.backgroundColor_ = 0x4C000000;
1862     property.settingFlag_ = SystemBarSettingFlag::ALL_SETTING;
1863     ASSERT_EQ(WMError::WM_OK, window->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, property));
1864     ASSERT_EQ(WMError::WM_OK, window->Destroy(true));
1865 }
1866 
1867 /**
1868  * @tc.name: SetSystemBarProperties
1869  * @tc.desc: SetSystemBarProperties test
1870  * @tc.type: FUNC
1871  */
1872 HWTEST_F(WindowSceneSessionImplTest, SetSystemBarProperties, TestSize.Level1)
1873 {
1874     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1875     option->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
1876     option->SetWindowName("SetSystemBarProperties");
1877     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1878     window->state_ = WindowState::STATE_SHOWN;
1879     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1880     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1881     window->property_->SetPersistentId(1);
1882     window->hostSession_ = session;
1883     std::map<WindowType, SystemBarProperty> properties;
1884     std::map<WindowType, SystemBarPropertyFlag> propertyFlags;
1885     SystemBarProperty current = window->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_STATUS_BAR);
1886     SystemBarProperty property;
1887     properties[WindowType::WINDOW_TYPE_STATUS_BAR] = property;
1888     SystemBarPropertyFlag propertyFlag;
1889     propertyFlag.contentColorFlag = true;
1890     propertyFlags[WindowType::WINDOW_TYPE_STATUS_BAR] = propertyFlag;
1891     ASSERT_EQ(WMError::WM_OK, window->SetSystemBarProperties(properties, propertyFlags));
1892     if (property.contentColor_ != current.contentColor_) {
1893         std::map<WindowType, SystemBarProperty> currProperties;
1894         ASSERT_EQ(WMError::WM_OK, window->GetSystemBarProperties(currProperties));
1895         ASSERT_EQ(currProperties[WindowType::WINDOW_TYPE_STATUS_BAR].contentColor_, property.contentColor_);
1896     }
1897 }
1898 
1899 /**
1900  * @tc.name: GetSystemBarProperties
1901  * @tc.desc: GetSystemBarProperties test
1902  * @tc.type: FUNC
1903  */
1904 HWTEST_F(WindowSceneSessionImplTest, GetSystemBarProperties, TestSize.Level1)
1905 {
1906     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1907     option->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
1908     option->SetWindowName("GetSystemBarProperties");
1909     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1910     std::map<WindowType, SystemBarProperty> properties;
1911     ASSERT_EQ(WMError::WM_OK, window->GetSystemBarProperties(properties));
1912 }
1913 
1914 /**
1915  * @tc.name: SpecificBarProperty
1916  * @tc.desc: SpecificBarProperty01 test
1917  * @tc.type: FUNC
1918  */
1919 HWTEST_F(WindowSceneSessionImplTest, SpecificBarProperty, TestSize.Level1)
1920 {
1921     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1922     option->SetWindowName("SpecificBarProperty");
1923     option->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
1924     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1925 
1926     SystemBarProperty property = SystemBarProperty();
1927     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW,
1928               window->SetSpecificBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, property));
1929 }
1930 
1931 /**
1932  * @tc.name: NotifySpecificWindowSessionProperty
1933  * @tc.desc: NotifySpecificWindowSessionProperty01 test
1934  * @tc.type: FUNC
1935  */
1936 HWTEST_F(WindowSceneSessionImplTest, NotifySpecificWindowSessionProperty, TestSize.Level1)
1937 {
1938     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1939     option->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
1940     option->SetWindowName("NotifySpecificWindowSessionProperty");
1941     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1942 
1943     SystemBarProperty property = SystemBarProperty();
1944     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW,
1945               window->NotifySpecificWindowSessionProperty(WindowType::WINDOW_TYPE_STATUS_BAR, property));
1946     window->property_->SetPersistentId(190);
1947     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1948     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1949     ASSERT_NE(nullptr, session);
1950     window->hostSession_ = session;
1951     window->state_ = WindowState::STATE_HIDDEN;
1952     ASSERT_EQ(WMError::WM_OK,
1953               window->NotifySpecificWindowSessionProperty(WindowType::WINDOW_TYPE_NAVIGATION_BAR, property));
1954     window->state_ = WindowState::STATE_SHOWN;
1955     ASSERT_EQ(WMError::WM_OK,
1956               window->NotifySpecificWindowSessionProperty(WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR, property));
1957 }
1958 
1959 /**
1960  * @tc.name: LimitCameraFloatWindowMininumSize
1961  * @tc.desc: LimitCameraFloatWindowMininumSize01 test
1962  * @tc.type: FUNC
1963  */
1964 HWTEST_F(WindowSceneSessionImplTest, LimitCameraFloatWindowMininumSize, TestSize.Level1)
1965 {
1966     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1967     ASSERT_NE(option, nullptr);
1968     option->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
1969     option->SetWindowName("LimitCameraFloatWindowMininumSize");
1970     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1971     ASSERT_NE(window, nullptr);
1972     uint32_t width = 33;
1973     uint32_t height = 31;
1974     float vpr = 0.0f;
1975     window->LimitCameraFloatWindowMininumSize(width, height, vpr);
1976 }
1977 
1978 /**
1979  * @tc.name: NotifyWindowNeedAvoid
1980  * @tc.desc: NotifyWindowNeedAvoid test
1981  * @tc.type: FUNC
1982  */
1983 HWTEST_F(WindowSceneSessionImplTest, NotifyWindowNeedAvoid, TestSize.Level1)
1984 {
1985     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1986     option->SetWindowName("NotifyWindowNeedAvoid");
1987     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
1988     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->NotifyWindowNeedAvoid(false));
1989 
1990     window->state_ = WindowState::STATE_SHOWN;
1991     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1992     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1993     window->property_->SetPersistentId(190);
1994     window->hostSession_ = session;
1995     ASSERT_EQ(WMError::WM_OK, window->NotifyWindowNeedAvoid(false));
1996 }
1997 
1998 /**
1999  * @tc.name: SetLayoutFullScreenByApiVersion
2000  * @tc.desc: SetLayoutFullScreenByApiVersion test
2001  * @tc.type: FUNC
2002  */
2003 HWTEST_F(WindowSceneSessionImplTest, SetLayoutFullScreenByApiVersion, TestSize.Level0)
2004 {
2005     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2006     option->SetWindowName("SetLayoutFullScreenByApiVersion");
2007     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2008     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetLayoutFullScreenByApiVersion(false));
2009     window->state_ = WindowState::STATE_SHOWN;
2010     window->property_->SetPersistentId(190);
2011     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
2012     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2013     window->hostSession_ = session;
2014     ASSERT_EQ(WMError::WM_OK, window->SetLayoutFullScreenByApiVersion(false));
2015     ASSERT_EQ(false, window->property_->IsLayoutFullScreen());
2016 }
2017 
2018 /**
2019  * @tc.name: SetIgnoreSafeArea
2020  * @tc.desc: SetIgnoreSafeArea test
2021  * @tc.type: FUNC
2022  */
2023 HWTEST_F(WindowSceneSessionImplTest, SetIgnoreSafeArea, TestSize.Level0)
2024 {
2025     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2026     option->SetWindowName("SetIgnoreSafeArea");
2027     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2028     EXPECT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetIgnoreSafeArea(false));
2029     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
2030     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2031     window->hostSession_ = session;
2032     window->state_ = WindowState::STATE_SHOWN;
2033     window->property_->SetPersistentId(1);
2034     EXPECT_EQ(WMError::WM_OK, window->SetIgnoreSafeArea(false));
2035     EXPECT_FALSE(window->isIgnoreSafeArea_);
2036     EXPECT_EQ(WMError::WM_OK, window->SetIgnoreSafeArea(true));
2037     EXPECT_TRUE(window->isIgnoreSafeArea_);
2038 }
2039 
2040 /**
2041  * @tc.name: SetGlobalMaximizeMode
2042  * @tc.desc: SetGlobalMaximizeMode test
2043  * @tc.type: FUNC
2044  */
2045 HWTEST_F(WindowSceneSessionImplTest, SetGlobalMaximizeMode, TestSize.Level1)
2046 {
2047     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2048     option->SetWindowName("SetGlobalMaximizeMode");
2049     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2050     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetGlobalMaximizeMode(MaximizeMode::MODE_RECOVER));
2051 
2052     window->state_ = WindowState::STATE_SHOWN;
2053     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
2054     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2055     window->property_->SetPersistentId(190);
2056     window->hostSession_ = session;
2057     window->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
2058     ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, window->SetGlobalMaximizeMode(MaximizeMode::MODE_RECOVER));
2059 
2060     window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
2061     ASSERT_EQ(WMError::WM_OK, window->SetGlobalMaximizeMode(MaximizeMode::MODE_RECOVER));
2062 }
2063 
2064 /**
2065  * @tc.name: CheckParmAndPermission
2066  * @tc.desc: CheckParmAndPermission test
2067  * @tc.type: FUNC
2068  */
2069 HWTEST_F(WindowSceneSessionImplTest, CheckParmAndPermission, TestSize.Level1)
2070 {
2071     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2072     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2073     window->property_->SetWindowName("CheckParmAndPermission");
2074     window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
2075 
2076     auto surfaceNode = window->GetSurfaceNode();
2077     if (surfaceNode == nullptr) {
2078         ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->CheckParmAndPermission());
2079     } else {
2080         ASSERT_EQ(WMError::WM_OK, window->CheckParmAndPermission());
2081         window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
2082         ASSERT_EQ(WMError::WM_OK, window->CheckParmAndPermission());
2083     }
2084 }
2085 
2086 /**
2087  * @tc.name: SetTurnScreenOn
2088  * @tc.desc: SetTurnScreenOn test
2089  * @tc.type: FUNC
2090  */
2091 HWTEST_F(WindowSceneSessionImplTest, SetTurnScreenOn, TestSize.Level1)
2092 {
2093     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2094     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2095     window->property_->SetWindowName("SetTurnScreenOn");
2096     window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
2097     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetTurnScreenOn(false));
2098 
2099     window->property_->SetPersistentId(1);
2100     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
2101     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2102     window->hostSession_ = session;
2103     ASSERT_EQ(WMError::WM_OK, window->SetTurnScreenOn(false));
2104 }
2105 
2106 /**
2107  * @tc.name: SetKeepScreenOn01
2108  * @tc.desc: Window is Invalid
2109  * @tc.type: FUNC
2110  */
2111 HWTEST_F(WindowSceneSessionImplTest, SetKeepScreenOn01, TestSize.Level1)
2112 {
2113     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2114     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2115 
2116     window->property_->SetWindowName("SetKeepScreenOn");
2117     window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
2118     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetKeepScreenOn(false));
2119     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetKeepScreenOn(true));
2120 }
2121 
2122 /**
2123  * @tc.name: SetKeepScreenOn02
2124  * @tc.desc: Window is Valid
2125  * @tc.type: FUNC
2126  */
2127 HWTEST_F(WindowSceneSessionImplTest, SetKeepScreenOn02, TestSize.Level1)
2128 {
2129     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2130     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2131 
2132     window->property_->SetWindowName("SetKeepScreenOn");
2133     window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
2134     window->property_->SetPersistentId(1);
2135     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
2136     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2137     window->hostSession_ = session;
2138     ASSERT_EQ(WMError::WM_OK, window->SetKeepScreenOn(true));
2139     ASSERT_TRUE(window->IsKeepScreenOn());
2140     ASSERT_EQ(WMError::WM_OK, window->SetKeepScreenOn(false));
2141     ASSERT_FALSE(window->IsKeepScreenOn());
2142 }
2143 
2144 /**
2145  * @tc.name: SetViewKeepScreenOn01
2146  * @tc.desc: Window is Invalid
2147  * @tc.type: FUNC
2148  */
2149 HWTEST_F(WindowSceneSessionImplTest, SetViewKeepScreenOn01, TestSize.Level1)
2150 {
2151     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2152     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2153 
2154     window->property_->SetWindowName("SetViewKeepScreenOn");
2155     window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
2156     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetViewKeepScreenOn(false));
2157     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetViewKeepScreenOn(true));
2158 }
2159 
2160 /**
2161  * @tc.name: SetViewKeepScreenOn02
2162  * @tc.desc: Window is Valid
2163  * @tc.type: FUNC
2164  */
2165 HWTEST_F(WindowSceneSessionImplTest, SetViewKeepScreenOn02, TestSize.Level1)
2166 {
2167     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2168     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2169 
2170     window->property_->SetWindowName("SetViewKeepScreenOn");
2171     window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
2172     window->property_->SetPersistentId(1);
2173     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
2174     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2175     window->hostSession_ = session;
2176     ASSERT_EQ(WMError::WM_OK, window->SetViewKeepScreenOn(true));
2177     ASSERT_TRUE(window->IsViewKeepScreenOn());
2178     ASSERT_EQ(WMError::WM_OK, window->SetViewKeepScreenOn(false));
2179     ASSERT_FALSE(window->IsViewKeepScreenOn());
2180 }
2181 
2182 /**
2183  * @tc.name: SetWindowShadowEnabled01
2184  * @tc.desc: Window is Invalid
2185  * @tc.type: FUNC
2186  */
2187 HWTEST_F(WindowSceneSessionImplTest, SetWindowShadowEnabled01, TestSize.Level1)
2188 {
2189     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2190     option->SetBundleName("SetWindowShadowEnabled");
2191     option->SetWindowName("SetWindowShadowEnabled");
2192     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2193     ASSERT_NE(nullptr, window);
2194 
2195     window->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
2196     window->property_->SetPersistentId(1);
2197     window->hostSession_ = nullptr;
2198     window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
2199     EXPECT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetWindowShadowEnabled(false));
2200     EXPECT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetWindowShadowEnabled(true));
2201 
2202     window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
2203     EXPECT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetWindowShadowEnabled(false));
2204     EXPECT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetWindowShadowEnabled(true));
2205 
2206     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
2207     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2208     ASSERT_NE(nullptr, session);
2209     window->hostSession_ = session;
2210     EXPECT_EQ(WMError::WM_OK, window->SetWindowShadowEnabled(true));
2211     EXPECT_EQ(true, window->GetWindowShadowEnabled());
2212     EXPECT_EQ(WMError::WM_OK, window->SetWindowShadowEnabled(false));
2213     EXPECT_EQ(false, window->GetWindowShadowEnabled());
2214 
2215     window->windowSystemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW;
2216     window->property_->SetPcAppInpadCompatibleMode(true);
2217     EXPECT_EQ(WMError::WM_OK, window->SetWindowShadowEnabled(true));
2218 }
2219 
2220 /**
2221  * @tc.name: SetPrivacyMode01
2222  * @tc.desc: SetPrivacyMode as true
2223  * @tc.type: FUNC
2224  */
2225 HWTEST_F(WindowSceneSessionImplTest, SetPrivacyMode01, TestSize.Level1)
2226 {
2227     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2228     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2229 
2230     window->property_->SetWindowName("SetPrivacyMode");
2231     window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
2232     window->property_->SetPersistentId(1);
2233     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
2234     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2235     window->hostSession_ = session;
2236     ASSERT_EQ(WMError::WM_OK, window->SetPrivacyMode(true));
2237     ASSERT_EQ(true, window->IsPrivacyMode());
2238 }
2239 
2240 /**
2241  * @tc.name: SetPrivacyMode02
2242  * @tc.desc: SetPrivacyMode as false
2243  * @tc.type: FUNC
2244  */
2245 HWTEST_F(WindowSceneSessionImplTest, SetPrivacyMode02, TestSize.Level1)
2246 {
2247     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2248     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2249 
2250     window->property_->SetWindowName("SetPrivacyMode");
2251     window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
2252     window->property_->SetPersistentId(1);
2253     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
2254     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2255     window->hostSession_ = session;
2256     ASSERT_EQ(WMError::WM_OK, window->SetPrivacyMode(false));
2257     ASSERT_EQ(false, window->IsPrivacyMode());
2258 }
2259 
2260 /**
2261  * @tc.name: SetPrivacyMode03
2262  * @tc.desc: Window is invalid
2263  * @tc.type: FUNC
2264  */
2265 HWTEST_F(WindowSceneSessionImplTest, SetPrivacyMode03, TestSize.Level1)
2266 {
2267     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2268     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2269 
2270     window->property_->SetWindowName("SetPrivacyMode");
2271     window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
2272     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetPrivacyMode(false));
2273 }
2274 
2275 /**
2276  * @tc.name: IsPrivacyMode
2277  * @tc.desc: Set window privacy mode as true and false
2278  * @tc.type: FUNC
2279  */
2280 HWTEST_F(WindowSceneSessionImplTest, IsPrivacyModec, TestSize.Level1)
2281 {
2282     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2283     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2284 
2285     window->property_->SetWindowName("IsPrivacyModec");
2286     window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
2287     window->property_->SetPersistentId(1);
2288     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
2289     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2290     window->hostSession_ = session;
2291     window->SetPrivacyMode(true);
2292     ASSERT_EQ(true, window->IsPrivacyMode());
2293     window->SetPrivacyMode(false);
2294     ASSERT_EQ(false, window->IsPrivacyMode());
2295 }
2296 
2297 /**
2298  * @tc.name: SetSystemPrivacyMode
2299  * @tc.desc: Set Ststemwindow privacy mode as true and false
2300  * @tc.type: FUNC
2301  */
2302 HWTEST_F(WindowSceneSessionImplTest, SetSystemPrivacyMode, TestSize.Level1)
2303 {
2304     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2305     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2306 
2307     window->property_->SetWindowName("SetSystemPrivacyMode");
2308     window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
2309     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
2310     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2311     window->hostSession_ = session;
2312     window->SetSystemPrivacyMode(true);
2313     ASSERT_EQ(true, window->property_->GetSystemPrivacyMode());
2314     window->SetSystemPrivacyMode(false);
2315     ASSERT_EQ(false, window->property_->GetSystemPrivacyMode());
2316 }
2317 
2318 /**
2319  * @tc.name: SetSnapshotSkip
2320  * @tc.desc: SetSnapshotSkip test
2321  * @tc.type: FUNC
2322  */
2323 HWTEST_F(WindowSceneSessionImplTest, SetSnapshotSkip, TestSize.Level1)
2324 {
2325     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2326     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2327     window->property_->SetWindowName("SetSnapshotSkip");
2328     window->property_->SetWindowType(WindowType::ABOVE_APP_SYSTEM_WINDOW_BASE);
2329     window->property_->SetPersistentId(1);
2330     auto surfaceNode_mocker = CreateRSSurfaceNode();
2331     ASSERT_NE(nullptr, surfaceNode_mocker);
2332 
2333     window->surfaceNode_ = surfaceNode_mocker;
2334     auto surfaceNode = window->GetSurfaceNode();
2335     window->property_->SetSnapshotSkip(true);
2336     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetSnapshotSkip(false));
2337     ASSERT_EQ(true, window->property_->GetSnapshotSkip());
2338 }
2339 
2340 /**
2341  * @tc.name: SetImmersiveModeEnabledState
2342  * @tc.desc: SetImmersiveModeEnabledState test
2343  * @tc.type: FUNC
2344  */
2345 HWTEST_F(WindowSceneSessionImplTest, SetImmersiveModeEnabledState, TestSize.Level0)
2346 {
2347     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2348     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2349     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetImmersiveModeEnabledState(false));
2350 
2351     window->property_->SetPersistentId(1);
2352     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
2353     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2354     window->hostSession_ = session;
2355     window->property_->SetWindowName("SetImmersiveModeEnabledState");
2356     window->property_->SetWindowType(WindowType::WINDOW_TYPE_PIP);
2357     window->state_ = WindowState::STATE_CREATED;
2358     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetImmersiveModeEnabledState(false));
2359 
2360     window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
2361     ASSERT_EQ(WMError::WM_OK, window->SetImmersiveModeEnabledState(true));
2362     ASSERT_EQ(true, window->GetImmersiveModeEnabledState());
2363     ASSERT_EQ(WMError::WM_OK, window->SetImmersiveModeEnabledState(false));
2364     ASSERT_EQ(false, window->GetImmersiveModeEnabledState());
2365 
2366     window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
2367     ASSERT_EQ(WMError::WM_OK, window->SetLayoutFullScreen(true));
2368     ASSERT_EQ(true, window->IsLayoutFullScreen());
2369     ASSERT_EQ(WMError::WM_OK, window->SetLayoutFullScreen(false));
2370     ASSERT_EQ(false, window->IsLayoutFullScreen());
2371     ASSERT_EQ(WMError::WM_OK, window->SetImmersiveModeEnabledState(true));
2372     ASSERT_EQ(true, window->IsLayoutFullScreen());
2373     ASSERT_EQ(WMError::WM_OK, window->SetImmersiveModeEnabledState(false));
2374     ASSERT_EQ(false, window->IsLayoutFullScreen());
2375 
2376     window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
2377     ASSERT_EQ(WMError::WM_OK, window->SetImmersiveModeEnabledState(true));
2378     ASSERT_EQ(true, window->IsLayoutFullScreen());
2379     ASSERT_EQ(true, window->GetImmersiveModeEnabledState());
2380     ASSERT_EQ(WMError::WM_OK, window->MaximizeFloating());
2381     ASSERT_EQ(true, window->IsLayoutFullScreen());
2382 }
2383 
2384 /**
2385  * @tc.name: IsImmersiveLayout01
2386  * @tc.desc: IsImmersiveLayout test
2387  * @tc.type: FUNC
2388  */
2389 HWTEST_F(WindowSceneSessionImplTest, IsImmersiveLayout01, TestSize.Level0)
2390 {
2391     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2392     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2393     window->property_->SetPersistentId(1);
2394     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
2395     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2396     window->hostSession_ = session;
2397     window->isIgnoreSafeArea_ = true;
2398     window->state_ = WindowState::STATE_CREATED;
2399 
2400     bool isImmersiveLayout = false;
2401     EXPECT_EQ(WMError::WM_OK, window->IsImmersiveLayout(isImmersiveLayout));
2402 
2403     window->isIgnoreSafeArea_ = false;
2404     EXPECT_EQ(WMError::WM_OK, window->IsImmersiveLayout(isImmersiveLayout));
2405 
2406     window->state_ = WindowState::STATE_DESTROYED;
2407     EXPECT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->IsImmersiveLayout(isImmersiveLayout));
2408 }
2409 
2410 /**
2411  * @tc.name: SetLayoutFullScreen01
2412  * @tc.desc: SetLayoutFullScreen test
2413  * @tc.type: FUNC
2414  */
2415 HWTEST_F(WindowSceneSessionImplTest, SetLayoutFullScreen01, TestSize.Level0)
2416 {
2417     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2418     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2419     window->property_->SetWindowName("SetLayoutFullScreen01");
2420     window->property_->SetWindowType(WindowType::BELOW_APP_SYSTEM_WINDOW_BASE);
2421     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetLayoutFullScreen(false));
2422     window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
2423     window->property_->SetWindowMode(WindowMode::WINDOW_MODE_UNDEFINED);
2424     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetLayoutFullScreen(false));
2425     window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
2426     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetLayoutFullScreen(false));
2427     window->property_->SetPersistentId(1);
2428     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
2429     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2430     window->hostSession_ = session;
2431     WMError res = window->SetLayoutFullScreen(false);
2432     ASSERT_EQ(WMError::WM_OK, res);
2433     ASSERT_EQ(false, window->IsLayoutFullScreen());
2434     ASSERT_EQ(WMError::WM_OK, window->SetLayoutFullScreen(true));
2435     ASSERT_EQ(true, window->IsLayoutFullScreen());
2436     window->property_->SetWindowModeSupportType(0);
2437     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetLayoutFullScreen(false));
2438 }
2439 
2440 /**
2441  * @tc.name: SetTitleAndDockHoverShown
2442  * @tc.desc: SetTitleAndDockHoverShown test
2443  * @tc.type: FUNC
2444  */
2445 HWTEST_F(WindowSceneSessionImplTest, SetTitleAndDockHoverShown, TestSize.Level1)
2446 {
2447     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2448     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2449     EXPECT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetTitleAndDockHoverShown(true, true));
2450 
2451     window->property_->SetPersistentId(1);
2452     window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
2453     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
2454     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2455     window->hostSession_ = session;
2456     EXPECT_EQ(WMError::WM_ERROR_INVALID_CALLING, window->SetTitleAndDockHoverShown(true, true));
2457 
2458     window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
2459     window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
2460     EXPECT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetTitleAndDockHoverShown(true, true));
2461 
2462     window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
2463     window->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
2464     EXPECT_EQ(WMError::WM_ERROR_INVALID_CALLING, window->SetTitleAndDockHoverShown(true, true));
2465     window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
2466     EXPECT_EQ(WMError::WM_OK, window->SetTitleAndDockHoverShown(true, true));
2467 
2468     window->windowSystemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW;
2469     window->property_->SetPcAppInpadCompatibleMode(true);
2470     window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
2471     window->windowSystemConfig_.freeMultiWindowEnable_ = false;
2472     EXPECT_EQ(WMError::WM_OK, window->SetTitleAndDockHoverShown(true, true));
2473 }
2474 
2475 /**
2476  * @tc.name: NotifyCompatibleModePropertyChange
2477  * @tc.desc: NotifyCompatibleModePropertyChange
2478  * @tc.type: FUNC
2479  */
2480 HWTEST_F(WindowSceneSessionImplTest, NotifyCompatibleModePropertyChange, TestSize.Level1)
2481 {
2482     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2483     ASSERT_NE(nullptr, option);
2484     option->SetWindowName("HandleDownForCompatibleMode");
2485     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2486     ASSERT_NE(nullptr, window);
2487 
2488     window->hostSession_ = nullptr;
2489     window->property_->persistentId_ = INVALID_SESSION_ID;
2490     window->state_ = WindowState::STATE_DESTROYED;
2491 
2492     sptr<CompatibleModeProperty> compatibleModeProperty = sptr<CompatibleModeProperty>::MakeSptr();
2493     auto ret = window->NotifyCompatibleModePropertyChange(compatibleModeProperty);
2494     ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_WINDOW);
2495 
2496     SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"};
2497     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2498     window->hostSession_ = session;
2499     window->property_->persistentId_ = ROTATE_ANIMATION_DURATION;
2500     window->state_ = WindowState::STATE_CREATED;
2501     ret = window->NotifyCompatibleModePropertyChange(compatibleModeProperty);
2502     ASSERT_EQ(ret, WSError::WS_OK);
2503 }
2504 
2505 /**
2506  * @tc.name: SetLayoutFullScreen03
2507  * @tc.desc: SetLayoutFullScreen test
2508  * @tc.type: FUNC
2509  */
2510 HWTEST_F(WindowSceneSessionImplTest, SetLayoutFullScreen03, TestSize.Level1)
2511 {
2512     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2513     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2514     window->property_->SetWindowName("SetLayoutFullScreen03");
2515     window->property_->SetPersistentId(1);
2516     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
2517     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2518     window->hostSession_ = session;
2519     WMError res = window->SetLayoutFullScreen(false);
2520     window->property_->SetWindowType(WindowType::BELOW_APP_SYSTEM_WINDOW_BASE);
2521     ASSERT_EQ(WMError::WM_OK, res);
2522     ASSERT_EQ(false, window->IsLayoutFullScreen());
2523     ASSERT_EQ(WMError::WM_OK, window->SetLayoutFullScreen(true));
2524     ASSERT_EQ(true, window->IsLayoutFullScreen());
2525     window->property_->SetWindowModeSupportType(0);
2526     sptr<CompatibleModeProperty> compatibleModeProperty = sptr<CompatibleModeProperty>::MakeSptr();
2527     compatibleModeProperty->SetIsAdaptToImmersive(true);
2528     window->property_->SetCompatibleModeProperty(compatibleModeProperty);
2529     sptr<WindowSessionImpl> mainWindow = CreateWindow("mainWindow", WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, 100);
2530     mainWindow->SetFreeMultiWindowMode(true);
2531     ASSERT_EQ(WMError::WM_OK, mainWindow->SetLayoutFullScreen(true));
2532 }
2533 
2534 /**
2535  * @tc.name: SetFullScreen
2536  * @tc.desc: SetFullScreen test
2537  * @tc.type: FUNC
2538  */
2539 HWTEST_F(WindowSceneSessionImplTest, SetFullScreen, TestSize.Level0)
2540 {
2541     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2542     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2543     window->property_->SetWindowName("SetLayoutFullScreen01");
2544     window->property_->SetWindowType(WindowType::BELOW_APP_SYSTEM_WINDOW_BASE);
2545     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetFullScreen(false));
2546 
2547     window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
2548     window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
2549     window->property_->SetWindowModeSupportType(0);
2550     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetFullScreen(false));
2551 
2552     window->property_->SetWindowModeSupportType(1);
2553     window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
2554     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetFullScreen(false));
2555 
2556     window->property_->SetPersistentId(1);
2557     window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
2558     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetFullScreen(false));
2559     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
2560     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2561     window->state_ = WindowState::STATE_SHOWN;
2562     window->hostSession_ = session;
2563     ASSERT_EQ(WMError::WM_OK, window->SetFullScreen(false));
2564     ASSERT_EQ(false, window->IsLayoutFullScreen());
2565     ASSERT_EQ(WMError::WM_OK, window->SetFullScreen(true));
2566     ASSERT_EQ(true, window->IsLayoutFullScreen());
2567 }
2568 
2569 /**
2570  * @tc.name: SetGestureBackEnabled
2571  * @tc.desc: SetGestureBackEnabled test
2572  * @tc.type: FUNC
2573  */
2574 HWTEST_F(WindowSceneSessionImplTest, SetGestureBackEnabled, TestSize.Level1)
2575 {
2576     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2577     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2578     window->property_->SetPersistentId(1);
2579     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
2580     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2581     window->hostSession_ = session;
2582     window->property_->SetWindowName("SetGestureBackEnabled");
2583     window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
2584     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetGestureBackEnabled(false));
2585     window->property_->SetWindowType(WindowType::WINDOW_TYPE_PIP);
2586     window->state_ = WindowState::STATE_CREATED;
2587     window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
2588     ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, window->SetGestureBackEnabled(false));
2589     window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
2590     window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
2591     ASSERT_EQ(WMError::WM_OK, window->SetGestureBackEnabled(false));
2592     bool enable;
2593     ASSERT_EQ(WMError::WM_OK, window->GetGestureBackEnabled(enable));
2594     ASSERT_EQ(false, enable);
2595     ASSERT_EQ(WMError::WM_OK, window->SetGestureBackEnabled(true));
2596     ASSERT_EQ(WMError::WM_OK, window->GetGestureBackEnabled(enable));
2597     ASSERT_EQ(true, enable);
2598 }
2599 
2600 /**
2601  * @tc.name: PcAppInPadNormalClose
2602  * @tc.desc: PcAppInPadNormalClose test
2603  * @tc.type: FUNC
2604  */
2605 HWTEST_F(WindowSceneSessionImplTest, PcAppInPadNormalClose, TestSize.Level1)
2606 {
2607     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2608     option->SetWindowName("PcAppInPadNormalClose");
2609     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2610     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
2611     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2612     ASSERT_EQ(WSError::WS_ERROR_INVALID_WINDOW, window->PcAppInPadNormalClose());
2613 
2614     window->hostSession_ = session;
2615     window->property_->SetPersistentId(1);
2616     ASSERT_EQ(WSError::WS_ERROR_INVALID_WINDOW, window->PcAppInPadNormalClose());
2617 
2618     window->property_->SetIsPcAppInPad(true);
2619     ASSERT_EQ(WSError::WS_OK, window->PcAppInPadNormalClose());
2620 }
2621 
2622 /**
2623  * @tc.name: SetPropertySessionInfo01
2624  * @tc.desc: SetPropertySessionInfo test
2625  * @tc.type: FUNC
2626  */
2627 HWTEST_F(WindowSceneSessionImplTest, SetPropertySessionInfo01, TestSize.Level1)
2628 {
2629     const std::string bundleName = "setPropertSessionInfoTest";
2630     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2631     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2632     windowSceneSession->property_->sessionInfo_.bundleName_ = bundleName;
2633 
2634     windowSceneSession->context_ = nullptr;
2635     windowSceneSession->CreateAndConnectSpecificSession();
2636     ASSERT_EQ(windowSceneSession->property_->sessionInfo_.bundleName_, bundleName);
2637 
2638     windowSceneSession->context_ = abilityContext_;
2639     windowSceneSession->property_->sessionInfo_.bundleName_ = bundleName;
2640     windowSceneSession->CreateAndConnectSpecificSession();
2641     ASSERT_EQ(windowSceneSession->property_->sessionInfo_.bundleName_, abilityContext_->GetBundleName());
2642 }
2643 
2644 /**
2645  * @tc.name: SetWindowDelayRaiseEnabled
2646  * @tc.desc: SetWindowDelayRaiseEnabled test
2647  * @tc.type: FUNC
2648  */
2649 HWTEST_F(WindowSceneSessionImplTest, SetWindowDelayRaiseEnabled, TestSize.Level1)
2650 {
2651     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2652     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2653     window->property_->SetPersistentId(1);
2654     SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"};
2655     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2656     window->hostSession_ = session;
2657     window->property_->SetWindowName("SetWindowDelayRaiseEnabled");
2658     window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
2659     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetWindowDelayRaiseEnabled(false));
2660     window->windowSystemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW;
2661     window->windowSystemConfig_.freeMultiWindowEnable_ = true;
2662     window->windowSystemConfig_.freeMultiWindowSupport_ = true;
2663     window->uiContent_ = std::make_unique<Ace::UIContentMocker>();
2664     ASSERT_EQ(WMError::WM_OK, window->SetWindowDelayRaiseEnabled(false));
2665     window->windowSystemConfig_.freeMultiWindowEnable_ = false;
2666     window->windowSystemConfig_.freeMultiWindowSupport_ = false;
2667     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetWindowDelayRaiseEnabled(false));
2668     window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
2669     window->property_->SetWindowType(WindowType::WINDOW_TYPE_TOAST);
2670     ASSERT_EQ(WMError::WM_ERROR_INVALID_TYPE, window->SetWindowDelayRaiseEnabled(false));
2671     window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
2672     ASSERT_EQ(WMError::WM_OK, window->SetWindowDelayRaiseEnabled(false));
2673     ASSERT_EQ(false, window->IsWindowDelayRaiseEnabled());
2674     ASSERT_EQ(WMError::WM_OK, window->SetWindowDelayRaiseEnabled(true));
2675     ASSERT_EQ(true, window->IsWindowDelayRaiseEnabled());
2676 }
2677 
2678 /**
2679  * @tc.name: SetFollowParentMultiScreenPolicy
2680  * @tc.desc: SetFollowParentMultiScreenPolicy test
2681  * @tc.type: FUNC
2682  */
2683 HWTEST_F(WindowSceneSessionImplTest, SetFollowParentMultiScreenPolicy, Function | SmallTest | Level2)
2684 {
2685     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2686     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2687     SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"};
2688     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2689     window->hostSession_ = session;
2690     window->property_->SetWindowName("SetFollowParentMultiScreenPolicy");
2691     window->property_->SetPersistentId(0);
2692     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetFollowParentMultiScreenPolicy(true));
2693     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetFollowParentMultiScreenPolicy(false));
2694     window->property_->SetPersistentId(1);
2695     window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
2696     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetFollowParentMultiScreenPolicy(true));
2697     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetFollowParentMultiScreenPolicy(false));
2698     window->windowSystemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW;
2699     window->windowSystemConfig_.freeMultiWindowEnable_ = false;
2700     window->windowSystemConfig_.freeMultiWindowSupport_ = false;
2701     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetFollowParentMultiScreenPolicy(true));
2702     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetFollowParentMultiScreenPolicy(false));
2703     window->windowSystemConfig_.freeMultiWindowEnable_ = true;
2704     window->windowSystemConfig_.freeMultiWindowSupport_ = true;
2705     window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
2706     ASSERT_EQ(WMError::WM_ERROR_INVALID_CALLING, window->SetFollowParentMultiScreenPolicy(true));
2707     ASSERT_EQ(WMError::WM_ERROR_INVALID_CALLING, window->SetFollowParentMultiScreenPolicy(false));
2708     window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
2709     ASSERT_EQ(WMError::WM_OK, window->SetFollowParentMultiScreenPolicy(true));
2710     ASSERT_EQ(WMError::WM_OK, window->SetFollowParentMultiScreenPolicy(false));
2711     window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
2712     ASSERT_EQ(WMError::WM_OK, window->SetFollowParentMultiScreenPolicy(true));
2713     ASSERT_EQ(WMError::WM_OK, window->SetFollowParentMultiScreenPolicy(false));
2714 
2715     window->windowSystemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW;
2716     window->property_->SetPcAppInpadCompatibleMode(true);
2717     window->windowSystemConfig_.freeMultiWindowEnable_ = false;
2718     EXPECT_EQ(WMError::WM_OK, window->SetFollowParentMultiScreenPolicy(false));
2719 }
2720 
2721 /**
2722  * @tc.name: CloseSpecificScene
2723  * @tc.desc: CloseSpecificScene test
2724  * @tc.type: FUNC
2725  */
2726 HWTEST_F(WindowSceneSessionImplTest, CloseSpecificScene, TestSize.Level1)
2727 {
2728     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2729     option->SetWindowName("Close01");
2730     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2731     windowSceneSession->property_->SetPersistentId(1);
2732     windowSceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
2733     windowSceneSession->property_->SetDecorEnable(false);
2734     EXPECT_EQ(WSError::WS_ERROR_INVALID_OPERATION, windowSceneSession->CloseSpecificScene());
2735     windowSceneSession->property_->SetDecorEnable(true);
2736     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
2737     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2738     windowSceneSession->hostSession_ = session;
2739     sptr<IWindowWillCloseListener> listener = sptr<IWindowWillCloseListener>::MakeSptr();
2740     windowSceneSession->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
2741     auto res = windowSceneSession->RegisterWindowWillCloseListeners(listener);
2742     EXPECT_EQ(WMError::WM_OK, res);
2743     EXPECT_EQ(WSError::WS_OK, windowSceneSession->CloseSpecificScene());
2744     res = windowSceneSession->UnRegisterWindowWillCloseListeners(listener);
2745     EXPECT_EQ(WMError::WM_OK, res);
2746     EXPECT_EQ(WSError::WS_OK, windowSceneSession->CloseSpecificScene());
2747 }
2748 
2749 /**
2750  * @tc.name: SetSubWindowSource
2751  * @tc.desc: SetSubWindowSource test 1
2752  * @tc.type: FUNC
2753  */
2754 HWTEST_F(WindowSceneSessionImplTest, SetSubWindowSource01, TestSize.Level1)
2755 {
2756     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2757     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2758     window->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
2759     window->property_->SetPersistentId(1);
2760     SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"};
2761     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2762     window->hostSession_ = session;
2763     window->property_->SetWindowName("SetSubWindowSource");
2764     auto res = window->SetSubWindowSource(SubWindowSource::SUB_WINDOW_SOURCE_ARKUI);
2765     EXPECT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
2766     window->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
2767     res = window->SetSubWindowSource(SubWindowSource::SUB_WINDOW_SOURCE_ARKUI);
2768     EXPECT_EQ(WMError::WM_OK, res);
2769 }
2770 
2771 /**
2772  * @tc.name: SetSubWindowSource
2773  * @tc.desc: SetSubWindowSource test 2
2774  * @tc.type: FUNC
2775  */
2776 HWTEST_F(WindowSceneSessionImplTest, SetSubWindowSource02, TestSize.Level1)
2777 {
2778     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2779     sptr<WindowSceneSessionImpl> window = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2780     window->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
2781     window->property_->SetPersistentId(0);
2782     window->hostSession_ = nullptr;
2783     auto res = window->SetSubWindowSource(SubWindowSource::SUB_WINDOW_SOURCE_ARKUI);
2784     EXPECT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW);
2785 }
2786 
2787 /**
2788  * @tc.name: GetAndVerifyWindowTypeForArkUI01
2789  * @tc.desc: GetAndVerifyWindowTypeForArkUI01 test
2790  * @tc.type: FUNC
2791  */
2792 HWTEST_F(WindowSceneSessionImplTest, GetAndVerifyWindowTypeForArkUI01, TestSize.Level1)
2793 {
2794     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2795     option->SetWindowName("GetAndVerifyWindowTypeForArkUI");
2796     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2797 
2798     windowSceneSession->SetWindowType(WindowType::WINDOW_TYPE_SCENE_BOARD);
2799     windowSceneSession->property_->SetPersistentId(100);
2800     windowSceneSession->property_->SetParentPersistentId(99);
2801     windowSceneSession->property_->SetParentId(99);
2802     windowSceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
2803     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
2804     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2805     EXPECT_EQ(WMError::WM_OK, windowSceneSession->Create(abilityContext_, session));
2806 
2807     auto parentWindow = WindowSceneSessionImpl::GetWindowWithId(100);
2808     EXPECT_EQ(parentWindow != nullptr, true);
2809 
2810     std::string windowName ="GetAndVerifyWindowTypeForArkUIWindowName";
2811     WindowType windowType;
2812     WindowType parentWindowType = WindowType::WINDOW_TYPE_SCENE_BOARD;
2813     windowSceneSession->SetWindowType(WindowType::WINDOW_TYPE_SCENE_BOARD);
2814     auto ret = WindowSceneSessionImpl::GetAndVerifyWindowTypeForArkUI(100, "GetAndVerifyWindowTypeForArkUI",
2815         parentWindowType, windowType);
2816     EXPECT_EQ(WMError::WM_ERROR_REPEAT_OPERATION, ret);
2817 
2818     windowSceneSession->SetWindowType(WindowType::WINDOW_TYPE_SCENE_BOARD);
2819     ret = WindowSceneSessionImpl::GetAndVerifyWindowTypeForArkUI(100, windowName, parentWindowType, windowType);
2820     EXPECT_EQ(WMError::WM_OK, ret);
2821     EXPECT_EQ(windowType == WindowType::WINDOW_TYPE_SYSTEM_FLOAT, true);
2822 
2823     parentWindowType = WindowType::WINDOW_TYPE_DESKTOP;
2824     windowSceneSession->SetWindowType(WindowType::WINDOW_TYPE_DESKTOP);
2825     ret = WindowSceneSessionImpl::GetAndVerifyWindowTypeForArkUI(100, windowName, parentWindowType, windowType);
2826     EXPECT_EQ(WMError::WM_OK, ret);
2827     EXPECT_EQ(windowType == WindowType::WINDOW_TYPE_SYSTEM_FLOAT, true);
2828 
2829     parentWindowType = WindowType::WINDOW_TYPE_UI_EXTENSION;
2830     windowSceneSession->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION);
2831     ret = WindowSceneSessionImpl::GetAndVerifyWindowTypeForArkUI(100, windowName, parentWindowType, windowType);
2832     EXPECT_EQ(WMError::WM_OK, ret);
2833     EXPECT_EQ(windowType == WindowType::WINDOW_TYPE_APP_SUB_WINDOW, true);
2834 
2835     EXPECT_EQ(WMError::WM_OK, windowSceneSession->Destroy(true));
2836 }
2837 
2838 /**
2839  * @tc.name: GetAndVerifyWindowTypeForArkUI02
2840  * @tc.desc: GetAndVerifyWindowTypeForArkUI02 test
2841  * @tc.type: FUNC
2842  */
2843 HWTEST_F(WindowSceneSessionImplTest, GetAndVerifyWindowTypeForArkUI02, TestSize.Level1)
2844 {
2845     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2846     option->SetWindowName("GetAndVerifyWindowTypeForArkUI");
2847     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2848 
2849     windowSceneSession->SetWindowType(WindowType::WINDOW_TYPE_SCENE_BOARD);
2850     windowSceneSession->property_->SetPersistentId(101);
2851     windowSceneSession->property_->SetParentPersistentId(100);
2852     windowSceneSession->property_->SetParentId(100);
2853     windowSceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
2854     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
2855     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2856     EXPECT_EQ(WMError::WM_OK, windowSceneSession->Create(abilityContext_, session));
2857 
2858     auto parentWindow = WindowSceneSessionImpl::GetWindowWithId(101);
2859     EXPECT_EQ(parentWindow != nullptr, true);
2860 
2861     std::string windowName ="GetAndVerifyWindowTypeForArkUIWindowName";
2862     WindowType windowType;
2863     WindowType parentWindowType = WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW;
2864     windowSceneSession->SetWindowType(WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW);
2865     auto ret = WindowSceneSessionImpl::GetAndVerifyWindowTypeForArkUI(101, windowName, parentWindowType, windowType);
2866     EXPECT_EQ(WMError::WM_ERROR_INVALID_TYPE, ret);
2867 
2868     parentWindowType = WindowType::WINDOW_TYPE_FLOAT;
2869     windowSceneSession->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
2870     ret = WindowSceneSessionImpl::GetAndVerifyWindowTypeForArkUI(101, windowName, parentWindowType, windowType);
2871     EXPECT_EQ(WMError::WM_OK, ret);
2872     EXPECT_EQ(windowType == WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW, true);
2873 
2874     parentWindowType = WindowType::WINDOW_TYPE_APP_SUB_WINDOW;
2875     windowSceneSession->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
2876     ret = WindowSceneSessionImpl::GetAndVerifyWindowTypeForArkUI(102, windowName, parentWindowType, windowType);
2877     EXPECT_EQ(WMError::WM_ERROR_INVALID_WINDOW, ret);
2878 
2879     parentWindowType = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW;
2880     windowSceneSession->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
2881     ret = WindowSceneSessionImpl::GetAndVerifyWindowTypeForArkUI(101, windowName, parentWindowType, windowType);
2882     EXPECT_EQ(WMError::WM_OK, ret);
2883     EXPECT_EQ(windowType == WindowType::WINDOW_TYPE_APP_SUB_WINDOW, true);
2884 
2885     EXPECT_EQ(WMError::WM_OK, windowSceneSession->Destroy(true));
2886 }
2887 
2888 /**
2889  * @tc.name: GetAndVerifyWindowTypeForArkUI03
2890  * @tc.desc: GetAndVerifyWindowTypeForArkUI03 test
2891  * @tc.type: FUNC
2892  */
2893 HWTEST_F(WindowSceneSessionImplTest, GetAndVerifyWindowTypeForArkUI03, TestSize.Level1)
2894 {
2895     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2896     option->SetWindowName("GetAndVerifyWindowTypeForArkUI");
2897     sptr<WindowSceneSessionImpl> windowSceneSession = sptr<WindowSceneSessionImpl>::MakeSptr(option);
2898 
2899     windowSceneSession->SetWindowType(WindowType::WINDOW_TYPE_SCENE_BOARD);
2900     windowSceneSession->property_->SetPersistentId(101);
2901     windowSceneSession->property_->SetParentPersistentId(100);
2902     windowSceneSession->property_->SetParentId(100);
2903     windowSceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
2904     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
2905     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2906     EXPECT_EQ(WMError::WM_OK, windowSceneSession->Create(abilityContext_, session));
2907 
2908     auto parentWindow = WindowSceneSessionImpl::GetWindowWithId(101);
2909     EXPECT_EQ(parentWindow != nullptr, true);
2910 
2911     std::string windowName ="GetAndVerifyWindowTypeForArkUIWindowName";
2912     WindowType windowType;
2913     WindowType parentWindowType = WindowType::WINDOW_TYPE_APP_SUB_WINDOW;
2914 
2915     windowSceneSession->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
2916     windowSceneSession->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
2917     windowSceneSession->property_->SetSubWindowLevel(1);
2918     auto ret = WindowSceneSessionImpl::GetAndVerifyWindowTypeForArkUI(101, windowName, parentWindowType, windowType);
2919     EXPECT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ret);
2920 
2921     ret = WindowSceneSessionImpl::GetAndVerifyWindowTypeForArkUI(101, windowName,
2922         WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, windowType);
2923     EXPECT_EQ(WMError::WM_ERROR_INVALID_WINDOW, ret);
2924 
2925     windowSceneSession->windowSystemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW;
2926     ret = WindowSceneSessionImpl::GetAndVerifyWindowTypeForArkUI(101, windowName, parentWindowType, windowType);
2927     EXPECT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ret);
2928 
2929     windowSceneSession->property_->SetIsUIExtFirstSubWindow(true);
2930     ret = WindowSceneSessionImpl::GetAndVerifyWindowTypeForArkUI(101, windowName, parentWindowType, windowType);
2931     EXPECT_EQ(WMError::WM_OK, ret);
2932 
2933     windowSceneSession->property_->SetIsUIExtFirstSubWindow(false);
2934     windowSceneSession->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
2935     ret = WindowSceneSessionImpl::GetAndVerifyWindowTypeForArkUI(101, windowName, parentWindowType, windowType);
2936     EXPECT_EQ(WMError::WM_OK, ret);
2937     EXPECT_EQ(windowType, WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
2938 
2939     EXPECT_EQ(WMError::WM_OK, windowSceneSession->Destroy(true));
2940 }
2941 
2942 /**
2943  * @tc.name: VerifySubWindowLevel
2944  * @tc.desc: VerifySubWindowLevel test
2945  * @tc.type: FUNC
2946  */
2947 HWTEST_F(WindowSceneSessionImplTest, VerifySubWindowLevel, TestSize.Level1)
2948 {
2949     sptr<WindowSessionImpl> windowSceneSession = nullptr;
2950     auto ret = WindowSceneSessionImpl::VerifySubWindowLevel(false, windowSceneSession);
2951     EXPECT_EQ(WMError::WM_ERROR_NULLPTR, ret);
2952 
2953     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2954     option->SetWindowName("VerifySubWindowLevel");
2955     windowSceneSession = sptr<WindowSessionImpl>::MakeSptr(option);
2956     ret = WindowSceneSessionImpl::VerifySubWindowLevel(true, windowSceneSession);
2957     EXPECT_EQ(WMError::WM_OK, ret);
2958 
2959     windowSceneSession->property_->SetIsUIExtFirstSubWindow(true);
2960     ret = WindowSceneSessionImpl::VerifySubWindowLevel(false, windowSceneSession);
2961     EXPECT_EQ(WMError::WM_OK, ret);
2962 
2963     windowSceneSession->property_->SetIsUIExtFirstSubWindow(false);
2964     windowSceneSession->property_->SetSubWindowLevel(1);
2965     windowSceneSession->windowSystemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW;
2966     ret = WindowSceneSessionImpl::VerifySubWindowLevel(false, windowSceneSession);
2967     EXPECT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ret);
2968 
2969     windowSceneSession->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
2970     ret = WindowSceneSessionImpl::VerifySubWindowLevel(false, windowSceneSession);
2971     EXPECT_EQ(WMError::WM_OK, ret);
2972 }
2973 } // namespace
2974 } // namespace Rosen
2975 } // namespace OHOS
2976