1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <gtest/gtest.h>
17 #include "ability_context_impl.h"
18 #include "window.h"
19 #include "mock_window_adapter.h"
20 #include "singleton_mocker.h"
21 #include "scene_board_judgement.h"
22 #include "key_event.h"
23 #include "accessibility_event_info.h"
24 
25 using namespace testing;
26 using namespace testing::ext;
27 
28 namespace OHOS {
29 namespace Rosen {
30 using Mocker = SingletonMocker<WindowAdapter, MockWindowAdapter>;
31 class WindowTest : public testing::Test {
32 public:
33     static void SetUpTestCase();
34     static void TearDownTestCase();
35     virtual void SetUp() override;
36     virtual void TearDown() override;
37     static inline std::shared_ptr<AbilityRuntime::AbilityContext> abilityContext_;
38 };
SetUpTestCase()39 void WindowTest::SetUpTestCase()
40 {
41     abilityContext_ = std::make_shared<AbilityRuntime::AbilityContextImpl>();
42 }
43 
TearDownTestCase()44 void WindowTest::TearDownTestCase()
45 {
46 }
47 
SetUp()48 void WindowTest::SetUp()
49 {
50 }
51 
TearDown()52 void WindowTest::TearDown()
53 {
54 }
55 
56 namespace {
57 /**
58  * @tc.name: Create01
59  * @tc.desc: Create window with no WindowName and no abilityToken
60  * @tc.type: FUNC
61  */
62 HWTEST_F(WindowTest, Create01, Function | SmallTest | Level2)
63 {
64     sptr<WindowOption> option = new WindowOption();
65     ASSERT_EQ(nullptr, Window::Create("", option));
66 }
67 
68 /**
69  * @tc.name: Create02
70  * @tc.desc: Create window with WindowName and no abilityToken
71  * @tc.type: FUNC
72  */
73 HWTEST_F(WindowTest, Create02, Function | SmallTest | Level2)
74 {
75     std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
76     sptr<WindowOption> option = new WindowOption();
77     auto window = Window::Create("WindowTest02", option);
78     if (window != nullptr)
79     {
80         ASSERT_NE(nullptr, window);
81     }
82     if (window != nullptr)
83     {
84         ASSERT_EQ(WMError::WM_OK, window->Destroy());
85     }
86 }
87 
88 /**
89  * @tc.name: Create03
90  * @tc.desc: Mock CreateWindow return WM_ERROR_SAMGR, create window with WindowName and no abilityToken
91  * @tc.type: FUNC
92  */
93 HWTEST_F(WindowTest, Create03, Function | SmallTest | Level2)
94 {
95     std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
96     sptr<WindowOption> option = new WindowOption();
97     auto window = Window::Create("WindowTest03", option);
98     if (window != nullptr) {
99         ASSERT_EQ(nullptr, Window::Create("WindowTest03", option));
100     }
101 }
102 
103 /**
104  * @tc.name: Create04
105  * @tc.desc: Create window with WindowName and no option
106  * @tc.type: FUNC
107  */
108 HWTEST_F(WindowTest, Create04, Function | SmallTest | Level2)
109 {
110     sptr<WindowOption> option = nullptr;
111     ASSERT_EQ(nullptr, Window::Create("", option));
112 }
113 
114 /**
115  * @tc.name: CreatePiP
116  * @tc.desc: Create PiP window with option
117  * @tc.type: FUNC
118  */
119 HWTEST_F(WindowTest, CreatePiP, Function | SmallTest | Level2)
120 {
121     sptr<WindowOption> option = nullptr;
122     PiPTemplateInfo pipTemplateInfo;
123     ASSERT_EQ(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_));
124     option = new WindowOption();
125     ASSERT_EQ(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_));
126     option->SetWindowName("pip_window");
127     ASSERT_EQ(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_));
128     option->SetWindowType(WindowType::WINDOW_TYPE_PIP);
129     option->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
130     Rect rect = {0, 0, 10, 10};
131     option->SetWindowRect(rect);
132     WMError errCode;
133     if (SceneBoardJudgement::IsSceneBoardEnabled()) {
134         sptr<Window> window = Window::CreatePiP(option, pipTemplateInfo, abilityContext_, errCode);
135         if (errCode == WMError::WM_OK) {
136             ASSERT_NE(nullptr, window);
137         } else {
138             ASSERT_EQ(nullptr, window);
139         }
140     } else {
141         ASSERT_EQ(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_, errCode));
142     }
143 }
144 
145 /**
146  * @tc.name: Find01
147  * @tc.desc: Find with no name
148  * @tc.type: FUNC
149  */
150 HWTEST_F(WindowTest, Find01, Function | SmallTest | Level2)
151 {
152     ASSERT_EQ(nullptr, Window::Find(""));
153 }
154 
155 /**
156  * @tc.name: Find02
157  * @tc.desc: Find with name
158  * @tc.type: FUNC
159  */
160 HWTEST_F(WindowTest, Find02, Function | SmallTest | Level2)
161 {
162     std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
163     sptr<WindowOption> option = new WindowOption();
164 
165     auto window = Window::Create("WindowTest03", option);
166     if (window != nullptr) {
167         ASSERT_NE(nullptr, window);
168     }
169     if (Window::Find("WindowTest03") != nullptr) {
170         ASSERT_NE(nullptr, Window::Find("WindowTest03"));
171     }
172 
173     if (window != nullptr) {
174         ASSERT_EQ(WMError::WM_OK, window->Destroy());
175     }
176 }
177 
178 /**
179  * @tc.name: GetSurfaceNode
180  * @tc.desc: get node
181  * @tc.type: FUNC
182  */
183 HWTEST_F(WindowTest, GetSurfaceNode, Function | SmallTest | Level2)
184 {
185     sptr<Window> window = new Window();
186     ASSERT_NE(nullptr, window);
187     ASSERT_EQ(nullptr, window->GetSurfaceNode());
188     ASSERT_EQ(WMError::WM_OK, window->Destroy());
189 }
190 
191 /**
192  * @tc.name: GetContext
193  * @tc.desc: get context
194  * @tc.type: FUNC
195  */
196 HWTEST_F(WindowTest, GetContext, Function | SmallTest | Level2)
197 {
198     sptr<Window> window = new Window();
199     ASSERT_NE(nullptr, window);
200     ASSERT_EQ(nullptr, window->GetContext());
201     ASSERT_EQ(WMError::WM_OK, window->Destroy());
202 }
203 
204 /**
205  * @tc.name: GetRect
206  * @tc.desc: get rect
207  * @tc.type: FUNC
208  */
209 HWTEST_F(WindowTest, GetRect, Function | SmallTest | Level2)
210 {
211     sptr<Window> window = new Window();
212     ASSERT_NE(nullptr, window);
213     ASSERT_EQ(Rect(), window->GetRect());
214     ASSERT_EQ(WMError::WM_OK, window->Destroy());
215 }
216 
217 /**
218  * @tc.name: GetRequestRect
219  * @tc.desc: get rect
220  * @tc.type: FUNC
221  */
222 HWTEST_F(WindowTest, GetRequestRect, Function | SmallTest | Level2)
223 {
224     sptr<Window> window = new Window();
225     ASSERT_NE(nullptr, window);
226     ASSERT_EQ(Rect(), window->GetRequestRect());
227     ASSERT_EQ(WMError::WM_OK, window->Destroy());
228 }
229 
230 /**
231  * @tc.name: GetType
232  * @tc.desc: get type
233  * @tc.type: FUNC
234  */
235 HWTEST_F(WindowTest, GetType, Function | SmallTest | Level2)
236 {
237     sptr<Window> window = new Window();
238     ASSERT_NE(nullptr, window);
239     ASSERT_EQ(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, window->GetType());
240     ASSERT_EQ(WMError::WM_OK, window->Destroy());
241 }
242 
243 /**
244  * @tc.name: GetMode
245  * @tc.desc: get mode
246  * @tc.type: FUNC
247  */
248 HWTEST_F(WindowTest, GetMode, Function | SmallTest | Level2)
249 {
250     sptr<Window> window = new Window();
251     ASSERT_NE(nullptr, window);
252     ASSERT_EQ(WindowMode::WINDOW_MODE_UNDEFINED, window->GetMode());
253     ASSERT_EQ(WMError::WM_OK, window->Destroy());
254 
255     auto window_ = new (std::nothrow)Window();
256     ASSERT_NE(nullptr, window_);
257     ASSERT_EQ(WindowMode::WINDOW_MODE_UNDEFINED, window_->GetMode());
258 }
259 
260 /**
261  * @tc.name: GetAlpha
262  * @tc.desc: get alpha
263  * @tc.type: FUNC
264  */
265 HWTEST_F(WindowTest, GetAlpha, Function | SmallTest | Level2)
266 {
267     sptr<Window> window = new Window();
268     ASSERT_NE(nullptr, window);
269     ASSERT_EQ(0.0f, window->GetAlpha());
270     ASSERT_EQ(WMError::WM_OK, window->Destroy());
271 }
272 
273 /**
274  * @tc.name: GetFocusable
275  * @tc.desc: get focusable
276  * @tc.type: FUNC
277  */
278 HWTEST_F(WindowTest, GetFocusable, Function | SmallTest | Level2)
279 {
280     sptr<Window> window = new Window();
281     ASSERT_NE(nullptr, window);
282     ASSERT_EQ(false, window->GetFocusable());
283     ASSERT_EQ(WMError::WM_OK, window->Destroy());
284 }
285 
286 /**
287  * @tc.name: SetFocusable
288  * @tc.desc: set Focusable
289  * @tc.type: FUNC
290  */
291 HWTEST_F(WindowTest, SetFocusable, Function | SmallTest | Level2)
292 {
293     sptr<Window> window = new Window();
294     ASSERT_NE(nullptr, window);
295     ASSERT_EQ(WMError::WM_OK, window->SetFocusable(true));
296     ASSERT_EQ(WMError::WM_OK, window->Destroy());
297 }
298 
299 /**
300  * @tc.name: GetTouchable
301  * @tc.desc: get Touchable
302  * @tc.type: FUNC
303  */
304 HWTEST_F(WindowTest, GetTouchable, Function | SmallTest | Level2)
305 {
306     sptr<Window> window = new Window();
307     ASSERT_NE(nullptr, window);
308     ASSERT_EQ(false, window->GetTouchable());
309     ASSERT_EQ(WMError::WM_OK, window->Destroy());
310 }
311 
312 /**
313  * @tc.name: SetTouchable
314  * @tc.desc: set Touchable
315  * @tc.type: FUNC
316  */
317 HWTEST_F(WindowTest, SetTouchable, Function | SmallTest | Level2)
318 {
319     sptr<Window> window = new Window();
320     ASSERT_NE(nullptr, window);
321     ASSERT_EQ(WMError::WM_OK, window->SetTouchable(true));
322     ASSERT_EQ(WMError::WM_OK, window->Destroy());
323 }
324 
325 /**
326  * @tc.name: GetSystemBarPropertyByType
327  * @tc.desc: get SystemBarPropertyByType
328  * @tc.type: FUNC
329  */
330 HWTEST_F(WindowTest, GetSystemBarPropertyByType, Function | SmallTest | Level2)
331 {
332     sptr<Window> window = new Window();
333     ASSERT_NE(nullptr, window);
334     ASSERT_EQ(SystemBarProperty(), window->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW));
335     ASSERT_EQ(WMError::WM_OK, window->Destroy());
336 }
337 
338 /**
339  * @tc.name: SetSystemBarProperty
340  * @tc.desc: set SystemBarProperty
341  * @tc.type: FUNC
342  */
343 HWTEST_F(WindowTest, SetSystemBarProperty, Function | SmallTest | Level2)
344 {
345     sptr<Window> window = new Window();
346     SystemBarProperty prop;
347     ASSERT_NE(nullptr, window);
348     auto ret = window->SetSystemBarProperty(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, prop);
349     ASSERT_EQ(WMError::WM_OK, ret);
350     ASSERT_EQ(WMError::WM_OK, window->Destroy());
351 }
352 
353 /**
354  * @tc.name: IsFullScreen
355  * @tc.desc: get FullScreen
356  * @tc.type: FUNC
357  */
358 HWTEST_F(WindowTest, IsFullScreen, Function | SmallTest | Level2)
359 {
360     sptr<Window> window = new Window();
361     ASSERT_NE(nullptr, window);
362     ASSERT_EQ(false, window->IsFullScreen());
363     ASSERT_EQ(WMError::WM_OK, window->Destroy());
364 }
365 
366 /**
367  * @tc.name: IsLayoutFullScreen
368  * @tc.desc: get
369  * @tc.type: FUNC
370  */
371 HWTEST_F(WindowTest, IsLayoutFullScreen, Function | SmallTest | Level2)
372 {
373     sptr<Window> window = new Window();
374     ASSERT_NE(nullptr, window);
375     ASSERT_EQ(false, window->IsLayoutFullScreen());
376     ASSERT_EQ(WMError::WM_OK, window->Destroy());
377 }
378 
379 /**
380  * @tc.name: SetAlpha
381  * @tc.desc: set
382  * @tc.type: FUNC
383  */
384 HWTEST_F(WindowTest, SetAlpha, Function | SmallTest | Level2)
385 {
386     sptr<Window> window = new Window();
387     ASSERT_NE(nullptr, window);
388     ASSERT_EQ(WMError::WM_OK, window->SetAlpha(0.0f));
389     ASSERT_EQ(WMError::WM_OK, window->Destroy());
390 }
391 
392 /**
393  * @tc.name: SetTransform
394  * @tc.desc: set
395  * @tc.type: FUNC
396  */
397 HWTEST_F(WindowTest, SetTransform, Function | SmallTest | Level2)
398 {
399     sptr<Window> window = new Window();
400     ASSERT_NE(nullptr, window);
401     Transform trans;
402     ASSERT_EQ(WMError::WM_OK, window->SetTransform(trans));
403     ASSERT_EQ(WMError::WM_OK, window->Destroy());
404 }
405 
406 /**
407  * @tc.name: GetTransform
408  * @tc.desc: get
409  * @tc.type: FUNC
410  */
411 HWTEST_F(WindowTest, GetTransform, Function | SmallTest | Level2)
412 {
413     sptr<Window> window = new Window();
414     ASSERT_NE(nullptr, window);
415     Transform trans;
416     ASSERT_EQ(trans, window->GetTransform());
417     ASSERT_EQ(WMError::WM_OK, window->Destroy());
418 }
419 
420 /**
421  * @tc.name: GetAvoidAreaByType
422  * @tc.desc: get
423  * @tc.type: FUNC
424  */
425 HWTEST_F(WindowTest, GetAvoidAreaByType, Function | SmallTest | Level2)
426 {
427     sptr<Window> window = new Window();
428     ASSERT_NE(nullptr, window);
429     AvoidArea avoidArea;
430     auto ret = window->GetAvoidAreaByType(AvoidAreaType::TYPE_CUTOUT, avoidArea);
431     ASSERT_EQ(WMError::WM_OK, ret);
432     ASSERT_EQ(WMError::WM_OK, window->Destroy());
433 }
434 
435 /**
436  * @tc.name: SetImmersiveModeEnabledState
437  * @tc.desc: get
438  * @tc.type: FUNC
439  */
440 HWTEST_F(WindowTest, SetImmersiveModeEnabledState, Function | SmallTest | Level2)
441 {
442     sptr<Window> window = new Window();
443     ASSERT_NE(nullptr, window);
444     auto ret = window->SetImmersiveModeEnabledState(true);
445     ASSERT_EQ(WMError::WM_OK, ret);
446     ASSERT_EQ(WMError::WM_OK, window->Destroy());
447 }
448 
449 /**
450  * @tc.name: SetLayoutFullScreen
451  * @tc.desc: get
452  * @tc.type: FUNC
453  */
454 HWTEST_F(WindowTest, SetLayoutFullScreen, Function | SmallTest | Level2)
455 {
456     sptr<Window> window = new Window();
457     ASSERT_NE(nullptr, window);
458     auto ret = window->SetLayoutFullScreen(true);
459     ASSERT_EQ(WMError::WM_OK, ret);
460     ASSERT_EQ(WMError::WM_OK, window->Destroy());
461 }
462 
463 /**
464  * @tc.name: SetTitleAndDockHoverShown
465  * @tc.desc: get
466  * @tc.type: FUNC
467  */
468 HWTEST_F(WindowTest, SetTitleAndDockHoverShown, Function | SmallTest | Level2)
469 {
470     sptr<Window> window = sptr<Window>::MakeSptr();
471     ASSERT_NE(nullptr, window);
472     auto ret = window->SetTitleAndDockHoverShown(true, true);
473     EXPECT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ret);
474     EXPECT_EQ(WMError::WM_OK, window->Destroy());
475 }
476 
477 /**
478  * @tc.name: SetFullScreen
479  * @tc.desc: get
480  * @tc.type: FUNC
481  */
482 HWTEST_F(WindowTest, SetFullScreen, Function | SmallTest | Level2)
483 {
484     sptr<Window> window = new Window();
485     ASSERT_NE(nullptr, window);
486     auto ret = window->SetFullScreen(true);
487     ASSERT_EQ(WMError::WM_OK, ret);
488     ASSERT_EQ(WMError::WM_OK, window->Destroy());
489 }
490 
491 /**
492  * @tc.name: Destroy
493  * @tc.desc: get
494  * @tc.type: FUNC
495  */
496 HWTEST_F(WindowTest, Destroy, Function | SmallTest | Level2)
497 {
498     sptr<Window> window = new Window();
499     ASSERT_NE(nullptr, window);
500     auto ret = window->Destroy();
501     ASSERT_EQ(WMError::WM_OK, ret);
502     ASSERT_EQ(WMError::WM_OK, window->Destroy());
503 }
504 
505 /**
506  * @tc.name: Show
507  * @tc.desc: get
508  * @tc.type: FUNC
509  */
510 HWTEST_F(WindowTest, Show, Function | SmallTest | Level2)
511 {
512     sptr<Window> window = new Window();
513     ASSERT_NE(nullptr, window);
514     auto ret = window->Show();
515     ASSERT_EQ(WMError::WM_OK, ret);
516     ASSERT_EQ(WMError::WM_OK, window->Destroy());
517 }
518 
519 /**
520  * @tc.name: Hide
521  * @tc.desc: get
522  * @tc.type: FUNC
523  */
524 HWTEST_F(WindowTest, Hide, Function | SmallTest | Level2)
525 {
526     sptr<Window> window = new Window();
527     ASSERT_NE(nullptr, window);
528     auto ret = window->Hide();
529     ASSERT_EQ(WMError::WM_OK, ret);
530     ASSERT_EQ(WMError::WM_OK, window->Destroy());
531 }
532 
533 /**
534  * @tc.name: MoveTo
535  * @tc.desc: get
536  * @tc.type: FUNC
537  */
538 HWTEST_F(WindowTest, MoveTo, Function | SmallTest | Level2)
539 {
540     sptr<Window> window = new Window();
541     ASSERT_NE(nullptr, window);
542     auto ret = window->MoveTo(0, 0);
543     ASSERT_EQ(WMError::WM_OK, ret);
544     ASSERT_EQ(WMError::WM_OK, window->Destroy());
545 }
546 
547 /**
548  * @tc.name: Resize
549  * @tc.desc: get
550  * @tc.type: FUNC
551  */
552 HWTEST_F(WindowTest, Resize, Function | SmallTest | Level2)
553 {
554     sptr<Window> window = new Window();
555     ASSERT_NE(nullptr, window);
556     auto ret = window->Resize(0, 0);
557     ASSERT_EQ(WMError::WM_OK, ret);
558     ASSERT_EQ(WMError::WM_OK, window->Destroy());
559 }
560 
561 /**
562  * @tc.name: SetKeepScreenOn
563  * @tc.desc: get
564  * @tc.type: FUNC
565  */
566 HWTEST_F(WindowTest, SetKeepScreenOn, Function | SmallTest | Level2)
567 {
568     sptr<Window> window = new Window();
569     ASSERT_NE(nullptr, window);
570     auto ret = window->SetKeepScreenOn(true);
571     ASSERT_EQ(WMError::WM_OK, ret);
572     ASSERT_EQ(WMError::WM_OK, window->Destroy());
573 }
574 
575 /**
576  * @tc.name: IsKeepScreenOn
577  * @tc.desc: get
578  * @tc.type: FUNC
579  */
580 HWTEST_F(WindowTest, IsKeepScreenOn, Function | SmallTest | Level2)
581 {
582     sptr<Window> window = new Window();
583     ASSERT_NE(nullptr, window);
584     auto ret = window->IsKeepScreenOn();
585     ASSERT_EQ(false, ret);
586     ASSERT_EQ(WMError::WM_OK, window->Destroy());
587 }
588 
589 /**
590  * @tc.name: SetTurnScreenOn
591  * @tc.desc: get
592  * @tc.type: FUNC
593  */
594 HWTEST_F(WindowTest, SetTurnScreenOn, Function | SmallTest | Level2)
595 {
596     sptr<Window> window = new Window();
597     ASSERT_NE(nullptr, window);
598     auto ret = window->SetTurnScreenOn(true);
599     ASSERT_EQ(WMError::WM_OK, ret);
600     ASSERT_EQ(WMError::WM_OK, window->Destroy());
601 }
602 
603 /**
604  * @tc.name: IsTurnScreenOn
605  * @tc.desc: get
606  * @tc.type: FUNC
607  */
608 HWTEST_F(WindowTest, IsTurnScreenOn, Function | SmallTest | Level2)
609 {
610     sptr<Window> window = new Window();
611     ASSERT_NE(nullptr, window);
612     auto ret = window->IsTurnScreenOn();
613     ASSERT_EQ(false, ret);
614     ASSERT_EQ(WMError::WM_OK, window->Destroy());
615 }
616 
617 /**
618  * @tc.name: SetBackgroundColor
619  * @tc.desc: get
620  * @tc.type: FUNC
621  */
622 HWTEST_F(WindowTest, SetBackgroundColor, Function | SmallTest | Level2)
623 {
624     sptr<Window> window = new Window();
625     ASSERT_NE(nullptr, window);
626     auto ret = window->SetBackgroundColor("0x00000000");
627     ASSERT_EQ(WMError::WM_OK, ret);
628     ASSERT_EQ(WMError::WM_OK, window->Destroy());
629 }
630 
631 /**
632  * @tc.name: SetTransparent
633  * @tc.desc: get
634  * @tc.type: FUNC
635  */
636 HWTEST_F(WindowTest, SetTransparent, Function | SmallTest | Level2)
637 {
638     sptr<Window> window = new Window();
639     ASSERT_NE(nullptr, window);
640     auto ret = window->SetTransparent(true);
641     ASSERT_EQ(WMError::WM_OK, ret);
642     ASSERT_EQ(WMError::WM_OK, window->Destroy());
643 }
644 
645 /**
646  * @tc.name: IsTransparent
647  * @tc.desc: get
648  * @tc.type: FUNC
649  */
650 HWTEST_F(WindowTest, IsTransparent, Function | SmallTest | Level2)
651 {
652     sptr<Window> window = new Window();
653     ASSERT_NE(nullptr, window);
654     auto ret = window->IsTransparent();
655     ASSERT_EQ(false, ret);
656     ASSERT_EQ(WMError::WM_OK, window->Destroy());
657 }
658 
659 /**
660  * @tc.name: SetBrightness
661  * @tc.desc: get
662  * @tc.type: FUNC
663  */
664 HWTEST_F(WindowTest, SetBrightness, Function | SmallTest | Level2)
665 {
666     sptr<Window> window = new Window();
667     ASSERT_NE(nullptr, window);
668     auto ret = window->SetBrightness(0.0f);
669     ASSERT_EQ(WMError::WM_OK, ret);
670     ASSERT_EQ(WMError::WM_OK, window->Destroy());
671 }
672 
673 /**
674  * @tc.name: GetBrightness
675  * @tc.desc: get
676  * @tc.type: FUNC
677  */
678 HWTEST_F(WindowTest, GetBrightness, Function | SmallTest | Level2)
679 {
680     sptr<Window> window = new Window();
681     ASSERT_NE(nullptr, window);
682     auto ret = window->GetBrightness();
683     ASSERT_EQ(0.0f, ret);
684     ASSERT_EQ(WMError::WM_OK, window->Destroy());
685 }
686 
687 /**
688  * @tc.name: SetPrivacyMode
689  * @tc.desc: get
690  * @tc.type: FUNC
691  */
692 HWTEST_F(WindowTest, SetPrivacyMode, Function | SmallTest | Level2)
693 {
694     sptr<Window> window = new Window();
695     ASSERT_NE(nullptr, window);
696     auto ret = window->SetPrivacyMode(0.0f);
697     ASSERT_EQ(WMError::WM_OK, ret);
698     ASSERT_EQ(WMError::WM_OK, window->Destroy());
699 }
700 
701 /**
702  * @tc.name: IsPrivacyMode
703  * @tc.desc: get
704  * @tc.type: FUNC
705  */
706 HWTEST_F(WindowTest, IsPrivacyMode, Function | SmallTest | Level2)
707 {
708     sptr<Window> window = new Window();
709     ASSERT_NE(nullptr, window);
710     auto ret = window->IsPrivacyMode();
711     ASSERT_EQ(false, ret);
712     ASSERT_EQ(WMError::WM_OK, window->Destroy());
713 }
714 
715 /**
716  * @tc.name: SetSystemPrivacyMode
717  * @tc.desc: get
718  * @tc.type: FUNC
719  */
720 HWTEST_F(WindowTest, SetSystemPrivacyMode, Function | SmallTest | Level2)
721 {
722     sptr<Window> window = new Window();
723     ASSERT_NE(nullptr, window);
724     auto ret = false;
725     window->SetSystemPrivacyMode(true);
726     ASSERT_EQ(false, ret);
727     ASSERT_EQ(WMError::WM_OK, window->Destroy());
728 }
729 
730 /**
731  * @tc.name: BindDialogTarget
732  * @tc.desc: get
733  * @tc.type: FUNC
734  */
735 HWTEST_F(WindowTest, BindDialogTarget, Function | SmallTest | Level2)
736 {
737     sptr<Window> window = new Window();
738     ASSERT_NE(nullptr, window);
739     sptr<IRemoteObject> targetToken;
740     auto ret = window->BindDialogTarget(targetToken);
741     ASSERT_EQ(WMError::WM_OK, ret);
742     ASSERT_EQ(WMError::WM_OK, window->Destroy());
743 }
744 
745 /**
746  * @tc.name: RaiseToAppTop
747  * @tc.desc: get
748  * @tc.type: FUNC
749  */
750 HWTEST_F(WindowTest, RaiseToAppTop, Function | SmallTest | Level2)
751 {
752     sptr<Window> window = new Window();
753     ASSERT_NE(nullptr, window);
754     auto ret = window->RaiseToAppTop();
755     ASSERT_EQ(WMError::WM_OK, ret);
756     ASSERT_EQ(WMError::WM_OK, window->Destroy());
757 }
758 
759 /**
760  * @tc.name: SetSnapshotSkip
761  * @tc.desc: get
762  * @tc.type: FUNC
763  */
764 HWTEST_F(WindowTest, SetSnapshotSkip, Function | SmallTest | Level2)
765 {
766     sptr<Window> window = new Window();
767     ASSERT_NE(nullptr, window);
768     auto ret = window->SetSnapshotSkip(true);
769     ASSERT_EQ(WMError::WM_OK, ret);
770     ASSERT_EQ(WMError::WM_OK, window->Destroy());
771 }
772 
773 /**
774  * @tc.name: SetCornerRadius
775  * @tc.desc: get
776  * @tc.type: FUNC
777  */
778 HWTEST_F(WindowTest, SetCornerRadius, Function | SmallTest | Level2)
779 {
780     sptr<Window> window = new Window();
781     ASSERT_NE(nullptr, window);
782     auto ret = window->SetCornerRadius(1.0f);
783     ASSERT_EQ(WMError::WM_OK, ret);
784     ASSERT_EQ(WMError::WM_OK, window->Destroy());
785 }
786 
787 /**
788  * @tc.name: SetShadowRadius
789  * @tc.desc: get
790  * @tc.type: FUNC
791  */
792 HWTEST_F(WindowTest, SetShadowRadius, Function | SmallTest | Level2)
793 {
794     sptr<Window> window = new Window();
795     ASSERT_NE(nullptr, window);
796     auto ret = window->SetShadowRadius(1.0f);
797     ASSERT_EQ(WMError::WM_OK, ret);
798     ASSERT_EQ(WMError::WM_OK, window->Destroy());
799 }
800 
801 /**
802  * @tc.name: SetShadowColor
803  * @tc.desc: get
804  * @tc.type: FUNC
805  */
806 HWTEST_F(WindowTest, SetShadowColor, Function | SmallTest | Level2)
807 {
808     sptr<Window> window = new Window();
809     ASSERT_NE(nullptr, window);
810     auto ret = window->SetShadowColor("0x00000000");
811     ASSERT_EQ(WMError::WM_OK, ret);
812     ASSERT_EQ(WMError::WM_OK, window->Destroy());
813 }
814 
815 /**
816  * @tc.name: SetShadowOffsetX
817  * @tc.desc: get
818  * @tc.type: FUNC
819  */
820 HWTEST_F(WindowTest, SetShadowOffsetX, Function | SmallTest | Level2)
821 {
822     sptr<Window> window = new Window();
823     ASSERT_NE(nullptr, window);
824     auto ret = window->SetShadowOffsetX(0.0f);
825     ASSERT_EQ(WMError::WM_OK, ret);
826     ASSERT_EQ(WMError::WM_OK, window->Destroy());
827 }
828 
829 /**
830  * @tc.name: SetShadowOffsetY
831  * @tc.desc: get
832  * @tc.type: FUNC
833  */
834 HWTEST_F(WindowTest, SetShadowOffsetY, Function | SmallTest | Level2)
835 {
836     sptr<Window> window = new Window();
837     ASSERT_NE(nullptr, window);
838     auto ret = window->SetShadowOffsetY(0.0f);
839     ASSERT_EQ(WMError::WM_OK, ret);
840     ASSERT_EQ(WMError::WM_OK, window->Destroy());
841 }
842 
843 /**
844  * @tc.name: SetBlur
845  * @tc.desc: get
846  * @tc.type: FUNC
847  */
848 HWTEST_F(WindowTest, SetBlur, Function | SmallTest | Level2)
849 {
850     sptr<Window> window = new Window();
851     ASSERT_NE(nullptr, window);
852     auto ret = window->SetBlur(0.0f);
853     ASSERT_EQ(WMError::WM_OK, ret);
854     ASSERT_EQ(WMError::WM_OK, window->Destroy());
855 }
856 
857 /**
858  * @tc.name: SetBackdropBlur
859  * @tc.desc: get
860  * @tc.type: FUNC
861  */
862 HWTEST_F(WindowTest, SetBackdropBlur, Function | SmallTest | Level2)
863 {
864     sptr<Window> window = new Window();
865     ASSERT_NE(nullptr, window);
866     auto ret = window->SetBackdropBlur(0.0f);
867     ASSERT_EQ(WMError::WM_OK, ret);
868     ASSERT_EQ(WMError::WM_OK, window->Destroy());
869 }
870 
871 /**
872  * @tc.name: SetBackdropBlurStyle
873  * @tc.desc: get
874  * @tc.type: FUNC
875  */
876 HWTEST_F(WindowTest, SetBackdropBlurStyle, Function | SmallTest | Level2)
877 {
878     sptr<Window> window = new Window();
879     ASSERT_NE(nullptr, window);
880     auto ret = window->SetBackdropBlurStyle(WindowBlurStyle::WINDOW_BLUR_OFF);
881     ASSERT_EQ(WMError::WM_OK, ret);
882     ASSERT_EQ(WMError::WM_OK, window->Destroy());
883 }
884 
885 /**
886  * @tc.name: RequestFocus
887  * @tc.desc: get
888  * @tc.type: FUNC
889  */
890 HWTEST_F(WindowTest, RequestFocus, Function | SmallTest | Level2)
891 {
892     sptr<Window> window = new Window();
893     ASSERT_NE(nullptr, window);
894     auto ret = window->RequestFocus();
895     ASSERT_EQ(WMError::WM_OK, ret);
896     ASSERT_EQ(WMError::WM_OK, window->Destroy());
897 }
898 
899 /**
900  * @tc.name: IsFocused
901  * @tc.desc: get
902  * @tc.type: FUNC
903  */
904 HWTEST_F(WindowTest, IsFocused, Function | SmallTest | Level2)
905 {
906     sptr<Window> window = new Window();
907     ASSERT_NE(nullptr, window);
908     auto ret = window->IsFocused();
909     ASSERT_EQ(false, ret);
910     ASSERT_EQ(WMError::WM_OK, window->Destroy());
911 }
912 
913 /**
914  * @tc.name: UpdateSurfaceNodeAfterCustomAnimation
915  * @tc.desc: get
916  * @tc.type: FUNC
917  */
918 HWTEST_F(WindowTest, UpdateSurfaceNodeAfterCustomAnimation, Function | SmallTest | Level2)
919 {
920     sptr<Window> window = new Window();
921     ASSERT_NE(nullptr, window);
922     auto ret = window->UpdateSurfaceNodeAfterCustomAnimation(false);
923     ASSERT_EQ(WMError::WM_OK, ret);
924     ASSERT_EQ(WMError::WM_OK, window->Destroy());
925 }
926 
927 /**
928  * @tc.name: SetInputEventConsumer
929  * @tc.desc: get
930  * @tc.type: FUNC
931  */
932 HWTEST_F(WindowTest, SetInputEventConsumer, Function | SmallTest | Level2)
933 {
934     sptr<Window> window = new Window();
935     ASSERT_NE(nullptr, window);
936     auto ret = true;
937     std::shared_ptr<IInputEventConsumer> inputEventConsumer;
938     window->SetInputEventConsumer(inputEventConsumer);
939     ASSERT_EQ(true, ret);
940     ASSERT_EQ(WMError::WM_OK, window->Destroy());
941 }
942 
943 /**
944  * @tc.name: ConsumeKeyEvent
945  * @tc.desc: get
946  * @tc.type: FUNC
947  */
948 HWTEST_F(WindowTest, ConsumeKeyEvent, Function | SmallTest | Level2)
949 {
950     sptr<Window> window = new Window();
951     ASSERT_NE(nullptr, window);
952     auto ret = WMError::WM_OK;
953     std::shared_ptr<MMI::KeyEvent> inputEvent = nullptr;
954     window->ConsumeKeyEvent(inputEvent);
955     ASSERT_EQ(WMError::WM_OK, ret);
956     ASSERT_EQ(WMError::WM_OK, window->Destroy());
957 }
958 
959 /**
960  * @tc.name: PreNotifyKeyEvent
961  * @tc.desc: get
962  * @tc.type: FUNC
963  */
964 HWTEST_F(WindowTest, PreNotifyKeyEvent, Function | SmallTest | Level2)
965 {
966     sptr<Window> window = new Window();
967     ASSERT_NE(nullptr, window);
968     auto ret = WMError::WM_OK;
969     std::shared_ptr<MMI::KeyEvent> inputEvent = nullptr;
970     window->PreNotifyKeyEvent(inputEvent);
971     ASSERT_EQ(WMError::WM_OK, ret);
972     ASSERT_EQ(WMError::WM_OK, window->Destroy());
973 }
974 
975 /**
976  * @tc.name: ConsumePointerEvent
977  * @tc.desc: get
978  * @tc.type: FUNC
979  */
980 HWTEST_F(WindowTest, ConsumePointerEvent, Function | SmallTest | Level2)
981 {
982     sptr<Window> window = new Window();
983     ASSERT_NE(nullptr, window);
984     auto ret = WMError::WM_OK;
985     std::shared_ptr<MMI::PointerEvent> inputEvent = nullptr;
986     window->ConsumePointerEvent(inputEvent);
987     ASSERT_EQ(WMError::WM_OK, ret);
988     ASSERT_EQ(WMError::WM_OK, window->Destroy());
989 }
990 
991 /**
992  * @tc.name: RequestVsync
993  * @tc.desc: get
994  * @tc.type: FUNC
995  */
996 HWTEST_F(WindowTest, RequestVsync, Function | SmallTest | Level2)
997 {
998     sptr<Window> window = new Window();
999     ASSERT_NE(nullptr, window);
1000     std::shared_ptr<VsyncCallback> vsyncCallback = nullptr;
1001     auto ret = WMError::WM_OK;
1002     window->RequestVsync(vsyncCallback);
1003     // no return
1004     ASSERT_EQ(WMError::WM_OK, ret);
1005     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1006 }
1007 
1008 /**
1009  * @tc.name: UpdateConfiguration
1010  * @tc.desc: get
1011  * @tc.type: FUNC
1012  */
1013 HWTEST_F(WindowTest, UpdateConfiguration, Function | SmallTest | Level2)
1014 {
1015     sptr<Window> window = new Window();
1016     ASSERT_NE(nullptr, window);
1017     std::shared_ptr<AppExecFwk::Configuration> conf = nullptr;
1018     auto ret = WMError::WM_OK;
1019     window->UpdateConfiguration(conf);
1020     // no return
1021     ASSERT_EQ(WMError::WM_OK, ret);
1022     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1023 }
1024 
1025 /**
1026  * @tc.name: RegisterLifeCycleListener
1027  * @tc.desc: get
1028  * @tc.type: FUNC
1029  */
1030 HWTEST_F(WindowTest, RegisterLifeCycleListener, Function | SmallTest | Level2)
1031 {
1032     sptr<Window> window = new Window();
1033     ASSERT_NE(nullptr, window);
1034     sptr<IWindowLifeCycle> listener = nullptr;
1035     auto ret = window->RegisterLifeCycleListener(listener);
1036     ASSERT_EQ(WMError::WM_OK, ret);
1037     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1038 }
1039 
1040 /**
1041  * @tc.name: UnregisterLifeCycleListener
1042  * @tc.desc: get
1043  * @tc.type: FUNC
1044  */
1045 HWTEST_F(WindowTest, UnregisterLifeCycleListener, Function | SmallTest | Level2)
1046 {
1047     sptr<Window> window = new Window();
1048     ASSERT_NE(nullptr, window);
1049     sptr<IWindowLifeCycle> listener = nullptr;
1050     auto ret = window->UnregisterLifeCycleListener(listener);
1051     ASSERT_EQ(WMError::WM_OK, ret);
1052     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1053 }
1054 
1055 /**
1056  * @tc.name: RegisterWindowChangeListener
1057  * @tc.desc: get
1058  * @tc.type: FUNC
1059  */
1060 HWTEST_F(WindowTest, RegisterWindowChangeListener, Function | SmallTest | Level2)
1061 {
1062     sptr<Window> window = new Window();
1063     ASSERT_NE(nullptr, window);
1064     sptr<IWindowChangeListener> listener = nullptr;
1065     auto ret = window->RegisterWindowChangeListener(listener);
1066     ASSERT_EQ(WMError::WM_OK, ret);
1067     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1068 }
1069 
1070 /**
1071  * @tc.name: UnregisterWindowChangeListener
1072  * @tc.desc: get
1073  * @tc.type: FUNC
1074  */
1075 HWTEST_F(WindowTest, UnregisterWindowChangeListener, Function | SmallTest | Level2)
1076 {
1077     sptr<Window> window = new Window();
1078     ASSERT_NE(nullptr, window);
1079     sptr<IWindowChangeListener> listener = nullptr;
1080     auto ret = window->UnregisterWindowChangeListener(listener);
1081     ASSERT_EQ(WMError::WM_OK, ret);
1082     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1083 }
1084 
1085 /**
1086  * @tc.name: RegisterAvoidAreaChangeListener
1087  * @tc.desc: get
1088  * @tc.type: FUNC
1089  */
1090 HWTEST_F(WindowTest, RegisterAvoidAreaChangeListener, Function | SmallTest | Level2)
1091 {
1092     sptr<Window> window = new Window();
1093     ASSERT_NE(nullptr, window);
1094     sptr<IAvoidAreaChangedListener> listener = nullptr;
1095     auto ret = window->RegisterAvoidAreaChangeListener(listener);
1096     ASSERT_EQ(WMError::WM_OK, ret);
1097     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1098 }
1099 
1100 /**
1101  * @tc.name: UnregisterAvoidAreaChangeListener
1102  * @tc.desc: get
1103  * @tc.type: FUNC
1104  */
1105 HWTEST_F(WindowTest, UnregisterAvoidAreaChangeListener, Function | SmallTest | Level2)
1106 {
1107     sptr<Window> window = new Window();
1108     ASSERT_NE(nullptr, window);
1109     sptr<IAvoidAreaChangedListener> listener = nullptr;
1110     auto ret = window->UnregisterAvoidAreaChangeListener(listener);
1111     ASSERT_EQ(WMError::WM_OK, ret);
1112     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1113 }
1114 
1115 /**
1116  * @tc.name: RegisterDragListener
1117  * @tc.desc: get
1118  * @tc.type: FUNC
1119  */
1120 HWTEST_F(WindowTest, RegisterDragListener, Function | SmallTest | Level2)
1121 {
1122     sptr<Window> window = new Window();
1123     ASSERT_NE(nullptr, window);
1124     sptr<IWindowDragListener> listener = nullptr;
1125     auto ret = window->RegisterDragListener(listener);
1126     ASSERT_EQ(WMError::WM_OK, ret);
1127     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1128 }
1129 
1130 /**
1131  * @tc.name: UnregisterDragListener
1132  * @tc.desc: get
1133  * @tc.type: FUNC
1134  */
1135 HWTEST_F(WindowTest, UnregisterDragListener, Function | SmallTest | Level2)
1136 {
1137     sptr<Window> window = new Window();
1138     ASSERT_NE(nullptr, window);
1139     sptr<IWindowDragListener> listener = nullptr;
1140     auto ret = window->UnregisterDragListener(listener);
1141     ASSERT_EQ(WMError::WM_OK, ret);
1142     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1143 }
1144 
1145 /**
1146  * @tc.name: RegisterDisplayMoveListener
1147  * @tc.desc: get
1148  * @tc.type: FUNC
1149  */
1150 HWTEST_F(WindowTest, RegisterDisplayMoveListener, Function | SmallTest | Level2)
1151 {
1152     sptr<Window> window = new Window();
1153     ASSERT_NE(nullptr, window);
1154     sptr<IDisplayMoveListener> listener = nullptr;
1155     auto ret = window->RegisterDisplayMoveListener(listener);
1156     ASSERT_EQ(WMError::WM_OK, ret);
1157     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1158 }
1159 
1160 /**
1161  * @tc.name: UnregisterDisplayMoveListener
1162  * @tc.desc: get
1163  * @tc.type: FUNC
1164  */
1165 HWTEST_F(WindowTest, UnregisterDisplayMoveListener, Function | SmallTest | Level2)
1166 {
1167     sptr<Window> window = new Window();
1168     ASSERT_NE(nullptr, window);
1169     sptr<IDisplayMoveListener> listener = nullptr;
1170     auto ret = window->UnregisterDisplayMoveListener(listener);
1171     ASSERT_EQ(WMError::WM_OK, ret);
1172     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1173 }
1174 
1175 /**
1176  * @tc.name: RegisterWindowDestroyedListener
1177  * @tc.desc: get
1178  * @tc.type: FUNC
1179  */
1180 HWTEST_F(WindowTest, RegisterWindowDestroyedListener, Function | SmallTest | Level2)
1181 {
1182     sptr<Window> window = new Window();
1183     ASSERT_NE(nullptr, window);
1184     NotifyNativeWinDestroyFunc func = nullptr;
1185     auto ret = WMError::WM_OK;
1186     window->RegisterWindowDestroyedListener(func);
1187     // no return
1188     ASSERT_EQ(WMError::WM_OK, ret);
1189     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1190 }
1191 
1192 /**
1193  * @tc.name: RegisterOccupiedAreaChangeListener
1194  * @tc.desc: get
1195  * @tc.type: FUNC
1196  */
1197 HWTEST_F(WindowTest, RegisterOccupiedAreaChangeListener, Function | SmallTest | Level2)
1198 {
1199     sptr<Window> window = new Window();
1200     ASSERT_NE(nullptr, window);
1201     sptr<IOccupiedAreaChangeListener> listener = nullptr;
1202     auto ret = window->RegisterOccupiedAreaChangeListener(listener);
1203     ASSERT_EQ(WMError::WM_OK, ret);
1204     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1205 }
1206 
1207 /**
1208  * @tc.name: UnregisterOccupiedAreaChangeListener
1209  * @tc.desc: get
1210  * @tc.type: FUNC
1211  */
1212 HWTEST_F(WindowTest, UnregisterOccupiedAreaChangeListener, Function | SmallTest | Level2)
1213 {
1214     sptr<Window> window = new Window();
1215     ASSERT_NE(nullptr, window);
1216     sptr<IOccupiedAreaChangeListener> listener = nullptr;
1217     auto ret = window->UnregisterOccupiedAreaChangeListener(listener);
1218     ASSERT_EQ(WMError::WM_OK, ret);
1219     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1220 }
1221 
1222 /**
1223  * @tc.name: RegisterTouchOutsideListener
1224  * @tc.desc: get
1225  * @tc.type: FUNC
1226  */
1227 HWTEST_F(WindowTest, RegisterTouchOutsideListener, Function | SmallTest | Level2)
1228 {
1229     sptr<Window> window = new Window();
1230     ASSERT_NE(nullptr, window);
1231     sptr<ITouchOutsideListener> listener = nullptr;
1232     auto ret = window->RegisterTouchOutsideListener(listener);
1233     ASSERT_EQ(WMError::WM_OK, ret);
1234     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1235 }
1236 
1237 /**
1238  * @tc.name: UnregisterTouchOutsideListener
1239  * @tc.desc: get
1240  * @tc.type: FUNC
1241  */
1242 HWTEST_F(WindowTest, UnregisterTouchOutsideListener, Function | SmallTest | Level2)
1243 {
1244     sptr<Window> window = new Window();
1245     ASSERT_NE(nullptr, window);
1246     sptr<ITouchOutsideListener> listener = nullptr;
1247     auto ret = window->UnregisterTouchOutsideListener(listener);
1248     ASSERT_EQ(WMError::WM_OK, ret);
1249     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1250 }
1251 
1252 /**
1253  * @tc.name: RegisterAnimationTransitionController
1254  * @tc.desc: get
1255  * @tc.type: FUNC
1256  */
1257 HWTEST_F(WindowTest, RegisterAnimationTransitionController, Function | SmallTest | Level2)
1258 {
1259     sptr<Window> window = new Window();
1260     ASSERT_NE(nullptr, window);
1261     sptr<IAnimationTransitionController> listener = nullptr;
1262     auto ret = window->RegisterAnimationTransitionController(listener);
1263     ASSERT_EQ(WMError::WM_OK, ret);
1264     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1265 }
1266 
1267 /**
1268  * @tc.name: RegisterScreenshotListener
1269  * @tc.desc: get
1270  * @tc.type: FUNC
1271  */
1272 HWTEST_F(WindowTest, RegisterScreenshotListener, Function | SmallTest | Level2)
1273 {
1274     sptr<Window> window = new Window();
1275     ASSERT_NE(nullptr, window);
1276     sptr<IScreenshotListener> listener = nullptr;
1277     auto ret = window->RegisterScreenshotListener(listener);
1278     ASSERT_EQ(WMError::WM_OK, ret);
1279     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1280 }
1281 
1282 /**
1283  * @tc.name: UnregisterScreenshotListener
1284  * @tc.desc: get
1285  * @tc.type: FUNC
1286  */
1287 HWTEST_F(WindowTest, UnregisterScreenshotListener, Function | SmallTest | Level2)
1288 {
1289     sptr<Window> window = new Window();
1290     ASSERT_NE(nullptr, window);
1291     sptr<IScreenshotListener> listener = nullptr;
1292     auto ret = window->UnregisterScreenshotListener(listener);
1293     ASSERT_EQ(WMError::WM_OK, ret);
1294     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1295 }
1296 
1297 /**
1298  * @tc.name: RegisterDialogTargetTouchListener
1299  * @tc.desc: get
1300  * @tc.type: FUNC
1301  */
1302 HWTEST_F(WindowTest, RegisterDialogTargetTouchListener, Function | SmallTest | Level2)
1303 {
1304     sptr<Window> window = new Window();
1305     ASSERT_NE(nullptr, window);
1306     sptr<IDialogTargetTouchListener> listener = nullptr;
1307     auto ret = window->RegisterDialogTargetTouchListener(listener);
1308     ASSERT_EQ(WMError::WM_OK, ret);
1309     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1310 
1311     auto window_ = new (std::nothrow)Window();
1312     ASSERT_NE(nullptr, window_);
1313     sptr<IDialogTargetTouchListener> listener_;
1314     auto ret_ = window_->RegisterDialogTargetTouchListener(listener_);
1315     ASSERT_EQ(WMError::WM_OK, ret_);
1316     ASSERT_EQ(WMError::WM_OK, window_->Destroy());
1317 }
1318 
1319 /**
1320  * @tc.name: UnregisterDialogTargetTouchListener
1321  * @tc.desc: get
1322  * @tc.type: FUNC
1323  */
1324 HWTEST_F(WindowTest, UnregisterDialogTargetTouchListener, Function | SmallTest | Level2)
1325 {
1326     sptr<Window> window = new Window();
1327     ASSERT_NE(nullptr, window);
1328     sptr<IDialogTargetTouchListener> listener = nullptr;
1329     auto ret = window->UnregisterDialogTargetTouchListener(listener);
1330     ASSERT_EQ(WMError::WM_OK, ret);
1331     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1332 
1333     auto window_ = new (std::nothrow)Window();
1334     ASSERT_NE(nullptr, window_);
1335     ASSERT_EQ(WMError::WM_OK, window_->UnregisterDialogTargetTouchListener(listener));
1336     ASSERT_EQ(WMError::WM_OK, window_->Destroy());
1337 }
1338 
1339 /**
1340  * @tc.name: RegisterDialogDeathRecipientListener
1341  * @tc.desc: get
1342  * @tc.type: FUNC
1343  */
1344 HWTEST_F(WindowTest, RegisterDialogDeathRecipientListener, Function | SmallTest | Level2)
1345 {
1346     sptr<Window> window = new Window();
1347     ASSERT_NE(nullptr, window);
1348     auto ret = WMError::WM_OK;
1349     sptr<IDialogDeathRecipientListener> listener = nullptr;
1350     window->RegisterDialogDeathRecipientListener(listener);
1351     ASSERT_EQ(WMError::WM_OK, ret);
1352     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1353 }
1354 
1355 /**
1356  * @tc.name: UnregisterDialogDeathRecipientListener
1357  * @tc.desc: get
1358  * @tc.type: FUNC
1359  */
1360 HWTEST_F(WindowTest, UnregisterDialogDeathRecipientListener, Function | SmallTest | Level2)
1361 {
1362     sptr<Window> window = new Window();
1363     ASSERT_NE(nullptr, window);
1364     auto ret = WMError::WM_OK;
1365     sptr<IDialogDeathRecipientListener> listener = nullptr;
1366     window->UnregisterDialogDeathRecipientListener(listener);
1367     ASSERT_EQ(WMError::WM_OK, ret);
1368     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1369 }
1370 
1371 /**
1372  * @tc.name: NotifyTouchDialogTarget
1373  * @tc.desc: get
1374  * @tc.type: FUNC
1375  */
1376 HWTEST_F(WindowTest, NotifyTouchDialogTarget, Function | SmallTest | Level2)
1377 {
1378     sptr<Window> window = new Window();
1379     ASSERT_NE(nullptr, window);
1380     auto ret = WMError::WM_OK;
1381     sptr<IDialogTargetTouchListener> listener = nullptr;
1382     window->NotifyTouchDialogTarget();
1383     ASSERT_EQ(WMError::WM_OK, ret);
1384     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1385 }
1386 
1387 /**
1388  * @tc.name: SetAceAbilityHandler
1389  * @tc.desc: get
1390  * @tc.type: FUNC
1391  */
1392 HWTEST_F(WindowTest, SetAceAbilityHandler, Function | SmallTest | Level2)
1393 {
1394     sptr<Window> window = new Window();
1395     ASSERT_NE(nullptr, window);
1396     auto ret = WMError::WM_OK;
1397     sptr<IAceAbilityHandler> handler = nullptr;
1398     window->SetAceAbilityHandler(handler);
1399     ASSERT_EQ(WMError::WM_OK, ret);
1400     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1401 }
1402 
1403 /**
1404  * @tc.name: NapiSetUIContent
1405  * @tc.desc: get
1406  * @tc.type: FUNC
1407  */
1408 HWTEST_F(WindowTest, NapiSetUIContent, Function | SmallTest | Level2)
1409 {
1410     sptr<Window> window = new Window();
1411     ASSERT_NE(nullptr, window);
1412     napi_env env = nullptr;
1413     napi_value storage = nullptr;
1414     auto ret = window->NapiSetUIContent("info", env, storage);
1415     ASSERT_EQ(WMError::WM_OK, ret);
1416     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1417 }
1418 
1419 /**
1420  * @tc.name: SetUIContentByAbc
1421  * @tc.desc: get
1422  * @tc.type: FUNC
1423  */
1424 HWTEST_F(WindowTest, SetUIContentByAbc, Function | SmallTest | Level2)
1425 {
1426     sptr<Window> window = new Window();
1427     ASSERT_NE(nullptr, window);
1428     napi_env env = nullptr;
1429     napi_value storage = nullptr;
1430     auto ret = window->SetUIContentByAbc("/system/etc/window/resources/test.abc", env, storage);
1431     ASSERT_EQ(WMError::WM_OK, ret);
1432     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1433 }
1434 
1435 /**
1436  * @tc.name: GetContentInfo
1437  * @tc.desc: get
1438  * @tc.type: FUNC
1439  */
1440 HWTEST_F(WindowTest, GetContentInfo, Function | SmallTest | Level2)
1441 {
1442     sptr<Window> window = new Window();
1443     ASSERT_NE(nullptr, window);
1444     auto ret = window->GetContentInfo();
1445     ASSERT_EQ(std::string(), ret);
1446     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1447 }
1448 
1449 /**
1450  * @tc.name: GetUIContent
1451  * @tc.desc: get
1452  * @tc.type: FUNC
1453  */
1454 HWTEST_F(WindowTest, GetUIContent, Function | SmallTest | Level2)
1455 {
1456     sptr<Window> window = new Window();
1457     ASSERT_NE(nullptr, window);
1458     auto ret = window->GetUIContent();
1459     ASSERT_EQ(nullptr, ret);
1460     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1461 }
1462 
1463 /**
1464  * @tc.name: OnNewWant
1465  * @tc.desc: get
1466  * @tc.type: FUNC
1467  */
1468 HWTEST_F(WindowTest, OnNewWant, Function | SmallTest | Level2)
1469 {
1470     sptr<Window> window = new Window();
1471     ASSERT_NE(nullptr, window);
1472     AAFwk::Want want;
1473     auto ret = true;
1474     window->OnNewWant(want);
1475     ASSERT_EQ(true, ret);
1476     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1477 }
1478 
1479 /**
1480  * @tc.name: SetRequestedOrientation
1481  * @tc.desc: get
1482  * @tc.type: FUNC
1483  */
1484 HWTEST_F(WindowTest, SetRequestedOrientation, Function | SmallTest | Level2)
1485 {
1486     sptr<Window> window = new Window();
1487     ASSERT_NE(nullptr, window);
1488     auto ret = true;
1489     Orientation ori = Orientation::UNSPECIFIED;
1490     window->SetRequestedOrientation(ori);
1491     ASSERT_EQ(true, ret);
1492     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1493 }
1494 
1495 /**
1496  * @tc.name: GetRequestedOrientation
1497  * @tc.desc: get
1498  * @tc.type: FUNC
1499  */
1500 HWTEST_F(WindowTest, GetRequestedOrientation, Function | SmallTest | Level2)
1501 {
1502     sptr<Window> window = new Window();
1503     ASSERT_NE(nullptr, window);
1504     auto ret = window->GetRequestedOrientation();
1505     ASSERT_EQ(Orientation::UNSPECIFIED, ret);
1506     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1507 }
1508 
1509 /**
1510  * @tc.name: SetRequestWindowModeSupportType
1511  * @tc.desc: get
1512  * @tc.type: FUNC
1513  */
1514 HWTEST_F(WindowTest, SetRequestWindowModeSupportType, Function | SmallTest | Level2)
1515 {
1516     sptr<Window> window = new Window();
1517     ASSERT_NE(nullptr, window);
1518     uint32_t windowModeSupportType = 0;
1519     window->SetRequestWindowModeSupportType(windowModeSupportType);
1520     ASSERT_EQ(static_cast<uint32_t>(Orientation::UNSPECIFIED), windowModeSupportType);
1521     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1522 }
1523 
1524 /**
1525  * @tc.name: GetRequestWindowModeSupportType
1526  * @tc.desc: get
1527  * @tc.type: FUNC
1528  */
1529 HWTEST_F(WindowTest, GetRequestWindowModeSupportType, Function | SmallTest | Level2)
1530 {
1531     sptr<Window> window = new Window();
1532     ASSERT_NE(nullptr, window);
1533     uint32_t ret = window->GetRequestWindowModeSupportType();
1534     ASSERT_EQ(true, ret == 0);
1535     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1536 }
1537 
1538 /**
1539  * @tc.name: SetTouchHotAreas
1540  * @tc.desc: get
1541  * @tc.type: FUNC
1542  */
1543 HWTEST_F(WindowTest, SetTouchHotAreas, Function | SmallTest | Level2)
1544 {
1545     sptr<Window> window = new Window();
1546     ASSERT_NE(nullptr, window);
1547     std::vector<Rect> rects;
1548     auto ret = window->SetTouchHotAreas(rects);
1549     ASSERT_EQ(WMError::WM_OK, ret);
1550     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1551 }
1552 
1553 /**
1554  * @tc.name: GetRequestedTouchHotAreas
1555  * @tc.desc: get
1556  * @tc.type: FUNC
1557  */
1558 HWTEST_F(WindowTest, GetRequestedTouchHotAreas, Function | SmallTest | Level2)
1559 {
1560     sptr<Window> window = new Window();
1561     ASSERT_NE(nullptr, window);
1562     std::vector<Rect> rects;
1563     auto ret = WMError::WM_OK;
1564     window->GetRequestedTouchHotAreas(rects);
1565     ASSERT_EQ(WMError::WM_OK, ret);
1566     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1567 }
1568 
1569 /**
1570  * @tc.name: IsMainHandlerAvailable
1571  * @tc.desc: get
1572  * @tc.type: FUNC
1573  */
1574 HWTEST_F(WindowTest, IsMainHandlerAvailable, Function | SmallTest | Level2)
1575 {
1576     sptr<Window> window = new Window();
1577     sptr<WindowOption> option = new (std::nothrow)WindowOption();
1578     option->SetMainHandlerAvailable(false);
1579     ASSERT_NE(nullptr, window);
1580     auto ret = window->IsMainHandlerAvailable();
1581     ASSERT_EQ(false, ret);
1582     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1583 }
1584 
1585 /**
1586  * @tc.name: SetAPPWindowLabel
1587  * @tc.desc: get
1588  * @tc.type: FUNC
1589  */
1590 HWTEST_F(WindowTest, SetAPPWindowLabel, Function | SmallTest | Level2)
1591 {
1592     sptr<Window> window = new Window();
1593     ASSERT_NE(nullptr, window);
1594     auto ret = window->SetAPPWindowLabel("");
1595     ASSERT_EQ(WMError::WM_OK, ret);
1596     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1597 
1598     auto window_ = new (std::nothrow)Window();
1599     ASSERT_NE(nullptr, window_);
1600     ASSERT_EQ(WMError::WM_OK,  window_->SetAPPWindowLabel("000111"));
1601     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1602 }
1603 
1604 /**
1605  * @tc.name: IsDecorEnable
1606  * @tc.desc: get
1607  * @tc.type: FUNC
1608  */
1609 HWTEST_F(WindowTest, IsDecorEnable, Function | SmallTest | Level2)
1610 {
1611     sptr<Window> window = new Window();
1612     ASSERT_NE(nullptr, window);
1613     auto ret = window->IsDecorEnable();
1614     ASSERT_EQ(false, ret);
1615     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1616 }
1617 
1618 /**
1619  * @tc.name: Maximize
1620  * @tc.desc: get
1621  * @tc.type: FUNC
1622  */
1623 HWTEST_F(WindowTest, Maximize, Function | SmallTest | Level2)
1624 {
1625     sptr<Window> window = new Window();
1626     ASSERT_NE(nullptr, window);
1627     auto ret = window->Maximize();
1628     ASSERT_EQ(WMError::WM_OK, ret);
1629     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1630 }
1631 
1632 /**
1633  * @tc.name: MaximizeFloating
1634  * @tc.desc: get
1635  * @tc.type: FUNC
1636  */
1637 HWTEST_F(WindowTest, MaximizeFloating, Function | SmallTest | Level2)
1638 {
1639     sptr<Window> window = new Window();
1640     ASSERT_NE(nullptr, window);
1641     auto ret = window->MaximizeFloating();
1642     ASSERT_EQ(WMError::WM_OK, ret);
1643     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1644 }
1645 
1646 /**
1647  * @tc.name: Minimize
1648  * @tc.desc: get
1649  * @tc.type: FUNC
1650  */
1651 HWTEST_F(WindowTest, Minimize, Function | SmallTest | Level2)
1652 {
1653     sptr<Window> window = new Window();
1654     ASSERT_NE(nullptr, window);
1655     auto ret = window->Minimize();
1656     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ret);
1657     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1658 }
1659 
1660 /**
1661  * @tc.name: Recover
1662  * @tc.desc: get
1663  * @tc.type: FUNC
1664  */
1665 HWTEST_F(WindowTest, Recover, Function | SmallTest | Level2)
1666 {
1667     sptr<Window> window = new Window();
1668     ASSERT_NE(nullptr, window);
1669     auto ret = window->Recover();
1670 
1671     if (SceneBoardJudgement::IsSceneBoardEnabled()) {
1672         ASSERT_NE(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ret);
1673     } else {
1674         ASSERT_EQ(WMError::WM_OK, ret);
1675     }
1676     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1677 }
1678 
1679 /**
1680  * @tc.name: Close
1681  * @tc.desc: get
1682  * @tc.type: FUNC
1683  */
1684 HWTEST_F(WindowTest, Close, Function | SmallTest | Level2)
1685 {
1686     sptr<Window> window = new Window();
1687     ASSERT_NE(nullptr, window);
1688     auto ret = window->Close();
1689     ASSERT_EQ(true, ret == WMError::WM_OK);
1690     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1691 }
1692 
1693 /**
1694  * @tc.name: StartMove
1695  * @tc.desc: get
1696  * @tc.type: FUNC
1697  */
1698 HWTEST_F(WindowTest, StartMove, Function | SmallTest | Level2)
1699 {
1700     sptr<Window> window = new Window();
1701     ASSERT_NE(nullptr, window);
1702     auto ret = WMError::WM_OK;
1703     window->StartMove();
1704     ASSERT_EQ(WMError::WM_OK, ret);
1705     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1706 }
1707 
1708 /**
1709  * @tc.name: SetGlobalMaximizeMode
1710  * @tc.desc: get
1711  * @tc.type: FUNC
1712  */
1713 HWTEST_F(WindowTest, SetGlobalMaximizeMode, Function | SmallTest | Level2)
1714 {
1715     sptr<Window> window = new Window();
1716     ASSERT_NE(nullptr, window);
1717     auto ret = window->SetGlobalMaximizeMode(MaximizeMode::MODE_AVOID_SYSTEM_BAR);
1718     ASSERT_EQ(WMError::WM_OK, ret);
1719     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1720 }
1721 
1722 /**
1723  * @tc.name: GetGlobalMaximizeMode
1724  * @tc.desc: get
1725  * @tc.type: FUNC
1726  */
1727 HWTEST_F(WindowTest, GetGlobalMaximizeMode, Function | SmallTest | Level2)
1728 {
1729     sptr<Window> window = new Window();
1730     ASSERT_NE(nullptr, window);
1731 
1732     auto ret = window->GetGlobalMaximizeMode();
1733     ASSERT_EQ(MaximizeMode::MODE_FULL_FILL, ret);
1734     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1735 }
1736 
1737 /**
1738  * @tc.name: IsSupportWideGamut
1739  * @tc.desc: get
1740  * @tc.type: FUNC
1741  */
1742 HWTEST_F(WindowTest, IsSupportWideGamut, Function | SmallTest | Level2)
1743 {
1744     sptr<Window> window = new Window();
1745     ASSERT_NE(nullptr, window);
1746     auto ret = window->IsSupportWideGamut();
1747     ASSERT_EQ(false, ret);
1748     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1749 }
1750 
1751 /**
1752  * @tc.name: SetColorSpace
1753  * @tc.desc: get
1754  * @tc.type: FUNC
1755  */
1756 HWTEST_F(WindowTest, SetColorSpace, Function | SmallTest | Level2)
1757 {
1758     sptr<Window> window = new Window();
1759     ASSERT_NE(nullptr, window);
1760     bool ret = true;
1761     window->SetColorSpace(ColorSpace::COLOR_SPACE_DEFAULT);
1762     ASSERT_EQ(true, ret);
1763     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1764 }
1765 
1766 /**
1767  * @tc.name: GetColorSpace
1768  * @tc.desc: get
1769  * @tc.type: FUNC
1770  */
1771 HWTEST_F(WindowTest, GetColorSpace, Function | SmallTest | Level2)
1772 {
1773     sptr<Window> window = new Window();
1774     ASSERT_NE(nullptr, window);
1775     auto ret = window->GetColorSpace();
1776     ASSERT_EQ(ColorSpace::COLOR_SPACE_DEFAULT, ret);
1777     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1778 }
1779 
1780 /**
1781  * @tc.name: DumpInfo
1782  * @tc.desc: get
1783  * @tc.type: FUNC
1784  */
1785 HWTEST_F(WindowTest, DumpInfo, Function | SmallTest | Level2)
1786 {
1787     sptr<Window> window = new Window();
1788     ASSERT_NE(nullptr, window);
1789     std::vector<std::string> params;
1790     std::vector<std::string> info;
1791     auto ret = true;
1792     window->DumpInfo(params, info);
1793     ASSERT_EQ(true, ret);
1794     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1795 }
1796 
1797 /**
1798  * @tc.name: Snapshot
1799  * @tc.desc: get
1800  * @tc.type: FUNC
1801  */
1802 HWTEST_F(WindowTest, Snapshot, Function | SmallTest | Level2)
1803 {
1804     sptr<Window> window = new Window();
1805     ASSERT_NE(nullptr, window);
1806     auto pixmap = window->Snapshot();
1807     ASSERT_EQ(pixmap, nullptr);
1808     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1809 }
1810 
1811 /**
1812  * @tc.name: NotifyMemoryLevel
1813  * @tc.desc: get
1814  * @tc.type: FUNC
1815  */
1816 HWTEST_F(WindowTest, NotifyMemoryLevel, Function | SmallTest | Level2)
1817 {
1818     sptr<Window> window = new Window();
1819     ASSERT_NE(nullptr, window);
1820     auto ret = window->NotifyMemoryLevel(0);
1821     ASSERT_EQ(WMError::WM_OK, ret);
1822     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1823 
1824     auto window_ = new (std::nothrow) Window();
1825     ASSERT_NE(nullptr, window_);
1826     ASSERT_EQ(WMError::WM_OK, window_->NotifyMemoryLevel(22));
1827     ASSERT_EQ(WMError::WM_OK, window_->Destroy());
1828 }
1829 
1830 /**
1831  * @tc.name: IsAllowHaveSystemSubWindow
1832  * @tc.desc: get
1833  * @tc.type: FUNC
1834  */
1835 HWTEST_F(WindowTest, IsAllowHaveSystemSubWindow, Function | SmallTest | Level2)
1836 {
1837     sptr<Window> window = new Window();
1838     ASSERT_NE(nullptr, window);
1839     window->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1840     auto ret = window->IsAllowHaveSystemSubWindow();
1841     ASSERT_EQ(false, ret);
1842     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1843 }
1844 
1845 /**
1846  * @tc.name: SetAspectRatio
1847  * @tc.desc: get
1848  * @tc.type: FUNC
1849  */
1850 HWTEST_F(WindowTest, SetAspectRatio, Function | SmallTest | Level2)
1851 {
1852     sptr<Window> window = new Window();
1853     ASSERT_NE(nullptr, window);
1854     auto ret = window->SetAspectRatio(0.0f);
1855     ASSERT_EQ(WMError::WM_OK, ret);
1856     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1857 
1858     auto window_ = new (std::nothrow) Window();
1859     ASSERT_NE(nullptr, window_);
1860     ASSERT_EQ(WMError::WM_OK, window_->SetAspectRatio(0.1f));
1861     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1862 }
1863 
1864 /**
1865  * @tc.name: ResetAspectRatio
1866  * @tc.desc: get
1867  * @tc.type: FUNC
1868  */
1869 HWTEST_F(WindowTest, ResetAspectRatio, Function | SmallTest | Level2)
1870 {
1871     sptr<Window> window = new Window();
1872     ASSERT_NE(nullptr, window);
1873     auto ret = window->ResetAspectRatio();
1874     ASSERT_EQ(WMError::WM_OK, ret);
1875     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1876 }
1877 
1878 /**
1879  * @tc.name: GetKeyboardAnimationConfig
1880  * @tc.desc: get
1881  * @tc.type: FUNC
1882  */
1883 HWTEST_F(WindowTest, GetKeyboardAnimationConfig, Function | SmallTest | Level2)
1884 {
1885     sptr<Window> window = new Window();
1886     ASSERT_NE(nullptr, window);
1887     KeyboardAnimationCurve curve;
1888     auto ret = window->GetKeyboardAnimationConfig();
1889     ASSERT_EQ(true, ret.curveIn.duration_ == curve.duration_);
1890     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1891 }
1892 
1893 /**
1894  * @tc.name: SetNeedDefaultAnimation
1895  * @tc.desc: get
1896  * @tc.type: FUNC
1897  */
1898 HWTEST_F(WindowTest, SetNeedDefaultAnimation, Function | SmallTest | Level2)
1899 {
1900     sptr<Window> window = new Window();
1901     ASSERT_NE(nullptr, window);
1902     auto ret = true;
1903     window->SetNeedDefaultAnimation(true);
1904     ASSERT_EQ(true, ret);
1905     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1906 }
1907 
1908 /**
1909  * @tc.name: TransferAbilityResult
1910  * @tc.desc: get
1911  * @tc.type: FUNC
1912  */
1913 HWTEST_F(WindowTest, TransferAbilityResult, Function | SmallTest | Level2)
1914 {
1915     sptr<Window> window = new Window();
1916     ASSERT_NE(nullptr, window);
1917     AAFwk::Want want;
1918     auto ret = window->TransferAbilityResult(0, want);
1919     ASSERT_EQ(WMError::WM_OK, ret);
1920     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1921 }
1922 
1923 /**
1924  * @tc.name: TransferExtensionData
1925  * @tc.desc: get
1926  * @tc.type: FUNC
1927  */
1928 HWTEST_F(WindowTest, TransferExtensionData, Function | SmallTest | Level2)
1929 {
1930     sptr<Window> window = new Window();
1931     ASSERT_NE(nullptr, window);
1932     AAFwk::WantParams wantParams;
1933     auto ret = window->TransferExtensionData(wantParams);
1934     ASSERT_EQ(WMError::WM_OK, ret);
1935     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1936 }
1937 
1938 /**
1939  * @tc.name: RegisterTransferComponentDataListener
1940  * @tc.desc: get
1941  * @tc.type: FUNC
1942  */
1943 HWTEST_F(WindowTest, RegisterTransferComponentDataListener, Function | SmallTest | Level2)
1944 {
1945     sptr<Window> window = new Window();
1946     ASSERT_NE(nullptr, window);
1947     NotifyTransferComponentDataFunc func;
1948     auto ret = true;
1949     window->RegisterTransferComponentDataListener(func);
1950     ASSERT_EQ(true, ret);
1951     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1952 }
1953 
1954 /**
1955  * @tc.name: WindowChangeListener
1956  * @tc.desc: WindowChangeListener01 fun
1957  * @tc.type: FUNC
1958  */
1959 HWTEST_F(WindowTest, WindowChangeListener01, Function | SmallTest | Level3)
1960 {
1961     sptr<Window> window = new Window();
1962     ASSERT_NE(nullptr, window);
1963     auto ret = true;
1964     sptr<IWindowChangeListener> listener = new IWindowChangeListener();
1965     window->RegisterWindowChangeListener(listener);
1966     listener->OnModeChange(WindowMode::WINDOW_MODE_UNDEFINED, false);
1967     window->UnregisterWindowChangeListener(listener);
1968     ASSERT_EQ(true, ret);
1969     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1970 }
1971 
1972 /**
1973  * @tc.name: IOccupiedAreaChangeListener
1974  * @tc.desc: IOccupiedAreaChangeListener fun
1975  * @tc.type: FUNC
1976  */
1977 HWTEST_F(WindowTest, IOccupiedAreaChangeListener, Function | SmallTest | Level3)
1978 {
1979     sptr<Window> window = new Window();
1980     ASSERT_NE(nullptr, window);
1981     auto ret = true;
1982     sptr<IOccupiedAreaChangeListener> listener = new IOccupiedAreaChangeListener();
1983     Rect rect_ = {0, 0, 0, 0};
1984     window->RegisterOccupiedAreaChangeListener(listener);
1985     sptr<OccupiedAreaChangeInfo> info = new OccupiedAreaChangeInfo(OccupiedAreaType::TYPE_INPUT, rect_, 80);
1986     listener->OnSizeChange(info, nullptr);
1987     window->UnregisterOccupiedAreaChangeListener(listener);
1988     ASSERT_EQ(true, ret);
1989     ASSERT_EQ(WMError::WM_OK, window->Destroy());
1990 }
1991 
1992 /**
1993  * @tc.name: WindowChangeListener
1994  * @tc.desc: WindowChangeListener02 fun
1995  * @tc.type: FUNC
1996  */
1997 HWTEST_F(WindowTest, WindowChangeListener02, Function | SmallTest | Level3)
1998 {
1999     sptr<Window> window = new Window();
2000     ASSERT_NE(nullptr, window);
2001     auto ret = true;
2002     sptr<IWindowChangeListener> listener = new IWindowChangeListener();
2003     window->RegisterWindowChangeListener(listener);
2004     Rect rect_ = {0, 0, 0, 0};
2005     std::shared_ptr<RSTransaction> rstransaction;
2006     listener->OnSizeChange(rect_, WindowSizeChangeReason::UNDEFINED, rstransaction);
2007     window->UnregisterWindowChangeListener(listener);
2008     ASSERT_EQ(true, ret);
2009     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2010 }
2011 
2012 /**
2013  * @tc.name: IAnimationTransitionController
2014  * @tc.desc: IAnimationTransitionController fun
2015  * @tc.type: FUNC
2016  */
2017 HWTEST_F(WindowTest, IAnimationTransitionController, Function | SmallTest | Level3)
2018 {
2019     sptr<Window> window = new Window();
2020     ASSERT_NE(nullptr, window);
2021     auto ret = true;
2022     sptr<IAnimationTransitionController> listener = new IAnimationTransitionController();
2023     window->RegisterAnimationTransitionController(listener);
2024     listener->AnimationForShown();
2025     listener->AnimationForHidden();
2026     ASSERT_EQ(true, ret);
2027     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2028 }
2029 
2030 /**
2031  * @tc.name: IInputEventConsumer
2032  * @tc.desc: IInputEventConsumer fun
2033  * @tc.type: FUNC
2034  */
2035 HWTEST_F(WindowTest, IInputEventConsumer, Function | SmallTest | Level3)
2036 {
2037     sptr<Window> window = new Window();
2038     ASSERT_NE(nullptr, window);
2039     auto ret = true;
2040     std::shared_ptr<IInputEventConsumer> listener = std::make_shared<IInputEventConsumer>();
2041     std::shared_ptr<MMI::KeyEvent> keyEvent = nullptr;
2042     std::shared_ptr<MMI::PointerEvent> pointerEvent = nullptr;
2043     std::shared_ptr<MMI::AxisEvent> axisEvent = nullptr;
2044     listener->OnInputEvent(keyEvent);
2045     listener->OnInputEvent(pointerEvent);
2046     listener->OnInputEvent(axisEvent);
2047     ASSERT_EQ(true, ret);
2048     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2049 }
2050 
2051 /**
2052  * @tc.name: IDialogDeathRecipientListener
2053  * @tc.desc: IDialogDeathRecipientListener fun
2054  * @tc.type: FUNC
2055  */
2056 HWTEST_F(WindowTest, IDialogDeathRecipientListener, Function | SmallTest | Level3)
2057 {
2058     sptr<Window> window = new Window();
2059     ASSERT_NE(nullptr, window);
2060     auto ret = true;
2061     sptr<IDialogDeathRecipientListener> listener = new IDialogDeathRecipientListener();
2062     Rect rect_ = {0, 0, 0, 0};
2063     sptr<OccupiedAreaChangeInfo> info = new OccupiedAreaChangeInfo(OccupiedAreaType::TYPE_INPUT, rect_, 80);
2064     listener->OnDialogDeathRecipient();
2065     ASSERT_EQ(true, ret);
2066     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2067 }
2068 
2069 /**
2070  * @tc.name: IAceAbilityHandler
2071  * @tc.desc: IAceAbilityHandler fun
2072  * @tc.type: FUNC
2073  */
2074 HWTEST_F(WindowTest, IAceAbilityHandler, Function | SmallTest | Level3)
2075 {
2076     sptr<Window> window = new Window();
2077     ASSERT_NE(nullptr, window);
2078     auto ret = true;
2079     sptr<IAceAbilityHandler> listener = new IAceAbilityHandler();
2080     uint32_t color = 66;
2081     listener->SetBackgroundColor(color);
2082     listener->GetBackgroundColor();
2083     ASSERT_EQ(true, ret);
2084     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2085 }
2086 
2087 /**
2088  * @tc.name: IDispatchInputEventListener
2089  * @tc.desc: IDispatchInputEventListener fun
2090  * @tc.type: FUNC
2091  */
2092 HWTEST_F(WindowTest, IDispatchInputEventListener, Function | SmallTest | Level3)
2093 {
2094     sptr<Window> window = new Window();
2095     ASSERT_NE(nullptr, window);
2096     auto ret = true;
2097     sptr<IDispatchInputEventListener> listener = new IDispatchInputEventListener();
2098     std::shared_ptr<MMI::KeyEvent> keyEvent = nullptr;
2099     std::shared_ptr<MMI::PointerEvent> pointerEvent = nullptr;
2100     std::shared_ptr<MMI::AxisEvent> axisEvent = nullptr;
2101     listener->OnDispatchPointerEvent(pointerEvent);
2102     listener->OnDispatchKeyEvent(keyEvent);
2103     ASSERT_EQ(true, ret);
2104     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2105 }
2106 
2107 /**
2108  * @tc.name: Marshalling
2109  * @tc.desc: keyboardAnimationCurve marshalling
2110  * @tc.type: FUNC
2111  */
2112 HWTEST_F(WindowTest, keyboardAnimationCurveMarshalling, Function | SmallTest | Level3)
2113 {
2114     MessageParcel data;
2115     KeyboardAnimationCurve curveConfig;
2116     auto ret = data.WriteParcelable(&curveConfig);
2117     Parcel parcel;
2118     curveConfig.Unmarshalling(parcel);
2119     ASSERT_EQ(true, ret);
2120 }
2121 
2122 /**
2123  * @tc.name: BackgroundFailed
2124  * @tc.desc: window life cycle BackgroundFailed
2125  * @tc.type: FUNC
2126  */
2127 HWTEST_F(WindowTest, WindowLifeCycleBackgroundFailed, Function | SmallTest | Level3)
2128 {
2129     IWindowLifeCycle windowLifeCycle;
2130     int32_t  ret = 0;
2131     windowLifeCycle.BackgroundFailed(ret);
2132     ASSERT_EQ(0, ret);
2133 }
2134 
2135 /**
2136  * @tc.name: GetVSyncPeriod
2137  * @tc.desc: window GetVSyncPeriod
2138  * @tc.type: FUNC
2139  */
2140 HWTEST_F(WindowTest, GetVSyncPeriod, Function | SmallTest | Level3)
2141 {
2142     sptr<WindowOption> winOption = nullptr;
2143     winOption = new (std::nothrow) OHOS::Rosen::WindowOption();
2144     ASSERT_NE(nullptr, winOption);
2145     winOption->SetWindowType(OHOS::Rosen::WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
2146 
2147     sptr<WindowOption> option = new WindowOption;
2148     sptr<Window> window = Window::Create("win", option);
2149     if (window != nullptr) {
2150         ASSERT_NE(nullptr, window);
2151         int64_t period = window->GetVSyncPeriod();
2152         ASSERT_LE(-1, period);
2153     }
2154     sptr<Window> window_ = new Window();
2155     ASSERT_NE(nullptr, window_);
2156     int64_t period_ = window_->GetVSyncPeriod();
2157     ASSERT_LE(-1, period_);
2158 }
2159 
2160 /**
2161  * @tc.name: performBack
2162  * @tc.desc: window performBack
2163  * @tc.type: FUNC
2164  */
2165 HWTEST_F(WindowTest, performBack, Function | SmallTest | Level3)
2166 {
2167     sptr<WindowOption> winOption = nullptr;
2168     winOption = new (std::nothrow) OHOS::Rosen::WindowOption();
2169     ASSERT_NE(nullptr, winOption);
2170     winOption->SetWindowType(OHOS::Rosen::WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
2171 
2172     sptr<WindowOption> option = new WindowOption;
2173     sptr<Window> window = Window::Create("performBack", option);
2174     if (window != nullptr) {
2175         ASSERT_NE(nullptr, window);
2176         window->PerformBack()
2177         ;
2178     }
2179     sptr<Window> window_ = new Window();
2180     ASSERT_NE(nullptr, window_);
2181     window_->PerformBack();
2182 }
2183 
2184 /**
2185  * @tc.name: SetResizeByDragEnabled
2186  * @tc.desc: set dragEnabled flag
2187  * @tc.type: FUNC
2188  */
2189 HWTEST_F(WindowTest, SetResizeByDragEnabled, Function | SmallTest | Level2)
2190 {
2191     sptr<Window> window = new Window();
2192     ASSERT_NE(nullptr, window);
2193     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetResizeByDragEnabled(true));
2194     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2195 }
2196 
2197 /**
2198  * @tc.name: SetRaiseByClickEnabled
2199  * @tc.desc: set raiseEnabled flag
2200  * @tc.type: FUNC
2201  */
2202 HWTEST_F(WindowTest, SetRaiseByClickEnabled, Function | SmallTest | Level2)
2203 {
2204     sptr<Window> window = new Window();
2205     ASSERT_NE(nullptr, window);
2206     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetRaiseByClickEnabled(true));
2207     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2208 }
2209 
2210 /**
2211  * @tc.name: RaiseAboveTarget
2212  * @tc.desc: RaiseAboveTarget flag
2213  * @tc.type: FUNC
2214  */
2215 HWTEST_F(WindowTest, RaiseAboveTarget, Function | SmallTest | Level2)
2216 {
2217     sptr<Window> window = new Window();
2218     ASSERT_NE(nullptr, window);
2219     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->RaiseAboveTarget(2));
2220     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2221 }
2222 
2223 /**
2224  * @tc.name: HideNonSystemFloatingWindows
2225  * @tc.desc: set shouldHide flag
2226  * @tc.type: FUNC
2227  */
2228 HWTEST_F(WindowTest, HideNonSystemFloatingWindows, Function | SmallTest | Level2)
2229 {
2230     sptr<Window> window = new Window();
2231     ASSERT_NE(nullptr, window);
2232     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->HideNonSystemFloatingWindows(false));
2233     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2234 }
2235 
2236 /**
2237  * @tc.name: GetWindowLimits
2238  * @tc.desc: window GetWindowLimits
2239  * @tc.type: FUNC
2240  */
2241 HWTEST_F(WindowTest, GetWindowLimits, Function | SmallTest | Level2)
2242 {
2243     sptr<Window> window = new Window();
2244     ASSERT_NE(nullptr, window);
2245     WindowLimits windowLimits;
2246     auto ret = window->GetWindowLimits(windowLimits);
2247     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ret);
2248     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2249 }
2250 
2251 /**
2252  * @tc.name: SetWindowLimits
2253  * @tc.desc: window SetWindowLimits
2254  * @tc.type: FUNC
2255  */
2256 HWTEST_F(WindowTest, SetWindowLimits, Function | SmallTest | Level2)
2257 {
2258     sptr<Window> window = new Window();
2259     ASSERT_NE(nullptr, window);
2260     WindowLimits windowLimits;
2261     auto ret = window->SetWindowLimits(windowLimits);
2262     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ret);
2263     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2264 }
2265 
2266 /**
2267  * @tc.name: RegisterWindowVisibilityChangeListener
2268  * @tc.desc: Register window visibility change listener
2269  * @tc.type: FUNC
2270  */
2271 HWTEST_F(WindowTest, RegisterWindowVisibilityChangeListener, Function | SmallTest | Level2)
2272 {
2273     sptr<Window> window = new Window();
2274     ASSERT_NE(nullptr, window);
2275     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->RegisterWindowVisibilityChangeListener(nullptr));
2276     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2277 }
2278 
2279 /**
2280  * @tc.name: UnregisterWindowVisibilityChangeListener
2281  * @tc.desc: Unregister window visibility change listener
2282  * @tc.type: FUNC
2283  */
2284 HWTEST_F(WindowTest, UnregisterWindowVisibilityChangeListener, Function | SmallTest | Level2)
2285 {
2286     sptr<Window> window = new Window();
2287     ASSERT_NE(nullptr, window);
2288     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->UnregisterWindowVisibilityChangeListener(nullptr));
2289     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2290 }
2291 
2292 /**
2293  * @tc.name: TransferAccessibilityEvent
2294  * @tc.desc: get
2295  * @tc.type: FUNC
2296  */
2297 HWTEST_F(WindowTest, TransferAccessibilityEvent, Function | SmallTest | Level2)
2298 {
2299     sptr<Window> window = new Window();
2300     ASSERT_NE(nullptr, window);
2301     Accessibility::AccessibilityEventInfo info;
2302     int64_t uiExtensionIdLevel = 0;
2303     ASSERT_EQ(WMError::WM_OK, window->TransferAccessibilityEvent(info, uiExtensionIdLevel));
2304 }
2305 
2306 /**
2307  * @tc.name: FlushFrameRate
2308  * @tc.desc: FlushFrameRate Test
2309  * @tc.type: FUNC
2310  */
2311 HWTEST_F(WindowTest, FlushFrameRate, Function | SmallTest | Level2)
2312 {
2313     sptr<Window> window = new Window();
2314     ASSERT_NE(nullptr, window);
2315     uint32_t rate = 120;
2316     uint32_t rateType = 0;
2317     int32_t animatorExpectedFrameRate = -1;
2318     window->FlushFrameRate(rate, animatorExpectedFrameRate, rateType);
2319     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2320 }
2321 
2322 /**
2323  * @tc.name: SetSingleFrameComposerEnabled
2324  * @tc.desc: set single frame composer enable flag
2325  * @tc.type: FUNC
2326  */
2327 HWTEST_F(WindowTest, SetSingleFrameComposerEnabled, Function | SmallTest | Level2)
2328 {
2329     sptr<Window> window = new Window();
2330     ASSERT_NE(nullptr, window);
2331     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetSingleFrameComposerEnabled(false));
2332     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2333 }
2334 
2335 /**
2336  * @tc.name: Maximize01
2337  * @tc.desc: maximize interface Test
2338  * @tc.type: FUNC
2339  */
2340 HWTEST_F(WindowTest, Maximize01, Function | SmallTest | Level2)
2341 {
2342     sptr<Window> window = new Window();
2343     ASSERT_NE(nullptr, window);
2344     MaximizePresentation presentation = MaximizePresentation::ENTER_IMMERSIVE;
2345     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->Maximize(presentation));
2346 }
2347 
2348 /**
2349  * @tc.name: RegisterWindowRectChangeListener
2350  * @tc.desc: get
2351  * @tc.type: FUNC
2352  */
2353 HWTEST_F(WindowTest, RegisterWindowRectChangeListener, Function | SmallTest | Level2)
2354 {
2355     sptr<Window> window = new Window();
2356     ASSERT_NE(nullptr, window);
2357     sptr<IWindowRectChangeListener> listener = nullptr;
2358     auto ret = window->RegisterWindowRectChangeListener(listener);
2359     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ret);
2360     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2361 }
2362 
2363 /**
2364  * @tc.name: UnregisterWindowRectChangeListener
2365  * @tc.desc: get
2366  * @tc.type: FUNC
2367  */
2368 HWTEST_F(WindowTest, UnregisterWindowRectChangeListener, Function | SmallTest | Level2)
2369 {
2370     sptr<Window> window = new Window();
2371     ASSERT_NE(nullptr, window);
2372     sptr<IWindowRectChangeListener> listener = nullptr;
2373     auto ret = window->UnregisterWindowRectChangeListener(listener);
2374     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ret);
2375     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2376 }
2377 
2378 /**
2379  * @tc.name: RegisterKeyboardPanelInfoChangeListener
2380  * @tc.desc: get
2381  * @tc.type: FUNC
2382  */
2383 HWTEST_F(WindowTest, RegisterKeyboardPanelInfoChangeListener, Function | SmallTest | Level2)
2384 {
2385     sptr<Window> window = new Window();
2386     ASSERT_NE(nullptr, window);
2387     sptr<IKeyboardPanelInfoChangeListener> listener = nullptr;
2388     auto ret = window->RegisterKeyboardPanelInfoChangeListener(listener);
2389     ASSERT_EQ(WMError::WM_OK, ret);
2390     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2391 }
2392 
2393 /**
2394  * @tc.name: UnregisterKeyboardPanelInfoChangeListener
2395  * @tc.desc: get
2396  * @tc.type: FUNC
2397  */
2398 HWTEST_F(WindowTest, UnregisterKeyboardPanelInfoChangeListener, Function | SmallTest | Level2)
2399 {
2400     sptr<Window> window = new Window();
2401     ASSERT_NE(nullptr, window);
2402     sptr<IKeyboardPanelInfoChangeListener> listener = nullptr;
2403     auto ret = window->UnregisterKeyboardPanelInfoChangeListener(listener);
2404     ASSERT_EQ(WMError::WM_OK, ret);
2405     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2406 }
2407 
2408 /**
2409  * @tc.name: GetTopWindowWithContext
2410  * @tc.desc: get
2411  * @tc.type: FUNC
2412  */
2413 HWTEST_F(WindowTest, GetTopWindowWithContext, Function | SmallTest | Level2)
2414 {
2415     sptr<Window> window = new Window();
2416     ASSERT_NE(nullptr, window);
2417     std::shared_ptr<AbilityRuntime::Context> context = nullptr;
2418     auto ret = window->GetTopWindowWithContext(context);
2419     ASSERT_EQ(nullptr, ret);
2420 }
2421 
2422 /**
2423  * @tc.name: GetTopWindowWithId
2424  * @tc.desc: get
2425  * @tc.type: FUNC
2426  */
2427 HWTEST_F(WindowTest, GetTopWindowWithId, Function | SmallTest | Level2)
2428 {
2429     sptr<Window> window = new Window();
2430     ASSERT_NE(nullptr, window);
2431     std::shared_ptr<AbilityRuntime::Context> context = nullptr;
2432     auto ret = window->GetTopWindowWithContext(context);
2433     ASSERT_EQ(nullptr, ret);
2434 }
2435 
2436 /**
2437  * @tc.name: Create05
2438  * @tc.desc: Create window with WindowName and no abilityToken
2439  * @tc.type: FUNC
2440  */
2441 HWTEST_F(WindowTest, Create05, Function | SmallTest | Level2)
2442 {
2443     std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
2444     sptr<WindowOption> option = nullptr;
2445     auto window = Window::Create("WindowTest02", option);
2446     uint32_t version = 0;
2447     if (version < 10) {
2448         ASSERT_NE(10, version);
2449     }
2450     WindowOption windowoption;
2451     windowoption.onlySupportSceneBoard_ = true;
2452     ASSERT_NE(true, option->GetOnlySupportSceneBoard());
2453 }
2454 
2455 /**
2456  * @tc.name: GetMainWindowWithContext|GetWindowWithId
2457  *                      |GetSubWindow|UpdateConfigurationForAll
2458  * @tc.desc: get
2459  * @tc.type: FUNC
2460  */
2461 HWTEST_F(WindowTest, GetMainWindowWithContext, Function | SmallTest | Level2)
2462 {
2463     sptr<Window> window = new Window();
2464     uint32_t windId = 0;
2465     uint32_t parentId = 1;
2466     std::shared_ptr<AppExecFwk::Configuration> configuration = nullptr;
2467 
2468     std::shared_ptr<AbilityRuntime::Context> context = nullptr;
2469     auto ret = window->GetMainWindowWithContext(context);
2470     window->GetWindowWithId(windId);
2471     window->GetSubWindow(parentId);
2472     window->UpdateConfigurationForAll(configuration);
2473     ASSERT_EQ(nullptr, ret);
2474 }
2475 
2476 /**
2477  * @tc.name: SetTopmost|GetWIsTopmostindowWithId
2478  * @tc.desc: get
2479  * @tc.type: FUNC
2480  */
2481 HWTEST_F(WindowTest, SetTopmost, Function | SmallTest | Level2)
2482 {
2483     sptr<Window> window = new Window();
2484     ASSERT_NE(nullptr, window);
2485     auto ret = window->SetTopmost(false);
2486     ASSERT_EQ(WMError::WM_OK, ret);
2487     ASSERT_EQ(false, window->IsTopmost());
2488     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2489 }
2490 
2491 /**
2492  * @tc.name: SetUIContentByName
2493  * @tc.desc: get
2494  * @tc.type: FUNC
2495  */
2496 HWTEST_F(WindowTest, SetUIContentByName, Function | SmallTest | Level2)
2497 {
2498     sptr<Window> window = new Window();
2499     ASSERT_NE(nullptr, window);
2500     napi_env env = nullptr;
2501     napi_value storage = nullptr;
2502     auto ret = window->SetUIContentByName("/system/etc/window/resources/test.abc", env, storage);
2503     ASSERT_EQ(WMError::WM_OK, ret);
2504     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2505 }
2506 
2507 /**
2508  * @tc.name: TriggerBindModalUIExtension
2509  * @tc.desc: get
2510  * @tc.type: FUNC
2511  */
2512 HWTEST_F(WindowTest, TriggerBindModalUIExtension, Function | SmallTest | Level2)
2513 {
2514     sptr<WindowOption> winOption = nullptr;
2515     winOption = new(std::nothrow) OHOS::Rosen::WindowOption();
2516     ASSERT_NE(nullptr, winOption);
2517     winOption->SetWindowType(OHOS::Rosen::WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
2518     sptr<WindowOption> option = new WindowOption();
2519     sptr<Window> window = Window::Create("TriggerBindModalUIExtension", option);
2520     if (window != nullptr) {
2521         ASSERT_NE(nullptr, window);
2522         window->TriggerBindModalUIExtension();
2523     }
2524     sptr<Window> window_ = new Window();
2525     ASSERT_NE(nullptr, window_);
2526     window_->PerformBack();
2527 }
2528 
2529 /**
2530  * @tc.name: RegisterTransferComponentDataForResultListener
2531  * @tc.desc: get
2532  * @tc.type: FUNC
2533  */
2534 HWTEST_F(WindowTest, RegisterTransferComponentDataForResultListener, Function | SmallTest | Level2)
2535 {
2536     sptr<Window> window = new Window();
2537     ASSERT_NE(nullptr, window);
2538     NotifyTransferComponentDataForResultFunc func;
2539     auto ret = true;
2540     window->RegisterTransferComponentDataForResultListener(func);
2541     ASSERT_EQ(true, ret);
2542     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2543 }
2544 
2545 /**
2546  * @tc.name: SetTextFieldAvoidInfo|KeepKeyboardOnFocus
2547  * @tc.desc: get
2548  * @tc.type: FUNC
2549  */
2550 HWTEST_F(WindowTest, SetTextFieldAvoidInfo, Function | SmallTest | Level2)
2551 {
2552     sptr<Window> window = new Window();
2553     ASSERT_NE(nullptr, window);
2554     auto ret = window->SetTextFieldAvoidInfo(50.0, 100.0);
2555     ASSERT_EQ(WMError::WM_OK, ret);
2556     auto retur = window->KeepKeyboardOnFocus(false);
2557     ASSERT_EQ(WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT, retur);
2558     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2559 }
2560 
2561 /**
2562  * @tc.name: Test01
2563  * @tc.desc: Test01
2564  * @tc.type: FUNC
2565  */
2566 HWTEST_F(WindowTest, Test01, Function | SmallTest | Level2)
2567 {
2568     sptr<Window> window = new Window();
2569     ASSERT_NE(nullptr, window);
2570     SystemBarProperty prop;
2571     ASSERT_EQ(WMError::WM_OK, window->SetSpecificBarProperty(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, prop));
2572     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetDecorVisible(true));
2573     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetWindowTitleMoveEnabled(true));
2574     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetTitleButtonVisible(true, true, true, true));
2575     auto var = 5;
2576     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetDecorHeight(var));
2577     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->GetDecorHeight(var));
2578     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->ClearKeyEventFilter());
2579     IWindowVisibilityChangedListener windowVisibilityChangedListener;
2580     windowVisibilityChangedListener.OnWindowVisibilityChangedCallback(false);
2581     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2582 }
2583 
2584 /**
2585  * @tc.name: Test02
2586  * @tc.desc: Test02
2587  * @tc.type: FUNC
2588  */
2589 HWTEST_F(WindowTest, Test02, Function | SmallTest | Level2)
2590 {
2591     sptr<Window> window = new Window();
2592     ASSERT_NE(nullptr, window);
2593     IWindowLifeCycle windowLifeCycle;
2594     windowLifeCycle.AfterResumed();
2595     windowLifeCycle.AfterPaused();
2596     windowLifeCycle.AfterDestroyed();
2597     IWindowStatusChangeListener windowStatusChangeListener;
2598     windowStatusChangeListener.OnWindowStatusChange(WindowStatus::WINDOW_STATUS_UNDEFINED);
2599     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetDefaultDensityEnabled(true));
2600     ASSERT_EQ(false, window->GetDefaultDensityEnabled());
2601     Rect rect_ = {0, 0, 0, 0};
2602     window->UpdatePiPRect(rect_, WindowSizeChangeReason::UNDEFINED);
2603     IWindowRectChangeListener windowRectChangeListener;
2604     windowRectChangeListener.OnRectChange(rect_, WindowSizeChangeReason::UNDEFINED);
2605     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2606 }
2607 
2608 /**
2609  * @tc.name: Test03
2610  * @tc.desc: Test03
2611  * @tc.type: FUNC
2612  */
2613 HWTEST_F(WindowTest, Test03, Function | SmallTest | Level2)
2614 {
2615     sptr<Window> window = new Window();
2616     ASSERT_NE(nullptr, window);
2617     KeyEventFilterFunc keyEventFilterFunc;
2618     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetKeyEventFilter(keyEventFilterFunc));
2619     IWindowNoInteractionListener windowNoInteractionListener;
2620     windowNoInteractionListener.OnWindowNoInteractionCallback();
2621     windowNoInteractionListener.SetTimeout(100);
2622     ASSERT_EQ(0, windowNoInteractionListener.GetTimeout());
2623     TitleButtonRect titleButtonRect = {3, 3, 3, 3};
2624     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->GetTitleButtonArea(titleButtonRect));
2625     IWindowTitleButtonRectChangedListener windowTitleButtonRectChangedListener;
2626     windowTitleButtonRectChangedListener.OnWindowTitleButtonRectChanged(titleButtonRect);
2627     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2628 }
2629 
2630 /**
2631  * @tc.name: Test04
2632  * @tc.desc: Test04
2633  * @tc.type: FUNC
2634  */
2635 HWTEST_F(WindowTest, Test04, Function | SmallTest | Level2)
2636 {
2637     sptr<Window> window = new Window();
2638     ASSERT_NE(nullptr, window);
2639     ASSERT_EQ(nullptr, window->GetUIContentWithId(0));
2640     window->TriggerBindModalUIExtension();
2641     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetGrayScale(0));
2642     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2643 }
2644 
2645 /**
2646  * @tc.name: Test05
2647  * @tc.desc: Test05
2648  * @tc.type: FUNC
2649  */
2650 HWTEST_F(WindowTest, Test05, Function | SmallTest | Level2)
2651 {
2652     sptr<Window> window = new Window();
2653     ASSERT_NE(nullptr, window);
2654     auto mainWinId = 0;
2655     auto window1 = window->GetTopWindowWithId(mainWinId);
2656     ASSERT_EQ(nullptr, window1);
2657     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2658 }
2659 
2660 /**
2661  * @tc.name: SetTitleButtonVisible
2662  * @tc.desc: SetTitleButtonVisible
2663  * @tc.type: FUNC
2664 */
2665 HWTEST_F(WindowTest, SetTitleButtonVisible, Function | SmallTest | Level2)
2666 {
2667     sptr<Window> window = new (std::nothrow) Window();
2668     ASSERT_NE(window, nullptr);
2669     WMError res = window->SetTitleButtonVisible(true, true, true, true);
2670     ASSERT_EQ(res, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
2671     res = window->SetTitleButtonVisible(false, true, true, true);
2672     ASSERT_EQ(res, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
2673     res = window->SetTitleButtonVisible(true, false, true, true);
2674     ASSERT_EQ(res, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
2675     res = window->SetTitleButtonVisible(true, true, false, true);
2676     ASSERT_EQ(res, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
2677     res = window->SetTitleButtonVisible(false, false, true, true);
2678     ASSERT_EQ(res, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
2679     res = window->SetTitleButtonVisible(false, true, false, true);
2680     ASSERT_EQ(res, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
2681     res = window->SetTitleButtonVisible(true, false, false, true);
2682     ASSERT_EQ(res, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
2683     res = window->SetTitleButtonVisible(false, false, false, true);
2684     ASSERT_EQ(res, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
2685 }
2686 
2687 /**
2688  * @tc.name: GetWindowStatus
2689  * @tc.desc: GetWindowStatus
2690  * @tc.type: FUNC
2691  */
2692 HWTEST_F(WindowTest, GetWindowStatus, Function | SmallTest | Level2)
2693 {
2694     sptr<Window> window = new (std::nothrow) Window();
2695     ASSERT_NE(window, nullptr);
2696     WindowStatus windowStatus;
2697     auto ret = window->GetWindowStatus(windowStatus);
2698     ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ret);
2699     ASSERT_EQ(WMError::WM_OK, window->Destroy());
2700 }
2701 
2702 /**
2703  * @tc.name: IsPcOrPadCapabilityEnabled
2704  * @tc.desc: IsPcOrPadCapabilityEnabled
2705  * @tc.type: FUNC
2706  */
2707 HWTEST_F(WindowTest, IsPcOrPadCapabilityEnabled, Function | SmallTest | Level2)
2708 {
2709     sptr<Window> window = sptr<Window>::MakeSptr();
2710     ASSERT_NE(window, nullptr);
2711     auto ret = window->IsPcOrPadCapabilityEnabled();
2712     EXPECT_EQ(false, ret);
2713     EXPECT_EQ(WMError::WM_OK, window->Destroy());
2714 }
2715 
2716 /**
2717  * @tc.name: RegisterMainWindowCloseListeners
2718  * @tc.desc: RegisterMainWindowCloseListeners
2719  * @tc.type: FUNC
2720  */
2721 HWTEST_F(WindowTest, RegisterMainWindowCloseListeners, Function | SmallTest | Level2)
2722 {
2723     sptr<Window> window = sptr<Window>::MakeSptr();
2724     ASSERT_NE(window, nullptr);
2725     sptr<IMainWindowCloseListener> listener = sptr<IMainWindowCloseListener>::MakeSptr();
2726     auto ret = window->RegisterMainWindowCloseListeners(listener);
2727     EXPECT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ret);
2728     EXPECT_EQ(WMError::WM_OK, window->Destroy());
2729 }
2730 
2731 /**
2732  * @tc.name: UnregisterMainWindowCloseListeners
2733  * @tc.desc: UnregisterMainWindowCloseListeners
2734  * @tc.type: FUNC
2735  */
2736 HWTEST_F(WindowTest, UnregisterMainWindowCloseListeners, Function | SmallTest | Level2)
2737 {
2738     sptr<Window> window = sptr<Window>::MakeSptr();
2739     ASSERT_NE(window, nullptr);
2740     sptr<IMainWindowCloseListener> listener = sptr<IMainWindowCloseListener>::MakeSptr();
2741     auto ret = window->UnregisterMainWindowCloseListeners(listener);
2742     EXPECT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ret);
2743     EXPECT_EQ(WMError::WM_OK, window->Destroy());
2744 }
2745 }
2746 } // namespace Rosen
2747 } // namespace OHOS