• 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 <filesystem>
17 #include <fstream>
18 #include <gtest/gtest.h>
19 #include <int_wrapper.h>
20 #include <want_params_wrapper.h>
21 
22 #include "ability_context_impl.h"
23 #include "accessibility_event_info.h"
24 #include "color_parser.h"
25 #include "extension/extension_business_info.h"
26 #include "mock_session.h"
27 #include "mock_session_stub.h"
28 #include "mock_uicontent.h"
29 #include "mock_window.h"
30 #include "parameters.h"
31 #include "window_helper.h"
32 #include "window_session_impl.h"
33 #include "wm_common.h"
34 #include "window_manager_hilog.h"
35 
36 using namespace testing;
37 using namespace testing::ext;
38 
39 namespace OHOS {
40 namespace Rosen {
41 namespace {
42     std::string g_errLog;
MyLogCallback(const LogType type,const LogLevel level,const unsigned int domain,const char * tag,const char * msg)43     void MyLogCallback(const LogType type, const LogLevel level, const unsigned int domain, const char *tag,
44         const char *msg)
45     {
46         g_errLog = msg;
47     }
48 class WindowSessionImplTest : public testing::Test {
49 public:
50     static void SetUpTestCase();
51     static void TearDownTestCase();
52     void SetUp() override;
53     void TearDown() override;
54 
55     std::shared_ptr<AbilityRuntime::AbilityContext> abilityContext_;
56 
57 private:
58     static constexpr uint32_t WAIT_SYNC_IN_NS = 50000;
59 };
60 
SetUpTestCase()61 void WindowSessionImplTest::SetUpTestCase() {}
62 
TearDownTestCase()63 void WindowSessionImplTest::TearDownTestCase() {}
64 
SetUp()65 void WindowSessionImplTest::SetUp()
66 {
67     abilityContext_ = std::make_shared<AbilityRuntime::AbilityContextImpl>();
68 }
69 
TearDown()70 void WindowSessionImplTest::TearDown()
71 {
72     usleep(WAIT_SYNC_IN_NS);
73     abilityContext_ = nullptr;
74 }
75 
76 namespace {
77 /**
78  * @tc.name: CreateWindowAndDestroy01
79  * @tc.desc: Create window and destroy window
80  * @tc.type: FUNC
81  */
82 HWTEST_F(WindowSessionImplTest, CreateWindowAndDestroy01, TestSize.Level1)
83 {
84     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
85     option->SetWindowName("CreateWindow01");
86     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
87 
88     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
89     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
90     ASSERT_NE(nullptr, session);
91     ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
92     ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, session));
93     ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, session));
94     window->property_->SetPersistentId(1);
95     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
96     // session is null
97     window = sptr<WindowSessionImpl>::MakeSptr(option);
98     ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, nullptr));
99     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
100 
101     window = sptr<WindowSessionImpl>::MakeSptr(option);
102     ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, session));
103     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy(false));
104 }
105 
106 /**
107  * @tc.name: CreateWindowAndDestroy02
108  * @tc.desc: Create window and destroy window
109  * @tc.type: FUNC
110  */
111 HWTEST_F(WindowSessionImplTest, CreateWindowAndDestroy02, TestSize.Level1)
112 {
113     std::string identityToken = "testToken";
114     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
115     option->SetWindowName("CreateWindow01");
116     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
117 
118     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
119     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
120     ASSERT_NE(nullptr, session);
121     ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session, identityToken));
122     ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, session, identityToken));
123     ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, session, identityToken));
124     window->property_->SetPersistentId(1);
125     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
126     // session is null
127     window = sptr<WindowSessionImpl>::MakeSptr(option);
128     ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, nullptr));
129     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
130 
131     window = sptr<WindowSessionImpl>::MakeSptr(option);
132     ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, session, identityToken));
133     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy(false));
134 }
135 
136 /**
137  * @tc.name: Connect01
138  * @tc.desc: Connect session
139  * @tc.type: FUNC
140  */
141 HWTEST_F(WindowSessionImplTest, Connect01, TestSize.Level1)
142 {
143     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
144     option->SetWindowName("Connect01");
145     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
146     window->property_->SetPersistentId(1);
147     // connect with null session
148     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->Connect());
149 
150     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
151     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
152     ASSERT_NE(nullptr, session);
153     window->hostSession_ = session;
154     EXPECT_CALL(*(session), Connect(_, _, _, _, _, _, _)).WillOnce(Return(WSError::WS_ERROR_NULLPTR));
155     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->Connect());
156     EXPECT_CALL(*(session), Connect(_, _, _, _, _, _, _)).WillOnce(Return(WSError::WS_OK));
157     ASSERT_EQ(WMError::WM_OK, window->Connect());
158     ASSERT_EQ(WMError::WM_OK, window->Destroy());
159 }
160 
161 
162 /**
163  * @tc.name: Connect_RegisterWindowScaleCallback
164  * @tc.desc: Connect test RegisterWindowScaleCallback
165  * @tc.type: FUNC
166  */
167 HWTEST_F(WindowSessionImplTest, Connect_RegisterWindowScaleCallback, TestSize.Level1)
168 {
169     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
170     option->SetWindowName("Connect_RegisterWindowScaleCallback");
171     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
172     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
173     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
174     window->hostSession_ = session;
175     window->property_->SetPersistentId(1);
176     EXPECT_CALL(*(session), Connect(_, _, _, _, _, _, _)).WillRepeatedly(Return(WSError::WS_OK));
177     window->property_->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION);
178     EXPECT_EQ(WMError::WM_OK, window->Connect());
179     window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
180     sptr<CompatibleModeProperty> compatibleModeProperty = sptr<CompatibleModeProperty>::MakeSptr();
181     compatibleModeProperty->SetIsAdaptToSimulationScale(true);
182     window->property_->SetCompatibleModeProperty(compatibleModeProperty);
183     EXPECT_EQ(WMError::WM_OK, window->Connect());
184     EXPECT_EQ(WMError::WM_OK, window->Destroy());
185 }
186 
187 /**
188  * @tc.name: Show01
189  * @tc.desc: Show session
190  * @tc.type: FUNC
191  */
192 HWTEST_F(WindowSessionImplTest, Show01, TestSize.Level1)
193 {
194     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
195     option->SetWindowName("Show01");
196     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
197     ASSERT_NE(nullptr, window);
198     window->property_->SetPersistentId(1);
199     // show with null session
200     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Show());
201 
202     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
203     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
204     ASSERT_NE(nullptr, session);
205     window->hostSession_ = session;
206     EXPECT_CALL(*(session), Foreground(_, _, _)).WillOnce(Return(WSError::WS_OK));
207     ASSERT_EQ(WMError::WM_OK, window->Show());
208     ASSERT_EQ(WMError::WM_OK, window->Show());
209     window->state_ = WindowState::STATE_CREATED;
210     EXPECT_CALL(*(session), Foreground(_, _, _)).WillOnce(Return(WSError::WS_ERROR_INVALID_SESSION));
211     ASSERT_EQ(WMError::WM_ERROR_INVALID_SESSION, window->Show());
212     ASSERT_EQ(WMError::WM_OK, window->Destroy());
213 }
214 
215 /**
216  * @tc.name: Hide01
217  * @tc.desc: Hide session
218  * @tc.type: FUNC
219  */
220 HWTEST_F(WindowSessionImplTest, Hide01, TestSize.Level1)
221 {
222     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
223     option->SetWindowName("Hide01");
224     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
225     ASSERT_NE(nullptr, window);
226     window->property_->SetPersistentId(1);
227     // show with null session
228     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Hide());
229 
230     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
231     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
232     ASSERT_NE(nullptr, session);
233     window->hostSession_ = session;
234     ASSERT_EQ(WMError::WM_OK, window->Hide());
235     ASSERT_EQ(WMError::WM_OK, window->Hide());
236     window->state_ = WindowState::STATE_CREATED;
237     ASSERT_EQ(WMError::WM_OK, window->Hide());
238     window->state_ = WindowState::STATE_SHOWN;
239     window->property_->type_ = WindowType::WINDOW_TYPE_FLOAT;
240     ASSERT_EQ(WMError::WM_OK, window->Hide());
241     window->property_->type_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW;
242     ASSERT_EQ(WMError::WM_OK, window->Destroy());
243 }
244 
245 /**
246  * @tc.name: SetWindowType01
247  * @tc.desc: SetWindowType
248  * @tc.type: FUNC
249  */
250 HWTEST_F(WindowSessionImplTest, SetWindowType01, TestSize.Level1)
251 {
252     GTEST_LOG_(INFO) << "WindowSessionImplTest: SetWindowType01 start";
253     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
254     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
255     ASSERT_NE(window->property_, nullptr);
256 
257     window->property_->SetPersistentId(1);
258     option->SetWindowName("SetWindowType01");
259     WindowType type = WindowType::WINDOW_TYPE_BOOT_ANIMATION;
260     option->SetWindowType(type);
261     window = sptr<WindowSessionImpl>::MakeSptr(option);
262     ASSERT_NE(window, nullptr);
263 
264     WindowType type1 = WindowType::WINDOW_TYPE_POINTER;
265     option->SetWindowType(type1);
266     window = sptr<WindowSessionImpl>::MakeSptr(option);
267     ASSERT_NE(window, nullptr);
268 
269     WindowType type2 = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW;
270     option->SetWindowType(type2);
271     window = sptr<WindowSessionImpl>::MakeSptr(option);
272     ASSERT_NE(window, nullptr);
273 
274     WindowType type3 = WindowType::APP_MAIN_WINDOW_END;
275     option->SetWindowType(type3);
276     window = sptr<WindowSessionImpl>::MakeSptr(option);
277     ASSERT_NE(window, nullptr);
278 
279     GTEST_LOG_(INFO) << "WindowSessionImplTest: SetWindowType01 end";
280 }
281 
282 /**
283  * @tc.name: ColorSpace
284  * @tc.desc: SetColorSpace and GetColorSpace
285  * @tc.type: FUNC
286  */
287 HWTEST_F(WindowSessionImplTest, ColorSpace, TestSize.Level1)
288 {
289     GTEST_LOG_(INFO) << "WindowSessionImplTest: ColorSpace start";
290     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
291     option->SetWindowName("ColorSpace");
292     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
293     ASSERT_NE(window, nullptr);
294     ASSERT_NE(window->property_, nullptr);
295     window->property_->SetPersistentId(1);
296 
297     window->SetColorSpace(ColorSpace::COLOR_SPACE_DEFAULT);
298     ColorSpace colorSpace = window->GetColorSpace();
299     ASSERT_EQ(colorSpace, ColorSpace::COLOR_SPACE_DEFAULT);
300 
301     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
302     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
303     ASSERT_NE(session, nullptr);
304     window->hostSession_ = session;
305     window->state_ = WindowState::STATE_CREATED;
306     ASSERT_FALSE(window->IsWindowSessionInvalid());
307     window->surfaceNode_ = nullptr;
308     window->SetColorSpace(ColorSpace::COLOR_SPACE_WIDE_GAMUT);
309     ColorSpace colorSpace1 = window->GetColorSpace();
310     ASSERT_EQ(colorSpace1, ColorSpace::COLOR_SPACE_DEFAULT);
311 
312     struct RSSurfaceNodeConfig config;
313     window->surfaceNode_ = RSSurfaceNode::Create(config);
314     window->SetColorSpace(ColorSpace::COLOR_SPACE_WIDE_GAMUT);
315     ColorSpace colorSpace2 = window->GetColorSpace();
316     ASSERT_EQ(colorSpace2, ColorSpace::COLOR_SPACE_WIDE_GAMUT);
317     GTEST_LOG_(INFO) << "WindowSessionImplTest: ColorSpace end";
318 }
319 
320 /**
321  * @tc.name: MakeSubOrDialogWindowDragableAndMoveble02
322  * @tc.desc: MakeSubOrDialogWindowDragableAndMoveble
323  * @tc.type: FUNC
324  */
325 HWTEST_F(WindowSessionImplTest, MakeSubOrDialogWindowDragableAndMoveble02, TestSize.Level1)
326 {
327     GTEST_LOG_(INFO) << "WindowSessionImplTest: MakeSubOrDialogWindowDragableAndMoveble02 start";
328     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
329     option->SetDialogDecorEnable(true);
330     option->SetWindowName("MakeSubOrDialogWindowDragableAndMoveble02");
331     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
332     ASSERT_NE(nullptr, window);
333     window->property_->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
334     window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
335     window->MakeSubOrDialogWindowDragableAndMoveble();
336     ASSERT_EQ(true, window->property_->IsDecorEnable());
337     GTEST_LOG_(INFO) << "WindowSessionImplTest: MakeSubOrDialogWindowDragableAndMoveble02 end";
338 }
339 
340 /**
341  * @tc.name: MakeSubOrDialogWindowDragableAndMoveble03
342  * @tc.desc: MakeSubOrDialogWindowDragableAndMoveble
343  * @tc.type: FUNC
344  */
345 HWTEST_F(WindowSessionImplTest, MakeSubOrDialogWindowDragableAndMoveble03, TestSize.Level1)
346 {
347     GTEST_LOG_(INFO) << "WindowSessionImplTest: MakeSubOrDialogWindowDragableAndMoveble03 start";
348     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
349     option->SetDialogDecorEnable(true);
350     option->SetWindowName("MakeSubOrDialogWindowDragableAndMoveble03");
351     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
352     ASSERT_NE(nullptr, window);
353     window->property_->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
354     window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
355     window->MakeSubOrDialogWindowDragableAndMoveble();
356     ASSERT_EQ(false, window->property_->IsDecorEnable());
357     GTEST_LOG_(INFO) << "WindowSessionImplTest: MakeSubOrDialogWindowDragableAndMoveble03 end";
358 }
359 
360 /**
361  * @tc.name: MakeSubOrDialogWindowDragableAndMoveble
362  * @tc.desc: MakeSubOrDialogWindowDragableAndMoveble04
363  * @tc.type: FUNC
364  */
365 HWTEST_F(WindowSessionImplTest, MakeSubOrDialogWindowDragableAndMoveble04, TestSize.Level1)
366 {
367     GTEST_LOG_(INFO) << "WindowSessionImplTest: MakeSubOrDialogWindowDragableAndMoveble04 start";
368     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
369     ASSERT_NE(nullptr, option);
370     option->SetSubWindowDecorEnable(true);
371     option->SetWindowName("MakeSubOrDialogWindowDragableAndMoveble04");
372     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
373     ASSERT_NE(nullptr, window);
374     window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
375     window->windowSystemConfig_.freeMultiWindowSupport_ = true;
376     window->windowSystemConfig_.freeMultiWindowEnable_ = true;
377     window->MakeSubOrDialogWindowDragableAndMoveble();
378     ASSERT_TRUE(window->property_->IsDecorEnable());
379     GTEST_LOG_(INFO) << "WindowSessionImplTest: MakeSubOrDialogWindowDragableAndMoveble04 end";
380 }
381 
382 /**
383  * @tc.name: MakeSubOrDialogWindowDragableAndMoveble05
384  * @tc.desc: MakeSubOrDialogWindowDragableAndMoveble
385  * @tc.type: FUNC
386  */
387 HWTEST_F(WindowSessionImplTest, MakeSubOrDialogWindowDragableAndMoveble05, TestSize.Level1)
388 {
389     GTEST_LOG_(INFO) << "WindowSessionImplTest: MakeSubOrDialogWindowDragableAndMoveble05 start";
390     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
391     option->SetSubWindowDecorEnable(true);
392     option->SetWindowName("MakeSubOrDialogWindowDragableAndMoveble05");
393     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
394     window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
395     window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
396     EXPECT_EQ(false, window->property_->IsDecorEnable());
397     window->MakeSubOrDialogWindowDragableAndMoveble();
398     EXPECT_EQ(true, window->property_->IsDecorEnable());
399     window->property_->SetDecorEnable(false);
400     sptr<WindowOption> option1 = sptr<WindowOption>::MakeSptr();
401     option->SetWindowName("MakeSubOrDialogWindowDragableAndMoveble05_mainWindow");
402     sptr<WindowSessionImpl> mainWindow = sptr<WindowSessionImpl>::MakeSptr(option1);
403     mainWindow->property_->SetPersistentId(1);
404     mainWindow->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
405     WindowSessionImpl::windowSessionMap_.clear();
406     WindowSessionImpl::windowSessionMap_.insert(std::make_pair(mainWindow->GetWindowName(),
407         std::pair<uint64_t, sptr<WindowSessionImpl>>(mainWindow->GetWindowId(), mainWindow)));
408     window->MakeSubOrDialogWindowDragableAndMoveble();
409     EXPECT_EQ(true, window->property_->IsDecorEnable());
410     sptr<CompatibleModeProperty> compatibleModeProperty = sptr<CompatibleModeProperty>::MakeSptr();
411     compatibleModeProperty->SetIsAdaptToSubWindow(true);
412     mainWindow->context_ = std::make_shared<AbilityRuntime::AbilityContextImpl>();
413     window->context_ = mainWindow->context_;
414     window->property_->SetDecorEnable(false);
415     window->MakeSubOrDialogWindowDragableAndMoveble();
416     EXPECT_EQ(false, window->property_->IsDecorEnable());
417     GTEST_LOG_(INFO) << "WindowSessionImplTest: MakeSubOrDialogWindowDragableAndMoveble05 end";
418 }
419 
420 /**
421  * @tc.name: WindowSessionCreateCheck01
422  * @tc.desc: WindowSessionCreateCheck01
423  * @tc.type: FUNC
424  */
425 HWTEST_F(WindowSessionImplTest, WindowSessionCreateCheck01, TestSize.Level1)
426 {
427     GTEST_LOG_(INFO) << "WindowSessionImplTest: WindowSessionCreateCheck01 start";
428     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
429     option->SetWindowName("WindowSessionCreateCheck");
430     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
431     ASSERT_NE(nullptr, window);
432 
433     sptr<WindowOption> option1 = sptr<WindowOption>::MakeSptr();
434     option1->SetWindowName("WindowSessionCreateCheck"); // set the same name
435     sptr<WindowSessionImpl> window1 = new (std::nothrow) WindowSessionImpl(option1);
436     ASSERT_NE(nullptr, window1);
437 
438     WMError res = window1->WindowSessionCreateCheck();
439     ASSERT_EQ(res, WMError::WM_OK);
440     GTEST_LOG_(INFO) << "WindowSessionImplTest: WindowSessionCreateCheck01 end";
441 }
442 
443 /**
444  * @tc.name: WindowSessionCreateCheck
445  * @tc.desc: WindowSessionCreateCheck03
446  * @tc.type: FUNC
447  */
448 HWTEST_F(WindowSessionImplTest, WindowSessionCreateCheck03, TestSize.Level1)
449 {
450     GTEST_LOG_(INFO) << "WindowSessionImplTest: WindowSessionCreateCheck03 start";
451     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
452     std::string name = "WindowSessionCreateCheck03";
453     option->SetWindowName(name);
454     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
455     ASSERT_NE(window, nullptr);
456     window->windowSessionMap_[name] = std::pair<int32_t, sptr<WindowSessionImpl>>(1, window);
457     WMError res = window->WindowSessionCreateCheck();
458     ASSERT_EQ(res, WMError::WM_ERROR_REPEAT_OPERATION);
459     GTEST_LOG_(INFO) << "WindowSessionImplTest: WindowSessionCreateCheck03 end";
460 }
461 
462 /**
463  * @tc.name: SetActive
464  * @tc.desc: SetActive
465  * @tc.type: FUNC
466  */
467 HWTEST_F(WindowSessionImplTest, SetActive, TestSize.Level1)
468 {
469     GTEST_LOG_(INFO) << "WindowSessionImplTest: SetActive start";
470     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
471     option->SetWindowName("WindowSessionCreateCheck");
472     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
473     ASSERT_NE(window, nullptr);
474 
475     WSError res1 = window->SetActive(true);
476     ASSERT_EQ(res1, WSError::WS_OK);
477     res1 = window->SetActive(false);
478     ASSERT_EQ(res1, WSError::WS_OK);
479 
480     GTEST_LOG_(INFO) << "WindowSessionImplTest: SetActive end";
481 }
482 
483 /**
484  * @tc.name: UpdateFocus
485  * @tc.desc: UpdateFocus
486  * @tc.type: FUNC
487  */
488 HWTEST_F(WindowSessionImplTest, UpdateFocus, TestSize.Level1)
489 {
490     GTEST_LOG_(INFO) << "WindowSessionImplTest: UpdateFocus start";
491     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
492     option->SetWindowName("WindowSessionCreateCheck");
493     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
494     ASSERT_NE(window, nullptr);
495 
496     WSError res = window->UpdateFocus(true);
497     ASSERT_EQ(res, WSError::WS_OK);
498     res = window->UpdateFocus(false);
499     ASSERT_EQ(res, WSError::WS_OK);
500 
501     GTEST_LOG_(INFO) << "WindowSessionImplTest: UpdateFocus end";
502 }
503 
504 /**
505  * @tc.name: RequestFocusByClient
506  * @tc.desc: RequestFocusByClient Test
507  * @tc.type: FUNC
508  */
509 HWTEST_F(WindowSessionImplTest, RequestFocusByClient, TestSize.Level1)
510 {
511     GTEST_LOG_(INFO) << "WindowSessionImplTest: RequestFocusByClient start";
512     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
513     option->SetWindowName("WindowRequestFocusByClientCheck");
514     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
515     ASSERT_NE(window, nullptr);
516 
517     WMError res = window->RequestFocusByClient(true);
518     ASSERT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW);
519     res = window->RequestFocusByClient(false);
520     ASSERT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW);
521 
522     window->property_->SetPersistentId(1);
523     SessionInfo sessionInfo = { "RequestFocusByClient", "RequestFocusByClient", "RequestFocusByClient" };
524     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
525     ASSERT_NE(session, nullptr);
526     window->hostSession_ = session;
527     window->state_ = WindowState::STATE_INITIAL;
528     res = window->RequestFocusByClient(true);
529     ASSERT_EQ(res, WMError::WM_OK);
530     res = window->RequestFocusByClient(false);
531     ASSERT_EQ(res, WMError::WM_OK);
532 
533     GTEST_LOG_(INFO) << "WindowSessionImplTest: RequestFocusByClient end";
534 }
535 
536 /**
537  * @tc.name: CreateWindowAndDestroy01
538  * @tc.desc: GetPersistentId
539  * @tc.type: FUNC
540  */
541 HWTEST_F(WindowSessionImplTest, GetPersistentId01, TestSize.Level1)
542 {
543     GTEST_LOG_(INFO) << "WindowSessionImplTest: GetPersistentId start";
544     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
545     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
546     ASSERT_NE(window->property_, nullptr);
547 
548     window->property_->SetPersistentId(1);
549     const int32_t res2 = window->GetPersistentId();
550     ASSERT_EQ(res2, 1);
551     GTEST_LOG_(INFO) << "WindowSessionImplTest: GetPersistentId end";
552 }
553 
554 /**
555  * @tc.name: GetFloatingWindowParentId
556  * @tc.desc: GetFloatingWindowParentId and UpdateTitleButtonVisibility
557  * @tc.type: FUNC
558  */
559 HWTEST_F(WindowSessionImplTest, GetFloatingWindowParentId, TestSize.Level1)
560 {
561     GTEST_LOG_(INFO) << "WindowSessionImplTest: GetFloatingWindowParentId start";
562     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
563     option->SetWindowName("Connect");
564     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
565     ASSERT_NE(nullptr, window);
566     window->property_->SetPersistentId(1);
567     // connect with null session
568     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->Connect());
569 
570     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
571     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
572     ASSERT_NE(nullptr, session);
573     window->hostSession_ = session;
574     EXPECT_CALL(*(session), Connect(_, _, _, _, _, _, _)).WillOnce(Return(WSError::WS_ERROR_NULLPTR));
575     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->Connect());
576     EXPECT_CALL(*(session), Connect(_, _, _, _, _, _, _)).WillOnce(Return(WSError::WS_OK));
577     ASSERT_EQ(WMError::WM_OK, window->Connect());
578 
579     window->UpdateTitleButtonVisibility();
580     int32_t res = window->GetFloatingWindowParentId();
581     ASSERT_EQ(res, INVALID_SESSION_ID);
582     GTEST_LOG_(INFO) << "WindowSessionImplTest: GetFloatingWindowParentId start";
583 }
584 
585 /**
586  * @tc.name: UpdateDecorEnable
587  * @tc.desc: UpdateDecorEnable
588  * @tc.type: FUNC
589  */
590 HWTEST_F(WindowSessionImplTest, UpdateDecorEnable, TestSize.Level1)
591 {
592     GTEST_LOG_(INFO) << "WindowSessionImplTest: UpdateDecorEnable start";
593     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
594     option->SetWindowName("UpdateDecorEnable");
595     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
596 
597     WindowMode mode = WindowMode::WINDOW_MODE_UNDEFINED;
598     window->UpdateDecorEnable(true, mode);
599     ASSERT_EQ(window->property_->windowMode_, mode);
600     mode = WindowMode::WINDOW_MODE_UNDEFINED;
601     window->UpdateDecorEnable(false, mode);
602     ASSERT_EQ(window->property_->windowMode_, mode);
603     mode = WindowMode::WINDOW_MODE_FULLSCREEN;
604     window->property_->compatibleModeProperty_->SetDisableDecorFullscreen(true);
605     window->UpdateDecorEnable(false, mode);
606     ASSERT_EQ(window->property_->windowMode_, mode);
607     GTEST_LOG_(INFO) << "WindowSessionImplTest: UpdateDecorEnable end";
608 }
609 
610 /**
611  * @tc.name: NotifyModeChange
612  * @tc.desc: NotifyModeChange
613  * @tc.type: FUNC
614  */
615 HWTEST_F(WindowSessionImplTest, NotifyModeChange, TestSize.Level1)
616 {
617     GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyModeChange start";
618     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
619     option->SetWindowName("NotifyModeChange");
620     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
621     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
622     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
623     window->hostSession_ = session;
624 
625     WindowMode mode = WindowMode::WINDOW_MODE_UNDEFINED;
626     window->NotifyModeChange(mode, true);
627     window->NotifyModeChange(mode, false);
628     ASSERT_EQ(window->property_->windowMode_, mode);
629     ASSERT_EQ(window->property_->isDecorEnable_, false);
630     GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyModeChange end";
631 }
632 
633 /**
634  * @tc.name: RequestVsyncSucc
635  * @tc.desc: RequestVsync Test Succ
636  * @tc.type: FUNC
637  */
638 HWTEST_F(WindowSessionImplTest, RequestVsyncSucc, TestSize.Level1)
639 {
640     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
641     option->SetWindowName("RequestVsyncSucc");
642     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
643     ASSERT_NE(window, nullptr);
644     std::shared_ptr<VsyncCallback> vsyncCallback = std::make_shared<VsyncCallback>();
645     window->state_ = WindowState::STATE_SHOWN;
646     ASSERT_EQ(WindowState::STATE_SHOWN, window->GetWindowState());
647     ASSERT_NE(window->vsyncStation_, nullptr);
648     window->RequestVsync(vsyncCallback);
649     window->vsyncStation_ = nullptr;
650     window->RequestVsync(vsyncCallback);
651 }
652 
653 /**
654  * @tc.name: RequestVsyncErr
655  * @tc.desc: RequestVsync Test Err
656  * @tc.type: FUNC
657  */
658 HWTEST_F(WindowSessionImplTest, RequestVsyncErr, TestSize.Level1)
659 {
660     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
661     option->SetWindowName("RequestVsyncErr");
662     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
663     ASSERT_NE(window, nullptr);
664     std::shared_ptr<VsyncCallback> vsyncCallback = std::make_shared<VsyncCallback>();
665     window->state_ = WindowState::STATE_DESTROYED;
666     ASSERT_EQ(WindowState::STATE_DESTROYED, window->GetWindowState());
667     window->vsyncStation_ = nullptr;
668     window->RequestVsync(vsyncCallback);
669 }
670 
671 /**
672  * @tc.name: ClearVsync
673  * @tc.desc: Clear vsync test
674  * @tc.type: FUNC
675  */
676 HWTEST_F(WindowSessionImplTest, ClearVsync, TestSize.Level1)
677 {
678     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
679     option->SetWindowName("ClearVsync");
680     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
681     ASSERT_NE(window, nullptr);
682     window->ClearVsyncStation();
683     ASSERT_NE(window, nullptr);
684 }
685 
686 /**
687  * @tc.name: SetFocusable
688  * @tc.desc: SetFocusable
689  * @tc.type: FUNC
690  */
691 HWTEST_F(WindowSessionImplTest, SetFocusable, TestSize.Level1)
692 {
693     GTEST_LOG_(INFO) << "WindowSessionImplTest: SetFocusable start";
694     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
695     option->SetWindowName("SetFocusable");
696     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
697 
698     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
699     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
700     ASSERT_NE(nullptr, session);
701     ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
702     window->hostSession_ = session;
703     window->property_->SetPersistentId(1);
704     ASSERT_FALSE(window->GetPersistentId() == INVALID_SESSION_ID);
705     ASSERT_FALSE(window->IsWindowSessionInvalid());
706     WMError res = window->SetFocusable(true);
707     ASSERT_EQ(res, WMError::WM_OK);
708     ASSERT_EQ(WMError::WM_OK, window->Destroy());
709 
710     // session is null
711     window = sptr<WindowSessionImpl>::MakeSptr(option);
712     ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, nullptr));
713     res = window->SetFocusable(true);
714     ASSERT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW);
715     res = window->SetFocusable(false);
716     ASSERT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW);
717     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
718     GTEST_LOG_(INFO) << "WindowSessionImplTest: SetFocusable end";
719 }
720 
721 /**
722  * @tc.name: SetTouchable
723  * @tc.desc: SetTouchable
724  * @tc.type: FUNC
725  */
726 HWTEST_F(WindowSessionImplTest, SetTouchable, TestSize.Level1)
727 {
728     GTEST_LOG_(INFO) << "WindowSessionImplTest: SetTouchable start";
729     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
730     option->SetWindowName("SetTouchable");
731     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
732 
733     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
734     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
735     ASSERT_NE(nullptr, session);
736     ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
737     ASSERT_NE(window->property_, nullptr);
738     window->hostSession_ = session;
739     window->property_->SetPersistentId(1);
740     ASSERT_FALSE(window->IsWindowSessionInvalid());
741     WMError res = window->SetTouchable(true);
742     ASSERT_EQ(res, WMError::WM_OK);
743     ASSERT_NE(window->property_, nullptr);
744     ASSERT_TRUE(window->property_->touchable_);
745     ASSERT_EQ(WMError::WM_OK, window->Destroy());
746 
747     // session is null
748     window = sptr<WindowSessionImpl>::MakeSptr(option);
749     ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, nullptr));
750     res = window->SetTouchable(true);
751     ASSERT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW);
752     res = window->SetTouchable(false);
753     ASSERT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW);
754     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
755     GTEST_LOG_(INFO) << "WindowSessionImplTest: SetTouchable end";
756 }
757 
758 /**
759  * @tc.name: SetBrightness01
760  * @tc.desc: SetBrightness
761  * @tc.type: FUNC
762  */
763 HWTEST_F(WindowSessionImplTest, SetBrightness01, TestSize.Level1)
764 {
765     GTEST_LOG_(INFO) << "WindowSessionImplTest: SetBrightness01 start";
766     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
767     option->SetWindowName("SetBrightness01");
768     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
769 
770     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
771     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
772     EXPECT_NE(nullptr, session);
773     EXPECT_EQ(WMError::WM_OK, window->Create(nullptr, session));
774     EXPECT_NE(nullptr, window->property_);
775     window->property_->SetPersistentId(1);
776 
777     float brightness = -0.5f; // brightness < 0
778     WMError res = window->SetBrightness(brightness);
779     EXPECT_EQ(res, WMError::WM_ERROR_INVALID_PARAM);
780     brightness = 2.0f; // brightness > 1
781     res = window->SetBrightness(brightness);
782     EXPECT_EQ(res, WMError::WM_ERROR_INVALID_PARAM);
783 
784     brightness = 0.5f;
785     window->hostSession_ = session;
786     EXPECT_FALSE(window->IsWindowSessionInvalid());
787     res = window->SetBrightness(brightness);
788     EXPECT_EQ(res, WMError::WM_OK);
789     ASSERT_EQ(WMError::WM_OK, window->Destroy());
790     GTEST_LOG_(INFO) << "WindowSessionImplTest: SetBrightness01 end";
791 }
792 
793 /**
794  * @tc.name: SetBrightness02
795  * @tc.desc: SetBrightness
796  * @tc.type: FUNC
797  */
798 HWTEST_F(WindowSessionImplTest, SetBrightness02, TestSize.Level1)
799 {
800     GTEST_LOG_(INFO) << "WindowSessionImplTest: SetBrightness02 start";
801     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
802     option->SetWindowName("SetBrightness02");
803     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
804 
805     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
806     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
807     EXPECT_NE(nullptr, session);
808     EXPECT_EQ(WMError::WM_OK, window->Create(nullptr, session));
809     window->hostSession_ = session;
810     EXPECT_NE(nullptr, window->property_);
811     window->property_->SetPersistentId(1);
812     window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
813     float brightness = 0.5f;
814     WMError res = window->SetBrightness(brightness);
815     EXPECT_EQ(res, WMError::WM_ERROR_INVALID_TYPE);
816 
817     window->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
818     res = window->SetBrightness(brightness);
819     EXPECT_EQ(res, WMError::WM_OK);
820 
821     window->property_->SetWindowType(WindowType::WINDOW_TYPE_WALLET_SWIPE_CARD);
822     res = window->SetBrightness(brightness);
823     EXPECT_EQ(res, WMError::WM_OK);
824     ASSERT_EQ(WMError::WM_OK, window->Destroy());
825     GTEST_LOG_(INFO) << "WindowSessionImplTest: SetBrightness02 end";
826 }
827 
828 /**
829  * @tc.name: GetContentInfo
830  * @tc.desc: GetContentInfo
831  * @tc.type: FUNC
832  */
833 HWTEST_F(WindowSessionImplTest, GetContentInfo, TestSize.Level1)
834 {
835     GTEST_LOG_(INFO) << "WindowSessionImplTest: GetContentInfo start";
836     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
837     option->SetWindowName("GetContentInfo");
838     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
839 
840     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
841     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
842     ASSERT_NE(nullptr, session);
843     ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
844 
845     std::string res = window->GetContentInfo();
846     ASSERT_EQ(res, "");
847     window->uiContent_ = nullptr;
848     res = window->GetContentInfo();
849     ASSERT_EQ(res, "");
850     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
851     GTEST_LOG_(INFO) << "WindowSessionImplTest: GetContentInfo end";
852 }
853 
854 /**
855  * @tc.name: OnNewWant
856  * @tc.desc: OnNewWant
857  * @tc.type: FUNC
858  */
859 HWTEST_F(WindowSessionImplTest, OnNewWant, TestSize.Level1)
860 {
861     GTEST_LOG_(INFO) << "WindowSessionImplTest: OnNewWant start";
862     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
863     option->SetWindowName("OnNewWant");
864     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
865 
866     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
867     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
868     ASSERT_NE(nullptr, session);
869     ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
870 
871     AAFwk::Want want;
872     window->uiContent_ = nullptr;
873     window->OnNewWant(want);
874     ASSERT_EQ(window->GetUIContentSharedPtr(), nullptr);
875     window->uiContent_ = std::make_unique<Ace::UIContentMocker>();
876     window->OnNewWant(want);
877     ASSERT_NE(window->GetUIContentSharedPtr(), nullptr);
878 
879     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
880     GTEST_LOG_(INFO) << "WindowSessionImplTest: OnNewWant end";
881 }
882 
883 /**
884  * @tc.name: SetAPPWindowLabel
885  * @tc.desc: SetAPPWindowLabel
886  * @tc.type: FUNC
887  */
888 HWTEST_F(WindowSessionImplTest, SetAPPWindowLabel, TestSize.Level1)
889 {
890     GTEST_LOG_(INFO) << "WindowSessionImplTest: SetAPPWindowLabel start";
891     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
892     option->SetWindowName("SetAPPWindowLabel");
893     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
894 
895     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
896     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
897     ASSERT_NE(nullptr, session);
898     ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
899 
900     std::string label = "label";
901     window->uiContent_ = nullptr;
902     WMError res = window->SetAPPWindowLabel(label);
903     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
904 
905     window->uiContent_ = std::make_unique<Ace::UIContentMocker>();
906     res = window->SetAPPWindowLabel(label);
907     ASSERT_EQ(res, WMError::WM_OK);
908     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
909     GTEST_LOG_(INFO) << "WindowSessionImplTest: SetAPPWindowLabel end";
910 }
911 
912 /**
913  * @tc.name: RegisterListener01
914  * @tc.desc: RegisterListener and UnregisterListener
915  * @tc.type: FUNC
916  */
917 HWTEST_F(WindowSessionImplTest, RegisterListener01, TestSize.Level1)
918 {
919     GTEST_LOG_(INFO) << "WindowSessionImplTest: RegisterListener01 start";
920     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
921     option->SetWindowName("RegisterListener01");
922     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
923 
924     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
925     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
926     ASSERT_NE(nullptr, session);
927     ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
928     window->hostSession_ = session;
929     ASSERT_NE(window->property_, nullptr);
930     window->property_->SetPersistentId(1);
931 
932     sptr<IWindowLifeCycle> listener = nullptr;
933     WMError res = window->RegisterLifeCycleListener(listener);
934     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
935     res = window->UnregisterLifeCycleListener(listener);
936     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
937 
938     sptr<IOccupiedAreaChangeListener> listener1 = nullptr;
939     res = window->RegisterOccupiedAreaChangeListener(listener1);
940     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
941     res = window->UnregisterOccupiedAreaChangeListener(listener1);
942     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
943 
944     sptr<IWindowChangeListener> listener2 = nullptr;
945     res = window->RegisterWindowChangeListener(listener2);
946     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
947     res = window->UnregisterWindowChangeListener(listener2);
948     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
949 
950     sptr<IDialogDeathRecipientListener> listener3 = nullptr;
951     window->RegisterDialogDeathRecipientListener(listener3);
952     window->UnregisterDialogDeathRecipientListener(listener3);
953 
954     sptr<IDialogTargetTouchListener> listener4 = nullptr;
955     res = window->RegisterDialogTargetTouchListener(listener4);
956     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
957     res = window->UnregisterDialogTargetTouchListener(listener4);
958     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
959     sptr<IWindowStatusChangeListener> listener5 = nullptr;
960     res = window->RegisterWindowStatusChangeListener(listener5);
961     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
962     res = window->UnregisterWindowStatusChangeListener(listener5);
963     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
964     sptr<IWindowCrossAxisListener> listener6 = nullptr;
965     res = window->RegisterWindowCrossAxisListener(listener6);
966     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
967     res = window->UnregisterWindowCrossAxisListener(listener6);
968     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
969     ASSERT_EQ(WMError::WM_OK, window->Destroy());
970     GTEST_LOG_(INFO) << "WindowSessionImplTest: RegisterListener01 end";
971 }
972 
973 /**
974  * @tc.name: RegisterListener02
975  * @tc.desc: RegisterListener and UnregisterListener
976  * @tc.type: FUNC
977  */
978 HWTEST_F(WindowSessionImplTest, RegisterListener02, TestSize.Level1)
979 {
980     GTEST_LOG_(INFO) << "WindowSessionImplTest: RegisterListener02 start";
981     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
982     option->SetWindowName("RegisterListener02");
983     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
984     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
985     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
986     ASSERT_NE(nullptr, session);
987     ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
988     window->hostSession_ = session;
989     ASSERT_NE(window->property_, nullptr);
990     window->property_->SetPersistentId(1);
991 
992     sptr<IScreenshotListener> listener5 = nullptr;
993     WMError res = window->RegisterScreenshotListener(listener5);
994     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
995     res = window->UnregisterScreenshotListener(listener5);
996     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
997 
998     sptr<IAvoidAreaChangedListener> listener6 = nullptr;
999     res = window->RegisterAvoidAreaChangeListener(listener6);
1000     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
1001     res = window->UnregisterAvoidAreaChangeListener(listener6);
1002     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
1003 
1004     sptr<ITouchOutsideListener> listener7 = nullptr;
1005     res = window->RegisterTouchOutsideListener(listener7);
1006     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
1007     res = window->UnregisterTouchOutsideListener(listener7);
1008     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
1009 
1010     IWindowVisibilityListenerSptr listener8 = nullptr;
1011     res = window->RegisterWindowVisibilityChangeListener(listener8);
1012     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
1013     res = window->UnregisterWindowVisibilityChangeListener(listener8);
1014     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
1015 
1016     IDisplayIdChangeListenerSptr listener9 = nullptr;
1017     res = window->RegisterDisplayIdChangeListener(listener9);
1018     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
1019     res = window->UnregisterDisplayIdChangeListener(listener9);
1020     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
1021 
1022     sptr<IWindowTitleButtonRectChangedListener> listener10 = nullptr;
1023     res = window->RegisterWindowTitleButtonRectChangeListener(listener10);
1024     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
1025     res = window->UnregisterWindowTitleButtonRectChangeListener(listener10);
1026     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
1027     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1028     GTEST_LOG_(INFO) << "WindowSessionImplTest: RegisterListener02 end";
1029 }
1030 
1031 /**
1032  * @tc.name: RegisterListener03
1033  * @tc.desc: RegisterListener and UnregisterListener
1034  * @tc.type: FUNC
1035  */
1036 HWTEST_F(WindowSessionImplTest, RegisterListener03, TestSize.Level1)
1037 {
1038     GTEST_LOG_(INFO) << "WindowSessionImplTest: RegisterListener03 start";
1039     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1040     option->SetWindowName("RegisterListener03");
1041     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1042 
1043     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1044     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1045     ASSERT_NE(nullptr, session);
1046     ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1047     window->hostSession_ = session;
1048     ASSERT_NE(window->property_, nullptr);
1049     window->property_->SetPersistentId(1);
1050 
1051     sptr<IDisplayMoveListener> listener6 = nullptr;
1052     WMError res = window->RegisterDisplayMoveListener(listener6);
1053     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
1054     res = window->UnregisterDisplayMoveListener(listener6);
1055     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
1056 
1057     sptr<IWindowRectChangeListener> listener7 = nullptr;
1058     res = window->RegisterWindowRectChangeListener(listener7);
1059     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
1060 
1061     sptr<ISubWindowCloseListener> listener10 = nullptr;
1062     res = window->RegisterSubWindowCloseListeners(listener10);
1063     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
1064     res = window->UnregisterSubWindowCloseListeners(listener10);
1065     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
1066 
1067     sptr<ISwitchFreeMultiWindowListener> listener11 = nullptr;
1068     res = window->RegisterSwitchFreeMultiWindowListener(listener11);
1069     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
1070     res = window->UnregisterSwitchFreeMultiWindowListener(listener11);
1071     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
1072 
1073     sptr<IMainWindowCloseListener> listener12 = nullptr;
1074     res = window->RegisterMainWindowCloseListeners(listener12);
1075     EXPECT_EQ(res, WMError::WM_ERROR_NULLPTR);
1076     res = window->UnregisterMainWindowCloseListeners(listener12);
1077     EXPECT_EQ(res, WMError::WM_ERROR_NULLPTR);
1078 
1079     ISystemDensityChangeListenerSptr listener13 = nullptr;
1080     res = window->RegisterSystemDensityChangeListener(listener13);
1081     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
1082     res = window->UnregisterSystemDensityChangeListener(listener13);
1083     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
1084     EXPECT_EQ(WMError::WM_OK, window->Destroy());
1085     GTEST_LOG_(INFO) << "WindowSessionImplTest: RegisterListener03 end";
1086 }
1087 
1088 /**
1089  * @tc.name: RegisterListener04
1090  * @tc.desc: RegisterListener and UnregisterListener
1091  * @tc.type: FUNC
1092  */
1093 HWTEST_F(WindowSessionImplTest, RegisterListener04, TestSize.Level1)
1094 {
1095     GTEST_LOG_(INFO) << "WindowSessionImplTest: RegisterListener04 start";
1096     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1097     option->SetWindowName("RegisterListener04");
1098     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1099 
1100     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1101     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1102     ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1103     window->hostSession_ = session;
1104     window->property_->SetPersistentId(1);
1105 
1106     sptr<IWindowWillCloseListener> listener14 = nullptr;
1107     WMError res = window->RegisterWindowWillCloseListeners(listener14);
1108     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
1109     res = window->UnRegisterWindowWillCloseListeners(listener14);
1110     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
1111 
1112     EXPECT_EQ(WMError::WM_OK, window->Destroy());
1113     GTEST_LOG_(INFO) << "WindowSessionImplTest: RegisterListener04 end";
1114 }
1115 
1116 /**
1117  * @tc.name: RegisterListener05
1118  * @tc.desc: RegisterListener and UnregisterListener
1119  * @tc.type: FUNC
1120  */
1121 HWTEST_F(WindowSessionImplTest, RegisterListener05, TestSize.Level1)
1122 {
1123     GTEST_LOG_(INFO) << "WindowSessionImplTest: RegisterListener05 start";
1124     sptr<WindowOption> listenerOption = sptr<WindowOption>::MakeSptr();
1125     ASSERT_NE(nullptr, listenerOption);
1126     listenerOption->SetWindowName("RegisterListener05");
1127     sptr<WindowSessionImpl> listenerwindow = sptr<WindowSessionImpl>::MakeSptr(listenerOption);
1128     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1129     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1130     EXPECT_EQ(WMError::WM_OK, listenerwindow->Create(nullptr, session));
1131     listenerwindow->hostSession_ = session;
1132     ASSERT_NE(nullptr, listenerwindow->property_);
1133     listenerwindow->property_->SetPersistentId(1);
1134     sptr<IWindowStageLifeCycle> listener = nullptr;
1135     WMError res = listenerwindow->RegisterWindowStageLifeCycleListener(listener);
1136     EXPECT_EQ(res, WMError::WM_ERROR_NULLPTR);
1137     res = listenerwindow->UnregisterWindowStageLifeCycleListener(listener);
1138     EXPECT_EQ(res, WMError::WM_ERROR_NULLPTR);
1139     EXPECT_EQ(WMError::WM_OK, listenerwindow->Destroy());
1140     GTEST_LOG_(INFO) << "WindowSessionImplTest: RegisterListener05 end";
1141 }
1142 
1143 /**
1144  * @tc.name: NotifyDisplayMove
1145  * @tc.desc: NotifyDisplayMove
1146  * @tc.type: FUNC
1147  */
1148 HWTEST_F(WindowSessionImplTest, NotifyDisplayMove, TestSize.Level1)
1149 {
1150     GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyDisplayMove start";
1151     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1152     option->SetWindowName("NotifyDisplayMove");
1153     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1154 
1155     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1156     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1157     ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1158 
1159     DisplayId from = 0;
1160     DisplayId to = 2;
1161     window->NotifyDisplayMove(from, to);
1162     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
1163     GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyDisplayMove end";
1164 }
1165 
1166 /**
1167  * @tc.name: NotifyAfterForeground
1168  * @tc.desc: NotifyAfterForeground
1169  * @tc.type: FUNC
1170  */
1171 HWTEST_F(WindowSessionImplTest, NotifyAfterForeground, TestSize.Level1)
1172 {
1173     GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyAfterForeground start";
1174     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1175     option->SetWindowName("NotifyAfterForeground");
1176     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1177 
1178     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1179     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1180     ASSERT_NE(nullptr, session);
1181     ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1182 
1183     window->NotifyAfterForeground(true, true);
1184     window->NotifyAfterForeground(false, false);
1185     window->vsyncStation_ = nullptr;
1186     window->NotifyAfterForeground(false, false);
1187     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
1188     GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyAfterForeground end";
1189 }
1190 
1191 /**
1192  * @tc.name: NotifyAfterBackground
1193  * @tc.desc: NotifyAfterBackground
1194  * @tc.type: FUNC
1195  */
1196 HWTEST_F(WindowSessionImplTest, NotifyAfterBackground, TestSize.Level1)
1197 {
1198     GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyAfterBackground start";
1199     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1200     option->SetWindowName("NotifyAfterBackground");
1201     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1202 
1203     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1204     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1205     ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1206 
1207     window->NotifyAfterBackground(true, true);
1208     window->NotifyAfterBackground(false, false);
1209     window->vsyncStation_ = nullptr;
1210     window->NotifyAfterBackground(false, false);
1211     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
1212     GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyAfterBackground end";
1213 }
1214 
1215 /**
1216  * @tc.name: NotifyForegroundInteractiveStatus
1217  * @tc.desc: NotifyForegroundInteractiveStatus
1218  * @tc.type: FUNC
1219  */
1220 HWTEST_F(WindowSessionImplTest, NotifyForegroundInteractiveStatus, TestSize.Level1)
1221 {
1222     g_errLog.clear();
1223     LOG_SetCallback(MyLogCallback);
1224     GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyForegroundInteractiveStatus start";
1225     sptr<WindowOption> option = new WindowOption();
1226     ASSERT_NE(option, nullptr);
1227     option->SetWindowName("NotifyForegroundInteractiveStatus");
1228     sptr<WindowSessionImpl> foreWindow = sptr<WindowSessionImpl>::MakeSptr(option);;
1229     ASSERT_NE(foreWindow, nullptr);
1230     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1231     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
1232     ASSERT_NE(session, nullptr);
1233     foreWindow->property_->SetPersistentId(1);
1234     foreWindow->hostSession_ = session;
1235     foreWindow->state_ = WindowState::STATE_SHOWN;
1236     EXPECT_FALSE(foreWindow->IsWindowSessionInvalid());
1237     foreWindow->isDidForeground_ = false;
1238     foreWindow->NotifyForegroundInteractiveStatus(true);
1239     foreWindow->NotifyForegroundInteractiveStatus(false);
1240     EXPECT_TRUE(g_errLog.find("isDidForeground:") == std::string::npos);
1241     EXPECT_EQ(WMError::WM_OK, foreWindow->Destroy());
1242     LOG_SetCallback(nullptr);
1243     GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyForegroundInteractiveStatus end";
1244 }
1245 
1246 /**
1247  * @tc.name: NotifyForegroundInteractiveStatus01
1248  * @tc.desc: NotifyForegroundInteractiveStatus01
1249  * @tc.type: FUNC
1250  */
1251 HWTEST_F(WindowSessionImplTest, NotifyForegroundInteractiveStatus01, TestSize.Level1)
1252 {
1253     g_errLog.clear();
1254     LOG_SetCallback(MyLogCallback);
1255     GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyForegroundInteractiveStatus01 start";
1256     sptr<WindowOption> option = new WindowOption();
1257     ASSERT_NE(option, nullptr);
1258     option->SetWindowName("NotifyForegroundInteractiveStatus01");
1259     sptr<WindowSessionImpl> foreWindow1 = new (std::nothrow) WindowSessionImpl(option);
1260     ASSERT_NE(foreWindow1, nullptr);
1261     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1262     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
1263     ASSERT_NE(session, nullptr);
1264     foreWindow1->property_->SetPersistentId(1);
1265     foreWindow1->hostSession_ = session;
1266     foreWindow1->state_ = WindowState::STATE_SHOWN;
1267     EXPECT_FALSE(foreWindow1->IsWindowSessionInvalid());
1268     foreWindow1->isDidForeground_ = true;
1269     foreWindow1->NotifyForegroundInteractiveStatus(true);
1270     EXPECT_TRUE(g_errLog.find("isDidForeground:") == std::string::npos);
1271 
1272     ASSERT_NE(nullptr, foreWindow1->property_);
1273     foreWindow1->property_->SetPersistentId(1);
1274     foreWindow1->property_->SetUseControlState(true);
1275     foreWindow1->NotifyForegroundInteractiveStatus(false);
1276     foreWindow1->NotifyForegroundInteractiveStatus(true);
1277     EXPECT_TRUE(g_errLog.find("useControlState:") != std::string::npos);
1278     foreWindow1->property_->SetUseControlState(false);
1279     foreWindow1->NotifyForegroundInteractiveStatus(false);
1280     foreWindow1->NotifyForegroundInteractiveStatus(true);
1281     EXPECT_EQ(WMError::WM_OK, foreWindow1->Destroy());
1282     LOG_SetCallback(nullptr);
1283     GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyForegroundInteractiveStatus01 end";
1284 }
1285 
1286 /**
1287  * @tc.name: NotifyLifecyclePausedStatus
1288  * @tc.desc: NotifyLifecyclePausedStatus
1289  * @tc.type: FUNC
1290  */
1291 HWTEST_F(WindowSessionImplTest, NotifyLifecyclePausedStatus, TestSize.Level1)
1292 {
1293     g_errLog.clear();
1294     LOG_SetCallback(MyLogCallback);
1295     GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyLifecyclePausedStatus start";
1296     sptr<WindowOption> option = new WindowOption();
1297     ASSERT_NE(nullptr, option);
1298     option->SetWindowName("NotifyLifecyclePausedStatus");
1299     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
1300     ASSERT_NE(nullptr, window);
1301     window->property_->SetPersistentId(1);
1302     window->state_ = WindowState::STATE_SHOWN;
1303     window->NotifyLifecyclePausedStatus();
1304     window->state_ = WindowState::STATE_DESTROYED;
1305     window->NotifyLifecyclePausedStatus();
1306 
1307     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1308     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
1309     ASSERT_NE(nullptr, session);
1310     window->hostSession_ = session;
1311     window->state_ = WindowState::STATE_SHOWN;
1312     EXPECT_FALSE(window->IsWindowSessionInvalid());
1313     window->NotifyLifecyclePausedStatus();
1314     window->state_ = WindowState::STATE_DESTROYED;
1315     window->NotifyLifecyclePausedStatus();
1316     EXPECT_TRUE(g_errLog.find("isDidForeground:") == std::string::npos);
1317     EXPECT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
1318     LOG_SetCallback(nullptr);
1319     GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyLifecyclePausedStatus end";
1320 }
1321 
1322 /**
1323  * @tc.name: NotifyAfterLifecycleForeground
1324  * @tc.desc: NotifyAfterLifecycleForeground
1325  * @tc.type: FUNC
1326  */
1327 HWTEST_F(WindowSessionImplTest, NotifyAfterLifecycleForeground, TestSize.Level1)
1328 {
1329     GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyAfterLifecycleForeground start";
1330     sptr<WindowOption> foreOption = sptr<WindowOption>::MakeSptr();
1331     ASSERT_NE(nullptr, foreOption);
1332     foreOption->SetWindowName("NotifyAfterLifecycleForeground");
1333     sptr<WindowSessionImpl> foreWindow = sptr<WindowSessionImpl>::MakeSptr(foreOption);
1334     ASSERT_NE(nullptr, foreWindow);
1335     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1336     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
1337     ASSERT_NE(nullptr, session);
1338     EXPECT_EQ(WMError::WM_OK, foreWindow->Create(nullptr, session));
1339     foreWindow->NotifyAfterLifecycleForeground();
1340     EXPECT_EQ(WMError::WM_ERROR_INVALID_WINDOW, foreWindow->Destroy());
1341     GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyAfterLifecycleForeground end";
1342 }
1343 
1344 /**
1345  * @tc.name: NotifyAfterLifecycleBackground
1346  * @tc.desc: NotifyAfterLifecycleBackground
1347  * @tc.type: FUNC
1348  */
1349 HWTEST_F(WindowSessionImplTest, NotifyAfterLifecycleBackground, TestSize.Level1)
1350 {
1351     GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyAfterLifecycleBackground start";
1352     sptr<WindowOption> backOption = sptr<WindowOption>::MakeSptr();
1353     ASSERT_NE(nullptr, backOption);
1354     backOption->SetWindowName("NotifyAfterLifecycleBackground");
1355     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(backOption);
1356     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1357     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
1358     ASSERT_NE(nullptr, session);
1359     EXPECT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1360     window->NotifyAfterLifecycleBackground();
1361     EXPECT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
1362     GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyAfterLifecycleBackground end";
1363 }
1364 
1365 /**
1366  * @tc.name: Notify03
1367  * @tc.desc: NotifyCloseExistPipWindow NotifyAfterLifecycleResumed
1368  * @tc.type: FUNC
1369  */
1370  HWTEST_F(WindowSessionImplTest, NotifyAfterLifecycleResumed, TestSize.Level1)
1371 {
1372     sptr<WindowOption> notifyOption = sptr<WindowOption>::MakeSptr();
1373     ASSERT_NE(nullptr, notifyOption);
1374     notifyOption->SetWindowName("NotifyAfterLifecycleResumed");
1375     sptr<WindowSessionImpl> notifyWindow = sptr<WindowSessionImpl>::MakeSptr(notifyOption);
1376     ASSERT_NE(nullptr, notifyWindow);
1377     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1378     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1379     EXPECT_EQ(WMError::WM_OK, notifyWindow->Create(nullptr, session));
1380     notifyWindow->NotifyAfterLifecycleResumed();
1381     EXPECT_EQ(false, notifyWindow->isInteractiveStateFlag_);
1382     notifyWindow->state_ = WindowState::STATE_CREATED;
1383     notifyWindow->isDidForeground_ = true;
1384     notifyWindow->NotifyAfterLifecycleResumed();
1385     notifyWindow->state_ = WindowState::STATE_SHOWN;
1386     notifyWindow->isDidForeground_ = false;
1387     notifyWindow->NotifyAfterLifecycleResumed();
1388 
1389     notifyWindow->state_ = WindowState::STATE_CREATED;
1390     notifyWindow->isDidForeground_ = false;
1391     notifyWindow->NotifyAfterLifecycleResumed();
1392     notifyWindow->state_ = WindowState::STATE_SHOWN;
1393     notifyWindow->isDidForeground_ = true;
1394     notifyWindow->NotifyAfterLifecycleResumed();
1395     EXPECT_EQ(true, notifyWindow->isInteractiveStateFlag_);
1396     notifyWindow->NotifyAfterLifecycleResumed();
1397 
1398     ASSERT_NE(nullptr, notifyWindow->property_);
1399     notifyWindow->property_->SetPersistentId(1);
1400     notifyWindow->property_->SetUseControlState(true);
1401     notifyWindow->NotifyAfterLifecycleResumed();
1402     WSError res = notifyWindow->NotifyCloseExistPipWindow();
1403     EXPECT_EQ(res, WSError::WS_OK);
1404     EXPECT_EQ(WMError::WM_ERROR_INVALID_WINDOW, notifyWindow->Destroy());
1405 }
1406 
1407 /**
1408  * @tc.name: Notify03
1409  * @tc.desc: NotifyCloseExistPipWindow NotifyAfterLifecyclePaused
1410  * @tc.type: FUNC
1411  */
1412  HWTEST_F(WindowSessionImplTest, NotifyAfterLifecyclePaused, TestSize.Level1)
1413 {
1414     sptr<WindowOption> pauseOption = sptr<WindowOption>::MakeSptr();
1415     ASSERT_NE(nullptr, pauseOption);
1416     pauseOption->SetWindowName("NotifyAfterLifecyclePaused");
1417     sptr<WindowSessionImpl> pauseWindow = sptr<WindowSessionImpl>::MakeSptr(pauseOption);
1418     ASSERT_NE(nullptr, pauseWindow);
1419     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1420     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1421     EXPECT_EQ(WMError::WM_OK, pauseWindow->Create(nullptr, session));
1422     pauseWindow->NotifyAfterLifecycleResumed();
1423     pauseWindow->NotifyAfterLifecyclePaused();
1424     EXPECT_EQ(false, pauseWindow->isInteractiveStateFlag_);
1425     pauseWindow->NotifyAfterLifecyclePaused();
1426     WSError res = pauseWindow->NotifyCloseExistPipWindow();
1427     EXPECT_EQ(res, WSError::WS_OK);
1428     EXPECT_EQ(WMError::WM_ERROR_INVALID_WINDOW, pauseWindow->Destroy());
1429 }
1430 
1431 /**
1432  * @tc.name: Notify04
1433  * @tc.desc: NotifyAppUseControlStatus
1434  * @tc.type: FUNC
1435  */
1436  HWTEST_F(WindowSessionImplTest, NotifyAppUseControlStatusWhenSetStateThenReturnOK, TestSize.Level1)
1437 {
1438     sptr<WindowOption> appOption = sptr<WindowOption>::MakeSptr();
1439     ASSERT_NE(nullptr, appOption);
1440     appOption->SetWindowName("NotifyAppUseControlStatus");
1441     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(appOption);
1442     ASSERT_NE(nullptr, window);
1443     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1444     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1445     EXPECT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1446 
1447     window->property_->SetPersistentId(1);
1448     window->hostSession_ = session;
1449     window->state_ = WindowState::STATE_HIDDEN;
1450     window->NotifyAppUseControlStatus(true);
1451 
1452     window->state_ = WindowState::STATE_SHOWN;
1453     window->NotifyAppUseControlStatus(true);
1454 
1455     EXPECT_FALSE(window->IsWindowSessionInvalid());
1456     window->state_ = WindowState::STATE_HIDDEN;
1457     window->NotifyAppUseControlStatus(true);
1458 
1459     window->state_ = WindowState::STATE_SHOWN;
1460     window->NotifyAppUseControlStatus(true);
1461     window->NotifyAppUseControlStatus(false);
1462 
1463     WSError res = window->NotifyCloseExistPipWindow();
1464     EXPECT_EQ(res, WSError::WS_OK);
1465     EXPECT_EQ(WMError::WS_OK, window->Destroy());
1466 }
1467 
1468 /**
1469  * @tc.name: MarkProcessed
1470  * @tc.desc: MarkProcessed
1471  * @tc.type: FUNC
1472  */
1473 HWTEST_F(WindowSessionImplTest, MarkProcessed, TestSize.Level1)
1474 {
1475     GTEST_LOG_(INFO) << "WindowSessionImplTest: MarkProcessed start";
1476     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1477     option->SetWindowName("MarkProcessed");
1478     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1479 
1480     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1481     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
1482     ASSERT_NE(nullptr, session);
1483     ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1484 
1485     int32_t eventId = 1;
1486     window->state_ = WindowState::STATE_DESTROYED;
1487     window->hostSession_ = session;
1488     ASSERT_EQ(window->GetPersistentId(), INVALID_SESSION_ID);
1489     ASSERT_EQ(window->state_, WindowState::STATE_DESTROYED);
1490     WSError res = window->MarkProcessed(eventId);
1491     ASSERT_EQ(res, WSError::WS_DO_NOTHING);
1492     window->hostSession_ = nullptr;
1493     res = window->MarkProcessed(eventId);
1494     ASSERT_EQ(res, WSError::WS_DO_NOTHING);
1495     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
1496     GTEST_LOG_(INFO) << "WindowSessionImplTest: MarkProcessed end";
1497 }
1498 
1499 /**
1500  * @tc.name: Notify01
1501  * @tc.desc: NotifyDestroy NotifyTouchDialogTarget NotifyScreenshot
1502  * @tc.type: FUNC
1503  */
1504 HWTEST_F(WindowSessionImplTest, Notify01, TestSize.Level1)
1505 {
1506     GTEST_LOG_(INFO) << "WindowSessionImplTest: Notify01 start";
1507     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1508     option->SetWindowName("Notify01");
1509     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1510 
1511     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1512     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
1513     ASSERT_NE(nullptr, session);
1514     ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1515 
1516     window->NotifyTouchDialogTarget();
1517     window->uiContent_ = nullptr;
1518     window->NotifyScreenshot();
1519     window->uiContent_ = std::make_unique<Ace::UIContentMocker>();
1520     window->NotifyScreenshot();
1521     WSError res = window->NotifyDestroy();
1522     ASSERT_EQ(res, WSError::WS_OK);
1523     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
1524     GTEST_LOG_(INFO) << "WindowSessionImplTest: Notify01 end";
1525 }
1526 
1527 /**
1528  * @tc.name: NotifyKeyEvent
1529  * @tc.desc: NotifyKeyEvent
1530  * @tc.type: FUNC
1531  */
1532 HWTEST_F(WindowSessionImplTest, NotifyKeyEvent, TestSize.Level1)
1533 {
1534     GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyKeyEvent start";
1535     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1536     option->SetWindowName("NotifyKeyEvent");
1537     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1538 
1539     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1540     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1541     ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1542 
1543     std::shared_ptr<MMI::KeyEvent> keyEvent = MMI::KeyEvent::Create();
1544     bool isConsumed = false;
1545     bool notifyInputMethod = false;
1546     keyEvent->SetKeyCode(MMI::KeyEvent::KEYCODE_VIRTUAL_MULTITASK);
1547     window->NotifyKeyEvent(keyEvent, isConsumed, notifyInputMethod);
1548 
1549     keyEvent->SetKeyCode(MMI::KeyEvent::KEYCODE_BACK);
1550     window->NotifyKeyEvent(keyEvent, isConsumed, notifyInputMethod);
1551 
1552     notifyInputMethod = true;
1553     window->NotifyKeyEvent(keyEvent, isConsumed, notifyInputMethod);
1554 
1555     keyEvent = nullptr;
1556     window->NotifyKeyEvent(keyEvent, isConsumed, notifyInputMethod);
1557     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
1558     GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyKeyEvent end";
1559 }
1560 
1561 /**
1562  * @tc.name: UpdateProperty01
1563  * @tc.desc: UpdateProperty
1564  * @tc.type: FUNC
1565  */
1566 HWTEST_F(WindowSessionImplTest, UpdateProperty01, TestSize.Level1)
1567 {
1568     GTEST_LOG_(INFO) << "WindowSessionImplTest: UpdateProperty01 start";
1569     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1570     option->SetWindowName("UpdateProperty01");
1571     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1572     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1573     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1574     ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1575 
1576     ASSERT_NE(nullptr, window->property_);
1577     window->property_->SetPersistentId(1);
1578     WMError res = window->UpdateProperty(WSPropertyChangeAction::ACTION_UPDATE_RECT);
1579     ASSERT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW);
1580     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
1581 }
1582 
1583 /**
1584  * @tc.name: UpdateProperty02
1585  * @tc.desc: UpdateProperty
1586  * @tc.type: FUNC
1587  */
1588 HWTEST_F(WindowSessionImplTest, UpdateProperty02, TestSize.Level1)
1589 {
1590     GTEST_LOG_(INFO) << "WindowSessionImplTest: UpdateProperty02 start";
1591     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1592     option->SetWindowName("UpdateProperty02");
1593 
1594     // session is null
1595     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1596     ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, nullptr));
1597     WMError res = window->UpdateProperty(WSPropertyChangeAction::ACTION_UPDATE_RECT);
1598     ASSERT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW);
1599     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
1600     GTEST_LOG_(INFO) << "WindowSessionImplTest: UpdateProperty02 end";
1601 }
1602 
1603 /**
1604  * @tc.name: Find
1605  * @tc.desc: Find
1606  * @tc.type: FUNC
1607  */
1608 HWTEST_F(WindowSessionImplTest, Find, TestSize.Level1)
1609 {
1610     GTEST_LOG_(INFO) << "WindowSessionImplTest: Find start";
1611     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1612     option->SetWindowName("Find");
1613     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1614 
1615     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1616     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
1617     ASSERT_NE(nullptr, session);
1618     ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1619 
1620     std::string name = "Find";
1621     sptr<Window> res = window->Find(name);
1622     ASSERT_EQ(res, nullptr);
1623 
1624     name = "111";
1625     res = window->Find(name);
1626     ASSERT_EQ(res, nullptr);
1627     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
1628     GTEST_LOG_(INFO) << "WindowSessionImplTest: Find end";
1629 }
1630 
1631 /**
1632  * @tc.name: SetBackgroundColor01
1633  * @tc.desc: SetBackgroundColor string
1634  * @tc.type: FUNC
1635  */
1636 HWTEST_F(WindowSessionImplTest, SetBackgroundColor01, TestSize.Level1)
1637 {
1638     GTEST_LOG_(INFO) << "WindowSessionImplTest: SetBackgroundColor01 start";
1639     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1640     option->SetWindowName("SetBackgroundColor01");
1641     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1642 
1643     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1644     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
1645     ASSERT_NE(nullptr, session);
1646     ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, session));
1647 
1648     std::string color = "Blue";
1649     WMError res = window->SetBackgroundColor(color);
1650     ASSERT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW);
1651 
1652     color = "111";
1653     res = window->SetBackgroundColor(color);
1654     ASSERT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW);
1655     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
1656     // session is null
1657     window = new WindowSessionImpl(option);
1658     ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, nullptr));
1659     res = window->SetBackgroundColor(color);
1660     ASSERT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW);
1661     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
1662     GTEST_LOG_(INFO) << "WindowSessionImplTest: SetBackgroundColor01 end";
1663 }
1664 
1665 /**
1666  * @tc.name: SetBackgroundColor02
1667  * @tc.desc: SetBackgroundColor(uint32_t) and GetBackgroundColor
1668  * @tc.type: FUNC
1669  */
1670 HWTEST_F(WindowSessionImplTest, SetBackgroundColor02, TestSize.Level1)
1671 {
1672     GTEST_LOG_(INFO) << "WindowSessionImplTest: SetBackgroundColor02 start";
1673     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1674     option->SetWindowName("SetBackgroundColor02");
1675     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1676 
1677     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1678     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
1679     ASSERT_NE(nullptr, session);
1680     ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1681 
1682     WMError res = window->SetBackgroundColor(0xffffffff);
1683     ASSERT_EQ(res, WMError::WM_ERROR_INVALID_OPERATION);
1684     uint32_t ret = window->GetBackgroundColor();
1685     ASSERT_EQ(ret, 0xffffffff);
1686     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
1687     GTEST_LOG_(INFO) << "WindowSessionImplTest: SetBackgroundColor02 end";
1688 }
1689 
1690 /**
1691  * @tc.name: SetAPPWindowIcon
1692  * @tc.desc: SetAPPWindowIcon
1693  * @tc.type: FUNC
1694  */
1695 HWTEST_F(WindowSessionImplTest, SetAPPWindowIcon, TestSize.Level1)
1696 {
1697     GTEST_LOG_(INFO) << "WindowSessionImplTest: SetAPPWindowIcon start";
1698     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1699     option->SetWindowName("SetAPPWindowIcon");
1700     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1701 
1702     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1703     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
1704     ASSERT_NE(nullptr, session);
1705     ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1706     std::shared_ptr<Media::PixelMap> icon1(nullptr);
1707     WMError res = window->SetAPPWindowIcon(icon1);
1708     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
1709 
1710     std::shared_ptr<Media::PixelMap> icon2 = std::shared_ptr<Media::PixelMap>();
1711     res = window->SetAPPWindowIcon(icon2);
1712     ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
1713 
1714     Media::InitializationOptions opts;
1715     opts.size.width = 200;  // 200 test width
1716     opts.size.height = 300; // 300 test height
1717     opts.pixelFormat = Media::PixelFormat::ARGB_8888;
1718     opts.alphaType = Media::AlphaType::IMAGE_ALPHA_TYPE_OPAQUE;
1719     std::unique_ptr<Media::PixelMap> pixelMapPtr = Media::PixelMap::Create(opts);
1720     ASSERT_NE(pixelMapPtr.get(), nullptr);
1721     window->uiContent_ = std::make_unique<Ace::UIContentMocker>();
1722     res = window->SetAPPWindowIcon(std::shared_ptr<Media::PixelMap>(pixelMapPtr.release()));
1723     ASSERT_EQ(res, WMError::WM_OK);
1724     ASSERT_NE(window->GetUIContentSharedPtr(), nullptr);
1725     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
1726     GTEST_LOG_(INFO) << "WindowSessionImplTest: SetAPPWindowIcon end";
1727 }
1728 
1729 /**
1730  * @tc.name: Notify02
1731  * @tc.desc: NotifyAvoidAreaChange NotifyPointerEvent NotifyTouchOutside NotifyWindowVisibility
1732  * @tc.type: FUNC
1733  */
1734 HWTEST_F(WindowSessionImplTest, Notify02, TestSize.Level1)
1735 {
1736     GTEST_LOG_(INFO) << "WindowSessionImplTest: Notify02 start";
1737     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1738     option->SetWindowName("Notify02");
1739     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1740 
1741     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1742     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1743     ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1744 
1745     sptr<AvoidArea> avoidArea = new AvoidArea();
1746     avoidArea->topRect_ = { 1, 0, 0, 0 };
1747     avoidArea->leftRect_ = { 0, 1, 0, 0 };
1748     avoidArea->rightRect_ = { 0, 0, 1, 0 };
1749     avoidArea->bottomRect_ = { 0, 0, 0, 1 };
1750     AvoidAreaType type = AvoidAreaType::TYPE_SYSTEM;
1751     window->NotifyAvoidAreaChange(avoidArea, type);
1752 
1753     std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
1754     window->NotifyPointerEvent(pointerEvent);
1755     WSError res = window->NotifyTouchOutside();
1756     ASSERT_EQ(res, WSError::WS_OK);
1757 
1758     res = window->NotifyWindowVisibility(true);
1759     ASSERT_EQ(res, WSError::WS_OK);
1760     bool terminateCloseProcess = false;
1761     window->NotifySubWindowClose(terminateCloseProcess);
1762 
1763     bool enable = false;
1764     window->NotifySwitchFreeMultiWindow(enable);
1765 
1766     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
1767     GTEST_LOG_(INFO) << "WindowSessionImplTest: Notify02 end";
1768 }
1769 
1770 /**
1771  * @tc.name: SetAceAbilityHandler
1772  * @tc.desc: SetAceAbilityHandler
1773  * @tc.type: FUNC
1774  */
1775 HWTEST_F(WindowSessionImplTest, SetAceAbilityHandler, TestSize.Level1)
1776 {
1777     GTEST_LOG_(INFO) << "WindowSessionImplTest: SetAceAbilityHandler start";
1778     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1779     option->SetWindowName("SetAceAbilityHandler");
1780     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1781 
1782     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1783     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1784     ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1785 
1786     sptr<IAceAbilityHandler> handler = sptr<IAceAbilityHandler>();
1787     ASSERT_EQ(handler, nullptr);
1788     GTEST_LOG_(INFO) << "WindowSessionImplTest: SetAceAbilityHandler 111";
1789     window->SetAceAbilityHandler(handler);
1790     ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
1791     GTEST_LOG_(INFO) << "WindowSessionImplTest: SetAceAbilityHandler end";
1792 }
1793 
1794 /**
1795  * @tc.name: SetRaiseByClickEnabled01
1796  * @tc.desc: SetRaiseByClickEnabled and check the retCode
1797  * @tc.type: FUNC
1798  */
1799 HWTEST_F(WindowSessionImplTest, SetRaiseByClickEnabled01, TestSize.Level1)
1800 {
1801     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1802     option->SetWindowName("SetRaiseByClickEnabled01");
1803     option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1804     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
1805     ASSERT_NE(nullptr, window);
1806 
1807     WMError retCode = window->SetRaiseByClickEnabled(true);
1808     ASSERT_EQ(retCode, WMError::WM_ERROR_INVALID_PARENT);
1809 
1810     option->SetWindowName("SetRaiseByClickForFloatWindow");
1811     option->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
1812     sptr<WindowSessionImpl> floatWindow = new (std::nothrow) WindowSessionImpl(option);
1813     floatWindow->property_->SetParentPersistentId(1);
1814 
1815     retCode = floatWindow->SetRaiseByClickEnabled(true);
1816     ASSERT_EQ(retCode, WMError::WM_ERROR_INVALID_CALLING);
1817 
1818     option->SetWindowName("SetRaiseByClickForSubWindow");
1819     option->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1820     sptr<WindowSessionImpl> subWindow = new (std::nothrow) WindowSessionImpl(option);
1821     ASSERT_NE(nullptr, subWindow);
1822 
1823     subWindow->property_->SetParentPersistentId(1);
1824     subWindow->Hide();
1825     retCode = subWindow->SetRaiseByClickEnabled(true);
1826     ASSERT_EQ(retCode, WMError::WM_DO_NOTHING);
1827 
1828     subWindow->state_ = WindowState::STATE_SHOWN;
1829     retCode = subWindow->SetRaiseByClickEnabled(true);
1830     ASSERT_EQ(retCode, WMError::WM_ERROR_INVALID_WINDOW);
1831 
1832     subWindow->property_->SetParentPersistentId(2);
1833     subWindow->SetRaiseByClickEnabled(true);
1834     ASSERT_EQ(subWindow->property_->GetRaiseEnabled(), true);
1835 }
1836 
1837 /**
1838  * @tc.name: HideNonSystemFloatingWindows01
1839  * @tc.desc: HideNonSystemFloatingWindows and check the retCode
1840  * @tc.type: FUNC
1841  */
1842 HWTEST_F(WindowSessionImplTest, HideNonSystemFloatingWindows01, TestSize.Level1)
1843 {
1844     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1845     option->SetWindowName("HideNonSystemFloatingWindows01");
1846     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
1847     ASSERT_NE(nullptr, window);
1848     WMError retCode = window->HideNonSystemFloatingWindows(false);
1849     ASSERT_EQ(retCode, WMError::WM_ERROR_INVALID_WINDOW);
1850     window->property_->SetPersistentId(1);
1851     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1852     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
1853     ASSERT_NE(nullptr, session);
1854     window->hostSession_ = session;
1855     window->state_ = WindowState::STATE_CREATED;
1856     window->HideNonSystemFloatingWindows(false);
1857 }
1858 
1859 /**
1860  * @tc.name: UpdateWindowModetest01
1861  * @tc.desc: UpdateWindowMode
1862  * @tc.type: FUNC
1863  */
1864 HWTEST_F(WindowSessionImplTest, UpdateWindowMode, TestSize.Level1)
1865 {
1866     GTEST_LOG_(INFO) << "WindowSessionImplTest: UpdateWindowModetest01 start";
1867     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1868     ASSERT_NE(option, nullptr);
1869     option->SetWindowName("UpdateWindowMode");
1870     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
1871     ASSERT_NE(window, nullptr);
1872     WindowMode mode = WindowMode{ 0 };
1873     auto ret = window->UpdateWindowMode(mode);
1874     ASSERT_EQ(ret, WSError::WS_OK);
1875     GTEST_LOG_(INFO) << "WindowSessionImplTest: UpdateWindowModetest01 end";
1876 }
1877 
1878 /**
1879  * @tc.name: UpdateDensitytest01
1880  * @tc.desc: UpdateDensity
1881  * @tc.type: FUNC
1882  */
1883 HWTEST_F(WindowSessionImplTest, UpdateDensity, TestSize.Level1)
1884 {
1885     GTEST_LOG_(INFO) << "WindowSessionImplTest: UpdateDensitytest01 start";
1886     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1887     option->SetWindowName("UpdateDensity");
1888     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
1889     ASSERT_NE(window, nullptr);
1890     ASSERT_NE(window->property_, nullptr);
1891 
1892     Rect rect1;
1893     rect1.posX_ = 1;
1894     rect1.posY_ = 2;
1895     rect1.height_ = 3;
1896     rect1.width_ = 4;
1897     window->property_->SetWindowRect(rect1);
1898     auto rect2 = window->GetRect();
1899     ASSERT_EQ(1, rect2.posX_);
1900     ASSERT_EQ(2, rect2.posY_);
1901     ASSERT_EQ(3, rect2.height_);
1902     ASSERT_EQ(4, rect2.width_);
1903 
1904     window->UpdateDensity();
1905     GTEST_LOG_(INFO) << "WindowSessionImplTest: UpdateDensitytest01 end";
1906 }
1907 
1908 /**
1909  * @tc.name: UpdateDisplayIdtest01
1910  * @tc.desc: UpdateDisplayId
1911  * @tc.type: FUNC
1912  */
1913 HWTEST_F(WindowSessionImplTest, UpdateDisplayId, TestSize.Level1)
1914 {
1915     GTEST_LOG_(INFO) << "WindowSessionImplTest: UpdateDisplayIdtest01 start";
1916     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1917     option->SetWindowName("UpdateDisplayId");
1918     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
1919     ASSERT_NE(window, nullptr);
1920     uint64_t newDisplayId = 2;
1921     auto ret = window->UpdateDisplayId(newDisplayId);
1922     ASSERT_EQ(ret, WSError::WS_OK);
1923     uint64_t displayId = window->property_->GetDisplayId();
1924     ASSERT_EQ(newDisplayId, displayId);
1925     GTEST_LOG_(INFO) << "WindowSessionImplTest: UpdateDisplayIdtest01 end";
1926 }
1927 
1928 /**
1929  * @tc.name: IsFloatingWindowAppTypetest01
1930  * @tc.desc: IsFloatingWindowAppType
1931  * @tc.type: FUNC
1932  */
1933 HWTEST_F(WindowSessionImplTest, IsFloatingWindowAppType, TestSize.Level1)
1934 {
1935     GTEST_LOG_(INFO) << "WindowSessionImplTest: IsFloatingWindowAppTypetest01 start";
1936     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1937     option->SetWindowName("IsFloatingWindowAppType");
1938     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
1939     ASSERT_NE(window, nullptr);
1940     window->IsFloatingWindowAppType();
1941     ASSERT_NE(window, nullptr);
1942     GTEST_LOG_(INFO) << "WindowSessionImplTest: IsFloatingWindowAppTypetest01 end";
1943 }
1944 
1945 /**
1946  * @tc.name: SetUniqueVirtualPixelRatio
1947  * @tc.desc: SetUniqueVirtualPixelRatio
1948  * @tc.type: FUNC
1949  */
1950 HWTEST_F(WindowSessionImplTest, SetUniqueVirtualPixelRatio, TestSize.Level1)
1951 {
1952     sptr<WindowOption> option = new (std::nothrow) WindowOption();
1953     ASSERT_NE(option, nullptr);
1954     option->SetWindowName("SetUniqueVirtualPixelRatio");
1955     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
1956     ASSERT_NE(window, nullptr);
1957     window->SetUniqueVirtualPixelRatio(true, 3.25f);
1958     window->SetUniqueVirtualPixelRatio(false, 3.25f);
1959 }
1960 
1961 /**
1962  * @tc.name: EnableDrag
1963  * @tc.desc: EnableDrag Test
1964  * @tc.type: FUNC
1965  */
1966 HWTEST_F(WindowSessionImplTest, EnableDrag, TestSize.Level1)
1967 {
1968     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1969     option->SetWindowName("EnableDrag");
1970     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1971     window->property_->SetPersistentId(2101);
1972     window->property_->SetWindowType(WindowType::WINDOW_TYPE_GLOBAL_SEARCH);
1973     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1974     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1975     window->hostSession_ = session;
1976 
1977     window->windowSystemConfig_.windowUIType_ = WindowUIType::INVALID_WINDOW;
1978     auto result = window->EnableDrag(true);
1979     ASSERT_EQ(result, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
1980 
1981     window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
1982     window->property_->type_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW;
1983     result = window->EnableDrag(true);
1984     ASSERT_EQ(result, WMError::WM_ERROR_INVALID_CALLING);
1985 
1986     window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
1987     window->property_->type_ = WindowType::WINDOW_TYPE_APP_SUB_WINDOW;
1988     result = window->EnableDrag(true);
1989     ASSERT_NE(result, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
1990 }
1991 
1992 /**
1993  * @tc.name: AddSetUIContentTimeoutCheck
1994  * @tc.desc: AddSetUIContentTimeoutCheck
1995  * @tc.type: FUNC
1996  */
1997 HWTEST_F(WindowSessionImplTest, AddSetUIContentTimeoutCheck_test, TestSize.Level1)
1998 {
1999     sptr<WindowOption> option = new (std::nothrow) WindowOption();
2000     ASSERT_NE(option, nullptr);
2001     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
2002     ASSERT_NE(window, nullptr);
2003     window->handler_ = nullptr;
2004 
2005     option->SetWindowName("AddSetUIContentTimeoutCheck_test");
2006     option->SetBundleName("UTtest");
2007     WindowType type1 = WindowType::APP_MAIN_WINDOW_BASE;
2008     option->SetWindowType(type1);
2009     sptr<WindowSessionImpl> window1 = new (std::nothrow) WindowSessionImpl(option);
2010     ASSERT_NE(window1, nullptr);
2011     window1->AddSetUIContentTimeoutCheck();
2012 
2013     WindowType type2 = WindowType::WINDOW_TYPE_UI_EXTENSION;
2014     option->SetWindowType(type2);
2015     sptr<WindowSessionImpl> window2 = new (std::nothrow) WindowSessionImpl(option);
2016     ASSERT_NE(window2, nullptr);
2017     window2->AddSetUIContentTimeoutCheck();
2018     EXPECT_EQ(WindowType::WINDOW_TYPE_UI_EXTENSION, window2->property_->GetWindowType());
2019 }
2020 
2021 /**
2022  * @tc.name: FindMainWindowWithContext01
2023  * @tc.desc: FindMainWindowWithContext
2024  * @tc.type: FUNC
2025  */
2026 HWTEST_F(WindowSessionImplTest, FindMainWindowWithContext01, TestSize.Level1)
2027 {
2028     sptr<WindowOption> option = new (std::nothrow) WindowOption();
2029     option->SetWindowTag(WindowTag::MAIN_WINDOW);
2030     option->SetWindowName("FindMainWindowWithContext01");
2031     sptr<WindowSessionImpl> windowSession = new (std::nothrow) WindowSessionImpl(option);
2032     ASSERT_NE(nullptr, windowSession);
2033 
2034     windowSession->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
2035     ASSERT_TRUE(windowSession->FindMainWindowWithContext() == nullptr);
2036     windowSession->SetWindowType(WindowType::ABOVE_APP_SYSTEM_WINDOW_END);
2037     ASSERT_TRUE(windowSession->FindMainWindowWithContext() == nullptr);
2038 
2039     windowSession->property_->SetPersistentId(1002);
2040     windowSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
2041     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
2042     sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
2043     ASSERT_NE(nullptr, session);
2044     ASSERT_EQ(WMError::WM_OK, windowSession->Create(abilityContext_, session));
2045     windowSession->Destroy(true);
2046 }
2047 
2048 /**
2049  * @tc.name: FindExtensionWindowWithContext01
2050  * @tc.desc: FindExtensionWindowWithContext
2051  * @tc.type: FUNC
2052  */
2053 HWTEST_F(WindowSessionImplTest, FindExtensionWindowWithContext01, TestSize.Level1)
2054 {
2055     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2056     option->SetWindowName("FindExtensionWindowWithContext01");
2057     sptr<WindowSessionImpl> windowSession = sptr<WindowSessionImpl>::MakeSptr(option);
2058 
2059     ASSERT_TRUE(windowSession->FindExtensionWindowWithContext() == nullptr);
2060 
2061     windowSession->property_->SetPersistentId(12345);
2062     windowSession->property_->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION);
2063     windowSession->context_ = abilityContext_;
2064     WindowSessionImpl::GetWindowExtensionSessionSet().insert(windowSession);
2065     ASSERT_TRUE(nullptr != windowSession->FindExtensionWindowWithContext());
2066     windowSession->Destroy(true);
2067 }
2068 
2069 /**
2070  * @tc.name: SetUIContentComplete
2071  * @tc.desc: SetUIContentComplete
2072  * @tc.type: FUNC
2073  */
2074 HWTEST_F(WindowSessionImplTest, SetUIContentComplete, TestSize.Level1)
2075 {
2076     sptr<WindowOption> option = new (std::nothrow) WindowOption();
2077     ASSERT_NE(option, nullptr);
2078     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
2079     ASSERT_NE(window, nullptr);
2080     window->SetUIContentComplete();
2081     EXPECT_EQ(window->setUIContentCompleted_.load(), true);
2082 
2083     window->SetUIContentComplete();
2084     EXPECT_EQ(window->setUIContentCompleted_.load(), true);
2085 }
2086 
2087 /**
2088  * @tc.name: NotifySetUIContentComplete
2089  * @tc.desc: NotifySetUIContentComplete
2090  * @tc.type: FUNC
2091  */
2092 HWTEST_F(WindowSessionImplTest, NotifySetUIContentComplete, TestSize.Level1)
2093 {
2094     sptr<WindowOption> option = new (std::nothrow) WindowOption();
2095     ASSERT_NE(nullptr, option);
2096     option->SetWindowName("NotifySetUIContent");
2097     option->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
2098     sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
2099     ASSERT_NE(nullptr, window);
2100     window->NotifySetUIContentComplete();
2101     EXPECT_EQ(window->setUIContentCompleted_.load(), true);
2102 
2103     option->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
2104     window = new (std::nothrow) WindowSessionImpl(option);
2105     ASSERT_NE(nullptr, window);
2106     window->NotifySetUIContentComplete();
2107     EXPECT_EQ(window->setUIContentCompleted_.load(), true);
2108 
2109     option->SetWindowType(WindowType::SYSTEM_WINDOW_BASE);
2110     window = new (std::nothrow) WindowSessionImpl(option);
2111     ASSERT_NE(nullptr, window);
2112     window->NotifySetUIContentComplete();
2113     EXPECT_EQ(window->setUIContentCompleted_.load(), true);
2114 }
2115 
2116 /**
2117  * @tc.name: SetUIExtensionDestroyComplete
2118  * @tc.desc: SetUIExtensionDestroyComplete
2119  * @tc.type: FUNC
2120  */
2121 HWTEST_F(WindowSessionImplTest, SetUIExtensionDestroyComplete, TestSize.Level1)
2122 {
2123     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2124     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
2125     window->SetUIExtensionDestroyComplete();
2126     EXPECT_EQ(window->setUIExtensionDestroyCompleted_.load(), true);
2127     window->SetUIExtensionDestroyComplete();
2128     EXPECT_EQ(window->setUIExtensionDestroyCompleted_.load(), true);
2129 }
2130 
2131 /**
2132  * @tc.name: SetUIExtensionDestroyCompleteInSubWindow
2133  * @tc.desc: SetUIExtensionDestroyCompleteInSubWindow
2134  * @tc.type: FUNC
2135  */
2136 HWTEST_F(WindowSessionImplTest, SetUIExtensionDestroyCompleteInSubWindow, TestSize.Level1)
2137 {
2138     sptr<WindowOption> subWindowOption = sptr<WindowOption>::MakeSptr();
2139     subWindowOption->SetWindowName("subWindow");
2140     sptr<WindowSessionImpl> subWindowSession = sptr<WindowSessionImpl>::MakeSptr(subWindowOption);
2141     subWindowSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
2142     subWindowSession->context_ = abilityContext_;
2143     subWindowSession->SetUIExtensionDestroyCompleteInSubWindow();
2144 
2145     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2146     option->SetWindowName("SetUIExtensionDestroyCompleteInSubWindow");
2147     sptr<WindowSessionImpl> windowSession = sptr<WindowSessionImpl>::MakeSptr(option);
2148     ASSERT_TRUE(windowSession->FindExtensionWindowWithContext() == nullptr);
2149     windowSession->property_->SetPersistentId(12345);
2150     windowSession->property_->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION);
2151     windowSession->context_ = abilityContext_;
2152     WindowSessionImpl::GetWindowExtensionSessionSet().insert(windowSession);
2153     ASSERT_TRUE(nullptr != windowSession->FindExtensionWindowWithContext());
2154     windowSession->AddSetUIExtensionDestroyTimeoutCheck();
2155     EXPECT_EQ(windowSession->startUIExtensionDestroyTimer_.load(), true);
2156     subWindowSession->SetUIExtensionDestroyCompleteInSubWindow();
2157     EXPECT_EQ(windowSession->startUIExtensionDestroyTimer_.load(), false);
2158 }
2159 
2160 /**
2161  * @tc.name: AddSetUIExtensionDestroyTimeoutCheck
2162  * @tc.desc: AddSetUIExtensionDestroyTimeoutCheck
2163  * @tc.type: FUNC
2164  */
2165 HWTEST_F(WindowSessionImplTest, AddSetUIExtensionDestroyTimeoutCheck, TestSize.Level1)
2166 {
2167     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2168     option->SetWindowName("AddSetUIExtensionDestroyTimeoutCheck");
2169     option->SetBundleName("UTtest");
2170     option->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION);
2171     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
2172     window->AddSetUIExtensionDestroyTimeoutCheck();
2173     EXPECT_EQ(WindowType::WINDOW_TYPE_UI_EXTENSION, window->property_->GetWindowType());
2174     EXPECT_EQ(window->startUIExtensionDestroyTimer_.load(), true);
2175 }
2176 
2177 /**
2178  * @tc.name: GetStatusBarHeight
2179  * @tc.desc: GetStatusBarHeight test
2180  * @tc.type: FUNC
2181  */
2182 HWTEST_F(WindowSessionImplTest, GetStatusBarHeight, TestSize.Level1)
2183 {
2184     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2185     option->SetWindowName("GetStatusBarHeight");
2186     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
2187     ASSERT_NE(window, nullptr);
2188     ASSERT_EQ(0, window->GetStatusBarHeight());
2189 }
2190 
2191 /**
2192  * @tc.name: GetWindowStatusInner
2193  * @tc.desc: GetWindowStatusInner test
2194  * @tc.type: FUNC
2195  */
2196 HWTEST_F(WindowSessionImplTest, GetWindowStatusInner, TestSize.Level1)
2197 {
2198     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2199     option->SetWindowName("GetWindowStatusInner");
2200     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
2201     window->property_->SetPersistentId(1);
2202     SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
2203     sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
2204     window->hostSession_ = session;
2205     EXPECT_EQ(WindowStatus::WINDOW_STATUS_UNDEFINED, window->GetWindowStatusInner(WindowMode::WINDOW_MODE_PIP));
2206 
2207     window->SetTargetAPIVersion(14);
2208     window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
2209     EXPECT_EQ(WindowStatus::WINDOW_STATUS_FULLSCREEN, window->GetWindowStatusInner(WindowMode::WINDOW_MODE_FULLSCREEN));
2210     window->SetTargetAPIVersion(12);
2211     EXPECT_EQ(WindowStatus::WINDOW_STATUS_FULLSCREEN, window->GetWindowStatusInner(WindowMode::WINDOW_MODE_FULLSCREEN));
2212 
2213     EXPECT_EQ(WindowStatus::WINDOW_STATUS_SPLITSCREEN,
2214     window->GetWindowStatusInner(WindowMode::WINDOW_MODE_SPLIT_PRIMARY));
2215     EXPECT_EQ(WindowStatus::WINDOW_STATUS_SPLITSCREEN,
2216     window->GetWindowStatusInner(WindowMode::WINDOW_MODE_SPLIT_SECONDARY));
2217 
2218     window->property_->maximizeMode_ = MaximizeMode::MODE_AVOID_SYSTEM_BAR;
2219     EXPECT_EQ(WindowStatus::WINDOW_STATUS_MAXIMIZE, window->GetWindowStatusInner(WindowMode::WINDOW_MODE_FLOATING));
2220     window->property_->maximizeMode_ = MaximizeMode::MODE_FULL_FILL;
2221     EXPECT_EQ(WindowStatus::WINDOW_STATUS_FLOATING, window->GetWindowStatusInner(WindowMode::WINDOW_MODE_FLOATING));
2222 
2223     window->state_ = WindowState::STATE_HIDDEN;
2224     EXPECT_EQ(WindowStatus::WINDOW_STATUS_MINIMIZE, window->GetWindowStatusInner(WindowMode::WINDOW_MODE_PIP));
2225 }
2226 
2227 /**
2228  * @tc.name: GetBackgroundColor01
2229  * @tc.desc: GetBackgroundColor01 test
2230  * @tc.type: FUNC
2231  */
2232 HWTEST_F(WindowSessionImplTest, GetBackgroundColor01, TestSize.Level1)
2233 {
2234     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2235     option->SetWindowName("GetBackgroundColor01");
2236     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
2237     window->uiContent_ = std::make_unique<Ace::UIContentMocker>();
2238     EXPECT_EQ(0, window->GetBackgroundColor());
2239 }
2240 
2241 /**
2242  * @tc.name: GetBackgroundColor02
2243  * @tc.desc: GetBackgroundColor02 test
2244  * @tc.type: FUNC
2245  */
2246 HWTEST_F(WindowSessionImplTest, GetBackgroundColor02, TestSize.Level1)
2247 {
2248     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2249     option->SetWindowName("GetBackgroundColor02");
2250     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
2251     sptr<IAceAbilityHandler> handler = sptr<IAceAbilityHandler>();
2252     window->SetAceAbilityHandler(handler);
2253     EXPECT_EQ(0xffffffff, window->GetBackgroundColor());
2254 }
2255 
2256 /**
2257  * @tc.name: GetBackgroundColor03
2258  * @tc.desc: GetBackgroundColor03 test
2259  * @tc.type: FUNC
2260  */
2261 HWTEST_F(WindowSessionImplTest, GetBackgroundColor03, TestSize.Level1)
2262 {
2263     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2264     option->SetWindowName("GetBackgroundColor03");
2265     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
2266     EXPECT_EQ(0xffffffff, window->GetBackgroundColor());
2267 }
2268 
2269 /**
2270  * @tc.name: GetExtensionConfig
2271  * @tc.desc: GetExtensionConfig test
2272  * @tc.type: FUNC
2273  */
2274 HWTEST_F(WindowSessionImplTest, GetExtensionConfig, TestSize.Level1)
2275 {
2276     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2277     option->SetWindowName("GetExtensionConfig");
2278     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
2279     SessionInfo sessionInfo;
2280     window->hostSession_ = sptr<SessionMocker>::MakeSptr(sessionInfo);
2281     window->crossAxisState_ = CrossAxisState::STATE_CROSS;
2282     AAFwk::WantParams want;
2283     window->GetExtensionConfig(want);
2284     EXPECT_EQ(want.GetIntParam(Extension::CROSS_AXIS_FIELD, 0), static_cast<int32_t>(CrossAxisState::STATE_CROSS));
2285     window->crossAxisState_ = CrossAxisState::STATE_INVALID;
2286     window->GetExtensionConfig(want);
2287     EXPECT_EQ(want.GetIntParam(Extension::CROSS_AXIS_FIELD, 0), static_cast<int32_t>(CrossAxisState::STATE_INVALID));
2288     window->crossAxisState_ = CrossAxisState::STATE_NO_CROSS;
2289     window->GetExtensionConfig(want);
2290     EXPECT_EQ(want.GetIntParam(Extension::CROSS_AXIS_FIELD, 0), static_cast<int32_t>(CrossAxisState::STATE_NO_CROSS));
2291     window->crossAxisState_ = CrossAxisState::STATE_END;
2292     window->GetExtensionConfig(want);
2293     EXPECT_EQ(want.GetIntParam(Extension::CROSS_AXIS_FIELD, 0), static_cast<int32_t>(CrossAxisState::STATE_END));
2294 
2295     bool isHostWindowDelayRaiseEnabled = true;
2296     window->property_->SetWindowDelayRaiseEnabled(isHostWindowDelayRaiseEnabled);
2297     window->GetExtensionConfig(want);
2298     EXPECT_EQ(want.GetIntParam(Extension::HOST_WINDOW_DELAY_RAISE_STATE_FIELD, 0),
2299         static_cast<int32_t>(isHostWindowDelayRaiseEnabled));
2300     isHostWindowDelayRaiseEnabled = false;
2301     window->property_->SetWindowDelayRaiseEnabled(isHostWindowDelayRaiseEnabled);
2302     window->GetExtensionConfig(want);
2303     EXPECT_EQ(want.GetIntParam(Extension::HOST_WINDOW_DELAY_RAISE_STATE_FIELD, 0),
2304         static_cast<int32_t>(isHostWindowDelayRaiseEnabled));
2305 }
2306 
2307 /**
2308  * @tc.name: OnExtensionMessage
2309  * @tc.desc: OnExtensionMessage test
2310  * @tc.type: FUNC
2311  */
2312 HWTEST_F(WindowSessionImplTest, OnExtensionMessage, TestSize.Level1)
2313 {
2314     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2315     option->SetWindowName("OnExtensionMessage");
2316     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
2317     uint32_t code = 9999;
2318     int32_t persistentId = 1111;
2319     AAFwk::Want want;
2320     auto ret = window->OnExtensionMessage(code, persistentId, want);
2321     EXPECT_EQ(WMError::WM_OK, ret);
2322 
2323     code = static_cast<uint32_t>(Extension::Businesscode::NOTIFY_HOST_WINDOW_TO_RAISE);
2324     window->hostSession_ = nullptr;
2325     ASSERT_EQ(nullptr, window->GetHostSession());
2326     ret = window->OnExtensionMessage(code, persistentId, want);
2327     EXPECT_EQ(WMError::WM_ERROR_INVALID_WINDOW, ret);
2328     SessionInfo sessionInfo;
2329     window->hostSession_ = sptr<SessionMocker>::MakeSptr(sessionInfo);
2330     window->property_->SetPersistentId(1);
2331     ASSERT_FALSE(window->GetPersistentId() == INVALID_SESSION_ID);
2332     window->state_ = WindowState::STATE_CREATED;
2333     ASSERT_FALSE(window->state_ == WindowState::STATE_DESTROYED);
2334     window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
2335     ASSERT_EQ(true, WindowHelper::IsAppWindow(window->GetType()));
2336     ret = window->OnExtensionMessage(code, persistentId, want);
2337     EXPECT_EQ(WMError::WM_OK, ret);
2338 
2339     code = static_cast<uint32_t>(Extension::Businesscode::REGISTER_HOST_WINDOW_RECT_CHANGE_LISTENER);
2340     EXPECT_EQ(WMError::WM_OK, window->OnExtensionMessage(code, persistentId, want));
2341     code = static_cast<uint32_t>(Extension::Businesscode::UNREGISTER_HOST_WINDOW_RECT_CHANGE_LISTENER);
2342     EXPECT_EQ(WMError::WM_OK, window->OnExtensionMessage(code, persistentId, want));
2343 }
2344 
2345 /**
2346  * @tc.name: OnExtensionMessage_KeyboardListener
2347  * @tc.desc: OnExtensionMessage_KeyboardListener test
2348  * @tc.type: FUNC
2349  */
2350 HWTEST_F(WindowSessionImplTest, OnExtensionMessage_KeyboardListener, TestSize.Level1)
2351 {
2352     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2353     option->SetWindowName("OnExtensionMessage");
2354     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
2355     uint32_t code = 9999;
2356     int32_t persistentId = 1111;
2357     AAFwk::Want want;
2358 
2359     ASSERT_TRUE(window->keyboardDidShowUIExtListeners_.empty());
2360     code = static_cast<uint32_t>(Extension::Businesscode::REGISTER_KEYBOARD_DID_SHOW_LISTENER);
2361     EXPECT_EQ(WMError::WM_OK, window->OnExtensionMessage(code, persistentId, want));
2362     ASSERT_FALSE(window->keyboardDidShowUIExtListeners_.empty());
2363     EXPECT_EQ(WMError::WM_OK, window->OnExtensionMessage(code, persistentId, want));
2364 
2365     code = static_cast<uint32_t>(Extension::Businesscode::UNREGISTER_KEYBOARD_DID_SHOW_LISTENER);
2366     EXPECT_EQ(WMError::WM_OK, window->OnExtensionMessage(code, persistentId, want));
2367     ASSERT_TRUE(window->keyboardDidShowUIExtListeners_.empty());
2368     EXPECT_EQ(WMError::WM_OK, window->OnExtensionMessage(code, persistentId, want));
2369 
2370     ASSERT_TRUE(window->keyboardDidHideUIExtListeners_.empty());
2371     code = static_cast<uint32_t>(Extension::Businesscode::REGISTER_KEYBOARD_DID_HIDE_LISTENER);
2372     EXPECT_EQ(WMError::WM_OK, window->OnExtensionMessage(code, persistentId, want));
2373     ASSERT_FALSE(window->keyboardDidHideUIExtListeners_.empty());
2374     EXPECT_EQ(WMError::WM_OK, window->OnExtensionMessage(code, persistentId, want));
2375 
2376     code = static_cast<uint32_t>(Extension::Businesscode::UNREGISTER_KEYBOARD_DID_HIDE_LISTENER);
2377     EXPECT_EQ(WMError::WM_OK, window->OnExtensionMessage(code, persistentId, want));
2378     ASSERT_TRUE(window->keyboardDidHideUIExtListeners_.empty());
2379     EXPECT_EQ(WMError::WM_OK, window->OnExtensionMessage(code, persistentId, want));
2380 }
2381 
2382 /**
2383  * @tc.name: RegisterWaterfallModeChangeListener
2384  * @tc.desc: RegisterWaterfallModeChangeListener Test
2385  * @tc.type: FUNC
2386  */
2387 HWTEST_F(WindowSessionImplTest, RegisterWaterfallModeChangeListener, TestSize.Level1)
2388 {
2389     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2390     option->SetWindowName("waterfall");
2391     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
2392     sptr<IWaterfallModeChangeListener> listener = sptr<IWaterfallModeChangeListener>::MakeSptr();
2393     auto ret = window->RegisterWaterfallModeChangeListener(listener);
2394     ASSERT_EQ(WMError::WM_OK, ret);
2395     listener = nullptr;
2396     ret = window->RegisterWaterfallModeChangeListener(listener);
2397     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, ret);
2398     auto listeners = window->GetWaterfallModeChangeListeners();
2399     ASSERT_EQ(listeners.size(), 1);
2400 }
2401 
2402 /**
2403  * @tc.name: UnregisterWaterfallModeChangeListener
2404  * @tc.desc: UnregisterWaterfallModeChangeListener Test
2405  * @tc.type: FUNC
2406  */
2407 HWTEST_F(WindowSessionImplTest, UnregisterWaterfallModeChangeListener, TestSize.Level1)
2408 {
2409     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2410     option->SetWindowName("waterfall");
2411     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
2412     window->waterfallModeChangeListeners_.clear();
2413     sptr<IWaterfallModeChangeListener> listener = sptr<IWaterfallModeChangeListener>::MakeSptr();
2414     auto ret = window->RegisterWaterfallModeChangeListener(listener);
2415     ASSERT_EQ(WMError::WM_OK, ret);
2416     auto listeners = window->GetWaterfallModeChangeListeners();
2417     ASSERT_EQ(listeners.size(), 1);
2418     ret = window->UnregisterWaterfallModeChangeListener(listener);
2419     ASSERT_EQ(WMError::WM_OK, ret);
2420     listeners = window->GetWaterfallModeChangeListeners();
2421     ASSERT_EQ(listeners.size(), 0);
2422     listener = nullptr;
2423     ret = window->UnregisterWaterfallModeChangeListener(listener);
2424     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, ret);
2425 }
2426 
2427 /**
2428  * @tc.name: GetRouterStackInfo
2429  * @tc.desc: GetRouterStackInfo
2430  * @tc.type: FUNC
2431  */
2432 HWTEST_F(WindowSessionImplTest, GetRouterStackInfo, TestSize.Level1)
2433 {
2434     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2435     option->SetWindowName("GetRouterStackInfo");
2436     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
2437 
2438     window->uiContent_ = std::make_unique<Ace::UIContentMocker>();
2439     std::string testInfo;
2440     auto res = window->GetRouterStackInfo(testInfo);
2441     EXPECT_EQ(res, WMError::WM_OK);
2442 
2443     window->uiContent_ = nullptr;
2444     res = window->GetRouterStackInfo(testInfo);
2445     EXPECT_EQ(res, WMError::WM_ERROR_NULLPTR);
2446 }
2447 
2448 /**
2449  * @tc.name: IsWaterfallModeEnabled
2450  * @tc.desc: IsWaterfallModeEnabled
2451  * @tc.type: FUNC
2452  */
2453 HWTEST_F(WindowSessionImplTest, IsWaterfallModeEnabled, TestSize.Level1)
2454 {
2455     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2456     option->SetWindowName("IsWaterfallModeEnabled");
2457     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
2458     window->hostSession_ = nullptr;
2459     EXPECT_EQ(window->IsWaterfallModeEnabled(), false);
2460 
2461     auto mockHostSession = sptr<SessionStubMocker>::MakeSptr();
2462     window->hostSession_ = mockHostSession;
2463     window->property_->persistentId_ = 1234;
2464     EXPECT_CALL(*mockHostSession, GetWaterfallMode(_)).WillOnce(DoAll(SetArgReferee<0>(true), Return(WSError::WS_OK)));
2465     EXPECT_EQ(window->IsWaterfallModeEnabled(), true);
2466 }
2467 
2468 /**
2469  * @tc.name: NotifyWaterfallModeChange
2470  * @tc.desc: NotifyWaterfallModeChange Test
2471  * @tc.type: FUNC
2472  */
2473 HWTEST_F(WindowSessionImplTest, NotifyWaterfallModeChange, TestSize.Level1)
2474 {
2475     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2476     option->SetWindowName("waterfall");
2477     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
2478     window->state_ = WindowState::STATE_SHOWN;
2479     sptr<IWaterfallModeChangeListener> listener = sptr<IWaterfallModeChangeListener>::MakeSptr();
2480     auto ret = window->RegisterWaterfallModeChangeListener(listener);
2481     ASSERT_EQ(WMError::WM_OK, ret);
2482     window->NotifyWaterfallModeChange(true);
2483 }
2484 
2485 /**
2486  * @tc.name: NotifyAcrossDisplaysChange
2487  * @tc.desc: NotifyAcrossDisplaysChange Test
2488  * @tc.type: FUNC
2489  */
2490 HWTEST_F(WindowSessionImplTest, NotifyAcrossDisplaysChange, TestSize.Level1)
2491 {
2492     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2493     option->SetWindowName("waterfall");
2494     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
2495     window->property_->SetPersistentId(1);
2496     window->state_ = WindowState::STATE_SHOWN;
2497     sptr<IAcrossDisplaysChangeListener> listener = sptr<IAcrossDisplaysChangeListener>::MakeSptr();
2498     window->acrossDisplaysChangeListeners_[1].push_back(listener);
2499     window->RegisterAcrossDisplaysChangeListener(listener);
2500     auto ret = window->NotifyAcrossDisplaysChange(true);
2501     EXPECT_EQ(WMError::WM_OK, ret);
2502     ret = window->NotifyAcrossDisplaysChange(true);
2503     EXPECT_EQ(WMError::WM_DO_NOTHING, ret);
2504     window->acrossDisplaysChangeListeners_[1].push_back(nullptr);
2505     ret = window->NotifyAcrossDisplaysChange(false);
2506     EXPECT_EQ(WMError::WM_OK, ret);
2507 }
2508 
2509 /**
2510  * @tc.name: CreateSubWindowOutlineEnabled
2511  * @tc.desc: CreateSubWindowOutlineEnabled Test
2512  * @tc.type: FUNC
2513  */
2514 HWTEST_F(WindowSessionImplTest, CreateSubWindowOutlineEnabled, TestSize.Level1)
2515 {
2516     sptr<WindowOption> option1 = sptr<WindowOption>::MakeSptr();
2517     option1->SetWindowName("CreateSubWindowOutlineEnabled01");
2518     option1->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
2519     sptr<WindowSessionImpl> window1 = sptr<WindowSessionImpl>::MakeSptr(option1);
2520     ASSERT_EQ(false, window1->property_->IsSubWindowOutlineEnabled());
2521 
2522     sptr<WindowOption> option2 = sptr<WindowOption>::MakeSptr();
2523     option2->SetWindowName("CreateSubWindowOutlineEnabled02");
2524     option2->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
2525     option2->SetSubWindowOutlineEnabled(false);
2526     sptr<WindowSessionImpl> window2 = sptr<WindowSessionImpl>::MakeSptr(option2);
2527     ASSERT_EQ(false, window2->property_->IsSubWindowOutlineEnabled());
2528 
2529     sptr<WindowOption> option3 = sptr<WindowOption>::MakeSptr();
2530     option3->SetWindowName("CreateSubWindowOutlineEnabled03");
2531     option3->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
2532     option3->SetSubWindowOutlineEnabled(true);
2533     sptr<WindowSessionImpl> window3 = sptr<WindowSessionImpl>::MakeSptr(option3);
2534     ASSERT_EQ(true, window3->property_->IsSubWindowOutlineEnabled());
2535 }
2536 
2537 /**
2538  * @tc.name: GetAttachStateSyncResult
2539  * @tc.desc: GetAttachStateSyncResult Test
2540  * @tc.type: FUNC
2541  */
2542 HWTEST_F(WindowSessionImplTest, GetAttachStateSyncResult, TestSize.Level1)
2543 {
2544     g_errLog.clear();
2545     LOG_SetCallback(MyLogCallback);
2546     sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
2547     option->SetWindowName("GetAttachStateSyncResult");
2548     option->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
2549     sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
2550 
2551     window->lifecycleCallback_ = sptr<LifecycleFutureCallback>::MakeSptr();
2552     window->GetAttachStateSyncResult(true, true);
2553     EXPECT_TRUE(g_errLog.find("get attach state sync result") == std::string::npos);
2554 
2555     window->GetAttachStateSyncResult(true, false);
2556     EXPECT_TRUE(g_errLog.find("get attach state sync result") == std::string::npos);
2557 
2558     window->lifecycleCallback_ = nullptr;
2559     window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
2560     window->GetAttachStateSyncResult(true, true);
2561     EXPECT_TRUE(g_errLog.find("lifecycleCallback is null") != std::string::npos);
2562     EXPECT_TRUE(g_errLog.find("get attach state sync result") == std::string::npos);
2563 
2564     window->lifecycleCallback_ = sptr<LifecycleFutureCallback>::MakeSptr();
2565     window->GetAttachStateSyncResult(false, true);
2566     EXPECT_TRUE(g_errLog.find("get attach state sync result") == std::string::npos);
2567 
2568     window->GetAttachStateSyncResult(true, true);
2569     EXPECT_TRUE(g_errLog.find("get attach state sync result") != std::string::npos);
2570 
2571     window->GetAttachStateSyncResult(true, false);
2572     EXPECT_TRUE(g_errLog.find("get attach state sync result") != std::string::npos);
2573 }
2574 }
2575 } // namespace
2576 } // namespace Rosen
2577 } // namespace OHOS
2578