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