1 /* 2 * Copyright (c) 2024 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 18 #include "input_scene_board_judgement.h" 19 #include "input_manager_impl.h" 20 #include "multimodal_event_handler.h" 21 #include "multimodal_input_connect_manager.h" 22 23 #undef MMI_LOG_TAG 24 #define MMI_LOG_TAG "InputManagerImplTest" 25 26 namespace OHOS { 27 namespace MMI { 28 namespace { 29 using namespace testing::ext; 30 } // namespace 31 32 class InputManagerImplTest : public testing::Test { 33 public: SetUpTestCase(void)34 static void SetUpTestCase(void) {} TearDownTestCase(void)35 static void TearDownTestCase(void) {} 36 }; 37 38 /** 39 * @tc.name: InputManagerImplTest_IsValiadWindowAreas 40 * @tc.desc: Test IsValiadWindowAreas 41 * @tc.type: FUNC 42 * @tc.require: 43 */ 44 HWTEST_F(InputManagerImplTest, InputManagerImplTest_IsValiadWindowAreas, TestSize.Level1) 45 { 46 CALL_TEST_DEBUG; 47 WindowInfo windowInfo; 48 windowInfo.action = WINDOW_UPDATE_ACTION::UNKNOWN; 49 Rect rect; 50 rect.x = 100; 51 windowInfo.defaultHotAreas.push_back(rect); 52 windowInfo.pointerHotAreas.push_back(rect); 53 windowInfo.pointerChangeAreas.push_back(100); 54 windowInfo.transform.push_back(100.5); 55 std::vector<WindowInfo> windows; 56 windows.push_back(windowInfo); 57 EXPECT_FALSE(InputMgrImpl.IsValiadWindowAreas(windows)); 58 59 windows[0].pointerChangeAreas.clear(); 60 EXPECT_FALSE(InputMgrImpl.IsValiadWindowAreas(windows)); 61 } 62 63 /** 64 * @tc.name: InputManagerImplTest_PrintWindowInfo 65 * @tc.desc: Test PrintWindowInfo 66 * @tc.type: FUNC 67 * @tc.require: 68 */ 69 HWTEST_F(InputManagerImplTest, InputManagerImplTest_PrintWindowInfo, TestSize.Level1) 70 { 71 CALL_TEST_DEBUG; 72 WindowInfo windowInfo; 73 windowInfo.action = WINDOW_UPDATE_ACTION::UNKNOWN; 74 Rect rect { 75 .x = 100, 76 .y = 100, 77 .width = 300, 78 .height = 300, 79 }; 80 windowInfo.id = 10; 81 windowInfo.pid = 1000; 82 windowInfo.uid = 100; 83 windowInfo.area.x = 100; 84 windowInfo.area.y = 100; 85 windowInfo.area.height = 200; 86 windowInfo.area.width = 200; 87 windowInfo.agentWindowId = 50; 88 windowInfo.flags = 0; 89 windowInfo.displayId = 30; 90 windowInfo.zOrder = 60; 91 windowInfo.defaultHotAreas.push_back(rect); 92 windowInfo.pointerHotAreas.push_back(rect); 93 windowInfo.pointerChangeAreas.push_back(100); 94 windowInfo.transform.push_back(100.5); 95 std::vector<WindowInfo> windows; 96 windows.push_back(windowInfo); 97 EXPECT_NO_FATAL_FAILURE(InputMgrImpl.PrintWindowInfo(windows)); 98 } 99 100 /** 101 * @tc.name: InputManagerImplTest_RecoverPointerEvent 102 * @tc.desc: Test RecoverPointerEvent 103 * @tc.type: FUNC 104 * @tc.require: 105 */ 106 HWTEST_F(InputManagerImplTest, InputManagerImplTest_RecoverPointerEvent, TestSize.Level1) 107 { 108 CALL_TEST_DEBUG; 109 InputMgrImpl.lastPointerEvent_ = PointerEvent::Create(); 110 ASSERT_NE(InputMgrImpl.lastPointerEvent_, nullptr); 111 std::initializer_list<int32_t> pointerActionPullEvents { PointerEvent::POINTER_ACTION_MOVE, 112 PointerEvent::POINTER_ACTION_UP }; 113 InputMgrImpl.lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_UP); 114 EXPECT_FALSE(InputMgrImpl.RecoverPointerEvent(pointerActionPullEvents, PointerEvent::POINTER_ACTION_UP)); 115 116 PointerEvent::PointerItem item; 117 item.SetPointerId(1); 118 InputMgrImpl.lastPointerEvent_->SetPointerId(1); 119 InputMgrImpl.lastPointerEvent_->AddPointerItem(item); 120 EXPECT_TRUE(InputMgrImpl.RecoverPointerEvent(pointerActionPullEvents, PointerEvent::POINTER_ACTION_UP)); 121 122 InputMgrImpl.lastPointerEvent_->SetPointerId(2); 123 EXPECT_FALSE(InputMgrImpl.RecoverPointerEvent(pointerActionPullEvents, PointerEvent::POINTER_ACTION_UP)); 124 } 125 126 /** 127 * @tc.name: InputManagerImplTest_OnDisconnected_01 128 * @tc.desc: Test OnDisconnected 129 * @tc.type: FUNC 130 * @tc.require: 131 */ 132 HWTEST_F(InputManagerImplTest, InputManagerImplTest_OnDisconnected_01, TestSize.Level1) 133 { 134 CALL_TEST_DEBUG; 135 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create(); 136 ASSERT_NE(pointerEvent, nullptr); 137 pointerEvent->pointerAction_ = PointerEvent::POINTER_ACTION_UP; 138 139 EXPECT_NO_FATAL_FAILURE(InputMgrImpl.OnDisconnected()); 140 } 141 142 /** 143 * @tc.name: InputManagerImplTest_OnDisconnected_02 144 * @tc.desc: Test OnDisconnected 145 * @tc.type: FUNC 146 * @tc.require: 147 */ 148 HWTEST_F(InputManagerImplTest, InputManagerImplTest_OnDisconnected_02, TestSize.Level1) 149 { 150 CALL_TEST_DEBUG; 151 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create(); 152 ASSERT_NE(pointerEvent, nullptr); 153 pointerEvent->pointerAction_ = PointerEvent::POINTER_ACTION_PULL_UP; 154 155 EXPECT_NO_FATAL_FAILURE(InputMgrImpl.OnDisconnected()); 156 } 157 158 /** 159 * @tc.name: InputManagerImplTest_OnKeyEvent_01 160 * @tc.desc: Test OnKeyEvent 161 * @tc.type: FUNC 162 * @tc.require: 163 */ 164 HWTEST_F(InputManagerImplTest, InputManagerImplTest_OnKeyEvent_01, TestSize.Level1) 165 { 166 CALL_TEST_DEBUG; 167 std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create(); 168 ASSERT_NE(keyEvent, nullptr); 169 170 MMIClientPtr client = MMIEventHdl.GetMMIClient(); 171 EXPECT_NO_FATAL_FAILURE(InputMgrImpl.OnKeyEvent(keyEvent)); 172 } 173 174 /** 175 * @tc.name: InputManagerImplTest_IsValiadWindowAreas_01 176 * @tc.desc: Test IsValiadWindowAreas 177 * @tc.type: FUNC 178 * @tc.require: 179 */ 180 HWTEST_F(InputManagerImplTest, InputManagerImplTest_IsValiadWindowAreas_01, TestSize.Level1) 181 { 182 CALL_TEST_DEBUG; 183 std::vector<WindowInfo> windows; 184 WindowInfo window; 185 window.action = WINDOW_UPDATE_ACTION::DEL; 186 187 bool ret = InputMgrImpl.IsValiadWindowAreas(windows); 188 EXPECT_TRUE(ret); 189 } 190 191 /** 192 * @tc.name: InputManagerImplTest_IsValiadWindowAreas_02 193 * @tc.desc: Test IsValiadWindowAreas 194 * @tc.type: FUNC 195 * @tc.require: 196 */ 197 HWTEST_F(InputManagerImplTest, InputManagerImplTest_IsValiadWindowAreas_02, TestSize.Level1) 198 { 199 CALL_TEST_DEBUG; 200 std::vector<WindowInfo> windows; 201 WindowInfo window; 202 window.action = WINDOW_UPDATE_ACTION::CHANGE; 203 204 bool ret = InputMgrImpl.IsValiadWindowAreas(windows); 205 EXPECT_TRUE(ret); 206 } 207 208 /** 209 * @tc.name: InputManagerImplTest_SetCustomCursor_01 210 * @tc.desc: Test SetCustomCursor 211 * @tc.type: FUNC 212 * @tc.require: 213 */ 214 HWTEST_F(InputManagerImplTest, InputManagerImplTest_SetCustomCursor_01, TestSize.Level1) 215 { 216 CALL_TEST_DEBUG; 217 int32_t windowId = 2; 218 int32_t focusX = 3; 219 int32_t focusY = 4; 220 void* pixelMap = nullptr; 221 int32_t winPid = InputMgrImpl.GetWindowPid(windowId); 222 int32_t ret = InputMgrImpl.SetCustomCursor(windowId, focusX, focusY, pixelMap); 223 EXPECT_NE(ret, RET_OK); 224 } 225 226 /** 227 * @tc.name: InputManagerImplTest_SetMouseHotSpot_01 228 * @tc.desc: Test SetMouseHotSpot 229 * @tc.type: FUNC 230 * @tc.require: 231 */ 232 HWTEST_F(InputManagerImplTest, InputManagerImplTest_SetMouseHotSpot_01, TestSize.Level1) 233 { 234 CALL_TEST_DEBUG; 235 int32_t windowId = 2; 236 int32_t hotSpotX = 3; 237 int32_t hotSpotY = 4; 238 239 int32_t winPid = InputMgrImpl.GetWindowPid(windowId); 240 int32_t ret = InputMgrImpl.SetMouseHotSpot(windowId, hotSpotX, hotSpotY); 241 EXPECT_EQ(ret, RET_ERR); 242 } 243 244 /** 245 * @tc.name: InputManagerImplTest_SetMouseHotSpot_02 246 * @tc.desc: Test SetMouseHotSpot 247 * @tc.type: FUNC 248 * @tc.require: 249 */ 250 HWTEST_F(InputManagerImplTest, InputManagerImplTest_SetMouseHotSpot_02, TestSize.Level1) 251 { 252 CALL_TEST_DEBUG; 253 int32_t windowId = -5; 254 int32_t hotSpotX = 2; 255 int32_t hotSpotY = 3; 256 257 int32_t winPid = InputMgrImpl.GetWindowPid(windowId); 258 EXPECT_FALSE(winPid != -1); 259 int32_t ret = InputMgrImpl.SetMouseHotSpot(windowId, hotSpotX, hotSpotY); 260 EXPECT_EQ(ret, RET_ERR); 261 } 262 263 /** 264 * @tc.name: InputManagerImplTest_ReAddInputEventFilter_01 265 * @tc.desc: Test ReAddInputEventFilter 266 * @tc.type: FUNC 267 * @tc.require: 268 */ 269 HWTEST_F(InputManagerImplTest, InputManagerImplTest_ReAddInputEventFilter_01, TestSize.Level1) 270 { 271 CALL_TEST_DEBUG; 272 EXPECT_FALSE(InputMgrImpl.eventFilterServices_.size() > 4); 273 ASSERT_NO_FATAL_FAILURE(InputMgrImpl.ReAddInputEventFilter()); 274 } 275 276 /** 277 * @tc.name: InputManagerImplTest_IsPointerVisible_01 278 * @tc.desc: Test IsPointerVisible 279 * @tc.type: FUNC 280 * @tc.require: 281 */ 282 HWTEST_F(InputManagerImplTest, InputManagerImplTest_IsPointerVisible_01, TestSize.Level1) 283 { 284 CALL_TEST_DEBUG; 285 bool ret = InputMgrImpl.IsPointerVisible(); 286 EXPECT_TRUE(ret); 287 } 288 289 /** 290 * @tc.name: InputManagerImplTest_IsPointerVisible_02 291 * @tc.desc: Test IsPointerVisible 292 * @tc.type: FUNC 293 * @tc.require: 294 */ 295 HWTEST_F(InputManagerImplTest, InputManagerImplTest_IsPointerVisible_02, TestSize.Level1) 296 { 297 CALL_TEST_DEBUG; 298 bool ret = InputMgrImpl.IsPointerVisible(); 299 EXPECT_TRUE(ret); 300 } 301 302 /** 303 * @tc.name: InputManagerImplTest_SetPointerColor_01 304 * @tc.desc: Test SetPointerColor 305 * @tc.type: FUNC 306 * @tc.require: 307 */ 308 HWTEST_F(InputManagerImplTest, InputManagerImplTest_SetPointerColor_01, TestSize.Level1) 309 { 310 CALL_TEST_DEBUG; 311 int32_t color = 6; 312 int32_t ret = InputMgrImpl.SetPointerColor(color); 313 EXPECT_EQ(ret, RET_OK); 314 } 315 316 /** 317 * @tc.name: InputManagerImplTest_SetPointerColor_02 318 * @tc.desc: Test SetPointerColor 319 * @tc.type: FUNC 320 * @tc.require: 321 */ 322 HWTEST_F(InputManagerImplTest, InputManagerImplTest_SetPointerColor_02, TestSize.Level1) 323 { 324 CALL_TEST_DEBUG; 325 int32_t color = -10; 326 int32_t ret = InputMgrImpl.SetPointerColor(color); 327 EXPECT_EQ(ret, RET_OK); 328 } 329 330 /** 331 * @tc.name: InputManagerImplTest_SetPointerSpeed_01 332 * @tc.desc: Test SetPointerSpeed 333 * @tc.type: FUNC 334 * @tc.require: 335 */ 336 HWTEST_F(InputManagerImplTest, InputManagerImplTest_SetPointerSpeed_01, TestSize.Level1) 337 { 338 CALL_TEST_DEBUG; 339 int32_t speed = 10; 340 int32_t ret2 = InputMgrImpl.SetPointerSpeed(speed); 341 EXPECT_EQ(ret2, RET_OK); 342 } 343 344 /** 345 * @tc.name: InputManagerImplTest_EnableCombineKey_01 346 * @tc.desc: Test EnableCombineKey 347 * @tc.type: FUNC 348 * @tc.require: 349 */ 350 HWTEST_F(InputManagerImplTest, InputManagerImplTest_EnableCombineKey_01, TestSize.Level1) 351 { 352 CALL_TEST_DEBUG; 353 bool enable = true; 354 int32_t ret2 = InputMgrImpl.EnableCombineKey(enable); 355 EXPECT_EQ(ret2, RET_OK); 356 } 357 358 /** 359 * @tc.name: InputManagerImplTest_EnableCombineKey_02 360 * @tc.desc: Test EnableCombineKey 361 * @tc.type: FUNC 362 * @tc.require: 363 */ 364 HWTEST_F(InputManagerImplTest, InputManagerImplTest_EnableCombineKey_02, TestSize.Level1) 365 { 366 CALL_TEST_DEBUG; 367 bool enable = false; 368 int32_t ret2 = InputMgrImpl.EnableCombineKey(enable); 369 EXPECT_EQ(ret2, RET_OK); 370 } 371 372 /** 373 * @tc.name: InputManagerImplTest_OnConnected_01 374 * @tc.desc: Test OnConnected 375 * @tc.type: FUNC 376 * @tc.require: 377 */ 378 HWTEST_F(InputManagerImplTest, InputManagerImplTest_OnConnected_01, TestSize.Level1) 379 { 380 CALL_TEST_DEBUG; 381 EXPECT_TRUE(InputMgrImpl.displayGroupInfo_.windowsInfo.empty()); 382 EXPECT_TRUE(InputMgrImpl.displayGroupInfo_.displaysInfo.empty()); 383 ASSERT_NO_FATAL_FAILURE(InputMgrImpl.OnConnected()); 384 } 385 386 /** 387 * @tc.name: InputManagerImplTest_OnConnected_02 388 * @tc.desc: Test OnConnected 389 * @tc.type: FUNC 390 * @tc.require: 391 */ 392 HWTEST_F(InputManagerImplTest, InputManagerImplTest_OnConnected_02, TestSize.Level1) 393 { 394 CALL_TEST_DEBUG; 395 InputMgrImpl.displayGroupInfo_.width = 50; 396 InputMgrImpl.displayGroupInfo_.height = 60; 397 WindowInfo windowInfo; 398 windowInfo.id = 1; 399 windowInfo.pid = 2; 400 InputMgrImpl.displayGroupInfo_.windowsInfo.push_back(windowInfo); 401 EXPECT_FALSE(InputMgrImpl.displayGroupInfo_.windowsInfo.empty()); 402 403 DisplayInfo displayInfo; 404 displayInfo.width = 10; 405 displayInfo.height = 20; 406 InputMgrImpl.displayGroupInfo_.displaysInfo.push_back(displayInfo); 407 EXPECT_FALSE(InputMgrImpl.displayGroupInfo_.displaysInfo.empty()); 408 409 EXPECT_TRUE(InputMgrImpl.anrObservers_.empty()); 410 ASSERT_NO_FATAL_FAILURE(InputMgrImpl.OnConnected()); 411 } 412 413 /** 414 * @tc.name: InputManagerImplTest_OnConnected_03 415 * @tc.desc: Test OnConnected 416 * @tc.type: FUNC 417 * @tc.require: 418 */ 419 HWTEST_F(InputManagerImplTest, InputManagerImplTest_OnConnected_03, TestSize.Level1) 420 { 421 CALL_TEST_DEBUG; 422 DisplayInfo displayInfo; 423 displayInfo.width = 10; 424 displayInfo.height = 20; 425 InputMgrImpl.displayGroupInfo_.displaysInfo.push_back(displayInfo); 426 EXPECT_FALSE(InputMgrImpl.displayGroupInfo_.displaysInfo.empty()); 427 ASSERT_NO_FATAL_FAILURE(InputMgrImpl.OnConnected()); 428 } 429 430 /** 431 * @tc.name: InputManagerImplTest_OnConnected_04 432 * @tc.desc: Test OnConnected 433 * @tc.type: FUNC 434 * @tc.require: 435 */ 436 HWTEST_F(InputManagerImplTest, InputManagerImplTest_OnConnected_04, TestSize.Level1) 437 { 438 CALL_TEST_DEBUG; 439 InputMgrImpl.displayGroupInfo_.width = 50; 440 InputMgrImpl.displayGroupInfo_.height = 60; 441 WindowInfo windowInfo; 442 windowInfo.id = 1; 443 windowInfo.pid = 2; 444 InputMgrImpl.displayGroupInfo_.windowsInfo.push_back(windowInfo); 445 EXPECT_FALSE(InputMgrImpl.displayGroupInfo_.windowsInfo.empty()); 446 ASSERT_NO_FATAL_FAILURE(InputMgrImpl.OnConnected()); 447 } 448 449 /** 450 * @tc.name: InputManagerImplTest_SetPixelMapData_01 451 * @tc.desc: Test SetPixelMapData 452 * @tc.type: FUNC 453 * @tc.require: 454 */ 455 HWTEST_F(InputManagerImplTest, InputManagerImplTest_SetPixelMapData_01, TestSize.Level1) 456 { 457 CALL_TEST_DEBUG; 458 int32_t infoId = -1; 459 void* pixelMap = nullptr; 460 int32_t ret = InputMgrImpl.SetPixelMapData(infoId, pixelMap); 461 EXPECT_EQ(ret, RET_ERR); 462 463 infoId = 2; 464 int32_t ret2 = InputMgrImpl.SetPixelMapData(infoId, pixelMap); 465 EXPECT_EQ(ret2, RET_ERR); 466 } 467 468 /** 469 * @tc.name: InputManagerImplTest_SendEnhanceConfig_01 470 * @tc.desc: Test SendEnhanceConfig 471 * @tc.type: FUNC 472 * @tc.require: 473 */ 474 HWTEST_F(InputManagerImplTest, InputManagerImplTest_SendEnhanceConfig_01, TestSize.Level1) 475 { 476 CALL_TEST_DEBUG; 477 MmiMessageId idMsg = MmiMessageId::SCINFO_CONFIG; 478 NetPacket pkt(idMsg); 479 EXPECT_EQ(InputMgrImpl.PackEnhanceConfig(pkt), RET_ERR); 480 ASSERT_NO_FATAL_FAILURE(InputMgrImpl.SendEnhanceConfig()); 481 } 482 483 /** 484 * @tc.name: InputManagerImplTest_SendEnhanceConfig_02 485 * @tc.desc: Test SendEnhanceConfig 486 * @tc.type: FUNC 487 * @tc.require: 488 */ 489 HWTEST_F(InputManagerImplTest, InputManagerImplTest_SendEnhanceConfig_02, TestSize.Level1) 490 { 491 CALL_TEST_DEBUG; 492 MmiMessageId idMsg = MmiMessageId::INVALID; 493 NetPacket pkt(idMsg); 494 EXPECT_EQ(InputMgrImpl.PackEnhanceConfig(pkt), RET_ERR); 495 ASSERT_NO_FATAL_FAILURE(InputMgrImpl.SendEnhanceConfig()); 496 } 497 498 /** 499 * @tc.name: InputManagerImplTest_GetPointerColor_01 500 * @tc.desc: Test GetPointerColor 501 * @tc.type: FUNC 502 * @tc.require: 503 */ 504 HWTEST_F(InputManagerImplTest, InputManagerImplTest_GetPointerColor_01, TestSize.Level1) 505 { 506 CALL_TEST_DEBUG; 507 int32_t color = 5; 508 int32_t ret = InputMgrImpl.GetPointerColor(color); 509 EXPECT_EQ(ret, RET_OK); 510 511 color = -1; 512 int32_t ret2 = InputMgrImpl.GetPointerColor(color); 513 EXPECT_EQ(ret2, RET_OK); 514 } 515 516 /** 517 * @tc.name: InputManagerImplTest_GetMouseScrollRows_01 518 * @tc.desc: Test GetMouseScrollRows 519 * @tc.type: FUNC 520 * @tc.require: 521 */ 522 HWTEST_F(InputManagerImplTest, InputManagerImplTest_GetMouseScrollRows_01, TestSize.Level1) 523 { 524 CALL_TEST_DEBUG; 525 int32_t rows = 8; 526 int32_t ret = InputMgrImpl.GetMouseScrollRows(rows); 527 EXPECT_EQ(ret, RET_OK); 528 529 rows = -5; 530 int32_t ret2 = InputMgrImpl.GetMouseScrollRows(rows); 531 EXPECT_EQ(ret2, RET_OK); 532 } 533 534 /** 535 * @tc.name: InputManagerImplTest_SetMouseScrollRows_01 536 * @tc.desc: Test SetMouseScrollRows 537 * @tc.type: FUNC 538 * @tc.require: 539 */ 540 HWTEST_F(InputManagerImplTest, InputManagerImplTest_SetMouseScrollRows_01, TestSize.Level1) 541 { 542 CALL_TEST_DEBUG; 543 int32_t rows = 3; 544 int32_t ret = InputMgrImpl.SetMouseScrollRows(rows); 545 EXPECT_EQ(ret, RET_OK); 546 547 rows = -2; 548 int32_t ret2 = InputMgrImpl.SetMouseScrollRows(rows); 549 EXPECT_EQ(ret2, RET_OK); 550 } 551 552 /** 553 * @tc.name: InputManagerImplTest_LeaveCaptureMode_01 554 * @tc.desc: Test LeaveCaptureMode 555 * @tc.type: FUNC 556 * @tc.require: 557 */ 558 HWTEST_F(InputManagerImplTest, InputManagerImplTest_LeaveCaptureMode_01, TestSize.Level1) 559 { 560 CALL_TEST_DEBUG; 561 int32_t windowId = 3; 562 int32_t ret = InputMgrImpl.LeaveCaptureMode(windowId); 563 EXPECT_EQ(ret, RET_OK); 564 } 565 566 /** 567 * @tc.name: InputManagerImplTest_EnableInputDevice_01 568 * @tc.desc: Test EnableInputDevice 569 * @tc.type: FUNC 570 * @tc.require: 571 */ 572 HWTEST_F(InputManagerImplTest, InputManagerImplTest_EnableInputDevice_01, TestSize.Level1) 573 { 574 CALL_TEST_DEBUG; 575 bool enable = false; 576 int32_t ret = InputMgrImpl.EnableInputDevice(enable); 577 EXPECT_EQ(ret, RET_OK); 578 579 enable = true; 580 int32_t ret2 = InputMgrImpl.EnableInputDevice(enable); 581 EXPECT_EQ(ret2, RET_OK); 582 } 583 584 /** 585 * @tc.name: InputManagerImplTest_ConvertToCapiKeyAction_001 586 * @tc.desc: Test the funcation ConvertToCapiKeyAction 587 * @tc.type: FUNC 588 * @tc.require: 589 */ 590 HWTEST_F(InputManagerImplTest, InputManagerImplTest_ConvertToCapiKeyAction_001, TestSize.Level1) 591 { 592 CALL_TEST_DEBUG; 593 int32_t keyAction = KeyEvent::KEY_ACTION_DOWN; 594 ASSERT_NO_FATAL_FAILURE(InputMgrImpl.ConvertToCapiKeyAction(keyAction)); 595 keyAction = KeyEvent::KEY_ACTION_UP; 596 ASSERT_NO_FATAL_FAILURE(InputMgrImpl.ConvertToCapiKeyAction(keyAction)); 597 keyAction = KeyEvent::KEY_ACTION_CANCEL; 598 ASSERT_NO_FATAL_FAILURE(InputMgrImpl.ConvertToCapiKeyAction(keyAction)); 599 keyAction = 10; 600 ASSERT_NO_FATAL_FAILURE(InputMgrImpl.ConvertToCapiKeyAction(keyAction)); 601 } 602 603 /** 604 * @tc.name: InputManagerImplTest_GetTouchpadThreeFingersTapSwitch_001 605 * @tc.desc: Test the funcation GetTouchpadThreeFingersTapSwitch 606 * @tc.type: FUNC 607 * @tc.require: 608 */ 609 HWTEST_F(InputManagerImplTest, InputManagerImplTest_GetTouchpadThreeFingersTapSwitch_001, TestSize.Level1) 610 { 611 CALL_TEST_DEBUG; 612 bool switchFlag = true; 613 int32_t ret = InputMgrImpl.GetTouchpadThreeFingersTapSwitch(switchFlag); 614 EXPECT_EQ(ret, RET_OK); 615 switchFlag = true; 616 ret = InputMgrImpl.GetTouchpadThreeFingersTapSwitch(switchFlag); 617 EXPECT_EQ(ret, RET_OK); 618 } 619 620 /** 621 * @tc.name: InputManagerImplTest_SetTouchpadThreeFingersTapSwitch_001 622 * @tc.desc: Test the funcation SetTouchpadThreeFingersTapSwitch 623 * @tc.type: FUNC 624 * @tc.require: 625 */ 626 HWTEST_F(InputManagerImplTest, InputManagerImplTest_SetTouchpadThreeFingersTapSwitch_001, TestSize.Level1) 627 { 628 CALL_TEST_DEBUG; 629 bool switchFlag = true; 630 int32_t ret = InputMgrImpl.SetTouchpadThreeFingersTapSwitch(switchFlag); 631 EXPECT_EQ(ret, RET_OK); 632 switchFlag = true; 633 ret = InputMgrImpl.SetTouchpadThreeFingersTapSwitch(switchFlag); 634 EXPECT_EQ(ret, RET_OK); 635 } 636 637 /** 638 * @tc.name: InputManagerImplTest_SetCurrentUser_001 639 * @tc.desc: Test the funcation SetCurrentUser 640 * @tc.type: FUNC 641 * @tc.require: 642 */ 643 HWTEST_F(InputManagerImplTest, InputManagerImplTest_SetCurrentUser_001, TestSize.Level1) 644 { 645 CALL_TEST_DEBUG; 646 int32_t userId = 1; 647 int32_t ret = InputMgrImpl.SetCurrentUser(userId); 648 EXPECT_EQ(ret, RET_ERR); 649 userId = 0; 650 ret = InputMgrImpl.SetCurrentUser(userId); 651 EXPECT_EQ(ret, RET_ERR); 652 userId = -1; 653 ret = InputMgrImpl.SetCurrentUser(userId); 654 EXPECT_EQ(ret, RET_ERR); 655 } 656 657 /** 658 * @tc.name: InputManagerImplTest_Authorize_001 659 * @tc.desc: Test the funcation Authorize 660 * @tc.type: FUNC 661 * @tc.require: 662 */ 663 HWTEST_F(InputManagerImplTest, InputManagerImplTest_Authorize_001, TestSize.Level1) 664 { 665 CALL_TEST_DEBUG; 666 bool isAuthorize = true; 667 ASSERT_NO_FATAL_FAILURE(InputMgrImpl.Authorize(isAuthorize)); 668 isAuthorize = false; 669 ASSERT_NO_FATAL_FAILURE(InputMgrImpl.Authorize(isAuthorize)); 670 } 671 672 /** 673 * @tc.name: InputManagerImplTest_SubscribeLongPressEvent 674 * @tc.desc: Test SubscribeLongPressEvent 675 * @tc.type: FUNC 676 * @tc.require: 677 */ 678 HWTEST_F(InputManagerImplTest, InputManagerImplTest_SubscribeLongPressEvent, TestSize.Level1) 679 { 680 CALL_TEST_DEBUG; 681 LongPressRequest longPR = { 682 .fingerCount = 3, 683 .duration = 2, 684 }; 685 int32_t ret = InputMgrImpl.SubscribeLongPressEvent(longPR, nullptr); 686 ASSERT_EQ(ret, RET_ERR); 687 } 688 689 /** 690 * @tc.name: InputManagerImplTest_UnsubscribeLongPressEvent 691 * @tc.desc: Test UnsubscribeLongPressEvent 692 * @tc.type: FUNC 693 * @tc.require: 694 */ 695 HWTEST_F(InputManagerImplTest, InputManagerImplTest_UnsubscribeLongPressEvent, TestSize.Level1) 696 { 697 CALL_TEST_DEBUG; 698 int32_t subscriberId = 0; 699 ASSERT_NO_FATAL_FAILURE(InputMgrImpl.UnsubscribeLongPressEvent(subscriberId)); 700 } 701 } // namespace MMI 702 } // namespace OHOS 703