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
24 using namespace testing;
25 using namespace testing::ext;
26
27 namespace OHOS {
28 namespace Rosen {
29 using Mocker = SingletonMocker<WindowAdapter, MockWindowAdapter>;
30 class WindowTest : public testing::Test {
31 public:
32 static void SetUpTestCase();
33 static void TearDownTestCase();
34 virtual void SetUp() override;
35 virtual void TearDown() override;
36 static inline std::shared_ptr<AbilityRuntime::AbilityContext> abilityContext_;
37 };
SetUpTestCase()38 void WindowTest::SetUpTestCase()
39 {
40 abilityContext_ = std::make_shared<AbilityRuntime::AbilityContextImpl>();
41 }
42
TearDownTestCase()43 void WindowTest::TearDownTestCase()
44 {
45 }
46
SetUp()47 void WindowTest::SetUp()
48 {
49 }
50
TearDown()51 void WindowTest::TearDown()
52 {
53 }
54
55 namespace {
56 /**
57 * @tc.name: Create01
58 * @tc.desc: Create window with no WindowName and no abilityToken
59 * @tc.type: FUNC
60 */
61 HWTEST_F(WindowTest, Create01, Function | SmallTest | Level2)
62 {
63 sptr<WindowOption> option = new WindowOption();
64 ASSERT_EQ(nullptr, Window::Create("", option));
65 }
66
67 /**
68 * @tc.name: Create02
69 * @tc.desc: Create window with WindowName and no abilityToken
70 * @tc.type: FUNC
71 */
72 HWTEST_F(WindowTest, Create02, Function | SmallTest | Level2)
73 {
74 std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
75 sptr<WindowOption> option = new WindowOption();
76 auto window = Window::Create("WindowTest02", option);
77 if (window != nullptr)
78 {
79 ASSERT_NE(nullptr, window);
80 }
81 if (window != nullptr)
82 {
83 ASSERT_EQ(WMError::WM_OK, window->Destroy());
84 }
85 }
86
87 /**
88 * @tc.name: Create03
89 * @tc.desc: Mock CreateWindow return WM_ERROR_SAMGR, create window with WindowName and no abilityToken
90 * @tc.type: FUNC
91 */
92 HWTEST_F(WindowTest, Create03, Function | SmallTest | Level2)
93 {
94 std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
95 sptr<WindowOption> option = new WindowOption();
96 auto window = Window::Create("WindowTest03", option);
97 if (window != nullptr) {
98 ASSERT_EQ(nullptr, Window::Create("WindowTest03", option));
99 }
100 }
101
102 /**
103 * @tc.name: Create04
104 * @tc.desc: Create window with WindowName and no option
105 * @tc.type: FUNC
106 */
107 HWTEST_F(WindowTest, Create04, Function | SmallTest | Level2)
108 {
109 sptr<WindowOption> option = nullptr;
110 ASSERT_EQ(nullptr, Window::Create("", option));
111 }
112
113 /**
114 * @tc.name: Find01
115 * @tc.desc: Find with no name
116 * @tc.type: FUNC
117 */
118 HWTEST_F(WindowTest, Find01, Function | SmallTest | Level2)
119 {
120 ASSERT_EQ(nullptr, Window::Find(""));
121 }
122
123 /**
124 * @tc.name: Find02
125 * @tc.desc: Find with name
126 * @tc.type: FUNC
127 */
128 HWTEST_F(WindowTest, Find02, Function | SmallTest | Level2)
129 {
130 std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
131 sptr<WindowOption> option = new WindowOption();
132
133 auto window = Window::Create("WindowTest03", option);
134 if (window != nullptr) {
135 ASSERT_NE(nullptr, window);
136 }
137 if (Window::Find("WindowTest03") != nullptr) {
138 ASSERT_NE(nullptr, Window::Find("WindowTest03"));
139 }
140
141 if (window != nullptr) {
142 ASSERT_EQ(WMError::WM_OK, window->Destroy());
143 }
144 }
145
146 /**
147 * @tc.name: GetSurfaceNode
148 * @tc.desc: get node
149 * @tc.type: FUNC
150 */
151 HWTEST_F(WindowTest, GetSurfaceNode, Function | SmallTest | Level2)
152 {
153 sptr<Window> window = new Window();
154 ASSERT_NE(nullptr, window);
155 ASSERT_EQ(nullptr, window->GetSurfaceNode());
156 ASSERT_EQ(WMError::WM_OK, window->Destroy());
157 }
158
159 /**
160 * @tc.name: GetContext
161 * @tc.desc: get context
162 * @tc.type: FUNC
163 */
164 HWTEST_F(WindowTest, GetContext, Function | SmallTest | Level2)
165 {
166 sptr<Window> window = new Window();
167 ASSERT_NE(nullptr, window);
168 ASSERT_EQ(nullptr, window->GetContext());
169 ASSERT_EQ(WMError::WM_OK, window->Destroy());
170 }
171
172 /**
173 * @tc.name: GetRect
174 * @tc.desc: get rect
175 * @tc.type: FUNC
176 */
177 HWTEST_F(WindowTest, GetRect, Function | SmallTest | Level2)
178 {
179 sptr<Window> window = new Window();
180 ASSERT_NE(nullptr, window);
181 ASSERT_EQ(Rect(), window->GetRect());
182 ASSERT_EQ(WMError::WM_OK, window->Destroy());
183 }
184
185 /**
186 * @tc.name: GetRequestRect
187 * @tc.desc: get rect
188 * @tc.type: FUNC
189 */
190 HWTEST_F(WindowTest, GetRequestRect, Function | SmallTest | Level2)
191 {
192 sptr<Window> window = new Window();
193 ASSERT_NE(nullptr, window);
194 ASSERT_EQ(Rect(), window->GetRequestRect());
195 ASSERT_EQ(WMError::WM_OK, window->Destroy());
196 }
197
198 /**
199 * @tc.name: GetType
200 * @tc.desc: get type
201 * @tc.type: FUNC
202 */
203 HWTEST_F(WindowTest, GetType, Function | SmallTest | Level2)
204 {
205 sptr<Window> window = new Window();
206 ASSERT_NE(nullptr, window);
207 ASSERT_EQ(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, window->GetType());
208 ASSERT_EQ(WMError::WM_OK, window->Destroy());
209 }
210
211 /**
212 * @tc.name: GetMode
213 * @tc.desc: get mode
214 * @tc.type: FUNC
215 */
216 HWTEST_F(WindowTest, GetMode, Function | SmallTest | Level2)
217 {
218 sptr<Window> window = new Window();
219 ASSERT_NE(nullptr, window);
220 ASSERT_EQ(WindowMode::WINDOW_MODE_UNDEFINED, window->GetMode());
221 ASSERT_EQ(WMError::WM_OK, window->Destroy());
222
223 auto window_ = new (std::nothrow)Window();
224 ASSERT_NE(nullptr, window_);
225 ASSERT_EQ(WindowMode::WINDOW_MODE_UNDEFINED, window_->GetMode());
226 }
227
228 /**
229 * @tc.name: GetAlpha
230 * @tc.desc: get alpha
231 * @tc.type: FUNC
232 */
233 HWTEST_F(WindowTest, GetAlpha, Function | SmallTest | Level2)
234 {
235 sptr<Window> window = new Window();
236 ASSERT_NE(nullptr, window);
237 ASSERT_EQ(0.0f, window->GetAlpha());
238 ASSERT_EQ(WMError::WM_OK, window->Destroy());
239 }
240
241 /**
242 * @tc.name: GetFocusable
243 * @tc.desc: get focusable
244 * @tc.type: FUNC
245 */
246 HWTEST_F(WindowTest, GetFocusable, Function | SmallTest | Level2)
247 {
248 sptr<Window> window = new Window();
249 ASSERT_NE(nullptr, window);
250 ASSERT_EQ(false, window->GetFocusable());
251 ASSERT_EQ(WMError::WM_OK, window->Destroy());
252 }
253
254 /**
255 * @tc.name: SetFocusable
256 * @tc.desc: set Focusable
257 * @tc.type: FUNC
258 */
259 HWTEST_F(WindowTest, SetFocusable, Function | SmallTest | Level2)
260 {
261 sptr<Window> window = new Window();
262 ASSERT_NE(nullptr, window);
263 ASSERT_EQ(WMError::WM_OK, window->SetFocusable(true));
264 ASSERT_EQ(WMError::WM_OK, window->Destroy());
265 }
266
267 /**
268 * @tc.name: GetTouchable
269 * @tc.desc: get Touchable
270 * @tc.type: FUNC
271 */
272 HWTEST_F(WindowTest, GetTouchable, Function | SmallTest | Level2)
273 {
274 sptr<Window> window = new Window();
275 ASSERT_NE(nullptr, window);
276 ASSERT_EQ(false, window->GetTouchable());
277 ASSERT_EQ(WMError::WM_OK, window->Destroy());
278 }
279
280 /**
281 * @tc.name: SetTouchable
282 * @tc.desc: set Touchable
283 * @tc.type: FUNC
284 */
285 HWTEST_F(WindowTest, SetTouchable, Function | SmallTest | Level2)
286 {
287 sptr<Window> window = new Window();
288 ASSERT_NE(nullptr, window);
289 ASSERT_EQ(WMError::WM_OK, window->SetTouchable(true));
290 ASSERT_EQ(WMError::WM_OK, window->Destroy());
291 }
292
293 /**
294 * @tc.name: GetSystemBarPropertyByType
295 * @tc.desc: get SystemBarPropertyByType
296 * @tc.type: FUNC
297 */
298 HWTEST_F(WindowTest, GetSystemBarPropertyByType, Function | SmallTest | Level2)
299 {
300 sptr<Window> window = new Window();
301 ASSERT_NE(nullptr, window);
302 ASSERT_EQ(SystemBarProperty(), window->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW));
303 ASSERT_EQ(WMError::WM_OK, window->Destroy());
304 }
305
306 /**
307 * @tc.name: SetSystemBarProperty
308 * @tc.desc: set SystemBarProperty
309 * @tc.type: FUNC
310 */
311 HWTEST_F(WindowTest, SetSystemBarProperty, Function | SmallTest | Level2)
312 {
313 sptr<Window> window = new Window();
314 SystemBarProperty prop;
315 ASSERT_NE(nullptr, window);
316 auto ret = window->SetSystemBarProperty(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, prop);
317 ASSERT_EQ(WMError::WM_OK, ret);
318 ASSERT_EQ(WMError::WM_OK, window->Destroy());
319 }
320
321 /**
322 * @tc.name: IsFullScreen
323 * @tc.desc: get FullScreen
324 * @tc.type: FUNC
325 */
326 HWTEST_F(WindowTest, IsFullScreen, Function | SmallTest | Level2)
327 {
328 sptr<Window> window = new Window();
329 ASSERT_NE(nullptr, window);
330 ASSERT_EQ(false, window->IsFullScreen());
331 ASSERT_EQ(WMError::WM_OK, window->Destroy());
332 }
333
334 /**
335 * @tc.name: IsLayoutFullScreen
336 * @tc.desc: get
337 * @tc.type: FUNC
338 */
339 HWTEST_F(WindowTest, IsLayoutFullScreen, Function | SmallTest | Level2)
340 {
341 sptr<Window> window = new Window();
342 ASSERT_NE(nullptr, window);
343 ASSERT_EQ(false, window->IsLayoutFullScreen());
344 ASSERT_EQ(WMError::WM_OK, window->Destroy());
345 }
346
347 /**
348 * @tc.name: SetAlpha
349 * @tc.desc: set
350 * @tc.type: FUNC
351 */
352 HWTEST_F(WindowTest, SetAlpha, Function | SmallTest | Level2)
353 {
354 sptr<Window> window = new Window();
355 ASSERT_NE(nullptr, window);
356 ASSERT_EQ(WMError::WM_OK, window->SetAlpha(0.0f));
357 ASSERT_EQ(WMError::WM_OK, window->Destroy());
358 }
359
360 /**
361 * @tc.name: SetTransform
362 * @tc.desc: set
363 * @tc.type: FUNC
364 */
365 HWTEST_F(WindowTest, SetTransform, Function | SmallTest | Level2)
366 {
367 sptr<Window> window = new Window();
368 ASSERT_NE(nullptr, window);
369 Transform trans;
370 ASSERT_EQ(WMError::WM_OK, window->SetTransform(trans));
371 ASSERT_EQ(WMError::WM_OK, window->Destroy());
372 }
373
374 /**
375 * @tc.name: GetTransform
376 * @tc.desc: get
377 * @tc.type: FUNC
378 */
379 HWTEST_F(WindowTest, GetTransform, Function | SmallTest | Level2)
380 {
381 sptr<Window> window = new Window();
382 ASSERT_NE(nullptr, window);
383 Transform trans;
384 ASSERT_EQ(trans, window->GetTransform());
385 ASSERT_EQ(WMError::WM_OK, window->Destroy());
386 }
387
388 /**
389 * @tc.name: GetAvoidAreaByType
390 * @tc.desc: get
391 * @tc.type: FUNC
392 */
393 HWTEST_F(WindowTest, GetAvoidAreaByType, Function | SmallTest | Level2)
394 {
395 sptr<Window> window = new Window();
396 ASSERT_NE(nullptr, window);
397 AvoidArea avoidArea;
398 auto ret = window->GetAvoidAreaByType(AvoidAreaType::TYPE_CUTOUT, avoidArea);
399 ASSERT_EQ(WMError::WM_OK, ret);
400 ASSERT_EQ(WMError::WM_OK, window->Destroy());
401 }
402
403 /**
404 * @tc.name: SetLayoutFullScreen
405 * @tc.desc: get
406 * @tc.type: FUNC
407 */
408 HWTEST_F(WindowTest, SetLayoutFullScreen, Function | SmallTest | Level2)
409 {
410 sptr<Window> window = new Window();
411 ASSERT_NE(nullptr, window);
412 auto ret = window->SetLayoutFullScreen(true);
413 ASSERT_EQ(WMError::WM_OK, ret);
414 ASSERT_EQ(WMError::WM_OK, window->Destroy());
415 }
416
417 /**
418 * @tc.name: SetFullScreen
419 * @tc.desc: get
420 * @tc.type: FUNC
421 */
422 HWTEST_F(WindowTest, SetFullScreen, Function | SmallTest | Level2)
423 {
424 sptr<Window> window = new Window();
425 ASSERT_NE(nullptr, window);
426 auto ret = window->SetFullScreen(true);
427 ASSERT_EQ(WMError::WM_OK, ret);
428 ASSERT_EQ(WMError::WM_OK, window->Destroy());
429 }
430
431 /**
432 * @tc.name: Destroy
433 * @tc.desc: get
434 * @tc.type: FUNC
435 */
436 HWTEST_F(WindowTest, Destroy, Function | SmallTest | Level2)
437 {
438 sptr<Window> window = new Window();
439 ASSERT_NE(nullptr, window);
440 auto ret = window->Destroy();
441 ASSERT_EQ(WMError::WM_OK, ret);
442 ASSERT_EQ(WMError::WM_OK, window->Destroy());
443 }
444
445 /**
446 * @tc.name: Show
447 * @tc.desc: get
448 * @tc.type: FUNC
449 */
450 HWTEST_F(WindowTest, Show, Function | SmallTest | Level2)
451 {
452 sptr<Window> window = new Window();
453 ASSERT_NE(nullptr, window);
454 auto ret = window->Show();
455 ASSERT_EQ(WMError::WM_OK, ret);
456 ASSERT_EQ(WMError::WM_OK, window->Destroy());
457 }
458
459 /**
460 * @tc.name: Hide
461 * @tc.desc: get
462 * @tc.type: FUNC
463 */
464 HWTEST_F(WindowTest, Hide, Function | SmallTest | Level2)
465 {
466 sptr<Window> window = new Window();
467 ASSERT_NE(nullptr, window);
468 auto ret = window->Hide();
469 ASSERT_EQ(WMError::WM_OK, ret);
470 ASSERT_EQ(WMError::WM_OK, window->Destroy());
471 }
472
473 /**
474 * @tc.name: MoveTo
475 * @tc.desc: get
476 * @tc.type: FUNC
477 */
478 HWTEST_F(WindowTest, MoveTo, Function | SmallTest | Level2)
479 {
480 sptr<Window> window = new Window();
481 ASSERT_NE(nullptr, window);
482 auto ret = window->MoveTo(0, 0);
483 ASSERT_EQ(WMError::WM_OK, ret);
484 ASSERT_EQ(WMError::WM_OK, window->Destroy());
485 }
486
487 /**
488 * @tc.name: Resize
489 * @tc.desc: get
490 * @tc.type: FUNC
491 */
492 HWTEST_F(WindowTest, Resize, Function | SmallTest | Level2)
493 {
494 sptr<Window> window = new Window();
495 ASSERT_NE(nullptr, window);
496 auto ret = window->Resize(0, 0);
497 ASSERT_EQ(WMError::WM_OK, ret);
498 ASSERT_EQ(WMError::WM_OK, window->Destroy());
499 }
500
501 /**
502 * @tc.name: SetKeepScreenOn
503 * @tc.desc: get
504 * @tc.type: FUNC
505 */
506 HWTEST_F(WindowTest, SetKeepScreenOn, Function | SmallTest | Level2)
507 {
508 sptr<Window> window = new Window();
509 ASSERT_NE(nullptr, window);
510 auto ret = window->SetKeepScreenOn(true);
511 ASSERT_EQ(WMError::WM_OK, ret);
512 ASSERT_EQ(WMError::WM_OK, window->Destroy());
513 }
514
515 /**
516 * @tc.name: IsKeepScreenOn
517 * @tc.desc: get
518 * @tc.type: FUNC
519 */
520 HWTEST_F(WindowTest, IsKeepScreenOn, Function | SmallTest | Level2)
521 {
522 sptr<Window> window = new Window();
523 ASSERT_NE(nullptr, window);
524 auto ret = window->IsKeepScreenOn();
525 ASSERT_EQ(false, ret);
526 ASSERT_EQ(WMError::WM_OK, window->Destroy());
527 }
528
529 /**
530 * @tc.name: SetTurnScreenOn
531 * @tc.desc: get
532 * @tc.type: FUNC
533 */
534 HWTEST_F(WindowTest, SetTurnScreenOn, Function | SmallTest | Level2)
535 {
536 sptr<Window> window = new Window();
537 ASSERT_NE(nullptr, window);
538 auto ret = window->SetTurnScreenOn(true);
539 ASSERT_EQ(WMError::WM_OK, ret);
540 ASSERT_EQ(WMError::WM_OK, window->Destroy());
541 }
542
543 /**
544 * @tc.name: IsTurnScreenOn
545 * @tc.desc: get
546 * @tc.type: FUNC
547 */
548 HWTEST_F(WindowTest, IsTurnScreenOn, Function | SmallTest | Level2)
549 {
550 sptr<Window> window = new Window();
551 ASSERT_NE(nullptr, window);
552 auto ret = window->IsTurnScreenOn();
553 ASSERT_EQ(false, ret);
554 ASSERT_EQ(WMError::WM_OK, window->Destroy());
555 }
556
557 /**
558 * @tc.name: SetBackgroundColor
559 * @tc.desc: get
560 * @tc.type: FUNC
561 */
562 HWTEST_F(WindowTest, SetBackgroundColor, Function | SmallTest | Level2)
563 {
564 sptr<Window> window = new Window();
565 ASSERT_NE(nullptr, window);
566 auto ret = window->SetBackgroundColor("0x00000000");
567 ASSERT_EQ(WMError::WM_OK, ret);
568 ASSERT_EQ(WMError::WM_OK, window->Destroy());
569 }
570
571 /**
572 * @tc.name: SetTransparent
573 * @tc.desc: get
574 * @tc.type: FUNC
575 */
576 HWTEST_F(WindowTest, SetTransparent, Function | SmallTest | Level2)
577 {
578 sptr<Window> window = new Window();
579 ASSERT_NE(nullptr, window);
580 auto ret = window->SetTransparent(true);
581 ASSERT_EQ(WMError::WM_OK, ret);
582 ASSERT_EQ(WMError::WM_OK, window->Destroy());
583 }
584
585 /**
586 * @tc.name: IsTransparent
587 * @tc.desc: get
588 * @tc.type: FUNC
589 */
590 HWTEST_F(WindowTest, IsTransparent, Function | SmallTest | Level2)
591 {
592 sptr<Window> window = new Window();
593 ASSERT_NE(nullptr, window);
594 auto ret = window->IsTransparent();
595 ASSERT_EQ(false, ret);
596 ASSERT_EQ(WMError::WM_OK, window->Destroy());
597 }
598
599 /**
600 * @tc.name: SetBrightness
601 * @tc.desc: get
602 * @tc.type: FUNC
603 */
604 HWTEST_F(WindowTest, SetBrightness, Function | SmallTest | Level2)
605 {
606 sptr<Window> window = new Window();
607 ASSERT_NE(nullptr, window);
608 auto ret = window->SetBrightness(0.0f);
609 ASSERT_EQ(WMError::WM_OK, ret);
610 ASSERT_EQ(WMError::WM_OK, window->Destroy());
611 }
612
613 /**
614 * @tc.name: GetBrightness
615 * @tc.desc: get
616 * @tc.type: FUNC
617 */
618 HWTEST_F(WindowTest, GetBrightness, Function | SmallTest | Level2)
619 {
620 sptr<Window> window = new Window();
621 ASSERT_NE(nullptr, window);
622 auto ret = window->GetBrightness();
623 ASSERT_EQ(0.0f, ret);
624 ASSERT_EQ(WMError::WM_OK, window->Destroy());
625 }
626
627 /**
628 * @tc.name: SetPrivacyMode
629 * @tc.desc: get
630 * @tc.type: FUNC
631 */
632 HWTEST_F(WindowTest, SetPrivacyMode, Function | SmallTest | Level2)
633 {
634 sptr<Window> window = new Window();
635 ASSERT_NE(nullptr, window);
636 auto ret = window->SetPrivacyMode(0.0f);
637 ASSERT_EQ(WMError::WM_OK, ret);
638 ASSERT_EQ(WMError::WM_OK, window->Destroy());
639 }
640
641 /**
642 * @tc.name: IsPrivacyMode
643 * @tc.desc: get
644 * @tc.type: FUNC
645 */
646 HWTEST_F(WindowTest, IsPrivacyMode, Function | SmallTest | Level2)
647 {
648 sptr<Window> window = new Window();
649 ASSERT_NE(nullptr, window);
650 auto ret = window->IsPrivacyMode();
651 ASSERT_EQ(false, ret);
652 ASSERT_EQ(WMError::WM_OK, window->Destroy());
653 }
654
655 /**
656 * @tc.name: SetSystemPrivacyMode
657 * @tc.desc: get
658 * @tc.type: FUNC
659 */
660 HWTEST_F(WindowTest, SetSystemPrivacyMode, Function | SmallTest | Level2)
661 {
662 sptr<Window> window = new Window();
663 ASSERT_NE(nullptr, window);
664 auto ret = false;
665 window->SetSystemPrivacyMode(true);
666 ASSERT_EQ(false, ret);
667 ASSERT_EQ(WMError::WM_OK, window->Destroy());
668 }
669
670 /**
671 * @tc.name: BindDialogTarget
672 * @tc.desc: get
673 * @tc.type: FUNC
674 */
675 HWTEST_F(WindowTest, BindDialogTarget, Function | SmallTest | Level2)
676 {
677 sptr<Window> window = new Window();
678 ASSERT_NE(nullptr, window);
679 sptr<IRemoteObject> targetToken;
680 auto ret = window->BindDialogTarget(targetToken);
681 ASSERT_EQ(WMError::WM_OK, ret);
682 ASSERT_EQ(WMError::WM_OK, window->Destroy());
683 }
684
685 /**
686 * @tc.name: RaiseToAppTop
687 * @tc.desc: get
688 * @tc.type: FUNC
689 */
690 HWTEST_F(WindowTest, RaiseToAppTop, Function | SmallTest | Level2)
691 {
692 sptr<Window> window = new Window();
693 ASSERT_NE(nullptr, window);
694 auto ret = window->RaiseToAppTop();
695 ASSERT_EQ(WmErrorCode::WM_OK, ret);
696 ASSERT_EQ(WMError::WM_OK, window->Destroy());
697 }
698
699 /**
700 * @tc.name: SetSnapshotSkip
701 * @tc.desc: get
702 * @tc.type: FUNC
703 */
704 HWTEST_F(WindowTest, SetSnapshotSkip, Function | SmallTest | Level2)
705 {
706 sptr<Window> window = new Window();
707 ASSERT_NE(nullptr, window);
708 auto ret = window->SetSnapshotSkip(true);
709 ASSERT_EQ(WMError::WM_OK, ret);
710 ASSERT_EQ(WMError::WM_OK, window->Destroy());
711 }
712
713 /**
714 * @tc.name: SetCornerRadius
715 * @tc.desc: get
716 * @tc.type: FUNC
717 */
718 HWTEST_F(WindowTest, SetCornerRadius, Function | SmallTest | Level2)
719 {
720 sptr<Window> window = new Window();
721 ASSERT_NE(nullptr, window);
722 auto ret = window->SetCornerRadius(1.0f);
723 ASSERT_EQ(WMError::WM_OK, ret);
724 ASSERT_EQ(WMError::WM_OK, window->Destroy());
725 }
726
727 /**
728 * @tc.name: SetShadowRadius
729 * @tc.desc: get
730 * @tc.type: FUNC
731 */
732 HWTEST_F(WindowTest, SetShadowRadius, Function | SmallTest | Level2)
733 {
734 sptr<Window> window = new Window();
735 ASSERT_NE(nullptr, window);
736 auto ret = window->SetShadowRadius(1.0f);
737 ASSERT_EQ(WMError::WM_OK, ret);
738 ASSERT_EQ(WMError::WM_OK, window->Destroy());
739 }
740
741 /**
742 * @tc.name: SetShadowColor
743 * @tc.desc: get
744 * @tc.type: FUNC
745 */
746 HWTEST_F(WindowTest, SetShadowColor, Function | SmallTest | Level2)
747 {
748 sptr<Window> window = new Window();
749 ASSERT_NE(nullptr, window);
750 auto ret = window->SetShadowColor("0x00000000");
751 ASSERT_EQ(WMError::WM_OK, ret);
752 ASSERT_EQ(WMError::WM_OK, window->Destroy());
753 }
754
755 /**
756 * @tc.name: SetShadowOffsetX
757 * @tc.desc: get
758 * @tc.type: FUNC
759 */
760 HWTEST_F(WindowTest, SetShadowOffsetX, Function | SmallTest | Level2)
761 {
762 sptr<Window> window = new Window();
763 ASSERT_NE(nullptr, window);
764 auto ret = window->SetShadowOffsetX(0.0f);
765 ASSERT_EQ(WMError::WM_OK, ret);
766 ASSERT_EQ(WMError::WM_OK, window->Destroy());
767 }
768
769 /**
770 * @tc.name: SetShadowOffsetY
771 * @tc.desc: get
772 * @tc.type: FUNC
773 */
774 HWTEST_F(WindowTest, SetShadowOffsetY, Function | SmallTest | Level2)
775 {
776 sptr<Window> window = new Window();
777 ASSERT_NE(nullptr, window);
778 auto ret = window->SetShadowOffsetY(0.0f);
779 ASSERT_EQ(WMError::WM_OK, ret);
780 ASSERT_EQ(WMError::WM_OK, window->Destroy());
781 }
782
783 /**
784 * @tc.name: SetBlur
785 * @tc.desc: get
786 * @tc.type: FUNC
787 */
788 HWTEST_F(WindowTest, SetBlur, Function | SmallTest | Level2)
789 {
790 sptr<Window> window = new Window();
791 ASSERT_NE(nullptr, window);
792 auto ret = window->SetBlur(0.0f);
793 ASSERT_EQ(WMError::WM_OK, ret);
794 ASSERT_EQ(WMError::WM_OK, window->Destroy());
795 }
796
797 /**
798 * @tc.name: SetBackdropBlur
799 * @tc.desc: get
800 * @tc.type: FUNC
801 */
802 HWTEST_F(WindowTest, SetBackdropBlur, Function | SmallTest | Level2)
803 {
804 sptr<Window> window = new Window();
805 ASSERT_NE(nullptr, window);
806 auto ret = window->SetBackdropBlur(0.0f);
807 ASSERT_EQ(WMError::WM_OK, ret);
808 ASSERT_EQ(WMError::WM_OK, window->Destroy());
809 }
810
811 /**
812 * @tc.name: SetBackdropBlurStyle
813 * @tc.desc: get
814 * @tc.type: FUNC
815 */
816 HWTEST_F(WindowTest, SetBackdropBlurStyle, Function | SmallTest | Level2)
817 {
818 sptr<Window> window = new Window();
819 ASSERT_NE(nullptr, window);
820 auto ret = window->SetBackdropBlurStyle(WindowBlurStyle::WINDOW_BLUR_OFF);
821 ASSERT_EQ(WMError::WM_OK, ret);
822 ASSERT_EQ(WMError::WM_OK, window->Destroy());
823 }
824
825 /**
826 * @tc.name: RequestFocus
827 * @tc.desc: get
828 * @tc.type: FUNC
829 */
830 HWTEST_F(WindowTest, RequestFocus, Function | SmallTest | Level2)
831 {
832 sptr<Window> window = new Window();
833 ASSERT_NE(nullptr, window);
834 auto ret = window->RequestFocus();
835 ASSERT_EQ(WMError::WM_OK, ret);
836 ASSERT_EQ(WMError::WM_OK, window->Destroy());
837 }
838
839 /**
840 * @tc.name: IsFocused
841 * @tc.desc: get
842 * @tc.type: FUNC
843 */
844 HWTEST_F(WindowTest, IsFocused, Function | SmallTest | Level2)
845 {
846 sptr<Window> window = new Window();
847 ASSERT_NE(nullptr, window);
848 auto ret = window->IsFocused();
849 ASSERT_EQ(false, ret);
850 ASSERT_EQ(WMError::WM_OK, window->Destroy());
851 }
852
853 /**
854 * @tc.name: UpdateSurfaceNodeAfterCustomAnimation
855 * @tc.desc: get
856 * @tc.type: FUNC
857 */
858 HWTEST_F(WindowTest, UpdateSurfaceNodeAfterCustomAnimation, Function | SmallTest | Level2)
859 {
860 sptr<Window> window = new Window();
861 ASSERT_NE(nullptr, window);
862 auto ret = window->UpdateSurfaceNodeAfterCustomAnimation(false);
863 ASSERT_EQ(WMError::WM_OK, ret);
864 ASSERT_EQ(WMError::WM_OK, window->Destroy());
865 }
866
867 /**
868 * @tc.name: SetInputEventConsumer
869 * @tc.desc: get
870 * @tc.type: FUNC
871 */
872 HWTEST_F(WindowTest, SetInputEventConsumer, Function | SmallTest | Level2)
873 {
874 sptr<Window> window = new Window();
875 ASSERT_NE(nullptr, window);
876 auto ret = true;
877 std::shared_ptr<IInputEventConsumer> inputEventConsumer;
878 window->SetInputEventConsumer(inputEventConsumer);
879 ASSERT_EQ(true, ret);
880 ASSERT_EQ(WMError::WM_OK, window->Destroy());
881 }
882
883 /**
884 * @tc.name: ConsumeKeyEvent
885 * @tc.desc: get
886 * @tc.type: FUNC
887 */
888 HWTEST_F(WindowTest, ConsumeKeyEvent, Function | SmallTest | Level2)
889 {
890 sptr<Window> window = new Window();
891 ASSERT_NE(nullptr, window);
892 auto ret = WMError::WM_OK;
893 std::shared_ptr<MMI::KeyEvent> inputEvent = nullptr;
894 window->ConsumeKeyEvent(inputEvent);
895 ASSERT_EQ(WMError::WM_OK, ret);
896 ASSERT_EQ(WMError::WM_OK, window->Destroy());
897 }
898
899 /**
900 * @tc.name: ConsumePointerEvent
901 * @tc.desc: get
902 * @tc.type: FUNC
903 */
904 HWTEST_F(WindowTest, ConsumePointerEvent, Function | SmallTest | Level2)
905 {
906 sptr<Window> window = new Window();
907 ASSERT_NE(nullptr, window);
908 auto ret = WMError::WM_OK;
909 std::shared_ptr<MMI::PointerEvent> inputEvent = nullptr;
910 window->ConsumePointerEvent(inputEvent);
911 ASSERT_EQ(WMError::WM_OK, ret);
912 ASSERT_EQ(WMError::WM_OK, window->Destroy());
913 }
914
915 /**
916 * @tc.name: RequestVsync
917 * @tc.desc: get
918 * @tc.type: FUNC
919 */
920 HWTEST_F(WindowTest, RequestVsync, Function | SmallTest | Level2)
921 {
922 sptr<Window> window = new Window();
923 ASSERT_NE(nullptr, window);
924 std::shared_ptr<VsyncCallback> vsyncCallback = nullptr;
925 auto ret = WMError::WM_OK;
926 window->RequestVsync(vsyncCallback);
927 // no return
928 ASSERT_EQ(WMError::WM_OK, ret);
929 ASSERT_EQ(WMError::WM_OK, window->Destroy());
930 }
931
932 /**
933 * @tc.name: UpdateConfiguration
934 * @tc.desc: get
935 * @tc.type: FUNC
936 */
937 HWTEST_F(WindowTest, UpdateConfiguration, Function | SmallTest | Level2)
938 {
939 sptr<Window> window = new Window();
940 ASSERT_NE(nullptr, window);
941 std::shared_ptr<AppExecFwk::Configuration> conf = nullptr;
942 auto ret = WMError::WM_OK;
943 window->UpdateConfiguration(conf);
944 // no return
945 ASSERT_EQ(WMError::WM_OK, ret);
946 ASSERT_EQ(WMError::WM_OK, window->Destroy());
947 }
948
949 /**
950 * @tc.name: RegisterLifeCycleListener
951 * @tc.desc: get
952 * @tc.type: FUNC
953 */
954 HWTEST_F(WindowTest, RegisterLifeCycleListener, Function | SmallTest | Level2)
955 {
956 sptr<Window> window = new Window();
957 ASSERT_NE(nullptr, window);
958 sptr<IWindowLifeCycle> listener = nullptr;
959 auto ret = window->RegisterLifeCycleListener(listener);
960 ASSERT_EQ(WMError::WM_OK, ret);
961 ASSERT_EQ(WMError::WM_OK, window->Destroy());
962 }
963
964 /**
965 * @tc.name: UnregisterLifeCycleListener
966 * @tc.desc: get
967 * @tc.type: FUNC
968 */
969 HWTEST_F(WindowTest, UnregisterLifeCycleListener, Function | SmallTest | Level2)
970 {
971 sptr<Window> window = new Window();
972 ASSERT_NE(nullptr, window);
973 sptr<IWindowLifeCycle> listener = nullptr;
974 auto ret = window->UnregisterLifeCycleListener(listener);
975 ASSERT_EQ(WMError::WM_OK, ret);
976 ASSERT_EQ(WMError::WM_OK, window->Destroy());
977 }
978
979 /**
980 * @tc.name: RegisterWindowChangeListener
981 * @tc.desc: get
982 * @tc.type: FUNC
983 */
984 HWTEST_F(WindowTest, RegisterWindowChangeListener, Function | SmallTest | Level2)
985 {
986 sptr<Window> window = new Window();
987 ASSERT_NE(nullptr, window);
988 sptr<IWindowChangeListener> listener = nullptr;
989 auto ret = window->RegisterWindowChangeListener(listener);
990 ASSERT_EQ(WMError::WM_OK, ret);
991 ASSERT_EQ(WMError::WM_OK, window->Destroy());
992 }
993
994 /**
995 * @tc.name: UnregisterWindowChangeListener
996 * @tc.desc: get
997 * @tc.type: FUNC
998 */
999 HWTEST_F(WindowTest, UnregisterWindowChangeListener, Function | SmallTest | Level2)
1000 {
1001 sptr<Window> window = new Window();
1002 ASSERT_NE(nullptr, window);
1003 sptr<IWindowChangeListener> listener = nullptr;
1004 auto ret = window->UnregisterWindowChangeListener(listener);
1005 ASSERT_EQ(WMError::WM_OK, ret);
1006 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1007 }
1008
1009 /**
1010 * @tc.name: RegisterAvoidAreaChangeListener
1011 * @tc.desc: get
1012 * @tc.type: FUNC
1013 */
1014 HWTEST_F(WindowTest, RegisterAvoidAreaChangeListener, Function | SmallTest | Level2)
1015 {
1016 sptr<Window> window = new Window();
1017 ASSERT_NE(nullptr, window);
1018 sptr<IAvoidAreaChangedListener> listener = nullptr;
1019 auto ret = window->RegisterAvoidAreaChangeListener(listener);
1020 ASSERT_EQ(WMError::WM_OK, ret);
1021 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1022 }
1023
1024 /**
1025 * @tc.name: UnregisterAvoidAreaChangeListener
1026 * @tc.desc: get
1027 * @tc.type: FUNC
1028 */
1029 HWTEST_F(WindowTest, UnregisterAvoidAreaChangeListener, Function | SmallTest | Level2)
1030 {
1031 sptr<Window> window = new Window();
1032 ASSERT_NE(nullptr, window);
1033 sptr<IAvoidAreaChangedListener> listener = nullptr;
1034 auto ret = window->UnregisterAvoidAreaChangeListener(listener);
1035 ASSERT_EQ(WMError::WM_OK, ret);
1036 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1037 }
1038
1039 /**
1040 * @tc.name: RegisterDragListener
1041 * @tc.desc: get
1042 * @tc.type: FUNC
1043 */
1044 HWTEST_F(WindowTest, RegisterDragListener, Function | SmallTest | Level2)
1045 {
1046 sptr<Window> window = new Window();
1047 ASSERT_NE(nullptr, window);
1048 sptr<IWindowDragListener> listener = nullptr;
1049 auto ret = window->RegisterDragListener(listener);
1050 ASSERT_EQ(WMError::WM_OK, ret);
1051 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1052 }
1053
1054 /**
1055 * @tc.name: UnregisterDragListener
1056 * @tc.desc: get
1057 * @tc.type: FUNC
1058 */
1059 HWTEST_F(WindowTest, UnregisterDragListener, Function | SmallTest | Level2)
1060 {
1061 sptr<Window> window = new Window();
1062 ASSERT_NE(nullptr, window);
1063 sptr<IWindowDragListener> listener = nullptr;
1064 auto ret = window->UnregisterDragListener(listener);
1065 ASSERT_EQ(WMError::WM_OK, ret);
1066 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1067 }
1068
1069 /**
1070 * @tc.name: RegisterDisplayMoveListener
1071 * @tc.desc: get
1072 * @tc.type: FUNC
1073 */
1074 HWTEST_F(WindowTest, RegisterDisplayMoveListener, Function | SmallTest | Level2)
1075 {
1076 sptr<Window> window = new Window();
1077 ASSERT_NE(nullptr, window);
1078 sptr<IDisplayMoveListener> listener = nullptr;
1079 auto ret = window->RegisterDisplayMoveListener(listener);
1080 ASSERT_EQ(WMError::WM_OK, ret);
1081 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1082 }
1083
1084 /**
1085 * @tc.name: UnregisterDisplayMoveListener
1086 * @tc.desc: get
1087 * @tc.type: FUNC
1088 */
1089 HWTEST_F(WindowTest, UnregisterDisplayMoveListener, Function | SmallTest | Level2)
1090 {
1091 sptr<Window> window = new Window();
1092 ASSERT_NE(nullptr, window);
1093 sptr<IDisplayMoveListener> listener = nullptr;
1094 auto ret = window->UnregisterDisplayMoveListener(listener);
1095 ASSERT_EQ(WMError::WM_OK, ret);
1096 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1097 }
1098
1099 /**
1100 * @tc.name: RegisterWindowDestroyedListener
1101 * @tc.desc: get
1102 * @tc.type: FUNC
1103 */
1104 HWTEST_F(WindowTest, RegisterWindowDestroyedListener, Function | SmallTest | Level2)
1105 {
1106 sptr<Window> window = new Window();
1107 ASSERT_NE(nullptr, window);
1108 NotifyNativeWinDestroyFunc func = nullptr;
1109 auto ret = WMError::WM_OK;
1110 window->RegisterWindowDestroyedListener(func);
1111 // no return
1112 ASSERT_EQ(WMError::WM_OK, ret);
1113 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1114 }
1115
1116 /**
1117 * @tc.name: RegisterOccupiedAreaChangeListener
1118 * @tc.desc: get
1119 * @tc.type: FUNC
1120 */
1121 HWTEST_F(WindowTest, RegisterOccupiedAreaChangeListener, Function | SmallTest | Level2)
1122 {
1123 sptr<Window> window = new Window();
1124 ASSERT_NE(nullptr, window);
1125 sptr<IOccupiedAreaChangeListener> listener = nullptr;
1126 auto ret = window->RegisterOccupiedAreaChangeListener(listener);
1127 ASSERT_EQ(WMError::WM_OK, ret);
1128 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1129 }
1130
1131 /**
1132 * @tc.name: UnregisterOccupiedAreaChangeListener
1133 * @tc.desc: get
1134 * @tc.type: FUNC
1135 */
1136 HWTEST_F(WindowTest, UnregisterOccupiedAreaChangeListener, Function | SmallTest | Level2)
1137 {
1138 sptr<Window> window = new Window();
1139 ASSERT_NE(nullptr, window);
1140 sptr<IOccupiedAreaChangeListener> listener = nullptr;
1141 auto ret = window->UnregisterOccupiedAreaChangeListener(listener);
1142 ASSERT_EQ(WMError::WM_OK, ret);
1143 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1144 }
1145
1146 /**
1147 * @tc.name: RegisterTouchOutsideListener
1148 * @tc.desc: get
1149 * @tc.type: FUNC
1150 */
1151 HWTEST_F(WindowTest, RegisterTouchOutsideListener, Function | SmallTest | Level2)
1152 {
1153 sptr<Window> window = new Window();
1154 ASSERT_NE(nullptr, window);
1155 sptr<ITouchOutsideListener> listener = nullptr;
1156 auto ret = window->RegisterTouchOutsideListener(listener);
1157 ASSERT_EQ(WMError::WM_OK, ret);
1158 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1159 }
1160
1161 /**
1162 * @tc.name: UnregisterTouchOutsideListener
1163 * @tc.desc: get
1164 * @tc.type: FUNC
1165 */
1166 HWTEST_F(WindowTest, UnregisterTouchOutsideListener, Function | SmallTest | Level2)
1167 {
1168 sptr<Window> window = new Window();
1169 ASSERT_NE(nullptr, window);
1170 sptr<ITouchOutsideListener> listener = nullptr;
1171 auto ret = window->UnregisterTouchOutsideListener(listener);
1172 ASSERT_EQ(WMError::WM_OK, ret);
1173 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1174 }
1175
1176 /**
1177 * @tc.name: RegisterAnimationTransitionController
1178 * @tc.desc: get
1179 * @tc.type: FUNC
1180 */
1181 HWTEST_F(WindowTest, RegisterAnimationTransitionController, Function | SmallTest | Level2)
1182 {
1183 sptr<Window> window = new Window();
1184 ASSERT_NE(nullptr, window);
1185 sptr<IAnimationTransitionController> listener = nullptr;
1186 auto ret = window->RegisterAnimationTransitionController(listener);
1187 ASSERT_EQ(WMError::WM_OK, ret);
1188 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1189 }
1190
1191 /**
1192 * @tc.name: RegisterScreenshotListener
1193 * @tc.desc: get
1194 * @tc.type: FUNC
1195 */
1196 HWTEST_F(WindowTest, RegisterScreenshotListener, Function | SmallTest | Level2)
1197 {
1198 sptr<Window> window = new Window();
1199 ASSERT_NE(nullptr, window);
1200 sptr<IScreenshotListener> listener = nullptr;
1201 auto ret = window->RegisterScreenshotListener(listener);
1202 ASSERT_EQ(WMError::WM_OK, ret);
1203 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1204 }
1205
1206 /**
1207 * @tc.name: UnregisterScreenshotListener
1208 * @tc.desc: get
1209 * @tc.type: FUNC
1210 */
1211 HWTEST_F(WindowTest, UnregisterScreenshotListener, Function | SmallTest | Level2)
1212 {
1213 sptr<Window> window = new Window();
1214 ASSERT_NE(nullptr, window);
1215 sptr<IScreenshotListener> listener = nullptr;
1216 auto ret = window->UnregisterScreenshotListener(listener);
1217 ASSERT_EQ(WMError::WM_OK, ret);
1218 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1219 }
1220
1221 /**
1222 * @tc.name: RegisterDialogTargetTouchListener
1223 * @tc.desc: get
1224 * @tc.type: FUNC
1225 */
1226 HWTEST_F(WindowTest, RegisterDialogTargetTouchListener, Function | SmallTest | Level2)
1227 {
1228 sptr<Window> window = new Window();
1229 ASSERT_NE(nullptr, window);
1230 sptr<IDialogTargetTouchListener> listener = nullptr;
1231 auto ret = window->RegisterDialogTargetTouchListener(listener);
1232 ASSERT_EQ(WMError::WM_OK, ret);
1233 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1234
1235 auto window_ = new (std::nothrow)Window();
1236 ASSERT_NE(nullptr, window_);
1237 sptr<IDialogTargetTouchListener> listener_;
1238 auto ret_ = window_->RegisterDialogTargetTouchListener(listener_);
1239 ASSERT_EQ(WMError::WM_OK, ret_);
1240 ASSERT_EQ(WMError::WM_OK, window_->Destroy());
1241 }
1242
1243 /**
1244 * @tc.name: UnregisterDialogTargetTouchListener
1245 * @tc.desc: get
1246 * @tc.type: FUNC
1247 */
1248 HWTEST_F(WindowTest, UnregisterDialogTargetTouchListener, Function | SmallTest | Level2)
1249 {
1250 sptr<Window> window = new Window();
1251 ASSERT_NE(nullptr, window);
1252 sptr<IDialogTargetTouchListener> listener = nullptr;
1253 auto ret = window->UnregisterDialogTargetTouchListener(listener);
1254 ASSERT_EQ(WMError::WM_OK, ret);
1255 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1256
1257 auto window_ = new (std::nothrow)Window();
1258 ASSERT_NE(nullptr, window_);
1259 ASSERT_EQ(WMError::WM_OK, window_->UnregisterDialogTargetTouchListener(listener));
1260 ASSERT_EQ(WMError::WM_OK, window_->Destroy());
1261 }
1262
1263 /**
1264 * @tc.name: RegisterDialogDeathRecipientListener
1265 * @tc.desc: get
1266 * @tc.type: FUNC
1267 */
1268 HWTEST_F(WindowTest, RegisterDialogDeathRecipientListener, Function | SmallTest | Level2)
1269 {
1270 sptr<Window> window = new Window();
1271 ASSERT_NE(nullptr, window);
1272 auto ret = WMError::WM_OK;
1273 sptr<IDialogDeathRecipientListener> listener = nullptr;
1274 window->RegisterDialogDeathRecipientListener(listener);
1275 ASSERT_EQ(WMError::WM_OK, ret);
1276 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1277 }
1278
1279 /**
1280 * @tc.name: UnregisterDialogDeathRecipientListener
1281 * @tc.desc: get
1282 * @tc.type: FUNC
1283 */
1284 HWTEST_F(WindowTest, UnregisterDialogDeathRecipientListener, Function | SmallTest | Level2)
1285 {
1286 sptr<Window> window = new Window();
1287 ASSERT_NE(nullptr, window);
1288 auto ret = WMError::WM_OK;
1289 sptr<IDialogDeathRecipientListener> listener = nullptr;
1290 window->UnregisterDialogDeathRecipientListener(listener);
1291 ASSERT_EQ(WMError::WM_OK, ret);
1292 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1293 }
1294
1295 /**
1296 * @tc.name: NotifyTouchDialogTarget
1297 * @tc.desc: get
1298 * @tc.type: FUNC
1299 */
1300 HWTEST_F(WindowTest, NotifyTouchDialogTarget, Function | SmallTest | Level2)
1301 {
1302 sptr<Window> window = new Window();
1303 ASSERT_NE(nullptr, window);
1304 auto ret = WMError::WM_OK;
1305 sptr<IDialogTargetTouchListener> listener = nullptr;
1306 window->NotifyTouchDialogTarget();
1307 ASSERT_EQ(WMError::WM_OK, ret);
1308 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1309 }
1310
1311 /**
1312 * @tc.name: SetAceAbilityHandler
1313 * @tc.desc: get
1314 * @tc.type: FUNC
1315 */
1316 HWTEST_F(WindowTest, SetAceAbilityHandler, Function | SmallTest | Level2)
1317 {
1318 sptr<Window> window = new Window();
1319 ASSERT_NE(nullptr, window);
1320 auto ret = WMError::WM_OK;
1321 sptr<IAceAbilityHandler> handler = nullptr;
1322 window->SetAceAbilityHandler(handler);
1323 ASSERT_EQ(WMError::WM_OK, ret);
1324 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1325 }
1326
1327 /**
1328 * @tc.name: SetUIContent
1329 * @tc.desc: get
1330 * @tc.type: FUNC
1331 */
1332 HWTEST_F(WindowTest, SetUIContent, Function | SmallTest | Level2)
1333 {
1334 sptr<Window> window = new Window();
1335 ASSERT_NE(nullptr, window);
1336 NativeEngine* engine = nullptr;
1337 NativeValue* storage = nullptr;
1338 auto ret = window->SetUIContent("info", engine, storage);
1339 ASSERT_EQ(WMError::WM_OK, ret);
1340 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1341 }
1342
1343 /**
1344 * @tc.name: GetContentInfo
1345 * @tc.desc: get
1346 * @tc.type: FUNC
1347 */
1348 HWTEST_F(WindowTest, GetContentInfo, Function | SmallTest | Level2)
1349 {
1350 sptr<Window> window = new Window();
1351 ASSERT_NE(nullptr, window);
1352 auto ret = window->GetContentInfo();
1353 ASSERT_EQ(std::string(), ret);
1354 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1355 }
1356
1357 /**
1358 * @tc.name: GetUIContent
1359 * @tc.desc: get
1360 * @tc.type: FUNC
1361 */
1362 HWTEST_F(WindowTest, GetUIContent, Function | SmallTest | Level2)
1363 {
1364 sptr<Window> window = new Window();
1365 ASSERT_NE(nullptr, window);
1366 auto ret = window->GetUIContent();
1367 ASSERT_EQ(nullptr, ret);
1368 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1369 }
1370
1371 /**
1372 * @tc.name: OnNewWant
1373 * @tc.desc: get
1374 * @tc.type: FUNC
1375 */
1376 HWTEST_F(WindowTest, OnNewWant, Function | SmallTest | Level2)
1377 {
1378 sptr<Window> window = new Window();
1379 ASSERT_NE(nullptr, window);
1380 AAFwk::Want want;
1381 auto ret = true;
1382 window->OnNewWant(want);
1383 ASSERT_EQ(true, ret);
1384 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1385 }
1386
1387 /**
1388 * @tc.name: SetRequestedOrientation
1389 * @tc.desc: get
1390 * @tc.type: FUNC
1391 */
1392 HWTEST_F(WindowTest, SetRequestedOrientation, Function | SmallTest | Level2)
1393 {
1394 sptr<Window> window = new Window();
1395 ASSERT_NE(nullptr, window);
1396 auto ret = true;
1397 Orientation ori = Orientation::UNSPECIFIED;
1398 window->SetRequestedOrientation(ori);
1399 ASSERT_EQ(true, ret);
1400 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1401 }
1402
1403 /**
1404 * @tc.name: GetRequestedOrientation
1405 * @tc.desc: get
1406 * @tc.type: FUNC
1407 */
1408 HWTEST_F(WindowTest, GetRequestedOrientation, Function | SmallTest | Level2)
1409 {
1410 sptr<Window> window = new Window();
1411 ASSERT_NE(nullptr, window);
1412 auto ret = window->GetRequestedOrientation();
1413 ASSERT_EQ(Orientation::UNSPECIFIED, ret);
1414 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1415 }
1416
1417 /**
1418 * @tc.name: SetRequestModeSupportInfo
1419 * @tc.desc: get
1420 * @tc.type: FUNC
1421 */
1422 HWTEST_F(WindowTest, SetRequestModeSupportInfo, Function | SmallTest | Level2)
1423 {
1424 sptr<Window> window = new Window();
1425 ASSERT_NE(nullptr, window);
1426 uint32_t modeSupportInfo = 0;
1427 window->SetRequestModeSupportInfo(modeSupportInfo);
1428 ASSERT_EQ(static_cast<uint32_t>(Orientation::UNSPECIFIED), modeSupportInfo);
1429 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1430 }
1431
1432 /**
1433 * @tc.name: GetRequestModeSupportInfo
1434 * @tc.desc: get
1435 * @tc.type: FUNC
1436 */
1437 HWTEST_F(WindowTest, GetRequestModeSupportInfo, Function | SmallTest | Level2)
1438 {
1439 sptr<Window> window = new Window();
1440 ASSERT_NE(nullptr, window);
1441 uint32_t ret = window->GetRequestModeSupportInfo();
1442 ASSERT_EQ(true, ret == 0);
1443 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1444 }
1445
1446 /**
1447 * @tc.name: SetTouchHotAreas
1448 * @tc.desc: get
1449 * @tc.type: FUNC
1450 */
1451 HWTEST_F(WindowTest, SetTouchHotAreas, Function | SmallTest | Level2)
1452 {
1453 sptr<Window> window = new Window();
1454 ASSERT_NE(nullptr, window);
1455 std::vector<Rect> rects;
1456 auto ret = window->SetTouchHotAreas(rects);
1457 ASSERT_EQ(WMError::WM_OK, ret);
1458 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1459 }
1460
1461 /**
1462 * @tc.name: GetRequestedTouchHotAreas
1463 * @tc.desc: get
1464 * @tc.type: FUNC
1465 */
1466 HWTEST_F(WindowTest, GetRequestedTouchHotAreas, Function | SmallTest | Level2)
1467 {
1468 sptr<Window> window = new Window();
1469 ASSERT_NE(nullptr, window);
1470 std::vector<Rect> rects;
1471 auto ret = WMError::WM_OK;
1472 window->GetRequestedTouchHotAreas(rects);
1473 ASSERT_EQ(WMError::WM_OK, ret);
1474 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1475 }
1476
1477 /**
1478 * @tc.name: IsMainHandlerAvailable
1479 * @tc.desc: get
1480 * @tc.type: FUNC
1481 */
1482 HWTEST_F(WindowTest, IsMainHandlerAvailable, Function | SmallTest | Level2)
1483 {
1484 sptr<Window> window = new Window();
1485 sptr<WindowOption> option = new (std::nothrow)WindowOption();
1486 option->SetMainHandlerAvailable(false);
1487 ASSERT_NE(nullptr, window);
1488 auto ret = window->IsMainHandlerAvailable();
1489 ASSERT_EQ(false, ret);
1490 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1491 }
1492
1493 /**
1494 * @tc.name: SetAPPWindowLabel
1495 * @tc.desc: get
1496 * @tc.type: FUNC
1497 */
1498 HWTEST_F(WindowTest, SetAPPWindowLabel, Function | SmallTest | Level2)
1499 {
1500 sptr<Window> window = new Window();
1501 ASSERT_NE(nullptr, window);
1502 auto ret = window->SetAPPWindowLabel("");
1503 ASSERT_EQ(WMError::WM_OK, ret);
1504 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1505
1506 auto window_ = new (std::nothrow)Window();
1507 ASSERT_NE(nullptr, window_);
1508 ASSERT_EQ(WMError::WM_OK, window_->SetAPPWindowLabel("000111"));
1509 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1510 }
1511
1512 /**
1513 * @tc.name: IsDecorEnable
1514 * @tc.desc: get
1515 * @tc.type: FUNC
1516 */
1517 HWTEST_F(WindowTest, IsDecorEnable, Function | SmallTest | Level2)
1518 {
1519 sptr<Window> window = new Window();
1520 ASSERT_NE(nullptr, window);
1521 auto ret = window->IsDecorEnable();
1522 ASSERT_EQ(false, ret);
1523 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1524 }
1525
1526 /**
1527 * @tc.name: Maximize
1528 * @tc.desc: get
1529 * @tc.type: FUNC
1530 */
1531 HWTEST_F(WindowTest, Maximize, Function | SmallTest | Level2)
1532 {
1533 sptr<Window> window = new Window();
1534 ASSERT_NE(nullptr, window);
1535 auto ret = window->Maximize();
1536 ASSERT_EQ(WMError::WM_OK, ret);
1537 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1538 }
1539
1540 /**
1541 * @tc.name: MaximizeFloating
1542 * @tc.desc: get
1543 * @tc.type: FUNC
1544 */
1545 HWTEST_F(WindowTest, MaximizeFloating, Function | SmallTest | Level2)
1546 {
1547 sptr<Window> window = new Window();
1548 ASSERT_NE(nullptr, window);
1549 auto ret = window->MaximizeFloating();
1550 ASSERT_EQ(WMError::WM_OK, ret);
1551 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1552 }
1553
1554 /**
1555 * @tc.name: Minimize
1556 * @tc.desc: get
1557 * @tc.type: FUNC
1558 */
1559 HWTEST_F(WindowTest, Minimize, Function | SmallTest | Level2)
1560 {
1561 sptr<Window> window = new Window();
1562 ASSERT_NE(nullptr, window);
1563 auto ret = window->Minimize();
1564 ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ret);
1565 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1566 }
1567
1568 /**
1569 * @tc.name: Recover
1570 * @tc.desc: get
1571 * @tc.type: FUNC
1572 */
1573 HWTEST_F(WindowTest, Recover, Function | SmallTest | Level2)
1574 {
1575 sptr<Window> window = new Window();
1576 ASSERT_NE(nullptr, window);
1577 auto ret = window->Recover();
1578 ASSERT_EQ(true, ret == WMError::WM_OK);
1579 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1580 }
1581
1582 /**
1583 * @tc.name: Close
1584 * @tc.desc: get
1585 * @tc.type: FUNC
1586 */
1587 HWTEST_F(WindowTest, Close, Function | SmallTest | Level2)
1588 {
1589 sptr<Window> window = new Window();
1590 ASSERT_NE(nullptr, window);
1591 auto ret = window->Close();
1592 ASSERT_EQ(true, ret == WMError::WM_OK);
1593 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1594 }
1595
1596 /**
1597 * @tc.name: StartMove
1598 * @tc.desc: get
1599 * @tc.type: FUNC
1600 */
1601 HWTEST_F(WindowTest, StartMove, Function | SmallTest | Level2)
1602 {
1603 sptr<Window> window = new Window();
1604 ASSERT_NE(nullptr, window);
1605 auto ret = WMError::WM_OK;
1606 window->StartMove();
1607 ASSERT_EQ(WMError::WM_OK, ret);
1608 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1609 }
1610
1611 /**
1612 * @tc.name: SetGlobalMaximizeMode
1613 * @tc.desc: get
1614 * @tc.type: FUNC
1615 */
1616 HWTEST_F(WindowTest, SetGlobalMaximizeMode, Function | SmallTest | Level2)
1617 {
1618 sptr<Window> window = new Window();
1619 ASSERT_NE(nullptr, window);
1620 auto ret = window->SetGlobalMaximizeMode(MaximizeMode::MODE_AVOID_SYSTEM_BAR);
1621 ASSERT_EQ(WMError::WM_OK, ret);
1622 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1623 }
1624
1625 /**
1626 * @tc.name: GetGlobalMaximizeMode
1627 * @tc.desc: get
1628 * @tc.type: FUNC
1629 */
1630 HWTEST_F(WindowTest, GetGlobalMaximizeMode, Function | SmallTest | Level2)
1631 {
1632 sptr<Window> window = new Window();
1633 ASSERT_NE(nullptr, window);
1634
1635 auto ret = window->GetGlobalMaximizeMode();
1636 ASSERT_EQ(MaximizeMode::MODE_FULL_FILL, ret);
1637 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1638 }
1639
1640 /**
1641 * @tc.name: IsSupportWideGamut
1642 * @tc.desc: get
1643 * @tc.type: FUNC
1644 */
1645 HWTEST_F(WindowTest, IsSupportWideGamut, Function | SmallTest | Level2)
1646 {
1647 sptr<Window> window = new Window();
1648 ASSERT_NE(nullptr, window);
1649 auto ret = window->IsSupportWideGamut();
1650 ASSERT_EQ(false, ret);
1651 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1652 }
1653
1654 /**
1655 * @tc.name: SetColorSpace
1656 * @tc.desc: get
1657 * @tc.type: FUNC
1658 */
1659 HWTEST_F(WindowTest, SetColorSpace, Function | SmallTest | Level2)
1660 {
1661 sptr<Window> window = new Window();
1662 ASSERT_NE(nullptr, window);
1663 bool ret = true;
1664 window->SetColorSpace(ColorSpace::COLOR_SPACE_DEFAULT);
1665 ASSERT_EQ(true, ret);
1666 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1667 }
1668
1669 /**
1670 * @tc.name: GetColorSpace
1671 * @tc.desc: get
1672 * @tc.type: FUNC
1673 */
1674 HWTEST_F(WindowTest, GetColorSpace, Function | SmallTest | Level2)
1675 {
1676 sptr<Window> window = new Window();
1677 ASSERT_NE(nullptr, window);
1678 auto ret = window->GetColorSpace();
1679 ASSERT_EQ(ColorSpace::COLOR_SPACE_DEFAULT, ret);
1680 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1681 }
1682
1683 /**
1684 * @tc.name: DumpInfo
1685 * @tc.desc: get
1686 * @tc.type: FUNC
1687 */
1688 HWTEST_F(WindowTest, DumpInfo, Function | SmallTest | Level2)
1689 {
1690 sptr<Window> window = new Window();
1691 ASSERT_NE(nullptr, window);
1692 std::vector<std::string> params;
1693 std::vector<std::string> info;
1694 auto ret = true;
1695 window->DumpInfo(params, info);
1696 ASSERT_EQ(true, ret);
1697 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1698 }
1699
1700 /**
1701 * @tc.name: Snapshot
1702 * @tc.desc: get
1703 * @tc.type: FUNC
1704 */
1705 HWTEST_F(WindowTest, Snapshot, Function | SmallTest | Level2)
1706 {
1707 sptr<Window> window = new Window();
1708 ASSERT_NE(nullptr, window);
1709 auto pixmap = window->Snapshot();
1710 ASSERT_EQ(pixmap, nullptr);
1711 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1712 }
1713
1714 /**
1715 * @tc.name: NotifyMemoryLevel
1716 * @tc.desc: get
1717 * @tc.type: FUNC
1718 */
1719 HWTEST_F(WindowTest, NotifyMemoryLevel, Function | SmallTest | Level2)
1720 {
1721 sptr<Window> window = new Window();
1722 ASSERT_NE(nullptr, window);
1723 auto ret = window->NotifyMemoryLevel(0);
1724 ASSERT_EQ(WMError::WM_OK, ret);
1725 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1726
1727 auto window_ = new (std::nothrow) Window();
1728 ASSERT_NE(nullptr, window_);
1729 ASSERT_EQ(WMError::WM_OK, window_->NotifyMemoryLevel(22));
1730 ASSERT_EQ(WMError::WM_OK, window_->Destroy());
1731 }
1732
1733 /**
1734 * @tc.name: IsAllowHaveSystemSubWindow
1735 * @tc.desc: get
1736 * @tc.type: FUNC
1737 */
1738 HWTEST_F(WindowTest, IsAllowHaveSystemSubWindow, Function | SmallTest | Level2)
1739 {
1740 sptr<Window> window = new Window();
1741 ASSERT_NE(nullptr, window);
1742 window->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1743 auto ret = window->IsAllowHaveSystemSubWindow();
1744 ASSERT_EQ(false, ret);
1745 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1746 }
1747
1748 /**
1749 * @tc.name: SetAspectRatio
1750 * @tc.desc: get
1751 * @tc.type: FUNC
1752 */
1753 HWTEST_F(WindowTest, SetAspectRatio, Function | SmallTest | Level2)
1754 {
1755 sptr<Window> window = new Window();
1756 ASSERT_NE(nullptr, window);
1757 auto ret = window->SetAspectRatio(0.0f);
1758 ASSERT_EQ(WMError::WM_OK, ret);
1759 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1760
1761 auto window_ = new (std::nothrow) Window();
1762 ASSERT_NE(nullptr, window_);
1763 ASSERT_EQ(WMError::WM_OK, window_->SetAspectRatio(0.1f));
1764 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1765 }
1766
1767 /**
1768 * @tc.name: ResetAspectRatio
1769 * @tc.desc: get
1770 * @tc.type: FUNC
1771 */
1772 HWTEST_F(WindowTest, ResetAspectRatio, Function | SmallTest | Level2)
1773 {
1774 sptr<Window> window = new Window();
1775 ASSERT_NE(nullptr, window);
1776 auto ret = window->ResetAspectRatio();
1777 ASSERT_EQ(WMError::WM_OK, ret);
1778 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1779 }
1780
1781 /**
1782 * @tc.name: GetKeyboardAnimationConfig
1783 * @tc.desc: get
1784 * @tc.type: FUNC
1785 */
1786 HWTEST_F(WindowTest, GetKeyboardAnimationConfig, Function | SmallTest | Level2)
1787 {
1788 sptr<Window> window = new Window();
1789 ASSERT_NE(nullptr, window);
1790 KeyboardAnimationConfig config;
1791 auto ret = window->GetKeyboardAnimationConfig();
1792 ASSERT_EQ(true, ret.durationIn_ == config.durationIn_);
1793 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1794 }
1795
1796 /**
1797 * @tc.name: SetNeedDefaultAnimation
1798 * @tc.desc: get
1799 * @tc.type: FUNC
1800 */
1801 HWTEST_F(WindowTest, SetNeedDefaultAnimation, Function | SmallTest | Level2)
1802 {
1803 sptr<Window> window = new Window();
1804 ASSERT_NE(nullptr, window);
1805 auto ret = true;
1806 window->SetNeedDefaultAnimation(true);
1807 ASSERT_EQ(true, ret);
1808 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1809 }
1810
1811 /**
1812 * @tc.name: TransferAbilityResult
1813 * @tc.desc: get
1814 * @tc.type: FUNC
1815 */
1816 HWTEST_F(WindowTest, TransferAbilityResult, Function | SmallTest | Level2)
1817 {
1818 sptr<Window> window = new Window();
1819 ASSERT_NE(nullptr, window);
1820 AAFwk::Want want;
1821 auto ret = window->TransferAbilityResult(0, want);
1822 ASSERT_EQ(WMError::WM_OK, ret);
1823 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1824 }
1825
1826 /**
1827 * @tc.name: TransferExtensionData
1828 * @tc.desc: get
1829 * @tc.type: FUNC
1830 */
1831 HWTEST_F(WindowTest, TransferExtensionData, Function | SmallTest | Level2)
1832 {
1833 sptr<Window> window = new Window();
1834 ASSERT_NE(nullptr, window);
1835 AAFwk::WantParams wantParams;
1836 auto ret = window->TransferExtensionData(wantParams);
1837 ASSERT_EQ(WMError::WM_OK, ret);
1838 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1839 }
1840
1841 /**
1842 * @tc.name: RegisterTransferComponentDataListener
1843 * @tc.desc: get
1844 * @tc.type: FUNC
1845 */
1846 HWTEST_F(WindowTest, RegisterTransferComponentDataListener, Function | SmallTest | Level2)
1847 {
1848 sptr<Window> window = new Window();
1849 ASSERT_NE(nullptr, window);
1850 NotifyTransferComponentDataFunc func;
1851 auto ret = true;
1852 window->RegisterTransferComponentDataListener(func);
1853 ASSERT_EQ(true, ret);
1854 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1855 }
1856
1857 /**
1858 * @tc.name: WindowChangeListener
1859 * @tc.desc: WindowChangeListener01 fun
1860 * @tc.type: FUNC
1861 */
1862 HWTEST_F(WindowTest, WindowChangeListener01, Function | SmallTest | Level3)
1863 {
1864 sptr<Window> window = new Window();
1865 ASSERT_NE(nullptr, window);
1866 auto ret = true;
1867 sptr<IWindowChangeListener> listener = new IWindowChangeListener();
1868 window->RegisterWindowChangeListener(listener);
1869 listener->OnModeChange(WindowMode::WINDOW_MODE_UNDEFINED, false);
1870 window->UnregisterWindowChangeListener(listener);
1871 ASSERT_EQ(true, ret);
1872 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1873 }
1874
1875 /**
1876 * @tc.name: IOccupiedAreaChangeListener
1877 * @tc.desc: IOccupiedAreaChangeListener fun
1878 * @tc.type: FUNC
1879 */
1880 HWTEST_F(WindowTest, IOccupiedAreaChangeListener, Function | SmallTest | Level3)
1881 {
1882 sptr<Window> window = new Window();
1883 ASSERT_NE(nullptr, window);
1884 auto ret = true;
1885 sptr<IOccupiedAreaChangeListener> listener = new IOccupiedAreaChangeListener();
1886 Rect rect_ = {0, 0, 0, 0};
1887 window->RegisterOccupiedAreaChangeListener(listener);
1888 sptr<OccupiedAreaChangeInfo> info = new OccupiedAreaChangeInfo(OccupiedAreaType::TYPE_INPUT, rect_, 80);
1889 listener->OnSizeChange(info, nullptr);
1890 window->UnregisterOccupiedAreaChangeListener(listener);
1891 ASSERT_EQ(true, ret);
1892 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1893 }
1894
1895 /**
1896 * @tc.name: WindowChangeListener
1897 * @tc.desc: WindowChangeListener02 fun
1898 * @tc.type: FUNC
1899 */
1900 HWTEST_F(WindowTest, WindowChangeListener02, Function | SmallTest | Level3)
1901 {
1902 sptr<Window> window = new Window();
1903 ASSERT_NE(nullptr, window);
1904 auto ret = true;
1905 sptr<IWindowChangeListener> listener = new IWindowChangeListener();
1906 window->RegisterWindowChangeListener(listener);
1907 Rect rect_ = {0, 0, 0, 0};
1908 std::shared_ptr<RSTransaction> rstransaction;
1909 listener->OnSizeChange(rect_, WindowSizeChangeReason::UNDEFINED, rstransaction);
1910 window->UnregisterWindowChangeListener(listener);
1911 ASSERT_EQ(true, ret);
1912 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1913 }
1914
1915 /**
1916 * @tc.name: IAnimationTransitionController
1917 * @tc.desc: IAnimationTransitionController fun
1918 * @tc.type: FUNC
1919 */
1920 HWTEST_F(WindowTest, IAnimationTransitionController, Function | SmallTest | Level3)
1921 {
1922 sptr<Window> window = new Window();
1923 ASSERT_NE(nullptr, window);
1924 auto ret = true;
1925 sptr<IAnimationTransitionController> listener = new IAnimationTransitionController();
1926 window->RegisterAnimationTransitionController(listener);
1927 listener->AnimationForShown();
1928 listener->AnimationForHidden();
1929 ASSERT_EQ(true, ret);
1930 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1931 }
1932
1933 /**
1934 * @tc.name: IInputEventConsumer
1935 * @tc.desc: IInputEventConsumer fun
1936 * @tc.type: FUNC
1937 */
1938 HWTEST_F(WindowTest, IInputEventConsumer, Function | SmallTest | Level3)
1939 {
1940 sptr<Window> window = new Window();
1941 ASSERT_NE(nullptr, window);
1942 auto ret = true;
1943 std::shared_ptr<IInputEventConsumer> listener = std::make_shared<IInputEventConsumer>();
1944 std::shared_ptr<MMI::KeyEvent> keyEvent = nullptr;
1945 std::shared_ptr<MMI::PointerEvent> pointerEvent = nullptr;
1946 std::shared_ptr<MMI::AxisEvent> axisEvent = nullptr;
1947 listener->OnInputEvent(keyEvent);
1948 listener->OnInputEvent(pointerEvent);
1949 listener->OnInputEvent(axisEvent);
1950 ASSERT_EQ(true, ret);
1951 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1952 }
1953
1954 /**
1955 * @tc.name: IDialogDeathRecipientListener
1956 * @tc.desc: IDialogDeathRecipientListener fun
1957 * @tc.type: FUNC
1958 */
1959 HWTEST_F(WindowTest, IDialogDeathRecipientListener, Function | SmallTest | Level3)
1960 {
1961 sptr<Window> window = new Window();
1962 ASSERT_NE(nullptr, window);
1963 auto ret = true;
1964 sptr<IDialogDeathRecipientListener> listener = new IDialogDeathRecipientListener();
1965 Rect rect_ = {0, 0, 0, 0};
1966 sptr<OccupiedAreaChangeInfo> info = new OccupiedAreaChangeInfo(OccupiedAreaType::TYPE_INPUT, rect_, 80);
1967 listener->OnDialogDeathRecipient();
1968 ASSERT_EQ(true, ret);
1969 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1970 }
1971
1972 /**
1973 * @tc.name: IAceAbilityHandler
1974 * @tc.desc: IAceAbilityHandler fun
1975 * @tc.type: FUNC
1976 */
1977 HWTEST_F(WindowTest, IAceAbilityHandler, Function | SmallTest | Level3)
1978 {
1979 sptr<Window> window = new Window();
1980 ASSERT_NE(nullptr, window);
1981 auto ret = true;
1982 sptr<IAceAbilityHandler> listener = new IAceAbilityHandler();
1983 uint32_t color = 66;
1984 listener->SetBackgroundColor(color);
1985 listener->GetBackgroundColor();
1986 ASSERT_EQ(true, ret);
1987 ASSERT_EQ(WMError::WM_OK, window->Destroy());
1988 }
1989
1990 /**
1991 * @tc.name: IDispatchInputEventListener
1992 * @tc.desc: IDispatchInputEventListener fun
1993 * @tc.type: FUNC
1994 */
1995 HWTEST_F(WindowTest, IDispatchInputEventListener, Function | SmallTest | Level3)
1996 {
1997 sptr<Window> window = new Window();
1998 ASSERT_NE(nullptr, window);
1999 auto ret = true;
2000 sptr<IDispatchInputEventListener> listener = new IDispatchInputEventListener();
2001 std::shared_ptr<MMI::KeyEvent> keyEvent = nullptr;
2002 std::shared_ptr<MMI::PointerEvent> pointerEvent = nullptr;
2003 std::shared_ptr<MMI::AxisEvent> axisEvent = nullptr;
2004 listener->OnDispatchPointerEvent(pointerEvent);
2005 listener->OnDispatchKeyEvent(keyEvent);
2006 ASSERT_EQ(true, ret);
2007 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2008 }
2009
2010 /**
2011 * @tc.name: Marshalling
2012 * @tc.desc: keyboardAnimationConfig marshalling
2013 * @tc.type: FUNC
2014 */
2015 HWTEST_F(WindowTest, KeyboardAnimationConfigMarshalling, Function | SmallTest | Level3)
2016 {
2017 MessageParcel data;
2018 KeyboardAnimationConfig config;
2019 auto ret = data.WriteParcelable(&config);
2020 Parcel parcel;
2021 config.Unmarshalling(parcel);
2022 ASSERT_EQ(true, ret);
2023 }
2024
2025 /**
2026 * @tc.name: BackgroundFailed
2027 * @tc.desc: window life cycle BackgroundFailed
2028 * @tc.type: FUNC
2029 */
2030 HWTEST_F(WindowTest, WindowLifeCycleBackgroundFailed, Function | SmallTest | Level3)
2031 {
2032 IWindowLifeCycle windowLifeCycle;
2033 int32_t ret = 0;
2034 windowLifeCycle.BackgroundFailed(ret);
2035 ASSERT_EQ(0, ret);
2036 }
2037
2038 /**
2039 * @tc.name: GetVSyncPeriod
2040 * @tc.desc: window GetVSyncPeriod
2041 * @tc.type: FUNC
2042 */
2043 HWTEST_F(WindowTest, GetVSyncPeriod, Function | SmallTest | Level3)
2044 {
2045 sptr<WindowOption> winOption = nullptr;
2046 winOption = new (std::nothrow) OHOS::Rosen::WindowOption();
2047 ASSERT_NE(nullptr, winOption);
2048 winOption->SetWindowType(OHOS::Rosen::WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
2049
2050 sptr<WindowOption> option = new WindowOption;
2051 sptr<Window> window = Window::Create("win", option);
2052 if (window != nullptr) {
2053 ASSERT_NE(nullptr, window);
2054 int64_t period = window->GetVSyncPeriod();
2055 ASSERT_LE(-1, period);
2056 }
2057 sptr<Window> window_ = new Window();
2058 ASSERT_NE(nullptr, window_);
2059 int64_t period_ = window_->GetVSyncPeriod();
2060 ASSERT_LE(-1, period_);
2061 }
2062
2063 /**
2064 * @tc.name: performBack
2065 * @tc.desc: window performBack
2066 * @tc.type: FUNC
2067 */
2068 HWTEST_F(WindowTest, performBack, Function | SmallTest | Level3)
2069 {
2070 sptr<WindowOption> winOption = nullptr;
2071 winOption = new (std::nothrow) OHOS::Rosen::WindowOption();
2072 ASSERT_NE(nullptr, winOption);
2073 winOption->SetWindowType(OHOS::Rosen::WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
2074
2075 sptr<WindowOption> option = new WindowOption;
2076 sptr<Window> window = Window::Create("performBack", option);
2077 if (window != nullptr) {
2078 ASSERT_NE(nullptr, window);
2079 window->PerformBack()
2080 ;
2081 }
2082 sptr<Window> window_ = new Window();
2083 ASSERT_NE(nullptr, window_);
2084 window_->PerformBack();
2085 }
2086
2087 /**
2088 * @tc.name: SetResizeByDragEnabled
2089 * @tc.desc: set dragEnabled flag
2090 * @tc.type: FUNC
2091 */
2092 HWTEST_F(WindowTest, SetResizeByDragEnabled, Function | SmallTest | Level2)
2093 {
2094 sptr<Window> window = new Window();
2095 ASSERT_NE(nullptr, window);
2096 ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetResizeByDragEnabled(true));
2097 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2098 }
2099
2100 /**
2101 * @tc.name: SetRaiseByClickEnabled
2102 * @tc.desc: set raiseEnabled flag
2103 * @tc.type: FUNC
2104 */
2105 HWTEST_F(WindowTest, SetRaiseByClickEnabled, Function | SmallTest | Level2)
2106 {
2107 sptr<Window> window = new Window();
2108 ASSERT_NE(nullptr, window);
2109 ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetRaiseByClickEnabled(true));
2110 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2111 }
2112
2113 /**
2114 * @tc.name: RaiseAboveTarget
2115 * @tc.desc: RaiseAboveTarget flag
2116 * @tc.type: FUNC
2117 */
2118 HWTEST_F(WindowTest, RaiseAboveTarget, Function | SmallTest | Level2)
2119 {
2120 sptr<Window> window = new Window();
2121 ASSERT_NE(nullptr, window);
2122 ASSERT_EQ(WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT, window->RaiseAboveTarget(2));
2123 ASSERT_EQ(WMError::WM_OK, window->Destroy());
2124 }
2125
2126 }
2127 } // namespace Rosen
2128 } // namespace OHOS