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: Close
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: CloseDirectly
1695 * @tc.desc: CloseDirectly
1696 * @tc.type: FUNC
1697 */
1698 HWTEST_F(WindowTest, CloseDirectly, Function | SmallTest | Level2)
1699 {
1700 sptr<Window> window = sptr<Window>::MakeSptr();
1701 auto ret = window->CloseDirectly();
1702 ASSERT_EQ(ret, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
1703 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1704 }
1705
1706 /**
1707 * @tc.name: StartMove
1708 * @tc.desc: get
1709 * @tc.type: FUNC
1710 */
1711 HWTEST_F(WindowTest, StartMove, Function | SmallTest | Level2)
1712 {
1713 sptr<Window> window = new Window();
1714 ASSERT_NE(nullptr, window);
1715 auto ret = WMError::WM_OK;
1716 window->StartMove();
1717 ASSERT_EQ(WMError::WM_OK, ret);
1718 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1719 }
1720
1721 /**
1722 * @tc.name: SetGlobalMaximizeMode
1723 * @tc.desc: get
1724 * @tc.type: FUNC
1725 */
1726 HWTEST_F(WindowTest, SetGlobalMaximizeMode, Function | SmallTest | Level2)
1727 {
1728 sptr<Window> window = new Window();
1729 ASSERT_NE(nullptr, window);
1730 auto ret = window->SetGlobalMaximizeMode(MaximizeMode::MODE_AVOID_SYSTEM_BAR);
1731 ASSERT_EQ(WMError::WM_OK, ret);
1732 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1733 }
1734
1735 /**
1736 * @tc.name: GetGlobalMaximizeMode
1737 * @tc.desc: get
1738 * @tc.type: FUNC
1739 */
1740 HWTEST_F(WindowTest, GetGlobalMaximizeMode, Function | SmallTest | Level2)
1741 {
1742 sptr<Window> window = new Window();
1743 ASSERT_NE(nullptr, window);
1744
1745 auto ret = window->GetGlobalMaximizeMode();
1746 ASSERT_EQ(MaximizeMode::MODE_FULL_FILL, ret);
1747 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1748 }
1749
1750 /**
1751 * @tc.name: IsSupportWideGamut
1752 * @tc.desc: get
1753 * @tc.type: FUNC
1754 */
1755 HWTEST_F(WindowTest, IsSupportWideGamut, Function | SmallTest | Level2)
1756 {
1757 sptr<Window> window = new Window();
1758 ASSERT_NE(nullptr, window);
1759 auto ret = window->IsSupportWideGamut();
1760 ASSERT_EQ(false, ret);
1761 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1762 }
1763
1764 /**
1765 * @tc.name: SetColorSpace
1766 * @tc.desc: get
1767 * @tc.type: FUNC
1768 */
1769 HWTEST_F(WindowTest, SetColorSpace, Function | SmallTest | Level2)
1770 {
1771 sptr<Window> window = new Window();
1772 ASSERT_NE(nullptr, window);
1773 bool ret = true;
1774 window->SetColorSpace(ColorSpace::COLOR_SPACE_DEFAULT);
1775 ASSERT_EQ(true, ret);
1776 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1777 }
1778
1779 /**
1780 * @tc.name: GetColorSpace
1781 * @tc.desc: get
1782 * @tc.type: FUNC
1783 */
1784 HWTEST_F(WindowTest, GetColorSpace, Function | SmallTest | Level2)
1785 {
1786 sptr<Window> window = new Window();
1787 ASSERT_NE(nullptr, window);
1788 auto ret = window->GetColorSpace();
1789 ASSERT_EQ(ColorSpace::COLOR_SPACE_DEFAULT, ret);
1790 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1791 }
1792
1793 /**
1794 * @tc.name: DumpInfo
1795 * @tc.desc: get
1796 * @tc.type: FUNC
1797 */
1798 HWTEST_F(WindowTest, DumpInfo, Function | SmallTest | Level2)
1799 {
1800 sptr<Window> window = new Window();
1801 ASSERT_NE(nullptr, window);
1802 std::vector<std::string> params;
1803 std::vector<std::string> info;
1804 auto ret = true;
1805 window->DumpInfo(params, info);
1806 ASSERT_EQ(true, ret);
1807 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1808 }
1809
1810 /**
1811 * @tc.name: Snapshot
1812 * @tc.desc: get
1813 * @tc.type: FUNC
1814 */
1815 HWTEST_F(WindowTest, Snapshot, Function | SmallTest | Level2)
1816 {
1817 sptr<Window> window = new Window();
1818 ASSERT_NE(nullptr, window);
1819 auto pixmap = window->Snapshot();
1820 ASSERT_EQ(pixmap, nullptr);
1821 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1822 }
1823
1824 /**
1825 * @tc.name: NotifyMemoryLevel
1826 * @tc.desc: get
1827 * @tc.type: FUNC
1828 */
1829 HWTEST_F(WindowTest, NotifyMemoryLevel, Function | SmallTest | Level2)
1830 {
1831 sptr<Window> window = new Window();
1832 ASSERT_NE(nullptr, window);
1833 auto ret = window->NotifyMemoryLevel(0);
1834 ASSERT_EQ(WMError::WM_OK, ret);
1835 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1836
1837 auto window_ = new (std::nothrow) Window();
1838 ASSERT_NE(nullptr, window_);
1839 ASSERT_EQ(WMError::WM_OK, window_->NotifyMemoryLevel(22));
1840 ASSERT_EQ(WMError::WM_OK, window_->Destroy());
1841 }
1842
1843 /**
1844 * @tc.name: IsAllowHaveSystemSubWindow
1845 * @tc.desc: get
1846 * @tc.type: FUNC
1847 */
1848 HWTEST_F(WindowTest, IsAllowHaveSystemSubWindow, Function | SmallTest | Level2)
1849 {
1850 sptr<Window> window = new Window();
1851 ASSERT_NE(nullptr, window);
1852 window->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1853 auto ret = window->IsAllowHaveSystemSubWindow();
1854 ASSERT_EQ(false, ret);
1855 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1856 }
1857
1858 /**
1859 * @tc.name: SetAspectRatio
1860 * @tc.desc: get
1861 * @tc.type: FUNC
1862 */
1863 HWTEST_F(WindowTest, SetAspectRatio, Function | SmallTest | Level2)
1864 {
1865 sptr<Window> window = new Window();
1866 ASSERT_NE(nullptr, window);
1867 auto ret = window->SetAspectRatio(0.0f);
1868 ASSERT_EQ(WMError::WM_OK, ret);
1869 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1870
1871 auto window_ = new (std::nothrow) Window();
1872 ASSERT_NE(nullptr, window_);
1873 ASSERT_EQ(WMError::WM_OK, window_->SetAspectRatio(0.1f));
1874 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1875 }
1876
1877 /**
1878 * @tc.name: ResetAspectRatio
1879 * @tc.desc: get
1880 * @tc.type: FUNC
1881 */
1882 HWTEST_F(WindowTest, ResetAspectRatio, Function | SmallTest | Level2)
1883 {
1884 sptr<Window> window = new Window();
1885 ASSERT_NE(nullptr, window);
1886 auto ret = window->ResetAspectRatio();
1887 ASSERT_EQ(WMError::WM_OK, ret);
1888 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1889 }
1890
1891 /**
1892 * @tc.name: GetKeyboardAnimationConfig
1893 * @tc.desc: get
1894 * @tc.type: FUNC
1895 */
1896 HWTEST_F(WindowTest, GetKeyboardAnimationConfig, Function | SmallTest | Level2)
1897 {
1898 sptr<Window> window = new Window();
1899 ASSERT_NE(nullptr, window);
1900 KeyboardAnimationCurve curve;
1901 auto ret = window->GetKeyboardAnimationConfig();
1902 ASSERT_EQ(true, ret.curveIn.duration_ == curve.duration_);
1903 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1904 }
1905
1906 /**
1907 * @tc.name: SetNeedDefaultAnimation
1908 * @tc.desc: get
1909 * @tc.type: FUNC
1910 */
1911 HWTEST_F(WindowTest, SetNeedDefaultAnimation, Function | SmallTest | Level2)
1912 {
1913 sptr<Window> window = new Window();
1914 ASSERT_NE(nullptr, window);
1915 auto ret = true;
1916 window->SetNeedDefaultAnimation(true);
1917 ASSERT_EQ(true, ret);
1918 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1919 }
1920
1921 /**
1922 * @tc.name: TransferAbilityResult
1923 * @tc.desc: get
1924 * @tc.type: FUNC
1925 */
1926 HWTEST_F(WindowTest, TransferAbilityResult, Function | SmallTest | Level2)
1927 {
1928 sptr<Window> window = new Window();
1929 ASSERT_NE(nullptr, window);
1930 AAFwk::Want want;
1931 auto ret = window->TransferAbilityResult(0, want);
1932 ASSERT_EQ(WMError::WM_OK, ret);
1933 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1934 }
1935
1936 /**
1937 * @tc.name: TransferExtensionData
1938 * @tc.desc: get
1939 * @tc.type: FUNC
1940 */
1941 HWTEST_F(WindowTest, TransferExtensionData, Function | SmallTest | Level2)
1942 {
1943 sptr<Window> window = new Window();
1944 ASSERT_NE(nullptr, window);
1945 AAFwk::WantParams wantParams;
1946 auto ret = window->TransferExtensionData(wantParams);
1947 ASSERT_EQ(WMError::WM_OK, ret);
1948 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1949 }
1950
1951 /**
1952 * @tc.name: RegisterTransferComponentDataListener
1953 * @tc.desc: get
1954 * @tc.type: FUNC
1955 */
1956 HWTEST_F(WindowTest, RegisterTransferComponentDataListener, Function | SmallTest | Level2)
1957 {
1958 sptr<Window> window = new Window();
1959 ASSERT_NE(nullptr, window);
1960 NotifyTransferComponentDataFunc func;
1961 auto ret = true;
1962 window->RegisterTransferComponentDataListener(func);
1963 ASSERT_EQ(true, ret);
1964 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1965 }
1966
1967 /**
1968 * @tc.name: WindowChangeListener
1969 * @tc.desc: WindowChangeListener01 fun
1970 * @tc.type: FUNC
1971 */
1972 HWTEST_F(WindowTest, WindowChangeListener01, Function | SmallTest | Level3)
1973 {
1974 sptr<Window> window = new Window();
1975 ASSERT_NE(nullptr, window);
1976 auto ret = true;
1977 sptr<IWindowChangeListener> listener = new IWindowChangeListener();
1978 window->RegisterWindowChangeListener(listener);
1979 listener->OnModeChange(WindowMode::WINDOW_MODE_UNDEFINED, false);
1980 window->UnregisterWindowChangeListener(listener);
1981 ASSERT_EQ(true, ret);
1982 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1983 }
1984
1985 /**
1986 * @tc.name: IOccupiedAreaChangeListener
1987 * @tc.desc: IOccupiedAreaChangeListener fun
1988 * @tc.type: FUNC
1989 */
1990 HWTEST_F(WindowTest, IOccupiedAreaChangeListener, Function | SmallTest | Level3)
1991 {
1992 sptr<Window> window = new Window();
1993 ASSERT_NE(nullptr, window);
1994 auto ret = true;
1995 sptr<IOccupiedAreaChangeListener> listener = new IOccupiedAreaChangeListener();
1996 Rect rect_ = {0, 0, 0, 0};
1997 window->RegisterOccupiedAreaChangeListener(listener);
1998 sptr<OccupiedAreaChangeInfo> info = new OccupiedAreaChangeInfo(OccupiedAreaType::TYPE_INPUT, rect_, 80);
1999 listener->OnSizeChange(info, nullptr);
2000 window->UnregisterOccupiedAreaChangeListener(listener);
2001 ASSERT_EQ(true, ret);
2002 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2003 }
2004
2005 /**
2006 * @tc.name: WindowChangeListener
2007 * @tc.desc: WindowChangeListener02 fun
2008 * @tc.type: FUNC
2009 */
2010 HWTEST_F(WindowTest, WindowChangeListener02, Function | SmallTest | Level3)
2011 {
2012 sptr<Window> window = new Window();
2013 ASSERT_NE(nullptr, window);
2014 auto ret = true;
2015 sptr<IWindowChangeListener> listener = new IWindowChangeListener();
2016 window->RegisterWindowChangeListener(listener);
2017 Rect rect_ = {0, 0, 0, 0};
2018 std::shared_ptr<RSTransaction> rstransaction;
2019 listener->OnSizeChange(rect_, WindowSizeChangeReason::UNDEFINED, rstransaction);
2020 window->UnregisterWindowChangeListener(listener);
2021 ASSERT_EQ(true, ret);
2022 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2023 }
2024
2025 /**
2026 * @tc.name: IAnimationTransitionController
2027 * @tc.desc: IAnimationTransitionController fun
2028 * @tc.type: FUNC
2029 */
2030 HWTEST_F(WindowTest, IAnimationTransitionController, Function | SmallTest | Level3)
2031 {
2032 sptr<Window> window = new Window();
2033 ASSERT_NE(nullptr, window);
2034 auto ret = true;
2035 sptr<IAnimationTransitionController> listener = new IAnimationTransitionController();
2036 window->RegisterAnimationTransitionController(listener);
2037 listener->AnimationForShown();
2038 listener->AnimationForHidden();
2039 ASSERT_EQ(true, ret);
2040 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2041 }
2042
2043 /**
2044 * @tc.name: IInputEventConsumer
2045 * @tc.desc: IInputEventConsumer fun
2046 * @tc.type: FUNC
2047 */
2048 HWTEST_F(WindowTest, IInputEventConsumer, Function | SmallTest | Level3)
2049 {
2050 sptr<Window> window = new Window();
2051 ASSERT_NE(nullptr, window);
2052 auto ret = true;
2053 std::shared_ptr<IInputEventConsumer> listener = std::make_shared<IInputEventConsumer>();
2054 std::shared_ptr<MMI::KeyEvent> keyEvent = nullptr;
2055 std::shared_ptr<MMI::PointerEvent> pointerEvent = nullptr;
2056 std::shared_ptr<MMI::AxisEvent> axisEvent = nullptr;
2057 listener->OnInputEvent(keyEvent);
2058 listener->OnInputEvent(pointerEvent);
2059 listener->OnInputEvent(axisEvent);
2060 ASSERT_EQ(true, ret);
2061 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2062 }
2063
2064 /**
2065 * @tc.name: IDialogDeathRecipientListener
2066 * @tc.desc: IDialogDeathRecipientListener fun
2067 * @tc.type: FUNC
2068 */
2069 HWTEST_F(WindowTest, IDialogDeathRecipientListener, Function | SmallTest | Level3)
2070 {
2071 sptr<Window> window = new Window();
2072 ASSERT_NE(nullptr, window);
2073 auto ret = true;
2074 sptr<IDialogDeathRecipientListener> listener = new IDialogDeathRecipientListener();
2075 Rect rect_ = {0, 0, 0, 0};
2076 sptr<OccupiedAreaChangeInfo> info = new OccupiedAreaChangeInfo(OccupiedAreaType::TYPE_INPUT, rect_, 80);
2077 listener->OnDialogDeathRecipient();
2078 ASSERT_EQ(true, ret);
2079 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2080 }
2081
2082 /**
2083 * @tc.name: IAceAbilityHandler
2084 * @tc.desc: IAceAbilityHandler fun
2085 * @tc.type: FUNC
2086 */
2087 HWTEST_F(WindowTest, IAceAbilityHandler, Function | SmallTest | Level3)
2088 {
2089 sptr<Window> window = new Window();
2090 ASSERT_NE(nullptr, window);
2091 auto ret = true;
2092 sptr<IAceAbilityHandler> listener = new IAceAbilityHandler();
2093 uint32_t color = 66;
2094 listener->SetBackgroundColor(color);
2095 listener->GetBackgroundColor();
2096 ASSERT_EQ(true, ret);
2097 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2098 }
2099
2100 /**
2101 * @tc.name: IDispatchInputEventListener
2102 * @tc.desc: IDispatchInputEventListener fun
2103 * @tc.type: FUNC
2104 */
2105 HWTEST_F(WindowTest, IDispatchInputEventListener, Function | SmallTest | Level3)
2106 {
2107 sptr<Window> window = new Window();
2108 ASSERT_NE(nullptr, window);
2109 auto ret = true;
2110 sptr<IDispatchInputEventListener> listener = new IDispatchInputEventListener();
2111 std::shared_ptr<MMI::KeyEvent> keyEvent = nullptr;
2112 std::shared_ptr<MMI::PointerEvent> pointerEvent = nullptr;
2113 std::shared_ptr<MMI::AxisEvent> axisEvent = nullptr;
2114 listener->OnDispatchPointerEvent(pointerEvent);
2115 listener->OnDispatchKeyEvent(keyEvent);
2116 ASSERT_EQ(true, ret);
2117 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2118 }
2119
2120 /**
2121 * @tc.name: Marshalling
2122 * @tc.desc: keyboardAnimationCurve marshalling
2123 * @tc.type: FUNC
2124 */
2125 HWTEST_F(WindowTest, keyboardAnimationCurveMarshalling, Function | SmallTest | Level3)
2126 {
2127 MessageParcel data;
2128 KeyboardAnimationCurve curveConfig;
2129 auto ret = data.WriteParcelable(&curveConfig);
2130 Parcel parcel;
2131 curveConfig.Unmarshalling(parcel);
2132 ASSERT_EQ(true, ret);
2133 }
2134
2135 /**
2136 * @tc.name: BackgroundFailed
2137 * @tc.desc: window life cycle BackgroundFailed
2138 * @tc.type: FUNC
2139 */
2140 HWTEST_F(WindowTest, WindowLifeCycleBackgroundFailed, Function | SmallTest | Level3)
2141 {
2142 IWindowLifeCycle windowLifeCycle;
2143 int32_t ret = 0;
2144 windowLifeCycle.BackgroundFailed(ret);
2145 ASSERT_EQ(0, ret);
2146 }
2147
2148 /**
2149 * @tc.name: GetVSyncPeriod
2150 * @tc.desc: window GetVSyncPeriod
2151 * @tc.type: FUNC
2152 */
2153 HWTEST_F(WindowTest, GetVSyncPeriod, Function | SmallTest | Level3)
2154 {
2155 sptr<WindowOption> winOption = nullptr;
2156 winOption = new (std::nothrow) OHOS::Rosen::WindowOption();
2157 ASSERT_NE(nullptr, winOption);
2158 winOption->SetWindowType(OHOS::Rosen::WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
2159
2160 sptr<WindowOption> option = new WindowOption;
2161 sptr<Window> window = Window::Create("win", option);
2162 if (window != nullptr) {
2163 ASSERT_NE(nullptr, window);
2164 int64_t period = window->GetVSyncPeriod();
2165 ASSERT_LE(-1, period);
2166 }
2167 sptr<Window> window_ = new Window();
2168 ASSERT_NE(nullptr, window_);
2169 int64_t period_ = window_->GetVSyncPeriod();
2170 ASSERT_LE(-1, period_);
2171 }
2172
2173 /**
2174 * @tc.name: performBack
2175 * @tc.desc: window performBack
2176 * @tc.type: FUNC
2177 */
2178 HWTEST_F(WindowTest, performBack, Function | SmallTest | Level3)
2179 {
2180 sptr<WindowOption> winOption = nullptr;
2181 winOption = new (std::nothrow) OHOS::Rosen::WindowOption();
2182 ASSERT_NE(nullptr, winOption);
2183 winOption->SetWindowType(OHOS::Rosen::WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
2184
2185 sptr<WindowOption> option = new WindowOption;
2186 sptr<Window> window = Window::Create("performBack", option);
2187 if (window != nullptr) {
2188 ASSERT_NE(nullptr, window);
2189 window->PerformBack()
2190 ;
2191 }
2192 sptr<Window> window_ = new Window();
2193 ASSERT_NE(nullptr, window_);
2194 window_->PerformBack();
2195 }
2196
2197 /**
2198 * @tc.name: SetResizeByDragEnabled
2199 * @tc.desc: set dragEnabled flag
2200 * @tc.type: FUNC
2201 */
2202 HWTEST_F(WindowTest, SetResizeByDragEnabled, 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->SetResizeByDragEnabled(true));
2207 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2208 }
2209
2210 /**
2211 * @tc.name: SetRaiseByClickEnabled
2212 * @tc.desc: set raiseEnabled flag
2213 * @tc.type: FUNC
2214 */
2215 HWTEST_F(WindowTest, SetRaiseByClickEnabled, 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->SetRaiseByClickEnabled(true));
2220 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2221 }
2222
2223 /**
2224 * @tc.name: RaiseAboveTarget
2225 * @tc.desc: RaiseAboveTarget flag
2226 * @tc.type: FUNC
2227 */
2228 HWTEST_F(WindowTest, RaiseAboveTarget, 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->RaiseAboveTarget(2));
2233 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2234 }
2235
2236 /**
2237 * @tc.name: HideNonSystemFloatingWindows
2238 * @tc.desc: set shouldHide flag
2239 * @tc.type: FUNC
2240 */
2241 HWTEST_F(WindowTest, HideNonSystemFloatingWindows, Function | SmallTest | Level2)
2242 {
2243 sptr<Window> window = new Window();
2244 ASSERT_NE(nullptr, window);
2245 ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->HideNonSystemFloatingWindows(false));
2246 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2247 }
2248
2249 /**
2250 * @tc.name: GetWindowLimits
2251 * @tc.desc: window GetWindowLimits
2252 * @tc.type: FUNC
2253 */
2254 HWTEST_F(WindowTest, GetWindowLimits, Function | SmallTest | Level2)
2255 {
2256 sptr<Window> window = new Window();
2257 ASSERT_NE(nullptr, window);
2258 WindowLimits windowLimits;
2259 auto ret = window->GetWindowLimits(windowLimits);
2260 ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ret);
2261 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2262 }
2263
2264 /**
2265 * @tc.name: SetWindowLimits
2266 * @tc.desc: window SetWindowLimits
2267 * @tc.type: FUNC
2268 */
2269 HWTEST_F(WindowTest, SetWindowLimits, Function | SmallTest | Level2)
2270 {
2271 sptr<Window> window = new Window();
2272 ASSERT_NE(nullptr, window);
2273 WindowLimits windowLimits;
2274 auto ret = window->SetWindowLimits(windowLimits, false);
2275 ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ret);
2276 ret = window->SetWindowLimits(windowLimits, true);
2277 ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ret);
2278 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2279 }
2280
2281 /**
2282 * @tc.name: RegisterWindowVisibilityChangeListener
2283 * @tc.desc: Register window visibility change listener
2284 * @tc.type: FUNC
2285 */
2286 HWTEST_F(WindowTest, RegisterWindowVisibilityChangeListener, Function | SmallTest | Level2)
2287 {
2288 sptr<Window> window = new Window();
2289 ASSERT_NE(nullptr, window);
2290 ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->RegisterWindowVisibilityChangeListener(nullptr));
2291 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2292 }
2293
2294 /**
2295 * @tc.name: UnregisterWindowVisibilityChangeListener
2296 * @tc.desc: Unregister window visibility change listener
2297 * @tc.type: FUNC
2298 */
2299 HWTEST_F(WindowTest, UnregisterWindowVisibilityChangeListener, Function | SmallTest | Level2)
2300 {
2301 sptr<Window> window = new Window();
2302 ASSERT_NE(nullptr, window);
2303 ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->UnregisterWindowVisibilityChangeListener(nullptr));
2304 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2305 }
2306
2307 /**
2308 * @tc.name: TransferAccessibilityEvent
2309 * @tc.desc: get
2310 * @tc.type: FUNC
2311 */
2312 HWTEST_F(WindowTest, TransferAccessibilityEvent, Function | SmallTest | Level2)
2313 {
2314 sptr<Window> window = new Window();
2315 ASSERT_NE(nullptr, window);
2316 Accessibility::AccessibilityEventInfo info;
2317 int64_t uiExtensionIdLevel = 0;
2318 ASSERT_EQ(WMError::WM_OK, window->TransferAccessibilityEvent(info, uiExtensionIdLevel));
2319 }
2320
2321 /**
2322 * @tc.name: FlushFrameRate
2323 * @tc.desc: FlushFrameRate Test
2324 * @tc.type: FUNC
2325 */
2326 HWTEST_F(WindowTest, FlushFrameRate, Function | SmallTest | Level2)
2327 {
2328 sptr<Window> window = new Window();
2329 ASSERT_NE(nullptr, window);
2330 uint32_t rate = 120;
2331 uint32_t rateType = 0;
2332 int32_t animatorExpectedFrameRate = -1;
2333 window->FlushFrameRate(rate, animatorExpectedFrameRate, rateType);
2334 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2335 }
2336
2337 /**
2338 * @tc.name: SetSingleFrameComposerEnabled
2339 * @tc.desc: set single frame composer enable flag
2340 * @tc.type: FUNC
2341 */
2342 HWTEST_F(WindowTest, SetSingleFrameComposerEnabled, Function | SmallTest | Level2)
2343 {
2344 sptr<Window> window = new Window();
2345 ASSERT_NE(nullptr, window);
2346 ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetSingleFrameComposerEnabled(false));
2347 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2348 }
2349
2350 /**
2351 * @tc.name: Maximize01
2352 * @tc.desc: maximize interface Test
2353 * @tc.type: FUNC
2354 */
2355 HWTEST_F(WindowTest, Maximize01, Function | SmallTest | Level2)
2356 {
2357 sptr<Window> window = new Window();
2358 ASSERT_NE(nullptr, window);
2359 MaximizePresentation presentation = MaximizePresentation::ENTER_IMMERSIVE;
2360 ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->Maximize(presentation));
2361 }
2362
2363 /**
2364 * @tc.name: RegisterWindowRectChangeListener
2365 * @tc.desc: get
2366 * @tc.type: FUNC
2367 */
2368 HWTEST_F(WindowTest, RegisterWindowRectChangeListener, Function | SmallTest | Level2)
2369 {
2370 sptr<Window> window = new Window();
2371 ASSERT_NE(nullptr, window);
2372 sptr<IWindowRectChangeListener> listener = nullptr;
2373 auto ret = window->RegisterWindowRectChangeListener(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: UnregisterWindowRectChangeListener
2380 * @tc.desc: get
2381 * @tc.type: FUNC
2382 */
2383 HWTEST_F(WindowTest, UnregisterWindowRectChangeListener, Function | SmallTest | Level2)
2384 {
2385 sptr<Window> window = new Window();
2386 ASSERT_NE(nullptr, window);
2387 sptr<IWindowRectChangeListener> listener = nullptr;
2388 auto ret = window->UnregisterWindowRectChangeListener(listener);
2389 ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ret);
2390 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2391 }
2392
2393 /**
2394 * @tc.name: RegisterKeyboardPanelInfoChangeListener
2395 * @tc.desc: get
2396 * @tc.type: FUNC
2397 */
2398 HWTEST_F(WindowTest, RegisterKeyboardPanelInfoChangeListener, Function | SmallTest | Level2)
2399 {
2400 sptr<Window> window = new Window();
2401 ASSERT_NE(nullptr, window);
2402 sptr<IKeyboardPanelInfoChangeListener> listener = nullptr;
2403 auto ret = window->RegisterKeyboardPanelInfoChangeListener(listener);
2404 ASSERT_EQ(WMError::WM_OK, ret);
2405 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2406 }
2407
2408 /**
2409 * @tc.name: UnregisterKeyboardPanelInfoChangeListener
2410 * @tc.desc: get
2411 * @tc.type: FUNC
2412 */
2413 HWTEST_F(WindowTest, UnregisterKeyboardPanelInfoChangeListener, Function | SmallTest | Level2)
2414 {
2415 sptr<Window> window = new Window();
2416 ASSERT_NE(nullptr, window);
2417 sptr<IKeyboardPanelInfoChangeListener> listener = nullptr;
2418 auto ret = window->UnregisterKeyboardPanelInfoChangeListener(listener);
2419 ASSERT_EQ(WMError::WM_OK, ret);
2420 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2421 }
2422
2423 /**
2424 * @tc.name: GetTopWindowWithContext
2425 * @tc.desc: get
2426 * @tc.type: FUNC
2427 */
2428 HWTEST_F(WindowTest, GetTopWindowWithContext, Function | SmallTest | Level2)
2429 {
2430 sptr<Window> window = new Window();
2431 ASSERT_NE(nullptr, window);
2432 std::shared_ptr<AbilityRuntime::Context> context = nullptr;
2433 auto ret = window->GetTopWindowWithContext(context);
2434 ASSERT_EQ(nullptr, ret);
2435 }
2436
2437 /**
2438 * @tc.name: GetTopWindowWithId
2439 * @tc.desc: get
2440 * @tc.type: FUNC
2441 */
2442 HWTEST_F(WindowTest, GetTopWindowWithId, Function | SmallTest | Level2)
2443 {
2444 sptr<Window> window = new Window();
2445 ASSERT_NE(nullptr, window);
2446 std::shared_ptr<AbilityRuntime::Context> context = nullptr;
2447 auto ret = window->GetTopWindowWithContext(context);
2448 ASSERT_EQ(nullptr, ret);
2449 }
2450
2451 /**
2452 * @tc.name: Create05
2453 * @tc.desc: Create window with WindowName and no abilityToken
2454 * @tc.type: FUNC
2455 */
2456 HWTEST_F(WindowTest, Create05, Function | SmallTest | Level2)
2457 {
2458 std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
2459 sptr<WindowOption> option = nullptr;
2460 auto window = Window::Create("WindowTest02", option);
2461 uint32_t version = 0;
2462 if (version < 10) {
2463 ASSERT_NE(10, version);
2464 }
2465 WindowOption windowoption;
2466 windowoption.onlySupportSceneBoard_ = true;
2467 ASSERT_NE(true, option->GetOnlySupportSceneBoard());
2468 }
2469
2470 /**
2471 * @tc.name: GetMainWindowWithContext|GetWindowWithId
2472 * |GetSubWindow|UpdateConfigurationForAll
2473 * @tc.desc: get
2474 * @tc.type: FUNC
2475 */
2476 HWTEST_F(WindowTest, GetMainWindowWithContext, Function | SmallTest | Level2)
2477 {
2478 sptr<Window> window = new Window();
2479 uint32_t windId = 0;
2480 uint32_t parentId = 1;
2481 std::shared_ptr<AppExecFwk::Configuration> configuration = nullptr;
2482
2483 std::shared_ptr<AbilityRuntime::Context> context = nullptr;
2484 auto ret = window->GetMainWindowWithContext(context);
2485 window->GetWindowWithId(windId);
2486 window->GetSubWindow(parentId);
2487 window->UpdateConfigurationForAll(configuration);
2488 ASSERT_EQ(nullptr, ret);
2489 }
2490
2491 /**
2492 * @tc.name: SetTopmost|GetWIsTopmostindowWithId
2493 * @tc.desc: get
2494 * @tc.type: FUNC
2495 */
2496 HWTEST_F(WindowTest, SetTopmost, Function | SmallTest | Level2)
2497 {
2498 sptr<Window> window = new Window();
2499 ASSERT_NE(nullptr, window);
2500 auto ret = window->SetTopmost(false);
2501 ASSERT_EQ(WMError::WM_OK, ret);
2502 ASSERT_EQ(false, window->IsTopmost());
2503 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2504 }
2505
2506 /**
2507 * @tc.name: SetUIContentByName
2508 * @tc.desc: get
2509 * @tc.type: FUNC
2510 */
2511 HWTEST_F(WindowTest, SetUIContentByName, Function | SmallTest | Level2)
2512 {
2513 sptr<Window> window = new Window();
2514 ASSERT_NE(nullptr, window);
2515 napi_env env = nullptr;
2516 napi_value storage = nullptr;
2517 auto ret = window->SetUIContentByName("/system/etc/window/resources/test.abc", env, storage);
2518 ASSERT_EQ(WMError::WM_OK, ret);
2519 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2520 }
2521
2522 /**
2523 * @tc.name: TriggerBindModalUIExtension
2524 * @tc.desc: get
2525 * @tc.type: FUNC
2526 */
2527 HWTEST_F(WindowTest, TriggerBindModalUIExtension, Function | SmallTest | Level2)
2528 {
2529 sptr<WindowOption> winOption = nullptr;
2530 winOption = new(std::nothrow) OHOS::Rosen::WindowOption();
2531 ASSERT_NE(nullptr, winOption);
2532 winOption->SetWindowType(OHOS::Rosen::WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
2533 sptr<WindowOption> option = new WindowOption();
2534 sptr<Window> window = Window::Create("TriggerBindModalUIExtension", option);
2535 if (window != nullptr) {
2536 ASSERT_NE(nullptr, window);
2537 window->TriggerBindModalUIExtension();
2538 }
2539 sptr<Window> window_ = new Window();
2540 ASSERT_NE(nullptr, window_);
2541 window_->PerformBack();
2542 }
2543
2544 /**
2545 * @tc.name: RegisterTransferComponentDataForResultListener
2546 * @tc.desc: get
2547 * @tc.type: FUNC
2548 */
2549 HWTEST_F(WindowTest, RegisterTransferComponentDataForResultListener, Function | SmallTest | Level2)
2550 {
2551 sptr<Window> window = new Window();
2552 ASSERT_NE(nullptr, window);
2553 NotifyTransferComponentDataForResultFunc func;
2554 auto ret = true;
2555 window->RegisterTransferComponentDataForResultListener(func);
2556 ASSERT_EQ(true, ret);
2557 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2558 }
2559
2560 /**
2561 * @tc.name: SetTextFieldAvoidInfo|KeepKeyboardOnFocus
2562 * @tc.desc: get
2563 * @tc.type: FUNC
2564 */
2565 HWTEST_F(WindowTest, SetTextFieldAvoidInfo, Function | SmallTest | Level2)
2566 {
2567 sptr<Window> window = new Window();
2568 ASSERT_NE(nullptr, window);
2569 auto ret = window->SetTextFieldAvoidInfo(50.0, 100.0);
2570 ASSERT_EQ(WMError::WM_OK, ret);
2571 auto retur = window->KeepKeyboardOnFocus(false);
2572 ASSERT_EQ(WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT, retur);
2573 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2574 }
2575
2576 /**
2577 * @tc.name: Test01
2578 * @tc.desc: Test01
2579 * @tc.type: FUNC
2580 */
2581 HWTEST_F(WindowTest, Test01, Function | SmallTest | Level2)
2582 {
2583 sptr<Window> window = new Window();
2584 ASSERT_NE(nullptr, window);
2585 SystemBarProperty prop;
2586 ASSERT_EQ(WMError::WM_OK, window->SetSpecificBarProperty(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, prop));
2587 ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetDecorVisible(true));
2588 ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetWindowTitleMoveEnabled(true));
2589 ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetTitleButtonVisible(true, true, true, true));
2590 auto var = 5;
2591 ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetDecorHeight(var));
2592 ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->GetDecorHeight(var));
2593 ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->ClearKeyEventFilter());
2594 IWindowVisibilityChangedListener windowVisibilityChangedListener;
2595 windowVisibilityChangedListener.OnWindowVisibilityChangedCallback(false);
2596 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2597 }
2598
2599 /**
2600 * @tc.name: Test02
2601 * @tc.desc: Test02
2602 * @tc.type: FUNC
2603 */
2604 HWTEST_F(WindowTest, Test02, Function | SmallTest | Level2)
2605 {
2606 sptr<Window> window = new Window();
2607 ASSERT_NE(nullptr, window);
2608 IWindowLifeCycle windowLifeCycle;
2609 windowLifeCycle.AfterResumed();
2610 windowLifeCycle.AfterPaused();
2611 windowLifeCycle.AfterDestroyed();
2612 IWindowStatusChangeListener windowStatusChangeListener;
2613 windowStatusChangeListener.OnWindowStatusChange(WindowStatus::WINDOW_STATUS_UNDEFINED);
2614 ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetDefaultDensityEnabled(true));
2615 ASSERT_EQ(false, window->GetDefaultDensityEnabled());
2616 Rect rect_ = {0, 0, 0, 0};
2617 window->UpdatePiPRect(rect_, WindowSizeChangeReason::UNDEFINED);
2618 IWindowRectChangeListener windowRectChangeListener;
2619 windowRectChangeListener.OnRectChange(rect_, WindowSizeChangeReason::UNDEFINED);
2620 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2621 }
2622
2623 /**
2624 * @tc.name: Test03
2625 * @tc.desc: Test03
2626 * @tc.type: FUNC
2627 */
2628 HWTEST_F(WindowTest, Test03, Function | SmallTest | Level2)
2629 {
2630 sptr<Window> window = new Window();
2631 ASSERT_NE(nullptr, window);
2632 KeyEventFilterFunc keyEventFilterFunc;
2633 ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetKeyEventFilter(keyEventFilterFunc));
2634 IWindowNoInteractionListener windowNoInteractionListener;
2635 windowNoInteractionListener.OnWindowNoInteractionCallback();
2636 windowNoInteractionListener.SetTimeout(100);
2637 ASSERT_EQ(0, windowNoInteractionListener.GetTimeout());
2638 TitleButtonRect titleButtonRect = {3, 3, 3, 3};
2639 ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->GetTitleButtonArea(titleButtonRect));
2640 IWindowTitleButtonRectChangedListener windowTitleButtonRectChangedListener;
2641 windowTitleButtonRectChangedListener.OnWindowTitleButtonRectChanged(titleButtonRect);
2642 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2643 }
2644
2645 /**
2646 * @tc.name: Test04
2647 * @tc.desc: Test04
2648 * @tc.type: FUNC
2649 */
2650 HWTEST_F(WindowTest, Test04, Function | SmallTest | Level2)
2651 {
2652 sptr<Window> window = new Window();
2653 ASSERT_NE(nullptr, window);
2654 ASSERT_EQ(nullptr, window->GetUIContentWithId(0));
2655 window->TriggerBindModalUIExtension();
2656 ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetGrayScale(0));
2657 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2658 }
2659
2660 /**
2661 * @tc.name: Test05
2662 * @tc.desc: Test05
2663 * @tc.type: FUNC
2664 */
2665 HWTEST_F(WindowTest, Test05, Function | SmallTest | Level2)
2666 {
2667 sptr<Window> window = new Window();
2668 ASSERT_NE(nullptr, window);
2669 auto mainWinId = 0;
2670 auto window1 = window->GetTopWindowWithId(mainWinId);
2671 ASSERT_EQ(nullptr, window1);
2672 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2673 }
2674
2675 /**
2676 * @tc.name: SetTitleButtonVisible
2677 * @tc.desc: SetTitleButtonVisible
2678 * @tc.type: FUNC
2679 */
2680 HWTEST_F(WindowTest, SetTitleButtonVisible, Function | SmallTest | Level2)
2681 {
2682 sptr<Window> window = new (std::nothrow) Window();
2683 ASSERT_NE(window, nullptr);
2684 WMError res = window->SetTitleButtonVisible(true, true, true, true);
2685 ASSERT_EQ(res, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
2686 res = window->SetTitleButtonVisible(false, true, true, true);
2687 ASSERT_EQ(res, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
2688 res = window->SetTitleButtonVisible(true, false, true, true);
2689 ASSERT_EQ(res, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
2690 res = window->SetTitleButtonVisible(true, true, false, true);
2691 ASSERT_EQ(res, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
2692 res = window->SetTitleButtonVisible(false, false, true, true);
2693 ASSERT_EQ(res, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
2694 res = window->SetTitleButtonVisible(false, true, false, true);
2695 ASSERT_EQ(res, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
2696 res = window->SetTitleButtonVisible(true, false, false, true);
2697 ASSERT_EQ(res, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
2698 res = window->SetTitleButtonVisible(false, false, false, true);
2699 ASSERT_EQ(res, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
2700 }
2701
2702 /**
2703 * @tc.name: SetWindowTitle
2704 * @tc.desc: SetWindowTitle
2705 * @tc.type: FUNC
2706 */
2707 HWTEST_F(WindowTest, SetWindowTitle, Function | SmallTest | Level2)
2708 {
2709 sptr<Window> window = sptr<Window>::MakeSptr();
2710 std::string title = "SetWindowTitle";
2711 auto ret = window->SetWindowTitle(title);
2712 ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ret);
2713 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2714 }
2715
2716 /**
2717 * @tc.name: GetWindowStatus
2718 * @tc.desc: GetWindowStatus
2719 * @tc.type: FUNC
2720 */
2721 HWTEST_F(WindowTest, GetWindowStatus, Function | SmallTest | Level2)
2722 {
2723 sptr<Window> window = new (std::nothrow) Window();
2724 ASSERT_NE(window, nullptr);
2725 WindowStatus windowStatus;
2726 auto ret = window->GetWindowStatus(windowStatus);
2727 ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ret);
2728 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2729 }
2730
2731 /**
2732 * @tc.name: IsPcOrPadCapabilityEnabled
2733 * @tc.desc: IsPcOrPadCapabilityEnabled
2734 * @tc.type: FUNC
2735 */
2736 HWTEST_F(WindowTest, IsPcOrPadCapabilityEnabled, Function | SmallTest | Level2)
2737 {
2738 sptr<Window> window = sptr<Window>::MakeSptr();
2739 ASSERT_NE(window, nullptr);
2740 auto ret = window->IsPcOrPadCapabilityEnabled();
2741 EXPECT_EQ(false, ret);
2742 EXPECT_EQ(WMError::WM_OK, window->Destroy());
2743 }
2744
2745 /**
2746 * @tc.name: RegisterMainWindowCloseListeners
2747 * @tc.desc: RegisterMainWindowCloseListeners
2748 * @tc.type: FUNC
2749 */
2750 HWTEST_F(WindowTest, RegisterMainWindowCloseListeners, Function | SmallTest | Level2)
2751 {
2752 sptr<Window> window = sptr<Window>::MakeSptr();
2753 ASSERT_NE(window, nullptr);
2754 sptr<IMainWindowCloseListener> listener = sptr<IMainWindowCloseListener>::MakeSptr();
2755 auto ret = window->RegisterMainWindowCloseListeners(listener);
2756 EXPECT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ret);
2757 EXPECT_EQ(WMError::WM_OK, window->Destroy());
2758 }
2759
2760 /**
2761 * @tc.name: UnregisterMainWindowCloseListeners
2762 * @tc.desc: UnregisterMainWindowCloseListeners
2763 * @tc.type: FUNC
2764 */
2765 HWTEST_F(WindowTest, UnregisterMainWindowCloseListeners, Function | SmallTest | Level2)
2766 {
2767 sptr<Window> window = sptr<Window>::MakeSptr();
2768 ASSERT_NE(window, nullptr);
2769 sptr<IMainWindowCloseListener> listener = sptr<IMainWindowCloseListener>::MakeSptr();
2770 auto ret = window->UnregisterMainWindowCloseListeners(listener);
2771 EXPECT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ret);
2772 EXPECT_EQ(WMError::WM_OK, window->Destroy());
2773 }
2774
2775 /**
2776 * @tc.name: RegisterWindowWillCloseListeners
2777 * @tc.desc: RegisterWindowWillCloseListeners
2778 * @tc.type: FUNC
2779 */
2780 HWTEST_F(WindowTest, RegisterWindowWillCloseListeners, Function | SmallTest | Level2)
2781 {
2782 sptr<Window> window = sptr<Window>::MakeSptr();
2783 sptr<IWindowWillCloseListener> listener = sptr<IWindowWillCloseListener>::MakeSptr();
2784 auto ret = window->RegisterWindowWillCloseListeners(listener);
2785 EXPECT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ret);
2786 EXPECT_EQ(WMError::WM_OK, window->Destroy());
2787 }
2788
2789 /**
2790 * @tc.name: UnRegisterWindowWillCloseListeners
2791 * @tc.desc: UnRegisterWindowWillCloseListeners
2792 * @tc.type: FUNC
2793 */
2794 HWTEST_F(WindowTest, UnRegisterWindowWillCloseListeners, Function | SmallTest | Level2)
2795 {
2796 sptr<Window> window = sptr<Window>::MakeSptr();
2797 sptr<IWindowWillCloseListener> listener = sptr<IWindowWillCloseListener>::MakeSptr();
2798 auto ret = window->UnRegisterWindowWillCloseListeners(listener);
2799 EXPECT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ret);
2800 EXPECT_EQ(WMError::WM_OK, window->Destroy());
2801 }
2802
2803 /**
2804 * @tc.name: GetIsMidScene
2805 * @tc.desc: GetIsMidScene
2806 * @tc.type: FUNC
2807 */
2808 HWTEST_F(WindowTest, GetIsMidScene, Function | SmallTest | Level2)
2809 {
2810 sptr<Window> window = sptr<Window>::MakeSptr();
2811 bool isMidScene = false;
2812 WMError res = window->GetIsMidScene(isMidScene);
2813 EXPECT_EQ(WMError::WM_OK, res);
2814 ASSERT_EQ(isMidScene, false);
2815 EXPECT_EQ(WMError::WM_OK, window->Destroy());
2816 }
2817
2818 /**
2819 * @tc.name: GetLayoutTransform
2820 * @tc.desc: get
2821 * @tc.type: FUNC
2822 */
2823 HWTEST_F(WindowTest, GetLayoutTransform, Function | SmallTest | Level2)
2824 {
2825 sptr<Window> window = sptr<Window>::MakeSptr();
2826 Transform trans;
2827 ASSERT_EQ(trans, window->GetLayoutTransform());
2828 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2829 }
2830 } // namespace
2831 } // namespace Rosen
2832 } // namespace OHOS