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