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