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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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, Function | SmallTest | Level3)
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: GetUnreliableWindowInfo
1605 * @tc.desc: Window controller window is unreliable window
1606 * @tc.type: FUNC
1607 */
1608 HWTEST_F(WindowControllerTest, GetUnreliableWindowInfo1, Function | SmallTest | Level3)
1609 {
1610 windowRoot_->windowNodeMap_.clear();
1611 sptr<WindowProperty> property = new WindowProperty();
1612 ASSERT_NE(nullptr, property);
1613 property->SetWindowType(WindowType::WINDOW_TYPE_TOAST);
1614 sptr<WindowNode> windowNode = new WindowNode(property);
1615 ASSERT_NE(nullptr, windowNode);
1616 windowNode->currentVisibility_ = true;
1617 windowRoot_->windowNodeMap_.insert(std::make_pair(windowNode->GetWindowId(), windowNode));
1618 std::vector<sptr<UnreliableWindowInfo>> infos;
1619 ASSERT_EQ(WMError::WM_OK, windowController_->GetUnreliableWindowInfo(0, infos));
1620 EXPECT_EQ(1, infos.size());
1621
1622 sptr<WindowProperty> property2 = new WindowProperty();
1623 ASSERT_NE(nullptr, property2);
1624 property2->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1625 sptr<WindowNode> windowNode2 = new WindowNode(property2);
1626 ASSERT_NE(nullptr, windowNode2);
1627 windowNode2->currentVisibility_ = true;
1628 windowRoot_->windowNodeMap_.insert(std::make_pair(windowNode2->GetWindowId(), windowNode2));
1629 ASSERT_EQ(WMError::WM_OK, windowController_->GetUnreliableWindowInfo(0, infos));
1630 EXPECT_EQ(2, infos.size());
1631
1632 sptr<WindowProperty> property3 = new WindowProperty();
1633 ASSERT_NE(nullptr, property3);
1634 property3->SetParentId(windowNode->GetWindowId());
1635 property3->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1636 sptr<WindowNode> windowNode3 = new WindowNode(property3);
1637 ASSERT_NE(nullptr, windowNode3);
1638 windowNode3->currentVisibility_ = true;
1639 windowRoot_->windowNodeMap_.insert(std::make_pair(windowNode3->GetWindowId(), windowNode3));
1640 ASSERT_EQ(WMError::WM_OK, windowController_->GetUnreliableWindowInfo(0, infos));
1641 EXPECT_EQ(3, infos.size());
1642 }
1643
1644 /**
1645 * @tc.name: GetUnreliableWindowInfo
1646 * @tc.desc: Window controller windowId is equal to the parameter
1647 * @tc.type: FUNC
1648 */
1649 HWTEST_F(WindowControllerTest, GetUnreliableWindowInfo2, Function | SmallTest | Level3)
1650 {
1651 windowRoot_->windowNodeMap_.clear();
1652 sptr<WindowProperty> property = new WindowProperty();
1653 ASSERT_NE(nullptr, property);
1654 sptr<WindowNode> windowNode = new WindowNode(property);
1655 ASSERT_NE(nullptr, windowNode);
1656 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1657 std::vector<sptr<UnreliableWindowInfo>> infos;
1658 ASSERT_EQ(WMError::WM_OK, windowController_->GetUnreliableWindowInfo(1, infos));
1659 ASSERT_EQ(false, infos.empty());
1660 }
1661
1662 /**
1663 * @tc.name: GetUnreliableWindowInfo
1664 * @tc.desc: Window controller window type is not correct, window is invisible
1665 * @tc.type: FUNC
1666 */
1667 HWTEST_F(WindowControllerTest, GetUnreliableWindowInfo3, Function | SmallTest | Level3)
1668 {
1669 windowRoot_->windowNodeMap_.clear();
1670 sptr<WindowProperty> property = new WindowProperty();
1671 ASSERT_NE(nullptr, property);
1672 property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
1673 sptr<WindowNode> windowNode = new WindowNode(property);
1674 ASSERT_NE(nullptr, windowNode);
1675 windowNode->currentVisibility_ = true;
1676 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1677 std::vector<sptr<UnreliableWindowInfo>> infos;
1678 ASSERT_EQ(WMError::WM_OK, windowController_->GetUnreliableWindowInfo(0, infos));
1679 ASSERT_EQ(true, infos.empty());
1680
1681 windowRoot_->windowNodeMap_.clear();
1682 windowNode->currentVisibility_ = false;
1683 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1684 ASSERT_EQ(WMError::WM_OK, windowController_->GetUnreliableWindowInfo(0, infos));
1685 ASSERT_EQ(true, infos.empty());
1686 }
1687
1688 /**
1689 * @tc.name: UpdateProperty
1690 * @tc.desc: Window controller UpdateProperty property is nullptr
1691 * @tc.type: FUNC
1692 */
1693 HWTEST_F(WindowControllerTest, UpdateProperty1, Function | SmallTest | Level3)
1694 {
1695 windowRoot_->windowNodeMap_.clear();
1696 sptr<WindowProperty> property = nullptr;
1697 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_RECT;
1698 WMError res = windowController_->UpdateProperty(property, action);
1699 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, res);
1700 }
1701
1702 /**
1703 * @tc.name: UpdateProperty
1704 * @tc.desc: Window controller UpdateProperty windowRoot_ is nullptr
1705 * @tc.type: FUNC
1706 */
1707 HWTEST_F(WindowControllerTest, UpdateProperty2, Function | SmallTest | Level3)
1708 {
1709 windowRoot_->windowNodeMap_.clear();
1710 sptr<IWindow> window;
1711 sptr<WindowProperty> property = new WindowProperty();
1712 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1713 sptr<WindowNode> windowNode = new WindowNode(property);
1714 property->SetParentId(INVALID_WINDOW_ID);
1715 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1716
1717 uint32_t windowId = windowNode->GetWindowId();
1718 ASSERT_EQ(nullptr, windowRoot_->GetWindowNode(windowId));
1719 ASSERT_NE(nullptr, property);
1720
1721 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_RECT;
1722 WMError res = windowController_->UpdateProperty(property, action);
1723 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, res);
1724 }
1725
1726 /**
1727 * @tc.name: UpdateProperty
1728 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_RECT
1729 * @tc.type: FUNC
1730 */
1731 HWTEST_F(WindowControllerTest, UpdateProperty3, Function | SmallTest | Level3)
1732 {
1733 windowRoot_->windowNodeMap_.clear();
1734 sptr<IWindow> window;
1735 sptr<WindowProperty> property = new WindowProperty();
1736 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1737 sptr<WindowNode> windowNode = new WindowNode(property);
1738 property->SetParentId(INVALID_WINDOW_ID);
1739 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
1740
1741 uint32_t windowId = windowNode->GetWindowId();
1742 struct RSSurfaceNodeConfig surfaceNodeConfig;
1743 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty3";
1744 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1745 ASSERT_EQ(WMError::WM_OK,
1746 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1747 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
1748 ASSERT_NE(nullptr, property);
1749
1750 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_RECT;
1751 WMError res = windowController_->UpdateProperty(property, action);
1752 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1753
1754 windowNode->SetWindowRect({50, 50, 50, 50});
1755 windowNode->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1756 res = windowController_->UpdateProperty(property, action);
1757 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1758
1759 property->SetWindowType(WindowType::WINDOW_TYPE_STATUS_BAR);
1760 property->SetWindowSizeChangeReason(WindowSizeChangeReason::UNDEFINED);
1761 res = windowController_->UpdateProperty(property, action);
1762 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1763
1764 property->SetWindowSizeChangeReason(WindowSizeChangeReason::RESIZE);
1765 res = windowController_->UpdateProperty(property, action);
1766 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1767
1768 property->SetWindowSizeChangeReason(WindowSizeChangeReason::MOVE);
1769 res = windowController_->UpdateProperty(property, action);
1770 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1771
1772 property->SetWindowSizeChangeReason(WindowSizeChangeReason::DRAG_MOVE);
1773 res = windowController_->UpdateProperty(property, action);
1774 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1775 }
1776
1777 /**
1778 * @tc.name: UpdateProperty
1779 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_MODE
1780 * @tc.type: FUNC
1781 */
1782 HWTEST_F(WindowControllerTest, UpdateProperty4, Function | SmallTest | Level3)
1783 {
1784 windowRoot_->windowNodeMap_.clear();
1785 sptr<IWindow> window;
1786 sptr<WindowProperty> property = new WindowProperty();
1787 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1788 sptr<WindowNode> windowNode = new WindowNode(property);
1789 property->SetParentId(INVALID_WINDOW_ID);
1790 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1791 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
1792
1793 uint32_t windowId = windowNode->GetWindowId();
1794 struct RSSurfaceNodeConfig surfaceNodeConfig;
1795 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty4";
1796 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1797 ASSERT_EQ(WMError::WM_OK,
1798 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1799
1800 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
1801 ASSERT_NE(nullptr, property);
1802 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_MODE;
1803 WMError res = windowController_->UpdateProperty(property, action);
1804 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1805 }
1806
1807 /**
1808 * @tc.name: UpdateProperty
1809 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_FLAGS
1810 * @tc.type: FUNC
1811 */
1812 HWTEST_F(WindowControllerTest, UpdateProperty5, Function | SmallTest | Level3)
1813 {
1814 windowRoot_->windowNodeMap_.clear();
1815 sptr<IWindow> window;
1816 sptr<WindowProperty> property = new WindowProperty();
1817 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1818 sptr<WindowNode> windowNode = new WindowNode(property);
1819 property->SetParentId(INVALID_WINDOW_ID);
1820 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1821 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
1822
1823 uint32_t windowId = windowNode->GetWindowId();
1824 struct RSSurfaceNodeConfig surfaceNodeConfig;
1825 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty5";
1826 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1827 ASSERT_EQ(WMError::WM_OK,
1828 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1829
1830 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
1831 ASSERT_NE(nullptr, property);
1832 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_FLAGS;
1833 WMError res = windowController_->UpdateProperty(property, action);
1834 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1835 }
1836
1837 /**
1838 * @tc.name: UpdateProperty
1839 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_OTHER_PROPS
1840 * @tc.type: FUNC
1841 */
1842 HWTEST_F(WindowControllerTest, UpdateProperty6, Function | SmallTest | Level3)
1843 {
1844 windowRoot_->windowNodeMap_.clear();
1845 sptr<IWindow> window;
1846 sptr<WindowProperty> property = new WindowProperty();
1847 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1848 sptr<WindowNode> windowNode = new WindowNode(property);
1849 property->SetParentId(INVALID_WINDOW_ID);
1850 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1851 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
1852
1853 uint32_t windowId = windowNode->GetWindowId();
1854 struct RSSurfaceNodeConfig surfaceNodeConfig;
1855 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty6";
1856 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1857 ASSERT_EQ(WMError::WM_OK,
1858 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1859
1860 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
1861 ASSERT_NE(nullptr, property);
1862 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_OTHER_PROPS;
1863 WMError res = windowController_->UpdateProperty(property, action);
1864 ASSERT_EQ(WMError::WM_OK, res);
1865 }
1866
1867 /**
1868 * @tc.name: UpdateProperty
1869 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_FOCUSABLE
1870 * @tc.type: FUNC
1871 */
1872 HWTEST_F(WindowControllerTest, UpdateProperty7, Function | SmallTest | Level3)
1873 {
1874 windowRoot_->windowNodeMap_.clear();
1875 sptr<IWindow> window;
1876 sptr<WindowProperty> property = new WindowProperty();
1877 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1878 sptr<WindowNode> windowNode = new WindowNode(property);
1879 property->SetParentId(INVALID_WINDOW_ID);
1880 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1881 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
1882
1883 uint32_t windowId = windowNode->GetWindowId();
1884 struct RSSurfaceNodeConfig surfaceNodeConfig;
1885 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty7";
1886 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1887 ASSERT_EQ(WMError::WM_OK,
1888 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1889
1890 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
1891 ASSERT_NE(nullptr, property);
1892 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_FOCUSABLE;
1893 WMError res = windowController_->UpdateProperty(property, action);
1894 ASSERT_EQ(WMError::WM_OK, res);
1895 }
1896
1897 /**
1898 * @tc.name: UpdateProperty
1899 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_TOUCHABLE
1900 * @tc.type: FUNC
1901 */
1902 HWTEST_F(WindowControllerTest, UpdateProperty8, Function | SmallTest | Level3)
1903 {
1904 windowRoot_->windowNodeMap_.clear();
1905 sptr<IWindow> window;
1906 sptr<WindowProperty> property = new WindowProperty();
1907 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1908 sptr<WindowNode> windowNode = new WindowNode(property);
1909 property->SetParentId(INVALID_WINDOW_ID);
1910 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1911 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
1912
1913 uint32_t windowId = windowNode->GetWindowId();
1914 struct RSSurfaceNodeConfig surfaceNodeConfig;
1915 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty8";
1916 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1917 ASSERT_EQ(WMError::WM_OK,
1918 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1919
1920 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
1921 ASSERT_NE(nullptr, property);
1922 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_TOUCHABLE;
1923 WMError res = windowController_->UpdateProperty(property, action);
1924 ASSERT_EQ(WMError::WM_OK, res);
1925 }
1926
1927 /**
1928 * @tc.name: UpdateProperty
1929 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_CALLING_WINDOW
1930 * @tc.type: FUNC
1931 */
1932 HWTEST_F(WindowControllerTest, UpdateProperty9, Function | SmallTest | Level3)
1933 {
1934 windowRoot_->windowNodeMap_.clear();
1935 sptr<IWindow> window;
1936 sptr<WindowProperty> property = new WindowProperty();
1937 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1938 sptr<WindowNode> windowNode = new WindowNode(property);
1939 property->SetParentId(INVALID_WINDOW_ID);
1940 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1941 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
1942
1943 uint32_t windowId = windowNode->GetWindowId();
1944 struct RSSurfaceNodeConfig surfaceNodeConfig;
1945 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty9";
1946 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1947 ASSERT_EQ(WMError::WM_OK,
1948 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1949
1950 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
1951 ASSERT_NE(nullptr, property);
1952 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_CALLING_WINDOW;
1953 WMError res = windowController_->UpdateProperty(property, action);
1954 ASSERT_EQ(WMError::WM_OK, res);
1955 }
1956
1957 /**
1958 * @tc.name: UpdateProperty
1959 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_ORIENTATION
1960 * @tc.type: FUNC
1961 */
1962 HWTEST_F(WindowControllerTest, UpdateProperty10, Function | SmallTest | Level3)
1963 {
1964 windowRoot_->windowNodeMap_.clear();
1965 sptr<IWindow> window;
1966 sptr<WindowProperty> property = new WindowProperty();
1967 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1968 sptr<WindowNode> windowNode = new WindowNode(property);
1969 property->SetParentId(INVALID_WINDOW_ID);
1970 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1971 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
1972
1973 uint32_t windowId = windowNode->GetWindowId();
1974 struct RSSurfaceNodeConfig surfaceNodeConfig;
1975 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty10";
1976 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1977 ASSERT_EQ(WMError::WM_OK,
1978 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1979
1980 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
1981 ASSERT_NE(nullptr, property);
1982 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_ORIENTATION;
1983 WMError res = windowController_->UpdateProperty(property, action);
1984 ASSERT_EQ(WMError::WM_OK, res);
1985 }
1986
1987 /**
1988 * @tc.name: UpdateProperty
1989 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_TURN_SCREEN_ON
1990 * @tc.type: FUNC
1991 */
1992 HWTEST_F(WindowControllerTest, UpdateProperty11, Function | SmallTest | Level3)
1993 {
1994 windowRoot_->windowNodeMap_.clear();
1995 sptr<IWindow> window;
1996 sptr<WindowProperty> property = new WindowProperty();
1997 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1998 sptr<WindowNode> windowNode = new WindowNode(property);
1999 property->SetParentId(INVALID_WINDOW_ID);
2000 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2001 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2002
2003 uint32_t windowId = windowNode->GetWindowId();
2004 struct RSSurfaceNodeConfig surfaceNodeConfig;
2005 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty11";
2006 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2007 ASSERT_EQ(WMError::WM_OK,
2008 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2009
2010 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2011 ASSERT_NE(nullptr, property);
2012 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON;
2013 WMError res = windowController_->UpdateProperty(property, action);
2014 ASSERT_EQ(WMError::WM_OK, res);
2015 }
2016
2017 /**
2018 * @tc.name: UpdateProperty
2019 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_KEEP_SCREEN_ON
2020 * @tc.type: FUNC
2021 */
2022 HWTEST_F(WindowControllerTest, UpdateProperty12, Function | SmallTest | Level3)
2023 {
2024 windowRoot_->windowNodeMap_.clear();
2025 sptr<IWindow> window;
2026 sptr<WindowProperty> property = new WindowProperty();
2027 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2028 sptr<WindowNode> windowNode = new WindowNode(property);
2029 property->SetParentId(INVALID_WINDOW_ID);
2030 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2031 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2032
2033 uint32_t windowId = windowNode->GetWindowId();
2034 struct RSSurfaceNodeConfig surfaceNodeConfig;
2035 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty12";
2036 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2037 ASSERT_EQ(WMError::WM_OK,
2038 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2039
2040 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2041 ASSERT_NE(nullptr, property);
2042 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON;
2043 WMError res = windowController_->UpdateProperty(property, action);
2044 ASSERT_EQ(WMError::WM_OK, res);
2045 }
2046
2047 /**
2048 * @tc.name: UpdateProperty
2049 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_SET_BRIGHTNESS
2050 * @tc.type: FUNC
2051 */
2052 HWTEST_F(WindowControllerTest, UpdateProperty13, Function | SmallTest | Level3)
2053 {
2054 windowRoot_->windowNodeMap_.clear();
2055 sptr<IWindow> window;
2056 sptr<WindowProperty> property = new WindowProperty();
2057 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2058 sptr<WindowNode> windowNode = new WindowNode(property);
2059 property->SetParentId(INVALID_WINDOW_ID);
2060 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2061 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2062
2063 uint32_t windowId = windowNode->GetWindowId();
2064 struct RSSurfaceNodeConfig surfaceNodeConfig;
2065 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty13";
2066 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2067 ASSERT_EQ(WMError::WM_OK,
2068 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2069
2070 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2071 ASSERT_NE(nullptr, property);
2072 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_SET_BRIGHTNESS;
2073 WMError res = windowController_->UpdateProperty(property, action);
2074 ASSERT_EQ(WMError::WM_OK, res);
2075 }
2076
2077 /**
2078 * @tc.name: UpdateProperty
2079 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_MODE_SUPPORT_INFO
2080 * @tc.type: FUNC
2081 */
2082 HWTEST_F(WindowControllerTest, UpdateProperty14, Function | SmallTest | Level3)
2083 {
2084 windowRoot_->windowNodeMap_.clear();
2085 sptr<IWindow> window;
2086 sptr<WindowProperty> property = new WindowProperty();
2087 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2088 sptr<WindowNode> windowNode = new WindowNode(property);
2089 property->SetParentId(INVALID_WINDOW_ID);
2090 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2091 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2092
2093 uint32_t windowId = windowNode->GetWindowId();
2094 struct RSSurfaceNodeConfig surfaceNodeConfig;
2095 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty14";
2096 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2097 ASSERT_EQ(WMError::WM_OK,
2098 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2099
2100 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2101 ASSERT_NE(nullptr, property);
2102 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO;
2103 WMError res = windowController_->UpdateProperty(property, action);
2104 ASSERT_EQ(WMError::WM_OK, res);
2105 }
2106
2107 /**
2108 * @tc.name: UpdateProperty
2109 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_TOUCH_HOT_AREA
2110 * @tc.type: FUNC
2111 */
2112 HWTEST_F(WindowControllerTest, UpdateProperty15, Function | SmallTest | Level3)
2113 {
2114 windowRoot_->windowNodeMap_.clear();
2115 sptr<IWindow> window;
2116 sptr<WindowProperty> property = new WindowProperty();
2117 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2118 sptr<WindowNode> windowNode = new WindowNode(property);
2119 property->SetParentId(INVALID_WINDOW_ID);
2120 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2121 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2122
2123 uint32_t windowId = windowNode->GetWindowId();
2124 struct RSSurfaceNodeConfig surfaceNodeConfig;
2125 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty15";
2126 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2127 ASSERT_EQ(WMError::WM_OK,
2128 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2129
2130 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2131 ASSERT_NE(nullptr, property);
2132 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA;
2133 WMError res = windowController_->UpdateProperty(property, action);
2134 ASSERT_EQ(WMError::WM_OK, res);
2135 }
2136
2137 /**
2138 * @tc.name: UpdateProperty
2139 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_ANIMATION_FLAG
2140 * @tc.type: FUNC
2141 */
2142 HWTEST_F(WindowControllerTest, UpdateProperty16, Function | SmallTest | Level3)
2143 {
2144 windowRoot_->windowNodeMap_.clear();
2145 sptr<IWindow> window;
2146 sptr<WindowProperty> property = new WindowProperty();
2147 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2148 sptr<WindowNode> windowNode = new WindowNode(property);
2149 property->SetParentId(INVALID_WINDOW_ID);
2150 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2151 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2152
2153 uint32_t windowId = windowNode->GetWindowId();
2154 struct RSSurfaceNodeConfig surfaceNodeConfig;
2155 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty16";
2156 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2157 ASSERT_EQ(WMError::WM_OK,
2158 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2159
2160 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2161 ASSERT_NE(nullptr, property);
2162 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_ANIMATION_FLAG;
2163 WMError res = windowController_->UpdateProperty(property, action);
2164 ASSERT_EQ(WMError::WM_OK, res);
2165 }
2166
2167 /**
2168 * @tc.name: UpdateProperty
2169 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_TRANSFORM_PROPERTY
2170 * @tc.type: FUNC
2171 */
2172 HWTEST_F(WindowControllerTest, UpdateProperty17, Function | SmallTest | Level3)
2173 {
2174 windowRoot_->windowNodeMap_.clear();
2175 sptr<IWindow> window;
2176 sptr<WindowProperty> property = new WindowProperty();
2177 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2178 sptr<WindowNode> windowNode = new WindowNode(property);
2179 property->SetParentId(INVALID_WINDOW_ID);
2180 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2181 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2182
2183 uint32_t windowId = windowNode->GetWindowId();
2184 struct RSSurfaceNodeConfig surfaceNodeConfig;
2185 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty17";
2186 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2187 ASSERT_EQ(WMError::WM_OK,
2188 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2189
2190 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2191 ASSERT_NE(nullptr, property);
2192 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_TRANSFORM_PROPERTY;
2193 WMError res = windowController_->UpdateProperty(property, action);
2194 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
2195 }
2196
2197 /**
2198 * @tc.name: UpdateProperty
2199 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_ASPECT_RATIO
2200 * @tc.type: FUNC
2201 */
2202 HWTEST_F(WindowControllerTest, UpdateProperty19, Function | SmallTest | Level3)
2203 {
2204 windowRoot_->windowNodeMap_.clear();
2205 sptr<IWindow> window;
2206 sptr<WindowProperty> property = new WindowProperty();
2207 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2208 sptr<WindowNode> windowNode = new WindowNode(property);
2209 property->SetParentId(INVALID_WINDOW_ID);
2210 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2211 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2212
2213 uint32_t windowId = windowNode->GetWindowId();
2214 struct RSSurfaceNodeConfig surfaceNodeConfig;
2215 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty19";
2216 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2217 ASSERT_EQ(WMError::WM_OK,
2218 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2219
2220 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2221 ASSERT_NE(nullptr, property);
2222 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_ASPECT_RATIO;
2223 WMError res = windowController_->UpdateProperty(property, action);
2224 ASSERT_EQ(WMError::WM_OK, res);
2225 }
2226
2227 /**
2228 * @tc.name: UpdateProperty
2229 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_MAXIMIZE_STATE ResizeRect
2230 * @tc.type: FUNC
2231 */
2232 HWTEST_F(WindowControllerTest, UpdateProperty20, Function | SmallTest | Level3)
2233 {
2234 windowRoot_->windowNodeMap_.clear();
2235 sptr<IWindow> window;
2236 sptr<WindowProperty> property = new WindowProperty();
2237 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2238 sptr<WindowNode> windowNode = new WindowNode(property);
2239 property->SetParentId(INVALID_WINDOW_ID);
2240 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2241 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2242
2243 uint32_t windowId = windowNode->GetWindowId();
2244 struct RSSurfaceNodeConfig surfaceNodeConfig;
2245 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty20";
2246 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2247 ASSERT_EQ(WMError::WM_OK,
2248 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2249 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2250 ASSERT_NE(nullptr, property);
2251 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_MAXIMIZE_STATE;
2252 WMError res = windowController_->UpdateProperty(property, action);
2253 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
2254
2255 windowNode->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
2256 res = windowController_->UpdateProperty(property, action);
2257 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
2258
2259 property->SetWindowSizeChangeReason(WindowSizeChangeReason::MOVE);
2260 property->SetWindowType(WindowType::WINDOW_TYPE_DOCK_SLICE);
2261 res = windowController_->UpdateProperty(property, action);
2262 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
2263
2264 property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
2265 res = windowController_->UpdateProperty(property, action);
2266 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
2267
2268 property->SetWindowSizeChangeReason(WindowSizeChangeReason::RESIZE);
2269 res = windowController_->UpdateProperty(property, action);
2270 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
2271
2272 property->SetWindowSizeChangeReason(WindowSizeChangeReason::DRAG);
2273 res = windowController_->UpdateProperty(property, action);
2274 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
2275
2276 property->SetWindowSizeChangeReason(WindowSizeChangeReason::MAXIMIZE);
2277 res = windowController_->UpdateProperty(property, action);
2278 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
2279 }
2280
2281 /**
2282 * @tc.name: MinimizeWindowsByLauncher
2283 * @tc.desc: Window controller MinimizeWindowsByLauncher
2284 * @tc.type: FUNC
2285 */
2286 HWTEST_F(WindowControllerTest, MinimizeWindowsByLauncher, Function | SmallTest | Level3)
2287 {
2288 windowRoot_->windowNodeMap_.clear();
2289 sptr<IWindow> window;
2290 sptr<WindowProperty> property = new WindowProperty();
2291 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2292 sptr<WindowNode> windowNode = new WindowNode(property);
2293 property->SetParentId(INVALID_WINDOW_ID);
2294 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2295 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2296
2297 uint32_t windowId = windowNode->GetWindowId();
2298 struct RSSurfaceNodeConfig surfaceNodeConfig;
2299 surfaceNodeConfig.SurfaceNodeName = "MinimizeWindowsByLauncher";
2300 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2301
2302 std::vector<uint32_t> windowIds;
2303 windowIds.push_back(windowId);
2304 bool isAnimated = true;
2305 sptr<RSIWindowAnimationFinishedCallback> finishCallback;
2306 windowController_->MinimizeWindowsByLauncher(windowIds, isAnimated, finishCallback);
2307 isAnimated = false;
2308 windowController_->MinimizeWindowsByLauncher(windowIds, isAnimated, finishCallback);
2309 ASSERT_EQ(WMError::WM_OK,
2310 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2311 }
2312
2313 /**
2314 * @tc.name: OnScreenshot
2315 * @tc.desc: Window controller OnScreenshot
2316 * @tc.type: FUNC
2317 */
2318 HWTEST_F(WindowControllerTest, OnScreenshot, Function | SmallTest | Level3)
2319 {
2320 windowRoot_->windowNodeMap_.clear();
2321 sptr<IWindow> window;
2322 sptr<WindowProperty> property = new WindowProperty();
2323 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2324 sptr<WindowNode> windowNode = new WindowNode(property);
2325 property->SetParentId(INVALID_WINDOW_ID);
2326 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2327 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2328
2329 uint32_t windowId = windowNode->GetWindowId();
2330 struct RSSurfaceNodeConfig surfaceNodeConfig;
2331 surfaceNodeConfig.SurfaceNodeName = "OnScreenshot";
2332 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2333
2334 DisplayId displayId = static_cast<DisplayId>(windowId);
2335 windowController_->OnScreenshot(10);
2336 windowController_->OnScreenshot(displayId);
2337 ASSERT_EQ(WMError::WM_OK,
2338 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2339 }
2340 }
2341 }
2342 }
2343