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 <gmock/gmock.h> 17 #include <gtest/gtest.h> 18 19 #include <fstream> 20 21 #include "libinput-private.h" 22 23 #include "input_device_manager.h" 24 #include "key_auto_repeat.h" 25 #include "mmi_log.h" 26 #include "uds_server.h" 27 #include "uds_session.h" 28 #include "cJSON.h" 29 30 namespace OHOS { 31 namespace MMI { 32 namespace { 33 using namespace testing::ext; 34 constexpr int32_t MIN_VIRTUAL_INPUT_DEVICE_ID { 1000 }; 35 constexpr int32_t UINPUT_INPUT_DEVICE_ID { -1 }; 36 constexpr int32_t LOC_INPUT_DEVICE_ID { 1 }; 37 } // namespace 38 39 class InputDeviceManagerTest : public testing::Test { 40 public: SetUpTestCase(void)41 static void SetUpTestCase(void) {} TearDownTestCase(void)42 static void TearDownTestCase(void) {} 43 }; 44 45 class MockUDSSession : public UDSSession { 46 public: 47 MOCK_METHOD1(SendMsg, int32_t(NetPacket &)); MockUDSSession(const std::string & programName,const int32_t moduleType,const int32_t fd,const int32_t uid,const int32_t pid)48 MockUDSSession(const std::string &programName, const int32_t moduleType, const int32_t fd, const int32_t uid, 49 const int32_t pid) : UDSSession(programName, moduleType, fd, uid, pid) {} 50 }; 51 52 class MockInputDevice { 53 public: 54 MOCK_METHOD1(SetId, void(int32_t deviceId)); 55 MOCK_METHOD0(MakeVirtualDeviceInfo, int()); 56 }; 57 58 /** 59 * @tc.name: InputDeviceManagerTest_GetInputDeviceIds_003 60 * @tc.desc: Test the function GetInputDeviceIds 61 * @tc.type: FUNC 62 * @tc.require: 63 */ 64 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_GetInputDeviceIds_003, TestSize.Level1) 65 { 66 CALL_TEST_DEBUG; 67 InputDeviceManager manager; 68 InputDeviceManager::InputDeviceInfo info1; 69 info1.networkIdOrigin = "device1"; 70 info1.enable = true; 71 manager.inputDevice_[1] = info1; 72 InputDeviceManager::InputDeviceInfo info2; 73 info2.networkIdOrigin = "device2"; 74 info2.enable = false; 75 manager.inputDevice_[2] = info2; 76 InputDeviceManager::InputDeviceInfo info3; 77 info3.networkIdOrigin = "device3"; 78 info3.enable = true; 79 manager.inputDevice_[3] = info3; 80 auto ids = manager.GetInputDeviceIds(); 81 ASSERT_EQ(ids.size(), 3); 82 EXPECT_EQ(ids[0], 1); 83 EXPECT_EQ(ids[1], 2); 84 } 85 86 /** 87 * @tc.name: InputDeviceManagerTest_SupportKeys_003 88 * @tc.desc: Test the function SupportKeys 89 * @tc.type: FUNC 90 * @tc.require: 91 */ 92 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_SupportKeys_003, TestSize.Level1) 93 { 94 CALL_TEST_DEBUG; 95 InputDeviceManager manager; 96 InputDeviceManager::InputDeviceInfo info; 97 info.networkIdOrigin = "device1"; 98 info.enable = true; 99 manager.inputDevice_[1] = info; 100 std::vector<int32_t> keyCodes = {1}; 101 std::vector<bool> keystroke; 102 int32_t ret = manager.SupportKeys(1, keyCodes, keystroke); 103 ASSERT_EQ(ret, RET_OK); 104 ASSERT_EQ(keystroke.size(), 1); 105 EXPECT_EQ(keystroke[0], true); 106 } 107 108 /** 109 * @tc.name: InputDeviceManagerTest_GetDeviceConfig_003 110 * @tc.desc: Test the function GetDeviceConfig 111 * @tc.type: FUNC 112 * @tc.require: 113 */ 114 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_GetDeviceConfig_003, TestSize.Level1) 115 { 116 CALL_TEST_DEBUG; 117 InputDeviceManager manager; 118 int32_t keyboardType; 119 int32_t ret = manager.GetDeviceConfig(-1, keyboardType); 120 ASSERT_EQ(ret, false); 121 InputDeviceManager::InputDeviceInfo info; 122 info.networkIdOrigin = "device1"; 123 manager.inputDevice_[1] = info; 124 ret = manager.GetDeviceConfig(1, keyboardType); 125 ASSERT_EQ(ret, false); 126 std::map<int32_t, DeviceConfig> deviceConfig; 127 DeviceConfig config; 128 config.keyboardType = 1; 129 deviceConfig[1] = config; 130 ret = manager.GetDeviceConfig(1, keyboardType); 131 ASSERT_EQ(ret, RET_OK); 132 ASSERT_EQ(keyboardType, RET_OK); 133 } 134 135 /** 136 * @tc.name: InputDeviceManagerTest_NotifyDevRemoveCallback_002 137 * @tc.desc: Test the function NotifyDevRemoveCallback 138 * @tc.type: FUNC 139 * @tc.require: 140 */ 141 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_NotifyDevRemoveCallback_002, TestSize.Level1) 142 { 143 CALL_TEST_DEBUG; 144 InputDeviceManager deviceManager; 145 int32_t deviceId = 1; 146 InputDeviceManager::InputDeviceInfo deviceInfo; 147 deviceInfo.sysUid = ""; 148 ASSERT_NO_FATAL_FAILURE(deviceManager.NotifyDevRemoveCallback(deviceId, deviceInfo)); 149 } 150 151 /** 152 * @tc.name: InputDeviceManagerTest_GenerateVirtualDeviceId_001 153 * @tc.desc: Test the function GenerateVirtualDeviceId 154 * @tc.type: FUNC 155 * @tc.require: 156 */ 157 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_GenerateVirtualDeviceId_001, TestSize.Level1) 158 { 159 CALL_TEST_DEBUG; 160 InputDeviceManager deviceManager; 161 int32_t deviceId = 0; 162 int32_t MAX_VIRTUAL_INPUT_DEVICE_NUM = 128; 163 for (int i = 0; i < MAX_VIRTUAL_INPUT_DEVICE_NUM; i++) { 164 deviceManager.virtualInputDevices_.insert(std::make_pair(i, std::make_shared<InputDevice>())); 165 } 166 EXPECT_EQ(deviceManager.GenerateVirtualDeviceId(deviceId), RET_ERR); 167 } 168 169 /** 170 * @tc.name: InputDeviceManagerTest_GenerateVirtualDeviceId_002 171 * @tc.desc: Test the function GenerateVirtualDeviceId 172 * @tc.type: FUNC 173 * @tc.require: 174 */ 175 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_GenerateVirtualDeviceId_002, TestSize.Level1) 176 { 177 CALL_TEST_DEBUG; 178 InputDeviceManager deviceManager; 179 int32_t deviceId = 0; 180 deviceManager.virtualInputDevices_.insert(std::make_pair(1, std::make_shared<InputDevice>())); 181 EXPECT_EQ(deviceManager.GenerateVirtualDeviceId(deviceId), RET_OK); 182 } 183 184 /** 185 * @tc.name: InputDeviceManagerTest_GenerateVirtualDeviceId_003 186 * @tc.desc: Test the function GenerateVirtualDeviceId 187 * @tc.type: FUNC 188 * @tc.require: 189 */ 190 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_GenerateVirtualDeviceId_003, TestSize.Level1) 191 { 192 CALL_TEST_DEBUG; 193 InputDeviceManager deviceManager; 194 int32_t deviceId = 0; 195 EXPECT_EQ(deviceManager.GenerateVirtualDeviceId(deviceId), RET_OK); 196 } 197 198 /** 199 * @tc.name: InputDeviceManagerTest_RemoveVirtualInputDevice_001 200 * @tc.desc: Test the function RemoveVirtualInputDevice 201 * @tc.type: FUNC 202 * @tc.require: 203 */ 204 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_RemoveVirtualInputDevice_001, TestSize.Level1) 205 { 206 CALL_TEST_DEBUG; 207 InputDeviceManager deviceManager; 208 int32_t deviceId = 1; 209 EXPECT_EQ(deviceManager.RemoveVirtualInputDevice(deviceId), RET_ERR); 210 } 211 212 /** 213 * @tc.name: InputDeviceManagerTest_RemoveVirtualInputDevice_002 214 * @tc.desc: Test the function RemoveVirtualInputDevice 215 * @tc.type: FUNC 216 * @tc.require: 217 */ 218 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_RemoveVirtualInputDevice_002, TestSize.Level1) 219 { 220 CALL_TEST_DEBUG; 221 InputDeviceManager deviceManager; 222 int32_t deviceId = 1; 223 deviceManager.virtualInputDevices_[deviceId] = std::make_shared<InputDevice>(); 224 EXPECT_EQ(deviceManager.RemoveVirtualInputDevice(deviceId), RET_OK); 225 } 226 227 /** 228 * @tc.name: InputDeviceManagerTest_RemoveVirtualInputDevice_003 229 * @tc.desc: Test the function RemoveVirtualInputDevice 230 * @tc.type: FUNC 231 * @tc.require: 232 */ 233 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_RemoveVirtualInputDevice_003, TestSize.Level1) 234 { 235 CALL_TEST_DEBUG; 236 InputDeviceManager deviceManager; 237 int32_t deviceId = 1; 238 auto device = std::make_shared<InputDevice>(); 239 deviceManager.virtualInputDevices_[deviceId] = device; 240 EXPECT_EQ(deviceManager.RemoveVirtualInputDevice(deviceId), RET_OK); 241 EXPECT_EQ(deviceManager.virtualInputDevices_.find(deviceId), deviceManager.virtualInputDevices_.end()); 242 } 243 244 /** 245 * @tc.name: InputDeviceManagerTest_AddVirtualInputDevice_001 246 * @tc.desc: Test the function AddVirtualInputDevice 247 * @tc.type: FUNC 248 * @tc.require: 249 */ 250 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_AddVirtualInputDevice_001, TestSize.Level1) 251 { 252 CALL_TEST_DEBUG; 253 InputDeviceManager manager; 254 std::shared_ptr<MockInputDevice> mockDevice = std::make_shared<MockInputDevice>(); 255 int32_t deviceId = 0; 256 std::shared_ptr<InputDevice> device; 257 EXPECT_CALL(*mockDevice, MakeVirtualDeviceInfo()).WillRepeatedly(testing::Return(RET_ERR)); 258 int32_t ret = manager.AddVirtualInputDevice(device, deviceId); 259 EXPECT_EQ(ret, RET_ERR); 260 EXPECT_EQ(deviceId, RET_OK); 261 } 262 263 /** 264 * @tc.name: InputDeviceManagerTest_AddVirtualInputDevice_002 265 * @tc.desc: Test the function AddVirtualInputDevice 266 * @tc.type: FUNC 267 * @tc.require: 268 */ 269 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_AddVirtualInputDevice_002, TestSize.Level1) 270 { 271 CALL_TEST_DEBUG; 272 InputDeviceManager manager; 273 std::shared_ptr<MockInputDevice> mockDevice = std::make_shared<MockInputDevice>(); 274 int32_t deviceId = 1; 275 std::shared_ptr<InputDevice> device; 276 EXPECT_CALL(*mockDevice, MakeVirtualDeviceInfo()).WillRepeatedly(testing::Return(RET_ERR)); 277 int32_t ret = manager.AddVirtualInputDevice(device, deviceId); 278 EXPECT_EQ(ret, RET_ERR); 279 } 280 281 /** 282 * @tc.name: InputDeviceManagerTest_AddVirtualInputDevice_003 283 * @tc.desc: Test the function AddVirtualInputDevice 284 * @tc.type: FUNC 285 * @tc.require: 286 */ 287 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_AddVirtualInputDevice_003, TestSize.Level1) 288 { 289 CALL_TEST_DEBUG; 290 InputDeviceManager manager; 291 std::shared_ptr<MockInputDevice> mockDevice = std::make_shared<MockInputDevice>(); 292 int32_t deviceId = 1; 293 std::shared_ptr<InputDevice> device; 294 EXPECT_CALL(*mockDevice, MakeVirtualDeviceInfo()).WillRepeatedly(testing::Return(RET_OK)); 295 int32_t ret = manager.AddVirtualInputDevice(device, deviceId); 296 EXPECT_EQ(ret, RET_ERR); 297 } 298 299 /** 300 * @tc.name: InputDeviceManagerTest_AddVirtualInputDevice_004 301 * @tc.desc: Test the function AddVirtualInputDevice 302 * @tc.type: FUNC 303 * @tc.require: 304 */ 305 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_AddVirtualInputDevice_004, TestSize.Level1) 306 { 307 CALL_TEST_DEBUG; 308 InputDeviceManager deviceManager; 309 int32_t deviceId = 1; 310 std::shared_ptr<InputDevice> device; 311 312 int32_t MAX_VIRTUAL_INPUT_DEVICE_NUM = 128; 313 for (int i = 0; i < MAX_VIRTUAL_INPUT_DEVICE_NUM; i++) { 314 deviceManager.virtualInputDevices_.insert(std::make_pair(i, std::make_shared<InputDevice>())); 315 } 316 317 EXPECT_EQ(deviceManager.GenerateVirtualDeviceId(deviceId), RET_ERR); 318 int32_t ret = INPUT_DEV_MGR->AddVirtualInputDevice(device, deviceId); 319 EXPECT_EQ(ret, RET_ERR); 320 } 321 322 /** 323 * @tc.name: InputDeviceManagerTest_AddVirtualInputDevice_005 324 * @tc.desc: Test the function AddVirtualInputDevice 325 * @tc.type: FUNC 326 * @tc.require: 327 */ 328 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_AddVirtualInputDevice_005, TestSize.Level1) 329 { 330 CALL_TEST_DEBUG; 331 InputDeviceManager deviceManager; 332 int32_t deviceId = 2; 333 std::shared_ptr<InputDevice> device; 334 deviceManager.virtualInputDevices_.insert(std::make_pair(1, std::make_shared<InputDevice>())); 335 EXPECT_EQ(deviceManager.GenerateVirtualDeviceId(deviceId), RET_OK); 336 337 int32_t ret = INPUT_DEV_MGR->AddVirtualInputDevice(device, deviceId); 338 EXPECT_EQ(ret, RET_ERR); 339 } 340 341 /** 342 * @tc.name: InputDeviceManagerTest_AddVirtualInputDevice_006 343 * @tc.desc: Test the function AddVirtualInputDevice 344 * @tc.type: FUNC 345 * @tc.require: 346 */ 347 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_AddVirtualInputDevice_006, TestSize.Level1) 348 { 349 CALL_TEST_DEBUG; 350 InputDeviceManager deviceManager; 351 int32_t deviceId = 2; 352 std::shared_ptr<InputDevice> device; 353 std::shared_ptr<MockInputDevice> mockDevice = std::make_shared<MockInputDevice>(); 354 deviceManager.virtualInputDevices_.insert(std::make_pair(1, std::make_shared<InputDevice>())); 355 EXPECT_EQ(deviceManager.GenerateVirtualDeviceId(deviceId), RET_OK); 356 EXPECT_CALL(*mockDevice, MakeVirtualDeviceInfo()).WillRepeatedly(testing::Return(RET_ERR)); 357 358 int32_t ret = INPUT_DEV_MGR->AddVirtualInputDevice(device, deviceId); 359 EXPECT_EQ(ret, RET_ERR); 360 } 361 362 /** 363 * @tc.name: InputDeviceManagerTest_AddVirtualInputDevice_007 364 * @tc.desc: Test the function AddVirtualInputDevice 365 * @tc.type: FUNC 366 * @tc.require: 367 */ 368 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_AddVirtualInputDevice_007, TestSize.Level1) 369 { 370 CALL_TEST_DEBUG; 371 InputDeviceManager deviceManager; 372 int32_t deviceId = 2; 373 std::shared_ptr<InputDevice> device; 374 std::shared_ptr<MockInputDevice> mockDevice = std::make_shared<MockInputDevice>(); 375 deviceManager.virtualInputDevices_.insert(std::make_pair(1, std::make_shared<InputDevice>())); 376 EXPECT_EQ(deviceManager.GenerateVirtualDeviceId(deviceId), RET_OK); 377 EXPECT_CALL(*mockDevice, MakeVirtualDeviceInfo()).WillRepeatedly(testing::Return(RET_OK)); 378 379 int32_t ret = INPUT_DEV_MGR->AddVirtualInputDevice(device, deviceId); 380 EXPECT_EQ(ret, RET_ERR); 381 } 382 383 /** 384 * @tc.name: InputDeviceManagerTest_GetKeyboardType_003 385 * @tc.desc: Test the function GetKeyboardType 386 * @tc.type: FUNC 387 * @tc.require: 388 */ 389 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_GetKeyboardType_003, TestSize.Level1) 390 { 391 CALL_TEST_DEBUG; 392 InputDeviceManager inputDeviceManager; 393 int32_t deviceId = 1; 394 int32_t keyboardType = 0; 395 std::shared_ptr<InputDevice> device = std::make_shared<InputDevice>(); 396 inputDeviceManager.virtualInputDevices_.insert(std::make_pair(deviceId, device)); 397 EXPECT_EQ(inputDeviceManager.GetKeyboardType(deviceId, keyboardType), RET_OK); 398 EXPECT_EQ(keyboardType, KEYBOARD_TYPE_NONE); 399 } 400 401 /** 402 * @tc.name: InputDeviceManagerTest_GetKeyboardType_004 403 * @tc.desc: Test the function GetKeyboardType 404 * @tc.type: FUNC 405 * @tc.require: 406 */ 407 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_GetKeyboardType_004, TestSize.Level1) 408 { 409 CALL_TEST_DEBUG; 410 InputDeviceManager inputDeviceManager; 411 int32_t deviceId = 2; 412 int32_t keyboardType = 0; 413 std::shared_ptr<InputDevice> device = std::make_shared<InputDevice>(); 414 inputDeviceManager.virtualInputDevices_.insert(std::make_pair(deviceId, device)); 415 EXPECT_EQ(inputDeviceManager.GetKeyboardType(deviceId, keyboardType), RET_OK); 416 EXPECT_EQ(keyboardType, KEYBOARD_TYPE_NONE); 417 } 418 419 /** 420 * @tc.name: InputDeviceManagerTest_GetKeyboardType_005 421 * @tc.desc: Test the function GetKeyboardType 422 * @tc.type: FUNC 423 * @tc.require: 424 */ 425 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_GetKeyboardType_005, TestSize.Level1) 426 { 427 CALL_TEST_DEBUG; 428 InputDeviceManager inputDeviceManager; 429 int32_t deviceId = 3; 430 int32_t keyboardType = 0; 431 inputDeviceManager.inputDevice_.insert(std::make_pair(deviceId, InputDeviceManager::InputDeviceInfo())); 432 inputDeviceManager.inputDevice_[deviceId].enable = false; 433 EXPECT_EQ(inputDeviceManager.GetKeyboardType(deviceId, keyboardType), RET_ERR); 434 } 435 436 /** 437 * @tc.name: InputDeviceManagerTest_GetKeyboardType_006 438 * @tc.desc: Test the function GetKeyboardType with virtual device id 439 * @tc.type: FUNC 440 * @tc.require: 441 */ 442 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_GetKeyboardType_006, TestSize.Level1) 443 { 444 CALL_TEST_DEBUG; 445 InputDeviceManager inputDeviceManager; 446 int32_t deviceId = 1000; 447 int32_t keyboardType = 0; 448 auto inputDevice = std::make_shared<InputDevice>(); 449 inputDeviceManager.virtualInputDevices_[deviceId] = inputDevice; 450 EXPECT_EQ(inputDeviceManager.GetKeyboardType(deviceId, keyboardType), RET_OK); 451 EXPECT_EQ(keyboardType, KEYBOARD_TYPE_NONE); 452 } 453 454 /** 455 * @tc.name: InputDeviceManagerTest_GetKeyboardType_007 456 * @tc.desc: Test the function GetKeyboardType with touchscreen id without virtual keyboard 457 * @tc.type: FUNC 458 * @tc.require: 459 */ 460 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_GetKeyboardType_007, TestSize.Level1) 461 { 462 CALL_TEST_DEBUG; 463 InputDeviceManager inputDeviceManager; 464 int32_t deviceId = 1; 465 InputDeviceManager::InputDeviceInfo info; 466 info.isTouchableDevice = true; 467 info.enable = true; 468 inputDeviceManager.inputDevice_.insert(std::make_pair(deviceId, info)); 469 int32_t keyboardType = 0; 470 EXPECT_EQ(inputDeviceManager.GetKeyboardType(deviceId, keyboardType), RET_OK); 471 } 472 473 /** 474 * @tc.name: InputDeviceManagerTest_GetKeyboardType_008 475 * @tc.desc: Test the function GetKeyboardType with touchscreen id with virtual keyboard 476 * @tc.type: FUNC 477 * @tc.require: 478 */ 479 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_GetKeyboardType_008, TestSize.Level1) 480 { 481 CALL_TEST_DEBUG; 482 InputDeviceManager inputDeviceManager; 483 int32_t deviceId = 1; 484 InputDeviceManager::InputDeviceInfo info; 485 info.isTouchableDevice = true; 486 info.enable = true; 487 inputDeviceManager.inputDevice_.insert(std::make_pair(deviceId, info)); 488 int32_t keyboardType = 0; 489 490 int32_t deviceId1 = 1000; 491 auto device1 = std::make_shared<InputDevice>(); 492 device1->AddCapability(MMI::InputDeviceCapability::INPUT_DEV_CAP_KEYBOARD); 493 inputDeviceManager.virtualInputDevices_[deviceId1] = device1; 494 495 int32_t deviceId2 = 1001; 496 auto device2 = std::make_shared<InputDevice>(); 497 device2->AddCapability(MMI::InputDeviceCapability::INPUT_DEV_CAP_POINTER); 498 inputDeviceManager.virtualInputDevices_[deviceId2] = device2; 499 500 EXPECT_EQ(inputDeviceManager.GetKeyboardType(deviceId, keyboardType), RET_OK); 501 #ifdef OHOS_BUILD_ENABLE_VKEYBOARD 502 EXPECT_EQ(keyboardType, KEYBOARD_TYPE_ALPHABETICKEYBOARD); 503 #else // OHOS_BUILD_ENABLE_VKEYBOARD 504 EXPECT_NE(keyboardType, KEYBOARD_TYPE_UNKNOWN); 505 #endif // OHOS_BUILD_ENABLE_VKEYBOARD 506 } 507 508 /** 509 * @tc.name: InputDeviceManagerTest_OnEnableInputDevice_Test_001 510 * @tc.desc: Test the function OnEnableInputDevice 511 * @tc.type: FUNC 512 * @tc.require: 513 */ 514 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_OnEnableInputDevice_Test_001, TestSize.Level1) 515 { 516 CALL_TEST_DEBUG; 517 InputDeviceManager inputDevice; 518 bool enable = true; 519 int32_t keyboardType = KEYBOARD_TYPE_NONE; 520 EXPECT_TRUE(keyboardType != KEYBOARD_TYPE_ALPHABETICKEYBOARD); 521 int32_t ret = inputDevice.OnEnableInputDevice(enable); 522 EXPECT_EQ(ret, RET_OK); 523 } 524 525 /** 526 * @tc.name: InputDeviceManagerTest_OnEnableInputDevice_Test_02 527 * @tc.desc: Test the function OnEnableInputDevice 528 * @tc.type: FUNC 529 * @tc.require: 530 */ 531 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_OnEnableInputDevice_Test_02, TestSize.Level1) 532 { 533 CALL_TEST_DEBUG; 534 InputDeviceManager inputDevice; 535 int32_t deviceId = 3; 536 bool enable = true; 537 538 InputDeviceManager::InputDeviceInfo deviceInfo; 539 deviceInfo.isRemote = true; 540 deviceInfo.enable = false; 541 inputDevice.inputDevice_.insert(std::make_pair(deviceId, deviceInfo)); 542 543 int32_t ret = inputDevice.OnEnableInputDevice(enable); 544 EXPECT_EQ(ret, RET_OK); 545 } 546 547 /** 548 * @tc.name: InputDeviceManagerTest_OnEnableInputDevice_Test_03 549 * @tc.desc: Test the function OnEnableInputDevice 550 * @tc.type: FUNC 551 * @tc.require: 552 */ 553 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_OnEnableInputDevice_Test_03, TestSize.Level1) 554 { 555 CALL_TEST_DEBUG; 556 InputDeviceManager inputDevice; 557 int32_t deviceId = 3; 558 bool enable = true; 559 560 InputDeviceManager::InputDeviceInfo deviceInfo; 561 deviceInfo.isRemote = false; 562 deviceInfo.enable = true; 563 inputDevice.inputDevice_.insert(std::make_pair(deviceId, deviceInfo)); 564 565 int32_t ret = inputDevice.OnEnableInputDevice(enable); 566 EXPECT_EQ(ret, RET_OK); 567 } 568 569 /** 570 * @tc.name: InputDeviceManagerTest_OnEnableInputDevice_Test_04 571 * @tc.desc: Test the function OnEnableInputDevice 572 * @tc.type: FUNC 573 * @tc.require: 574 */ 575 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_OnEnableInputDevice_Test_04, TestSize.Level1) 576 { 577 CALL_TEST_DEBUG; 578 InputDeviceManager inputDevice; 579 int32_t deviceId = 5; 580 bool enable = true; 581 582 InputDeviceManager::InputDeviceInfo deviceInfo; 583 deviceInfo.isRemote = false; 584 deviceInfo.enable = false; 585 deviceInfo.isPointerDevice = false; 586 inputDevice.inputDevice_.insert(std::make_pair(deviceId, deviceInfo)); 587 588 int32_t ret = inputDevice.OnEnableInputDevice(enable); 589 EXPECT_EQ(ret, RET_OK); 590 } 591 592 /** 593 * @tc.name: InputDeviceManagerTest_OnEnableInputDevice_Test_05 594 * @tc.desc: Test the function OnEnableInputDevice 595 * @tc.type: FUNC 596 * @tc.require: 597 */ 598 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_OnEnableInputDevice_Test_05, TestSize.Level1) 599 { 600 CALL_TEST_DEBUG; 601 InputDeviceManager inputDevice; 602 int32_t deviceId = 3; 603 bool enable = true; 604 605 InputDeviceManager::InputDeviceInfo deviceInfo; 606 deviceInfo.isRemote = false; 607 deviceInfo.enable = false; 608 deviceInfo.isPointerDevice = true; 609 inputDevice.inputDevice_.insert(std::make_pair(deviceId, deviceInfo)); 610 611 int32_t ret = inputDevice.OnEnableInputDevice(enable); 612 EXPECT_EQ(ret, RET_OK); 613 } 614 615 /** 616 * @tc.name: InputDeviceManagerTest_OnEnableInputDevice_Test_06 617 * @tc.desc: Test the function OnEnableInputDevice 618 * @tc.type: FUNC 619 * @tc.require: 620 */ 621 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_OnEnableInputDevice_Test_06, TestSize.Level1) 622 { 623 CALL_TEST_DEBUG; 624 InputDeviceManager inputDevice; 625 int32_t deviceId = 3; 626 bool enable = true; 627 628 InputDeviceManager::InputDeviceInfo deviceInfo; 629 deviceInfo.isRemote = false; 630 deviceInfo.enable = true; 631 deviceInfo.isPointerDevice = true; 632 inputDevice.inputDevice_.insert(std::make_pair(deviceId, deviceInfo)); 633 634 int32_t ret = inputDevice.OnEnableInputDevice(enable); 635 EXPECT_EQ(ret, RET_OK); 636 } 637 638 /** 639 * @tc.name: InputDeviceManagerTest_GetKeyboardDevice_Test_001 640 * @tc.desc: Test the function GetKeyboardDevice 641 * @tc.type: FUNC 642 * @tc.require: 643 */ 644 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_GetKeyboardDevice_Test_001, TestSize.Level1) 645 { 646 CALL_TEST_DEBUG; 647 InputDeviceManager inputDevice; 648 struct libinput_device *device = nullptr; 649 std::vector<int32_t> keyCodes; 650 keyCodes.push_back(KeyEvent::KEYCODE_Q); 651 keyCodes.push_back(KeyEvent::KEYCODE_NUMPAD_1); 652 653 bool ret1 = inputDevice.IsMatchKeys(device, keyCodes); 654 EXPECT_FALSE(ret1); 655 auto ret2 = inputDevice.GetKeyboardDevice(); 656 EXPECT_EQ(ret2, nullptr); 657 } 658 659 /** 660 * @tc.name: InputDeviceManagerTest_OnInputDeviceAdded_Test_001 661 * @tc.desc: Test the function OnInputDeviceAdded 662 * @tc.type: FUNC 663 * @tc.require: 664 */ 665 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_OnInputDeviceAdded_Test_001, TestSize.Level1) 666 { 667 CALL_TEST_DEBUG; 668 InputDeviceManager inputDevice; 669 int32_t deviceId; 670 struct libinput_device *device = nullptr; 671 deviceId = 2; 672 ASSERT_NO_FATAL_FAILURE(inputDevice.OnInputDeviceAdded(device)); 673 } 674 675 /** 676 * @tc.name: InputDeviceManagerTest_GetDeviceSupportKey_Test_001 677 * @tc.desc: Test the function GetDeviceSupportKey 678 * @tc.type: FUNC 679 * @tc.require: 680 */ 681 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_GetDeviceSupportKey_Test_001, TestSize.Level1) 682 { 683 CALL_TEST_DEBUG; 684 std::vector<int32_t> keyCodes; 685 int32_t deviceId = 1; 686 int32_t keyboardType = KEYBOARD_TYPE_REMOTECONTROL; 687 std::map<int32_t, bool> determineKbType; 688 int32_t returnCode1 = 401; 689 int32_t returnCode2 = 65142786; 690 InputDeviceManager inputDevice; 691 keyCodes.push_back(KeyEvent::KEYCODE_Q); 692 keyCodes.push_back(KeyEvent::KEYCODE_HOME); 693 keyCodes.push_back(KeyEvent::KEYCODE_CTRL_LEFT); 694 keyCodes.push_back(KeyEvent::KEYCODE_F2); 695 696 int32_t ret1 = inputDevice.GetKeyboardBusMode(deviceId); 697 EXPECT_EQ(ret1, returnCode2); 698 int32_t ret2 = inputDevice.GetDeviceSupportKey(deviceId, keyboardType); 699 EXPECT_EQ(ret2, returnCode1); 700 } 701 702 /** 703 * @tc.name: GetInputDevice_Test_001 704 * @tc.desc: Test the function GetInputDevice 705 * @tc.type: FUNC 706 * @tc.require: 707 */ 708 HWTEST_F(InputDeviceManagerTest, GetInputDevice_Test_001, TestSize.Level1) 709 { 710 CALL_TEST_DEBUG; 711 InputDeviceManager inputDevice; 712 std::shared_ptr<InputDevice> inputDeviceManager{nullptr}; 713 int32_t id = 1; 714 bool checked = true; 715 inputDeviceManager = inputDevice.GetInputDevice(id, checked); 716 EXPECT_EQ(inputDeviceManager, nullptr); 717 } 718 719 /** 720 * @tc.name: GetInputDeviceIds_Test_001 721 * @tc.desc: Test the function GetInputDeviceIds 722 * @tc.type: FUNC 723 * @tc.require: 724 */ 725 HWTEST_F(InputDeviceManagerTest, GetInputDeviceIds_Test_001, TestSize.Level1) 726 { 727 CALL_TEST_DEBUG; 728 InputDeviceManager inputDevice; 729 ASSERT_NO_FATAL_FAILURE(inputDevice.GetInputDeviceIds()); 730 } 731 732 /** 733 * @tc.name: SupportKeys_Test_001 734 * @tc.desc: Test the function SupportKeys 735 * @tc.type: FUNC 736 * @tc.require: 737 */ 738 HWTEST_F(InputDeviceManagerTest, SupportKeys_Test_001, TestSize.Level1) 739 { 740 CALL_TEST_DEBUG; 741 InputDeviceManager inputDevice; 742 int32_t deviceId = 1; 743 std::vector<int32_t> keyCodes{12}; 744 std::vector<bool> keystroke{true}; 745 int32_t returnCode = 401; 746 int32_t ret = inputDevice.SupportKeys(deviceId, keyCodes, keystroke); 747 EXPECT_EQ(ret, returnCode); 748 } 749 750 /** 751 * @tc.name: GetDeviceConfig_Test_001 752 * @tc.desc: Test the function GetDeviceConfig 753 * @tc.type: FUNC 754 * @tc.require: 755 */ 756 HWTEST_F(InputDeviceManagerTest, GetDeviceConfig_Test_001, TestSize.Level1) 757 { 758 CALL_TEST_DEBUG; 759 InputDeviceManager inputDevice; 760 int32_t deviceId = 1; 761 int32_t keyboardType = 1; 762 bool ret = inputDevice.GetDeviceConfig(deviceId, keyboardType); 763 EXPECT_FALSE(ret); 764 } 765 766 /** 767 * @tc.name: GetDeviceSupportKey_Test_001 768 * @tc.desc: Test the function GetDeviceSupportKey 769 * @tc.type: FUNC 770 * @tc.require: 771 */ 772 HWTEST_F(InputDeviceManagerTest, GetDeviceSupportKey_Test_001, TestSize.Level1) 773 { 774 CALL_TEST_DEBUG; 775 InputDeviceManager inputDevice; 776 int32_t deviceId = 1; 777 int32_t keyboardType = 1; 778 int32_t returnCode = 401; 779 int32_t ret = inputDevice.GetDeviceSupportKey(deviceId, keyboardType); 780 EXPECT_EQ(ret, returnCode); 781 } 782 783 /** 784 * @tc.name: GetKeyboardType_Test_001 785 * @tc.desc: Test the function GetKeyboardType 786 * @tc.type: FUNC 787 * @tc.require: 788 */ 789 HWTEST_F(InputDeviceManagerTest, GetKeyboardType_Test_001, TestSize.Level1) 790 { 791 CALL_TEST_DEBUG; 792 InputDeviceManager inputDevice; 793 int32_t deviceId = 1; 794 int32_t keyboardType = 1; 795 int32_t returnCode = 401; 796 int32_t ret = inputDevice.GetKeyboardType(deviceId, keyboardType); 797 EXPECT_EQ(ret, returnCode); 798 } 799 800 /** 801 * @tc.name: HasTouchDevice_Test_001 802 * @tc.desc: Test the function HasTouchDevice 803 * @tc.type: FUNC 804 * @tc.require: 805 */ 806 HWTEST_F(InputDeviceManagerTest, HasTouchDevice_Test_001, TestSize.Level1) 807 { 808 CALL_TEST_DEBUG; 809 InputDeviceManager inputDevice; 810 bool ret = inputDevice.HasTouchDevice(); 811 EXPECT_FALSE(ret); 812 } 813 814 /** 815 * @tc.name: ScanPointerDevice_Test_001 816 * @tc.desc: Test the function ScanPointerDevice 817 * @tc.type: FUNC 818 * @tc.require: 819 */ 820 HWTEST_F(InputDeviceManagerTest, ScanPointerDevice_Test_001, TestSize.Level1) 821 { 822 CALL_TEST_DEBUG; 823 InputDeviceManager inputDevice; 824 ASSERT_NO_FATAL_FAILURE(inputDevice.ScanPointerDevice()); 825 } 826 827 /** 828 * @tc.name: Dump_Test_001 829 * @tc.desc: Test the function Dump 830 * @tc.type: FUNC 831 * @tc.require: 832 */ 833 HWTEST_F(InputDeviceManagerTest, Dump_Test_001, TestSize.Level1) 834 { 835 CALL_TEST_DEBUG; 836 InputDeviceManager inputDevice; 837 int32_t fd = 1; 838 std::vector<std::string> args{"test"}; 839 ASSERT_NO_FATAL_FAILURE(inputDevice.Dump(fd, args)); 840 } 841 842 /** 843 * @tc.name: DumpDeviceList_Test_001 844 * @tc.desc: Test the function DumpDeviceList 845 * @tc.type: FUNC 846 * @tc.require: 847 */ 848 HWTEST_F(InputDeviceManagerTest, DumpDeviceList_Test_001, TestSize.Level1) 849 { 850 CALL_TEST_DEBUG; 851 InputDeviceManager inputDevice; 852 int32_t fd = 1; 853 std::vector<std::string> args{"test"}; 854 ASSERT_NO_FATAL_FAILURE(inputDevice.DumpDeviceList(fd, args)); 855 } 856 857 /** 858 * @tc.name: GetVendorConfig_Test_001 859 * @tc.desc: Test the function GetVendorConfig 860 * @tc.type: FUNC 861 * @tc.require: 862 */ 863 HWTEST_F(InputDeviceManagerTest, GetVendorConfig_Test_001, TestSize.Level1) 864 { 865 CALL_TEST_DEBUG; 866 InputDeviceManager inputDevice; 867 int32_t deviceId = 1; 868 ASSERT_NO_FATAL_FAILURE(inputDevice.GetVendorConfig(deviceId)); 869 } 870 871 /** 872 * @tc.name: OnEnableInputDevice_Test_001 873 * @tc.desc: Test the function OnEnableInputDevice 874 * @tc.type: FUNC 875 * @tc.require: 876 */ 877 HWTEST_F(InputDeviceManagerTest, OnEnableInputDevice_Test_001, TestSize.Level1) 878 { 879 CALL_TEST_DEBUG; 880 InputDeviceManager inputDevice; 881 bool enable = true; 882 int32_t ret = inputDevice.OnEnableInputDevice(enable); 883 EXPECT_EQ(ret, RET_OK); 884 enable = false; 885 ret = inputDevice.OnEnableInputDevice(enable); 886 EXPECT_EQ(ret, RET_OK); 887 } 888 889 /** 890 * @tc.name: InitSessionLostCallback_Test_001 891 * @tc.desc: Test the function InitSessionLostCallback 892 * @tc.type: FUNC 893 * @tc.require: 894 */ 895 HWTEST_F(InputDeviceManagerTest, InitSessionLostCallback_Test_001, TestSize.Level1) 896 { 897 CALL_TEST_DEBUG; 898 InputDeviceManager inputDevice; 899 ASSERT_NO_FATAL_FAILURE(inputDevice.InitSessionLostCallback()); 900 } 901 902 /** 903 * @tc.name: InitSessionLostCallback_Test_002 904 * @tc.desc: Test the function InitSessionLostCallback 905 * @tc.type: FUNC 906 * @tc.require: 907 */ 908 HWTEST_F(InputDeviceManagerTest, InitSessionLostCallback_Test_002, TestSize.Level1) 909 { 910 CALL_TEST_DEBUG; 911 InputDeviceManager inputDevice; 912 inputDevice.sessionLostCallbackInitialized_ = true; 913 ASSERT_NO_FATAL_FAILURE(inputDevice.InitSessionLostCallback()); 914 } 915 916 /** 917 * @tc.name: InitSessionLostCallback_Test_003 918 * @tc.desc: Test the function InitSessionLostCallback 919 * @tc.type: FUNC 920 * @tc.require: 921 */ 922 HWTEST_F(InputDeviceManagerTest, InitSessionLostCallback_Test_003, TestSize.Level1) 923 { 924 CALL_TEST_DEBUG; 925 InputDeviceManager inputDevice; 926 inputDevice.sessionLostCallbackInitialized_ = false; 927 ASSERT_NO_FATAL_FAILURE(inputDevice.InitSessionLostCallback()); 928 EXPECT_FALSE(inputDevice.sessionLostCallbackInitialized_); 929 } 930 931 /** 932 * @tc.name: OnSessionLost_Test_001 933 * @tc.desc: Test the function OnSessionLost 934 * @tc.type: FUNC 935 * @tc.require: 936 */ 937 HWTEST_F(InputDeviceManagerTest, OnSessionLost_Test_001, TestSize.Level1) 938 { 939 CALL_TEST_DEBUG; 940 InputDeviceManager inputDevice; 941 std::string programName = "program"; 942 int32_t moduleType = 1; 943 int32_t fd = 2; 944 int32_t uid = 3; 945 int32_t pid = 4; 946 std::shared_ptr<MockUDSSession> session = std::make_shared<MockUDSSession> 947 (programName, moduleType, fd, uid, pid); 948 ASSERT_NE(session, nullptr); 949 ASSERT_NO_FATAL_FAILURE(inputDevice.OnSessionLost(session)); 950 session = nullptr; 951 ASSERT_NO_FATAL_FAILURE(inputDevice.OnSessionLost(session)); 952 } 953 954 955 /** 956 * @tc.name: NotifyMessage_Test_001 957 * @tc.desc: Test the function NotifyMessage 958 * @tc.type: FUNC 959 * @tc.require: 960 */ 961 HWTEST_F(InputDeviceManagerTest, NotifyMessage_Test_001, TestSize.Level1) 962 { 963 CALL_TEST_DEBUG; 964 InputDeviceManager inputDevice; 965 std::string programName = "program"; 966 int32_t moduleType = 1; 967 int32_t fd = 2; 968 int32_t uid = 3; 969 int32_t pid = 4; 970 std::shared_ptr<MockUDSSession> mockSession = std::make_shared<MockUDSSession> 971 (programName, moduleType, fd, uid, pid); 972 EXPECT_CALL(*mockSession, SendMsg(testing::_)).WillRepeatedly(testing::Return(true)); 973 int32_t result = inputDevice.NotifyMessage(mockSession, 1, "type"); 974 EXPECT_EQ(result, RET_OK); 975 } 976 977 /** 978 * @tc.name: NotifyMessage_Test_002 979 * @tc.desc: Test the function NotifyMessage 980 * @tc.type: FUNC 981 * @tc.require: 982 */ 983 HWTEST_F(InputDeviceManagerTest, NotifyMessage_Test_002, TestSize.Level1) 984 { 985 CALL_TEST_DEBUG; 986 InputDeviceManager inputDevice; 987 std::string programName = "program"; 988 int32_t moduleType = 1; 989 int32_t fd = 2; 990 int32_t uid = 3; 991 int32_t pid = 4; 992 std::shared_ptr<MockUDSSession> mockSession = std::make_shared<MockUDSSession> 993 (programName, moduleType, fd, uid, pid); 994 EXPECT_CALL(*mockSession, SendMsg(testing::_)).WillRepeatedly(testing::Return(false)); 995 int32_t result = inputDevice.NotifyMessage(mockSession, 1, "type"); 996 EXPECT_EQ(result, RET_OK); 997 } 998 999 /** 1000 * @tc.name: NotifyMessage_Test_003 1001 * @tc.desc: Test the function NotifyMessage 1002 * @tc.type: FUNC 1003 * @tc.require: 1004 */ 1005 HWTEST_F(InputDeviceManagerTest, NotifyMessage_Test_003, TestSize.Level1) 1006 { 1007 CALL_TEST_DEBUG; 1008 InputDeviceManager inputDevice; 1009 std::string programName = "program"; 1010 int32_t moduleType = 1; 1011 int32_t fd = 2; 1012 int32_t uid = 3; 1013 int32_t pid = 4; 1014 std::shared_ptr<MockUDSSession> mockSession = std::make_shared<MockUDSSession> 1015 (programName, moduleType, fd, uid, pid); 1016 EXPECT_CALL(*mockSession, SendMsg(testing::_)).WillRepeatedly(testing::Return(false)); 1017 SessionPtr nullSession = nullptr; 1018 int32_t result = inputDevice.NotifyMessage(nullSession, 1, "type"); 1019 EXPECT_NE(result, RET_OK); 1020 } 1021 1022 /** 1023 * @tc.name: GetInputDevice_Test_002 1024 * @tc.desc: Test the function GetInputDevice 1025 * @tc.type: FUNC 1026 * @tc.require: 1027 */ 1028 HWTEST_F(InputDeviceManagerTest, GetInputDevice_Test_002, TestSize.Level1) 1029 { 1030 CALL_TEST_DEBUG; 1031 InputDeviceManager inputDevice; 1032 1033 int32_t id = -1; 1034 bool checked = true; 1035 std::shared_ptr inputDeviceManager = inputDevice.GetInputDevice(id, checked); 1036 EXPECT_EQ(inputDeviceManager, nullptr); 1037 id = 1; 1038 checked = false; 1039 inputDeviceManager = inputDevice.GetInputDevice(id, checked); 1040 EXPECT_EQ(inputDeviceManager, nullptr); 1041 id = -1; 1042 checked = false; 1043 inputDeviceManager = inputDevice.GetInputDevice(id, checked); 1044 EXPECT_EQ(inputDeviceManager, nullptr); 1045 } 1046 1047 /** 1048 * @tc.name: GetInputDeviceIds_Test_002 1049 * @tc.desc: Test the function GetInputDeviceIds 1050 * @tc.type: FUNC 1051 * @tc.require: 1052 */ 1053 HWTEST_F(InputDeviceManagerTest, GetInputDeviceIds_Test_002, TestSize.Level1) 1054 { 1055 CALL_TEST_DEBUG; 1056 InputDeviceManager manager; 1057 std::vector<int32_t> expectedIds = {1, 2, 3}; 1058 std::vector<int32_t> actualIds = manager.GetInputDeviceIds(); 1059 ASSERT_NE(expectedIds, actualIds); 1060 } 1061 1062 /** 1063 * @tc.name: SupportKeys_Test_002 1064 * @tc.desc: Test the function SupportKeys 1065 * @tc.type: FUNC 1066 * @tc.require: 1067 */ 1068 HWTEST_F(InputDeviceManagerTest, SupportKeys_Test_002, TestSize.Level1) 1069 { 1070 CALL_TEST_DEBUG; 1071 InputDeviceManager inputDevice; 1072 int32_t deviceId = 1; 1073 int32_t COMMON_PARAMETER_ERROR = 401; 1074 std::vector<int32_t> keyCodes = {1, 2, 3}; 1075 std::vector<bool> keystrokes{true}; 1076 int32_t ret = inputDevice.SupportKeys(deviceId, keyCodes, keystrokes); 1077 EXPECT_EQ(ret, COMMON_PARAMETER_ERROR); 1078 EXPECT_NE(keystrokes.size(), keyCodes.size()); 1079 EXPECT_TRUE(keystrokes[0]); 1080 EXPECT_FALSE(keystrokes[1]); 1081 EXPECT_FALSE(keystrokes[2]); 1082 deviceId = -1; 1083 keyCodes = {1, 2, 3}; 1084 ret = inputDevice.SupportKeys(deviceId, keyCodes, keystrokes); 1085 EXPECT_EQ(ret, COMMON_PARAMETER_ERROR); 1086 EXPECT_FALSE(keystrokes.empty()); 1087 deviceId = 100; 1088 keyCodes = {1, 2, 3}; 1089 ret = inputDevice.SupportKeys(deviceId, keyCodes, keystrokes); 1090 EXPECT_EQ(ret, COMMON_PARAMETER_ERROR); 1091 EXPECT_FALSE(keystrokes.empty()); 1092 deviceId = 1; 1093 keyCodes.clear(); 1094 keystrokes.clear(); 1095 ret = inputDevice.SupportKeys(deviceId, keyCodes, keystrokes); 1096 EXPECT_EQ(ret, COMMON_PARAMETER_ERROR); 1097 EXPECT_TRUE(keystrokes.empty()); 1098 } 1099 1100 /** 1101 * @tc.name: GetDeviceConfig_Test_002 1102 * @tc.desc: Test the function GetDeviceConfig 1103 * @tc.type: FUNC 1104 * @tc.require: 1105 */ 1106 HWTEST_F(InputDeviceManagerTest, GetDeviceConfig_Test_002, TestSize.Level1) 1107 { 1108 CALL_TEST_DEBUG; 1109 InputDeviceManager inputDevice; 1110 int32_t deviceId = -1; 1111 int32_t keyboardType = 5; 1112 bool ret = inputDevice.GetDeviceConfig(deviceId, keyboardType); 1113 EXPECT_FALSE(ret); 1114 deviceId = 10; 1115 keyboardType = -3; 1116 ret = inputDevice.GetDeviceConfig(deviceId, keyboardType); 1117 EXPECT_FALSE(ret); 1118 deviceId = -8; 1119 keyboardType = -10; 1120 ret = inputDevice.GetDeviceConfig(deviceId, keyboardType); 1121 EXPECT_FALSE(ret); 1122 } 1123 1124 /** 1125 * @tc.name: GetKeyboardBusMode_Test_002 1126 * @tc.desc: Test the function GetKeyboardBusMode 1127 * @tc.type: FUNC 1128 * @tc.require: 1129 */ 1130 HWTEST_F(InputDeviceManagerTest, GetKeyboardBusMode_Test_002, TestSize.Level1) 1131 { 1132 CALL_TEST_DEBUG; 1133 InputDeviceManager inputDevice; 1134 int32_t deviceId = 1; 1135 int32_t ret = inputDevice.GetKeyboardBusMode(deviceId); 1136 EXPECT_NE(ret, 0); 1137 deviceId = 0; 1138 ret = inputDevice.GetKeyboardBusMode(deviceId); 1139 EXPECT_NE(ret, 0); 1140 deviceId = -5; 1141 ret = inputDevice.GetKeyboardBusMode(deviceId); 1142 EXPECT_NE(ret, 0); 1143 EXPECT_TRUE(ret); 1144 } 1145 1146 /** 1147 * @tc.name: GetDeviceSupportKey_Test_002 1148 * @tc.desc: Test the function GetDeviceSupportKey 1149 * @tc.type: FUNC 1150 * @tc.require: 1151 */ 1152 HWTEST_F(InputDeviceManagerTest, GetDeviceSupportKey_Test_002, TestSize.Level1) 1153 { 1154 CALL_TEST_DEBUG; 1155 InputDeviceManager inputDevice; 1156 int32_t deviceId = 1; 1157 int32_t keyboardType = -5; 1158 int32_t returnCode = 401; 1159 int32_t ret = inputDevice.GetDeviceSupportKey(deviceId, keyboardType); 1160 EXPECT_EQ(ret, returnCode); 1161 deviceId = -1; 1162 keyboardType = 2; 1163 ret = inputDevice.GetDeviceSupportKey(deviceId, keyboardType); 1164 EXPECT_EQ(ret, returnCode); 1165 deviceId = -1; 1166 keyboardType = -2; 1167 ret = inputDevice.GetDeviceSupportKey(deviceId, keyboardType); 1168 EXPECT_EQ(ret, returnCode); 1169 } 1170 1171 /** 1172 * @tc.name: GetKeyboardType_Test_002 1173 * @tc.desc: Test the function GetKeyboardType 1174 * @tc.type: FUNC 1175 * @tc.require: 1176 */ 1177 HWTEST_F(InputDeviceManagerTest, GetKeyboardType_Test_002, TestSize.Level1) 1178 { 1179 CALL_TEST_DEBUG; 1180 InputDeviceManager inputDevice; 1181 int32_t deviceId = 1; 1182 int32_t keyboardType = -100; 1183 int32_t returnCode = 401; 1184 int32_t ret = inputDevice.GetKeyboardType(deviceId, keyboardType); 1185 EXPECT_EQ(ret, returnCode); 1186 deviceId = -1; 1187 keyboardType = 1; 1188 ret = inputDevice.GetKeyboardType(deviceId, keyboardType); 1189 EXPECT_EQ(ret, returnCode); 1190 deviceId = -10; 1191 keyboardType = -5; 1192 ret = inputDevice.GetKeyboardType(deviceId, keyboardType); 1193 EXPECT_EQ(ret, returnCode); 1194 } 1195 1196 /** 1197 * @tc.name: SetInputStatusChangeCallback_Test_001 1198 * @tc.desc: Test the function SetInputStatusChangeCallback 1199 * @tc.type: FUNC 1200 * @tc.require: 1201 */ 1202 HWTEST_F(InputDeviceManagerTest, SetInputStatusChangeCallback_Test_001, TestSize.Level1) 1203 { 1204 CALL_TEST_DEBUG; 1205 InputDeviceManager inputDevice; 1206 using InputDeviceCallback = std::function<void(int, std::string, std::string, std::string)>; 1207 InputDeviceCallback callback = __anon354c2eb80202(int status, std::string nodeName, const std::string& deviceName, const std::string& deviceId) 1208 [] (int status, std::string nodeName, const std::string& deviceName, const std::string& deviceId) {}; 1209 ASSERT_NO_FATAL_FAILURE(inputDevice.SetInputStatusChangeCallback(callback)); 1210 } 1211 1212 /** 1213 * @tc.name: AddDevListener_Test_001 1214 * @tc.desc: Test the function AddDevListener 1215 * @tc.type: FUNC 1216 * @tc.require: 1217 */ 1218 HWTEST_F(InputDeviceManagerTest, AddDevListener_Test_001, TestSize.Level1) 1219 { 1220 CALL_TEST_DEBUG; 1221 InputDeviceManager inputDevice; 1222 SessionPtr session = std::shared_ptr<OHOS::MMI::UDSSession>(); 1223 ASSERT_NO_FATAL_FAILURE(inputDevice.AddDevListener(session)); 1224 } 1225 1226 /** 1227 * @tc.name: RemoveDevListener_Test_001 1228 * @tc.desc: Test the function RemoveDevListener 1229 * @tc.type: FUNC 1230 * @tc.require: 1231 */ 1232 HWTEST_F(InputDeviceManagerTest, RemoveDevListener_Test_001, TestSize.Level1) 1233 { 1234 CALL_TEST_DEBUG; 1235 InputDeviceManager inputDevice; 1236 SessionPtr session = std::shared_ptr<OHOS::MMI::UDSSession>(); 1237 ASSERT_NO_FATAL_FAILURE(inputDevice.RemoveDevListener(session)); 1238 } 1239 1240 /** 1241 * @tc.name: HasPointerDevice_Test_001 1242 * @tc.desc: Test the function HasPointerDevice 1243 * @tc.type: FUNC 1244 * @tc.require: 1245 */ 1246 HWTEST_F(InputDeviceManagerTest, HasPointerDevice_Test_001, TestSize.Level1) 1247 { 1248 CALL_TEST_DEBUG; 1249 InputDeviceManager inputDevice; 1250 bool ret = inputDevice.HasPointerDevice(); 1251 EXPECT_FALSE(ret); 1252 ret = inputDevice.HasTouchDevice(); 1253 EXPECT_FALSE(ret); 1254 } 1255 1256 /** 1257 * @tc.name: NotifyDevCallback_Test_001 1258 * @tc.desc: Test the function NotifyDevCallback 1259 * @tc.type: FUNC 1260 * @tc.require: 1261 */ 1262 HWTEST_F(InputDeviceManagerTest, NotifyDevCallback_Test_001, TestSize.Level1) 1263 { 1264 CALL_TEST_DEBUG; 1265 InputDeviceManager inputDevice; 1266 int32_t deviceId = 1; 1267 InputDeviceManager::InputDeviceInfo inDevice; 1268 ASSERT_NO_FATAL_FAILURE(inputDevice.NotifyDevCallback(deviceId, inDevice)); 1269 } 1270 1271 /** 1272 * @tc.name: OnInputDeviceAdded_Test_001 1273 * @tc.desc: Test the function OnInputDeviceAdded 1274 * @tc.type: FUNC 1275 * @tc.require: 1276 */ 1277 HWTEST_F(InputDeviceManagerTest, OnInputDeviceAdded_Test_001, TestSize.Level1) 1278 { 1279 CALL_TEST_DEBUG; 1280 InputDeviceManager inputDevice; 1281 libinput_device* inputDevices = nullptr; 1282 ASSERT_NO_FATAL_FAILURE(inputDevice.OnInputDeviceAdded(inputDevices)); 1283 } 1284 1285 /** 1286 * @tc.name: OnInputDeviceRemoved_Test_001 1287 * @tc.desc: Test the function OnInputDeviceRemoved 1288 * @tc.type: FUNC 1289 * @tc.require: 1290 */ 1291 HWTEST_F(InputDeviceManagerTest, OnInputDeviceRemoved_Test_001, TestSize.Level1) 1292 { 1293 CALL_TEST_DEBUG; 1294 InputDeviceManager inputDevice; 1295 libinput_device* inputDevices = nullptr; 1296 ASSERT_NO_FATAL_FAILURE(inputDevice.OnInputDeviceRemoved(inputDevices)); 1297 } 1298 1299 /** 1300 * @tc.name: InputDeviceManagerTest_IsRemote 1301 * @tc.desc: Test Cover the else branch of if (device != inputDevice_.end()) 1302 * @tc.type: FUNC 1303 * @tc.require: 1304 */ 1305 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_IsRemote, TestSize.Level1) 1306 { 1307 CALL_TEST_DEBUG; 1308 InputDeviceManager inputDevice; 1309 int32_t id = 30; 1310 ASSERT_FALSE(inputDevice.IsRemote(id)); 1311 } 1312 1313 /** 1314 * @tc.name: InputDeviceManagerTest_IsRemote_001 1315 * @tc.desc: Test Cover the if (device != inputDevice_.end()) branch 1316 * @tc.type: FUNC 1317 * @tc.require: 1318 */ 1319 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_IsRemote_001, TestSize.Level1) 1320 { 1321 CALL_TEST_DEBUG; 1322 InputDeviceManager inputDevice; 1323 InputDeviceManager::InputDeviceInfo inputDeviceInfo; 1324 int32_t id = 30; 1325 inputDeviceInfo.isRemote = true; 1326 inputDevice.inputDevice_.insert(std::make_pair(id, inputDeviceInfo)); 1327 ASSERT_TRUE(inputDevice.IsRemote(id)); 1328 } 1329 1330 /** 1331 * @tc.name: InputDeviceManagerTest_NotifyDevCallback 1332 * @tc.desc: Test Cover the if (!inDevice.isTouchableDevice || (deviceId < 0)) branch 1333 * @tc.type: FUNC 1334 * @tc.require: 1335 */ 1336 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_NotifyDevCallback, TestSize.Level1) 1337 { 1338 CALL_TEST_DEBUG; 1339 InputDeviceManager inputDevice; 1340 InputDeviceManager::InputDeviceInfo inDevice; 1341 int32_t deviceid = -1; 1342 inDevice.isTouchableDevice = false; 1343 ASSERT_NO_FATAL_FAILURE(inputDevice.NotifyDevCallback(deviceid, inDevice)); 1344 inDevice.isTouchableDevice = true; 1345 ASSERT_NO_FATAL_FAILURE(inputDevice.NotifyDevCallback(deviceid, inDevice)); 1346 } 1347 1348 /** 1349 * @tc.name: InputDeviceManagerTest_NotifyDevCallback_001 1350 * @tc.desc: Test Cover the if (!inDevice.sysUid.empty()) branch 1351 * @tc.type: FUNC 1352 * @tc.require: 1353 */ 1354 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_NotifyDevCallback_001, TestSize.Level1) 1355 { 1356 CALL_TEST_DEBUG; 1357 InputDeviceManager inputDevice; 1358 InputDeviceManager::InputDeviceInfo inDevice; 1359 int32_t deviceid = 1; 1360 inDevice.isTouchableDevice = true; 1361 inDevice.sysUid = "123456"; 1362 using inputDeviceCallback = 1363 std::function<void(int32_t deviceId, std::string nodeName, std::string devName, std::string devStatus)>; 1364 inputDeviceCallback callback = __anon354c2eb80302(int32_t deviceId, std::string nodeName, std::string devName, std::string devStatus) 1365 [] (int32_t deviceId, std::string nodeName, std::string devName, std::string devStatus) {}; 1366 inputDevice.SetInputStatusChangeCallback(callback); 1367 ASSERT_NO_FATAL_FAILURE(inputDevice.NotifyDevCallback(deviceid, inDevice)); 1368 inDevice.sysUid.clear(); 1369 ASSERT_NO_FATAL_FAILURE(inputDevice.NotifyDevCallback(deviceid, inDevice)); 1370 } 1371 1372 /** 1373 * @tc.name: InputDeviceManagerTest_ScanPointerDevice 1374 * @tc.desc: Test Cover the if (it->second.isPointerDevice && it->second.enable) branch 1375 * @tc.type: FUNC 1376 * @tc.require: 1377 */ 1378 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_ScanPointerDevice, TestSize.Level1) 1379 { 1380 CALL_TEST_DEBUG; 1381 InputDeviceManager inputDevice; 1382 InputDeviceManager::InputDeviceInfo inDevice; 1383 int32_t deviceId = 10; 1384 inDevice.isPointerDevice = false; 1385 inDevice.enable = false; 1386 inputDevice.inputDevice_.insert(std::make_pair(deviceId, inDevice)); 1387 deviceId = 15; 1388 inDevice.isPointerDevice = true; 1389 inDevice.enable = true; 1390 inputDevice.inputDevice_.insert(std::make_pair(deviceId, inDevice)); 1391 ASSERT_NO_FATAL_FAILURE(inputDevice.ScanPointerDevice()); 1392 } 1393 1394 /** 1395 * @tc.name: InputDeviceManagerTest_ScanPointerDevice_001 1396 * @tc.desc: Test Cover the if (!hasPointerDevice) branch 1397 * @tc.type: FUNC 1398 * @tc.require: 1399 */ 1400 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_ScanPointerDevice_001, TestSize.Level1) 1401 { 1402 CALL_TEST_DEBUG; 1403 InputDeviceManager inputDevice; 1404 InputDeviceManager::InputDeviceInfo inDevice; 1405 int32_t deviceId = 10; 1406 inDevice.isPointerDevice = false; 1407 inDevice.enable = false; 1408 inputDevice.inputDevice_.insert(std::make_pair(deviceId, inDevice)); 1409 ASSERT_NO_FATAL_FAILURE(inputDevice.ScanPointerDevice()); 1410 } 1411 1412 /** 1413 * @tc.name: InputDeviceManagerTest_OnEnableInputDevice 1414 * @tc.desc: Test Cover the if (enable) and if (keyboardType != KEYBOARD_TYPE_ALPHABETICKEYBOARD) and 1415 * <br> if (item.second.isPointerDevice && item.second.enable) branch 1416 * @tc.type: FUNC 1417 * @tc.require: 1418 */ 1419 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_OnEnableInputDevice, TestSize.Level1) 1420 { 1421 CALL_TEST_DEBUG; 1422 InputDeviceManager::InputDeviceInfo inDevice; 1423 DeviceConfig deviceConfig; 1424 deviceConfig.keyboardType = KEYBOARD_TYPE_NONE; 1425 bool enable = true; 1426 int32_t deviceId = 10; 1427 inDevice.isRemote = true; 1428 inDevice.enable = false; 1429 inDevice.isPointerDevice = true; 1430 INPUT_DEV_MGR->inputDevice_.insert(std::make_pair(deviceId, inDevice)); 1431 KeyRepeat->deviceConfig_.insert(std::make_pair(deviceId, deviceConfig)); 1432 ASSERT_EQ(INPUT_DEV_MGR->OnEnableInputDevice(enable), RET_OK); 1433 INPUT_DEV_MGR->inputDevice_.clear(); 1434 KeyRepeat->deviceConfig_.clear(); 1435 } 1436 1437 /** 1438 * @tc.name: InputDeviceManagerTest_OnEnableInputDevice_001 1439 * @tc.desc: Test Cover the else branch of the OnEnableInputDevice function 1440 * @tc.type: FUNC 1441 * @tc.require: 1442 */ 1443 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_OnEnableInputDevice_001, TestSize.Level1) 1444 { 1445 CALL_TEST_DEBUG; 1446 InputDeviceManager::InputDeviceInfo inDevice; 1447 DeviceConfig deviceConfig; 1448 deviceConfig.keyboardType = KEYBOARD_TYPE_ALPHABETICKEYBOARD; 1449 bool enable = false; 1450 int32_t deviceId = 20; 1451 inDevice.isRemote = true; 1452 inDevice.enable = true; 1453 inDevice.isPointerDevice = false; 1454 INPUT_DEV_MGR->inputDevice_.insert(std::make_pair(deviceId, inDevice)); 1455 KeyRepeat->deviceConfig_.insert(std::make_pair(deviceId, deviceConfig)); 1456 deviceId = 30; 1457 inDevice.isRemote = false; 1458 inDevice.enable = false; 1459 INPUT_DEV_MGR->inputDevice_.insert(std::make_pair(deviceId, inDevice)); 1460 ASSERT_EQ(INPUT_DEV_MGR->OnEnableInputDevice(enable), RET_OK); 1461 INPUT_DEV_MGR->inputDevice_.clear(); 1462 KeyRepeat->deviceConfig_.clear(); 1463 } 1464 1465 /** 1466 * @tc.name: InputDeviceManagerTest_GetTouchPadIds_001 1467 * @tc.desc: Test GetTouchPadIds 1468 * @tc.type: FUNC 1469 * @tc.require: 1470 */ 1471 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_GetTouchPadIds_001, TestSize.Level1) 1472 { 1473 CALL_TEST_DEBUG; 1474 InputDeviceManager inputDevice; 1475 InputDeviceManager::InputDeviceInfo inDevice; 1476 int32_t deviceId = 5; 1477 inDevice.isPointerDevice = false; 1478 inDevice.enable = false; 1479 inDevice.dhid = 2; 1480 inputDevice.inputDevice_.insert(std::make_pair(deviceId, inDevice)); 1481 ASSERT_NO_FATAL_FAILURE(INPUT_DEV_MGR->GetTouchPadIds()); 1482 } 1483 1484 /** 1485 * @tc.name: InputDeviceManagerTest_GetTouchPadIds_002 1486 * @tc.desc: Test GetTouchPadIds 1487 * @tc.type: FUNC 1488 * @tc.require: 1489 */ 1490 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_GetTouchPadIds_002, TestSize.Level1) 1491 { 1492 CALL_TEST_DEBUG; 1493 InputDeviceManager inputDevice; 1494 InputDeviceManager::InputDeviceInfo inDevice; 1495 int32_t deviceId = 3; 1496 inDevice.enable = false; 1497 inDevice.dhid = 2; 1498 inputDevice.inputDevice_.insert(std::make_pair(deviceId, inDevice)); 1499 inputDevice.inputDevice_.clear(); 1500 ASSERT_NO_FATAL_FAILURE(INPUT_DEV_MGR->GetTouchPadIds()); 1501 } 1502 1503 /** 1504 * @tc.name: InputDeviceManagerTest_IsMatchKeys_001 1505 * @tc.desc: Test IsMatchKeys 1506 * @tc.type: FUNC 1507 * @tc.require: 1508 */ 1509 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_IsMatchKeys_001, TestSize.Level1) 1510 { 1511 CALL_TEST_DEBUG; 1512 struct libinput_device *device = nullptr; 1513 std::vector<int32_t> keyCodes; 1514 keyCodes.push_back(KeyEvent::KEYCODE_T); 1515 keyCodes.push_back(KeyEvent::KEYCODE_NUMPAD_1); 1516 1517 bool ret1 = INPUT_DEV_MGR->IsMatchKeys(device, keyCodes); 1518 EXPECT_FALSE(ret1); 1519 } 1520 1521 /** 1522 * @tc.name: InputDeviceManagerTest_OnInputDeviceAdded_Test_01 1523 * @tc.desc: Test the function OnInputDeviceAdded 1524 * @tc.type: FUNC 1525 * @tc.require: 1526 */ 1527 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_OnInputDeviceAdded_Test_01, TestSize.Level1) 1528 { 1529 CALL_TEST_DEBUG; 1530 InputDeviceManager deviceMgr; 1531 int32_t deviceId = 3; 1532 struct libinput_device *inputDevice = nullptr; 1533 1534 InputDeviceManager::InputDeviceInfo deviceInfo; 1535 deviceInfo.inputDeviceOrigin = nullptr; 1536 deviceMgr.inputDevice_.insert(std::make_pair(deviceId, deviceInfo)); 1537 EXPECT_TRUE(deviceInfo.inputDeviceOrigin == inputDevice); 1538 ASSERT_NO_FATAL_FAILURE(deviceMgr.OnInputDeviceAdded(inputDevice)); 1539 } 1540 1541 /** 1542 * @tc.name: InputDeviceManagerTest_OnInputDeviceAdded_Test_02 1543 * @tc.desc: Test the function OnInputDeviceAdded 1544 * @tc.type: FUNC 1545 * @tc.require: 1546 */ 1547 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_OnInputDeviceAdded_Test_02, TestSize.Level1) 1548 { 1549 CALL_TEST_DEBUG; 1550 InputDeviceManager deviceMgr; 1551 int32_t deviceId = 3; 1552 struct libinput_device *inputDevice = nullptr; 1553 1554 InputDeviceManager::InputDeviceInfo deviceInfo; 1555 deviceInfo.isRemote = false; 1556 deviceInfo.isPointerDevice = true; 1557 deviceInfo.enable = true; 1558 deviceMgr.inputDevice_.insert(std::make_pair(deviceId, deviceInfo)); 1559 ASSERT_NO_FATAL_FAILURE(deviceMgr.OnInputDeviceAdded(inputDevice)); 1560 } 1561 1562 /** 1563 * @tc.name: OnInputDeviceRemoved_Test_01 1564 * @tc.desc: Test the function OnInputDeviceRemoved 1565 * @tc.type: FUNC 1566 * @tc.require: 1567 */ 1568 HWTEST_F(InputDeviceManagerTest, OnInputDeviceRemoved_Test_01, TestSize.Level1) 1569 { 1570 CALL_TEST_DEBUG; 1571 InputDeviceManager deviceMgr; 1572 int32_t deviceId = 5; 1573 struct libinput_device *inputDevice = nullptr; 1574 1575 InputDeviceManager::InputDeviceInfo deviceInfo; 1576 deviceInfo.inputDeviceOrigin = nullptr; 1577 deviceMgr.inputDevice_.insert(std::make_pair(deviceId, deviceInfo)); 1578 EXPECT_TRUE(deviceInfo.inputDeviceOrigin == inputDevice); 1579 ASSERT_NO_FATAL_FAILURE(deviceMgr.OnInputDeviceRemoved(inputDevice)); 1580 } 1581 1582 /** 1583 * @tc.name: OnInputDeviceRemoved_Test_02 1584 * @tc.desc: Test the function OnInputDeviceRemoved 1585 * @tc.type: FUNC 1586 * @tc.require: 1587 */ 1588 HWTEST_F(InputDeviceManagerTest, OnInputDeviceRemoved_Test_02, TestSize.Level1) 1589 { 1590 CALL_TEST_DEBUG; 1591 InputDeviceManager deviceMgr; 1592 int32_t deviceId = 5; 1593 struct libinput_device *inputDevice = nullptr; 1594 1595 InputDeviceManager::InputDeviceInfo deviceInfo; 1596 deviceInfo.isRemote = false; 1597 deviceInfo.isPointerDevice = true; 1598 deviceMgr.inputDevice_.insert(std::make_pair(deviceId, deviceInfo)); 1599 1600 std::string sysUid; 1601 EXPECT_TRUE(sysUid.empty()); 1602 ASSERT_NO_FATAL_FAILURE(deviceMgr.OnInputDeviceRemoved(inputDevice)); 1603 } 1604 1605 /** 1606 * @tc.name: InputDeviceManagerTest_GetKeyboardDevice_Test_01 1607 * @tc.desc: Test the function GetKeyboardDevice 1608 * @tc.type: FUNC 1609 * @tc.require: 1610 */ 1611 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_GetKeyboardDevice_Test_01, TestSize.Level1) 1612 { 1613 CALL_TEST_DEBUG; 1614 InputDeviceManager deviceMgr; 1615 struct libinput_device *device = nullptr; 1616 std::vector<int32_t> keyCodes; 1617 keyCodes.push_back(KeyEvent::KEYCODE_Q); 1618 keyCodes.push_back(KeyEvent::KEYCODE_NUMPAD_1); 1619 1620 bool ret1 = INPUT_DEV_MGR->IsMatchKeys(device, keyCodes); 1621 EXPECT_FALSE(ret1); 1622 auto ret2 = deviceMgr.GetKeyboardDevice(); 1623 EXPECT_EQ(ret2, nullptr); 1624 } 1625 1626 /** 1627 * @tc.name: InputDeviceManagerTest_GetKeyboardDevice_Test_02 1628 * @tc.desc: Test the function GetKeyboardDevice 1629 * @tc.type: FUNC 1630 * @tc.require: 1631 */ 1632 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_GetKeyboardDevice_Test_02, TestSize.Level1) 1633 { 1634 CALL_TEST_DEBUG; 1635 InputDeviceManager deviceMgr; 1636 struct libinput_device *device = nullptr; 1637 std::vector<int32_t> keyCodes; 1638 keyCodes.push_back(KeyEvent::KEYCODE_Q); 1639 keyCodes.push_back(KeyEvent::KEYCODE_NUMPAD_1); 1640 INPUT_DEV_MGR->inputDevice_.clear(); 1641 bool ret1 = INPUT_DEV_MGR->IsMatchKeys(device, keyCodes); 1642 EXPECT_FALSE(ret1); 1643 auto ret2 = deviceMgr.GetKeyboardDevice(); 1644 EXPECT_EQ(ret2, nullptr); 1645 } 1646 1647 /** 1648 * @tc.name: InputDeviceManagerTest_GetDeviceSupportKey_Test_01 1649 * @tc.desc: Test the function GetDeviceSupportKey 1650 * @tc.type: FUNC 1651 * @tc.require: 1652 */ 1653 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_GetDeviceSupportKey_Test_01, TestSize.Level1) 1654 { 1655 CALL_TEST_DEBUG; 1656 std::vector<int32_t> keyCodes; 1657 int32_t deviceId = 1; 1658 int32_t keyboardType = KEYBOARD_TYPE_REMOTECONTROL; 1659 std::vector<bool> supportKey; 1660 int32_t returnCode1 = 401; 1661 1662 InputDeviceManager inputDevice; 1663 keyCodes.push_back(KeyEvent::KEYCODE_Q); 1664 keyCodes.push_back(KeyEvent::KEYCODE_HOME); 1665 keyCodes.push_back(KeyEvent::KEYCODE_CTRL_LEFT); 1666 keyCodes.push_back(KeyEvent::KEYCODE_F2); 1667 1668 int32_t ret = INPUT_DEV_MGR->SupportKeys(deviceId, keyCodes, supportKey); 1669 EXPECT_NE(ret, RET_OK); 1670 int32_t ret2 = inputDevice.GetDeviceSupportKey(deviceId, keyboardType); 1671 EXPECT_EQ(ret2, returnCode1); 1672 } 1673 1674 /** 1675 * @tc.name: InputDeviceManagerTest_IsInputDeviceEnable_Test_01 1676 * @tc.desc: Test the function IsInputDeviceEnable 1677 * @tc.type: FUNC 1678 * @tc.require: 1679 */ 1680 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_IsInputDeviceEnable_Test_01, TestSize.Level1) 1681 { 1682 CALL_TEST_DEBUG; 1683 InputDeviceManager inputDevice; 1684 InputDeviceManager::InputDeviceInfo inDevice; 1685 int32_t deviceId = 1000; 1686 bool ret = inputDevice.IsInputDeviceEnable(deviceId); 1687 ASSERT_EQ(ret, false); 1688 deviceId = 5; 1689 inDevice.enable = true; 1690 inputDevice.inputDevice_.insert(std::make_pair(deviceId, inDevice)); 1691 deviceId = 5; 1692 ret = inputDevice.IsInputDeviceEnable(deviceId); 1693 ASSERT_EQ(ret, true); 1694 } 1695 1696 #ifdef OHOS_BUILD_ENABLE_KEYBOARD_EXT_FLAG 1697 /** 1698 * @tc.name: InputDeviceManagerTest_KeyboardExtFlag_Verify_Json 1699 * @tc.desc: Test the json file format 1700 * @tc.type: FUNC 1701 * @tc.require: 1702 */ 1703 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_KeyboardExtFlag_Verify_Json, TestSize.Level1) 1704 { 1705 CALL_TEST_DEBUG; 1706 const std::string filePath = "/system/etc/multimodalinput/keyboard_ext_flag.json"; 1707 std::ifstream file(filePath); 1708 EXPECT_TRUE(file.is_open()); 1709 std::string jsonContent = ReadJsonFile(filePath); 1710 EXPECT_FALSE(jsonContent.empty()); 1711 cJSON *root = cJSON_Parse(jsonContent.c_str()); 1712 EXPECT_NE(root, nullptr); 1713 cJSON *keyboardExtFlag = cJSON_GetObjectItem(root, "keyboardExtFlag"); 1714 EXPECT_NE(keyboardExtFlag, nullptr); 1715 EXPECT_EQ(keyboardExtFlag->type, cJSON_Array); 1716 cJSON *item = nullptr; 1717 cJSON *vendor = nullptr; 1718 cJSON *product = nullptr; 1719 cJSON *extFlag = nullptr; cJSON_ArrayForEach(item,keyboardExtFlag)1720 cJSON_ArrayForEach(item, keyboardExtFlag) 1721 { 1722 vendor = cJSON_GetObjectItem(item, "vendor"); 1723 EXPECT_NE(vendor, nullptr); 1724 EXPECT_EQ(vendor->type, cJSON_Number); 1725 product = cJSON_GetObjectItem(item, "product"); 1726 EXPECT_NE(product, nullptr); 1727 EXPECT_EQ(product->type, cJSON_Number); 1728 extFlag = cJSON_GetObjectItem(item, "extFlag"); 1729 EXPECT_NE(extFlag, nullptr); 1730 EXPECT_EQ(extFlag->type, cJSON_Number); 1731 } 1732 cJSON_Delete(root); 1733 } 1734 #endif // OHOS_BUILD_ENABLE_KEYBOARD_EXT_FLAG 1735 1736 /** 1737 * @tc.name: InputDeviceManagerTest_IsLocalDevice_Test_01 1738 * @tc.desc: Test the function IsLocalDevice 1739 * @tc.type: FUNC 1740 * @tc.require: 1741 */ 1742 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_IsLocalDevice_Test_01, TestSize.Level1) 1743 { 1744 CALL_TEST_DEBUG; 1745 InputDeviceManager::InputDeviceInfo info; 1746 info.networkIdOrigin = "local_device"; 1747 InputDeviceManager inputDevice; 1748 inputDevice.AddPhysicalInputDeviceInner(LOC_INPUT_DEVICE_ID, info); 1749 bool isLocalDevice = inputDevice.IsLocalDevice(LOC_INPUT_DEVICE_ID); 1750 ASSERT_EQ(isLocalDevice, true); 1751 1752 isLocalDevice = inputDevice.IsLocalDevice(UINPUT_INPUT_DEVICE_ID); 1753 ASSERT_EQ(isLocalDevice, false); 1754 1755 isLocalDevice = inputDevice.IsLocalDevice(MIN_VIRTUAL_INPUT_DEVICE_ID); 1756 ASSERT_EQ(isLocalDevice, false); 1757 } 1758 1759 /** 1760 * @tc.name: InputDeviceManagerTest_GetTouchscreenKeyboardType_001 1761 * @tc.desc: Test the function GetTouchscreenKeyboardType, non-touchscreen case. 1762 * @tc.type: FUNC 1763 * @tc.require: 1764 */ 1765 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_GetTouchscreenKeyboardType_001, TestSize.Level1) 1766 { 1767 CALL_TEST_DEBUG; 1768 InputDeviceManager inputDeviceManager; 1769 InputDeviceManager::InputDeviceInfo info; 1770 info.isTouchableDevice = false; 1771 int32_t keyboardType = 0; 1772 EXPECT_EQ(inputDeviceManager.GetTouchscreenKeyboardType(info, keyboardType), RET_ERR); 1773 } 1774 1775 /** 1776 * @tc.name: InputDeviceManagerTest_GetTouchscreenKeyboardType_002 1777 * @tc.desc: Test the function GetTouchscreenKeyboardType, touchscreen with no virtual devices. 1778 * @tc.type: FUNC 1779 * @tc.require: 1780 */ 1781 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_GetTouchscreenKeyboardType_002, TestSize.Level1) 1782 { 1783 CALL_TEST_DEBUG; 1784 InputDeviceManager inputDeviceManager; 1785 InputDeviceManager::InputDeviceInfo info; 1786 info.isTouchableDevice = true; 1787 int32_t keyboardType = 0; 1788 EXPECT_EQ(inputDeviceManager.GetTouchscreenKeyboardType(info, keyboardType), RET_ERR); 1789 } 1790 1791 /** 1792 * @tc.name: InputDeviceManagerTest_GetTouchscreenKeyboardType_003 1793 * @tc.desc: Test the function GetTouchscreenKeyboardType, touchscreen with floating keyboard. 1794 * @tc.type: FUNC 1795 * @tc.require: 1796 */ 1797 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_GetTouchscreenKeyboardType_003, TestSize.Level1) 1798 { 1799 CALL_TEST_DEBUG; 1800 InputDeviceManager inputDeviceManager; 1801 InputDeviceManager::InputDeviceInfo info; 1802 info.isTouchableDevice = true; 1803 int32_t keyboardType = 0; 1804 1805 int32_t deviceId = 1; 1806 auto device = std::make_shared<InputDevice>(); 1807 device->AddCapability(MMI::InputDeviceCapability::INPUT_DEV_CAP_KEYBOARD); 1808 inputDeviceManager.virtualInputDevices_[deviceId] = device; 1809 1810 EXPECT_EQ(inputDeviceManager.GetTouchscreenKeyboardType(info, keyboardType), RET_OK); 1811 EXPECT_EQ(keyboardType, KEYBOARD_TYPE_DIGITALKEYBOARD); 1812 } 1813 1814 /** 1815 * @tc.name: InputDeviceManagerTest_GetTouchscreenKeyboardType_004 1816 * @tc.desc: Test the function GetTouchscreenKeyboardType, touchscreen with full keyboard. 1817 * @tc.type: FUNC 1818 * @tc.require: 1819 */ 1820 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_GetTouchscreenKeyboardType_004, TestSize.Level1) 1821 { 1822 CALL_TEST_DEBUG; 1823 InputDeviceManager inputDeviceManager; 1824 InputDeviceManager::InputDeviceInfo info; 1825 info.isTouchableDevice = true; 1826 int32_t keyboardType = 0; 1827 1828 int32_t deviceId = 1; 1829 auto device = std::make_shared<InputDevice>(); 1830 device->AddCapability(MMI::InputDeviceCapability::INPUT_DEV_CAP_KEYBOARD); 1831 inputDeviceManager.virtualInputDevices_[deviceId] = device; 1832 1833 int32_t deviceId2 = 2; 1834 auto device2 = std::make_shared<InputDevice>(); 1835 device2->AddCapability(MMI::InputDeviceCapability::INPUT_DEV_CAP_POINTER); 1836 inputDeviceManager.virtualInputDevices_[deviceId2] = device2; 1837 1838 EXPECT_EQ(inputDeviceManager.GetTouchscreenKeyboardType(info, keyboardType), RET_OK); 1839 EXPECT_EQ(keyboardType, KEYBOARD_TYPE_ALPHABETICKEYBOARD); 1840 } 1841 1842 /** 1843 * @tc.name: InputDeviceManagerTest_GetVirtualKeyboardType_001 1844 * @tc.desc: Test the function GetVirtualKeyboardType with empty virtual device list 1845 * @tc.type: FUNC 1846 * @tc.require: 1847 */ 1848 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_GetVirtualKeyboardType_001, TestSize.Level1) 1849 { 1850 CALL_TEST_DEBUG; 1851 InputDeviceManager inputDeviceManager; 1852 int32_t deviceId = 1; 1853 int32_t keyboardType = 0; 1854 EXPECT_EQ(inputDeviceManager.GetVirtualKeyboardType(deviceId, keyboardType), RET_ERR); 1855 } 1856 1857 /** 1858 * @tc.name: InputDeviceManagerTest_GetVirtualKeyboardType_002 1859 * @tc.desc: Test the function GetVirtualKeyboardType with non-keyboard virtual device 1860 * @tc.type: FUNC 1861 * @tc.require: 1862 */ 1863 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_GetVirtualKeyboardType_002, TestSize.Level1) 1864 { 1865 CALL_TEST_DEBUG; 1866 InputDeviceManager inputDeviceManager; 1867 int32_t deviceId = 1; 1868 int32_t keyboardType = 0; 1869 inputDeviceManager.virtualInputDevices_[deviceId] = std::make_shared<InputDevice>(); 1870 EXPECT_EQ(inputDeviceManager.GetVirtualKeyboardType(deviceId, keyboardType), RET_OK); 1871 EXPECT_EQ(keyboardType, KEYBOARD_TYPE_NONE); 1872 } 1873 1874 /** 1875 * @tc.name: InputDeviceManagerTest_GetVirtualKeyboardType_003 1876 * @tc.desc: Test the function GetVirtualKeyboardType with floating virtual keyboard 1877 * @tc.type: FUNC 1878 * @tc.require: 1879 */ 1880 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_GetVirtualKeyboardType_003, TestSize.Level1) 1881 { 1882 CALL_TEST_DEBUG; 1883 InputDeviceManager inputDeviceManager; 1884 int32_t deviceId = 1; 1885 int32_t keyboardType = 0; 1886 auto device = std::make_shared<InputDevice>(); 1887 device->AddCapability(MMI::InputDeviceCapability::INPUT_DEV_CAP_KEYBOARD); 1888 inputDeviceManager.virtualInputDevices_[deviceId] = device; 1889 EXPECT_EQ(inputDeviceManager.GetVirtualKeyboardType(deviceId, keyboardType), RET_OK); 1890 EXPECT_EQ(keyboardType, KEYBOARD_TYPE_ALPHABETICKEYBOARD); 1891 } 1892 1893 /** 1894 * @tc.name: InputDeviceManagerTest_GetVirtualKeyboardType_004 1895 * @tc.desc: Test the function GetVirtualKeyboardType with full virtual keyboard 1896 * @tc.type: FUNC 1897 * @tc.require: 1898 */ 1899 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_GetVirtualKeyboardType_004, TestSize.Level1) 1900 { 1901 CALL_TEST_DEBUG; 1902 InputDeviceManager inputDeviceManager; 1903 int32_t deviceId = 1; 1904 int32_t keyboardType = 0; 1905 auto device1 = std::make_shared<InputDevice>(); 1906 device1->AddCapability(MMI::InputDeviceCapability::INPUT_DEV_CAP_KEYBOARD); 1907 inputDeviceManager.virtualInputDevices_[deviceId] = device1; 1908 1909 int32_t deviceId2 = 2; 1910 int32_t keyboardType2 = 0; 1911 auto device2 = std::make_shared<InputDevice>(); 1912 device2->AddCapability(MMI::InputDeviceCapability::INPUT_DEV_CAP_POINTER); 1913 inputDeviceManager.virtualInputDevices_[deviceId2] = device2; 1914 EXPECT_EQ(inputDeviceManager.GetVirtualKeyboardType(deviceId, keyboardType), RET_OK); 1915 EXPECT_EQ(keyboardType, KEYBOARD_TYPE_ALPHABETICKEYBOARD); 1916 1917 EXPECT_EQ(inputDeviceManager.GetVirtualKeyboardType(deviceId2, keyboardType2), RET_OK); 1918 EXPECT_EQ(keyboardType2, KEYBOARD_TYPE_NONE); 1919 } 1920 1921 /** 1922 * @tc.name: InputDeviceManagerTest_FillInputDeviceWithVirtualCapability_001 1923 * @tc.desc: Test the function FillInputDeviceWithVirtualCapability with non-touchscreen 1924 * @tc.type: FUNC 1925 * @tc.require: 1926 */ 1927 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_FillInputDeviceWithVirtualCapability_001, TestSize.Level1) 1928 { 1929 CALL_TEST_DEBUG; 1930 InputDeviceManager inputDeviceManager; 1931 auto inputDevice = std::make_shared<InputDevice>(); 1932 InputDeviceManager::InputDeviceInfo info; 1933 info.isTouchableDevice = false; 1934 ASSERT_NO_FATAL_FAILURE(inputDeviceManager.FillInputDeviceWithVirtualCapability(inputDevice, info)); 1935 EXPECT_EQ(inputDevice->HasCapability(InputDeviceCapability::INPUT_DEV_CAP_KEYBOARD), false); 1936 EXPECT_EQ(inputDevice->HasCapability(InputDeviceCapability::INPUT_DEV_CAP_POINTER), false); 1937 } 1938 1939 /** 1940 * @tc.name: InputDeviceManagerTest_FillInputDeviceWithVirtualCapability_002 1941 * @tc.desc: Test the function FillInputDeviceWithVirtualCapability with touchscreen but no virtual devices 1942 * @tc.type: FUNC 1943 * @tc.require: 1944 */ 1945 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_FillInputDeviceWithVirtualCapability_002, TestSize.Level1) 1946 { 1947 CALL_TEST_DEBUG; 1948 InputDeviceManager inputDeviceManager; 1949 auto inputDevice = std::make_shared<InputDevice>(); 1950 InputDeviceManager::InputDeviceInfo info; 1951 info.isTouchableDevice = true; 1952 ASSERT_NO_FATAL_FAILURE(inputDeviceManager.FillInputDeviceWithVirtualCapability(inputDevice, info)); 1953 EXPECT_EQ(inputDevice->HasCapability(InputDeviceCapability::INPUT_DEV_CAP_KEYBOARD), false); 1954 EXPECT_EQ(inputDevice->HasCapability(InputDeviceCapability::INPUT_DEV_CAP_POINTER), false); 1955 } 1956 1957 /** 1958 * @tc.name: InputDeviceManagerTest_FillInputDeviceWithVirtualCapability_003 1959 * @tc.desc: Test the function FillInputDeviceWithVirtualCapability with touchscreen and floating virtual keyboard 1960 * @tc.type: FUNC 1961 * @tc.require: 1962 */ 1963 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_FillInputDeviceWithVirtualCapability_003, TestSize.Level1) 1964 { 1965 CALL_TEST_DEBUG; 1966 InputDeviceManager inputDeviceManager; 1967 auto inputDevice = std::make_shared<InputDevice>(); 1968 InputDeviceManager::InputDeviceInfo info; 1969 info.isTouchableDevice = true; 1970 1971 int32_t deviceId2 = 2; 1972 auto device2 = std::make_shared<InputDevice>(); 1973 device2->AddCapability(MMI::InputDeviceCapability::INPUT_DEV_CAP_KEYBOARD); 1974 inputDeviceManager.virtualInputDevices_[deviceId2] = device2; 1975 1976 ASSERT_NO_FATAL_FAILURE(inputDeviceManager.FillInputDeviceWithVirtualCapability(inputDevice, info)); 1977 EXPECT_EQ(inputDevice->HasCapability(InputDeviceCapability::INPUT_DEV_CAP_KEYBOARD), true); 1978 EXPECT_EQ(inputDevice->HasCapability(InputDeviceCapability::INPUT_DEV_CAP_POINTER), false); 1979 } 1980 1981 /** 1982 * @tc.name: InputDeviceManagerTest_FillInputDeviceWithVirtualCapability_004 1983 * @tc.desc: Test the function FillInputDeviceWithVirtualCapability with touchscreen and virtual trackpad 1984 * @tc.type: FUNC 1985 * @tc.require: 1986 */ 1987 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_FillInputDeviceWithVirtualCapability_004, TestSize.Level1) 1988 { 1989 CALL_TEST_DEBUG; 1990 InputDeviceManager inputDeviceManager; 1991 auto inputDevice = std::make_shared<InputDevice>(); 1992 InputDeviceManager::InputDeviceInfo info; 1993 info.isTouchableDevice = true; 1994 1995 int32_t deviceId2 = 2; 1996 auto device2 = std::make_shared<InputDevice>(); 1997 device2->AddCapability(MMI::InputDeviceCapability::INPUT_DEV_CAP_POINTER); 1998 inputDeviceManager.virtualInputDevices_[deviceId2] = device2; 1999 2000 ASSERT_NO_FATAL_FAILURE(inputDeviceManager.FillInputDeviceWithVirtualCapability(inputDevice, info)); 2001 EXPECT_EQ(inputDevice->HasCapability(InputDeviceCapability::INPUT_DEV_CAP_KEYBOARD), false); 2002 EXPECT_EQ(inputDevice->HasCapability(InputDeviceCapability::INPUT_DEV_CAP_POINTER), true); 2003 } 2004 2005 /** 2006 * @tc.name: InputDeviceManagerTest_FillInputDeviceWithVirtualCapability_005 2007 * @tc.desc: Test the function FillInputDeviceWithVirtualCapability with touchscreen and full virtual keyboard 2008 * @tc.type: FUNC 2009 * @tc.require: 2010 */ 2011 HWTEST_F(InputDeviceManagerTest, InputDeviceManagerTest_FillInputDeviceWithVirtualCapability_005, TestSize.Level1) 2012 { 2013 CALL_TEST_DEBUG; 2014 InputDeviceManager inputDeviceManager; 2015 auto inputDevice = std::make_shared<InputDevice>(); 2016 InputDeviceManager::InputDeviceInfo info; 2017 info.isTouchableDevice = true; 2018 2019 int32_t deviceId2 = 2; 2020 auto device2 = std::make_shared<InputDevice>(); 2021 device2->AddCapability(MMI::InputDeviceCapability::INPUT_DEV_CAP_KEYBOARD); 2022 inputDeviceManager.virtualInputDevices_[deviceId2] = device2; 2023 2024 int32_t deviceId3 = 3; 2025 auto device3 = std::make_shared<InputDevice>(); 2026 device3->AddCapability(MMI::InputDeviceCapability::INPUT_DEV_CAP_POINTER); 2027 inputDeviceManager.virtualInputDevices_[deviceId3] = device3; 2028 2029 ASSERT_NO_FATAL_FAILURE(inputDeviceManager.FillInputDeviceWithVirtualCapability(inputDevice, info)); 2030 EXPECT_EQ(inputDevice->HasCapability(InputDeviceCapability::INPUT_DEV_CAP_KEYBOARD), true); 2031 EXPECT_EQ(inputDevice->HasCapability(InputDeviceCapability::INPUT_DEV_CAP_POINTER), true); 2032 } 2033 } // namespace MMI 2034 } // namespace OHOS 2035