1 /*
2  * Copyright (c) 2022-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 <fcntl.h>
17 #include <gtest/gtest.h>
18 #include "common_test_utils.h"
19 #include "iremote_object_mocker.h"
20 #include "mock_IWindow.h"
21 #include "mock_RSIWindowAnimationController.h"
22 #include "window_manager_service.h"
23 
24 #include <thread>
25 
26 #include <ability_manager_client.h>
27 #include <cinttypes>
28 #include <chrono>
29 #include <hisysevent.h>
30 #include <hitrace_meter.h>
31 #include <ipc_skeleton.h>
32 #include <parameters.h>
33 #include <rs_iwindow_animation_controller.h>
34 #include <system_ability_definition.h>
35 #include <sstream>
36 #include "xcollie/watchdog.h"
37 
38 #include "color_parser.h"
39 #include "display_manager.h"
40 #include "display_manager_service_inner.h"
41 #include "dm_common.h"
42 #include "drag_controller.h"
43 #include "minimize_app.h"
44 #include "permission.h"
45 #include "remote_animation.h"
46 #include "singleton_container.h"
47 #include "ui/rs_ui_director.h"
48 #include "window_helper.h"
49 #include "window_inner_manager.h"
50 #include "window_manager_agent_controller.h"
51 #include "window_manager_hilog.h"
52 #include "wm_common.h"
53 #include "wm_math.h"
54 #include "scene_board_judgement.h"
55 
56 
57 using namespace testing;
58 using namespace testing::ext;
59 namespace OHOS {
60 namespace Rosen {
61 class WindowManagerServiceTest : public testing::Test {
62 public:
63     static void SetUpTestCase();
64     static void TearDownTestCase();
65     void SetUp() override;
66     void TearDown() override;
67 
68     void SetAceessTokenPermission(const std::string processName);
69     sptr<WindowManagerService> wms = new WindowManagerService();
70     sptr<WindowManagerServiceHandler> wmsHandler_ = new WindowManagerServiceHandler();
71     sptr<IDisplayChangeListener> listener = new DisplayChangeListener();
72     sptr<IWindowInfoQueriedListener> windowInfoQueriedListener = new WindowInfoQueriedListener();
73 };
74 
SetUpTestCase()75 void WindowManagerServiceTest::SetUpTestCase()
76 {
77 }
78 
TearDownTestCase()79 void WindowManagerServiceTest::TearDownTestCase()
80 {
81 }
82 
SetUp()83 void WindowManagerServiceTest::SetUp()
84 {
85     CommonTestUtils::SetAceessTokenPermission("WindowManagerServiceTest");
86 }
87 
TearDown()88 void WindowManagerServiceTest::TearDown()
89 {
90 }
91 
92 namespace {
93 /**
94  * @tc.name: OnAddSystemAbility
95  * @tc.desc: OnAddSystemAbility test
96  * @tc.type: FUNC
97  */
98 HWTEST_F(WindowManagerServiceTest, OnAddSystemAbility01, Function | SmallTest | Level2)
99 {
100     std::string str = "OnAddSystemAbility";
101     wms->OnAddSystemAbility(0, str);
102     ASSERT_EQ(nullptr, wms->windowCommonEvent_->subscriber_);
103 }
104 /**
105  * @tc.name: WindowVisibilityChangeCallback
106  * @tc.desc: WindowVisibilityChangeCallback test
107  * @tc.type: FUNC
108  */
109 HWTEST_F(WindowManagerServiceTest, WindowVisibilityChangeCallback01, Function | SmallTest | Level2)
110 {
111     std::shared_ptr<RSOcclusionData> occlusionData = nullptr;
112     wms->WindowVisibilityChangeCallback(occlusionData);
113     ASSERT_EQ(nullptr, occlusionData);
114     int time = 10000;
115     std::chrono::milliseconds dura(time);
116     std::this_thread::sleep_for(dura);
117 }
118 /**
119  * @tc.name: InitWithAbilityManagerServiceAdded
120  * @tc.desc: Init with ability manager service added.
121  * @tc.type: FUNC
122  */
123 HWTEST_F(WindowManagerServiceTest, InitWithAbilityManagerServiceAdded01, Function | SmallTest | Level2)
124 {
125     wms->InitWithAbilityManagerServiceAdded();
126     wms->wmsHandler_ = new WindowManagerServiceHandler;
127     wms->InitWithAbilityManagerServiceAdded();
128     ASSERT_NE(nullptr, wms->wmsHandler_);
129 }
130 /**
131  * @tc.name: Dump
132  * @tc.desc: Dump info
133  * @tc.type: FUNC
134  */
135 HWTEST_F(WindowManagerServiceTest, Dump01, Function | SmallTest | Level2)
136 {
137     wms->windowDumper_ = nullptr;
138     std::vector<std::u16string> args;
139     const std::string dumpFile = "data/window_dump_test.txt";
140     int fd = open(dumpFile.c_str(), O_RDWR | O_CREAT | O_TRUNC, 0666);
141     if (fd == -1) {
142         return;
143     }
144     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
145         ASSERT_EQ(static_cast<int>(WMError::WM_OK), wms->Dump(-1, args));
146     } else {
147         ASSERT_NE(static_cast<int>(WMError::WM_ERROR_INVALID_PARAM), wms->Dump(-1, args));
148     }
149     ASSERT_EQ(static_cast<int>(WMError::WM_OK), wms->Dump(fd, args));
150     close(fd);
151     unlink(dumpFile.c_str());
152 }
153 /**
154  * @tc.name: NotifyWindowTransition
155  * @tc.desc: NotifyWindowTransition test
156  * @tc.type: FUNC
157  */
158 HWTEST_F(WindowManagerServiceTest, NotifyWindowTransition01, Function | SmallTest | Level2)
159 {
160     sptr<WindowTransitionInfo> fromInfo = nullptr;
161     sptr<WindowTransitionInfo> toInfo = nullptr;
162     ASSERT_EQ(WMError::WM_OK, wms->NotifyWindowTransition(fromInfo, toInfo, false));
163     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
164         ASSERT_EQ(WMError::WM_OK, wms->NotifyWindowTransition(fromInfo, toInfo, true));
165     } else {
166         ASSERT_NE(WMError::WM_ERROR_NO_REMOTE_ANIMATION, wms->NotifyWindowTransition(fromInfo, toInfo, true));
167     }
168 }
169 /**
170  * @tc.name: StartingWindow
171  * @tc.desc: StartingWindow test
172  * @tc.type: FUNC
173  */
174 HWTEST_F(WindowManagerServiceTest, StartingWindow01, Function | SmallTest | Level2)
175 {
176     wms->startingOpen_ = false;
177     wms->StartingWindow(nullptr, nullptr, false, 0);
178     ASSERT_EQ(false, wms->startingOpen_);
179     wms->CancelStartingWindow(nullptr);
180     wms->startingOpen_ = true;
181     wms->StartingWindow(nullptr, nullptr, false, 0);
182     ASSERT_EQ(true, wms->startingOpen_);
183     wms->CancelStartingWindow(nullptr);
184 }
185 
186 /**
187  * @tc.name: MoveMissionsToForeground
188  * @tc.desc: MoveMissionsToForont test
189  * @tc.type: FUNC
190  */
191 HWTEST_F(WindowManagerServiceTest, MoveMissionsToForeground01, Function | SmallTest | Level2)
192 {
193     WMError rs = wms->MoveMissionsToForeground({}, -1);
194     ASSERT_EQ(WMError::WM_OK, rs);
195 }
196 
197 
198 /**
199  * @tc.name: MoveMissionsToBackground
200  * @tc.desc: MoveMissionsToBackground test
201  * @tc.type: FUNC
202  */
203 HWTEST_F(WindowManagerServiceTest, MoveMissionsToBackground01, Function | SmallTest | Level2)
204 {
205     std::vector<int32_t> moveRs;
206     WMError rs = wms->MoveMissionsToBackground({}, moveRs);
207     ASSERT_EQ(WMError::WM_OK, rs);
208 }
209 
210 /**
211  * @tc.name: CreateWindow
212  * @tc.desc: CreateWindow test
213  * @tc.type: FUNC
214  */
215 HWTEST_F(WindowManagerServiceTest, CreateWindow01, Function | SmallTest | Level2)
216 {
217     sptr<IWindow> window = nullptr;
218     uint32_t id = 2;
219     std::shared_ptr<RSSurfaceNode> RS_node = nullptr;
220     sptr<WindowProperty> property = new WindowProperty();
221     property->SetWindowType(WindowType::WINDOW_TYPE_WALLPAPER);
222     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, wms->CreateWindow(window, property, RS_node, id, nullptr));
223     wms->DestroyWindow(id, true);
224 }
225 /**
226  * @tc.name: AddWindow
227  * @tc.desc: AddWindow test
228  * @tc.type: FUNC
229  */
230 HWTEST_F(WindowManagerServiceTest, AddWindow01, Function | SmallTest | Level2)
231 {
232     sptr<WindowProperty> property = nullptr;
233     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, wms->AddWindow(property));
234 }
235 /**
236  * @tc.name: RegisterWindowManagerAgent
237  * @tc.desc: RegisterWindowManagerAgent test
238  * @tc.type: FUNC
239  */
240 HWTEST_F(WindowManagerServiceTest, RegisterWindowManagerAgent01, Function | SmallTest | Level2)
241 {
242     sptr<IWindowManagerAgent> windowManagerAgent = nullptr;
243     WindowManagerAgentType type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT;
244     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, wms->RegisterWindowManagerAgent(type, windowManagerAgent));
245     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, wms->UnregisterWindowManagerAgent(type, windowManagerAgent));
246 }
247 /**
248  * @tc.name: SetWindowAnimationController
249  * @tc.desc: SetWindowAnimationController test
250  * @tc.type: FUNC
251  */
252 HWTEST_F(WindowManagerServiceTest, SetWindowAnimationController01, Function | SmallTest | Level2)
253 {
254     sptr<RSIWindowAnimationController> controller = nullptr;
255     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, wms->SetWindowAnimationController(controller));
256     controller = new RSIWindowAnimationControllerMocker;
257     ASSERT_EQ(WMError::WM_OK, wms->SetWindowAnimationController(controller));
258 }
259 /**
260  * @tc.name: OnWindowEvent
261  * @tc.desc: OnWindowEvent test
262  * @tc.type: FUNC
263  */
264 HWTEST_F(WindowManagerServiceTest, OnWindowEvent01, Function | SmallTest | Level2)
265 {
266     sptr<IRemoteObject> remoteObject = new IRemoteObjectMocker;
267     wms->OnWindowEvent(static_cast<Event>(1), remoteObject);
268     wms->OnWindowEvent(Event::REMOTE_DIED, remoteObject);
269     ASSERT_EQ(INVALID_WINDOW_ID, wms->windowRoot_->GetWindowIdByObject(remoteObject));
270 }
271 /**
272  * @tc.name: UpdateProperty
273  * @tc.desc: UpdateProperty test
274  * @tc.type: FUNC
275  */
276 HWTEST_F(WindowManagerServiceTest, UpdateProperty01, Function | SmallTest | Level2)
277 {
278     sptr<WindowProperty> windowProperty = nullptr;
279     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, wms->UpdateProperty(windowProperty,
280         PropertyChangeAction::ACTION_UPDATE_ANIMATION_FLAG, true));
281 }
282 /**
283  * @tc.name: GetModeChangeHotZones
284  * @tc.desc: GetModeChangeHotZones test
285  * @tc.type: FUNC
286  */
287 HWTEST_F(WindowManagerServiceTest, GetModeChangeHotZones01, Function | SmallTest | Level2)
288 {
289     ModeChangeHotZonesConfig config = {false, 0, 0, 0};
290     DisplayId displayId = 0;
291     ModeChangeHotZones hotZone;
292     wms->hotZonesConfig_ = config;
293     ASSERT_EQ(WMError::WM_DO_NOTHING, wms->GetModeChangeHotZones(displayId, hotZone));
294     config.isModeChangeHotZoneConfigured_ = true;
295     wms->hotZonesConfig_ = config;
296     ASSERT_EQ(WMError::WM_ERROR_NULLPTR, wms->GetModeChangeHotZones(displayId, hotZone));
297 }
298 /**
299  * @tc.name: UpdateAvoidAreaListener
300  * @tc.desc: UpdateAvoidAreaListener test
301  * @tc.type: FUNC
302  */
303 HWTEST_F(WindowManagerServiceTest, UpdateAvoidAreaListener01, Function | SmallTest | Level2)
304 {
305     sptr<WindowProperty> property = new WindowProperty();
306     sptr<WindowNode> node = new WindowNode(property);
307     wms->windowRoot_->windowNodeMap_.insert(std::make_pair(0, node));
308     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
309         ASSERT_EQ(WMError::WM_OK, wms->UpdateAvoidAreaListener(0, true));
310     } else {
311         ASSERT_NE(WMError::WM_DO_NOTHING, wms->UpdateAvoidAreaListener(0, true));
312     }
313 }
314 /**
315  * @tc.name: BindDialogTarget
316  * @tc.desc: BindDialogTarget test
317  * @tc.type: FUNC
318  */
319 HWTEST_F(WindowManagerServiceTest, BindDialogTarget01, Function | SmallTest | Level2)
320 {
321     sptr<IRemoteObject> targetToken = new IRemoteObjectMocker();
322     uint32_t id = 0;
323     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
324         ASSERT_EQ(WMError::WM_OK, wms->BindDialogTarget(id, targetToken));
325     } else {
326         ASSERT_NE(WMError::WM_ERROR_NULLPTR, wms->BindDialogTarget(id, targetToken));
327     }
328 }
329 /**
330  * @tc.name: DispatchKeyEvent01
331  * @tc.desc: Dispatch KeyEvent for app window bellow the component window.
332  * @tc.require: issueI6RMUY
333  * @tc.type: FUNC
334  */
335 HWTEST_F(WindowManagerServiceTest, DispatchKeyEvent01, Function | SmallTest | Level2)
336 {
337     wms = new WindowManagerService();
338     sptr<WindowNode> compNode = new WindowNode();
339     compNode->property_->type_ = WindowType::WINDOW_TYPE_APP_COMPONENT;
340     compNode->SetWindowToken(new IWindowMocker);
341     compNode->property_->windowId_ = 1U;
342     sptr<WindowNode> appNode = new WindowNode();
343     appNode->property_->type_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW;
344     IWindowMocker* token = new IWindowMocker;
345     appNode->SetWindowToken(token);
346     appNode->property_->windowId_ = 2U;
347     auto event = MMI::KeyEvent::Create();
348     wms->windowController_->windowRoot_->windowNodeMap_[appNode->GetWindowId()] = appNode;
349     wms->windowController_->windowRoot_->windowNodeMap_[compNode->GetWindowId()] = compNode;
350     sptr<WindowNodeContainer> container = new WindowNodeContainer(new DisplayInfo, 0);
351     wms->windowController_->windowRoot_->windowNodeContainerMap_[compNode->GetDisplayId()] = container;
352     wms->windowController_->windowRoot_->displayIdMap_[compNode->GetDisplayId()] = { compNode->GetDisplayId() };
353     container->appWindowNode_->children_.push_back(appNode);
354     container->appWindowNode_->children_.push_back(compNode);
355     std::vector<sptr<WindowNode>> windowNodes;
356     container->TraverseContainer(windowNodes);
357     ASSERT_TRUE(windowNodes[0] == compNode);
358     ASSERT_TRUE(windowNodes[1] == appNode);
359     EXPECT_CALL(*token, ConsumeKeyEvent(_));
360     wms->DispatchKeyEvent(compNode->GetWindowId(), event);
361     testing::Mock::AllowLeak(token);
362 }
363 /**
364  * @tc.name: DispatchKeyEvent02
365  * @tc.desc: Dispatch KeyEvent for app window bellow the app window.
366  * @tc.require: issueI6RMUY
367  * @tc.type: FUNC
368  */
369 HWTEST_F(WindowManagerServiceTest, DispatchKeyEvent02, Function | SmallTest | Level2)
370 {
371     wms = new WindowManagerService();
372     sptr<WindowNode> appNode1 = new WindowNode();
373     appNode1->property_->type_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW;
374     appNode1->SetWindowToken(new IWindowMocker);
375     appNode1->property_->windowId_ = 1U;
376     sptr<WindowNode> appNode2 = new WindowNode();
377     appNode2->property_->type_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW;
378     appNode2->SetWindowToken(new IWindowMocker);
379     appNode2->property_->windowId_ = 2U;
380     auto event = MMI::KeyEvent::Create();
381     wms->windowController_->windowRoot_->windowNodeMap_[appNode2->GetWindowId()] = appNode2;
382     wms->windowController_->windowRoot_->windowNodeMap_[appNode1->GetWindowId()] = appNode1;
383     sptr<WindowNodeContainer> container = new WindowNodeContainer(new DisplayInfo, 0);
384     wms->windowController_->windowRoot_->windowNodeContainerMap_[appNode1->GetDisplayId()] = container;
385     wms->windowController_->windowRoot_->displayIdMap_[appNode1->GetDisplayId()] = { appNode1->GetDisplayId() };
386     container->appWindowNode_->children_.push_back(appNode2);
387     container->appWindowNode_->children_.push_back(appNode1);
388     std::vector<sptr<WindowNode>> windowNodes;
389     container->TraverseContainer(windowNodes);
390     ASSERT_TRUE(windowNodes[0] == appNode1);
391     ASSERT_TRUE(windowNodes[1] == appNode2);
392     wms->DispatchKeyEvent(appNode1->GetWindowId(), event);
393 }
394 /**
395  * @tc.name: DispatchKeyEvent03
396  * @tc.desc: Dispatch KeyEvent for app window bellow two component window.
397  * @tc.require: issueI6RMUY
398  * @tc.type: FUNC
399  */
400 HWTEST_F(WindowManagerServiceTest, DispatchKeyEvent03, Function | SmallTest | Level2)
401 {
402     wms = new WindowManagerService();
403     sptr<WindowNode> compNode1 = new WindowNode();
404     compNode1->property_->type_ = WindowType::WINDOW_TYPE_APP_COMPONENT;
405     compNode1->SetWindowToken(new IWindowMocker);
406     compNode1->property_->windowId_ = 1U;
407     sptr<WindowNode> compNode2 = new WindowNode();
408     compNode2->property_->type_ = WindowType::WINDOW_TYPE_APP_COMPONENT;
409     compNode2->SetWindowToken(new IWindowMocker);
410     compNode2->property_->windowId_ = 2U;
411     sptr<WindowNode> appNode = new WindowNode();
412     appNode->property_->type_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW;
413     IWindowMocker* token = new IWindowMocker;
414     appNode->SetWindowToken(token);
415     appNode->property_->windowId_ = 3U;
416     auto event = MMI::KeyEvent::Create();
417     wms->windowController_->windowRoot_->windowNodeMap_[appNode->GetWindowId()] = appNode;
418     wms->windowController_->windowRoot_->windowNodeMap_[compNode1->GetWindowId()] = compNode1;
419     wms->windowController_->windowRoot_->windowNodeMap_[compNode2->GetWindowId()] = compNode2;
420     sptr<WindowNodeContainer> container = new WindowNodeContainer(new DisplayInfo, 0);
421     wms->windowController_->windowRoot_->windowNodeContainerMap_[compNode1->GetDisplayId()] = container;
422     wms->windowController_->windowRoot_->displayIdMap_[compNode1->GetDisplayId()] = { compNode1->GetDisplayId() };
423     container->appWindowNode_->children_.push_back(appNode);
424     container->appWindowNode_->children_.push_back(compNode1);
425     container->appWindowNode_->children_.push_back(compNode2);
426     std::vector<sptr<WindowNode>> windowNodes;
427     container->TraverseContainer(windowNodes);
428     ASSERT_TRUE(windowNodes[0] == compNode2);
429     ASSERT_TRUE(windowNodes[1] == compNode1);
430     ASSERT_TRUE(windowNodes[2] == appNode);
431     EXPECT_CALL(*token, ConsumeKeyEvent(_));
432     wms->DispatchKeyEvent(compNode2->GetWindowId(), event);
433     testing::Mock::AllowLeak(token);
434 }
435 /**
436  * @tc.name: SetWindowGravity
437  * @tc.desc: SetWindowGravity test
438  * @tc.type: FUNC
439  */
440 HWTEST_F(WindowManagerServiceTest, SetWindowGravity01, Function | SmallTest | Level2)
441 {
442     uint32_t id = 0;
443     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
444         ASSERT_EQ(WMError::WM_OK, wms->SetWindowGravity(id, WindowGravity::WINDOW_GRAVITY_BOTTOM, 0));
445     } else {
446         ASSERT_NE(WMError::WM_ERROR_NULLPTR, wms->SetWindowGravity(id, WindowGravity::WINDOW_GRAVITY_BOTTOM, 0));
447     }
448 }
449 /*
450  * @tc.name: GetWindowAnimationTargets01
451  * @tc.desc: get window animation targets
452  * @tc.type: FUNC
453  */
454 HWTEST_F(WindowManagerServiceTest, GetWindowAnimationTargets01, Function | SmallTest | Level2)
455 {
456     wms = new WindowManagerService();
457     sptr<WindowNode> compNode = new WindowNode();
458     compNode->property_->type_ = WindowType::WINDOW_TYPE_APP_COMPONENT;
459     compNode->SetWindowToken(new IWindowMocker);
460     compNode->property_->windowId_ = 1U;
461     compNode->abilityInfo_.missionId_ = 1;
462     sptr<WindowNode> appNode = new WindowNode();
463     appNode->property_->type_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW;
464     IWindowMocker* token = new IWindowMocker;
465     appNode->SetWindowToken(token);
466     appNode->property_->windowId_ = 2U;
467     appNode->abilityInfo_.missionId_ = 2;
468     wms->windowController_->windowRoot_->windowNodeMap_[appNode->GetWindowId()] = appNode;
469     wms->windowController_->windowRoot_->windowNodeMap_[compNode->GetWindowId()] = compNode;
470     sptr<WindowNodeContainer> container = new WindowNodeContainer(new DisplayInfo, 0);
471     wms->windowController_->windowRoot_->windowNodeContainerMap_[compNode->GetDisplayId()] = container;
472     wms->windowController_->windowRoot_->displayIdMap_[compNode->GetDisplayId()] = { compNode->GetDisplayId() };
473     container->appWindowNode_->children_.push_back(appNode);
474     container->appWindowNode_->children_.push_back(compNode);
475     RemoteAnimation::SetWindowControllerAndRoot(wms->windowController_, wms->windowController_->windowRoot_);
476     std::vector<uint32_t> missionIds;
477     missionIds.push_back(1);
478     missionIds.push_back(2);
479     std::vector<sptr<RSWindowAnimationTarget>> targets;
480     ASSERT_EQ(WMError::WM_OK, wms->GetWindowAnimationTargets(missionIds, targets));
481     ASSERT_EQ(0, targets.size());
482 }
483 
484 /**
485  * @tc.name: OnAccountSwitched
486  * @tc.desc: OnAccountSwitched test
487  * @tc.type: FUNC
488  */
489 HWTEST_F(WindowManagerServiceTest, OnAccountSwitched, Function | SmallTest | Level2)
490 {
491     int accountId = 0;
492     ASSERT_TRUE(wms != nullptr);
493     wms->OnAccountSwitched(accountId);
494     int time = 10000;
495     std::chrono::milliseconds dura(time);
496     std::this_thread::sleep_for(dura);
497 }
498 
499 /**
500  * @tc.name: InitWithRanderServiceAdded
501  * @tc.desc: InitWithRanderServiceAdded test
502  * @tc.type: FUNC
503  */
504 HWTEST_F(WindowManagerServiceTest, InitWithRanderServiceAdded, Function | SmallTest | Level2)
505 {
506     ASSERT_TRUE(wms != nullptr);
507     wms->InitWithRanderServiceAdded();
508 }
509 
510 /**
511  * @tc.name: NotifyWindowTransition02
512  * @tc.desc: NotifyWindowTransition02 test
513  * @tc.type: FUNC
514  */
515 HWTEST_F(WindowManagerServiceTest, NotifyWindowTransition02, Function | SmallTest | Level2)
516 {
517     sptr<AAFwk::AbilityTransitionInfo> from = new AAFwk::AbilityTransitionInfo();
518     sptr<AAFwk::AbilityTransitionInfo> to = new AAFwk::AbilityTransitionInfo();
519     bool animaEnabled = false;
520     ASSERT_TRUE(wmsHandler_ != nullptr);
521     wmsHandler_->NotifyWindowTransition(from, to, animaEnabled);
522 }
523 
524 /**
525  * @tc.name: NotifyAnimationAbilityDied
526  * @tc.desc: NotifyAnimationAbilityDied test
527  * @tc.type: FUNC
528  */
529 HWTEST_F(WindowManagerServiceTest, NotifyAnimationAbilityDied, Function | SmallTest | Level2)
530 {
531     sptr<AAFwk::AbilityTransitionInfo> info = new AAFwk::AbilityTransitionInfo();
532     ASSERT_TRUE(wmsHandler_ != nullptr);
533     wmsHandler_->NotifyAnimationAbilityDied(info);
534 }
535 
536 /**
537  * @tc.name: StartingWindow02
538  * @tc.desc: StartingWindow02 test
539  * @tc.type: FUNC
540  */
541 HWTEST_F(WindowManagerServiceTest, StartingWindow02, Function | SmallTest | Level2)
542 {
543     sptr<AAFwk::AbilityTransitionInfo> info = new AAFwk::AbilityTransitionInfo();
544     std::shared_ptr<Media::PixelMap> pixelMap = std::make_shared<Media::PixelMap>();
545     ASSERT_TRUE(wmsHandler_ != nullptr);
546     wmsHandler_->StartingWindow(info, pixelMap);
547 }
548 
549 /**
550  * @tc.name: StartingWindow03
551  * @tc.desc: StartingWindow03 test
552  * @tc.type: FUNC
553  */
554 HWTEST_F(WindowManagerServiceTest, StartingWindow03, Function | SmallTest | Level2)
555 {
556     sptr<AAFwk::AbilityTransitionInfo> info = new AAFwk::AbilityTransitionInfo();
557     std::shared_ptr<Media::PixelMap> pixelMap = std::make_shared<Media::PixelMap>();
558     uint32_t bgColor = 1;
559     ASSERT_TRUE(wmsHandler_ != nullptr);
560     wmsHandler_->StartingWindow(info, pixelMap, bgColor);
561 }
562 
563 /**
564  * @tc.name: CancelStartingWindow01
565  * @tc.desc: CancelStartingWindow test
566  * @tc.type: FUNC
567  */
568 HWTEST_F(WindowManagerServiceTest, CancelStartingWindow01, Function | SmallTest | Level2)
569 {
570     sptr<IRemoteObject> abilityToken = nullptr;
571     wms->startingOpen_ = false;
572     ASSERT_TRUE(wms != nullptr);
573     wmsHandler_->CancelStartingWindow(abilityToken);
574 }
575 
576 /**
577  * @tc.name: MoveMissionsToForeground02
578  * @tc.desc: MoveMissionsToForeground test
579  * @tc.type: FUNC
580  */
581 HWTEST_F(WindowManagerServiceTest, MoveMissionsToForeground02, Function | SmallTest | Level2)
582 {
583     const std::vector<int32_t> missionIds;
584     int32_t topMissionId = 1;
585     wms->windowGroupMgr_ = nullptr;
586     ASSERT_TRUE(wms != nullptr);
587     wmsHandler_->MoveMissionsToForeground(missionIds, topMissionId);
588 }
589 
590 /**
591  * @tc.name: Init
592  * @tc.desc: Init test
593  * @tc.type: FUNC
594  */
595 HWTEST_F(WindowManagerServiceTest, Init, Function | SmallTest | Level2)
596 {
597     wms->windowRoot_ = new WindowRoot(nullptr);
598     wms->Init();
599     ASSERT_NE(wms->windowRoot_, nullptr);
600 }
601 
602 /**
603  * @tc.name: Dump02
604  * @tc.desc: Dump02 test
605  * @tc.type: FUNC
606  */
607 HWTEST_F(WindowManagerServiceTest, Dump02, Function | SmallTest | Level2)
608 {
609     int fd = 2;
610     std::vector<std::u16string> args;
611     wms->Dump(fd, args);
612     ASSERT_EQ(fd, 2);
613     wms->windowDumper_ = nullptr;
614     ASSERT_TRUE(wms != nullptr);
615     wms->Dump(fd, args);
616 }
617 
618 /**
619  * @tc.name: ConfigStartingWindowAnimation
620  * @tc.desc: ConfigStartingWindowAnimation test
621  * @tc.type: FUNC
622  */
623 HWTEST_F(WindowManagerServiceTest, ConfigStartingWindowAnimation, Function | SmallTest | Level2)
624 {
625     WindowManagerConfig::ConfigItem animeConfig;
626     ASSERT_TRUE(wms != nullptr);
627     wms->ConfigStartingWindowAnimation(animeConfig);
628 }
629 
630 /**
631  * @tc.name: RequestFocus
632  * @tc.desc: RequestFocus test
633  * @tc.type: FUNC
634  */
635 HWTEST_F(WindowManagerServiceTest, RequestFocus, Function | SmallTest | Level2)
636 {
637     uint32_t windowId = 1;
638     WMError res = wms->RequestFocus(windowId);
639     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
640         ASSERT_NE(res, WMError::WM_OK);
641     } else {
642         ASSERT_EQ(res, WMError::WM_OK);
643     }
644 }
645 
646 /**
647  * @tc.name: GetAvoidAreaByType
648  * @tc.desc: GetAvoidAreaByType test
649  * @tc.type: FUNC
650  */
651 HWTEST_F(WindowManagerServiceTest, GetAvoidAreaByType, Function | SmallTest | Level2)
652 {
653     uint32_t windowId = 1;
654     AvoidAreaType avoidAreaType = AvoidAreaType::TYPE_SYSTEM;
655     ASSERT_TRUE(wms != nullptr);
656     wms->GetAvoidAreaByType(windowId, avoidAreaType);
657 }
658 
659 /**
660  * @tc.name: NotifyDisplayStateChange
661  * @tc.desc: NotifyDisplayStateChange test
662  * @tc.type: FUNC
663  */
664 HWTEST_F(WindowManagerServiceTest, NotifyDisplayStateChange, Function | SmallTest | Level2)
665 {
666     DisplayId defaultDisplayId = DisplayGroupInfo::GetInstance().GetDefaultDisplayId();
667     auto display = DisplayManager::GetInstance().GetDefaultDisplay();
668     sptr<DisplayInfo> displayInfo = display->GetDisplayInfo();
669     std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
670     DisplayStateChangeType type = DisplayStateChangeType::BEFORE_SUSPEND;
671     ASSERT_TRUE(wms != nullptr);
672     wms->NotifyDisplayStateChange(defaultDisplayId, displayInfo, displayInfoMap, type);
673 }
674 
675 /**
676  * @tc.name: OnDisplayStateChange
677  * @tc.desc: OnDisplayStateChange test
678  * @tc.type: FUNC
679  */
680 HWTEST_F(WindowManagerServiceTest, OnDisplayStateChange, Function | SmallTest | Level2)
681 {
682     DisplayId defaultDisplayId = DisplayGroupInfo::GetInstance().GetDefaultDisplayId();
683     auto display = DisplayManager::GetInstance().GetDefaultDisplay();
684     sptr<DisplayInfo> displayInfo = display->GetDisplayInfo();
685     std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
686     DisplayStateChangeType type = DisplayStateChangeType::BEFORE_SUSPEND;
687     ASSERT_TRUE(listener != nullptr);
688     listener->OnDisplayStateChange(defaultDisplayId, displayInfo, displayInfoMap, type);
689 }
690 
691 /**
692  * @tc.name: NotifyServerReadyToMoveOrDrag
693  * @tc.desc: NotifyServerReadyToMoveOrDrag test
694  * @tc.type: FUNC
695  */
696 HWTEST_F(WindowManagerServiceTest, NotifyServerReadyToMoveOrDrag, Function | SmallTest | Level2)
697 {
698     uint32_t windowId = 1;
699     sptr<WindowProperty> windowProperty;
700     sptr<MoveDragProperty> moveDragProperty;
701     ASSERT_TRUE(wms != nullptr);
702     wms->NotifyServerReadyToMoveOrDrag(windowId, windowProperty, moveDragProperty);
703 }
704 
705 /**
706  * @tc.name: ProcessPointDown
707  * @tc.desc: ProcessPointDown test
708  * @tc.type: FUNC
709  */
710 HWTEST_F(WindowManagerServiceTest, ProcessPointDown, Function | SmallTest | Level2)
711 {
712     uint32_t windowId = 1;
713     bool isPointDown = false;
714     ASSERT_TRUE(wms != nullptr);
715     wms->ProcessPointDown(windowId, isPointDown);
716 }
717 
718 /**
719  * @tc.name: MinimizeAllAppWindows
720  * @tc.desc: MinimizeAllAppWindows test
721  * @tc.type: FUNC
722  */
723 HWTEST_F(WindowManagerServiceTest, MinimizeAllAppWindows, Function | SmallTest | Level2)
724 {
725     DisplayId displayId = 1;
726     WMError res = wms->MinimizeAllAppWindows(displayId);
727     ASSERT_EQ(WMError::WM_OK, res);
728 }
729 
730 /**
731  * @tc.name: ToggleShownStateForAllAppWindows
732  * @tc.desc: ToggleShownStateForAllAppWindows test
733  * @tc.type: FUNC
734  */
735 HWTEST_F(WindowManagerServiceTest, ToggleShownStateForAllAppWindows, Function | SmallTest | Level2)
736 {
737     WMError res = wms->ToggleShownStateForAllAppWindows();
738     ASSERT_EQ(WMError::WM_OK, res);
739 }
740 
741 /**
742  * @tc.name: GetTopWindowId
743  * @tc.desc: GetTopWindowId test
744  * @tc.type: FUNC
745  */
746 HWTEST_F(WindowManagerServiceTest, GetTopWindowId, Function | SmallTest | Level2)
747 {
748     uint32_t mainWinId = 1;
749     uint32_t topWinId = 1;
750     WMError res = wms->GetTopWindowId(mainWinId, topWinId);
751     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
752         ASSERT_EQ(WMError::WM_OK, res);
753     } else {
754         ASSERT_NE(WMError::WM_ERROR_INVALID_WINDOW, res);
755     }
756 }
757 
758 /**
759  * @tc.name: SetWindowLayoutMode
760  * @tc.desc: SetWindowLayoutMode test
761  * @tc.type: FUNC
762  */
763 HWTEST_F(WindowManagerServiceTest, SetWindowLayoutMode, Function | SmallTest | Level2)
764 {
765     WindowLayoutMode mode = WindowLayoutMode::BASE;
766     WMError res = wms->SetWindowLayoutMode(mode);
767     ASSERT_EQ(WMError::WM_OK, res);
768 }
769 
770 /**
771  * @tc.name: GetAccessibilityWindowInfo
772  * @tc.desc: GetAccessibilityWindowInfo test
773  * @tc.type: FUNC
774  */
775 HWTEST_F(WindowManagerServiceTest, GetAccessibilityWindowInfo, Function | SmallTest | Level2)
776 {
777     std::vector<sptr<AccessibilityWindowInfo>> infos;
778     WMError res = wms->GetAccessibilityWindowInfo(infos);
779     ASSERT_EQ(WMError::WM_OK, res);
780 }
781 
782 /**
783  * @tc.name: GetUnreliableWindowInfo
784  * @tc.desc: GetUnreliableWindowInfo test
785  * @tc.type: FUNC
786  */
787 HWTEST_F(WindowManagerServiceTest, GetUnreliableWindowInfo, Function | SmallTest | Level2)
788 {
789     std::vector<sptr<UnreliableWindowInfo>> infos;
790     int32_t windowId = 0;
791     WMError res = wms->GetUnreliableWindowInfo(windowId, infos);
792     ASSERT_EQ(WMError::WM_OK, res);
793 }
794 
795 /**
796  * @tc.name: GetVisibilityWindowInfo
797  * @tc.desc: GetVisibilityWindowInfo test
798  * @tc.type: FUNC
799  */
800 HWTEST_F(WindowManagerServiceTest, GetVisibilityWindowInfo, Function | SmallTest | Level2)
801 {
802     std::vector<sptr<WindowVisibilityInfo>> infos;
803     WMError res = wms->GetVisibilityWindowInfo(infos);
804     ASSERT_EQ(WMError::WM_OK, res);
805 }
806 
807 /**
808  * @tc.name: RaiseToAppTop
809  * @tc.desc: RaiseToAppTop test
810  * @tc.type: FUNC
811  */
812 HWTEST_F(WindowManagerServiceTest, RaiseToAppTop, Function | SmallTest | Level2)
813 {
814     uint32_t windowId = 1;
815     WMError res = wms->RaiseToAppTop(windowId);
816     if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
817         ASSERT_EQ(WMError::WM_OK, res);
818     } else {
819         ASSERT_NE(WMError::WM_DO_NOTHING, res);
820     }
821 }
822 
823 /**
824  * @tc.name: GetSnapshot
825  * @tc.desc: GetSnapshot test
826  * @tc.type: FUNC
827  */
828 HWTEST_F(WindowManagerServiceTest, GetSnapshot, Function | SmallTest | Level2)
829 {
830     uint32_t windowId = 1;
831     ASSERT_EQ(nullptr, wms->GetSnapshot(windowId));
832 }
833 
834 /**
835  * @tc.name: MinimizeWindowsByLauncher
836  * @tc.desc: MinimizeWindowsByLauncher test
837  * @tc.type: FUNC
838  */
839 HWTEST_F(WindowManagerServiceTest, MinimizeWindowsByLauncher, Function | SmallTest | Level2)
840 {
841     std::vector<uint32_t> windowIds;
842     bool isAnimated = false;
843     sptr<RSIWindowAnimationFinishedCallback> finishCallback;
844     ASSERT_TRUE(wms != nullptr);
845     wms->MinimizeWindowsByLauncher(windowIds, isAnimated, finishCallback);
846 }
847 
848 /**
849  * @tc.name: SetAnchorAndScale
850  * @tc.desc: SetAnchorAndScale test
851  * @tc.type: FUNC
852  */
853 HWTEST_F(WindowManagerServiceTest, SetAnchorAndScale, Function | SmallTest | Level2)
854 {
855     int32_t x = 1;
856     int32_t y = 2;
857     float scale = 0.1;
858     ASSERT_TRUE(wms != nullptr);
859     wms->SetAnchorAndScale(x, y, scale);
860 }
861 
862 /**
863  * @tc.name: SetAnchorOffset
864  * @tc.desc: SetAnchorOffset test
865  * @tc.type: FUNC
866  */
867 HWTEST_F(WindowManagerServiceTest, SetAnchorOffset, Function | SmallTest | Level2)
868 {
869     int32_t deltaX = 1;
870     int32_t deltaY = 2;
871     ASSERT_TRUE(wms != nullptr);
872     wms->SetAnchorOffset(deltaX, deltaY);
873 }
874 
875 /**
876  * @tc.name: OffWindowZoom
877  * @tc.desc: OffWindowZoom test
878  * @tc.type: FUNC
879  */
880 HWTEST_F(WindowManagerServiceTest, OffWindowZoom, Function | SmallTest | Level2)
881 {
882     ASSERT_TRUE(wms != nullptr);
883     wms->OffWindowZoom();
884 }
885 
886 /**
887  * @tc.name: UpdateRsTree
888  * @tc.desc: UpdateRsTree test
889  * @tc.type: FUNC
890  */
891 HWTEST_F(WindowManagerServiceTest, UpdateRsTree, Function | SmallTest | Level2)
892 {
893     uint32_t windowId = 1;
894     bool isAdd = false;
895     ASSERT_TRUE(wms != nullptr);
896     wms->UpdateRsTree(windowId, isAdd);
897 }
898 
899 /**
900  * @tc.name: OnScreenshot
901  * @tc.desc: OnScreenshot test
902  * @tc.type: FUNC
903  */
904 HWTEST_F(WindowManagerServiceTest, OnScreenshot, Function | SmallTest | Level2)
905 {
906     DisplayId displayId = 1;
907     ASSERT_TRUE(wms != nullptr);
908     wms->OnScreenshot(displayId);
909 }
910 
911 /**
912  * @tc.name: HasPrivateWindow01
913  * @tc.desc: HasPrivateWindow01 test
914  * @tc.type: FUNC
915  */
916 HWTEST_F(WindowManagerServiceTest, HasPrivateWindow01, Function | SmallTest | Level2)
917 {
918     DisplayId displayId = 1;
919     bool hasPrivateWindow = false;
920     ASSERT_TRUE(wms != nullptr);
921     wms->HasPrivateWindow(displayId, hasPrivateWindow);
922 }
923 
924 /**
925  * @tc.name: SetGestureNavigaionEnabled
926  * @tc.desc: SetGestureNavigaionEnabled test
927  * @tc.type: FUNC
928  */
929 HWTEST_F(WindowManagerServiceTest, SetGestureNavigaionEnabled, Function | SmallTest | Level2)
930 {
931     bool enable = false;
932     ASSERT_TRUE(wms != nullptr);
933     WMError res = wms->SetGestureNavigaionEnabled(enable);
934     ASSERT_EQ(WMError::WM_OK, res);
935 }
936 
937 /**
938  * @tc.name: HasPrivateWindow02
939  * @tc.desc: HasPrivateWindow02 test
940  * @tc.type: FUNC
941  */
942 HWTEST_F(WindowManagerServiceTest, HasPrivateWindow02, Function | SmallTest | Level2)
943 {
944     DisplayId displayId = 1;
945     bool hasPrivateWindow = false;
946     ASSERT_TRUE(windowInfoQueriedListener != nullptr);
947     windowInfoQueriedListener->HasPrivateWindow(displayId, hasPrivateWindow);
948 }
949 
950 /**
951  * @tc.name: SetMaximizeMode
952  * @tc.desc: SetMaximizeMode test
953  * @tc.type: FUNC
954  */
955 HWTEST_F(WindowManagerServiceTest, SetMaximizeMode, Function | SmallTest | Level2)
956 {
957     MaximizeMode maximizeMode = MaximizeMode::MODE_AVOID_SYSTEM_BAR;
958     ASSERT_TRUE(wms != nullptr);
959     wms->SetMaximizeMode(maximizeMode);
960 }
961 
962 /**
963  * @tc.name: GetMaximizeMode
964  * @tc.desc: GetMaximizeMode test
965  * @tc.type: FUNC
966  */
967 HWTEST_F(WindowManagerServiceTest, GetMaximizeMode, Function | SmallTest | Level2)
968 {
969     ASSERT_TRUE(wms != nullptr);
970     ASSERT_EQ(MaximizeMode::MODE_RECOVER, wms->GetMaximizeMode());
971 }
972 
973 /**
974  * @tc.name: GetFocusWindowInfo
975  * @tc.desc: GetFocusWindowInfo test
976  * @tc.type: FUNC
977  */
978 HWTEST_F(WindowManagerServiceTest, GetFocusWindowInfo, Function | SmallTest | Level2)
979 {
980     FocusChangeInfo focusInfo;
981     ASSERT_TRUE(wms != nullptr);
982     wms->GetFocusWindowInfo(focusInfo);
983 }
984 
985 /**
986  * @tc.name: PostAsyncTask
987  * @tc.desc: PostAsyncTask test
988  * @tc.type: FUNC
989  */
990 HWTEST_F(WindowManagerServiceTest, PostAsyncTask, Function | SmallTest | Level2)
991 {
992     Task task;
993     std::shared_ptr<AppExecFwk::EventRunner> runner = AppExecFwk::EventRunner::Create("Test");
994     wms->handler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
995     ASSERT_TRUE(wms != nullptr);
996     wms->PostAsyncTask(task);
997     wms->PostVoidSyncTask(task);
998 }
999 
1000 /**
1001  * @tc.name: OnAddSystemAbility02
1002  * @tc.desc: OnAddSystemAbility02 test
1003  * @tc.type: FUNC
1004  */
1005 HWTEST_F(WindowManagerServiceTest, OnAddSystemAbility02, Function | SmallTest | Level2)
1006 {
1007     std::string str = "OnAddSystemAbility02";
1008     wms->OnAddSystemAbility(10, str);
1009     ASSERT_EQ(nullptr, wms->windowCommonEvent_->subscriber_);
1010     wms->OnAddSystemAbility(180, str);
1011     ASSERT_EQ(nullptr, wms->windowCommonEvent_->subscriber_);
1012     wms->OnAddSystemAbility(3299, str);
1013     ASSERT_NE(nullptr, wms->windowCommonEvent_->subscriber_);
1014 }
1015 
1016 /**
1017  * @tc.name: GetFocusWindow
1018  * @tc.desc: GetFocusWindow test
1019  * @tc.type: FUNC
1020  */
1021 HWTEST_F(WindowManagerServiceTest, GetFocusWindow, Function | SmallTest | Level2)
1022 {
1023     sptr<IRemoteObject> abilityToken = new IRemoteObjectMocker();
1024     ASSERT_TRUE(wmsHandler_ != nullptr);
1025     wmsHandler_->GetFocusWindow(abilityToken);
1026 }
1027 
1028 /**
1029  * @tc.name: MoveMissionsToBackground02
1030  * @tc.desc: MoveMissionsToBackground02 test
1031  * @tc.type: FUNC
1032  */
1033 HWTEST_F(WindowManagerServiceTest, MoveMissionsToBackground02, Function | SmallTest | Level2)
1034 {
1035     std::vector<int32_t> moveRs;
1036     int32_t rs = wmsHandler_->MoveMissionsToBackground({}, moveRs);
1037     ASSERT_EQ(0, rs);
1038 }
1039 
1040 /**
1041  * @tc.name: ConfigAppWindowCornerRadius
1042  * @tc.desc: ConfigAppWindowCornerRadius test
1043  * @tc.type: FUNC
1044  */
1045 HWTEST_F(WindowManagerServiceTest, ConfigAppWindowCornerRadius, Function | SmallTest | Level2)
1046 {
1047     const auto& config = WindowManagerConfig::GetConfig();
1048     WindowManagerConfig::ConfigItem item = config["decor"];
1049     float out = 1.0;
1050     ASSERT_TRUE(wms != nullptr);
1051     bool res = wms->ConfigAppWindowCornerRadius(item, out);
1052     ASSERT_EQ(res, false);
1053 }
1054 
1055 /**
1056  * @tc.name: GetFocusWindowInfo01
1057  * @tc.desc: GetFocusWindowInfo01 test
1058  * @tc.type: FUNC
1059  */
1060 HWTEST_F(WindowManagerServiceTest, GetFocusWindowInfo01, Function | SmallTest | Level2)
1061 {
1062     sptr<IRemoteObject> abilityToken = new IRemoteObjectMocker();
1063     ASSERT_TRUE(wms != nullptr);
1064     wms->GetFocusWindowInfo(abilityToken);
1065 }
1066 
1067 /**
1068  * @tc.name: OnStop
1069  * @tc.desc: OnStop test
1070  * @tc.type: FUNC
1071  */
1072 HWTEST_F(WindowManagerServiceTest, OnStop, Function | SmallTest | Level2)
1073 {
1074     ASSERT_TRUE(wms != nullptr);
1075     wms->OnStop();
1076 }
1077 
1078 /**
1079  * @tc.name: CheckSystemWindowPermission
1080  * @tc.desc: CheckSystemWindowPermission test
1081  * @tc.type: FUNC
1082  */
1083 HWTEST_F(WindowManagerServiceTest, CheckSystemWindowPermission, Function | SmallTest | Level2)
1084 {
1085     sptr<WindowProperty> property = new WindowProperty();
1086     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1087     ASSERT_TRUE(wms != nullptr);
1088     bool res = wms->CheckSystemWindowPermission(property);
1089     ASSERT_EQ(res, true);
1090     property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
1091     res = wms->CheckSystemWindowPermission(property);
1092     ASSERT_EQ(res, true);
1093     property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
1094     res = wms->CheckSystemWindowPermission(property);
1095     ASSERT_EQ(res, true);
1096 }
1097 
1098 /**
1099  * @tc.name: CreateWindow02
1100  * @tc.desc: CreateWindow02 test
1101  * @tc.type: FUNC
1102  */
1103 HWTEST_F(WindowManagerServiceTest, CreateWindow02, Function | SmallTest | Level2)
1104 {
1105     sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker();
1106     sptr<IWindow> iWindow = iface_cast<IWindow>(iRemoteObjectMocker);
1107     uint32_t id = 2;
1108     RSSurfaceNodeConfig config;
1109     config.SurfaceNodeName = "webTestSurfaceName";
1110     auto surfaceNode = RSSurfaceNode::Create(config, false);
1111     sptr<WindowProperty> property = new WindowProperty();
1112     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1113     ASSERT_EQ(WMError::WM_OK, wms->CreateWindow(iWindow, property, surfaceNode, id, nullptr));
1114     wms->DestroyWindow(id, true);
1115     property->SetWindowType(WindowType::APP_WINDOW_BASE);
1116     ASSERT_EQ(WMError::WM_OK, wms->CreateWindow(iWindow, property, surfaceNode, id, nullptr));
1117     wms->DestroyWindow(id, true);
1118 }
1119 
1120 /**
1121  * @tc.name: AddWindow02
1122  * @tc.desc: AddWindow02 test
1123  * @tc.type: FUNC
1124  */
1125 HWTEST_F(WindowManagerServiceTest, AddWindow02, Function | SmallTest | Level2)
1126 {
1127     sptr<WindowProperty> property = new WindowProperty();
1128     property->SetWindowType(WindowType::WINDOW_TYPE_WALLPAPER);
1129     ASSERT_EQ(WMError::WM_OK, wms->AddWindow(property));
1130     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1131 }
1132 
1133 /**
1134  * @tc.name: RemoveWindow
1135  * @tc.desc: RemoveWindow test
1136  * @tc.type: FUNC
1137  */
1138 HWTEST_F(WindowManagerServiceTest, RemoveWindow, Function | SmallTest | Level2)
1139 {
1140     sptr<WindowNode> appNode = new WindowNode();
1141     IWindowMocker* token = new IWindowMocker;
1142     appNode->SetWindowToken(token);
1143     bool isFromInnerkits = false;
1144     wms->windowController_->windowRoot_->windowNodeMap_[appNode->GetWindowId()] = appNode;
1145     WMError res = wms->RemoveWindow(appNode->GetWindowId(), isFromInnerkits);
1146     ASSERT_EQ(res, WMError::WM_ERROR_INVALID_OPERATION);
1147     res = wms->RemoveWindow(appNode->GetWindowId(), isFromInnerkits);
1148     ASSERT_EQ(res, WMError::WM_ERROR_INVALID_OPERATION);
1149 }
1150 
1151 /**
1152  * @tc.name: DestroyWindow
1153  * @tc.desc: DestroyWindow test
1154  * @tc.type: FUNC
1155  */
1156 HWTEST_F(WindowManagerServiceTest, DestroyWindow, Function | SmallTest | Level2)
1157 {
1158     sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker();
1159     sptr<IWindow> iWindow = iface_cast<IWindow>(iRemoteObjectMocker);
1160     sptr<WindowNode> appNode = new WindowNode();
1161     RSSurfaceNodeConfig config;
1162     config.SurfaceNodeName = "webTestSurfaceName";
1163     auto surfaceNode = RSSurfaceNode::Create(config, false);
1164     sptr<WindowProperty> property = new WindowProperty();
1165     property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1166     uint32_t id = appNode->GetWindowId();
1167     ASSERT_EQ(WMError::WM_OK, wms->CreateWindow(iWindow, property, surfaceNode, id, nullptr));
1168     IWindowMocker* token = new IWindowMocker;
1169     appNode->SetWindowToken(token);
1170     bool isFromInnerkits = true;
1171     wms->windowController_->windowRoot_->windowNodeMap_[appNode->GetWindowId()] = appNode;
1172     WMError res = wms->RemoveWindow(appNode->GetWindowId(), isFromInnerkits);
1173     ASSERT_EQ(res, WMError::WM_OK);
1174     res = wms->DestroyWindow(appNode->GetWindowId(), true);
1175     ASSERT_EQ(res, WMError::WM_OK);
1176 }
1177 
1178 /**
1179  * @tc.name: OnScreenshot01
1180  * @tc.desc: OnScreenshot01 test
1181  * @tc.type: FUNC
1182  */
1183 HWTEST_F(WindowManagerServiceTest, OnScreenshot01, Function | SmallTest | Level2)
1184 {
1185     DisplayId displayId = 1;
1186     ASSERT_TRUE(listener != nullptr);
1187     listener->OnScreenshot(displayId);
1188 }
1189 
1190 /**
1191  * @tc.name: NotifyServerReadyToMoveOrDrag02
1192  * @tc.desc: NotifyServerReadyToMoveOrDrag02 test
1193  * @tc.type: FUNC
1194  */
1195 HWTEST_F(WindowManagerServiceTest, NotifyServerReadyToMoveOrDrag02, Function | SmallTest | Level2)
1196 {
1197     sptr<WindowNode> appNode = new WindowNode();
1198     IWindowMocker* token = new IWindowMocker;
1199     appNode->SetWindowToken(token);
1200     wms->windowController_->windowRoot_->windowNodeMap_[appNode->GetWindowId()] = appNode;
1201     sptr<WindowProperty> property = new WindowProperty();
1202     sptr<MoveDragProperty> moveDragProperty = new MoveDragProperty();
1203     ASSERT_TRUE(wms != nullptr);
1204     wms->NotifyServerReadyToMoveOrDrag(appNode->GetWindowId(), property, moveDragProperty);
1205 }
1206 
1207 /**
1208  * @tc.name: ProcessPointUp
1209  * @tc.desc: ProcessPointUp test
1210  * @tc.type: FUNC
1211  */
1212 HWTEST_F(WindowManagerServiceTest, ProcessPointUp, Function | SmallTest | Level2)
1213 {
1214     uint32_t windowId = 1;
1215     ASSERT_TRUE(wms != nullptr);
1216     wms->ProcessPointUp(windowId);
1217 }
1218 }
1219 }
1220 }
1221