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