1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <gtest/gtest.h>
17 #include <map>
18 #include "display_manager.h"
19 #include "iremote_object_mocker.h"
20 #include "mock_rs_iwindow_animation_controller.h"
21 #include "remote_animation.h"
22 #include "starting_window.h"
23 #include "window_controller.h"
24 #include "scene_board_judgement.h"
25
26 using namespace testing;
27 using namespace testing::ext;
28
29 namespace OHOS {
30 namespace Rosen {
31 class WindowControllerTest : public testing::Test {
32 public:
33 static void SetUpTestCase();
34 static void TearDownTestCase();
35 void SetUp() override;
36 void TearDown() override;
37
38 static sptr<WindowController> windowController_;
39 static sptr<WindowRoot> windowRoot_;
40 static sptr<InputWindowMonitor> inputWindowMonitor_;
41 static sptr<WindowNode> node_;
42 static sptr<WindowTransitionInfo> transitionInfo_;
43 };
44
45 sptr<WindowController> WindowControllerTest::windowController_ = nullptr;
46 sptr<WindowRoot> WindowControllerTest::windowRoot_ = nullptr;
47 sptr<InputWindowMonitor> WindowControllerTest::inputWindowMonitor_ = nullptr;
48 sptr<WindowNode> WindowControllerTest::node_ = nullptr;
49 sptr<WindowTransitionInfo> WindowControllerTest::transitionInfo_ = nullptr;
50
RootCallback(Event event,const sptr<IRemoteObject> & remoteObject)51 void RootCallback(Event event, const sptr<IRemoteObject>& remoteObject)
52 {
53 return;
54 }
55
SetUpTestCase()56 void WindowControllerTest::SetUpTestCase()
57 {
58 windowRoot_ = new WindowRoot(RootCallback);
59 windowRoot_->displayIdMap_[0].push_back(0);
60 inputWindowMonitor_ = new InputWindowMonitor(windowRoot_);
61 windowController_ = new WindowController(windowRoot_, inputWindowMonitor_);
62 transitionInfo_ = new WindowTransitionInfo();
63 transitionInfo_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
64 node_ = StartingWindow::CreateWindowNode(transitionInfo_, 101); // 101 is windowId
65 node_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
66 }
67
TearDownTestCase()68 void WindowControllerTest::TearDownTestCase()
69 {
70 }
71
SetUp()72 void WindowControllerTest::SetUp()
73 {
74 }
75
TearDown()76 void WindowControllerTest::TearDown()
77 {
78 }
79
80 namespace {
81 /**
82 * @tc.name: GetSnapshot
83 * @tc.desc: test GetSnapshot
84 * @tc.type: FUNC
85 */
86 HWTEST_F(WindowControllerTest, GetSnapshot, TestSize.Level1)
87 {
88 int windowId = INVALID_WINDOW_ID;
89 ASSERT_EQ(nullptr, windowController_->GetSnapshot(windowId));
90 }
91
92 /**
93 * @tc.name: StartingWindow
94 * @tc.desc: Window controller starting window
95 * @tc.type: FUNC
96 */
97 HWTEST_F(WindowControllerTest, StartingWindow, TestSize.Level1)
98 {
99 windowRoot_->windowNodeMap_.clear();
100 windowController_->StartingWindow(nullptr, nullptr, 0, false);
101 ASSERT_EQ(0, windowRoot_->windowNodeMap_.size());
102
103 transitionInfo_->SetWindowMode(WindowMode::WINDOW_MODE_UNDEFINED);
104 windowController_->StartingWindow(transitionInfo_, nullptr, 0, false);
105 ASSERT_EQ(0, windowRoot_->windowNodeMap_.size());
106
107 sptr<IRemoteObject> abilityTokenMocker = new IRemoteObjectMocker();
108 transitionInfo_->SetAbilityToken(abilityTokenMocker);
109 windowController_->StartingWindow(transitionInfo_, nullptr, 0, false);
110 windowController_->StartingWindow(transitionInfo_, nullptr, 0, true);
111 ASSERT_EQ(1, windowRoot_->windowNodeMap_.size());
112
113 windowRoot_->windowNodeMap_.clear();
114 sptr<IRemoteObject> iRemoteObjectMocker = new IRemoteObjectMocker();
115 RemoteAnimation::windowAnimationController_ = iface_cast<RSIWindowAnimationController>(iRemoteObjectMocker);
116 windowController_->StartingWindow(transitionInfo_, nullptr, 0, true);
117 ASSERT_EQ(1, windowRoot_->windowNodeMap_.size());
118
119 windowRoot_->windowNodeMap_.clear();
120 windowRoot_->windowNodeMap_.insert(std::make_pair(node_->GetWindowId(), node_));
121 node_->abilityToken_ = abilityTokenMocker;
122 node_->stateMachine_.currState_ = WindowNodeState::SHOW_ANIMATION_PLAYING;
123 windowController_->StartingWindow(transitionInfo_, nullptr, 0, false);
124 ASSERT_EQ(1, windowRoot_->windowNodeMap_.size());
125
126 node_->stateMachine_.currState_ = WindowNodeState::STARTING_CREATED;
127 windowController_->StartingWindow(transitionInfo_, nullptr, 0, false);
128 transitionInfo_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
129 windowController_->StartingWindow(transitionInfo_, nullptr, 0, false);
130 transitionInfo_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
131 node_->property_->windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL;
132 windowController_->StartingWindow(transitionInfo_, nullptr, 0, false);
133 ASSERT_EQ(1, windowRoot_->windowNodeMap_.size());
134
135 // Cancel starting window
136 windowController_->CancelStartingWindow(nullptr);
137 windowController_->CancelStartingWindow(abilityTokenMocker);
138
139 node_->startingWindowShown_ = true;
140 windowController_->CancelStartingWindow(abilityTokenMocker);
141 ASSERT_EQ(0, windowRoot_->windowNodeMap_.size());
142
143 windowRoot_->windowNodeMap_.clear();
144 RemoteAnimation::windowAnimationController_ = nullptr;
145 }
146
147 /**
148 * @tc.name: NotifyWindowTransition
149 * @tc.desc: Window controller notify window transtition
150 * @tc.type: FUNC
151 */
152 HWTEST_F(WindowControllerTest, NotifyWindowTransition, Function | SmallTest | Level3)
153 {
154 sptr<WindowTransitionInfo> srcInfo = nullptr;
155 sptr<WindowTransitionInfo> dstInfo = nullptr;
156 ASSERT_EQ(WMError::WM_ERROR_NO_REMOTE_ANIMATION, windowController_->NotifyWindowTransition(srcInfo, dstInfo));
157
158 srcInfo = new WindowTransitionInfo();
159 sptr<IRemoteObject> srcAbilityTokenMocker = new IRemoteObjectMocker();
160 srcInfo->SetAbilityToken(srcAbilityTokenMocker);
161 sptr<WindowNode> srcNode = StartingWindow::CreateWindowNode(srcInfo, 102); // 102 is windowId
162 srcNode->property_->windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL;
163
164 dstInfo = new WindowTransitionInfo();
165 sptr<IRemoteObject> dstAbilityTokenMocker = new IRemoteObjectMocker();
166 dstInfo->SetAbilityToken(dstAbilityTokenMocker);
167 sptr<WindowNode> dstNode = StartingWindow::CreateWindowNode(dstInfo, 103); // 103 is windowId
168 dstNode->property_->windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL;
169
170 windowRoot_->windowNodeMap_.clear();
171 windowRoot_->windowNodeMap_.insert(std::make_pair(srcNode->GetWindowId(), srcNode));
172 windowRoot_->windowNodeMap_.insert(std::make_pair(dstNode->GetWindowId(), dstNode));
173
174 sptr<DisplayInfo> displayInfo = new DisplayInfo();
175 sptr<WindowNodeContainer> container = new WindowNodeContainer(displayInfo, 0);
176 windowRoot_->windowNodeContainerMap_.insert(std::make_pair(0, container));
177
178 sptr<MockRSIWindowAnimationController> mock = new MockRSIWindowAnimationController();
179 RemoteAnimation::windowAnimationController_ = mock;
180 RemoteAnimation::windowRoot_ = windowRoot_;
181 RemoteAnimation::animationFirst_ = true;
182
183 srcInfo->SetTransitionReason(TransitionReason::MINIMIZE);
184 srcNode->stateMachine_.currState_ = WindowNodeState::HIDDEN;
185 ASSERT_EQ(WMError::WM_ERROR_NO_REMOTE_ANIMATION, windowController_->NotifyWindowTransition(srcInfo, dstInfo));
186
187 srcInfo->SetTransitionReason(TransitionReason::MINIMIZE);
188 srcNode->stateMachine_.currState_ = WindowNodeState::STARTING_CREATED;
189 EXPECT_CALL(*mock, OnMinimizeWindow(_, _)).Times(1);
190 ASSERT_EQ(WMError::WM_OK, windowController_->NotifyWindowTransition(srcInfo, dstInfo));
191
192 srcInfo->SetTransitionReason(TransitionReason::CLOSE);
193 srcNode->stateMachine_.currState_ = WindowNodeState::STARTING_CREATED;
194 EXPECT_CALL(*mock, OnCloseWindow(_, _)).Times(1);
195 ASSERT_EQ(WMError::WM_OK, windowController_->NotifyWindowTransition(srcInfo, dstInfo));
196
197 srcInfo->SetTransitionReason(TransitionReason::BACK_TRANSITION);
198 srcNode->stateMachine_.currState_ = WindowNodeState::STARTING_CREATED;
199 EXPECT_CALL(*mock, OnAppBackTransition(_, _, _)).Times(1);
200 ASSERT_EQ(WMError::WM_OK, windowController_->NotifyWindowTransition(srcInfo, dstInfo));
201
202 srcInfo->SetTransitionReason(TransitionReason::ABILITY_TRANSITION);
203 dstNode->stateMachine_.currState_ = WindowNodeState::STARTING_CREATED;
204 dstNode->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
205 dstNode->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
206 EXPECT_CALL(*mock, OnStartApp(_, _, _)).Times(1);
207 ASSERT_EQ(WMError::WM_OK, windowController_->NotifyWindowTransition(srcInfo, dstInfo));
208
209 dstNode->stateMachine_.currState_ = WindowNodeState::STARTING_CREATED;
210 dstNode->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
211 EXPECT_CALL(*mock, OnStartApp(_, _, _)).Times(1);
212 ASSERT_EQ(WMError::WM_OK, windowController_->NotifyWindowTransition(srcInfo, dstInfo));
213
214 windowRoot_->windowNodeContainerMap_.clear();
215 RemoteAnimation::windowAnimationController_ = nullptr;
216 }
217
218 /**
219 * @tc.name: FocusWindow
220 * @tc.desc: Window controller focus window
221 * @tc.type: FUNC
222 */
223 HWTEST_F(WindowControllerTest, FocusWindow, TestSize.Level1)
224 {
225 sptr<IRemoteObject> abilityToken = nullptr;
226 windowController_->GetFocusWindowInfo(abilityToken);
227
228 sptr<DisplayInfo> displayInfo = new DisplayInfo();
229 sptr<WindowNodeContainer> container = new WindowNodeContainer(displayInfo, 0);
230 windowRoot_->windowNodeContainerMap_.insert(std::make_pair(0, container));
231
232 sptr<WindowNode> windowNode;
233 ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, windowController_->GetFocusWindowNode(0, windowNode));
234
235 windowRoot_->windowNodeMap_.clear();
236 windowRoot_->windowNodeMap_.insert(std::make_pair(node_->GetWindowId(), node_));
237 container->focusedWindow_ = node_->GetWindowId();
238 node_->currentVisibility_ = false;
239 ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, windowController_->GetFocusWindowNode(0, windowNode));
240
241 node_->currentVisibility_ = true;
242 ASSERT_EQ(WMError::WM_OK, windowController_->GetFocusWindowNode(0, windowNode));
243 windowRoot_->windowNodeContainerMap_.clear();
244 }
245
246 /**
247 * @tc.name: CreateWindow
248 * @tc.desc: Window controller create window
249 * @tc.type: FUNC
250 */
251 HWTEST_F(WindowControllerTest, CreateWindow, TestSize.Level1)
252 {
253 windowRoot_->windowNodeMap_.clear();
254 sptr<IWindow> window;
255 sptr<WindowProperty> property = new WindowProperty();
256 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
257
258 sptr<WindowProperty> property2 = new WindowProperty();
259 property2->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
260 sptr<WindowNode> windowNode = new WindowNode(property2);
261 windowRoot_->windowNodeMap_.insert(std::make_pair(1,windowNode));
262 sptr<WindowProperty> property3 = new WindowProperty();
263 property3->SetWindowType(WindowType::BELOW_APP_SYSTEM_WINDOW_BASE);
264 sptr<WindowNode> windowNode2 = new WindowNode(property3);
265 windowRoot_->windowNodeMap_.insert(std::make_pair(2,windowNode2));
266
267 uint32_t windowId;
268 property->SetParentId(INVALID_WINDOW_ID);
269 ASSERT_EQ(WMError::WM_ERROR_NULLPTR,
270 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
271 struct RSSurfaceNodeConfig surfaceNodeConfig;
272 surfaceNodeConfig.SurfaceNodeName = "SurfaceNode";
273 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
274 ASSERT_EQ(WMError::WM_OK, windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
275
276 property->SetParentId(1);
277 property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
278 ASSERT_EQ(WMError::WM_ERROR_INVALID_PARENT,
279 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
280
281 property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
282 ASSERT_EQ(WMError::WM_OK, windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
283
284 property->SetParentId(2);
285 property->SetWindowType(WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW);
286 ASSERT_EQ(WMError::WM_OK, windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
287 windowRoot_->windowNodeMap_.clear();
288
289 sptr<IRemoteObject> abilityTokenMocker = new IRemoteObjectMocker();
290 node_->abilityToken_ = abilityTokenMocker;
291
292 property->SetParentId(INVALID_WINDOW_ID);
293 property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
294 ASSERT_EQ(WMError::WM_OK,
295 windowController_->CreateWindow(window, property, surfaceNode, windowId, abilityTokenMocker, 0, 0));
296
297 property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
298 ASSERT_EQ(WMError::WM_ERROR_INVALID_PARENT,
299 windowController_->CreateWindow(window, property, surfaceNode, windowId, abilityTokenMocker, 0, 0));
300
301 property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
302 node_->startingWindowShown_ = false;
303 ASSERT_EQ(WMError::WM_OK,
304 windowController_->CreateWindow(window, property, surfaceNode, windowId, abilityTokenMocker, 0, 0));
305 windowRoot_->windowNodeMap_.clear();
306 }
307
308 /**
309 * @tc.name: NotifyAfterAddWindow
310 * @tc.desc: Window controller notify after add window
311 * @tc.type: FUNC
312 */
313 HWTEST_F(WindowControllerTest, NotifyAfterAddWindow, TestSize.Level1)
314 {
315 ASSERT_NE(nullptr, windowController_);
316 sptr<WindowNode> node0 = new WindowNode();
317 windowController_->NotifyAfterAddWindow(node0);
318 ASSERT_EQ(0, node0->children_.size());
319
320 sptr<WindowNode> node1 = new WindowNode();
321 node1->currentVisibility_ = false;
322 sptr<WindowNode> node2= new WindowNode();
323 node2->currentVisibility_ = true;
324
325 node0->children_.push_back(node1);
326 node0->children_.push_back(node2);
327 windowController_->NotifyAfterAddWindow(node0);
328 ASSERT_EQ(2, node0->children_.size());
329 ASSERT_EQ(nullptr, node0->children_[0]->abilityToken_);
330 }
331
332 /**
333 * @tc.name: AddWindowNode
334 * @tc.desc: Window controller add window node
335 * @tc.type: FUNC
336 */
337 HWTEST_F(WindowControllerTest, AddWindowNode, TestSize.Level1)
338 {
339 sptr<WindowProperty> property = new WindowProperty();
340 property->SetWindowId(0);
341 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowController_->AddWindowNode(property));
342
343 windowRoot_->windowNodeMap_.clear();
344 windowRoot_->windowNodeMap_.insert(std::make_pair(node_->GetWindowId(), node_));
345 property->SetWindowId(node_->GetWindowId());
346 node_->currentVisibility_ = true;
347 node_->startingWindowShown_ = false;
348 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, windowController_->AddWindowNode(property));
349
350 node_->currentVisibility_ = false;
351 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, windowController_->AddWindowNode(property));
352
353 Rect requestRect{0, 0, 100, 100};
354 property->SetRequestRect(requestRect);
355 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, windowController_->AddWindowNode(property));
356
357 node_->startingWindowShown_ = true;
358 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, windowController_->AddWindowNode(property));
359
360 windowRoot_->windowNodeMap_.clear();
361 }
362
363 /**
364 * @tc.name: InputCallingWindow
365 * @tc.desc: Window controller input calling window
366 * @tc.type: FUNC
367 */
368 HWTEST_F(WindowControllerTest, InputCallingWindow, TestSize.Level1)
369 {
370 windowController_->callingWindowId_ = 0;
371 windowRoot_->windowNodeMap_.clear();
372 sptr<WindowNode> node = new WindowNode();
373 node->property_->callingWindow_ = 0;
374 node->property_->displayId_ = DISPLAY_ID_INVALID;
375 windowController_->ResizeSoftInputCallingWindowIfNeed(node);
376 ASSERT_EQ(0, windowController_->callingWindowId_);
377
378 sptr<DisplayInfo> displayInfo = new DisplayInfo();
379 sptr<WindowNodeContainer> container = new WindowNodeContainer(displayInfo, 0);
380 windowRoot_->windowNodeContainerMap_.insert(std::make_pair(0, container));
381 node->property_->displayId_ = 0;
382 windowController_->ResizeSoftInputCallingWindowIfNeed(node);
383 ASSERT_EQ(0, windowController_->callingWindowId_);
384
385 windowRoot_->windowNodeMap_.insert(std::make_pair(node_->GetWindowId(), node_));
386 container->focusedWindow_ = node_->GetWindowId();
387 node_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
388 node_->currentVisibility_ = false;
389 windowController_->ResizeSoftInputCallingWindowIfNeed(node);
390 ASSERT_EQ(0, windowController_->callingWindowId_);
391
392 node_->currentVisibility_ = true;
393 node_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
394 windowController_->ResizeSoftInputCallingWindowIfNeed(node);
395
396 node_->currentVisibility_ = true;
397 node_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
398 windowController_->ResizeSoftInputCallingWindowIfNeed(node);
399 ASSERT_EQ(0, windowController_->callingWindowId_);
400
401 windowController_->callingWindowId_ = node_->GetWindowId();
402 windowController_->callingWindowRestoringRect_ = {0, 0, 0, 0};
403 windowController_->RestoreCallingWindowSizeIfNeed();
404 ASSERT_EQ(0, windowController_->callingWindowId_);
405
406 windowController_->callingWindowRestoringRect_ = {0, 0, 1, 1};
407 windowController_->callingWindowId_ = 0;
408 windowController_->RestoreCallingWindowSizeIfNeed();
409
410 windowController_->callingWindowId_ = node_->GetWindowId();
411 windowController_->RestoreCallingWindowSizeIfNeed();
412 ASSERT_EQ(0, windowController_->callingWindowId_);
413
414 windowController_->callingWindowId_ = node_->GetWindowId();
415 node_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
416 windowController_->RestoreCallingWindowSizeIfNeed();
417 ASSERT_EQ(0, windowController_->callingWindowId_);
418
419 windowRoot_->windowNodeMap_.clear();
420 windowRoot_->windowNodeContainerMap_.clear();
421 }
422
423 /**
424 * @tc.name: SetDefaultDisplayInfo
425 * @tc.desc: Window controller set default display info
426 * @tc.type: FUNC
427 */
428 HWTEST_F(WindowControllerTest, SetDefaultDisplayInfo, TestSize.Level1)
429 {
430 const int32_t displayWidth = 100;
431 const int32_t displayHeight = 200;
432 windowController_->defaultDisplayRect_ = { 0, 0, 0, 0 };
433
434 sptr<DisplayInfo> displayInfo = nullptr;
435 windowController_->SetDefaultDisplayInfo(0, displayInfo);
436 ASSERT_EQ(0, windowController_->defaultDisplayRect_.width_);
437 ASSERT_EQ(0, windowController_->defaultDisplayRect_.height_);
438
439 displayInfo = new DisplayInfo();
440 displayInfo->id_ = 1;
441 displayInfo->width_ = displayWidth;
442 displayInfo->height_ = displayHeight;
443
444 windowController_->SetDefaultDisplayInfo(0, displayInfo);
445 ASSERT_EQ(0, windowController_->defaultDisplayRect_.width_);
446 ASSERT_EQ(0, windowController_->defaultDisplayRect_.height_);
447
448 displayInfo->id_ = 0;
449 windowController_->SetDefaultDisplayInfo(0, displayInfo);
450 ASSERT_EQ(displayWidth, windowController_->defaultDisplayRect_.width_);
451 ASSERT_EQ(displayHeight, windowController_->defaultDisplayRect_.height_);
452 }
453
454 /**
455 * @tc.name: ProcessDisplayCompression
456 * @tc.desc: Window controller process display compression
457 * @tc.type: FUNC
458 */
459 HWTEST_F(WindowControllerTest, ProcessDisplayCompression, TestSize.Level1)
460 {
461 ASSERT_NE(nullptr, windowController_);
462 DisplayId defaultDisplayId = 0;
463 sptr<DisplayInfo> displayInfo = new DisplayInfo();
464 displayInfo->id_ = 1;
465 windowController_->ProcessDisplayCompression(defaultDisplayId, displayInfo);
466 ASSERT_EQ(nullptr, windowController_->maskingSurfaceNode_);
467
468 displayInfo->id_ = defaultDisplayId;
469 displayInfo->waterfallDisplayCompressionStatus_ = false;
470 windowController_->ProcessDisplayCompression(defaultDisplayId, displayInfo);
471 ASSERT_EQ(nullptr, windowController_->maskingSurfaceNode_);
472
473 displayInfo->waterfallDisplayCompressionStatus_ = true;
474 windowController_->ProcessDisplayCompression(defaultDisplayId, displayInfo);
475 ASSERT_NE(nullptr, windowController_->maskingSurfaceNode_);
476 }
477
478 /**
479 * @tc.name: StopBootAnimationIfNeed
480 * @tc.desc: Window controller stop boot animation if need
481 * @tc.type: FUNC
482 */
483 HWTEST_F(WindowControllerTest, StopBootAnimationIfNeed, TestSize.Level1)
484 {
485 ASSERT_NE(nullptr, windowController_);
486
487 sptr<WindowNode> node = nullptr;
488 windowController_->isBootAnimationStopped_ = true;
489 windowController_->StopBootAnimationIfNeed(node);
490 ASSERT_EQ(true, windowController_->isBootAnimationStopped_);
491
492 windowController_->isBootAnimationStopped_ = false;
493 windowController_->StopBootAnimationIfNeed(node);
494 ASSERT_EQ(false, windowController_->isBootAnimationStopped_);
495
496 node = new WindowNode();
497 node->SetDisplayId(DISPLAY_ID_INVALID + 1);
498 windowController_->StopBootAnimationIfNeed(node);
499 ASSERT_EQ(false, windowController_->isBootAnimationStopped_);
500
501 node->SetDisplayId(DISPLAY_ID_INVALID);
502 windowController_->StopBootAnimationIfNeed(node);
503 ASSERT_EQ(false, windowController_->isBootAnimationStopped_);
504 }
505
506 /**
507 * @tc.name: GetEmbedNodeId
508 * @tc.desc: Window controller get embed node id
509 * @tc.type: FUNC
510 */
511 HWTEST_F(WindowControllerTest, GetEmbedNodeId, TestSize.Level1)
512 {
513 std::vector<sptr<WindowNode>> windowNodes;
514 sptr<WindowNode> node0 = nullptr;
515 sptr<WindowNode> node1 = new WindowNode();
516 node1->property_->windowId_ = 1;
517 sptr<WindowNode> node2 = new WindowNode();
518 node2->property_->windowId_ = 2;
519 sptr<WindowNode> node3 = new WindowNode();
520 node3->property_->windowId_ = 3;
521
522 node1->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
523 ASSERT_EQ(0, windowController_->GetEmbedNodeId(windowNodes, node1));
524
525 node1->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_COMPONENT);
526 ASSERT_EQ(0, windowController_->GetEmbedNodeId(windowNodes, node1));
527
528 windowNodes.push_back(node0);
529 windowNodes.push_back(node2);
530 windowNodes.push_back(node1);
531 windowNodes.push_back(node2);
532 windowNodes.push_back(node3);
533
534 node1->SetWindowRect({50, 50, 50, 50});
535 node3->SetWindowRect({0, 0, 200, 200});
536 ASSERT_EQ(node3->GetWindowId(), windowController_->GetEmbedNodeId(windowNodes, node1));
537 }
538
539 /**
540 * @tc.name: BindDialogTarget
541 * @tc.desc: Window controller bind dialog target
542 * @tc.type: FUNC
543 */
544 HWTEST_F(WindowControllerTest, BindDialogTarget, TestSize.Level1)
545 {
546 windowRoot_->windowNodeMap_.clear();
547
548 uint32_t id = 0;
549 sptr<IRemoteObject> abilityTokenMocker = new IRemoteObjectMocker();
550 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowController_->BindDialogTarget(id, abilityTokenMocker));
551
552 windowRoot_->windowNodeMap_.insert(std::make_pair(node_->GetWindowId(), node_));
553 id = node_->GetWindowId();
554 ASSERT_EQ(WMError::WM_OK, windowController_->BindDialogTarget(id, abilityTokenMocker));
555 windowRoot_->windowNodeMap_.clear();
556 }
557
558 /**
559 * @tc.name: RaiseToAppTop
560 * @tc.desc: check app subwindow raise to top
561 * @tc.type: FUNC
562 */
563 HWTEST_F(WindowControllerTest, RaiseToAppTop, TestSize.Level1)
564 {
565 windowRoot_->windowNodeMap_.clear();
566
567 sptr<WindowNode> windowNode = new (std::nothrow)WindowNode();
568 windowNode->property_->windowId_ = 100;
569 windowNode->SetDisplayId(DISPLAY_ID_INVALID);
570
571 uint32_t windowId = windowNode->GetWindowId();
572 ASSERT_EQ(WMError::WM_DO_NOTHING, windowController_->RaiseToAppTop(windowId));
573
574 windowRoot_->windowNodeMap_.insert(std::make_pair(windowNode->GetWindowId(), windowNode));
575 ASSERT_EQ(WMError::WM_ERROR_INVALID_PARENT, windowController_->RaiseToAppTop(windowId));
576
577 sptr<WindowNode> parentWindow = new (std::nothrow)WindowNode();
578 parentWindow->property_->windowId_ = 90;
579 parentWindow->SetDisplayId(DISPLAY_ID_INVALID);
580 windowRoot_->windowNodeMap_.insert(std::make_pair(parentWindow->GetWindowId(), parentWindow));
581
582 windowNode->parent_ = parentWindow;
583 ASSERT_EQ(WMError::WM_DO_NOTHING, windowController_->RaiseToAppTop(windowId));
584
585 windowRoot_->windowNodeMap_.clear();
586 }
587
588 /**
589 * @tc.name: GetFocusWindowInfo
590 * @tc.desc: Window controller focus window
591 * @tc.type: FUNC
592 */
593 HWTEST_F(WindowControllerTest, GetFocusWindowInfo, TestSize.Level1)
594 {
595 sptr<DisplayInfo> displayInfo = new DisplayInfo();
596 sptr<WindowNodeContainer> container = new WindowNodeContainer(displayInfo, 0);
597 windowRoot_->windowNodeContainerMap_.insert(std::make_pair(0, container));
598
599 FocusChangeInfo focusInfo;
600 WMError res = windowController_->GetFocusWindowInfo(focusInfo);
601 windowRoot_->windowNodeContainerMap_.clear();
602 ASSERT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW);
603 }
604
605 /**
606 * @tc.name: CheckParentWindowValid
607 * @tc.desc: Window controller CheckParentWindowValid
608 * @tc.type: FUNC
609 */
610 HWTEST_F(WindowControllerTest, CreateWindow01, TestSize.Level1)
611 {
612 windowRoot_->windowNodeMap_.clear();
613 sptr<IWindow> window;
614 sptr<WindowProperty> property = new WindowProperty();
615 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
616
617 sptr<WindowProperty> property2 = new WindowProperty();
618 property2->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
619 sptr<WindowNode> windowNode = new WindowNode(property2);
620 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
621 sptr<WindowProperty> property3 = new WindowProperty();
622 property3->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
623 sptr<WindowNode> windowNode2 = new WindowNode(property3);
624 windowRoot_->windowNodeMap_.insert(std::make_pair(2, windowNode2));
625
626 uint32_t windowId;
627 property->SetParentId(1);
628 property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
629 struct RSSurfaceNodeConfig surfaceNodeConfig;
630 surfaceNodeConfig.SurfaceNodeName = "CheckParentWindowValid";
631 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
632 ASSERT_EQ(WMError::WM_OK,
633 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
634
635 property2->SetParentId(INVALID_WINDOW_ID);
636 ASSERT_EQ(WMError::WM_ERROR_INVALID_PARENT,
637 windowController_->CreateWindow(window, property2, surfaceNode, windowId, nullptr, 0, 0));
638
639 property3->SetParentId(1);
640 ASSERT_EQ(WMError::WM_ERROR_INVALID_PARENT,
641 windowController_->CreateWindow(window, property2, surfaceNode, windowId, nullptr, 0, 0));
642 }
643
644 /**
645 * @tc.name: CheckMultiDialogWindows
646 * @tc.desc: Window controller CheckParentWindowValid
647 * @tc.type: FUNC
648 */
649 HWTEST_F(WindowControllerTest, CreateWindow02, TestSize.Level1)
650 {
651 windowRoot_->windowNodeMap_.clear();
652 sptr<IWindow> window;
653 sptr<WindowProperty> property = new WindowProperty();
654 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
655
656 uint32_t windowId;
657 property->SetParentId(INVALID_WINDOW_ID);
658 property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
659 struct RSSurfaceNodeConfig surfaceNodeConfig;
660 surfaceNodeConfig.SurfaceNodeName = "CheckMultiDialogWindows";
661 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
662 sptr<IRemoteObject> abilityTokenMocker = new IRemoteObjectMocker();
663 node_->abilityToken_ = abilityTokenMocker;
664
665 ASSERT_EQ(WMError::WM_OK,
666 windowController_->CreateWindow(window, property, surfaceNode, windowId, abilityTokenMocker, 0, 0));
667 }
668
669 /**
670 * @tc.name: CheckMultiDialogWindows
671 * @tc.desc: Window controller CheckParentWindowValid
672 * @tc.type: FUNC
673 */
674 HWTEST_F(WindowControllerTest, CreateWindow03, TestSize.Level1)
675 {
676 windowRoot_->windowNodeMap_.clear();
677 sptr<IWindow> window;
678 sptr<WindowProperty> property = new WindowProperty();
679 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
680
681 uint32_t windowId;
682 property->SetParentId(INVALID_WINDOW_ID);
683 property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
684 struct RSSurfaceNodeConfig surfaceNodeConfig;
685 surfaceNodeConfig.SurfaceNodeName = "CheckMultiDialogWindows1";
686 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
687 sptr<IRemoteObject> abilityTokenMocker = new IRemoteObjectMocker();
688 node_->abilityToken_ = abilityTokenMocker;
689 node_->startingWindowShown_ = true;
690
691 ASSERT_EQ(WMError::WM_OK,
692 windowController_->CreateWindow(window, property, surfaceNode, windowId, abilityTokenMocker, 0, 0));
693 }
694
695 /**
696 * @tc.name: RemoveWindowNode
697 * @tc.desc: Window controller RemoveWindowNode
698 * @tc.type: FUNC
699 */
700 HWTEST_F(WindowControllerTest, RemoveWindowNode, TestSize.Level1)
701 {
702 windowRoot_->windowNodeMap_.clear();
703 sptr<IWindow> window;
704 sptr<WindowProperty> property = new WindowProperty();
705 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
706
707 uint32_t windowId;
708 property->SetParentId(INVALID_WINDOW_ID);
709 property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
710 struct RSSurfaceNodeConfig surfaceNodeConfig;
711 surfaceNodeConfig.SurfaceNodeName = "RemoveWindowNode";
712 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
713 ASSERT_EQ(WMError::WM_OK, windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
714
715 WMError res = windowController_->RemoveWindowNode(windowId, false);
716 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
717 }
718
719 /**
720 * @tc.name: RemoveWindowNode
721 * @tc.desc: Window controller RemoveWindowNode
722 * @tc.type: FUNC
723 */
724 HWTEST_F(WindowControllerTest, RemoveWindowNode1, TestSize.Level1)
725 {
726 windowRoot_->windowNodeMap_.clear();
727 sptr<IWindow> window;
728 sptr<WindowProperty> property = new WindowProperty();
729 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
730
731 uint32_t windowId;
732 property->SetParentId(INVALID_WINDOW_ID);
733 property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
734 struct RSSurfaceNodeConfig surfaceNodeConfig;
735 surfaceNodeConfig.SurfaceNodeName = "RemoveWindowNode1";
736 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
737 ASSERT_EQ(WMError::WM_OK, windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
738
739 WMError res = windowController_->RemoveWindowNode(windowId, true);
740 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
741 }
742
743 /**
744 * @tc.name: RemoveWindowNode
745 * @tc.desc: Window controller RemoveWindowNode
746 * @tc.type: FUNC
747 */
748 HWTEST_F(WindowControllerTest, RemoveWindowNode2, TestSize.Level1)
749 {
750 windowRoot_->windowNodeMap_.clear();
751 sptr<IWindow> window;
752 sptr<WindowProperty> property = new WindowProperty();
753 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
754
755 uint32_t windowId;
756 property->SetParentId(INVALID_WINDOW_ID);
757 property->SetWindowType(WindowType::WINDOW_TYPE_KEYGUARD);
758 struct RSSurfaceNodeConfig surfaceNodeConfig;
759 surfaceNodeConfig.SurfaceNodeName = "RemoveWindowNode2";
760 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
761 ASSERT_EQ(WMError::WM_OK, windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
762
763 WMError res = windowController_->RemoveWindowNode(windowId, true);
764 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
765 }
766
767 /**
768 * @tc.name: DestroyWindow
769 * @tc.desc: Window controller DestroyWindow true
770 * @tc.type: FUNC
771 */
772 HWTEST_F(WindowControllerTest, DestroyWindow, TestSize.Level1)
773 {
774 windowRoot_->windowNodeMap_.clear();
775 sptr<IWindow> window;
776 sptr<WindowProperty> property = new WindowProperty();
777 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
778
779 uint32_t windowId;
780 property->SetParentId(INVALID_WINDOW_ID);
781 property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
782 struct RSSurfaceNodeConfig surfaceNodeConfig;
783 surfaceNodeConfig.SurfaceNodeName = "DestroyWindow";
784 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
785 ASSERT_EQ(WMError::WM_OK, windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
786
787 WMError res = windowController_->DestroyWindow(100, true);
788 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, res);
789
790 res = windowController_->DestroyWindow(windowId, true);
791 ASSERT_EQ(WMError::WM_OK, res);
792 }
793
794 /**
795 * @tc.name: DestroyWindow1
796 * @tc.desc: Window controller DestroyWindow false
797 * @tc.type: FUNC
798 */
799 HWTEST_F(WindowControllerTest, DestroyWindow1, TestSize.Level1)
800 {
801 windowRoot_->windowNodeMap_.clear();
802 sptr<IWindow> window;
803 sptr<WindowProperty> property = new WindowProperty();
804 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
805
806 uint32_t windowId;
807 property->SetParentId(INVALID_WINDOW_ID);
808 property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
809 struct RSSurfaceNodeConfig surfaceNodeConfig;
810 surfaceNodeConfig.SurfaceNodeName = "DestroyWindow1";
811 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
812 ASSERT_EQ(WMError::WM_OK, windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
813
814 WMError res = windowController_->DestroyWindow(100, false);
815 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, res);
816
817 res = windowController_->DestroyWindow(windowId, false);
818 ASSERT_EQ(WMError::WM_OK, res);
819 }
820
821 /**
822 * @tc.name: RequestFocus
823 * @tc.desc: Window controller RequestFocus false
824 * @tc.type: FUNC
825 */
826 HWTEST_F(WindowControllerTest, RequestFocus, TestSize.Level1)
827 {
828 windowRoot_->windowNodeMap_.clear();
829 sptr<IWindow> window;
830 sptr<WindowProperty> property = new WindowProperty();
831 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
832 sptr<WindowNode> windowNode = new WindowNode(property);
833 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
834
835 uint32_t windowId;
836 property->SetParentId(INVALID_WINDOW_ID);
837 property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
838 struct RSSurfaceNodeConfig surfaceNodeConfig;
839 surfaceNodeConfig.SurfaceNodeName = "RequestFocus";
840 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
841 ASSERT_EQ(WMError::WM_OK, windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
842
843 WMError res = windowController_->RequestFocus(10);
844 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, res);
845
846 windowId = windowNode->GetWindowId();
847 res = windowController_->RequestFocus(windowId);
848 if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
849 ASSERT_NE(WMError::WM_ERROR_INVALID_OPERATION, res);
850 } else {
851 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
852 }
853 }
854
855 /**
856 * @tc.name: NotifyDisplayStateChange
857 * @tc.desc: Window controller NotifyDisplayStateChange
858 * @tc.type: FUNC
859 */
860 HWTEST_F(WindowControllerTest, NotifyDisplayStateChange, TestSize.Level1)
861 {
862 windowRoot_->windowNodeMap_.clear();
863 sptr<IWindow> window;
864 sptr<WindowProperty> property = new WindowProperty();
865 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
866 sptr<WindowNode> windowNode = new WindowNode(property);
867 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
868
869 uint32_t windowId;
870 property->SetParentId(INVALID_WINDOW_ID);
871 property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
872 struct RSSurfaceNodeConfig surfaceNodeConfig;
873 surfaceNodeConfig.SurfaceNodeName = "NotifyDisplayStateChange";
874 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
875
876 DisplayId defaultDisplayId = 0;
877 sptr<DisplayInfo> displayInfo = new DisplayInfo();
878 std::map < DisplayId, sptr < DisplayInfo >> displayInfoMap;
879
880 DisplayStateChangeType type = DisplayStateChangeType::BEFORE_SUSPEND;
881 windowController_->NotifyDisplayStateChange(defaultDisplayId, displayInfo, displayInfoMap, type);
882 type = DisplayStateChangeType::BEFORE_UNLOCK;
883 windowController_->NotifyDisplayStateChange(defaultDisplayId, displayInfo, displayInfoMap, type);
884 type = DisplayStateChangeType::CREATE;
885 windowController_->NotifyDisplayStateChange(defaultDisplayId, displayInfo, displayInfoMap, type);
886 type = DisplayStateChangeType::DESTROY;
887 windowController_->NotifyDisplayStateChange(defaultDisplayId, displayInfo, displayInfoMap, type);
888 type = DisplayStateChangeType::VIRTUAL_PIXEL_RATIO_CHANGE;
889 windowController_->NotifyDisplayStateChange(defaultDisplayId, displayInfo, displayInfoMap, type);
890 type = DisplayStateChangeType::UNKNOWN;
891 windowController_->NotifyDisplayStateChange(defaultDisplayId, displayInfo, displayInfoMap, type);
892
893 ASSERT_EQ(WMError::WM_OK,
894 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
895 }
896
897 /**
898 * @tc.name: NotifyDisplayStateChange
899 * @tc.desc: Window controller NotifyDisplayStateChange
900 * @tc.type: FUNC
901 */
902 HWTEST_F(WindowControllerTest, NotifyDisplayStateChange1, TestSize.Level1)
903 {
904 windowRoot_->windowNodeMap_.clear();
905 sptr<IWindow> window;
906 sptr<WindowProperty> property = new WindowProperty();
907 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
908 sptr<WindowNode> windowNode = new WindowNode(property);
909 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
910
911 uint32_t windowId;
912 property->SetParentId(INVALID_WINDOW_ID);
913 property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
914 struct RSSurfaceNodeConfig surfaceNodeConfig;
915 surfaceNodeConfig.SurfaceNodeName = "NotifyDisplayStateChange1";
916 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
917
918 DisplayId defaultDisplayId = 0;
919 sptr<DisplayInfo> displayInfo = new DisplayInfo();
920 std::map < DisplayId, sptr < DisplayInfo >> displayInfoMap;
921
922 DisplayStateChangeType type = DisplayStateChangeType::VIRTUAL_PIXEL_RATIO_CHANGE;
923 windowController_->NotifyDisplayStateChange(defaultDisplayId, displayInfo, displayInfoMap, type);
924
925 ASSERT_EQ(WMError::WM_OK,
926 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
927 }
928
929 /**
930 * @tc.name: ProcessDisplayChange
931 * @tc.desc: Window controller ProcessDisplayChange
932 * @tc.type: FUNC
933 */
934 HWTEST_F(WindowControllerTest, ProcessDisplayChange, TestSize.Level1)
935 {
936 windowRoot_->windowNodeMap_.clear();
937 sptr<IWindow> window;
938 sptr<WindowProperty> property = new WindowProperty();
939 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
940 sptr<WindowNode> windowNode = new WindowNode(property);
941 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
942
943 uint32_t windowId;
944 property->SetParentId(INVALID_WINDOW_ID);
945 property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
946 struct RSSurfaceNodeConfig surfaceNodeConfig;
947 surfaceNodeConfig.SurfaceNodeName = "ProcessDisplayChange";
948 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
949
950 DisplayId defaultDisplayId = 0;
951 sptr<DisplayInfo> displayInfo = new DisplayInfo();
952 std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
953 DisplayStateChangeType type = DisplayStateChangeType::VIRTUAL_PIXEL_RATIO_CHANGE;
954 windowController_->NotifyDisplayStateChange(defaultDisplayId, displayInfo, displayInfoMap, type);
955
956 displayInfo->SetDisplayId(defaultDisplayId);
957 windowController_->NotifyDisplayStateChange(defaultDisplayId, displayInfo, displayInfoMap, type);
958
959 sptr<DisplayInfo> displayInfo1 = nullptr;
960 windowController_->NotifyDisplayStateChange(defaultDisplayId, displayInfo1, displayInfoMap, type);
961
962 ASSERT_EQ(WMError::WM_OK,
963 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
964 }
965
966 /**
967 * @tc.name: ChangeMouseStyle
968 * @tc.desc: Window controller ChangeMouseStyle width > height
969 * @tc.type: FUNC
970 */
971 HWTEST_F(WindowControllerTest, ChangeMouseStyle1, TestSize.Level1)
972 {
973 windowRoot_->windowNodeMap_.clear();
974 sptr<IWindow> window;
975 sptr<WindowProperty> property = new WindowProperty();
976 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
977 property->SetParentId(INVALID_WINDOW_ID);
978 property->SetWindowType(WindowType::WINDOW_TYPE_DOCK_SLICE);
979 sptr<WindowNode> windowNode = new WindowNode(property);
980 windowNode->SetWindowRect({50, 50, 100, 50});
981 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
982
983 uint32_t windowId = windowNode->GetWindowId();
984 struct RSSurfaceNodeConfig surfaceNodeConfig;
985 surfaceNodeConfig.SurfaceNodeName = "ChangeMouseStyle1";
986 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
987 ASSERT_EQ(WMError::WM_OK,
988 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
989
990 sptr<MoveDragProperty> moveDragProperty;
991 WMError res = windowController_->ChangeMouseStyle(windowId, moveDragProperty);
992 if (SceneBoardJudgement::IsSceneBoardEnabled()) {
993 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
994 } else {
995 ASSERT_EQ(WMError::WM_OK, res);
996 }
997 }
998
999 /**
1000 * @tc.name: ChangeMouseStyle
1001 * @tc.desc: Window controller ChangeMouseStyle width < height
1002 * @tc.type: FUNC
1003 */
1004 HWTEST_F(WindowControllerTest, ChangeMouseStyle2, TestSize.Level1)
1005 {
1006 windowRoot_->windowNodeMap_.clear();
1007 sptr<IWindow> window;
1008 sptr<WindowProperty> property = new WindowProperty();
1009 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1010 property->SetParentId(INVALID_WINDOW_ID);
1011 property->SetWindowType(WindowType::WINDOW_TYPE_DOCK_SLICE);
1012 sptr<WindowNode> windowNode = new WindowNode(property);
1013 windowNode->SetWindowRect({50, 50, 20, 50});
1014 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1015
1016 uint32_t windowId = windowNode->GetWindowId();
1017 struct RSSurfaceNodeConfig surfaceNodeConfig;
1018 surfaceNodeConfig.SurfaceNodeName = "ChangeMouseStyle2";
1019 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1020 ASSERT_EQ(WMError::WM_OK,
1021 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1022
1023 sptr<MoveDragProperty> moveDragProperty;
1024 WMError res = windowController_->ChangeMouseStyle(windowId, moveDragProperty);
1025 if (SceneBoardJudgement::IsSceneBoardEnabled()) {
1026 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1027 } else {
1028 ASSERT_EQ(WMError::WM_OK, res);
1029 }
1030 }
1031
1032 /**
1033 * @tc.name: ChangeMouseStyle
1034 * @tc.desc: Window controller ChangeMouseStyle
1035 * @tc.type: FUNC
1036 */
1037 HWTEST_F(WindowControllerTest, ChangeMouseStyle3, TestSize.Level1)
1038 {
1039 windowRoot_->windowNodeMap_.clear();
1040 sptr<IWindow> window;
1041 sptr<WindowProperty> property = new WindowProperty();
1042 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1043 sptr<WindowNode> windowNode = new WindowNode(property);
1044 property->SetParentId(INVALID_WINDOW_ID);
1045 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1046 windowNode->SetWindowRect({50, 50, 50, 50});
1047 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1048
1049 uint32_t windowId = windowNode->GetWindowId();
1050 struct RSSurfaceNodeConfig surfaceNodeConfig;
1051 surfaceNodeConfig.SurfaceNodeName = "ChangeMouseStyle3";
1052 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1053 ASSERT_EQ(WMError::WM_OK,
1054 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1055
1056 sptr<MoveDragProperty> moveDragProperty = new MoveDragProperty();
1057 moveDragProperty->dragType_ = DragType::DRAG_UNDEFINED;
1058 WMError res = windowController_->ChangeMouseStyle(windowId, moveDragProperty);
1059 if (!SceneBoardJudgement::IsSceneBoardEnabled()) {
1060 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1061 } else {
1062 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1063 }
1064 }
1065
1066 /**
1067 * @tc.name: NotifyServerReadyToMoveOrDrag
1068 * @tc.desc: Window controller NotifyServerReadyToMoveOrDrag1
1069 * @tc.type: FUNC
1070 */
1071 HWTEST_F(WindowControllerTest, NotifyServerReadyToMoveOrDrag1, TestSize.Level1)
1072 {
1073 windowRoot_->windowNodeMap_.clear();
1074 sptr<IWindow> window;
1075 sptr<WindowProperty> property = new WindowProperty();
1076 property->SetMaximizeMode(MaximizeMode::MODE_AVOID_SYSTEM_BAR);
1077 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1078 sptr<WindowNode> windowNode = new WindowNode(property);
1079 property->SetParentId(INVALID_WINDOW_ID);
1080 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1081 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1082
1083 uint32_t windowId = windowNode->GetWindowId();
1084 struct RSSurfaceNodeConfig surfaceNodeConfig;
1085 surfaceNodeConfig.SurfaceNodeName = "NotifyServerReadyToMoveOrDrag1";
1086 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1087 ASSERT_EQ(WMError::WM_OK,
1088 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1089
1090 sptr<MoveDragProperty> moveDragProperty = new MoveDragProperty();
1091 WMError res = windowController_->NotifyServerReadyToMoveOrDrag(10, moveDragProperty);
1092 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, res);
1093
1094 ASSERT_EQ(windowNode->currentVisibility_, false);
1095 res = windowController_->NotifyServerReadyToMoveOrDrag(windowId, moveDragProperty);
1096 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1097
1098 windowNode->currentVisibility_ = true;
1099 res = windowController_->NotifyServerReadyToMoveOrDrag(windowId, moveDragProperty);
1100 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1101 }
1102
1103 /**
1104 * @tc.name: NotifyServerReadyToMoveOrDrag
1105 * @tc.desc: Window controller NotifyServerReadyToMoveOrDrag2
1106 * @tc.type: FUNC
1107 */
1108 HWTEST_F(WindowControllerTest, NotifyServerReadyToMoveOrDrag2, TestSize.Level1)
1109 {
1110 windowRoot_->windowNodeMap_.clear();
1111 sptr<IWindow> window;
1112 sptr<WindowProperty> property = new WindowProperty();
1113 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1114 sptr<WindowNode> windowNode = new WindowNode(property);
1115 property->SetParentId(INVALID_WINDOW_ID);
1116 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1117 windowNode->currentVisibility_ = true;
1118 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1119
1120 uint32_t windowId = windowNode->GetWindowId();
1121 struct RSSurfaceNodeConfig surfaceNodeConfig;
1122 surfaceNodeConfig.SurfaceNodeName = "NotifyServerReadyToMoveOrDrag2";
1123 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1124 ASSERT_EQ(WMError::WM_OK,
1125 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1126
1127 sptr<MoveDragProperty> moveDragProperty = new MoveDragProperty();
1128 moveDragProperty->startMoveFlag_ = false;
1129 moveDragProperty->startDragFlag_ = false;
1130 WMError res = windowController_->NotifyServerReadyToMoveOrDrag(windowId, moveDragProperty);
1131 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1132
1133 moveDragProperty->startMoveFlag_ = true;
1134 res = windowController_->NotifyServerReadyToMoveOrDrag(windowId, moveDragProperty);
1135 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1136
1137 moveDragProperty->startMoveFlag_ = false;
1138 moveDragProperty->startDragFlag_ = true;
1139 res = windowController_->NotifyServerReadyToMoveOrDrag(windowId, moveDragProperty);
1140 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1141
1142 moveDragProperty->startMoveFlag_ = true;
1143 res = windowController_->NotifyServerReadyToMoveOrDrag(windowId, moveDragProperty);
1144 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1145 }
1146
1147 /**
1148 * @tc.name: NotifyServerReadyToMoveOrDrag
1149 * @tc.desc: Window controller NotifyServerReadyToMoveOrDrag WindowType = WINDOW_TYPE_DOCK_SLICE
1150 * @tc.type: FUNC
1151 */
1152 HWTEST_F(WindowControllerTest, NotifyServerReadyToMoveOrDrag3, TestSize.Level1)
1153 {
1154 windowRoot_->windowNodeMap_.clear();
1155 sptr<IWindow> window;
1156 sptr<WindowProperty> property = new WindowProperty();
1157 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1158 sptr<WindowNode> windowNode = new WindowNode(property);
1159 property->SetParentId(INVALID_WINDOW_ID);
1160 property->SetWindowType(WindowType::WINDOW_TYPE_DOCK_SLICE);
1161 windowNode->currentVisibility_ = true;
1162 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1163
1164 uint32_t windowId = windowNode->GetWindowId();
1165 struct RSSurfaceNodeConfig surfaceNodeConfig;
1166 surfaceNodeConfig.SurfaceNodeName = "NotifyServerReadyToMoveOrDrag3";
1167 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1168 ASSERT_EQ(WMError::WM_OK,
1169 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1170
1171 sptr<MoveDragProperty> moveDragProperty = new MoveDragProperty();
1172 moveDragProperty->startMoveFlag_ = false;
1173 moveDragProperty->startDragFlag_ = false;
1174 WMError res = windowController_->NotifyServerReadyToMoveOrDrag(windowId, moveDragProperty);
1175 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1176
1177 moveDragProperty->startMoveFlag_ = true;
1178 res = windowController_->NotifyServerReadyToMoveOrDrag(windowId, moveDragProperty);
1179 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1180
1181 moveDragProperty->startMoveFlag_ = false;
1182 moveDragProperty->startDragFlag_ = true;
1183 res = windowController_->NotifyServerReadyToMoveOrDrag(windowId, moveDragProperty);
1184 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1185
1186 moveDragProperty->startMoveFlag_ = true;
1187 res = windowController_->NotifyServerReadyToMoveOrDrag(windowId, moveDragProperty);
1188 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1189 }
1190
1191 /**
1192 * @tc.name: ProcessPointDown
1193 * @tc.desc: Window controller ProcessPointDown
1194 * @tc.type: FUNC
1195 */
1196 HWTEST_F(WindowControllerTest, ProcessPointDown1, TestSize.Level1)
1197 {
1198 windowRoot_->windowNodeMap_.clear();
1199 sptr<IWindow> window;
1200 sptr<WindowProperty> property = new WindowProperty();
1201 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1202 sptr<WindowNode> windowNode = new WindowNode(property);
1203 property->SetParentId(INVALID_WINDOW_ID);
1204 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1205 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1206
1207 uint32_t windowId = windowNode->GetWindowId();
1208 struct RSSurfaceNodeConfig surfaceNodeConfig;
1209 surfaceNodeConfig.SurfaceNodeName = "ProcessPointDown1";
1210 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1211 ASSERT_EQ(WMError::WM_OK,
1212 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1213
1214 bool isPointDown = true;
1215 WMError res = windowController_->ProcessPointDown(10, isPointDown);
1216 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, res);
1217
1218 ASSERT_EQ(windowNode->currentVisibility_, false);
1219 res = windowController_->ProcessPointDown(windowId, isPointDown);
1220 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1221
1222 windowNode->currentVisibility_ = true;
1223 res = windowController_->ProcessPointDown(windowId, isPointDown);
1224 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1225 }
1226
1227 /**
1228 * @tc.name: ProcessPointDown
1229 * @tc.desc: Window controller ProcessPointDown
1230 * @tc.type: FUNC
1231 */
1232 HWTEST_F(WindowControllerTest, ProcessPointDown2, TestSize.Level1)
1233 {
1234 windowRoot_->windowNodeMap_.clear();
1235 sptr<IWindow> window;
1236 sptr<WindowProperty> property = new WindowProperty();
1237 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1238 sptr<WindowNode> windowNode = new WindowNode(property);
1239 property->SetParentId(INVALID_WINDOW_ID);
1240 property->SetWindowType(WindowType::WINDOW_TYPE_DOCK_SLICE);
1241 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1242
1243 uint32_t windowId = windowNode->GetWindowId();
1244 struct RSSurfaceNodeConfig surfaceNodeConfig;
1245 surfaceNodeConfig.SurfaceNodeName = "ProcessPointDown2";
1246 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1247 ASSERT_EQ(WMError::WM_OK,
1248 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1249
1250 bool isPointDown = true;
1251 windowNode->currentVisibility_ = true;
1252 WMError res = windowController_->ProcessPointDown(windowId, isPointDown);
1253 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1254
1255 isPointDown = false;
1256 res = windowController_->ProcessPointDown(windowId, isPointDown);
1257 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1258 }
1259
1260 /**
1261 * @tc.name: ProcessPointUp
1262 * @tc.desc: Window controller ProcessPointUp WindowType = WINDOW_TYPE_DOCK_SLICE
1263 * @tc.type: FUNC
1264 */
1265 HWTEST_F(WindowControllerTest, ProcessPointUp, TestSize.Level1)
1266 {
1267 windowRoot_->windowNodeMap_.clear();
1268 sptr<IWindow> window;
1269 sptr<WindowProperty> property = new WindowProperty();
1270 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1271 sptr<WindowNode> windowNode = new WindowNode(property);
1272 property->SetParentId(INVALID_WINDOW_ID);
1273 property->SetWindowType(WindowType::WINDOW_TYPE_DOCK_SLICE);
1274 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1275
1276 uint32_t windowId = windowNode->GetWindowId();
1277 struct RSSurfaceNodeConfig surfaceNodeConfig;
1278 surfaceNodeConfig.SurfaceNodeName = "ProcessPointUp";
1279 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1280 ASSERT_EQ(WMError::WM_OK,
1281 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1282
1283 WMError res = windowController_->ProcessPointUp(10);
1284 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, res);
1285
1286 res = windowController_->ProcessPointUp(windowId);
1287 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1288 }
1289
1290 /**
1291 * @tc.name: ProcessPointUp2
1292 * @tc.desc: Window controller ProcessPointUp2 WindowType = WINDOW_TYPE_APP_MAIN_WINDOW
1293 * @tc.type: FUNC
1294 */
1295 HWTEST_F(WindowControllerTest, ProcessPointUp2, TestSize.Level1)
1296 {
1297 windowRoot_->windowNodeMap_.clear();
1298 sptr<IWindow> window;
1299 sptr<WindowProperty> property = new WindowProperty();
1300 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1301 sptr<WindowNode> windowNode = new WindowNode(property);
1302 property->SetParentId(INVALID_WINDOW_ID);
1303 property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1304 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1305
1306 uint32_t windowId = windowNode->GetWindowId();
1307 struct RSSurfaceNodeConfig surfaceNodeConfig;
1308 surfaceNodeConfig.SurfaceNodeName = "ProcessPointUp2";
1309 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1310 ASSERT_EQ(WMError::WM_OK,
1311 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1312
1313 WMError res = windowController_->ProcessPointUp(windowId);
1314 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1315 }
1316
1317 /**
1318 * @tc.name: ProcessPointUp3
1319 * @tc.desc: Window controller ProcessPointUp3 WindowType = APP_WINDOW_BASE
1320 * @tc.type: FUNC
1321 */
1322 HWTEST_F(WindowControllerTest, ProcessPointUp3, TestSize.Level1)
1323 {
1324 windowRoot_->windowNodeMap_.clear();
1325 sptr<IWindow> window;
1326 sptr<WindowProperty> property = new WindowProperty();
1327 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1328 sptr<WindowNode> windowNode = new WindowNode(property);
1329 property->SetParentId(INVALID_WINDOW_ID);
1330 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1331 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1332
1333 uint32_t windowId = windowNode->GetWindowId();
1334 struct RSSurfaceNodeConfig surfaceNodeConfig;
1335 surfaceNodeConfig.SurfaceNodeName = "ProcessPointUp3";
1336 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1337 ASSERT_EQ(WMError::WM_OK,
1338 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1339
1340 WMError res = windowController_->ProcessPointUp(windowId);
1341 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1342 }
1343
1344 /**
1345 * @tc.name: InterceptInputEventToServer
1346 * @tc.desc: Window controller InterceptInputEventToServer
1347 * @tc.type: FUNC
1348 */
1349 HWTEST_F(WindowControllerTest, InterceptInputEventToServer, TestSize.Level1)
1350 {
1351 windowRoot_->windowNodeMap_.clear();
1352 sptr<IWindow> window;
1353 sptr<WindowProperty> property = new WindowProperty();
1354 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1355 sptr<WindowNode> windowNode = new WindowNode(property);
1356 property->SetParentId(INVALID_WINDOW_ID);
1357 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1358 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1359
1360 uint32_t windowId = windowNode->GetWindowId();
1361 struct RSSurfaceNodeConfig surfaceNodeConfig;
1362 surfaceNodeConfig.SurfaceNodeName = "InterceptInputEventToServer";
1363 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1364 ASSERT_EQ(WMError::WM_OK,
1365 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1366
1367 WMError res = windowController_->InterceptInputEventToServer(10);
1368 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, res);
1369
1370 res = windowController_->InterceptInputEventToServer(windowId);
1371 ASSERT_EQ(WMError::WM_OK, res);
1372 }
1373
1374 /**
1375 * @tc.name: RecoverInputEventToClient
1376 * @tc.desc: Window controller RecoverInputEventToClient
1377 * @tc.type: FUNC
1378 */
1379 HWTEST_F(WindowControllerTest, RecoverInputEventToClient, TestSize.Level1)
1380 {
1381 windowRoot_->windowNodeMap_.clear();
1382 sptr<IWindow> window;
1383 sptr<WindowProperty> property = new WindowProperty();
1384 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1385 sptr<WindowNode> windowNode = new WindowNode(property);
1386 property->SetParentId(INVALID_WINDOW_ID);
1387 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1388 windowNode->SetInputEventCallingPid(2048);
1389 windowNode->SetCallingPid(2048);
1390 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1391
1392 uint32_t windowId = windowNode->GetWindowId();
1393 struct RSSurfaceNodeConfig surfaceNodeConfig;
1394 surfaceNodeConfig.SurfaceNodeName = "RecoverInputEventToClient";
1395 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1396 ASSERT_EQ(WMError::WM_OK,
1397 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1398
1399 WMError res = windowController_->RecoverInputEventToClient(10);
1400 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, res);
1401
1402 res = windowController_->RecoverInputEventToClient(windowId);
1403 ASSERT_EQ(WMError::WM_OK, res);
1404 }
1405
1406 /**
1407 * @tc.name: RecoverInputEventToClient2
1408 * @tc.desc: Window controller RecoverInputEventToClient2
1409 * @tc.type: FUNC
1410 */
1411 HWTEST_F(WindowControllerTest, RecoverInputEventToClient2, TestSize.Level1)
1412 {
1413 windowRoot_->windowNodeMap_.clear();
1414 sptr<IWindow> window;
1415 sptr<WindowProperty> property = new WindowProperty();
1416 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1417 sptr<WindowNode> windowNode = new WindowNode(property);
1418 property->SetParentId(INVALID_WINDOW_ID);
1419 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1420 windowNode->SetInputEventCallingPid(2048);
1421 windowNode->SetCallingPid(1024);
1422 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1423
1424 uint32_t windowId = windowNode->GetWindowId();
1425 struct RSSurfaceNodeConfig surfaceNodeConfig;
1426 surfaceNodeConfig.SurfaceNodeName = "RecoverInputEventToClient2";
1427 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1428 ASSERT_EQ(WMError::WM_OK,
1429 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1430
1431 WMError res = windowController_->RecoverInputEventToClient(windowId);
1432 ASSERT_EQ(WMError::WM_OK, res);
1433 }
1434
1435 /**
1436 * @tc.name: RecoverDefaultMouseStyle
1437 * @tc.desc: Window controller RecoverDefaultMouseStyle
1438 * @tc.type: FUNC
1439 */
1440 HWTEST_F(WindowControllerTest, RecoverDefaultMouseStyle, TestSize.Level1)
1441 {
1442 windowRoot_->windowNodeMap_.clear();
1443 sptr<IWindow> window;
1444 sptr<WindowProperty> property = new WindowProperty();
1445 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1446 sptr<WindowNode> windowNode = new WindowNode(property);
1447 property->SetParentId(INVALID_WINDOW_ID);
1448 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1449 windowNode->SetInputEventCallingPid(2048);
1450 windowNode->SetCallingPid(1024);
1451 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1452
1453 uint32_t windowId = windowNode->GetWindowId();
1454 windowController_->RecoverDefaultMouseStyle(windowId);
1455 struct RSSurfaceNodeConfig surfaceNodeConfig;
1456 surfaceNodeConfig.SurfaceNodeName = "RecoverDefaultMouseStyle";
1457 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1458 ASSERT_EQ(WMError::WM_OK,
1459 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1460 }
1461
1462 /**
1463 * @tc.name: DispatchKeyEvent
1464 * @tc.desc: Window controller DispatchKeyEvent
1465 * @tc.type: FUNC
1466 */
1467 HWTEST_F(WindowControllerTest, DispatchKeyEvent, TestSize.Level1)
1468 {
1469 windowRoot_->windowNodeMap_.clear();
1470 sptr<IWindow> window;
1471 sptr<WindowProperty> property = new WindowProperty();
1472 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1473 sptr<WindowNode> windowNode = new WindowNode(property);
1474 property->SetParentId(INVALID_WINDOW_ID);
1475 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1476 windowNode->SetInputEventCallingPid(2048);
1477 windowNode->SetCallingPid(2048);
1478 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1479
1480 uint32_t windowId = windowNode->GetWindowId();
1481 struct RSSurfaceNodeConfig surfaceNodeConfig;
1482 surfaceNodeConfig.SurfaceNodeName = "DispatchKeyEvent";
1483 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1484 std::shared_ptr<MMI::KeyEvent> event = nullptr;
1485 windowController_->DispatchKeyEvent(10, event);
1486 windowController_->DispatchKeyEvent(windowId, event);
1487 ASSERT_EQ(WMError::WM_OK,
1488 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1489 }
1490
1491 /**
1492 * @tc.name: DispatchKeyEvent
1493 * @tc.desc: Window controller DispatchKeyEvent WindowType = WINDOW_TYPE_APP_COMPONENT
1494 * @tc.type: FUNC
1495 */
1496 HWTEST_F(WindowControllerTest, DispatchKeyEvent2, TestSize.Level1)
1497 {
1498 windowRoot_->windowNodeMap_.clear();
1499 sptr<IWindow> window;
1500 sptr<WindowProperty> property = new WindowProperty();
1501 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1502 sptr<WindowNode> windowNode = new WindowNode(property);
1503 property->SetParentId(INVALID_WINDOW_ID);
1504 property->SetWindowType(WindowType::WINDOW_TYPE_APP_COMPONENT);
1505 windowNode->SetInputEventCallingPid(2048);
1506 windowNode->SetCallingPid(2048);
1507 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1508
1509 uint32_t windowId = windowNode->GetWindowId();
1510 struct RSSurfaceNodeConfig surfaceNodeConfig;
1511 surfaceNodeConfig.SurfaceNodeName = "DispatchKeyEvent2";
1512 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1513
1514 std::shared_ptr<MMI::KeyEvent> event = nullptr;
1515 windowController_->DispatchKeyEvent(windowId, event);
1516 ASSERT_EQ(WMError::WM_ERROR_INVALID_PARENT,
1517 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1518 }
1519
1520 /**
1521 * @tc.name: NotifyWindowClientPointUp
1522 * @tc.desc: Window controller NotifyWindowClientPointUp
1523 * @tc.type: FUNC
1524 */
1525 HWTEST_F(WindowControllerTest, NotifyWindowClientPointUp, TestSize.Level1)
1526 {
1527 windowRoot_->windowNodeMap_.clear();
1528 sptr<IWindow> window;
1529 sptr<WindowProperty> property = new WindowProperty();
1530 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1531 sptr<WindowNode> windowNode = new WindowNode(property);
1532 property->SetParentId(INVALID_WINDOW_ID);
1533 property->SetWindowType(WindowType::WINDOW_TYPE_DOCK_SLICE);
1534 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1535
1536 uint32_t windowId = windowNode->GetWindowId();
1537 struct RSSurfaceNodeConfig surfaceNodeConfig;
1538 surfaceNodeConfig.SurfaceNodeName = "ProcessPointUp";
1539 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1540 ASSERT_EQ(WMError::WM_OK,
1541 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1542
1543 std::shared_ptr<MMI::PointerEvent> pointerEvent = nullptr;
1544 WMError res = windowController_->NotifyWindowClientPointUp(10, pointerEvent);
1545 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, res);
1546
1547 res = windowController_->NotifyWindowClientPointUp(windowId, pointerEvent);
1548 ASSERT_EQ(WMError::WM_OK, res);
1549 }
1550
1551 /**
1552 * @tc.name: MinimizeAllAppWindows
1553 * @tc.desc: Window controller MinimizeAllAppWindows
1554 * @tc.type: FUNC
1555 */
1556 HWTEST_F(WindowControllerTest, MinimizeAllAppWindows, TestSize.Level1)
1557 {
1558 windowRoot_->windowNodeMap_.clear();
1559 sptr<IWindow> window;
1560 sptr<WindowProperty> property = new WindowProperty();
1561 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1562 sptr<WindowNode> windowNode = new WindowNode(property);
1563 property->SetParentId(INVALID_WINDOW_ID);
1564 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1565 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1566
1567 uint32_t windowId = windowNode->GetWindowId();
1568 windowController_->MinimizeAllAppWindows(0);
1569 struct RSSurfaceNodeConfig surfaceNodeConfig;
1570 surfaceNodeConfig.SurfaceNodeName = "MinimizeAllAppWindows";
1571 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1572 ASSERT_EQ(WMError::WM_OK,
1573 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1574 }
1575
1576 /**
1577 * @tc.name: ToggleShownStateForAllAppWindows
1578 * @tc.desc: Window controller ToggleShownStateForAllAppWindows
1579 * @tc.type: FUNC
1580 */
1581 HWTEST_F(WindowControllerTest, ToggleShownStateForAllAppWindows, TestSize.Level1)
1582 {
1583 windowRoot_->windowNodeMap_.clear();
1584 sptr<IWindow> window;
1585 sptr<WindowProperty> property = new WindowProperty();
1586 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1587 sptr<WindowNode> windowNode = new WindowNode(property);
1588 property->SetParentId(INVALID_WINDOW_ID);
1589 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1590 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1591
1592 uint32_t windowId = windowNode->GetWindowId();
1593 struct RSSurfaceNodeConfig surfaceNodeConfig;
1594 surfaceNodeConfig.SurfaceNodeName = "ToggleShownStateForAllAppWindows";
1595 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1596 ASSERT_EQ(WMError::WM_OK,
1597 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1598
1599 WMError res = windowController_->ToggleShownStateForAllAppWindows();
1600 ASSERT_EQ(WMError::WM_OK, res);
1601 }
1602
1603 /**
1604 * @tc.name: NotifyScreenshotEvent
1605 * @tc.desc: Window controller NotifyScreenshotEvent
1606 * @tc.type: FUNC
1607 */
1608 HWTEST_F(WindowControllerTest, NotifyScreenshotEvent, TestSize.Level1)
1609 {
1610 windowRoot_->windowNodeMap_.clear();
1611 sptr<IWindow> window;
1612 sptr<WindowProperty> property = new WindowProperty();
1613 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1614 sptr<WindowNode> windowNode = new WindowNode(property);
1615 property->SetParentId(INVALID_WINDOW_ID);
1616 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1617 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1618
1619 uint32_t windowId = windowNode->GetWindowId();
1620 struct RSSurfaceNodeConfig surfaceNodeConfig;
1621 surfaceNodeConfig.SurfaceNodeName = "NotifyScreenshotEvent";
1622 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1623 EXPECT_EQ(WMError::WM_OK,
1624 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1625
1626 ScreenshotEventType type = ScreenshotEventType::SCROLL_SHOT_START;
1627 WMError res = windowController_->NotifyScreenshotEvent(type);
1628 EXPECT_EQ(WMError::WM_OK, res);
1629 }
1630
1631 /**
1632 * @tc.name: GetUnreliableWindowInfo
1633 * @tc.desc: Window controller window is unreliable window
1634 * @tc.type: FUNC
1635 */
1636 HWTEST_F(WindowControllerTest, GetUnreliableWindowInfo1, TestSize.Level1)
1637 {
1638 windowRoot_->windowNodeMap_.clear();
1639 sptr<WindowProperty> property = new WindowProperty();
1640 ASSERT_NE(nullptr, property);
1641 property->SetWindowType(WindowType::WINDOW_TYPE_TOAST);
1642 sptr<WindowNode> windowNode = new WindowNode(property);
1643 ASSERT_NE(nullptr, windowNode);
1644 windowNode->currentVisibility_ = true;
1645 windowRoot_->windowNodeMap_.insert(std::make_pair(windowNode->GetWindowId(), windowNode));
1646 std::vector<sptr<UnreliableWindowInfo>> infos;
1647 ASSERT_EQ(WMError::WM_OK, windowController_->GetUnreliableWindowInfo(0, infos));
1648 EXPECT_EQ(1, infos.size());
1649
1650 sptr<WindowProperty> property2 = new WindowProperty();
1651 ASSERT_NE(nullptr, property2);
1652 property2->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1653 sptr<WindowNode> windowNode2 = new WindowNode(property2);
1654 ASSERT_NE(nullptr, windowNode2);
1655 windowNode2->currentVisibility_ = true;
1656 windowRoot_->windowNodeMap_.insert(std::make_pair(windowNode2->GetWindowId(), windowNode2));
1657 ASSERT_EQ(WMError::WM_OK, windowController_->GetUnreliableWindowInfo(0, infos));
1658 EXPECT_EQ(2, infos.size());
1659
1660 sptr<WindowProperty> property3 = new WindowProperty();
1661 ASSERT_NE(nullptr, property3);
1662 property3->SetParentId(windowNode->GetWindowId());
1663 property3->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1664 sptr<WindowNode> windowNode3 = new WindowNode(property3);
1665 ASSERT_NE(nullptr, windowNode3);
1666 windowNode3->currentVisibility_ = true;
1667 windowRoot_->windowNodeMap_.insert(std::make_pair(windowNode3->GetWindowId(), windowNode3));
1668 ASSERT_EQ(WMError::WM_OK, windowController_->GetUnreliableWindowInfo(0, infos));
1669 EXPECT_EQ(3, infos.size());
1670 }
1671
1672 /**
1673 * @tc.name: GetUnreliableWindowInfo
1674 * @tc.desc: Window controller windowId is equal to the parameter
1675 * @tc.type: FUNC
1676 */
1677 HWTEST_F(WindowControllerTest, GetUnreliableWindowInfo2, TestSize.Level1)
1678 {
1679 windowRoot_->windowNodeMap_.clear();
1680 sptr<WindowProperty> property = new WindowProperty();
1681 ASSERT_NE(nullptr, property);
1682 sptr<WindowNode> windowNode = new WindowNode(property);
1683 ASSERT_NE(nullptr, windowNode);
1684 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1685 std::vector<sptr<UnreliableWindowInfo>> infos;
1686 ASSERT_EQ(WMError::WM_OK, windowController_->GetUnreliableWindowInfo(1, infos));
1687 ASSERT_EQ(false, infos.empty());
1688 }
1689
1690 /**
1691 * @tc.name: GetUnreliableWindowInfo
1692 * @tc.desc: Window controller window type is not correct, window is invisible
1693 * @tc.type: FUNC
1694 */
1695 HWTEST_F(WindowControllerTest, GetUnreliableWindowInfo3, TestSize.Level1)
1696 {
1697 windowRoot_->windowNodeMap_.clear();
1698 sptr<WindowProperty> property = new WindowProperty();
1699 ASSERT_NE(nullptr, property);
1700 property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
1701 sptr<WindowNode> windowNode = new WindowNode(property);
1702 ASSERT_NE(nullptr, windowNode);
1703 windowNode->currentVisibility_ = true;
1704 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1705 std::vector<sptr<UnreliableWindowInfo>> infos;
1706 ASSERT_EQ(WMError::WM_OK, windowController_->GetUnreliableWindowInfo(0, infos));
1707 ASSERT_EQ(true, infos.empty());
1708
1709 windowRoot_->windowNodeMap_.clear();
1710 windowNode->currentVisibility_ = false;
1711 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1712 ASSERT_EQ(WMError::WM_OK, windowController_->GetUnreliableWindowInfo(0, infos));
1713 ASSERT_EQ(true, infos.empty());
1714 }
1715
1716 /**
1717 * @tc.name: UpdateProperty
1718 * @tc.desc: Window controller UpdateProperty property is nullptr
1719 * @tc.type: FUNC
1720 */
1721 HWTEST_F(WindowControllerTest, UpdateProperty1, TestSize.Level1)
1722 {
1723 windowRoot_->windowNodeMap_.clear();
1724 sptr<WindowProperty> property = nullptr;
1725 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_RECT;
1726 WMError res = windowController_->UpdateProperty(property, action);
1727 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, res);
1728 }
1729
1730 /**
1731 * @tc.name: UpdateProperty
1732 * @tc.desc: Window controller UpdateProperty windowRoot_ is nullptr
1733 * @tc.type: FUNC
1734 */
1735 HWTEST_F(WindowControllerTest, UpdateProperty2, TestSize.Level1)
1736 {
1737 windowRoot_->windowNodeMap_.clear();
1738 sptr<IWindow> window;
1739 sptr<WindowProperty> property = new WindowProperty();
1740 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1741 sptr<WindowNode> windowNode = new WindowNode(property);
1742 property->SetParentId(INVALID_WINDOW_ID);
1743 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1744
1745 uint32_t windowId = windowNode->GetWindowId();
1746 ASSERT_EQ(nullptr, windowRoot_->GetWindowNode(windowId));
1747 ASSERT_NE(nullptr, property);
1748
1749 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_RECT;
1750 WMError res = windowController_->UpdateProperty(property, action);
1751 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, res);
1752 }
1753
1754 /**
1755 * @tc.name: UpdateProperty
1756 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_RECT
1757 * @tc.type: FUNC
1758 */
1759 HWTEST_F(WindowControllerTest, UpdateProperty3, TestSize.Level1)
1760 {
1761 windowRoot_->windowNodeMap_.clear();
1762 sptr<IWindow> window;
1763 sptr<WindowProperty> property = new WindowProperty();
1764 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1765 sptr<WindowNode> windowNode = new WindowNode(property);
1766 property->SetParentId(INVALID_WINDOW_ID);
1767 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
1768
1769 uint32_t windowId = windowNode->GetWindowId();
1770 struct RSSurfaceNodeConfig surfaceNodeConfig;
1771 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty3";
1772 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1773 ASSERT_EQ(WMError::WM_OK,
1774 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1775 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
1776 ASSERT_NE(nullptr, property);
1777
1778 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_RECT;
1779 WMError res = windowController_->UpdateProperty(property, action);
1780 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1781
1782 windowNode->SetWindowRect({50, 50, 50, 50});
1783 windowNode->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1784 res = windowController_->UpdateProperty(property, action);
1785 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1786
1787 property->SetWindowType(WindowType::WINDOW_TYPE_STATUS_BAR);
1788 property->SetWindowSizeChangeReason(WindowSizeChangeReason::UNDEFINED);
1789 res = windowController_->UpdateProperty(property, action);
1790 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1791
1792 property->SetWindowSizeChangeReason(WindowSizeChangeReason::RESIZE);
1793 res = windowController_->UpdateProperty(property, action);
1794 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1795
1796 property->SetWindowSizeChangeReason(WindowSizeChangeReason::MOVE);
1797 res = windowController_->UpdateProperty(property, action);
1798 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1799
1800 property->SetWindowSizeChangeReason(WindowSizeChangeReason::DRAG_MOVE);
1801 res = windowController_->UpdateProperty(property, action);
1802 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1803 }
1804
1805 /**
1806 * @tc.name: UpdateProperty
1807 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_MODE
1808 * @tc.type: FUNC
1809 */
1810 HWTEST_F(WindowControllerTest, UpdateProperty4, TestSize.Level1)
1811 {
1812 windowRoot_->windowNodeMap_.clear();
1813 sptr<IWindow> window;
1814 sptr<WindowProperty> property = new WindowProperty();
1815 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1816 sptr<WindowNode> windowNode = new WindowNode(property);
1817 property->SetParentId(INVALID_WINDOW_ID);
1818 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1819 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
1820
1821 uint32_t windowId = windowNode->GetWindowId();
1822 struct RSSurfaceNodeConfig surfaceNodeConfig;
1823 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty4";
1824 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1825 ASSERT_EQ(WMError::WM_OK,
1826 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1827
1828 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
1829 ASSERT_NE(nullptr, property);
1830 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_MODE;
1831 WMError res = windowController_->UpdateProperty(property, action);
1832 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1833 }
1834
1835 /**
1836 * @tc.name: UpdateProperty
1837 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_FLAGS
1838 * @tc.type: FUNC
1839 */
1840 HWTEST_F(WindowControllerTest, UpdateProperty5, TestSize.Level1)
1841 {
1842 windowRoot_->windowNodeMap_.clear();
1843 sptr<IWindow> window;
1844 sptr<WindowProperty> property = new WindowProperty();
1845 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1846 sptr<WindowNode> windowNode = new WindowNode(property);
1847 property->SetParentId(INVALID_WINDOW_ID);
1848 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1849 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
1850
1851 uint32_t windowId = windowNode->GetWindowId();
1852 struct RSSurfaceNodeConfig surfaceNodeConfig;
1853 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty5";
1854 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1855 ASSERT_EQ(WMError::WM_OK,
1856 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1857
1858 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
1859 ASSERT_NE(nullptr, property);
1860 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_FLAGS;
1861 WMError res = windowController_->UpdateProperty(property, action);
1862 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1863 }
1864
1865 /**
1866 * @tc.name: UpdateProperty
1867 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_OTHER_PROPS
1868 * @tc.type: FUNC
1869 */
1870 HWTEST_F(WindowControllerTest, UpdateProperty6, TestSize.Level1)
1871 {
1872 windowRoot_->windowNodeMap_.clear();
1873 sptr<IWindow> window;
1874 sptr<WindowProperty> property = new WindowProperty();
1875 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1876 sptr<WindowNode> windowNode = new WindowNode(property);
1877 property->SetParentId(INVALID_WINDOW_ID);
1878 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1879 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
1880
1881 uint32_t windowId = windowNode->GetWindowId();
1882 struct RSSurfaceNodeConfig surfaceNodeConfig;
1883 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty6";
1884 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1885 ASSERT_EQ(WMError::WM_OK,
1886 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1887
1888 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
1889 ASSERT_NE(nullptr, property);
1890 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_OTHER_PROPS;
1891 WMError res = windowController_->UpdateProperty(property, action);
1892 ASSERT_EQ(WMError::WM_OK, res);
1893 }
1894
1895 /**
1896 * @tc.name: UpdateProperty
1897 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_FOCUSABLE
1898 * @tc.type: FUNC
1899 */
1900 HWTEST_F(WindowControllerTest, UpdateProperty7, TestSize.Level1)
1901 {
1902 windowRoot_->windowNodeMap_.clear();
1903 sptr<IWindow> window;
1904 sptr<WindowProperty> property = new WindowProperty();
1905 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1906 sptr<WindowNode> windowNode = new WindowNode(property);
1907 property->SetParentId(INVALID_WINDOW_ID);
1908 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1909 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
1910
1911 uint32_t windowId = windowNode->GetWindowId();
1912 struct RSSurfaceNodeConfig surfaceNodeConfig;
1913 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty7";
1914 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1915 ASSERT_EQ(WMError::WM_OK,
1916 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1917
1918 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
1919 ASSERT_NE(nullptr, property);
1920 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_FOCUSABLE;
1921 WMError res = windowController_->UpdateProperty(property, action);
1922 ASSERT_EQ(WMError::WM_OK, res);
1923 }
1924
1925 /**
1926 * @tc.name: UpdateProperty
1927 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_TOUCHABLE
1928 * @tc.type: FUNC
1929 */
1930 HWTEST_F(WindowControllerTest, UpdateProperty8, TestSize.Level1)
1931 {
1932 windowRoot_->windowNodeMap_.clear();
1933 sptr<IWindow> window;
1934 sptr<WindowProperty> property = new WindowProperty();
1935 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1936 sptr<WindowNode> windowNode = new WindowNode(property);
1937 property->SetParentId(INVALID_WINDOW_ID);
1938 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1939 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
1940
1941 uint32_t windowId = windowNode->GetWindowId();
1942 struct RSSurfaceNodeConfig surfaceNodeConfig;
1943 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty8";
1944 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1945 ASSERT_EQ(WMError::WM_OK,
1946 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1947
1948 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
1949 ASSERT_NE(nullptr, property);
1950 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_TOUCHABLE;
1951 WMError res = windowController_->UpdateProperty(property, action);
1952 ASSERT_EQ(WMError::WM_OK, res);
1953 }
1954
1955 /**
1956 * @tc.name: UpdateProperty
1957 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_CALLING_WINDOW
1958 * @tc.type: FUNC
1959 */
1960 HWTEST_F(WindowControllerTest, UpdateProperty9, TestSize.Level1)
1961 {
1962 windowRoot_->windowNodeMap_.clear();
1963 sptr<IWindow> window;
1964 sptr<WindowProperty> property = new WindowProperty();
1965 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1966 sptr<WindowNode> windowNode = new WindowNode(property);
1967 property->SetParentId(INVALID_WINDOW_ID);
1968 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1969 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
1970
1971 uint32_t windowId = windowNode->GetWindowId();
1972 struct RSSurfaceNodeConfig surfaceNodeConfig;
1973 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty9";
1974 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1975 ASSERT_EQ(WMError::WM_OK,
1976 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1977
1978 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
1979 ASSERT_NE(nullptr, property);
1980 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_CALLING_WINDOW;
1981 WMError res = windowController_->UpdateProperty(property, action);
1982 ASSERT_EQ(WMError::WM_OK, res);
1983 }
1984
1985 /**
1986 * @tc.name: UpdateProperty
1987 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_ORIENTATION
1988 * @tc.type: FUNC
1989 */
1990 HWTEST_F(WindowControllerTest, UpdateProperty10, TestSize.Level1)
1991 {
1992 windowRoot_->windowNodeMap_.clear();
1993 sptr<IWindow> window;
1994 sptr<WindowProperty> property = new WindowProperty();
1995 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1996 sptr<WindowNode> windowNode = new WindowNode(property);
1997 property->SetParentId(INVALID_WINDOW_ID);
1998 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1999 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2000
2001 uint32_t windowId = windowNode->GetWindowId();
2002 struct RSSurfaceNodeConfig surfaceNodeConfig;
2003 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty10";
2004 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2005 ASSERT_EQ(WMError::WM_OK,
2006 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2007
2008 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2009 ASSERT_NE(nullptr, property);
2010 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_ORIENTATION;
2011 WMError res = windowController_->UpdateProperty(property, action);
2012 ASSERT_EQ(WMError::WM_OK, res);
2013 }
2014
2015 /**
2016 * @tc.name: UpdateProperty
2017 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_TURN_SCREEN_ON
2018 * @tc.type: FUNC
2019 */
2020 HWTEST_F(WindowControllerTest, UpdateProperty11, TestSize.Level1)
2021 {
2022 windowRoot_->windowNodeMap_.clear();
2023 sptr<IWindow> window;
2024 sptr<WindowProperty> property = new WindowProperty();
2025 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2026 sptr<WindowNode> windowNode = new WindowNode(property);
2027 property->SetParentId(INVALID_WINDOW_ID);
2028 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2029 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2030
2031 uint32_t windowId = windowNode->GetWindowId();
2032 struct RSSurfaceNodeConfig surfaceNodeConfig;
2033 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty11";
2034 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2035 ASSERT_EQ(WMError::WM_OK,
2036 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2037
2038 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2039 ASSERT_NE(nullptr, property);
2040 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON;
2041 WMError res = windowController_->UpdateProperty(property, action);
2042 ASSERT_EQ(WMError::WM_OK, res);
2043 }
2044
2045 /**
2046 * @tc.name: UpdateProperty
2047 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_KEEP_SCREEN_ON
2048 * @tc.type: FUNC
2049 */
2050 HWTEST_F(WindowControllerTest, UpdateProperty12, TestSize.Level1)
2051 {
2052 windowRoot_->windowNodeMap_.clear();
2053 sptr<IWindow> window;
2054 sptr<WindowProperty> property = new WindowProperty();
2055 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2056 sptr<WindowNode> windowNode = new WindowNode(property);
2057 property->SetParentId(INVALID_WINDOW_ID);
2058 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2059 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2060
2061 uint32_t windowId = windowNode->GetWindowId();
2062 struct RSSurfaceNodeConfig surfaceNodeConfig;
2063 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty12";
2064 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2065 ASSERT_EQ(WMError::WM_OK,
2066 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2067
2068 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2069 ASSERT_NE(nullptr, property);
2070 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON;
2071 WMError res = windowController_->UpdateProperty(property, action);
2072 ASSERT_EQ(WMError::WM_OK, res);
2073 }
2074
2075 /**
2076 * @tc.name: UpdateProperty
2077 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_SET_BRIGHTNESS
2078 * @tc.type: FUNC
2079 */
2080 HWTEST_F(WindowControllerTest, UpdateProperty13, TestSize.Level1)
2081 {
2082 windowRoot_->windowNodeMap_.clear();
2083 sptr<IWindow> window;
2084 sptr<WindowProperty> property = new WindowProperty();
2085 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2086 sptr<WindowNode> windowNode = new WindowNode(property);
2087 property->SetParentId(INVALID_WINDOW_ID);
2088 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2089 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2090
2091 uint32_t windowId = windowNode->GetWindowId();
2092 struct RSSurfaceNodeConfig surfaceNodeConfig;
2093 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty13";
2094 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2095 ASSERT_EQ(WMError::WM_OK,
2096 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2097
2098 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2099 ASSERT_NE(nullptr, property);
2100 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_SET_BRIGHTNESS;
2101 WMError res = windowController_->UpdateProperty(property, action);
2102 ASSERT_EQ(WMError::WM_OK, res);
2103 }
2104
2105 /**
2106 * @tc.name: UpdateProperty
2107 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_MODE_SUPPORT_INFO
2108 * @tc.type: FUNC
2109 */
2110 HWTEST_F(WindowControllerTest, UpdateProperty14, TestSize.Level1)
2111 {
2112 windowRoot_->windowNodeMap_.clear();
2113 sptr<IWindow> window;
2114 sptr<WindowProperty> property = new WindowProperty();
2115 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2116 sptr<WindowNode> windowNode = new WindowNode(property);
2117 property->SetParentId(INVALID_WINDOW_ID);
2118 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2119 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2120
2121 uint32_t windowId = windowNode->GetWindowId();
2122 struct RSSurfaceNodeConfig surfaceNodeConfig;
2123 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty14";
2124 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2125 ASSERT_EQ(WMError::WM_OK,
2126 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2127
2128 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2129 ASSERT_NE(nullptr, property);
2130 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO;
2131 WMError res = windowController_->UpdateProperty(property, action);
2132 ASSERT_EQ(WMError::WM_OK, res);
2133 }
2134
2135 /**
2136 * @tc.name: UpdateProperty
2137 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_TOUCH_HOT_AREA
2138 * @tc.type: FUNC
2139 */
2140 HWTEST_F(WindowControllerTest, UpdateProperty15, TestSize.Level1)
2141 {
2142 windowRoot_->windowNodeMap_.clear();
2143 sptr<IWindow> window;
2144 sptr<WindowProperty> property = new WindowProperty();
2145 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2146 sptr<WindowNode> windowNode = new WindowNode(property);
2147 property->SetParentId(INVALID_WINDOW_ID);
2148 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2149 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2150
2151 uint32_t windowId = windowNode->GetWindowId();
2152 struct RSSurfaceNodeConfig surfaceNodeConfig;
2153 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty15";
2154 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2155 ASSERT_EQ(WMError::WM_OK,
2156 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2157
2158 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2159 ASSERT_NE(nullptr, property);
2160 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA;
2161 WMError res = windowController_->UpdateProperty(property, action);
2162 ASSERT_EQ(WMError::WM_OK, res);
2163 }
2164
2165 /**
2166 * @tc.name: UpdateProperty
2167 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_ANIMATION_FLAG
2168 * @tc.type: FUNC
2169 */
2170 HWTEST_F(WindowControllerTest, UpdateProperty16, TestSize.Level1)
2171 {
2172 windowRoot_->windowNodeMap_.clear();
2173 sptr<IWindow> window;
2174 sptr<WindowProperty> property = new WindowProperty();
2175 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2176 sptr<WindowNode> windowNode = new WindowNode(property);
2177 property->SetParentId(INVALID_WINDOW_ID);
2178 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2179 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2180
2181 uint32_t windowId = windowNode->GetWindowId();
2182 struct RSSurfaceNodeConfig surfaceNodeConfig;
2183 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty16";
2184 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2185 ASSERT_EQ(WMError::WM_OK,
2186 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2187
2188 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2189 ASSERT_NE(nullptr, property);
2190 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_ANIMATION_FLAG;
2191 WMError res = windowController_->UpdateProperty(property, action);
2192 ASSERT_EQ(WMError::WM_OK, res);
2193 }
2194
2195 /**
2196 * @tc.name: UpdateProperty
2197 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_TRANSFORM_PROPERTY
2198 * @tc.type: FUNC
2199 */
2200 HWTEST_F(WindowControllerTest, UpdateProperty17, TestSize.Level1)
2201 {
2202 windowRoot_->windowNodeMap_.clear();
2203 sptr<IWindow> window;
2204 sptr<WindowProperty> property = new WindowProperty();
2205 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2206 sptr<WindowNode> windowNode = new WindowNode(property);
2207 property->SetParentId(INVALID_WINDOW_ID);
2208 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2209 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2210
2211 uint32_t windowId = windowNode->GetWindowId();
2212 struct RSSurfaceNodeConfig surfaceNodeConfig;
2213 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty17";
2214 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2215 ASSERT_EQ(WMError::WM_OK,
2216 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2217
2218 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2219 ASSERT_NE(nullptr, property);
2220 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_TRANSFORM_PROPERTY;
2221 WMError res = windowController_->UpdateProperty(property, action);
2222 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
2223 }
2224
2225 /**
2226 * @tc.name: UpdateProperty
2227 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_ASPECT_RATIO
2228 * @tc.type: FUNC
2229 */
2230 HWTEST_F(WindowControllerTest, UpdateProperty19, TestSize.Level1)
2231 {
2232 windowRoot_->windowNodeMap_.clear();
2233 sptr<IWindow> window;
2234 sptr<WindowProperty> property = new WindowProperty();
2235 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2236 sptr<WindowNode> windowNode = new WindowNode(property);
2237 property->SetParentId(INVALID_WINDOW_ID);
2238 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2239 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2240
2241 uint32_t windowId = windowNode->GetWindowId();
2242 struct RSSurfaceNodeConfig surfaceNodeConfig;
2243 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty19";
2244 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2245 ASSERT_EQ(WMError::WM_OK,
2246 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2247
2248 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2249 ASSERT_NE(nullptr, property);
2250 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_ASPECT_RATIO;
2251 WMError res = windowController_->UpdateProperty(property, action);
2252 ASSERT_EQ(WMError::WM_OK, res);
2253 }
2254
2255 /**
2256 * @tc.name: UpdateProperty
2257 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_MAXIMIZE_STATE ResizeRect
2258 * @tc.type: FUNC
2259 */
2260 HWTEST_F(WindowControllerTest, UpdateProperty20, TestSize.Level1)
2261 {
2262 windowRoot_->windowNodeMap_.clear();
2263 sptr<IWindow> window;
2264 sptr<WindowProperty> property = new WindowProperty();
2265 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2266 sptr<WindowNode> windowNode = new WindowNode(property);
2267 property->SetParentId(INVALID_WINDOW_ID);
2268 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2269 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2270
2271 uint32_t windowId = windowNode->GetWindowId();
2272 struct RSSurfaceNodeConfig surfaceNodeConfig;
2273 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty20";
2274 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2275 ASSERT_EQ(WMError::WM_OK,
2276 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2277 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2278 ASSERT_NE(nullptr, property);
2279 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_MAXIMIZE_STATE;
2280 WMError res = windowController_->UpdateProperty(property, action);
2281 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
2282
2283 windowNode->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
2284 res = windowController_->UpdateProperty(property, action);
2285 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
2286
2287 property->SetWindowSizeChangeReason(WindowSizeChangeReason::MOVE);
2288 property->SetWindowType(WindowType::WINDOW_TYPE_DOCK_SLICE);
2289 res = windowController_->UpdateProperty(property, action);
2290 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
2291
2292 property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
2293 res = windowController_->UpdateProperty(property, action);
2294 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
2295
2296 property->SetWindowSizeChangeReason(WindowSizeChangeReason::RESIZE);
2297 res = windowController_->UpdateProperty(property, action);
2298 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
2299
2300 property->SetWindowSizeChangeReason(WindowSizeChangeReason::DRAG);
2301 res = windowController_->UpdateProperty(property, action);
2302 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
2303
2304 property->SetWindowSizeChangeReason(WindowSizeChangeReason::MAXIMIZE);
2305 res = windowController_->UpdateProperty(property, action);
2306 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
2307 }
2308
2309 /**
2310 * @tc.name: MinimizeWindowsByLauncher
2311 * @tc.desc: Window controller MinimizeWindowsByLauncher
2312 * @tc.type: FUNC
2313 */
2314 HWTEST_F(WindowControllerTest, MinimizeWindowsByLauncher, TestSize.Level1)
2315 {
2316 windowRoot_->windowNodeMap_.clear();
2317 sptr<IWindow> window;
2318 sptr<WindowProperty> property = new WindowProperty();
2319 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2320 sptr<WindowNode> windowNode = new WindowNode(property);
2321 property->SetParentId(INVALID_WINDOW_ID);
2322 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2323 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2324
2325 uint32_t windowId = windowNode->GetWindowId();
2326 struct RSSurfaceNodeConfig surfaceNodeConfig;
2327 surfaceNodeConfig.SurfaceNodeName = "MinimizeWindowsByLauncher";
2328 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2329
2330 std::vector<uint32_t> windowIds;
2331 windowIds.push_back(windowId);
2332 bool isAnimated = true;
2333 sptr<RSIWindowAnimationFinishedCallback> finishCallback;
2334 windowController_->MinimizeWindowsByLauncher(windowIds, isAnimated, finishCallback);
2335 isAnimated = false;
2336 windowController_->MinimizeWindowsByLauncher(windowIds, isAnimated, finishCallback);
2337 ASSERT_EQ(WMError::WM_OK,
2338 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2339 }
2340
2341 /**
2342 * @tc.name: OnScreenshot
2343 * @tc.desc: Window controller OnScreenshot
2344 * @tc.type: FUNC
2345 */
2346 HWTEST_F(WindowControllerTest, OnScreenshot, TestSize.Level1)
2347 {
2348 windowRoot_->windowNodeMap_.clear();
2349 sptr<IWindow> window;
2350 sptr<WindowProperty> property = new WindowProperty();
2351 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2352 sptr<WindowNode> windowNode = new WindowNode(property);
2353 property->SetParentId(INVALID_WINDOW_ID);
2354 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2355 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2356
2357 uint32_t windowId = windowNode->GetWindowId();
2358 struct RSSurfaceNodeConfig surfaceNodeConfig;
2359 surfaceNodeConfig.SurfaceNodeName = "OnScreenshot";
2360 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2361
2362 DisplayId displayId = static_cast<DisplayId>(windowId);
2363 windowController_->OnScreenshot(10);
2364 windowController_->OnScreenshot(displayId);
2365 ASSERT_EQ(WMError::WM_OK,
2366 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2367 }
2368 }
2369 }
2370 }
2371