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