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