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 /**
106 * @tc.name: WindowVisibilityChangeCallback
107 * @tc.desc: WindowVisibilityChangeCallback test
108 * @tc.type: FUNC
109 */
110 HWTEST_F(WindowManagerServiceTest, WindowVisibilityChangeCallback01, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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, Function | SmallTest | Level2)
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: GetAccessibilityWindowInfo
789 * @tc.desc: GetAccessibilityWindowInfo test
790 * @tc.type: FUNC
791 */
792 HWTEST_F(WindowManagerServiceTest, GetAccessibilityWindowInfo, Function | SmallTest | Level2)
793 {
794 std::vector<sptr<AccessibilityWindowInfo>> infos;
795 WMError res = wms->GetAccessibilityWindowInfo(infos);
796 ASSERT_EQ(WMError::WM_OK, res);
797 }
798
799 /**
800 * @tc.name: GetUnreliableWindowInfo
801 * @tc.desc: GetUnreliableWindowInfo test
802 * @tc.type: FUNC
803 */
804 HWTEST_F(WindowManagerServiceTest, GetUnreliableWindowInfo, Function | SmallTest | Level2)
805 {
806 std::vector<sptr<UnreliableWindowInfo>> infos;
807 int32_t windowId = 0;
808 WMError res = wms->GetUnreliableWindowInfo(windowId, infos);
809 ASSERT_EQ(WMError::WM_OK, res);
810 }
811
812 /**
813 * @tc.name: GetVisibilityWindowInfo
814 * @tc.desc: GetVisibilityWindowInfo test
815 * @tc.type: FUNC
816 */
817 HWTEST_F(WindowManagerServiceTest, GetVisibilityWindowInfo, Function | SmallTest | Level2)
818 {
819 std::vector<sptr<WindowVisibilityInfo>> infos;
820 WMError res = wms->GetVisibilityWindowInfo(infos);
821 ASSERT_EQ(WMError::WM_OK, res);
822 }
823
824 /**
825 * @tc.name: RaiseToAppTop
826 * @tc.desc: RaiseToAppTop test
827 * @tc.type: FUNC
828 */
829 HWTEST_F(WindowManagerServiceTest, RaiseToAppTop, Function | SmallTest | Level2)
830 {
831 uint32_t windowId = 1;
832 WMError res = wms->RaiseToAppTop(windowId);
833 if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
834 ASSERT_EQ(WMError::WM_OK, res);
835 } else {
836 ASSERT_NE(WMError::WM_DO_NOTHING, res);
837 }
838 }
839
840 /**
841 * @tc.name: GetSnapshot
842 * @tc.desc: GetSnapshot test
843 * @tc.type: FUNC
844 */
845 HWTEST_F(WindowManagerServiceTest, GetSnapshot, Function | SmallTest | Level2)
846 {
847 uint32_t windowId = 1;
848 ASSERT_EQ(nullptr, wms->GetSnapshot(windowId));
849 }
850
851 /**
852 * @tc.name: MinimizeWindowsByLauncher
853 * @tc.desc: MinimizeWindowsByLauncher test
854 * @tc.type: FUNC
855 */
856 HWTEST_F(WindowManagerServiceTest, MinimizeWindowsByLauncher, Function | SmallTest | Level2)
857 {
858 std::vector<uint32_t> windowIds;
859 bool isAnimated = false;
860 sptr<RSIWindowAnimationFinishedCallback> finishCallback;
861 ASSERT_TRUE(wms != nullptr);
862 wms->MinimizeWindowsByLauncher(windowIds, isAnimated, finishCallback);
863 }
864
865 /**
866 * @tc.name: SetAnchorAndScale
867 * @tc.desc: SetAnchorAndScale test
868 * @tc.type: FUNC
869 */
870 HWTEST_F(WindowManagerServiceTest, SetAnchorAndScale, Function | SmallTest | Level2)
871 {
872 int32_t x = 1;
873 int32_t y = 2;
874 float scale = 0.1;
875 ASSERT_TRUE(wms != nullptr);
876 wms->SetAnchorAndScale(x, y, scale);
877 }
878
879 /**
880 * @tc.name: SetAnchorOffset
881 * @tc.desc: SetAnchorOffset test
882 * @tc.type: FUNC
883 */
884 HWTEST_F(WindowManagerServiceTest, SetAnchorOffset, Function | SmallTest | Level2)
885 {
886 int32_t deltaX = 1;
887 int32_t deltaY = 2;
888 ASSERT_TRUE(wms != nullptr);
889 wms->SetAnchorOffset(deltaX, deltaY);
890 }
891
892 /**
893 * @tc.name: OffWindowZoom
894 * @tc.desc: OffWindowZoom test
895 * @tc.type: FUNC
896 */
897 HWTEST_F(WindowManagerServiceTest, OffWindowZoom, Function | SmallTest | Level2)
898 {
899 ASSERT_TRUE(wms != nullptr);
900 wms->OffWindowZoom();
901 }
902
903 /**
904 * @tc.name: UpdateRsTree
905 * @tc.desc: UpdateRsTree test
906 * @tc.type: FUNC
907 */
908 HWTEST_F(WindowManagerServiceTest, UpdateRsTree, Function | SmallTest | Level2)
909 {
910 uint32_t windowId = 1;
911 bool isAdd = false;
912 ASSERT_TRUE(wms != nullptr);
913 wms->UpdateRsTree(windowId, isAdd);
914 }
915
916 /**
917 * @tc.name: OnScreenshot
918 * @tc.desc: OnScreenshot test
919 * @tc.type: FUNC
920 */
921 HWTEST_F(WindowManagerServiceTest, OnScreenshot, Function | SmallTest | Level2)
922 {
923 DisplayId displayId = 1;
924 ASSERT_TRUE(wms != nullptr);
925 wms->OnScreenshot(displayId);
926 }
927
928 /**
929 * @tc.name: HasPrivateWindow01
930 * @tc.desc: HasPrivateWindow01 test
931 * @tc.type: FUNC
932 */
933 HWTEST_F(WindowManagerServiceTest, HasPrivateWindow01, Function | SmallTest | Level2)
934 {
935 DisplayId displayId = 1;
936 bool hasPrivateWindow = false;
937 ASSERT_TRUE(wms != nullptr);
938 wms->HasPrivateWindow(displayId, hasPrivateWindow);
939 }
940
941 /**
942 * @tc.name: SetGestureNavigationEnabled
943 * @tc.desc: SetGestureNavigationEnabled test
944 * @tc.type: FUNC
945 */
946 HWTEST_F(WindowManagerServiceTest, SetGestureNavigationEnabled, Function | SmallTest | Level2)
947 {
948 bool enable = false;
949 ASSERT_TRUE(wms != nullptr);
950 WMError res = wms->SetGestureNavigationEnabled(enable);
951 ASSERT_EQ(WMError::WM_OK, res);
952 }
953
954 /**
955 * @tc.name: HasPrivateWindow02
956 * @tc.desc: HasPrivateWindow02 test
957 * @tc.type: FUNC
958 */
959 HWTEST_F(WindowManagerServiceTest, HasPrivateWindow02, Function | SmallTest | Level2)
960 {
961 DisplayId displayId = 1;
962 bool hasPrivateWindow = false;
963 ASSERT_TRUE(windowInfoQueriedListener != nullptr);
964 windowInfoQueriedListener->HasPrivateWindow(displayId, hasPrivateWindow);
965 }
966
967 /**
968 * @tc.name: SetMaximizeMode
969 * @tc.desc: SetMaximizeMode test
970 * @tc.type: FUNC
971 */
972 HWTEST_F(WindowManagerServiceTest, SetMaximizeMode, Function | SmallTest | Level2)
973 {
974 MaximizeMode maximizeMode = MaximizeMode::MODE_AVOID_SYSTEM_BAR;
975 ASSERT_TRUE(wms != nullptr);
976 wms->SetMaximizeMode(maximizeMode);
977 }
978
979 /**
980 * @tc.name: GetMaximizeMode
981 * @tc.desc: GetMaximizeMode test
982 * @tc.type: FUNC
983 */
984 HWTEST_F(WindowManagerServiceTest, GetMaximizeMode, Function | SmallTest | Level2)
985 {
986 ASSERT_TRUE(wms != nullptr);
987 ASSERT_EQ(MaximizeMode::MODE_RECOVER, wms->GetMaximizeMode());
988 }
989
990 /**
991 * @tc.name: GetFocusWindowInfo
992 * @tc.desc: GetFocusWindowInfo test
993 * @tc.type: FUNC
994 */
995 HWTEST_F(WindowManagerServiceTest, GetFocusWindowInfo, Function | SmallTest | Level2)
996 {
997 FocusChangeInfo focusInfo;
998 ASSERT_TRUE(wms != nullptr);
999 wms->GetFocusWindowInfo(focusInfo);
1000 }
1001
1002 /**
1003 * @tc.name: PostAsyncTask
1004 * @tc.desc: PostAsyncTask test
1005 * @tc.type: FUNC
1006 */
1007 HWTEST_F(WindowManagerServiceTest, PostAsyncTask, Function | SmallTest | Level2)
1008 {
1009 Task task;
1010 std::shared_ptr<AppExecFwk::EventRunner> runner = AppExecFwk::EventRunner::Create("Test");
1011 wms->handler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
1012 ASSERT_TRUE(wms != nullptr);
1013 wms->PostAsyncTask(task);
1014 wms->PostVoidSyncTask(task);
1015 }
1016
1017 /**
1018 * @tc.name: OnAddSystemAbility02
1019 * @tc.desc: OnAddSystemAbility02 test
1020 * @tc.type: FUNC
1021 */
1022 HWTEST_F(WindowManagerServiceTest, OnAddSystemAbility02, Function | SmallTest | Level2)
1023 {
1024 std::string str = "OnAddSystemAbility02";
1025 wms->OnAddSystemAbility(10, str);
1026 ASSERT_EQ(nullptr, wms->windowCommonEvent_->subscriber_);
1027 wms->OnAddSystemAbility(180, str);
1028 ASSERT_EQ(nullptr, wms->windowCommonEvent_->subscriber_);
1029 wms->OnAddSystemAbility(3299, str);
1030 ASSERT_NE(nullptr, wms->windowCommonEvent_->subscriber_);
1031 }
1032
1033 /**
1034 * @tc.name: GetFocusWindow
1035 * @tc.desc: GetFocusWindow test
1036 * @tc.type: FUNC
1037 */
1038 HWTEST_F(WindowManagerServiceTest, GetFocusWindow, Function | SmallTest | Level2)
1039 {
1040 sptr<IRemoteObject> abilityToken = new IRemoteObjectMocker();
1041 ASSERT_TRUE(wmsHandler_ != nullptr);
1042 wmsHandler_->GetFocusWindow(abilityToken);
1043 }
1044
1045 /**
1046 * @tc.name: MoveMissionsToBackground02
1047 * @tc.desc: MoveMissionsToBackground02 test
1048 * @tc.type: FUNC
1049 */
1050 HWTEST_F(WindowManagerServiceTest, MoveMissionsToBackground02, Function | SmallTest | Level2)
1051 {
1052 std::vector<int32_t> moveRs;
1053 int32_t rs = wmsHandler_->MoveMissionsToBackground({}, moveRs);
1054 ASSERT_EQ(0, rs);
1055 }
1056
1057 /**
1058 * @tc.name: ConfigAppWindowCornerRadius
1059 * @tc.desc: ConfigAppWindowCornerRadius test
1060 * @tc.type: FUNC
1061 */
1062 HWTEST_F(WindowManagerServiceTest, ConfigAppWindowCornerRadius, Function | SmallTest | Level2)
1063 {
1064 const auto& config = WindowManagerConfig::GetConfig();
1065 WindowManagerConfig::ConfigItem item = config["decor"];
1066 float out = 1.0;
1067 ASSERT_TRUE(wms != nullptr);
1068 bool res = wms->ConfigAppWindowCornerRadius(item, out);
1069 ASSERT_EQ(res, false);
1070 }
1071
1072 /**
1073 * @tc.name: GetFocusWindowInfo01
1074 * @tc.desc: GetFocusWindowInfo01 test
1075 * @tc.type: FUNC
1076 */
1077 HWTEST_F(WindowManagerServiceTest, GetFocusWindowInfo01, Function | SmallTest | Level2)
1078 {
1079 sptr<IRemoteObject> abilityToken = new IRemoteObjectMocker();
1080 ASSERT_TRUE(wms != nullptr);
1081 wms->GetFocusWindowInfo(abilityToken);
1082 }
1083
1084 /**
1085 * @tc.name: OnStop
1086 * @tc.desc: OnStop test
1087 * @tc.type: FUNC
1088 */
1089 HWTEST_F(WindowManagerServiceTest, OnStop, Function | SmallTest | Level2)
1090 {
1091 ASSERT_TRUE(wms != nullptr);
1092 wms->OnStop();
1093 }
1094
1095 /**
1096 * @tc.name: CheckSystemWindowPermission
1097 * @tc.desc: CheckSystemWindowPermission test
1098 * @tc.type: FUNC
1099 */
1100 HWTEST_F(WindowManagerServiceTest, CheckSystemWindowPermission, Function | SmallTest | Level2)
1101 {
1102 sptr<WindowProperty> property = new WindowProperty();
1103 property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1104 ASSERT_TRUE(wms != nullptr);
1105 bool res = wms->CheckSystemWindowPermission(property);
1106 ASSERT_EQ(res, true);
1107 property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
1108 res = wms->CheckSystemWindowPermission(property);
1109 ASSERT_EQ(res, true);
1110 property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
1111 res = wms->CheckSystemWindowPermission(property);
1112 ASSERT_EQ(res, true);
1113 }
1114
1115 /**
1116 * @tc.name: CreateWindow02
1117 * @tc.desc: CreateWindow02 test
1118 * @tc.type: FUNC
1119 */
1120 HWTEST_F(WindowManagerServiceTest, CreateWindow02, Function | SmallTest | Level2)
1121 {
1122 sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker();
1123 sptr<IWindow> iWindow = iface_cast<IWindow>(iRemoteObjectMocker);
1124 uint32_t id = 2;
1125 RSSurfaceNodeConfig config;
1126 config.SurfaceNodeName = "webTestSurfaceName";
1127 auto surfaceNode = RSSurfaceNode::Create(config, false);
1128 sptr<WindowProperty> property = new WindowProperty();
1129 property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1130 ASSERT_EQ(WMError::WM_OK, wms->CreateWindow(iWindow, property, surfaceNode, id, nullptr));
1131 wms->DestroyWindow(id, true);
1132 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1133 ASSERT_EQ(WMError::WM_OK, wms->CreateWindow(iWindow, property, surfaceNode, id, nullptr));
1134 wms->DestroyWindow(id, true);
1135 }
1136
1137 /**
1138 * @tc.name: AddWindow02
1139 * @tc.desc: AddWindow02 test
1140 * @tc.type: FUNC
1141 */
1142 HWTEST_F(WindowManagerServiceTest, AddWindow02, Function | SmallTest | Level2)
1143 {
1144 sptr<WindowProperty> property = new WindowProperty();
1145 property->SetWindowType(WindowType::WINDOW_TYPE_WALLPAPER);
1146 ASSERT_EQ(WMError::WM_OK, wms->AddWindow(property));
1147 property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1148 }
1149
1150 /**
1151 * @tc.name: RemoveWindow
1152 * @tc.desc: RemoveWindow test
1153 * @tc.type: FUNC
1154 */
1155 HWTEST_F(WindowManagerServiceTest, RemoveWindow, Function | SmallTest | Level2)
1156 {
1157 sptr<WindowNode> appNode = new WindowNode();
1158 IWindowMocker* token = new IWindowMocker;
1159 appNode->SetWindowToken(token);
1160 bool isFromInnerkits = false;
1161 wms->windowController_->windowRoot_->windowNodeMap_[appNode->GetWindowId()] = appNode;
1162 WMError res = wms->RemoveWindow(appNode->GetWindowId(), isFromInnerkits);
1163 ASSERT_EQ(res, WMError::WM_ERROR_INVALID_OPERATION);
1164 res = wms->RemoveWindow(appNode->GetWindowId(), isFromInnerkits);
1165 ASSERT_EQ(res, WMError::WM_ERROR_INVALID_OPERATION);
1166 }
1167
1168 /**
1169 * @tc.name: DestroyWindow
1170 * @tc.desc: DestroyWindow test
1171 * @tc.type: FUNC
1172 */
1173 HWTEST_F(WindowManagerServiceTest, DestroyWindow, Function | SmallTest | Level2)
1174 {
1175 sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker();
1176 sptr<IWindow> iWindow = iface_cast<IWindow>(iRemoteObjectMocker);
1177 sptr<WindowNode> appNode = new WindowNode();
1178 RSSurfaceNodeConfig config;
1179 config.SurfaceNodeName = "webTestSurfaceName";
1180 auto surfaceNode = RSSurfaceNode::Create(config, false);
1181 sptr<WindowProperty> property = new WindowProperty();
1182 property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1183 uint32_t id = appNode->GetWindowId();
1184 ASSERT_EQ(WMError::WM_OK, wms->CreateWindow(iWindow, property, surfaceNode, id, nullptr));
1185 IWindowMocker* token = new IWindowMocker;
1186 appNode->SetWindowToken(token);
1187 bool isFromInnerkits = true;
1188 wms->windowController_->windowRoot_->windowNodeMap_[appNode->GetWindowId()] = appNode;
1189 WMError res = wms->RemoveWindow(appNode->GetWindowId(), isFromInnerkits);
1190 ASSERT_EQ(res, WMError::WM_OK);
1191 res = wms->DestroyWindow(appNode->GetWindowId(), true);
1192 ASSERT_EQ(res, WMError::WM_OK);
1193 }
1194
1195 /**
1196 * @tc.name: OnScreenshot01
1197 * @tc.desc: OnScreenshot01 test
1198 * @tc.type: FUNC
1199 */
1200 HWTEST_F(WindowManagerServiceTest, OnScreenshot01, Function | SmallTest | Level2)
1201 {
1202 DisplayId displayId = 1;
1203 ASSERT_TRUE(listener != nullptr);
1204 listener->OnScreenshot(displayId);
1205 }
1206
1207 /**
1208 * @tc.name: NotifyServerReadyToMoveOrDrag02
1209 * @tc.desc: NotifyServerReadyToMoveOrDrag02 test
1210 * @tc.type: FUNC
1211 */
1212 HWTEST_F(WindowManagerServiceTest, NotifyServerReadyToMoveOrDrag02, Function | SmallTest | Level2)
1213 {
1214 sptr<WindowNode> appNode = new WindowNode();
1215 IWindowMocker* token = new IWindowMocker;
1216 appNode->SetWindowToken(token);
1217 wms->windowController_->windowRoot_->windowNodeMap_[appNode->GetWindowId()] = appNode;
1218 sptr<WindowProperty> property = new WindowProperty();
1219 sptr<MoveDragProperty> moveDragProperty = new MoveDragProperty();
1220 ASSERT_TRUE(wms != nullptr);
1221 wms->NotifyServerReadyToMoveOrDrag(appNode->GetWindowId(), property, moveDragProperty);
1222 }
1223
1224 /**
1225 * @tc.name: ProcessPointUp
1226 * @tc.desc: ProcessPointUp test
1227 * @tc.type: FUNC
1228 */
1229 HWTEST_F(WindowManagerServiceTest, ProcessPointUp, Function | SmallTest | Level2)
1230 {
1231 uint32_t windowId = 1;
1232 ASSERT_TRUE(wms != nullptr);
1233 wms->ProcessPointUp(windowId);
1234 }
1235 }
1236 }
1237 }
1238