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_OK, res);
1027 } else {
1028 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, 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 }
1062 }
1063
1064 /**
1065 * @tc.name: NotifyServerReadyToMoveOrDrag
1066 * @tc.desc: Window controller NotifyServerReadyToMoveOrDrag1
1067 * @tc.type: FUNC
1068 */
1069 HWTEST_F(WindowControllerTest, NotifyServerReadyToMoveOrDrag1, Function | SmallTest | Level3)
1070 {
1071 windowRoot_->windowNodeMap_.clear();
1072 sptr<IWindow> window;
1073 sptr<WindowProperty> property = new WindowProperty();
1074 property->SetMaximizeMode(MaximizeMode::MODE_AVOID_SYSTEM_BAR);
1075 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1076 sptr<WindowNode> windowNode = new WindowNode(property);
1077 property->SetParentId(INVALID_WINDOW_ID);
1078 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1079 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1080
1081 uint32_t windowId = windowNode->GetWindowId();
1082 struct RSSurfaceNodeConfig surfaceNodeConfig;
1083 surfaceNodeConfig.SurfaceNodeName = "NotifyServerReadyToMoveOrDrag1";
1084 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1085 ASSERT_EQ(WMError::WM_OK,
1086 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1087
1088 sptr<MoveDragProperty> moveDragProperty = new MoveDragProperty();
1089 WMError res = windowController_->NotifyServerReadyToMoveOrDrag(10, moveDragProperty);
1090 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, res);
1091
1092 ASSERT_EQ(windowNode->currentVisibility_, false);
1093 res = windowController_->NotifyServerReadyToMoveOrDrag(windowId, moveDragProperty);
1094 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1095
1096 windowNode->currentVisibility_ = true;
1097 res = windowController_->NotifyServerReadyToMoveOrDrag(windowId, moveDragProperty);
1098 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1099 }
1100
1101 /**
1102 * @tc.name: NotifyServerReadyToMoveOrDrag
1103 * @tc.desc: Window controller NotifyServerReadyToMoveOrDrag2
1104 * @tc.type: FUNC
1105 */
1106 HWTEST_F(WindowControllerTest, NotifyServerReadyToMoveOrDrag2, Function | SmallTest | Level3)
1107 {
1108 windowRoot_->windowNodeMap_.clear();
1109 sptr<IWindow> window;
1110 sptr<WindowProperty> property = new WindowProperty();
1111 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1112 sptr<WindowNode> windowNode = new WindowNode(property);
1113 property->SetParentId(INVALID_WINDOW_ID);
1114 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1115 windowNode->currentVisibility_ = true;
1116 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1117
1118 uint32_t windowId = windowNode->GetWindowId();
1119 struct RSSurfaceNodeConfig surfaceNodeConfig;
1120 surfaceNodeConfig.SurfaceNodeName = "NotifyServerReadyToMoveOrDrag2";
1121 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1122 ASSERT_EQ(WMError::WM_OK,
1123 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1124
1125 sptr<MoveDragProperty> moveDragProperty = new MoveDragProperty();
1126 moveDragProperty->startMoveFlag_ = false;
1127 moveDragProperty->startDragFlag_ = false;
1128 WMError res = windowController_->NotifyServerReadyToMoveOrDrag(windowId, moveDragProperty);
1129 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1130
1131 moveDragProperty->startMoveFlag_ = true;
1132 res = windowController_->NotifyServerReadyToMoveOrDrag(windowId, moveDragProperty);
1133 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1134
1135 moveDragProperty->startMoveFlag_ = false;
1136 moveDragProperty->startDragFlag_ = true;
1137 res = windowController_->NotifyServerReadyToMoveOrDrag(windowId, moveDragProperty);
1138 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1139
1140 moveDragProperty->startMoveFlag_ = true;
1141 res = windowController_->NotifyServerReadyToMoveOrDrag(windowId, moveDragProperty);
1142 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1143 }
1144
1145 /**
1146 * @tc.name: NotifyServerReadyToMoveOrDrag
1147 * @tc.desc: Window controller NotifyServerReadyToMoveOrDrag WindowType = WINDOW_TYPE_DOCK_SLICE
1148 * @tc.type: FUNC
1149 */
1150 HWTEST_F(WindowControllerTest, NotifyServerReadyToMoveOrDrag3, Function | SmallTest | Level3)
1151 {
1152 windowRoot_->windowNodeMap_.clear();
1153 sptr<IWindow> window;
1154 sptr<WindowProperty> property = new WindowProperty();
1155 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1156 sptr<WindowNode> windowNode = new WindowNode(property);
1157 property->SetParentId(INVALID_WINDOW_ID);
1158 property->SetWindowType(WindowType::WINDOW_TYPE_DOCK_SLICE);
1159 windowNode->currentVisibility_ = true;
1160 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1161
1162 uint32_t windowId = windowNode->GetWindowId();
1163 struct RSSurfaceNodeConfig surfaceNodeConfig;
1164 surfaceNodeConfig.SurfaceNodeName = "NotifyServerReadyToMoveOrDrag3";
1165 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1166 ASSERT_EQ(WMError::WM_OK,
1167 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1168
1169 sptr<MoveDragProperty> moveDragProperty = new MoveDragProperty();
1170 moveDragProperty->startMoveFlag_ = false;
1171 moveDragProperty->startDragFlag_ = false;
1172 WMError res = windowController_->NotifyServerReadyToMoveOrDrag(windowId, moveDragProperty);
1173 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1174
1175 moveDragProperty->startMoveFlag_ = true;
1176 res = windowController_->NotifyServerReadyToMoveOrDrag(windowId, moveDragProperty);
1177 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1178
1179 moveDragProperty->startMoveFlag_ = false;
1180 moveDragProperty->startDragFlag_ = true;
1181 res = windowController_->NotifyServerReadyToMoveOrDrag(windowId, moveDragProperty);
1182 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1183
1184 moveDragProperty->startMoveFlag_ = true;
1185 res = windowController_->NotifyServerReadyToMoveOrDrag(windowId, moveDragProperty);
1186 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1187 }
1188
1189 /**
1190 * @tc.name: ProcessPointDown
1191 * @tc.desc: Window controller ProcessPointDown
1192 * @tc.type: FUNC
1193 */
1194 HWTEST_F(WindowControllerTest, ProcessPointDown1, Function | SmallTest | Level3)
1195 {
1196 windowRoot_->windowNodeMap_.clear();
1197 sptr<IWindow> window;
1198 sptr<WindowProperty> property = new WindowProperty();
1199 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1200 sptr<WindowNode> windowNode = new WindowNode(property);
1201 property->SetParentId(INVALID_WINDOW_ID);
1202 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1203 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1204
1205 uint32_t windowId = windowNode->GetWindowId();
1206 struct RSSurfaceNodeConfig surfaceNodeConfig;
1207 surfaceNodeConfig.SurfaceNodeName = "ProcessPointDown1";
1208 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1209 ASSERT_EQ(WMError::WM_OK,
1210 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1211
1212 bool isPointDown = true;
1213 WMError res = windowController_->ProcessPointDown(10, isPointDown);
1214 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, res);
1215
1216 ASSERT_EQ(windowNode->currentVisibility_, false);
1217 res = windowController_->ProcessPointDown(windowId, isPointDown);
1218 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1219
1220 windowNode->currentVisibility_ = true;
1221 res = windowController_->ProcessPointDown(windowId, isPointDown);
1222 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1223 }
1224
1225 /**
1226 * @tc.name: ProcessPointDown
1227 * @tc.desc: Window controller ProcessPointDown
1228 * @tc.type: FUNC
1229 */
1230 HWTEST_F(WindowControllerTest, ProcessPointDown2, Function | SmallTest | Level3)
1231 {
1232 windowRoot_->windowNodeMap_.clear();
1233 sptr<IWindow> window;
1234 sptr<WindowProperty> property = new WindowProperty();
1235 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1236 sptr<WindowNode> windowNode = new WindowNode(property);
1237 property->SetParentId(INVALID_WINDOW_ID);
1238 property->SetWindowType(WindowType::WINDOW_TYPE_DOCK_SLICE);
1239 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1240
1241 uint32_t windowId = windowNode->GetWindowId();
1242 struct RSSurfaceNodeConfig surfaceNodeConfig;
1243 surfaceNodeConfig.SurfaceNodeName = "ProcessPointDown2";
1244 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1245 ASSERT_EQ(WMError::WM_OK,
1246 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1247
1248 bool isPointDown = true;
1249 windowNode->currentVisibility_ = true;
1250 WMError res = windowController_->ProcessPointDown(windowId, isPointDown);
1251 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1252
1253 isPointDown = false;
1254 res = windowController_->ProcessPointDown(windowId, isPointDown);
1255 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1256 }
1257
1258 /**
1259 * @tc.name: ProcessPointUp
1260 * @tc.desc: Window controller ProcessPointUp WindowType = WINDOW_TYPE_DOCK_SLICE
1261 * @tc.type: FUNC
1262 */
1263 HWTEST_F(WindowControllerTest, ProcessPointUp, Function | SmallTest | Level3)
1264 {
1265 windowRoot_->windowNodeMap_.clear();
1266 sptr<IWindow> window;
1267 sptr<WindowProperty> property = new WindowProperty();
1268 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1269 sptr<WindowNode> windowNode = new WindowNode(property);
1270 property->SetParentId(INVALID_WINDOW_ID);
1271 property->SetWindowType(WindowType::WINDOW_TYPE_DOCK_SLICE);
1272 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1273
1274 uint32_t windowId = windowNode->GetWindowId();
1275 struct RSSurfaceNodeConfig surfaceNodeConfig;
1276 surfaceNodeConfig.SurfaceNodeName = "ProcessPointUp";
1277 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1278 ASSERT_EQ(WMError::WM_OK,
1279 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1280
1281 WMError res = windowController_->ProcessPointUp(10);
1282 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, res);
1283
1284 res = windowController_->ProcessPointUp(windowId);
1285 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1286 }
1287
1288 /**
1289 * @tc.name: ProcessPointUp2
1290 * @tc.desc: Window controller ProcessPointUp2 WindowType = WINDOW_TYPE_APP_MAIN_WINDOW
1291 * @tc.type: FUNC
1292 */
1293 HWTEST_F(WindowControllerTest, ProcessPointUp2, Function | SmallTest | Level3)
1294 {
1295 windowRoot_->windowNodeMap_.clear();
1296 sptr<IWindow> window;
1297 sptr<WindowProperty> property = new WindowProperty();
1298 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1299 sptr<WindowNode> windowNode = new WindowNode(property);
1300 property->SetParentId(INVALID_WINDOW_ID);
1301 property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
1302 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1303
1304 uint32_t windowId = windowNode->GetWindowId();
1305 struct RSSurfaceNodeConfig surfaceNodeConfig;
1306 surfaceNodeConfig.SurfaceNodeName = "ProcessPointUp2";
1307 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1308 ASSERT_EQ(WMError::WM_OK,
1309 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1310
1311 WMError res = windowController_->ProcessPointUp(windowId);
1312 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1313 }
1314
1315 /**
1316 * @tc.name: ProcessPointUp3
1317 * @tc.desc: Window controller ProcessPointUp3 WindowType = APP_WINDOW_BASE
1318 * @tc.type: FUNC
1319 */
1320 HWTEST_F(WindowControllerTest, ProcessPointUp3, Function | SmallTest | Level3)
1321 {
1322 windowRoot_->windowNodeMap_.clear();
1323 sptr<IWindow> window;
1324 sptr<WindowProperty> property = new WindowProperty();
1325 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1326 sptr<WindowNode> windowNode = new WindowNode(property);
1327 property->SetParentId(INVALID_WINDOW_ID);
1328 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1329 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1330
1331 uint32_t windowId = windowNode->GetWindowId();
1332 struct RSSurfaceNodeConfig surfaceNodeConfig;
1333 surfaceNodeConfig.SurfaceNodeName = "ProcessPointUp3";
1334 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1335 ASSERT_EQ(WMError::WM_OK,
1336 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1337
1338 WMError res = windowController_->ProcessPointUp(windowId);
1339 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1340 }
1341
1342 /**
1343 * @tc.name: InterceptInputEventToServer
1344 * @tc.desc: Window controller InterceptInputEventToServer
1345 * @tc.type: FUNC
1346 */
1347 HWTEST_F(WindowControllerTest, InterceptInputEventToServer, Function | SmallTest | Level3)
1348 {
1349 windowRoot_->windowNodeMap_.clear();
1350 sptr<IWindow> window;
1351 sptr<WindowProperty> property = new WindowProperty();
1352 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1353 sptr<WindowNode> windowNode = new WindowNode(property);
1354 property->SetParentId(INVALID_WINDOW_ID);
1355 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1356 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1357
1358 uint32_t windowId = windowNode->GetWindowId();
1359 struct RSSurfaceNodeConfig surfaceNodeConfig;
1360 surfaceNodeConfig.SurfaceNodeName = "InterceptInputEventToServer";
1361 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1362 ASSERT_EQ(WMError::WM_OK,
1363 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1364
1365 WMError res = windowController_->InterceptInputEventToServer(10);
1366 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, res);
1367
1368 res = windowController_->InterceptInputEventToServer(windowId);
1369 ASSERT_EQ(WMError::WM_OK, res);
1370 }
1371
1372 /**
1373 * @tc.name: RecoverInputEventToClient
1374 * @tc.desc: Window controller RecoverInputEventToClient
1375 * @tc.type: FUNC
1376 */
1377 HWTEST_F(WindowControllerTest, RecoverInputEventToClient, Function | SmallTest | Level3)
1378 {
1379 windowRoot_->windowNodeMap_.clear();
1380 sptr<IWindow> window;
1381 sptr<WindowProperty> property = new WindowProperty();
1382 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1383 sptr<WindowNode> windowNode = new WindowNode(property);
1384 property->SetParentId(INVALID_WINDOW_ID);
1385 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1386 windowNode->SetInputEventCallingPid(2048);
1387 windowNode->SetCallingPid(2048);
1388 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1389
1390 uint32_t windowId = windowNode->GetWindowId();
1391 struct RSSurfaceNodeConfig surfaceNodeConfig;
1392 surfaceNodeConfig.SurfaceNodeName = "RecoverInputEventToClient";
1393 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1394 ASSERT_EQ(WMError::WM_OK,
1395 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1396
1397 WMError res = windowController_->RecoverInputEventToClient(10);
1398 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, res);
1399
1400 res = windowController_->RecoverInputEventToClient(windowId);
1401 ASSERT_EQ(WMError::WM_OK, res);
1402 }
1403
1404 /**
1405 * @tc.name: RecoverInputEventToClient2
1406 * @tc.desc: Window controller RecoverInputEventToClient2
1407 * @tc.type: FUNC
1408 */
1409 HWTEST_F(WindowControllerTest, RecoverInputEventToClient2, Function | SmallTest | Level3)
1410 {
1411 windowRoot_->windowNodeMap_.clear();
1412 sptr<IWindow> window;
1413 sptr<WindowProperty> property = new WindowProperty();
1414 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1415 sptr<WindowNode> windowNode = new WindowNode(property);
1416 property->SetParentId(INVALID_WINDOW_ID);
1417 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1418 windowNode->SetInputEventCallingPid(2048);
1419 windowNode->SetCallingPid(1024);
1420 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1421
1422 uint32_t windowId = windowNode->GetWindowId();
1423 struct RSSurfaceNodeConfig surfaceNodeConfig;
1424 surfaceNodeConfig.SurfaceNodeName = "RecoverInputEventToClient2";
1425 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1426 ASSERT_EQ(WMError::WM_OK,
1427 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1428
1429 WMError res = windowController_->RecoverInputEventToClient(windowId);
1430 ASSERT_EQ(WMError::WM_OK, res);
1431 }
1432
1433 /**
1434 * @tc.name: RecoverDefaultMouseStyle
1435 * @tc.desc: Window controller RecoverDefaultMouseStyle
1436 * @tc.type: FUNC
1437 */
1438 HWTEST_F(WindowControllerTest, RecoverDefaultMouseStyle, Function | SmallTest | Level3)
1439 {
1440 windowRoot_->windowNodeMap_.clear();
1441 sptr<IWindow> window;
1442 sptr<WindowProperty> property = new WindowProperty();
1443 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1444 sptr<WindowNode> windowNode = new WindowNode(property);
1445 property->SetParentId(INVALID_WINDOW_ID);
1446 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1447 windowNode->SetInputEventCallingPid(2048);
1448 windowNode->SetCallingPid(1024);
1449 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1450
1451 uint32_t windowId = windowNode->GetWindowId();
1452 windowController_->RecoverDefaultMouseStyle(windowId);
1453 struct RSSurfaceNodeConfig surfaceNodeConfig;
1454 surfaceNodeConfig.SurfaceNodeName = "RecoverDefaultMouseStyle";
1455 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1456 ASSERT_EQ(WMError::WM_OK,
1457 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1458 }
1459
1460 /**
1461 * @tc.name: DispatchKeyEvent
1462 * @tc.desc: Window controller DispatchKeyEvent
1463 * @tc.type: FUNC
1464 */
1465 HWTEST_F(WindowControllerTest, DispatchKeyEvent, Function | SmallTest | Level3)
1466 {
1467 windowRoot_->windowNodeMap_.clear();
1468 sptr<IWindow> window;
1469 sptr<WindowProperty> property = new WindowProperty();
1470 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1471 sptr<WindowNode> windowNode = new WindowNode(property);
1472 property->SetParentId(INVALID_WINDOW_ID);
1473 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1474 windowNode->SetInputEventCallingPid(2048);
1475 windowNode->SetCallingPid(2048);
1476 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1477
1478 uint32_t windowId = windowNode->GetWindowId();
1479 struct RSSurfaceNodeConfig surfaceNodeConfig;
1480 surfaceNodeConfig.SurfaceNodeName = "DispatchKeyEvent";
1481 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1482 std::shared_ptr<MMI::KeyEvent> event = nullptr;
1483 windowController_->DispatchKeyEvent(10, event);
1484 windowController_->DispatchKeyEvent(windowId, event);
1485 ASSERT_EQ(WMError::WM_OK,
1486 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1487 }
1488
1489 /**
1490 * @tc.name: DispatchKeyEvent
1491 * @tc.desc: Window controller DispatchKeyEvent WindowType = WINDOW_TYPE_APP_COMPONENT
1492 * @tc.type: FUNC
1493 */
1494 HWTEST_F(WindowControllerTest, DispatchKeyEvent2, Function | SmallTest | Level3)
1495 {
1496 windowRoot_->windowNodeMap_.clear();
1497 sptr<IWindow> window;
1498 sptr<WindowProperty> property = new WindowProperty();
1499 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1500 sptr<WindowNode> windowNode = new WindowNode(property);
1501 property->SetParentId(INVALID_WINDOW_ID);
1502 property->SetWindowType(WindowType::WINDOW_TYPE_APP_COMPONENT);
1503 windowNode->SetInputEventCallingPid(2048);
1504 windowNode->SetCallingPid(2048);
1505 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1506
1507 uint32_t windowId = windowNode->GetWindowId();
1508 struct RSSurfaceNodeConfig surfaceNodeConfig;
1509 surfaceNodeConfig.SurfaceNodeName = "DispatchKeyEvent2";
1510 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1511
1512 std::shared_ptr<MMI::KeyEvent> event = nullptr;
1513 windowController_->DispatchKeyEvent(windowId, event);
1514 ASSERT_EQ(WMError::WM_ERROR_INVALID_PARENT,
1515 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1516 }
1517
1518 /**
1519 * @tc.name: NotifyWindowClientPointUp
1520 * @tc.desc: Window controller NotifyWindowClientPointUp
1521 * @tc.type: FUNC
1522 */
1523 HWTEST_F(WindowControllerTest, NotifyWindowClientPointUp, Function | SmallTest | Level3)
1524 {
1525 windowRoot_->windowNodeMap_.clear();
1526 sptr<IWindow> window;
1527 sptr<WindowProperty> property = new WindowProperty();
1528 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1529 sptr<WindowNode> windowNode = new WindowNode(property);
1530 property->SetParentId(INVALID_WINDOW_ID);
1531 property->SetWindowType(WindowType::WINDOW_TYPE_DOCK_SLICE);
1532 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1533
1534 uint32_t windowId = windowNode->GetWindowId();
1535 struct RSSurfaceNodeConfig surfaceNodeConfig;
1536 surfaceNodeConfig.SurfaceNodeName = "ProcessPointUp";
1537 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1538 ASSERT_EQ(WMError::WM_OK,
1539 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1540
1541 std::shared_ptr<MMI::PointerEvent> pointerEvent = nullptr;
1542 WMError res = windowController_->NotifyWindowClientPointUp(10, pointerEvent);
1543 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, res);
1544
1545 res = windowController_->NotifyWindowClientPointUp(windowId, pointerEvent);
1546 ASSERT_EQ(WMError::WM_OK, res);
1547 }
1548
1549 /**
1550 * @tc.name: MinimizeAllAppWindows
1551 * @tc.desc: Window controller MinimizeAllAppWindows
1552 * @tc.type: FUNC
1553 */
1554 HWTEST_F(WindowControllerTest, MinimizeAllAppWindows, Function | SmallTest | Level3)
1555 {
1556 windowRoot_->windowNodeMap_.clear();
1557 sptr<IWindow> window;
1558 sptr<WindowProperty> property = new WindowProperty();
1559 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1560 sptr<WindowNode> windowNode = new WindowNode(property);
1561 property->SetParentId(INVALID_WINDOW_ID);
1562 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1563 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1564
1565 uint32_t windowId = windowNode->GetWindowId();
1566 windowController_->MinimizeAllAppWindows(0);
1567 struct RSSurfaceNodeConfig surfaceNodeConfig;
1568 surfaceNodeConfig.SurfaceNodeName = "MinimizeAllAppWindows";
1569 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1570 ASSERT_EQ(WMError::WM_OK,
1571 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1572 }
1573
1574 /**
1575 * @tc.name: ToggleShownStateForAllAppWindows
1576 * @tc.desc: Window controller ToggleShownStateForAllAppWindows
1577 * @tc.type: FUNC
1578 */
1579 HWTEST_F(WindowControllerTest, ToggleShownStateForAllAppWindows, Function | SmallTest | Level3)
1580 {
1581 windowRoot_->windowNodeMap_.clear();
1582 sptr<IWindow> window;
1583 sptr<WindowProperty> property = new WindowProperty();
1584 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1585 sptr<WindowNode> windowNode = new WindowNode(property);
1586 property->SetParentId(INVALID_WINDOW_ID);
1587 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1588 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1589
1590 uint32_t windowId = windowNode->GetWindowId();
1591 struct RSSurfaceNodeConfig surfaceNodeConfig;
1592 surfaceNodeConfig.SurfaceNodeName = "ToggleShownStateForAllAppWindows";
1593 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1594 ASSERT_EQ(WMError::WM_OK,
1595 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1596
1597 WMError res = windowController_->ToggleShownStateForAllAppWindows();
1598 ASSERT_EQ(WMError::WM_OK, res);
1599 }
1600
1601 /**
1602 * @tc.name: GetUnreliableWindowInfo
1603 * @tc.desc: Window controller window is unreliable window
1604 * @tc.type: FUNC
1605 */
1606 HWTEST_F(WindowControllerTest, GetUnreliableWindowInfo1, Function | SmallTest | Level3)
1607 {
1608 windowRoot_->windowNodeMap_.clear();
1609 sptr<WindowProperty> property = new WindowProperty();
1610 ASSERT_NE(nullptr, property);
1611 property->SetWindowType(WindowType::WINDOW_TYPE_TOAST);
1612 sptr<WindowNode> windowNode = new WindowNode(property);
1613 ASSERT_NE(nullptr, windowNode);
1614 windowNode->currentVisibility_ = true;
1615 windowRoot_->windowNodeMap_.insert(std::make_pair(windowNode->GetWindowId(), windowNode));
1616 std::vector<sptr<UnreliableWindowInfo>> infos;
1617 ASSERT_EQ(WMError::WM_OK, windowController_->GetUnreliableWindowInfo(0, infos));
1618 EXPECT_EQ(1, infos.size());
1619
1620 sptr<WindowProperty> property2 = new WindowProperty();
1621 ASSERT_NE(nullptr, property2);
1622 property2->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
1623 sptr<WindowNode> windowNode2 = new WindowNode(property2);
1624 ASSERT_NE(nullptr, windowNode2);
1625 windowNode2->currentVisibility_ = true;
1626 windowRoot_->windowNodeMap_.insert(std::make_pair(windowNode2->GetWindowId(), windowNode2));
1627 ASSERT_EQ(WMError::WM_OK, windowController_->GetUnreliableWindowInfo(0, infos));
1628 EXPECT_EQ(2, infos.size());
1629
1630 sptr<WindowProperty> property3 = new WindowProperty();
1631 ASSERT_NE(nullptr, property3);
1632 property3->SetParentId(windowNode->GetWindowId());
1633 property3->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1634 sptr<WindowNode> windowNode3 = new WindowNode(property3);
1635 ASSERT_NE(nullptr, windowNode3);
1636 windowNode3->currentVisibility_ = true;
1637 windowRoot_->windowNodeMap_.insert(std::make_pair(windowNode3->GetWindowId(), windowNode3));
1638 ASSERT_EQ(WMError::WM_OK, windowController_->GetUnreliableWindowInfo(0, infos));
1639 EXPECT_EQ(3, infos.size());
1640 }
1641
1642 /**
1643 * @tc.name: GetUnreliableWindowInfo
1644 * @tc.desc: Window controller windowId is equal to the parameter
1645 * @tc.type: FUNC
1646 */
1647 HWTEST_F(WindowControllerTest, GetUnreliableWindowInfo2, Function | SmallTest | Level3)
1648 {
1649 windowRoot_->windowNodeMap_.clear();
1650 sptr<WindowProperty> property = new WindowProperty();
1651 ASSERT_NE(nullptr, property);
1652 sptr<WindowNode> windowNode = new WindowNode(property);
1653 ASSERT_NE(nullptr, windowNode);
1654 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1655 std::vector<sptr<UnreliableWindowInfo>> infos;
1656 ASSERT_EQ(WMError::WM_OK, windowController_->GetUnreliableWindowInfo(1, infos));
1657 ASSERT_EQ(false, infos.empty());
1658 }
1659
1660 /**
1661 * @tc.name: GetUnreliableWindowInfo
1662 * @tc.desc: Window controller window type is not correct, window is invisible
1663 * @tc.type: FUNC
1664 */
1665 HWTEST_F(WindowControllerTest, GetUnreliableWindowInfo3, Function | SmallTest | Level3)
1666 {
1667 windowRoot_->windowNodeMap_.clear();
1668 sptr<WindowProperty> property = new WindowProperty();
1669 ASSERT_NE(nullptr, property);
1670 property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
1671 sptr<WindowNode> windowNode = new WindowNode(property);
1672 ASSERT_NE(nullptr, windowNode);
1673 windowNode->currentVisibility_ = true;
1674 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1675 std::vector<sptr<UnreliableWindowInfo>> infos;
1676 ASSERT_EQ(WMError::WM_OK, windowController_->GetUnreliableWindowInfo(0, infos));
1677 ASSERT_EQ(true, infos.empty());
1678
1679 windowRoot_->windowNodeMap_.clear();
1680 windowNode->currentVisibility_ = false;
1681 windowRoot_->windowNodeMap_.insert(std::make_pair(1, windowNode));
1682 ASSERT_EQ(WMError::WM_OK, windowController_->GetUnreliableWindowInfo(0, infos));
1683 ASSERT_EQ(true, infos.empty());
1684 }
1685
1686 /**
1687 * @tc.name: UpdateProperty
1688 * @tc.desc: Window controller UpdateProperty property is nullptr
1689 * @tc.type: FUNC
1690 */
1691 HWTEST_F(WindowControllerTest, UpdateProperty1, Function | SmallTest | Level3)
1692 {
1693 windowRoot_->windowNodeMap_.clear();
1694 sptr<WindowProperty> property = nullptr;
1695 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_RECT;
1696 WMError res = windowController_->UpdateProperty(property, action);
1697 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, res);
1698 }
1699
1700 /**
1701 * @tc.name: UpdateProperty
1702 * @tc.desc: Window controller UpdateProperty windowRoot_ is nullptr
1703 * @tc.type: FUNC
1704 */
1705 HWTEST_F(WindowControllerTest, UpdateProperty2, Function | SmallTest | Level3)
1706 {
1707 windowRoot_->windowNodeMap_.clear();
1708 sptr<IWindow> window;
1709 sptr<WindowProperty> property = new WindowProperty();
1710 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1711 sptr<WindowNode> windowNode = new WindowNode(property);
1712 property->SetParentId(INVALID_WINDOW_ID);
1713 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1714
1715 uint32_t windowId = windowNode->GetWindowId();
1716 ASSERT_EQ(nullptr, windowRoot_->GetWindowNode(windowId));
1717 ASSERT_NE(nullptr, property);
1718
1719 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_RECT;
1720 WMError res = windowController_->UpdateProperty(property, action);
1721 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, res);
1722 }
1723
1724 /**
1725 * @tc.name: UpdateProperty
1726 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_RECT
1727 * @tc.type: FUNC
1728 */
1729 HWTEST_F(WindowControllerTest, UpdateProperty3, Function | SmallTest | Level3)
1730 {
1731 windowRoot_->windowNodeMap_.clear();
1732 sptr<IWindow> window;
1733 sptr<WindowProperty> property = new WindowProperty();
1734 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1735 sptr<WindowNode> windowNode = new WindowNode(property);
1736 property->SetParentId(INVALID_WINDOW_ID);
1737 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
1738
1739 uint32_t windowId = windowNode->GetWindowId();
1740 struct RSSurfaceNodeConfig surfaceNodeConfig;
1741 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty3";
1742 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1743 ASSERT_EQ(WMError::WM_OK,
1744 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1745 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
1746 ASSERT_NE(nullptr, property);
1747
1748 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_RECT;
1749 WMError res = windowController_->UpdateProperty(property, action);
1750 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
1751
1752 windowNode->SetWindowRect({50, 50, 50, 50});
1753 windowNode->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1754 res = windowController_->UpdateProperty(property, action);
1755 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1756
1757 property->SetWindowType(WindowType::WINDOW_TYPE_STATUS_BAR);
1758 property->SetWindowSizeChangeReason(WindowSizeChangeReason::UNDEFINED);
1759 res = windowController_->UpdateProperty(property, action);
1760 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1761
1762 property->SetWindowSizeChangeReason(WindowSizeChangeReason::RESIZE);
1763 res = windowController_->UpdateProperty(property, action);
1764 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1765
1766 property->SetWindowSizeChangeReason(WindowSizeChangeReason::MOVE);
1767 res = windowController_->UpdateProperty(property, action);
1768 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1769
1770 property->SetWindowSizeChangeReason(WindowSizeChangeReason::DRAG_MOVE);
1771 res = windowController_->UpdateProperty(property, action);
1772 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1773 }
1774
1775 /**
1776 * @tc.name: UpdateProperty
1777 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_MODE
1778 * @tc.type: FUNC
1779 */
1780 HWTEST_F(WindowControllerTest, UpdateProperty4, Function | SmallTest | Level3)
1781 {
1782 windowRoot_->windowNodeMap_.clear();
1783 sptr<IWindow> window;
1784 sptr<WindowProperty> property = new WindowProperty();
1785 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1786 sptr<WindowNode> windowNode = new WindowNode(property);
1787 property->SetParentId(INVALID_WINDOW_ID);
1788 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1789 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
1790
1791 uint32_t windowId = windowNode->GetWindowId();
1792 struct RSSurfaceNodeConfig surfaceNodeConfig;
1793 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty4";
1794 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1795 ASSERT_EQ(WMError::WM_OK,
1796 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1797
1798 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
1799 ASSERT_NE(nullptr, property);
1800 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_MODE;
1801 WMError res = windowController_->UpdateProperty(property, action);
1802 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1803 }
1804
1805 /**
1806 * @tc.name: UpdateProperty
1807 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_FLAGS
1808 * @tc.type: FUNC
1809 */
1810 HWTEST_F(WindowControllerTest, UpdateProperty5, Function | SmallTest | Level3)
1811 {
1812 windowRoot_->windowNodeMap_.clear();
1813 sptr<IWindow> window;
1814 sptr<WindowProperty> property = new WindowProperty();
1815 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1816 sptr<WindowNode> windowNode = new WindowNode(property);
1817 property->SetParentId(INVALID_WINDOW_ID);
1818 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1819 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
1820
1821 uint32_t windowId = windowNode->GetWindowId();
1822 struct RSSurfaceNodeConfig surfaceNodeConfig;
1823 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty5";
1824 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1825 ASSERT_EQ(WMError::WM_OK,
1826 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1827
1828 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
1829 ASSERT_NE(nullptr, property);
1830 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_FLAGS;
1831 WMError res = windowController_->UpdateProperty(property, action);
1832 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
1833 }
1834
1835 /**
1836 * @tc.name: UpdateProperty
1837 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_OTHER_PROPS
1838 * @tc.type: FUNC
1839 */
1840 HWTEST_F(WindowControllerTest, UpdateProperty6, Function | SmallTest | Level3)
1841 {
1842 windowRoot_->windowNodeMap_.clear();
1843 sptr<IWindow> window;
1844 sptr<WindowProperty> property = new WindowProperty();
1845 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1846 sptr<WindowNode> windowNode = new WindowNode(property);
1847 property->SetParentId(INVALID_WINDOW_ID);
1848 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1849 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
1850
1851 uint32_t windowId = windowNode->GetWindowId();
1852 struct RSSurfaceNodeConfig surfaceNodeConfig;
1853 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty6";
1854 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1855 ASSERT_EQ(WMError::WM_OK,
1856 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1857
1858 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
1859 ASSERT_NE(nullptr, property);
1860 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_OTHER_PROPS;
1861 WMError res = windowController_->UpdateProperty(property, action);
1862 ASSERT_EQ(WMError::WM_OK, res);
1863 }
1864
1865 /**
1866 * @tc.name: UpdateProperty
1867 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_FOCUSABLE
1868 * @tc.type: FUNC
1869 */
1870 HWTEST_F(WindowControllerTest, UpdateProperty7, Function | SmallTest | Level3)
1871 {
1872 windowRoot_->windowNodeMap_.clear();
1873 sptr<IWindow> window;
1874 sptr<WindowProperty> property = new WindowProperty();
1875 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1876 sptr<WindowNode> windowNode = new WindowNode(property);
1877 property->SetParentId(INVALID_WINDOW_ID);
1878 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1879 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
1880
1881 uint32_t windowId = windowNode->GetWindowId();
1882 struct RSSurfaceNodeConfig surfaceNodeConfig;
1883 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty7";
1884 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1885 ASSERT_EQ(WMError::WM_OK,
1886 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1887
1888 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
1889 ASSERT_NE(nullptr, property);
1890 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_FOCUSABLE;
1891 WMError res = windowController_->UpdateProperty(property, action);
1892 ASSERT_EQ(WMError::WM_OK, res);
1893 }
1894
1895 /**
1896 * @tc.name: UpdateProperty
1897 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_TOUCHABLE
1898 * @tc.type: FUNC
1899 */
1900 HWTEST_F(WindowControllerTest, UpdateProperty8, Function | SmallTest | Level3)
1901 {
1902 windowRoot_->windowNodeMap_.clear();
1903 sptr<IWindow> window;
1904 sptr<WindowProperty> property = new WindowProperty();
1905 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1906 sptr<WindowNode> windowNode = new WindowNode(property);
1907 property->SetParentId(INVALID_WINDOW_ID);
1908 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1909 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
1910
1911 uint32_t windowId = windowNode->GetWindowId();
1912 struct RSSurfaceNodeConfig surfaceNodeConfig;
1913 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty8";
1914 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1915 ASSERT_EQ(WMError::WM_OK,
1916 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1917
1918 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
1919 ASSERT_NE(nullptr, property);
1920 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_TOUCHABLE;
1921 WMError res = windowController_->UpdateProperty(property, action);
1922 ASSERT_EQ(WMError::WM_OK, res);
1923 }
1924
1925 /**
1926 * @tc.name: UpdateProperty
1927 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_CALLING_WINDOW
1928 * @tc.type: FUNC
1929 */
1930 HWTEST_F(WindowControllerTest, UpdateProperty9, Function | SmallTest | Level3)
1931 {
1932 windowRoot_->windowNodeMap_.clear();
1933 sptr<IWindow> window;
1934 sptr<WindowProperty> property = new WindowProperty();
1935 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1936 sptr<WindowNode> windowNode = new WindowNode(property);
1937 property->SetParentId(INVALID_WINDOW_ID);
1938 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1939 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
1940
1941 uint32_t windowId = windowNode->GetWindowId();
1942 struct RSSurfaceNodeConfig surfaceNodeConfig;
1943 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty9";
1944 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1945 ASSERT_EQ(WMError::WM_OK,
1946 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1947
1948 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
1949 ASSERT_NE(nullptr, property);
1950 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_CALLING_WINDOW;
1951 WMError res = windowController_->UpdateProperty(property, action);
1952 ASSERT_EQ(WMError::WM_OK, res);
1953 }
1954
1955 /**
1956 * @tc.name: UpdateProperty
1957 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_ORIENTATION
1958 * @tc.type: FUNC
1959 */
1960 HWTEST_F(WindowControllerTest, UpdateProperty10, Function | SmallTest | Level3)
1961 {
1962 windowRoot_->windowNodeMap_.clear();
1963 sptr<IWindow> window;
1964 sptr<WindowProperty> property = new WindowProperty();
1965 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1966 sptr<WindowNode> windowNode = new WindowNode(property);
1967 property->SetParentId(INVALID_WINDOW_ID);
1968 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1969 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
1970
1971 uint32_t windowId = windowNode->GetWindowId();
1972 struct RSSurfaceNodeConfig surfaceNodeConfig;
1973 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty10";
1974 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
1975 ASSERT_EQ(WMError::WM_OK,
1976 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
1977
1978 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
1979 ASSERT_NE(nullptr, property);
1980 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_ORIENTATION;
1981 WMError res = windowController_->UpdateProperty(property, action);
1982 ASSERT_EQ(WMError::WM_OK, res);
1983 }
1984
1985 /**
1986 * @tc.name: UpdateProperty
1987 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_TURN_SCREEN_ON
1988 * @tc.type: FUNC
1989 */
1990 HWTEST_F(WindowControllerTest, UpdateProperty11, Function | SmallTest | Level3)
1991 {
1992 windowRoot_->windowNodeMap_.clear();
1993 sptr<IWindow> window;
1994 sptr<WindowProperty> property = new WindowProperty();
1995 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
1996 sptr<WindowNode> windowNode = new WindowNode(property);
1997 property->SetParentId(INVALID_WINDOW_ID);
1998 property->SetWindowType(WindowType::APP_WINDOW_BASE);
1999 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2000
2001 uint32_t windowId = windowNode->GetWindowId();
2002 struct RSSurfaceNodeConfig surfaceNodeConfig;
2003 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty11";
2004 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2005 ASSERT_EQ(WMError::WM_OK,
2006 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2007
2008 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2009 ASSERT_NE(nullptr, property);
2010 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON;
2011 WMError res = windowController_->UpdateProperty(property, action);
2012 ASSERT_EQ(WMError::WM_OK, res);
2013 }
2014
2015 /**
2016 * @tc.name: UpdateProperty
2017 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_KEEP_SCREEN_ON
2018 * @tc.type: FUNC
2019 */
2020 HWTEST_F(WindowControllerTest, UpdateProperty12, Function | SmallTest | Level3)
2021 {
2022 windowRoot_->windowNodeMap_.clear();
2023 sptr<IWindow> window;
2024 sptr<WindowProperty> property = new WindowProperty();
2025 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2026 sptr<WindowNode> windowNode = new WindowNode(property);
2027 property->SetParentId(INVALID_WINDOW_ID);
2028 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2029 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2030
2031 uint32_t windowId = windowNode->GetWindowId();
2032 struct RSSurfaceNodeConfig surfaceNodeConfig;
2033 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty12";
2034 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2035 ASSERT_EQ(WMError::WM_OK,
2036 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2037
2038 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2039 ASSERT_NE(nullptr, property);
2040 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON;
2041 WMError res = windowController_->UpdateProperty(property, action);
2042 ASSERT_EQ(WMError::WM_OK, res);
2043 }
2044
2045
2046 /**
2047 * @tc.name: UpdateProperty
2048 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_SET_BRIGHTNESS
2049 * @tc.type: FUNC
2050 */
2051 HWTEST_F(WindowControllerTest, UpdateProperty13, Function | SmallTest | Level3)
2052 {
2053 windowRoot_->windowNodeMap_.clear();
2054 sptr<IWindow> window;
2055 sptr<WindowProperty> property = new WindowProperty();
2056 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2057 sptr<WindowNode> windowNode = new WindowNode(property);
2058 property->SetParentId(INVALID_WINDOW_ID);
2059 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2060 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2061
2062 uint32_t windowId = windowNode->GetWindowId();
2063 struct RSSurfaceNodeConfig surfaceNodeConfig;
2064 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty13";
2065 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2066 ASSERT_EQ(WMError::WM_OK,
2067 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2068
2069 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2070 ASSERT_NE(nullptr, property);
2071 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_SET_BRIGHTNESS;
2072 WMError res = windowController_->UpdateProperty(property, action);
2073 ASSERT_EQ(WMError::WM_OK, res);
2074 }
2075
2076 /**
2077 * @tc.name: UpdateProperty
2078 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_MODE_SUPPORT_INFO
2079 * @tc.type: FUNC
2080 */
2081 HWTEST_F(WindowControllerTest, UpdateProperty14, Function | SmallTest | Level3)
2082 {
2083 windowRoot_->windowNodeMap_.clear();
2084 sptr<IWindow> window;
2085 sptr<WindowProperty> property = new WindowProperty();
2086 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2087 sptr<WindowNode> windowNode = new WindowNode(property);
2088 property->SetParentId(INVALID_WINDOW_ID);
2089 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2090 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2091
2092 uint32_t windowId = windowNode->GetWindowId();
2093 struct RSSurfaceNodeConfig surfaceNodeConfig;
2094 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty14";
2095 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2096 ASSERT_EQ(WMError::WM_OK,
2097 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2098
2099 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2100 ASSERT_NE(nullptr, property);
2101 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO;
2102 WMError res = windowController_->UpdateProperty(property, action);
2103 ASSERT_EQ(WMError::WM_OK, res);
2104 }
2105
2106 /**
2107 * @tc.name: UpdateProperty
2108 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_TOUCH_HOT_AREA
2109 * @tc.type: FUNC
2110 */
2111 HWTEST_F(WindowControllerTest, UpdateProperty15, Function | SmallTest | Level3)
2112 {
2113 windowRoot_->windowNodeMap_.clear();
2114 sptr<IWindow> window;
2115 sptr<WindowProperty> property = new WindowProperty();
2116 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2117 sptr<WindowNode> windowNode = new WindowNode(property);
2118 property->SetParentId(INVALID_WINDOW_ID);
2119 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2120 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2121
2122 uint32_t windowId = windowNode->GetWindowId();
2123 struct RSSurfaceNodeConfig surfaceNodeConfig;
2124 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty15";
2125 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2126 ASSERT_EQ(WMError::WM_OK,
2127 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2128
2129 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2130 ASSERT_NE(nullptr, property);
2131 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA;
2132 WMError res = windowController_->UpdateProperty(property, action);
2133 ASSERT_EQ(WMError::WM_OK, res);
2134 }
2135
2136 /**
2137 * @tc.name: UpdateProperty
2138 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_ANIMATION_FLAG
2139 * @tc.type: FUNC
2140 */
2141 HWTEST_F(WindowControllerTest, UpdateProperty16, Function | SmallTest | Level3)
2142 {
2143 windowRoot_->windowNodeMap_.clear();
2144 sptr<IWindow> window;
2145 sptr<WindowProperty> property = new WindowProperty();
2146 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2147 sptr<WindowNode> windowNode = new WindowNode(property);
2148 property->SetParentId(INVALID_WINDOW_ID);
2149 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2150 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2151
2152 uint32_t windowId = windowNode->GetWindowId();
2153 struct RSSurfaceNodeConfig surfaceNodeConfig;
2154 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty16";
2155 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2156 ASSERT_EQ(WMError::WM_OK,
2157 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2158
2159 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2160 ASSERT_NE(nullptr, property);
2161 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_ANIMATION_FLAG;
2162 WMError res = windowController_->UpdateProperty(property, action);
2163 ASSERT_EQ(WMError::WM_OK, res);
2164 }
2165
2166 /**
2167 * @tc.name: UpdateProperty
2168 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_TRANSFORM_PROPERTY
2169 * @tc.type: FUNC
2170 */
2171 HWTEST_F(WindowControllerTest, UpdateProperty17, Function | SmallTest | Level3)
2172 {
2173 windowRoot_->windowNodeMap_.clear();
2174 sptr<IWindow> window;
2175 sptr<WindowProperty> property = new WindowProperty();
2176 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2177 sptr<WindowNode> windowNode = new WindowNode(property);
2178 property->SetParentId(INVALID_WINDOW_ID);
2179 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2180 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2181
2182 uint32_t windowId = windowNode->GetWindowId();
2183 struct RSSurfaceNodeConfig surfaceNodeConfig;
2184 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty17";
2185 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2186 ASSERT_EQ(WMError::WM_OK,
2187 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2188
2189 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2190 ASSERT_NE(nullptr, property);
2191 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_TRANSFORM_PROPERTY;
2192 WMError res = windowController_->UpdateProperty(property, action);
2193 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
2194 }
2195
2196 /**
2197 * @tc.name: UpdateProperty
2198 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_ASPECT_RATIO
2199 * @tc.type: FUNC
2200 */
2201 HWTEST_F(WindowControllerTest, UpdateProperty19, Function | SmallTest | Level3)
2202 {
2203 windowRoot_->windowNodeMap_.clear();
2204 sptr<IWindow> window;
2205 sptr<WindowProperty> property = new WindowProperty();
2206 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2207 sptr<WindowNode> windowNode = new WindowNode(property);
2208 property->SetParentId(INVALID_WINDOW_ID);
2209 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2210 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2211
2212 uint32_t windowId = windowNode->GetWindowId();
2213 struct RSSurfaceNodeConfig surfaceNodeConfig;
2214 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty19";
2215 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2216 ASSERT_EQ(WMError::WM_OK,
2217 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2218
2219 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2220 ASSERT_NE(nullptr, property);
2221 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_ASPECT_RATIO;
2222 WMError res = windowController_->UpdateProperty(property, action);
2223 ASSERT_EQ(WMError::WM_OK, res);
2224 }
2225
2226 /**
2227 * @tc.name: UpdateProperty
2228 * @tc.desc: Window controller UpdateProperty ACTION_UPDATE_MAXIMIZE_STATE ResizeRect
2229 * @tc.type: FUNC
2230 */
2231 HWTEST_F(WindowControllerTest, UpdateProperty20, Function | SmallTest | Level3)
2232 {
2233 windowRoot_->windowNodeMap_.clear();
2234 sptr<IWindow> window;
2235 sptr<WindowProperty> property = new WindowProperty();
2236 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2237 sptr<WindowNode> windowNode = new WindowNode(property);
2238 property->SetParentId(INVALID_WINDOW_ID);
2239 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2240 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2241
2242 uint32_t windowId = windowNode->GetWindowId();
2243 struct RSSurfaceNodeConfig surfaceNodeConfig;
2244 surfaceNodeConfig.SurfaceNodeName = "UpdateProperty20";
2245 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2246 ASSERT_EQ(WMError::WM_OK,
2247 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2248 ASSERT_NE(nullptr, windowRoot_->GetWindowNode(windowId));
2249 ASSERT_NE(nullptr, property);
2250 PropertyChangeAction action = PropertyChangeAction::ACTION_UPDATE_MAXIMIZE_STATE;
2251 WMError res = windowController_->UpdateProperty(property, action);
2252 ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, res);
2253
2254 windowNode->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
2255 res = windowController_->UpdateProperty(property, action);
2256 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
2257
2258 property->SetWindowSizeChangeReason(WindowSizeChangeReason::MOVE);
2259 property->SetWindowType(WindowType::WINDOW_TYPE_DOCK_SLICE);
2260 res = windowController_->UpdateProperty(property, action);
2261 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
2262
2263 property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
2264 res = windowController_->UpdateProperty(property, action);
2265 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
2266
2267 property->SetWindowSizeChangeReason(WindowSizeChangeReason::RESIZE);
2268 res = windowController_->UpdateProperty(property, action);
2269 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
2270
2271 property->SetWindowSizeChangeReason(WindowSizeChangeReason::DRAG);
2272 res = windowController_->UpdateProperty(property, action);
2273 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
2274
2275 property->SetWindowSizeChangeReason(WindowSizeChangeReason::MAXIMIZE);
2276 res = windowController_->UpdateProperty(property, action);
2277 ASSERT_EQ(WMError::WM_ERROR_INVALID_DISPLAY, res);
2278 }
2279
2280 /**
2281 * @tc.name: MinimizeWindowsByLauncher
2282 * @tc.desc: Window controller MinimizeWindowsByLauncher
2283 * @tc.type: FUNC
2284 */
2285 HWTEST_F(WindowControllerTest, MinimizeWindowsByLauncher, Function | SmallTest | Level3)
2286 {
2287 windowRoot_->windowNodeMap_.clear();
2288 sptr<IWindow> window;
2289 sptr<WindowProperty> property = new WindowProperty();
2290 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2291 sptr<WindowNode> windowNode = new WindowNode(property);
2292 property->SetParentId(INVALID_WINDOW_ID);
2293 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2294 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2295
2296 uint32_t windowId = windowNode->GetWindowId();
2297 struct RSSurfaceNodeConfig surfaceNodeConfig;
2298 surfaceNodeConfig.SurfaceNodeName = "MinimizeWindowsByLauncher";
2299 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2300
2301 std::vector<uint32_t> windowIds;
2302 windowIds.push_back(windowId);
2303 bool isAnimated = true;
2304 sptr<RSIWindowAnimationFinishedCallback> finishCallback;
2305 windowController_->MinimizeWindowsByLauncher(windowIds, isAnimated, finishCallback);
2306 isAnimated = false;
2307 windowController_->MinimizeWindowsByLauncher(windowIds, isAnimated, finishCallback);
2308 ASSERT_EQ(WMError::WM_OK,
2309 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2310 }
2311
2312 /**
2313 * @tc.name: OnScreenshot
2314 * @tc.desc: Window controller OnScreenshot
2315 * @tc.type: FUNC
2316 */
2317 HWTEST_F(WindowControllerTest, OnScreenshot, Function | SmallTest | Level3)
2318 {
2319 windowRoot_->windowNodeMap_.clear();
2320 sptr<IWindow> window;
2321 sptr<WindowProperty> property = new WindowProperty();
2322 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
2323 sptr<WindowNode> windowNode = new WindowNode(property);
2324 property->SetParentId(INVALID_WINDOW_ID);
2325 property->SetWindowType(WindowType::APP_WINDOW_BASE);
2326 windowRoot_->windowNodeMap_.insert(std::make_pair(0, windowNode));
2327
2328 uint32_t windowId = windowNode->GetWindowId();
2329 struct RSSurfaceNodeConfig surfaceNodeConfig;
2330 surfaceNodeConfig.SurfaceNodeName = "OnScreenshot";
2331 surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig, RSSurfaceNodeType::DEFAULT);
2332
2333 DisplayId displayId = static_cast<DisplayId>(windowId);
2334 windowController_->OnScreenshot(10);
2335 windowController_->OnScreenshot(displayId);
2336 ASSERT_EQ(WMError::WM_OK,
2337 windowController_->CreateWindow(window, property, surfaceNode, windowId, nullptr, 0, 0));
2338 }
2339 }
2340 }
2341 }
2342