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 "proto.h" 19 20 #include "input_event_handler.h" 21 #include "mmi_log.h" 22 #include "mmi_service.h" 23 24 #undef MMI_LOG_TAG 25 #define MMI_LOG_TAG "MMIServerTest" 26 namespace OHOS { 27 namespace MMI { 28 namespace { 29 using namespace testing::ext; 30 } // namespace 31 32 class MMIServerTest : 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: MMIServerTest_OnThread_01 40 * @tc.desc: Test OnThread 41 * @tc.type: FUNC 42 * @tc.require: 43 */ 44 HWTEST_F(MMIServerTest, MMIServerTest_OnThread_01, TestSize.Level1) 45 { 46 MMIService mmiService; 47 EpollEventType epollType; 48 epollType = EPOLL_EVENT_INPUT; 49 ASSERT_NO_FATAL_FAILURE(mmiService.OnThread()); 50 } 51 52 /** 53 * @tc.name: ShiftAppPointerEvent_001 54 * @tc.desc: Test the function ShiftAppPointerEvent 55 * @tc.type: FUNC 56 * @tc.require: 57 */ 58 HWTEST_F(MMIServerTest, ShiftAppPointerEvent_001, TestSize.Level1) 59 { 60 MMIService mmiService; 61 ShiftWindowParam param; 62 param.sourceWindowId = -100; 63 param.targetWindowId = -200; 64 bool autoGenDown = true; 65 int32_t ret = mmiService.ShiftAppPointerEvent(param, autoGenDown); 66 EXPECT_NE(ret, RET_OK); 67 } 68 69 /** 70 * @tc.name: MMIServerTest_OnThread_02 71 * @tc.desc: Test OnThread 72 * @tc.type: FUNC 73 * @tc.require: 74 */ 75 HWTEST_F(MMIServerTest, MMIServerTest_OnThread_02, TestSize.Level1) 76 { 77 MMIService mmiService; 78 EpollEventType epollType; 79 epollType = EPOLL_EVENT_SOCKET; 80 ASSERT_NO_FATAL_FAILURE(mmiService.OnThread()); 81 } 82 83 /** 84 * @tc.name: MMIServerTest_OnThread_03 85 * @tc.desc: Test OnThread 86 * @tc.type: FUNC 87 * @tc.require: 88 */ 89 HWTEST_F(MMIServerTest, MMIServerTest_OnThread_03, TestSize.Level1) 90 { 91 MMIService mmiService; 92 EpollEventType epollType; 93 epollType = EPOLL_EVENT_SIGNAL; 94 ASSERT_NO_FATAL_FAILURE(mmiService.OnThread()); 95 } 96 97 /** 98 * @tc.name: MMIServerTest_OnThread_04 99 * @tc.desc: Test OnThread 100 * @tc.type: FUNC 101 * @tc.require: 102 */ 103 HWTEST_F(MMIServerTest, MMIServerTest_OnThread_04, TestSize.Level1) 104 { 105 MMIService mmiService; 106 EpollEventType epollType; 107 epollType = EPOLL_EVENT_ETASK; 108 ASSERT_NO_FATAL_FAILURE(mmiService.OnThread()); 109 } 110 111 /** 112 * @tc.name: MMIServerTest_EnableInputDevice_01 113 * @tc.desc: Test EnableInputDevice 114 * @tc.type: FUNC 115 * @tc.require: 116 */ 117 HWTEST_F(MMIServerTest, MMIServerTest_EnableInputDevice_01, TestSize.Level1) 118 { 119 MMIService mmiService; 120 bool enable = true; 121 int32_t ret = mmiService.EnableInputDevice(enable); 122 EXPECT_EQ(ret, ETASKS_POST_SYNCTASK_FAIL); 123 } 124 125 /** 126 * @tc.name: MMIServerTest_EnableInputDevice_02 127 * @tc.desc: Test EnableInputDevice 128 * @tc.type: FUNC 129 * @tc.require: 130 */ 131 HWTEST_F(MMIServerTest, MMIServerTest_EnableInputDevice_02, TestSize.Level1) 132 { 133 MMIService mmiService; 134 bool enable = false; 135 int32_t ret = mmiService.EnableInputDevice(enable); 136 EXPECT_EQ(ret, ETASKS_POST_SYNCTASK_FAIL); 137 } 138 139 /** 140 * @tc.name: MMIServerTest_OnDisconnected_01 141 * @tc.desc: Test OnDisconnected 142 * @tc.type: FUNC 143 * @tc.require: 144 */ 145 HWTEST_F(MMIServerTest, MMIServerTest_OnDisconnected_01, TestSize.Level1) 146 { 147 MMIService mmiService; 148 SessionPtr session; 149 auto ret1 = mmiService.RemoveInputEventFilter(-1); 150 EXPECT_EQ(ret1, ETASKS_POST_SYNCTASK_FAIL); 151 ASSERT_NO_FATAL_FAILURE(mmiService.OnDisconnected(session)); 152 } 153 154 /** 155 * @tc.name: MMIServerTest_OnDisconnected_02 156 * @tc.desc: Test OnDisconnected 157 * @tc.type: FUNC 158 * @tc.require: 159 */ 160 HWTEST_F(MMIServerTest, MMIServerTest_OnDisconnected_02, TestSize.Level1) 161 { 162 MMIService mmiService; 163 SessionPtr session; 164 auto ret1 = mmiService.RemoveInputEventFilter(2); 165 EXPECT_EQ(ret1, ETASKS_POST_SYNCTASK_FAIL); 166 ASSERT_NO_FATAL_FAILURE(mmiService.OnDisconnected(session)); 167 } 168 169 /** 170 * @tc.name: MMIServerTest_AddInputHandler_01 171 * @tc.desc: Test the function AddInputHandler 172 * @tc.type: FUNC 173 * @tc.require: 174 */ 175 HWTEST_F(MMIServerTest, MMIServerTest_AddInputHandler_01, TestSize.Level1) 176 { 177 MMIService mmiService; 178 InputHandlerType handlerType = InputHandlerType::MONITOR; 179 HandleEventType eventType = HANDLE_EVENT_TYPE_KEY; 180 int32_t priority = 1; 181 uint32_t deviceTags = 3; 182 int32_t ret = mmiService.AddInputHandler(handlerType, eventType, priority, deviceTags); 183 EXPECT_NE(ret, RET_ERR); 184 } 185 186 /** 187 * @tc.name: MMIServerTest_RemoveInputHandler_01 188 * @tc.desc: Test the function RemoveInputHandler 189 * @tc.type: FUNC 190 * @tc.require: 191 */ 192 HWTEST_F(MMIServerTest, MMIServerTest_RemoveInputHandler_01, TestSize.Level1) 193 { 194 MMIService mmiService; 195 InputHandlerType handlerType = InputHandlerType::INTERCEPTOR; 196 HandleEventType eventType = HANDLE_EVENT_TYPE_POINTER; 197 int32_t priority = 1; 198 uint32_t deviceTags = 2; 199 int32_t ret = mmiService.RemoveInputHandler(handlerType, eventType, priority, deviceTags); 200 EXPECT_NE(ret, RET_ERR); 201 } 202 203 /** 204 * @tc.name: AddEpollAndDelEpoll_001 205 * @tc.desc: Test the function AddEpoll and DelEpoll 206 * @tc.type: FUNC 207 * @tc.require: 208 */ 209 HWTEST_F(MMIServerTest, AddEpollAndDelEpoll_001, TestSize.Level1) 210 { 211 MMIService mmiService; 212 int32_t fd = -1; 213 int32_t ret = mmiService.AddEpoll(EPOLL_EVENT_INPUT, fd); 214 EXPECT_EQ(ret, RET_ERR); 215 ret = mmiService.DelEpoll(EPOLL_EVENT_INPUT, fd); 216 EXPECT_EQ(ret, RET_ERR); 217 fd = 1; 218 ret = mmiService.AddEpoll(EPOLL_EVENT_INPUT, fd); 219 EXPECT_EQ(ret, RET_ERR); 220 ret = mmiService.DelEpoll(EPOLL_EVENT_INPUT, fd); 221 EXPECT_EQ(ret, RET_ERR); 222 ret = mmiService.AddEpoll(EPOLL_EVENT_END, fd); 223 EXPECT_EQ(ret, RET_ERR); 224 ret = mmiService.DelEpoll(EPOLL_EVENT_END, fd); 225 EXPECT_EQ(ret, RET_ERR); 226 } 227 228 /** 229 * @tc.name: InitLibinputService_001 230 * @tc.desc: Test the function InitLibinputService 231 * @tc.type: FUNC 232 * @tc.require: 233 */ 234 HWTEST_F(MMIServerTest, InitLibinputService_001, TestSize.Level1) 235 { 236 MMIService mmiService; 237 bool ret = mmiService.InitService(); 238 EXPECT_FALSE(ret); 239 ret = mmiService.InitDelegateTasks(); 240 EXPECT_FALSE(ret); 241 } 242 243 /** 244 * @tc.name: AddAppDebugListener_001 245 * @tc.desc: Test the function AddAppDebugListener and RemoveAppDebugListener 246 * @tc.type: FUNC 247 * @tc.require: 248 */ 249 HWTEST_F(MMIServerTest, AddAppDebugListener_001, TestSize.Level1) 250 { 251 MMIService mmiService; 252 ASSERT_NO_FATAL_FAILURE(mmiService.AddAppDebugListener()); 253 ASSERT_NO_FATAL_FAILURE(mmiService.RemoveAppDebugListener()); 254 } 255 256 /** 257 * @tc.name: AllocSocketFd_001 258 * @tc.desc: Test the function AllocSocketFd 259 * @tc.type: FUNC 260 * @tc.require: 261 */ 262 HWTEST_F(MMIServerTest, AllocSocketFd_001, TestSize.Level1) 263 { 264 MMIService mmiService; 265 const std::string programName = "programName"; 266 const int32_t moduleType = 1; 267 int32_t toReturnClientFd = 1; 268 int32_t tokenType = 1; 269 int32_t ret = mmiService.AllocSocketFd(programName, moduleType, toReturnClientFd, tokenType); 270 EXPECT_NE(ret, RET_ERR); 271 } 272 273 /** 274 * @tc.name: AddInputEventFilter_001 275 * @tc.desc: Test the function AddInputEventFilter and RemoveInputEventFilter 276 * @tc.type: FUNC 277 * @tc.require: 278 */ 279 HWTEST_F(MMIServerTest, AddInputEventFilter_001, TestSize.Level1) 280 { 281 MMIService mmiService; 282 int32_t filterId = 1; 283 int32_t priority = 1; 284 uint32_t deviceTags = 1; 285 int32_t returnCode0 = 65142804; 286 int32_t returnCode = 65142786; 287 sptr<IEventFilter> filter; 288 int32_t ret = mmiService.AddInputEventFilter(filter, filterId, priority, deviceTags); 289 EXPECT_EQ(ret, returnCode); 290 ret = mmiService.RemoveInputEventFilter(filterId); 291 EXPECT_EQ(ret, returnCode0); 292 } 293 294 /** 295 * @tc.name: OnConnected_001 296 * @tc.desc: Test the function OnConnected and OnDisconnected 297 * @tc.type: FUNC 298 * @tc.require: 299 */ 300 HWTEST_F(MMIServerTest, OnConnected_001, TestSize.Level1) 301 { 302 MMIService mmiService; 303 SessionPtr session; 304 ASSERT_NO_FATAL_FAILURE(mmiService.OnConnected(session)); 305 ASSERT_NO_FATAL_FAILURE(mmiService.OnDisconnected(session)); 306 } 307 308 /** 309 * @tc.name: SetCustomCursor_001 310 * @tc.desc: Test the function SetCustomCursorPixelMap 311 * @tc.type: FUNC 312 * @tc.require: 313 */ 314 HWTEST_F(MMIServerTest, SetCustomCursorPixelMap_001, TestSize.Level1) 315 { 316 MMIService mmiService; 317 int32_t windowId = 1; 318 int32_t focusX = 200; 319 int32_t focusY = 500; 320 CursorPixelMap curPixelMap; 321 ASSERT_NO_FATAL_FAILURE(mmiService.SetCustomCursorPixelMap(windowId, focusX, focusY, curPixelMap)); 322 } 323 324 /** 325 * @tc.name: SetMouseIcon_001 326 * @tc.desc: Test the function SetMouseIcon 327 * @tc.type: FUNC 328 * @tc.require: 329 */ 330 HWTEST_F(MMIServerTest, SetMouseIcon_001, TestSize.Level1) 331 { 332 MMIService mmiService; 333 int32_t windowId = 1; 334 CursorPixelMap curPixelMap; 335 int32_t ret = mmiService.SetMouseIcon(windowId, curPixelMap); 336 EXPECT_NE(ret, RET_OK); 337 } 338 339 /** 340 * @tc.name: SetMouseHotSpot_001 341 * @tc.desc: Test the function SetMouseHotSpot 342 * @tc.type: FUNC 343 * @tc.require: 344 */ 345 HWTEST_F(MMIServerTest, SetMouseHotSpot_001, TestSize.Level1) 346 { 347 MMIService mmiService; 348 int32_t pid = 1; 349 int32_t windowId = 1; 350 int32_t hotSpotX = 100; 351 int32_t hotSpotY = 200; 352 int32_t ret = mmiService.SetMouseHotSpot(pid, windowId, hotSpotX, hotSpotY); 353 EXPECT_NE(ret, RET_OK); 354 } 355 356 /** 357 * @tc.name: SetNapStatus_001 358 * @tc.desc: Test the function SetNapStatus 359 * @tc.type: FUNC 360 * @tc.require: 361 */ 362 HWTEST_F(MMIServerTest, SetNapStatus_001, TestSize.Level1) 363 { 364 MMIService mmiService; 365 int32_t pid = 1; 366 int32_t uid = 2; 367 std::string bundleName = "bundleName"; 368 int32_t napStatus = 1; 369 int32_t ret = mmiService.SetNapStatus(pid, uid, bundleName, napStatus); 370 EXPECT_NE(ret, RET_OK); 371 } 372 373 /** 374 * @tc.name: ReadMouseScrollRows_001 375 * @tc.desc: Test the function ReadMouseScrollRows 376 * @tc.type: FUNC 377 * @tc.require: 378 */ 379 HWTEST_F(MMIServerTest, ReadMouseScrollRows_001, TestSize.Level1) 380 { 381 MMIService mmiService; 382 int32_t rows = 1; 383 int32_t ret = mmiService.ReadMouseScrollRows(rows); 384 EXPECT_EQ(ret, RET_OK); 385 } 386 387 /** 388 * @tc.name: SetMousePrimaryButton_001 389 * @tc.desc: Test the function SetMousePrimaryButton 390 * @tc.type: FUNC 391 * @tc.require: 392 */ 393 HWTEST_F(MMIServerTest, SetMousePrimaryButton_001, TestSize.Level1) 394 { 395 MMIService mmiService; 396 int32_t primaryButton = 1; 397 int32_t returnCode = 65142804; 398 int32_t ret = mmiService.SetMousePrimaryButton(primaryButton); 399 EXPECT_EQ(ret, returnCode); 400 } 401 402 /** 403 * @tc.name: ReadMousePrimaryButton_001 404 * @tc.desc: Test the function ReadMousePrimaryButton 405 * @tc.type: FUNC 406 * @tc.require: 407 */ 408 HWTEST_F(MMIServerTest, ReadMousePrimaryButton_001, TestSize.Level1) 409 { 410 MMIService mmiService; 411 int32_t primaryButton = 1; 412 int32_t ret = mmiService.ReadMousePrimaryButton(primaryButton); 413 EXPECT_EQ(ret, RET_OK); 414 } 415 416 /** 417 * @tc.name: GetMousePrimaryButton_001 418 * @tc.desc: Test the function GetMousePrimaryButton 419 * @tc.type: FUNC 420 * @tc.require: 421 */ 422 HWTEST_F(MMIServerTest, GetMousePrimaryButton_001, TestSize.Level1) 423 { 424 MMIService mmiService; 425 int32_t primaryButton = 1; 426 int32_t ret = mmiService.GetMousePrimaryButton(primaryButton); 427 EXPECT_NE(ret, RET_ERR); 428 } 429 430 /** 431 * @tc.name: CheckPointerVisible_001 432 * @tc.desc: Test the function CheckPointerVisible 433 * @tc.type: FUNC 434 * @tc.require: 435 */ 436 HWTEST_F(MMIServerTest, CheckPointerVisible_001, TestSize.Level1) 437 { 438 MMIService mmiService; 439 bool visible = true; 440 int32_t ret = mmiService.CheckPointerVisible(visible); 441 EXPECT_EQ(ret, RET_OK); 442 } 443 444 /** 445 * @tc.name: MarkProcessed_001 446 * @tc.desc: Test the function MarkProcessed 447 * @tc.type: FUNC 448 * @tc.require: 449 */ 450 HWTEST_F(MMIServerTest, MarkProcessed_001, TestSize.Level1) 451 { 452 MMIService mmiService; 453 int32_t eventType = 1; 454 int32_t eventId = 1; 455 int32_t ret = mmiService.MarkProcessed(eventType, eventId); 456 EXPECT_NE(ret, RET_ERR); 457 } 458 459 /** 460 * @tc.name: ReadPointerColor_001 461 * @tc.desc: Test the function ReadPointerColor 462 * @tc.type: FUNC 463 * @tc.require: 464 */ 465 HWTEST_F(MMIServerTest, ReadPointerColor_001, TestSize.Level1) 466 { 467 MMIService mmiService; 468 int32_t color = 1; 469 int32_t ret = mmiService.ReadPointerColor(color); 470 EXPECT_EQ(ret, RET_OK); 471 } 472 473 /** 474 * @tc.name: NotifyNapOnline_001 475 * @tc.desc: Test the function NotifyNapOnline 476 * @tc.type: FUNC 477 * @tc.require: 478 */ 479 HWTEST_F(MMIServerTest, NotifyNapOnline_001, TestSize.Level1) 480 { 481 MMIService mmiService; 482 int32_t ret = mmiService.NotifyNapOnline(); 483 EXPECT_EQ(ret, RET_OK); 484 } 485 486 /** 487 * @tc.name: RemoveInputEventObserver_001 488 * @tc.desc: Test the function RemoveInputEventObserver 489 * @tc.type: FUNC 490 * @tc.require: 491 */ 492 HWTEST_F(MMIServerTest, RemoveInputEventObserver_001, TestSize.Level1) 493 { 494 MMIService mmiService; 495 int32_t ret = mmiService.RemoveInputEventObserver(); 496 EXPECT_EQ(ret, RET_OK); 497 } 498 499 /** 500 * @tc.name: ClearWindowPointerStyle_001 501 * @tc.desc: Test the function ClearWindowPointerStyle 502 * @tc.type: FUNC 503 * @tc.require: 504 */ 505 HWTEST_F(MMIServerTest, ClearWindowPointerStyle_001, TestSize.Level1) 506 { 507 MMIService mmiService; 508 int32_t pid = 1; 509 int32_t windowId = 2; 510 int32_t ret = mmiService.ClearWindowPointerStyle(pid, windowId); 511 EXPECT_EQ(ret, RET_ERR); 512 } 513 514 /** 515 * @tc.name: ReadHoverScrollState_001 516 * @tc.desc: Test the function ReadHoverScrollState 517 * @tc.type: FUNC 518 * @tc.require: 519 */ 520 HWTEST_F(MMIServerTest, ReadHoverScrollState_001, TestSize.Level1) 521 { 522 MMIService mmiService; 523 bool state = true; 524 int32_t ret = mmiService.ReadHoverScrollState(state); 525 EXPECT_EQ(ret, RET_OK); 526 } 527 528 /** 529 * @tc.name: OnSupportKeys_001 530 * @tc.desc: Test the function OnSupportKeys 531 * @tc.type: FUNC 532 * @tc.require: 533 */ 534 HWTEST_F(MMIServerTest, OnSupportKeys_001, TestSize.Level1) 535 { 536 MMIService mmiService; 537 int32_t deviceId = 1; 538 int32_t return_code = 401; 539 std::vector<int32_t> keys{ 1 }; 540 std::vector<bool> keystroke{ true, true }; 541 std::vector<bool> keystroke1{ true, true, true, true, true, true }; 542 int32_t ret = mmiService.OnSupportKeys(deviceId, keys, keystroke); 543 EXPECT_EQ(ret, return_code); 544 ret = mmiService.OnSupportKeys(deviceId, keys, keystroke1); 545 EXPECT_NE(ret, RET_ERR); 546 } 547 548 /** 549 * @tc.name: SupportKeys_001 550 * @tc.desc: Test the function SupportKeys 551 * @tc.type: FUNC 552 * @tc.require: 553 */ 554 HWTEST_F(MMIServerTest, SupportKeys_001, TestSize.Level1) 555 { 556 MMIService mmiService; 557 int32_t deviceId = 1; 558 int32_t returnCode = 65142804; 559 std::vector<int32_t> keys{ 1 }; 560 std::vector<bool> keystroke{ true, true }; 561 int32_t ret = mmiService.SupportKeys(deviceId, keys, keystroke); 562 EXPECT_EQ(ret, returnCode); 563 } 564 565 /** 566 * @tc.name: OnGetDeviceIds_001 567 * @tc.desc: Test the function OnGetDeviceIds 568 * @tc.type: FUNC 569 * @tc.require: 570 */ 571 HWTEST_F(MMIServerTest, OnGetDeviceIds_001, TestSize.Level1) 572 { 573 MMIService mmiService; 574 std::vector<int32_t> ids{ 1 }; 575 int32_t ret = mmiService.OnGetDeviceIds(ids); 576 EXPECT_EQ(ret, RET_OK); 577 } 578 579 /** 580 * @tc.name: GetDeviceIds_001 581 * @tc.desc: Test the function GetDeviceIds 582 * @tc.type: FUNC 583 * @tc.require: 584 */ 585 HWTEST_F(MMIServerTest, GetDeviceIds_001, TestSize.Level1) 586 { 587 MMIService mmiService; 588 std::vector<int32_t> ids{ 1 }; 589 int32_t ret = mmiService.GetDeviceIds(ids); 590 EXPECT_NE(ret, RET_ERR); 591 } 592 593 /** 594 * @tc.name: OnGetDevice_001 595 * @tc.desc: Test the function OnGetDevice 596 * @tc.type: FUNC 597 * @tc.require: 598 */ 599 HWTEST_F(MMIServerTest, OnGetDevice_001, TestSize.Level1) 600 { 601 MMIService mmiService; 602 int32_t deviceId = 1; 603 int32_t return_code = 401; 604 std::shared_ptr<InputDevice> inputDevice = std::make_shared<InputDevice>(); 605 int32_t ret = mmiService.OnGetDevice(deviceId, inputDevice); 606 EXPECT_EQ(ret, return_code); 607 } 608 609 /** 610 * @tc.name: GetDevice_001 611 * @tc.desc: Test the function GetDevice 612 * @tc.type: FUNC 613 * @tc.require: 614 */ 615 HWTEST_F(MMIServerTest, GetDevice_001, TestSize.Level1) 616 { 617 MMIService mmiService; 618 int32_t returnCode = 65142804; 619 int32_t deviceId = 1; 620 InputDevice inputDevice; 621 int32_t ret = mmiService.GetDevice(deviceId, inputDevice); 622 EXPECT_EQ(ret, returnCode); 623 } 624 625 /** 626 * @tc.name: OnRegisterDevListener_001 627 * @tc.desc: Test the function OnRegisterDevListener 628 * @tc.type: FUNC 629 * @tc.require: 630 */ 631 HWTEST_F(MMIServerTest, OnRegisterDevListener_001, TestSize.Level1) 632 { 633 MMIService mmiService; 634 int32_t pid = 1; 635 int32_t ret = mmiService.OnRegisterDevListener(pid); 636 EXPECT_EQ(ret, RET_ERR); 637 } 638 639 /** 640 * @tc.name: RegisterDevListener_001 641 * @tc.desc: Test the function RegisterDevListener and OnUnregisterDevListener 642 * @tc.type: FUNC 643 * @tc.require: 644 */ 645 HWTEST_F(MMIServerTest, RegisterDevListener_001, TestSize.Level1) 646 { 647 MMIService mmiService; 648 int32_t pid = 1; 649 int32_t ret = mmiService.RegisterDevListener(); 650 EXPECT_NE(ret, RET_OK); 651 ret = mmiService.UnregisterDevListener(); 652 EXPECT_NE(ret, RET_OK); 653 ret = mmiService.OnUnregisterDevListener(pid); 654 EXPECT_EQ(ret, RET_OK); 655 } 656 657 /** 658 * @tc.name: OnGetKeyboardType_001 659 * @tc.desc: Test the function OnGetKeyboardType 660 * @tc.type: FUNC 661 * @tc.require: 662 */ 663 HWTEST_F(MMIServerTest, OnGetKeyboardType_001, TestSize.Level1) 664 { 665 MMIService mmiService; 666 int32_t deviceId = 1; 667 int32_t keyboardType = 1; 668 int32_t return_code = 401; 669 int32_t ret = mmiService.OnGetKeyboardType(deviceId, keyboardType); 670 EXPECT_EQ(ret, return_code); 671 } 672 673 /** 674 * @tc.name: GetKeyboardType_001 675 * @tc.desc: Test the function GetKeyboardType 676 * @tc.type: FUNC 677 * @tc.require: 678 */ 679 HWTEST_F(MMIServerTest, GetKeyboardType_001, TestSize.Level1) 680 { 681 MMIService mmiService; 682 int32_t returnCode = 65142804; 683 int32_t deviceId = 1; 684 int32_t keyboardType = 1; 685 int32_t ret = mmiService.GetKeyboardType(deviceId, keyboardType); 686 EXPECT_EQ(ret, returnCode); 687 } 688 689 /** 690 * @tc.name: GetKeyboardRepeatDelay_001 691 * @tc.desc: Test the function GetKeyboardRepeatDelay 692 * @tc.type: FUNC 693 * @tc.require: 694 */ 695 HWTEST_F(MMIServerTest, GetKeyboardRepeatDelay_001, TestSize.Level1) 696 { 697 MMIService mmiService; 698 int32_t returnCode = 65142800; 699 int32_t delay = 1; 700 int32_t ret = mmiService.GetKeyboardRepeatDelay(delay); 701 EXPECT_EQ(ret, returnCode); 702 } 703 704 /** 705 * @tc.name: GetKeyboardRepeatRate_001 706 * @tc.desc: Test the function GetKeyboardRepeatRate 707 * @tc.type: FUNC 708 * @tc.require: 709 */ 710 HWTEST_F(MMIServerTest, GetKeyboardRepeatRate_001, TestSize.Level1) 711 { 712 MMIService mmiService; 713 int32_t returnCode = 65142800; 714 int32_t rate = 1; 715 int32_t ret = mmiService.GetKeyboardRepeatRate(rate); 716 EXPECT_EQ(ret, returnCode); 717 } 718 719 /** 720 * @tc.name: CheckAddInput_001 721 * @tc.desc: Test the function CheckAddInput 722 * @tc.type: FUNC 723 * @tc.require: 724 */ 725 HWTEST_F(MMIServerTest, CheckAddInput_001, TestSize.Level1) 726 { 727 MMIService mmiService; 728 int32_t returnCode = 65142786; 729 int32_t pid = 1; 730 InputHandlerType handlerType = InputHandlerType::MONITOR; 731 HandleEventType eventType = 10; 732 int32_t priority = 1; 733 uint32_t deviceTags = 1; 734 int32_t ret = mmiService.CheckAddInput(pid, handlerType, eventType, priority, deviceTags); 735 EXPECT_EQ(ret, returnCode); 736 } 737 738 /** 739 * @tc.name: AddInputHandler_001 740 * @tc.desc: Test the function AddInputHandler 741 * @tc.type: FUNC 742 * @tc.require: 743 */ 744 HWTEST_F(MMIServerTest, AddInputHandler_001, TestSize.Level1) 745 { 746 MMIService mmiService; 747 InputHandlerType handlerType = InputHandlerType::INTERCEPTOR; 748 HandleEventType eventType = 10; 749 int32_t priority = 1; 750 uint32_t deviceTags = 1; 751 int32_t ret = mmiService.AddInputHandler(handlerType, eventType, priority, deviceTags); 752 EXPECT_NE(ret, RET_ERR); 753 } 754 755 /** 756 * @tc.name: CheckRemoveInput_001 757 * @tc.desc: Test the function CheckRemoveInput 758 * @tc.type: FUNC 759 * @tc.require: 760 */ 761 HWTEST_F(MMIServerTest, CheckRemoveInput_001, TestSize.Level1) 762 { 763 MMIService mmiService; 764 int32_t returnCode = 65142786; 765 int32_t pid = 1; 766 InputHandlerType handlerType = InputHandlerType::INTERCEPTOR; 767 HandleEventType eventType = 1; 768 int32_t priority = 1; 769 uint32_t deviceTags = 1; 770 int32_t ret = mmiService.CheckRemoveInput(pid, handlerType, eventType, priority, deviceTags); 771 EXPECT_EQ(ret, returnCode); 772 } 773 774 /** 775 * @tc.name: RemoveInputHandler_001 776 * @tc.desc: Test the function RemoveInputHandler 777 * @tc.type: FUNC 778 * @tc.require: 779 */ 780 HWTEST_F(MMIServerTest, RemoveInputHandler_001, TestSize.Level1) 781 { 782 MMIService mmiService; 783 InputHandlerType handlerType = InputHandlerType::INTERCEPTOR; 784 HandleEventType eventType = 1; 785 int32_t priority = 1; 786 uint32_t deviceTags = 1; 787 int32_t ret = mmiService.RemoveInputHandler(handlerType, eventType, priority, deviceTags); 788 EXPECT_NE(ret, RET_ERR); 789 } 790 791 /** 792 * @tc.name: CheckMarkConsumed_001 793 * @tc.desc: Test the function CheckMarkConsumed 794 * @tc.type: FUNC 795 * @tc.require: 796 */ 797 HWTEST_F(MMIServerTest, CheckMarkConsumed_001, TestSize.Level1) 798 { 799 MMIService mmiService; 800 int32_t returnCode = 65142786; 801 int32_t pid = 1; 802 int32_t eventId = 1; 803 int32_t ret = mmiService.CheckMarkConsumed(pid, eventId); 804 EXPECT_EQ(ret, returnCode); 805 } 806 807 /** 808 * @tc.name: MoveMouseEvent_001 809 * @tc.desc: Test the function MoveMouseEvent 810 * @tc.type: FUNC 811 * @tc.require: 812 */ 813 HWTEST_F(MMIServerTest, MoveMouseEvent_001, TestSize.Level1) 814 { 815 MMIService mmiService; 816 int32_t offsetX = 100; 817 int32_t offsetY = 200; 818 int32_t ret = mmiService.MoveMouseEvent(offsetX, offsetY); 819 EXPECT_NE(ret, RET_ERR); 820 } 821 822 /** 823 * @tc.name: CheckInjectKeyEvent_001 824 * @tc.desc: Test the function CheckInjectKeyEvent 825 * @tc.type: FUNC 826 * @tc.require: 827 */ 828 HWTEST_F(MMIServerTest, CheckInjectKeyEvent_001, TestSize.Level1) 829 { 830 MMIService mmiService; 831 int32_t returnCode = 65142786; 832 std::shared_ptr<KeyEvent> Event{ nullptr }; 833 int32_t pid = 1; 834 bool isNativeInject = false; 835 int32_t ret = mmiService.CheckInjectKeyEvent(Event, pid, isNativeInject); 836 EXPECT_EQ(ret, returnCode); 837 } 838 839 /** 840 * @tc.name: OnAddSystemAbility_001 841 * @tc.desc: Test the function OnAddSystemAbility 842 * @tc.type: FUNC 843 * @tc.require: 844 */ 845 HWTEST_F(MMIServerTest, OnAddSystemAbility_001, TestSize.Level1) 846 { 847 MMIService mmiService; 848 int32_t systemAbilityId = 1; 849 std::string deviceId = "device_id"; 850 systemAbilityId = RES_SCHED_SYS_ABILITY_ID; 851 ASSERT_NO_FATAL_FAILURE(mmiService.OnAddSystemAbility(systemAbilityId, deviceId)); 852 systemAbilityId = COMMON_EVENT_SERVICE_ID; 853 ASSERT_NO_FATAL_FAILURE(mmiService.OnAddSystemAbility(systemAbilityId, deviceId)); 854 systemAbilityId = APP_MGR_SERVICE_ID; 855 ASSERT_NO_FATAL_FAILURE(mmiService.OnAddSystemAbility(systemAbilityId, deviceId)); 856 } 857 858 /** 859 * @tc.name: SubscribeKeyEvent_001 860 * @tc.desc: Test the function SubscribeKeyEvent 861 * @tc.type: FUNC 862 * @tc.require: 863 */ 864 HWTEST_F(MMIServerTest, SubscribeKeyEvent_001, TestSize.Level1) 865 { 866 MMIService mmiService; 867 int32_t subscribeId = 1; 868 KeyOption option; 869 ASSERT_NO_FATAL_FAILURE(mmiService.SubscribeKeyEvent(subscribeId, option)); 870 ASSERT_NO_FATAL_FAILURE(mmiService.UnsubscribeKeyEvent(subscribeId)); 871 } 872 873 /** 874 * @tc.name: GetDisplayBindInfo_001 875 * @tc.desc: Test the function GetDisplayBindInfo 876 * @tc.type: FUNC 877 * @tc.require: 878 */ 879 HWTEST_F(MMIServerTest, GetDisplayBindInfo_001, TestSize.Level1) 880 { 881 MMIService mmiService; 882 DisplayBindInfos infos; 883 int32_t ret = mmiService.GetDisplayBindInfo(infos); 884 EXPECT_NE(ret, RET_ERR); 885 } 886 887 /** 888 * @tc.name: SetDisplayBind_001 889 * @tc.desc: Test the function SetDisplayBind 890 * @tc.type: FUNC 891 * @tc.require: 892 */ 893 HWTEST_F(MMIServerTest, SetDisplayBind_001, TestSize.Level1) 894 { 895 MMIService mmiService; 896 int32_t deviceId = 1; 897 int32_t displayId = 2; 898 std::string msg = "test"; 899 int32_t ret = mmiService.SetDisplayBind(deviceId, displayId, msg); 900 EXPECT_NE(ret, RET_ERR); 901 } 902 903 /** 904 * @tc.name: SetFunctionKeyState_001 905 * @tc.desc: Test the function SetFunctionKeyState 906 * @tc.type: FUNC 907 * @tc.require: 908 */ 909 HWTEST_F(MMIServerTest, SetFunctionKeyState_001, TestSize.Level1) 910 { 911 MMIService mmiService; 912 int32_t funcKey = 1; 913 bool enable = true; 914 bool state = false; 915 int32_t ret = mmiService.SetFunctionKeyState(funcKey, enable); 916 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 917 ret = mmiService.GetFunctionKeyState(funcKey, state); 918 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 919 } 920 921 /** 922 * @tc.name: OnDelegateTask_001 923 * @tc.desc: Test the function OnDelegateTask 924 * @tc.type: FUNC 925 * @tc.require: 926 */ 927 HWTEST_F(MMIServerTest, OnDelegateTask_001, TestSize.Level1) 928 { 929 MMIService mmiService; 930 epoll_event ev; 931 ev.events = 0; 932 ASSERT_NO_FATAL_FAILURE(mmiService.OnDelegateTask(ev)); 933 ev.events = 1; 934 ASSERT_NO_FATAL_FAILURE(mmiService.OnDelegateTask(ev)); 935 } 936 937 /** 938 * @tc.name: OnThread_001 939 * @tc.desc: Test the function OnThread 940 * @tc.type: FUNC 941 * @tc.require: 942 */ 943 HWTEST_F(MMIServerTest, OnThread_001, TestSize.Level1) 944 { 945 MMIService mmiService; 946 ASSERT_NO_FATAL_FAILURE(mmiService.OnThread()); 947 } 948 949 /** 950 * @tc.name: InitSignalHandler_001 951 * @tc.desc: Test the function InitSignalHandler 952 * @tc.type: FUNC 953 * @tc.require: 954 */ 955 HWTEST_F(MMIServerTest, InitSignalHandler_001, TestSize.Level1) 956 { 957 MMIService mmiService; 958 bool ret = mmiService.InitSignalHandler(); 959 EXPECT_EQ(ret, false); 960 } 961 962 /** 963 * @tc.name: AddReloadDeviceTimer_001 964 * @tc.desc: Test the function AddReloadDeviceTimer 965 * @tc.type: FUNC 966 * @tc.require: 967 */ 968 HWTEST_F(MMIServerTest, AddReloadDeviceTimer_001, TestSize.Level1) 969 { 970 MMIService mmiService; 971 ASSERT_NO_FATAL_FAILURE(mmiService.AddReloadDeviceTimer()); 972 } 973 974 /** 975 * @tc.name: Dump_001 976 * @tc.desc: Test the function Dump 977 * @tc.type: FUNC 978 * @tc.require: 979 */ 980 HWTEST_F(MMIServerTest, Dump_001, TestSize.Level1) 981 { 982 MMIService mmiService; 983 int32_t fd = -1; 984 std::vector<std::u16string> args; 985 int32_t ret = mmiService.Dump(fd, args); 986 EXPECT_EQ(ret, DUMP_PARAM_ERR); 987 fd = 1; 988 ret = mmiService.Dump(fd, args); 989 EXPECT_EQ(ret, DUMP_PARAM_ERR); 990 } 991 992 /** 993 * @tc.name: SetMouseCaptureMode_001 994 * @tc.desc: Test the function SetMouseCaptureMode 995 * @tc.type: FUNC 996 * @tc.require: 997 */ 998 HWTEST_F(MMIServerTest, SetMouseCaptureMode_001, TestSize.Level1) 999 { 1000 MMIService mmiService; 1001 int32_t windowId = 1; 1002 bool isCaptureMode = false; 1003 int32_t returnCode = 65142804; 1004 int32_t ret = mmiService.SetMouseCaptureMode(windowId, isCaptureMode); 1005 EXPECT_EQ(ret, returnCode); 1006 isCaptureMode = true; 1007 ret = mmiService.SetMouseCaptureMode(windowId, isCaptureMode); 1008 EXPECT_EQ(ret, returnCode); 1009 } 1010 1011 /** 1012 * @tc.name: OnGetWindowPid_001 1013 * @tc.desc: Test the function OnGetWindowPid 1014 * @tc.type: FUNC 1015 * @tc.require: 1016 */ 1017 HWTEST_F(MMIServerTest, OnGetWindowPid_001, TestSize.Level1) 1018 { 1019 MMIService mmiService; 1020 int32_t windowId = 1; 1021 int32_t windowPid = 1; 1022 int32_t ret = mmiService.OnGetWindowPid(windowId, windowPid); 1023 EXPECT_EQ(ret, RET_ERR); 1024 } 1025 1026 /** 1027 * @tc.name: GetWindowPid_001 1028 * @tc.desc: Test the function GetWindowPid 1029 * @tc.type: FUNC 1030 * @tc.require: 1031 */ 1032 HWTEST_F(MMIServerTest, GetWindowPid_001, TestSize.Level1) 1033 { 1034 MMIService mmiService; 1035 int32_t windowId = 1; 1036 int32_t windowPid = 1; 1037 int32_t ret = mmiService.GetWindowPid(windowId, windowPid); 1038 EXPECT_NE(ret, RET_ERR); 1039 } 1040 1041 /** 1042 * @tc.name: CheckPidPermission_001 1043 * @tc.desc: Test the function CheckPidPermission 1044 * @tc.type: FUNC 1045 * @tc.require: 1046 */ 1047 HWTEST_F(MMIServerTest, CheckPidPermission_001, TestSize.Level1) 1048 { 1049 MMIService mmiService; 1050 int32_t pid = 10; 1051 int32_t ret = mmiService.CheckPidPermission(pid); 1052 EXPECT_EQ(ret, RET_ERR); 1053 } 1054 1055 /** 1056 * @tc.name: SetShieldStatus_001 1057 * @tc.desc: Test the function SetShieldStatus 1058 * @tc.type: FUNC 1059 * @tc.require: 1060 */ 1061 HWTEST_F(MMIServerTest, SetShieldStatus_001, TestSize.Level1) 1062 { 1063 MMIService mmiService; 1064 int32_t returnCode = 65142800; 1065 int32_t shieldMode = 1; 1066 bool isShield = 0; 1067 int32_t ret = mmiService.SetShieldStatus(shieldMode, isShield); 1068 EXPECT_EQ(ret, returnCode); 1069 ret = mmiService.GetShieldStatus(shieldMode, isShield); 1070 EXPECT_EQ(ret, returnCode); 1071 } 1072 1073 /** 1074 * @tc.name: MMIServerTest_InitService 1075 * @tc.desc: Test Init Service 1076 * @tc.type: FUNC 1077 * @tc.require: 1078 */ 1079 HWTEST_F(MMIServerTest, MMIServerTest_InitService, TestSize.Level1) 1080 { 1081 MMIService service; 1082 service.state_ = ServiceRunningState::STATE_RUNNING; 1083 ASSERT_FALSE(service.InitService()); 1084 service.state_ = ServiceRunningState::STATE_NOT_START; 1085 service.mmiFd_ = 1000; 1086 ASSERT_FALSE(service.InitService()); 1087 } 1088 1089 /** 1090 * @tc.name: MMIServerTest_OnAppDebugStoped_01 1091 * @tc.desc: Test OnAppDebugStoped 1092 * @tc.type: FUNC 1093 * @tc.require: 1094 */ 1095 HWTEST_F(MMIServerTest, MMIServerTest_OnAppDebugStoped_01, TestSize.Level1) 1096 { 1097 AppDebugListener listener; 1098 std::vector<AppExecFwk::AppDebugInfo> debugInfos; 1099 ASSERT_NO_FATAL_FAILURE(listener.OnAppDebugStoped(debugInfos)); 1100 listener.appDebugPid_ = 4; 1101 ASSERT_NO_FATAL_FAILURE(listener.OnAppDebugStoped(debugInfos)); 1102 } 1103 1104 /** 1105 * @tc.name: MMIServerTest_GetPointerLocation_001 1106 * @tc.desc: Test the function GetPointerLocation 1107 * @tc.type: FUNC 1108 * @tc.require: 1109 */ 1110 HWTEST_F(MMIServerTest, MMIServerTest_GetPointerLocation_001, TestSize.Level1) 1111 { 1112 CALL_TEST_DEBUG; 1113 MMIService mmiService; 1114 int32_t displayId = 0; 1115 double displayX = 0.0; 1116 double displayY = 0.0; 1117 int32_t ret = mmiService.GetPointerLocation(displayId, displayX, displayY); 1118 EXPECT_EQ(ret, ERROR_APP_NOT_FOCUSED); 1119 } 1120 1121 /** 1122 * @tc.name: MMIServerTest_InitLibinputService_001 1123 * @tc.desc: Verify that InitLibinputService can be called properly (init cannot be simulated and return false) 1124 * @tc.type: FUNC 1125 * @tc.require: 1126 */ 1127 HWTEST_F(MMIServerTest, MMIServerTest_InitLibinputService_001, TestSize.Level1) 1128 { 1129 CALL_TEST_DEBUG; 1130 MMIService mmiService; 1131 bool ret = mmiService.InitLibinputService(); 1132 MMI_HILOGI("InitLibinputService return: %{public}d", ret); 1133 EXPECT_TRUE(true); 1134 } 1135 1136 /** 1137 * @tc.name: MMIServerTest_SetMouseScrollRows_001 1138 * @tc.desc: When the service is not running, return MMISERVICED_NOT_RUNING 1139 * @tc.type: FUNC 1140 */ 1141 HWTEST_F(MMIServerTest, MMIServerTest_SetMouseScrollRows_001, TestSize.Level1) 1142 { 1143 CALL_TEST_DEBUG; 1144 MMIService service; 1145 int32_t rows = 3; 1146 ErrCode ret = service.SetMouseScrollRows(rows); 1147 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 1148 } 1149 1150 /** 1151 * @tc.name: MMIServerTest_GetMouseScrollRows_001 1152 * @tc.desc: When GetMouseScrollRows is called while the service is not running it should return MMISERVICE_NOT_RUNNING 1153 * @tc.type: FUNC 1154 * @tc.require: 1155 */ 1156 HWTEST_F(MMIServerTest, MMIServerTest_GetMouseScrollRows_001, TestSize.Level1) 1157 { 1158 CALL_TEST_DEBUG; 1159 MMIService mmiService; 1160 int32_t rows = 0; 1161 ErrCode ret = mmiService.GetMouseScrollRows(rows); 1162 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 1163 } 1164 1165 /** 1166 * @tc.name: MMIServerTest_SetPointerSize_001 1167 * @tc.desc: Call SetPointerSize, and the return value is determined based on the current device status 1168 * @tc.type: FUNC 1169 * @tc.require: 1170 */ 1171 HWTEST_F(MMIServerTest, MMIServerTest_SetPointerSize_001, TestSize.Level1) 1172 { 1173 CALL_TEST_DEBUG; 1174 MMIService mmiService; 1175 int32_t ret = mmiService.SetPointerSize(20); 1176 EXPECT_TRUE(ret == MMISERVICE_NOT_RUNNING || ret == ERROR_NOT_SYSAPI || ret == RET_OK); 1177 } 1178 1179 /** 1180 * @tc.name: MMIServerTest_GetPointerSize_001 1181 * @tc.desc: Call GetPointerSize, and the return value is determined based on runtime status and system permissions 1182 * @tc.type: FUNC 1183 * @tc.require: 1184 */ 1185 HWTEST_F(MMIServerTest, MMIServerTest_GetPointerSize_001, TestSize.Level1) 1186 { 1187 CALL_TEST_DEBUG; 1188 MMIService mmiService; 1189 int32_t size = 0; 1190 int32_t ret = mmiService.GetPointerSize(size); 1191 EXPECT_TRUE(ret == MMISERVICE_NOT_RUNNING || ret == ERROR_NOT_SYSAPI || ret == RET_OK); 1192 if (ret == RET_OK) { 1193 EXPECT_GE(size, 0); 1194 } 1195 } 1196 1197 /** 1198 * @tc.name: MMIServerTest_GetCursorSurfaceId_001 1199 * @tc.desc: Obtain Cursor SurfaceId; the actual return value depends on the runtime status and permissions 1200 * @tc.type: FUNC 1201 * @tc.require: 1202 */ 1203 HWTEST_F(MMIServerTest, MMIServerTest_GetCursorSurfaceId_001, TestSize.Level1) 1204 { 1205 CALL_TEST_DEBUG; 1206 MMIService mmiService; 1207 uint64_t surfaceId = 123; 1208 ErrCode ret = mmiService.GetCursorSurfaceId(surfaceId); 1209 EXPECT_TRUE(ret == MMISERVICE_NOT_RUNNING || ret == ERROR_NOT_SYSAPI || ret == RET_OK); 1210 if (ret == RET_OK) { 1211 EXPECT_GE(surfaceId, 0); 1212 } 1213 } 1214 1215 /** 1216 * @tc.name: MMIServerTest_SetPointerVisible_001 1217 * @tc.desc: Set cursor visibility, priority less than 0, return RET_ERR 1218 * @tc.type: FUNC 1219 * @tc.require: 1220 */ 1221 HWTEST_F(MMIServerTest, MMIServerTest_SetPointerVisible_001, TestSize.Level1) 1222 { 1223 CALL_TEST_DEBUG; 1224 MMIService mmiService; 1225 int32_t ret = mmiService.SetPointerVisible(true, -1); // priority 非法 1226 EXPECT_EQ(ret, RET_ERR); 1227 } 1228 1229 /** 1230 * @tc.name: MMIServerTest_SetPointerVisible_002 1231 * @tc.desc: Set cursor visibility, priority is valid, return RET_OK or actual return value 1232 * @tc.type: FUNC 1233 * @tc.require: 1234 */ 1235 HWTEST_F(MMIServerTest, MMIServerTest_SetPointerVisible_002, TestSize.Level1) 1236 { 1237 CALL_TEST_DEBUG; 1238 MMIService mmiService; 1239 int32_t ret = mmiService.SetPointerVisible(false, 1); 1240 EXPECT_TRUE(ret == RET_OK || ret != RET_OK); 1241 } 1242 1243 /** 1244 * @tc.name: MMIServerTest_IsPointerVisible_001 1245 * @tc.desc: Verify that the logic of calling the IsPointerVisible interface is operational and compatible 1246 * @tc.type: FUNC 1247 * @tc.require: 1248 */ 1249 HWTEST_F(MMIServerTest, MMIServerTest_IsPointerVisible_001, TestSize.Level1) 1250 { 1251 CALL_TEST_DEBUG; 1252 MMIService mmiService; 1253 bool visible = false; 1254 ErrCode ret = mmiService.IsPointerVisible(visible); 1255 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_WAIT_TIMEOUT || ret == ETASKS_POST_SYNCTASK_FAIL); 1256 } 1257 1258 /** 1259 * @tc.name: MMIServerTest_SetPointerColor_001 1260 * @tc.desc: When the service is not running, calling SetPointerColor returns MMISERVICE_NOT_RUNNING 1261 * @tc.type: FUNC 1262 * @tc.require: 1263 */ 1264 HWTEST_F(MMIServerTest, MMIServerTest_SetPointerColor_001, TestSize.Level1) 1265 { 1266 CALL_TEST_DEBUG; 1267 MMIService mmiService; 1268 int32_t ret = mmiService.SetPointerColor(0xFF0000); 1269 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 1270 } 1271 1272 /** 1273 * @tc.name: MMIServerTest_GetPointerColor_001 1274 * @tc.desc: When the service is not running, calling GetPointerColor returns MMISERVICE_NOT_RUNNING 1275 * @tc.type: FUNC 1276 * @tc.require: 1277 */ 1278 HWTEST_F(MMIServerTest, MMIServerTest_GetPointerColor_001, TestSize.Level1) 1279 { 1280 CALL_TEST_DEBUG; 1281 MMIService mmiService; 1282 int32_t color = 0; 1283 int32_t ret = mmiService.GetPointerColor(color); 1284 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 1285 } 1286 1287 /** 1288 * @tc.name: MMIServerTest_SetPointerSpeed_001 1289 * @tc.desc: Non-system applications calling SetPointerSpeed should return ERROR_NOT_SYSAPI 1290 * @tc.type: FUNC 1291 * @tc.require: 1292 */ 1293 HWTEST_F(MMIServerTest, MMIServerTest_SetPointerSpeed_001, TestSize.Level1) 1294 { 1295 CALL_TEST_DEBUG; 1296 MMIService mmiService; 1297 int32_t ret = mmiService.SetPointerSpeed(3); 1298 EXPECT_TRUE(ret == ERROR_NOT_SYSAPI || ret == ETASKS_POST_SYNCTASK_FAIL); 1299 } 1300 1301 /** 1302 * @tc.name: MMIServerTest_GetPointerSpeed_001 1303 * @tc.desc: Non-system applications calling GetPointerSpeed should return ERROR_NOT_SYSAPI 1304 * @tc.type: FUNC 1305 * @tc.require: 1306 */ 1307 HWTEST_F(MMIServerTest, MMIServerTest_GetPointerSpeed_001, TestSize.Level1) 1308 { 1309 CALL_TEST_DEBUG; 1310 MMIService mmiService; 1311 int32_t speed = -1; 1312 int32_t ret = mmiService.GetPointerSpeed(speed); 1313 EXPECT_NE(ret, RET_OK); 1314 EXPECT_EQ(speed, 0); 1315 } 1316 1317 /** 1318 * @tc.name: MMIServerTest_SetPointerStyle_001 1319 * @tc.desc: Non-system application sets global pointer style, returns error code 1320 * @tc.type: FUNC 1321 * @tc.require: 1322 */ 1323 HWTEST_F(MMIServerTest, MMIServerTest_SetPointerStyle_001, TestSize.Level1) 1324 { 1325 CALL_TEST_DEBUG; 1326 MMIService mmiService; 1327 PointerStyle style; 1328 ErrCode ret = mmiService.SetPointerStyle(-1, style, false); 1329 EXPECT_NE(ret, RET_OK); 1330 } 1331 1332 /** 1333 * @tc.name: MMIServerTest_SetPointerStyle_002 1334 * @tc.desc: Non-system application windowId < 0, return error code 1335 * @tc.type: FUNC 1336 * @tc.require: 1337 */ 1338 HWTEST_F(MMIServerTest, MMIServerTest_SetPointerStyle_002, TestSize.Level1) 1339 { 1340 CALL_TEST_DEBUG; 1341 MMIService mmiService; 1342 PointerStyle style; 1343 ErrCode ret = mmiService.SetPointerStyle(-2, style, false); 1344 EXPECT_NE(ret, RET_OK); 1345 } 1346 1347 /** 1348 * @tc.name: MMIServerTest_SetPointerStyle_003 1349 * @tc.desc: Set the pointer style to normal and return RET_OK or Task error code 1350 * @tc.type: FUNC 1351 * @tc.require: 1352 */ 1353 HWTEST_F(MMIServerTest, MMIServerTest_SetPointerStyle_003, TestSize.Level1) 1354 { 1355 CALL_TEST_DEBUG; 1356 MMIService mmiService; 1357 PointerStyle style; 1358 ErrCode ret = mmiService.SetPointerStyle(1234, style, false); 1359 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_WAIT_TIMEOUT || ret == ETASKS_POST_SYNCTASK_FAIL); 1360 } 1361 1362 /** 1363 * @tc.name: MMIServerTest_GetPointerStyle_001 1364 * @tc.desc: Normally obtain the pointer style and verify whether the return value is RET_OK or fault-tolerant 1365 * @tc.type: FUNC 1366 * @tc.require: 1367 */ 1368 HWTEST_F(MMIServerTest, MMIServerTest_GetPointerStyle_001, TestSize.Level1) 1369 { 1370 CALL_TEST_DEBUG; 1371 MMIService mmiService; 1372 PointerStyle style; 1373 int32_t windowId = 100; 1374 bool isUiExtension = false; 1375 ErrCode ret = mmiService.GetPointerStyle(windowId, style, isUiExtension); 1376 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_WAIT_TIMEOUT || ret == ETASKS_POST_SYNCTASK_FAIL); 1377 } 1378 1379 /** 1380 * @tc.name: MMIServerTest_SetHoverScrollState_001 1381 * @tc.desc: When calling SetHoverScrollState in a non-system application, it returns ERROR_NOT_SYSAPI 1382 * @tc.type: FUNC 1383 * @tc.require: 1384 */ 1385 HWTEST_F(MMIServerTest, MMIServerTest_SetHoverScrollState_001, TestSize.Level1) 1386 { 1387 CALL_TEST_DEBUG; 1388 MMIService mmiService; 1389 ErrCode ret = mmiService.SetHoverScrollState(true); 1390 EXPECT_NE(ret, RET_OK); 1391 } 1392 1393 /** 1394 * @tc.name: MMIServerTest_SetHoverScrollState_002 1395 * @tc.desc: The system application calls SetHoverScrollState to verify whether the return value 1396 * @tc.type: FUNC 1397 * @tc.require: 1398 */ 1399 HWTEST_F(MMIServerTest, MMIServerTest_SetHoverScrollState_002, TestSize.Level1) 1400 { 1401 CALL_TEST_DEBUG; 1402 MMIService mmiService; 1403 ErrCode ret = mmiService.SetHoverScrollState(false); 1404 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_WAIT_TIMEOUT || ret == ETASKS_POST_SYNCTASK_FAIL); 1405 } 1406 1407 /** 1408 * @tc.name: MMIServerTest_GetHoverScrollState_001 1409 * @tc.desc: Non-system applications calling GetHoverScrollState return ERROR_NOT_SYSAPI 1410 * @tc.type: FUNC 1411 * @tc.require: 1412 */ 1413 HWTEST_F(MMIServerTest, MMIServerTest_GetHoverScrollState_001, TestSize.Level1) 1414 { 1415 CALL_TEST_DEBUG; 1416 MMIService mmiService; 1417 bool state = false; 1418 ErrCode ret = mmiService.GetHoverScrollState(state); 1419 EXPECT_NE(ret, RET_OK); 1420 } 1421 1422 /** 1423 * @tc.name: MMIServerTest_SetKeyboardRepeatDelay_001 1424 * @tc.desc: SetKeyboardRepeatDelay returns error when service is not running 1425 * @tc.type: FUNC 1426 * @tc.require: 1427 */ 1428 HWTEST_F(MMIServerTest, MMIServerTest_SetKeyboardRepeatDelay_001, TestSize.Level1) 1429 { 1430 CALL_TEST_DEBUG; 1431 MMIService mmiService; 1432 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 1433 int32_t delay = 500; 1434 ErrCode ret = mmiService.SetKeyboardRepeatDelay(delay); 1435 MMI_HILOGI("SetKeyboardRepeatDelay_001 ret: %{public}d", ret); 1436 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 1437 } 1438 1439 /** 1440 * @tc.name: MMIServerTest_SetKeyboardRepeatDelay_002 1441 * @tc.desc: SetKeyboardRepeatDelay returns success or error for valid running service 1442 * @tc.type: FUNC 1443 * @tc.require: 1444 */ 1445 HWTEST_F(MMIServerTest, MMIServerTest_SetKeyboardRepeatDelay_002, TestSize.Level1) 1446 { 1447 CALL_TEST_DEBUG; 1448 MMIService mmiService; 1449 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 1450 int32_t delay = 500; 1451 ErrCode ret = mmiService.SetKeyboardRepeatDelay(delay); 1452 MMI_HILOGI("SetKeyboardRepeatDelay_002 ret: %{public}d", ret); 1453 EXPECT_NE(ret, RET_OK); 1454 } 1455 1456 1457 /** 1458 * @tc.name: MMIServerTest_SetKeyboardRepeatRate_001 1459 * @tc.desc: When calling SetKeyboardRepeatRate with the service not running, it returns MMISERVICE_NOT_RUNNING 1460 * @tc.type: FUNC 1461 * @tc.require: 1462 */ 1463 HWTEST_F(MMIServerTest, MMIServerTest_SetKeyboardRepeatRate_001, TestSize.Level1) 1464 { 1465 CALL_TEST_DEBUG; 1466 MMIService mmiService; 1467 int32_t ret = mmiService.SetKeyboardRepeatRate(30); 1468 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 1469 } 1470 1471 /** 1472 * @tc.name: MMIServerTest_AddPreInputHandler_001 1473 * @tc.desc: Non-system applications result in AddPreInputHandler returning a value other than RET_OK 1474 * @tc.type: FUNC 1475 */ 1476 HWTEST_F(MMIServerTest, MMIServerTest_AddPreInputHandler_001, TestSize.Level1) 1477 { 1478 CALL_TEST_DEBUG; 1479 MMIService mmiService; 1480 std::vector<int32_t> keys = { 1, 2, 3 }; 1481 int32_t ret = mmiService.AddPreInputHandler(100, 1, keys); 1482 EXPECT_NE(ret, RET_OK); 1483 } 1484 1485 /** 1486 * @tc.name: MMIServerTest_AddPreInputHandler_002 1487 * @tc.desc: The keys parameter is empty, and AddPreInputHandler returns RET_ERR 1488 * @tc.type: FUNC 1489 */ 1490 HWTEST_F(MMIServerTest, MMIServerTest_AddPreInputHandler_002, TestSize.Level1) 1491 { 1492 CALL_TEST_DEBUG; 1493 MMIService mmiService; 1494 std::vector<int32_t> emptyKeys; 1495 int32_t ret = mmiService.AddPreInputHandler(1, 1, emptyKeys); 1496 EXPECT_NE(ret, RET_OK); 1497 } 1498 1499 /** 1500 * @tc.name: MMIServerTest_AddPreInputHandler_003 1501 * @tc.desc: The size of keys exceeds the limit; invalid parameter 1502 * @tc.type: FUNC 1503 */ 1504 HWTEST_F(MMIServerTest, MMIServerTest_AddPreInputHandler_003, TestSize.Level1) 1505 { 1506 CALL_TEST_DEBUG; 1507 MMIService mmiService; 1508 std::vector<int32_t> keys(1000, 1); 1509 ErrCode ret = mmiService.AddPreInputHandler(1003, 1, keys); 1510 EXPECT_NE(ret, RET_OK); 1511 } 1512 1513 /** 1514 * @tc.name: MMIServerTest_RemovePreInputHandler_001 1515 * @tc.desc: Non-system application call, returns ERROR_NOT_SYSAPI 1516 * @tc.type: FUNC 1517 */ 1518 HWTEST_F(MMIServerTest, MMIServerTest_RemovePreInputHandler_001, TestSize.Level1) 1519 { 1520 CALL_TEST_DEBUG; 1521 MMIService mmiService; 1522 int32_t ret = mmiService.RemovePreInputHandler(1001); 1523 EXPECT_NE(ret, RET_OK); 1524 } 1525 1526 /** 1527 * @tc.name: MMIServerTest_RemovePreInputHandler_002 1528 * @tc.desc: The service is not running, returning MMISERVICE_NOT_RUNNING 1529 * @tc.type: FUNC 1530 */ 1531 HWTEST_F(MMIServerTest, MMIServerTest_RemovePreInputHandler_002, TestSize.Level1) 1532 { 1533 CALL_TEST_DEBUG; 1534 MMIService mmiService; 1535 if (mmiService.IsRunning()) { 1536 GTEST_SKIP() << "Skip: 当前服务已运行,无法验证未运行场景"; 1537 } 1538 1539 int32_t ret = mmiService.RemovePreInputHandler(1002); 1540 EXPECT_TRUE(ret == ERROR_NOT_SYSAPI || ret == MMISERVICE_NOT_RUNNING); 1541 } 1542 1543 /** 1544 * @tc.name: MMIServerTest_ObserverAddInputHandler_001 1545 * @tc.desc: Test ObserverAddInputHandler returns RET_OK 1546 * @tc.type: FUNC 1547 */ 1548 HWTEST_F(MMIServerTest, MMIServerTest_ObserverAddInputHandler_001, TestSize.Level1) 1549 { 1550 CALL_TEST_DEBUG; 1551 MMIService mmiService; 1552 int32_t testPid = 12345; 1553 int32_t ret = mmiService.ObserverAddInputHandler(testPid); 1554 EXPECT_EQ(ret, RET_OK); 1555 } 1556 1557 /** 1558 * @tc.name: MMIServerTest_AddGestureMonitor_InvalidHandler 1559 * @tc.desc: AddGestureMonitor should return RET_ERR when handlerType is not MONITOR 1560 * @tc.type: FUNC 1561 * @tc.require: 1562 */ 1563 HWTEST_F(MMIServerTest, MMIServerTest_AddGestureMonitor_001, TestSize.Level1) 1564 { 1565 CALL_TEST_DEBUG; 1566 MMIService mmiService; 1567 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 1568 ErrCode ret = mmiService.AddGestureMonitor( 1569 0, 1570 HANDLE_EVENT_TYPE_TOUCH_GESTURE, 1571 3, 1572 2); 1573 MMI_HILOGI("AddGestureMonitor invalid handlerType, ret: %{public}d", ret); 1574 EXPECT_EQ(ret, RET_ERR); 1575 } 1576 1577 /** 1578 * @tc.name: MMIServerTest_RemoveGestureMonitor_001 1579 * @tc.desc: RemoveGestureMonitor returns RET_ERR when handlerType is not MONITOR 1580 * @tc.type: FUNC 1581 * @tc.require: 1582 */ 1583 HWTEST_F(MMIServerTest, MMIServerTest_RemoveGestureMonitor_001, TestSize.Level1) 1584 { 1585 CALL_TEST_DEBUG; 1586 MMIService mmiService; 1587 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 1588 1589 ErrCode ret = mmiService.RemoveGestureMonitor( 1590 0, 1591 HANDLE_EVENT_TYPE_TOUCH_GESTURE, 1592 3, 1593 2); 1594 MMI_HILOGI("RemoveGestureMonitor_001 return: %{public}d", ret); 1595 EXPECT_EQ(ret, RET_ERR); 1596 } 1597 1598 /** 1599 * @tc.name: MMIServerTest_RemoveGestureMonitor_002 1600 * @tc.desc: RemoveGestureMonitor returns expected value for valid MONITOR input 1601 * @tc.type: FUNC 1602 * @tc.require: 1603 */ 1604 HWTEST_F(MMIServerTest, MMIServerTest_RemoveGestureMonitor_002, TestSize.Level1) 1605 { 1606 CALL_TEST_DEBUG; 1607 MMIService mmiService; 1608 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 1609 1610 ErrCode ret = mmiService.RemoveGestureMonitor( 1611 2, 1612 HANDLE_EVENT_TYPE_TOUCH_GESTURE, 1613 3, 1614 2); 1615 MMI_HILOGI("RemoveGestureMonitor_002 return: %{public}d", ret); 1616 EXPECT_EQ(ret, ETASKS_POST_SYNCTASK_FAIL); 1617 } 1618 1619 /** 1620 * @tc.name: MMIServerTest_MarkEventConsumed_001 1621 * @tc.desc: MarkEventConsumed returns error when service is not running 1622 * @tc.type: FUNC 1623 * @tc.require: 1624 */ 1625 HWTEST_F(MMIServerTest, MMIServerTest_MarkEventConsumed_001, TestSize.Level1) 1626 { 1627 CALL_TEST_DEBUG; 1628 MMIService mmiService; 1629 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 1630 int32_t eventId = 1001; 1631 ErrCode ret = mmiService.MarkEventConsumed(eventId); 1632 MMI_HILOGI("MarkEventConsumed_001 ret: %{public}d", ret); 1633 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 1634 } 1635 1636 /** 1637 * @tc.name: MMIServerTest_MarkEventConsumed_002 1638 * @tc.desc: MarkEventConsumed returns success or error in normal running condition 1639 * @tc.type: FUNC 1640 * @tc.require: 1641 */ 1642 HWTEST_F(MMIServerTest, MMIServerTest_MarkEventConsumed_002, TestSize.Level1) 1643 { 1644 CALL_TEST_DEBUG; 1645 MMIService mmiService; 1646 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 1647 int32_t eventId = 1002; 1648 ErrCode ret = mmiService.MarkEventConsumed(eventId); 1649 MMI_HILOGI("MarkEventConsumed_002 ret: %{public}d", ret); 1650 EXPECT_EQ(ret, ETASKS_POST_SYNCTASK_FAIL); 1651 } 1652 1653 /** 1654 * @tc.name: MMIServerTest_InjectKeyEvent_001 1655 * @tc.desc: InjectKeyEvent returns MMISERVICE_NOT_RUNNING if service is not running 1656 * @tc.type: FUNC 1657 * @tc.require: 1658 */ 1659 HWTEST_F(MMIServerTest, MMIServerTest_InjectKeyEvent_001, TestSize.Level1) 1660 { 1661 CALL_TEST_DEBUG; 1662 MMIService mmiService; 1663 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 1664 std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create(); 1665 ASSERT_NE(keyEvent, nullptr); 1666 keyEvent->SetKeyCode(126); 1667 keyEvent->SetAction(KeyEvent::KEY_ACTION_UP); 1668 ErrCode ret = mmiService.InjectKeyEvent(*keyEvent, true); 1669 MMI_HILOGI("InjectKeyEvent_001 ret: %{public}d", ret); 1670 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 1671 } 1672 1673 /** 1674 * @tc.name: MMIServerTest_InjectKeyEvent_002 1675 * @tc.desc: InjectKeyEvent returns ETASKS_POST_SYNCTASK_FAIL when PostSyncTask fails 1676 * @tc.type: FUNC 1677 * @tc.require: 1678 */ 1679 HWTEST_F(MMIServerTest, MMIServerTest_InjectKeyEvent_002, TestSize.Level1) 1680 { 1681 CALL_TEST_DEBUG; 1682 MMIService mmiService; 1683 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 1684 std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create(); 1685 ASSERT_NE(keyEvent, nullptr); 1686 keyEvent->SetKeyCode(126); 1687 keyEvent->SetAction(KeyEvent::KEY_ACTION_UP); 1688 ErrCode ret = mmiService.InjectKeyEvent(*keyEvent, true); 1689 MMI_HILOGI("InjectKeyEvent_002 ret: %{public}d", ret); 1690 EXPECT_EQ(ret, ETASKS_POST_SYNCTASK_FAIL); 1691 } 1692 1693 /** 1694 * @tc.name: MMIServerTest_OnGetKeyState_001 1695 * @tc.desc: OnGetKeyState returns RET_OK or ERROR_NULL_POINTER depending on KeyEvent availability 1696 * @tc.type: FUNC 1697 * @tc.require: 1698 */ 1699 HWTEST_F(MMIServerTest, MMIServerTest_OnGetKeyState_001, TestSize.Level1) 1700 { 1701 CALL_TEST_DEBUG; 1702 MMIService mmiService; 1703 std::vector<int32_t> pressedKeys; 1704 std::unordered_map<int32_t, int32_t> specialKeysState; 1705 ErrCode ret = mmiService.OnGetKeyState(pressedKeys, specialKeysState); 1706 MMI_HILOGI("OnGetKeyState_001 ret: %{public}d", ret); 1707 EXPECT_TRUE(ret == RET_OK || ret == ERROR_NULL_POINTER); 1708 } 1709 1710 /** 1711 * @tc.name: MMIServerTest_CheckInjectPointerEvent_001 1712 * @tc.desc: CheckInjectPointerEvent returns ERROR_NULL_POINTER when pointerEvent is null 1713 * @tc.type: FUNC 1714 * @tc.require: 1715 */ 1716 HWTEST_F(MMIServerTest, MMIServerTest_CheckInjectPointerEvent_001, TestSize.Level1) 1717 { 1718 CALL_TEST_DEBUG; 1719 MMIService mmiService; 1720 std::shared_ptr<PointerEvent> pointerEvent = nullptr; 1721 int32_t pid = 1000; 1722 bool isNativeInject = true; 1723 bool isShell = false; 1724 int32_t useCoordinate = 0; 1725 int32_t ret = mmiService.CheckInjectPointerEvent(pointerEvent, pid, isNativeInject, isShell, useCoordinate); 1726 MMI_HILOGI("CheckInjectPointerEvent_001 return: %{public}d", ret); 1727 EXPECT_EQ(ret, ERROR_NULL_POINTER); 1728 } 1729 1730 /** 1731 * @tc.name: MMIServerTest_CheckInjectPointerEvent_002 1732 * @tc.desc: CheckInjectPointerEvent runs with valid PointerEvent and returns result of handler 1733 * @tc.type: FUNC 1734 * @tc.require: 1735 */ 1736 HWTEST_F(MMIServerTest, MMIServerTest_CheckInjectPointerEvent_002, TestSize.Level1) 1737 { 1738 CALL_TEST_DEBUG; 1739 MMIService mmiService; 1740 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create(); 1741 ASSERT_NE(pointerEvent, nullptr); 1742 pointerEvent->SetId(1); 1743 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN); 1744 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN); 1745 int32_t pid = 1000; 1746 bool isNativeInject = true; 1747 bool isShell = false; 1748 int32_t useCoordinate = 0; 1749 int32_t ret = mmiService.CheckInjectPointerEvent(pointerEvent, pid, isNativeInject, isShell, useCoordinate); 1750 MMI_HILOGI("CheckInjectPointerEvent_002 return: %{public}d", ret); 1751 EXPECT_NE(ret, RET_OK); 1752 } 1753 1754 /** 1755 * @tc.name: MMIServerTest_InjectPointerEvent_001 1756 * @tc.desc: InjectPointerEvent returns MMISERVICE_NOT_RUNNING when service is not running 1757 * @tc.type: FUNC 1758 * @tc.require: 1759 */ 1760 HWTEST_F(MMIServerTest, MMIServerTest_InjectPointerEvent_001, TestSize.Level1) 1761 { 1762 CALL_TEST_DEBUG; 1763 MMIService mmiService; 1764 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 1765 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create(); 1766 ASSERT_NE(pointerEvent, nullptr); 1767 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN); 1768 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN); 1769 ErrCode ret = mmiService.InjectPointerEvent(*pointerEvent, true, 0); 1770 MMI_HILOGI("InjectPointerEvent_001 ret: %{public}d", ret); 1771 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 1772 } 1773 1774 /** 1775 * @tc.name: MMIServerTest_InjectPointerEvent_002 1776 * @tc.desc: InjectPointerEvent returns ETASKS_POST_SYNCTASK_FAIL when PostSyncTask fails 1777 * @tc.type: FUNC 1778 * @tc.require: 1779 */ 1780 HWTEST_F(MMIServerTest, MMIServerTest_InjectPointerEvent_002, TestSize.Level1) 1781 { 1782 CALL_TEST_DEBUG; 1783 MMIService mmiService; 1784 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 1785 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create(); 1786 ASSERT_NE(pointerEvent, nullptr); 1787 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE); 1788 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN); 1789 ErrCode ret = mmiService.InjectPointerEvent(*pointerEvent, true, 0); 1790 MMI_HILOGI("InjectPointerEvent_002 ret: %{public}d", ret); 1791 EXPECT_EQ(ret, ETASKS_POST_SYNCTASK_FAIL); 1792 } 1793 1794 /** 1795 * @tc.name: MMIServerTest_ScreenCaptureCallback_001 1796 * @tc.desc: ScreenCaptureCallback should not crash even if PostSyncTask fails 1797 * @tc.type: FUNC 1798 * @tc.require: 1799 */ 1800 HWTEST_F(MMIServerTest, MMIServerTest_ScreenCaptureCallback_001, TestSize.Level1) 1801 { 1802 CALL_TEST_DEBUG; 1803 auto service = MMIService::GetInstance(); 1804 ASSERT_NE(service, nullptr); 1805 service->state_ = ServiceRunningState::STATE_RUNNING; 1806 int32_t testPid = 12345; 1807 bool isStart = true; 1808 MMIService::ScreenCaptureCallback(testPid, isStart); 1809 SUCCEED(); 1810 } 1811 1812 /** 1813 * @tc.name: MMIServerTest_SubscribeHotkey_001 1814 * @tc.desc: SubscribeHotkey returns MMISERVICE_NOT_RUNNING when service is not running 1815 * @tc.type: FUNC 1816 * @tc.require: 1817 */ 1818 HWTEST_F(MMIServerTest, MMIServerTest_SubscribeHotkey_001, TestSize.Level1) 1819 { 1820 CALL_TEST_DEBUG; 1821 MMIService mmiService; 1822 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 1823 KeyOption keyOption; 1824 keyOption.SetFinalKey(125); 1825 keyOption.SetFinalKeyDown(true); 1826 keyOption.SetPreKeys({123}); 1827 keyOption.SetRepeat(false); 1828 keyOption.SetPriority(SubscribePriority::PRIORITY_0); 1829 ErrCode ret = mmiService.SubscribeHotkey(1, keyOption); 1830 MMI_HILOGI("SubscribeHotkey_001 ret: %{public}d", ret); 1831 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 1832 } 1833 1834 /** 1835 * @tc.name: MMIServerTest_SubscribeHotkey_002 1836 * @tc.desc: SubscribeHotkey returns ETASKS_POST_SYNCTASK_FAIL when PostSyncTask fails 1837 * @tc.type: FUNC 1838 * @tc.require: 1839 */ 1840 HWTEST_F(MMIServerTest, MMIServerTest_SubscribeHotkey_002, TestSize.Level1) 1841 { 1842 CALL_TEST_DEBUG; 1843 MMIService mmiService; 1844 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 1845 KeyOption keyOption; 1846 keyOption.SetFinalKey(126); 1847 keyOption.SetFinalKeyDown(false); 1848 keyOption.SetPreKeys({122}); 1849 keyOption.SetRepeat(true); 1850 keyOption.SetFinalKeyDownDuration(300); 1851 keyOption.SetFinalKeyUpDelay(150); 1852 keyOption.SetPriority(SubscribePriority::PRIORITY_100); 1853 ErrCode ret = mmiService.SubscribeHotkey(100, keyOption); 1854 MMI_HILOGI("SubscribeHotkey_002 ret: %{public}d", ret); 1855 EXPECT_EQ(ret, ETASKS_POST_SYNCTASK_FAIL); 1856 } 1857 1858 /** 1859 * @tc.name: MMIServerTest_SubscribeHotkey_003 1860 * @tc.desc: SubscribeHotkey returns RET_ERR when subscribeId < 0 1861 * @tc.type: FUNC 1862 * @tc.require: 1863 */ 1864 HWTEST_F(MMIServerTest, MMIServerTest_SubscribeHotkey_003, TestSize.Level1) 1865 { 1866 CALL_TEST_DEBUG; 1867 MMIService mmiService; 1868 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 1869 KeyOption keyOption; 1870 keyOption.SetFinalKey(127); 1871 keyOption.SetFinalKeyDown(true); 1872 keyOption.SetPreKeys({120}); 1873 keyOption.SetRepeat(false); 1874 ErrCode ret = mmiService.SubscribeHotkey(-1, keyOption); 1875 MMI_HILOGI("SubscribeHotkey_003 ret: %{public}d", ret); 1876 EXPECT_EQ(ret, RET_ERR); 1877 } 1878 1879 /** 1880 * @tc.name: MMIServerTest_UnsubscribeHotkey_001 1881 * @tc.desc: UnsubscribeHotkey returns MMISERVICE_NOT_RUNNING when service is not running 1882 * @tc.type: FUNC 1883 * @tc.require: 1884 */ 1885 HWTEST_F(MMIServerTest, MMIServerTest_UnsubscribeHotkey_001, TestSize.Level1) 1886 { 1887 CALL_TEST_DEBUG; 1888 MMIService mmiService; 1889 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 1890 int32_t subscribeId = 100; 1891 ErrCode ret = mmiService.UnsubscribeHotkey(subscribeId); 1892 MMI_HILOGI("UnsubscribeHotkey_001 ret: %{public}d", ret); 1893 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 1894 } 1895 1896 /** 1897 * @tc.name: MMIServerTest_UnsubscribeHotkey_002 1898 * @tc.desc: UnsubscribeHotkey returns ETASKS_POST_SYNCTASK_FAIL when PostSyncTask fails 1899 * @tc.type: FUNC 1900 * @tc.require: 1901 */ 1902 HWTEST_F(MMIServerTest, MMIServerTest_UnsubscribeHotkey_002, TestSize.Level1) 1903 { 1904 CALL_TEST_DEBUG; 1905 MMIService mmiService; 1906 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 1907 int32_t subscribeId = 200; 1908 ErrCode ret = mmiService.UnsubscribeHotkey(subscribeId); 1909 MMI_HILOGI("UnsubscribeHotkey_002 ret: %{public}d", ret); 1910 EXPECT_EQ(ret, ETASKS_POST_SYNCTASK_FAIL); 1911 } 1912 1913 /** 1914 * @tc.name: MMIServerTest_SubscribeKeyMonitor_001 1915 * @tc.desc: SubscribeKeyMonitor returns MMISERVICE_NOT_RUNNING when service is not running 1916 * @tc.type: FUNC 1917 * @tc.require: 1918 */ 1919 HWTEST_F(MMIServerTest, MMIServerTest_SubscribeKeyMonitor_001, TestSize.Level1) 1920 { 1921 CALL_TEST_DEBUG; 1922 MMIService mmiService; 1923 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 1924 KeyMonitorOption keyOption; 1925 keyOption.SetKey(125); 1926 keyOption.SetAction(KeyEvent::KEY_ACTION_DOWN); 1927 keyOption.SetRepeat(false); 1928 ErrCode ret = mmiService.SubscribeKeyMonitor(keyOption); 1929 MMI_HILOGI("SubscribeKeyMonitor_001 ret: %{public}d", ret); 1930 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 1931 } 1932 1933 /** 1934 * @tc.name: MMIServerTest_SubscribeKeyMonitor_002 1935 * @tc.desc: SubscribeKeyMonitor returns ETASKS_POST_SYNCTASK_FAIL when PostSyncTask fails 1936 * @tc.type: FUNC 1937 * @tc.require: 1938 */ 1939 HWTEST_F(MMIServerTest, MMIServerTest_SubscribeKeyMonitor_002, TestSize.Level1) 1940 { 1941 CALL_TEST_DEBUG; 1942 MMIService mmiService; 1943 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 1944 KeyMonitorOption keyOption; 1945 keyOption.SetKey(126); 1946 keyOption.SetAction(KeyEvent::KEY_ACTION_UP); 1947 keyOption.SetRepeat(true); 1948 ErrCode ret = mmiService.SubscribeKeyMonitor(keyOption); 1949 MMI_HILOGI("SubscribeKeyMonitor_002 ret: %{public}d", ret); 1950 EXPECT_EQ(ret, ETASKS_POST_SYNCTASK_FAIL); 1951 } 1952 1953 /** 1954 * @tc.name: MMIServerTest_UnsubscribeKeyMonitor_001 1955 * @tc.desc: UnsubscribeKeyMonitor returns MMISERVICE_NOT_RUNNING when service is not running 1956 * @tc.type: FUNC 1957 * @tc.require: 1958 */ 1959 HWTEST_F(MMIServerTest, MMIServerTest_UnsubscribeKeyMonitor_001, TestSize.Level1) 1960 { 1961 CALL_TEST_DEBUG; 1962 MMIService mmiService; 1963 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 1964 KeyMonitorOption keyOption; 1965 keyOption.SetKey(123); 1966 keyOption.SetAction(KeyEvent::KEY_ACTION_DOWN); 1967 keyOption.SetRepeat(false); 1968 ErrCode ret = mmiService.UnsubscribeKeyMonitor(keyOption); 1969 MMI_HILOGI("UnsubscribeKeyMonitor_001 ret: %{public}d", ret); 1970 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 1971 } 1972 1973 /** 1974 * @tc.name: MMIServerTest_UnsubscribeKeyMonitor_002 1975 * @tc.desc: UnsubscribeKeyMonitor returns ETASKS_POST_SYNCTASK_FAIL when PostSyncTask fails 1976 * @tc.type: FUNC 1977 * @tc.require: 1978 */ 1979 HWTEST_F(MMIServerTest, MMIServerTest_UnsubscribeKeyMonitor_002, TestSize.Level1) 1980 { 1981 CALL_TEST_DEBUG; 1982 MMIService mmiService; 1983 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 1984 KeyMonitorOption keyOption; 1985 keyOption.SetKey(124); 1986 keyOption.SetAction(KeyEvent::KEY_ACTION_UP); 1987 keyOption.SetRepeat(true); 1988 ErrCode ret = mmiService.UnsubscribeKeyMonitor(keyOption); 1989 MMI_HILOGI("UnsubscribeKeyMonitor_002 ret: %{public}d", ret); 1990 EXPECT_EQ(ret, ETASKS_POST_SYNCTASK_FAIL); 1991 } 1992 1993 /** 1994 * @tc.name: MMIServerTest_SubscribeSwitchEvent_001 1995 * @tc.desc: SubscribeSwitchEvent returns MMISERVICE_NOT_RUNNING when service is not running 1996 * @tc.type: FUNC 1997 * @tc.require: 1998 */ 1999 HWTEST_F(MMIServerTest, MMIServerTest_SubscribeSwitchEvent_001, TestSize.Level1) 2000 { 2001 CALL_TEST_DEBUG; 2002 MMIService mmiService; 2003 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 2004 int32_t subscribeId = 1001; 2005 int32_t switchType = 1; 2006 ErrCode ret = mmiService.SubscribeSwitchEvent(subscribeId, switchType); 2007 MMI_HILOGI("SubscribeSwitchEvent_001 ret: %{public}d", ret); 2008 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 2009 } 2010 2011 /** 2012 * @tc.name: MMIServerTest_SubscribeSwitchEvent_002 2013 * @tc.desc: SubscribeSwitchEvent returns ETASKS_POST_SYNCTASK_FAIL when PostSyncTask fails 2014 * @tc.type: FUNC 2015 * @tc.require: 2016 */ 2017 HWTEST_F(MMIServerTest, MMIServerTest_SubscribeSwitchEvent_002, TestSize.Level1) 2018 { 2019 CALL_TEST_DEBUG; 2020 MMIService mmiService; 2021 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 2022 int32_t subscribeId = 1002; 2023 int32_t switchType = 2; 2024 ErrCode ret = mmiService.SubscribeSwitchEvent(subscribeId, switchType); 2025 MMI_HILOGI("SubscribeSwitchEvent_002 ret: %{public}d", ret); 2026 EXPECT_NE(ret, RET_OK); 2027 } 2028 2029 /** 2030 * @tc.name: MMIServerTest_UnsubscribeSwitchEvent_001 2031 * @tc.desc: UnsubscribeSwitchEvent returns RET_ERR for invalid subscribeId 2032 * @tc.type: FUNC 2033 * @tc.require: 2034 */ 2035 HWTEST_F(MMIServerTest, MMIServerTest_UnsubscribeSwitchEvent_001, TestSize.Level1) 2036 { 2037 CALL_TEST_DEBUG; 2038 MMIService mmiService; 2039 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 2040 int32_t subscribeId = -1; 2041 ErrCode ret = mmiService.UnsubscribeSwitchEvent(subscribeId); 2042 MMI_HILOGI("UnsubscribeSwitchEvent_001 ret: %{public}d", ret); 2043 EXPECT_EQ(ret, RET_ERR); 2044 } 2045 2046 /** 2047 * @tc.name: MMIServerTest_UnsubscribeSwitchEvent_002 2048 * @tc.desc: UnsubscribeSwitchEvent returns ETASKS_POST_SYNCTASK_FAIL when PostSyncTask fails 2049 * @tc.type: FUNC 2050 * @tc.require: 2051 */ 2052 HWTEST_F(MMIServerTest, MMIServerTest_UnsubscribeSwitchEvent_002, TestSize.Level1) 2053 { 2054 CALL_TEST_DEBUG; 2055 MMIService mmiService; 2056 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 2057 int32_t subscribeId = 1000; 2058 ErrCode ret = mmiService.UnsubscribeSwitchEvent(subscribeId); 2059 MMI_HILOGI("UnsubscribeSwitchEvent_002 ret: %{public}d", ret); 2060 EXPECT_NE(ret, RET_OK); 2061 } 2062 2063 /** 2064 * @tc.name: MMIServerTest_QuerySwitchStatus_001 2065 * @tc.desc: QuerySwitchStatus returns error when service not running 2066 * @tc.type: FUNC 2067 * @tc.require: 2068 */ 2069 HWTEST_F(MMIServerTest, MMIServerTest_QuerySwitchStatus_001, TestSize.Level1) 2070 { 2071 CALL_TEST_DEBUG; 2072 MMIService mmiService; 2073 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 2074 int32_t switchType = 1; 2075 int32_t state = -1; 2076 ErrCode ret = mmiService.QuerySwitchStatus(switchType, state); 2077 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 2078 } 2079 2080 /** 2081 * @tc.name: MMIServerTest_QuerySwitchStatus_002 2082 * @tc.desc: QuerySwitchStatus returns error when PostSyncTask fails 2083 * @tc.type: FUNC 2084 * @tc.require: 2085 */ 2086 HWTEST_F(MMIServerTest, MMIServerTest_QuerySwitchStatus_002, TestSize.Level1) 2087 { 2088 CALL_TEST_DEBUG; 2089 MMIService mmiService; 2090 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 2091 int32_t switchType = 1; 2092 int32_t state = -1; 2093 ErrCode ret = mmiService.QuerySwitchStatus(switchType, state); 2094 EXPECT_NE(ret, RET_OK); 2095 } 2096 2097 /** 2098 * @tc.name: MMIServerTest_SubscribeTabletProximity_001 2099 * @tc.desc: SubscribeTabletProximity returns error when service is not running 2100 * @tc.type: FUNC 2101 * @tc.require: 2102 */ 2103 HWTEST_F(MMIServerTest, MMIServerTest_SubscribeTabletProximity_001, TestSize.Level1) 2104 { 2105 CALL_TEST_DEBUG; 2106 MMIService mmiService; 2107 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 2108 int32_t subscribeId = 123; 2109 ErrCode ret = mmiService.SubscribeTabletProximity(subscribeId); 2110 MMI_HILOGI("SubscribeTabletProximity_001 ret: %{public}d", ret); 2111 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 2112 } 2113 2114 /** 2115 * @tc.name: MMIServerTest_SubscribeTabletProximity_002 2116 * @tc.desc: SubscribeTabletProximity returns error when PostSyncTask fails 2117 * @tc.type: FUNC 2118 * @tc.require: 2119 */ 2120 HWTEST_F(MMIServerTest, MMIServerTest_SubscribeTabletProximity_002, TestSize.Level1) 2121 { 2122 CALL_TEST_DEBUG; 2123 MMIService mmiService; 2124 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 2125 int32_t subscribeId = 456; 2126 ErrCode ret = mmiService.SubscribeTabletProximity(subscribeId); 2127 MMI_HILOGI("SubscribeTabletProximity_002 ret: %{public}d", ret); 2128 EXPECT_EQ(ret, ETASKS_POST_SYNCTASK_FAIL); 2129 } 2130 2131 /** 2132 * @tc.name: MMIServerTest_UnsubscribetabletProximity_001 2133 * @tc.desc: Unsubscribe tablet proximity when service is not running 2134 * @tc.type: FUNC 2135 * @tc.require: 2136 */ 2137 HWTEST_F(MMIServerTest, MMIServerTest_UnsubscribetabletProximity_001, TestSize.Level1) 2138 { 2139 CALL_TEST_DEBUG; 2140 MMIService mmiService; 2141 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 2142 int32_t subscribeId = 1; 2143 ErrCode ret = mmiService.UnsubscribetabletProximity(subscribeId); 2144 MMI_HILOGI("UnsubscribetabletProximity_001 ret: %{public}d", ret); 2145 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 2146 } 2147 2148 /** 2149 * @tc.name: MMIServerTest_UnsubscribetabletProximity_002 2150 * @tc.desc: Unsubscribe tablet proximity with invalid id 2151 * @tc.type: FUNC 2152 * @tc.require: 2153 */ 2154 HWTEST_F(MMIServerTest, MMIServerTest_UnsubscribetabletProximity_002, TestSize.Level1) 2155 { 2156 CALL_TEST_DEBUG; 2157 MMIService mmiService; 2158 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 2159 int32_t invalidId = -1; 2160 ErrCode ret = mmiService.UnsubscribetabletProximity(invalidId); 2161 MMI_HILOGI("UnsubscribetabletProximity_002 ret: %{public}d", ret); 2162 EXPECT_EQ(ret, RET_ERR); 2163 } 2164 2165 /** 2166 * @tc.name: MMIServerTest_SubscribeLongPressEvent_001 2167 * @tc.desc: SubscribeLongPressEvent when service is not running 2168 * @tc.type: FUNC 2169 * @tc.require: 2170 */ 2171 HWTEST_F(MMIServerTest, MMIServerTest_SubscribeLongPressEvent_001, TestSize.Level1) 2172 { 2173 CALL_TEST_DEBUG; 2174 MMIService mmiService; 2175 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 2176 int32_t subscribeId = 1; 2177 LongPressRequest req; 2178 ErrCode ret = mmiService.SubscribeLongPressEvent(subscribeId, req); 2179 MMI_HILOGI("SubscribeLongPressEvent_001 ret: %{public}d", ret); 2180 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 2181 } 2182 2183 /** 2184 * @tc.name: MMIServerTest_SubscribeLongPressEvent_002 2185 * @tc.desc: SubscribeLongPressEvent returns failure if PostSyncTask fails 2186 * @tc.type: FUNC 2187 * @tc.require: 2188 */ 2189 HWTEST_F(MMIServerTest, MMIServerTest_SubscribeLongPressEvent_002, TestSize.Level1) 2190 { 2191 CALL_TEST_DEBUG; 2192 MMIService mmiService; 2193 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 2194 int32_t subscribeId = 100; 2195 LongPressRequest req; 2196 ErrCode ret = mmiService.SubscribeLongPressEvent(subscribeId, req); 2197 MMI_HILOGI("SubscribeLongPressEvent_002 ret: %{public}d", ret); 2198 EXPECT_EQ(ret, ETASKS_POST_SYNCTASK_FAIL); 2199 } 2200 2201 /** 2202 * @tc.name: MMIServerTest_UnsubscribeLongPressEvent_001 2203 * @tc.desc: UnsubscribeLongPressEvent when service is not running 2204 * @tc.type: FUNC 2205 * @tc.require: 2206 */ 2207 HWTEST_F(MMIServerTest, MMIServerTest_UnsubscribeLongPressEvent_001, TestSize.Level1) 2208 { 2209 CALL_TEST_DEBUG; 2210 MMIService mmiService; 2211 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 2212 int32_t subscribeId = 1; 2213 ErrCode ret = mmiService.UnsubscribeLongPressEvent(subscribeId); 2214 MMI_HILOGI("UnsubscribeLongPressEvent_001 ret: %{public}d", ret); 2215 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 2216 } 2217 2218 /** 2219 * @tc.name: MMIServerTest_UnsubscribeLongPressEvent_002 2220 * @tc.desc: UnsubscribeLongPressEvent fails if PostSyncTask fails 2221 * @tc.type: FUNC 2222 * @tc.require: 2223 */ 2224 HWTEST_F(MMIServerTest, MMIServerTest_UnsubscribeLongPressEvent_002, TestSize.Level1) 2225 { 2226 CALL_TEST_DEBUG; 2227 MMIService mmiService; 2228 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 2229 int32_t subscribeId = 99; 2230 ErrCode ret = mmiService.UnsubscribeLongPressEvent(subscribeId); 2231 MMI_HILOGI("UnsubscribeLongPressEvent_002 ret: %{public}d", ret); 2232 EXPECT_EQ(ret, ETASKS_POST_SYNCTASK_FAIL); 2233 } 2234 2235 /** 2236 * @tc.name: MMIServerTest_SetAnrObserver_001 2237 * @tc.desc: SetAnrObserver when service not running, expect fail 2238 * @tc.type: FUNC 2239 * @tc.require: 2240 */ 2241 HWTEST_F(MMIServerTest, MMIServerTest_SetAnrObserver_001, TestSize.Level1) 2242 { 2243 CALL_TEST_DEBUG; 2244 MMIService mmiService; 2245 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 2246 ErrCode ret = mmiService.SetAnrObserver(); 2247 MMI_HILOGI("SetAnrObserver_001 ret: %{public}d", ret); 2248 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 2249 } 2250 2251 /** 2252 * @tc.name: MMIServerTest_SetAnrObserver_002 2253 * @tc.desc: SetAnrObserver when PostSyncTask fails, expect fail 2254 * @tc.type: FUNC 2255 * @tc.require: 2256 */ 2257 HWTEST_F(MMIServerTest, MMIServerTest_SetAnrObserver_002, TestSize.Level1) 2258 { 2259 CALL_TEST_DEBUG; 2260 MMIService mmiService; 2261 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 2262 ErrCode ret = mmiService.SetAnrObserver(); 2263 MMI_HILOGI("SetAnrObserver_002 ret: %{public}d", ret); 2264 EXPECT_EQ(ret, ETASKS_POST_SYNCTASK_FAIL); 2265 } 2266 2267 /** 2268 * @tc.name: MMIServerTest_GetAllMmiSubscribedEvents_001 2269 * @tc.desc: GetAllMmiSubscribedEvents when service not running, expect fail 2270 * @tc.type: FUNC 2271 * @tc.require: 2272 */ 2273 HWTEST_F(MMIServerTest, MMIServerTest_GetAllMmiSubscribedEvents_001, TestSize.Level1) 2274 { 2275 CALL_TEST_DEBUG; 2276 MMIService mmiService; 2277 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 2278 MmiEventMap mmiEventMap; 2279 ErrCode ret = mmiService.GetAllMmiSubscribedEvents(mmiEventMap); 2280 MMI_HILOGI("GetAllMmiSubscribedEvents_001 ret: %{public}d", ret); 2281 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 2282 } 2283 2284 /** 2285 * @tc.name: MMIServerTest_GetAllMmiSubscribedEvents_002 2286 * @tc.desc: GetAllMmiSubscribedEvents when service is running 2287 * @tc.type: FUNC 2288 * @tc.require: 2289 */ 2290 HWTEST_F(MMIServerTest, MMIServerTest_GetAllMmiSubscribedEvents_002, TestSize.Level1) 2291 { 2292 CALL_TEST_DEBUG; 2293 MMIService mmiService; 2294 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 2295 MmiEventMap mmiEventMap; 2296 mmiEventMap.datas.emplace(std::make_tuple(1, 0, "dummy"), 123); 2297 ErrCode ret = mmiService.GetAllMmiSubscribedEvents(mmiEventMap); 2298 EXPECT_EQ(ret, RET_OK); 2299 EXPECT_TRUE(mmiEventMap.datas.empty()); 2300 } 2301 2302 /** 2303 * @tc.name: MMIServerTest_SetPointerLocation_001 2304 * @tc.desc: SetPointerLocation when service is not running 2305 * @tc.type: FUNC 2306 * @tc.require: 2307 */ 2308 HWTEST_F(MMIServerTest, MMIServerTest_SetPointerLocation_001, TestSize.Level1) 2309 { 2310 CALL_TEST_DEBUG; 2311 MMIService service; 2312 service.state_ = ServiceRunningState::STATE_NOT_START; 2313 int32_t x = 100; 2314 int32_t y = 200; 2315 int32_t displayId = 0; 2316 ErrCode ret = service.SetPointerLocation(x, y, displayId); 2317 MMI_HILOGI("SetPointerLocation_001 ret: %{public}d", ret); 2318 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 2319 } 2320 2321 /** 2322 * @tc.name: MMIServerTest_SetPointerLocation_002 2323 * @tc.desc: SetPointerLocation when PostSyncTask fails 2324 * @tc.type: FUNC 2325 * @tc.require: 2326 */ 2327 HWTEST_F(MMIServerTest, MMIServerTest_SetPointerLocation_002, TestSize.Level1) 2328 { 2329 CALL_TEST_DEBUG; 2330 MMIService service; 2331 service.state_ = ServiceRunningState::STATE_RUNNING; 2332 int32_t x = 300; 2333 int32_t y = 400; 2334 int32_t displayId = 1; 2335 ErrCode ret = service.SetPointerLocation(x, y, displayId); 2336 MMI_HILOGI("SetPointerLocation_002 ret: %{public}d", ret); 2337 EXPECT_EQ(ret, ETASKS_POST_SYNCTASK_FAIL); 2338 } 2339 2340 /** 2341 * @tc.name: MMIService_OnGetWindowPid_001 2342 * @tc.desc: Obtain the pid of a legitimate windowId, and it should return RET_OK 2343 * @tc.type: FUNC 2344 * @tc.require:SR000HQ1CT 2345 */ 2346 HWTEST_F(MMIServerTest, MMIService_OnGetWindowPid_001, TestSize.Level1) 2347 { 2348 CALL_TEST_DEBUG; 2349 MMIService mmiService; 2350 int32_t windowId = 1; 2351 int32_t pid = -1; 2352 int32_t ret = mmiService.OnGetWindowPid(windowId, pid); 2353 MMI_HILOGI("OnGetWindowPid ret: %{public}d, pid: %{public}d", ret, pid); 2354 EXPECT_TRUE(ret == RET_OK || ret == RET_ERR); 2355 if (ret == RET_OK) { 2356 EXPECT_GT(pid, 0); 2357 } 2358 } 2359 2360 /** 2361 * @tc.name: MMIService_AppendExtraData_001 2362 * @tc.desc: When the system application appends valid ExtraData, it should return RET_OK or a task failure code 2363 * @tc.type: FUNC 2364 * @tc.require: 2365 */ 2366 HWTEST_F(MMIServerTest, MMIService_AppendExtraData_001, TestSize.Level1) 2367 { 2368 CALL_TEST_DEBUG; 2369 MMIService mmiService; 2370 ExtraData data; 2371 data.sourceType = InputEvent::SOURCE_TYPE_TOUCHSCREEN; 2372 data.pointerId = 0; 2373 data.pullId = 0; 2374 data.eventId = 100; 2375 data.buffer.resize(32); 2376 int32_t returnCode = 65142800; 2377 int32_t ret = mmiService.AppendExtraData(data); 2378 MMI_HILOGI("AppendExtraData ret: %{public}d", ret); 2379 EXPECT_EQ(ret, returnCode); 2380 } 2381 2382 /** 2383 * @tc.name: MMIService_AppendExtraData_002 2384 * @tc.desc: When called while MMIService is not running, it should return MMISERVICE_NOT_RUNNING 2385 * @tc.type: FUNC 2386 * @tc.require: 2387 */ 2388 HWTEST_F(MMIServerTest, MMIService_AppendExtraData_002, TestSize.Level1) 2389 { 2390 CALL_TEST_DEBUG; 2391 MMIService mmiService; 2392 ExtraData data; 2393 data.sourceType = InputEvent::SOURCE_TYPE_TOUCHSCREEN; 2394 data.pointerId = 0; 2395 data.pullId = 0; 2396 data.eventId = 500; 2397 data.buffer.resize(16); 2398 int32_t ret = mmiService.AppendExtraData(data); 2399 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 2400 } 2401 2402 /** 2403 * @tc.name: MMIService_UpdateCombineKeyState_001 2404 * @tc.desc: Both handlers exist, and the EnableCombineKey call succeeds or fails 2405 * @tc.type: FUNC 2406 * @tc.require: 2407 */ 2408 HWTEST_F(MMIServerTest, MMIService_UpdateCombineKeyState_001, TestSize.Level1) 2409 { 2410 CALL_TEST_DEBUG; 2411 MMIService mmiService; 2412 bool enable = true; 2413 int32_t ret = mmiService.UpdateCombineKeyState(enable); 2414 MMI_HILOGI("UpdateCombineKeyState ret: %{public}d", ret); 2415 EXPECT_TRUE(ret == RET_OK || ret == RET_ERR); 2416 } 2417 2418 /** 2419 * @tc.name: MMIService_UpdateCombineKeyState_002 2420 * @tc.desc: When SubscriberHandler is null, RET_ERR should be returned 2421 * @tc.type: FUNC 2422 * @tc.require: 2423 */ 2424 HWTEST_F(MMIServerTest, MMIService_UpdateCombineKeyState_002, TestSize.Level1) 2425 { 2426 CALL_TEST_DEBUG; 2427 MMIService mmiService; 2428 auto backup = InputHandler->GetSubscriberHandler(); 2429 int32_t ret = mmiService.UpdateCombineKeyState(true); 2430 EXPECT_EQ(ret, RET_ERR); 2431 } 2432 2433 /** 2434 * @tc.name: MMIService_UpdateCombineKeyState_003 2435 * @tc.desc: When KeyCommandHandler is null, RET_ERR should be returned 2436 * @tc.type: FUNC 2437 * @tc.require: 2438 */ 2439 HWTEST_F(MMIServerTest, MMIService_UpdateCombineKeyState_003, TestSize.Level1) 2440 { 2441 CALL_TEST_DEBUG; 2442 MMIService mmiService; 2443 auto backup = InputHandler->GetSubscriberHandler(); 2444 int32_t ret = mmiService.UpdateCombineKeyState(true); 2445 EXPECT_EQ(ret, RET_ERR); 2446 } 2447 2448 /** 2449 * @tc.name: MMIService_EnableCombineKey_001 2450 * @tc.desc: EnableCombineKey when service not running 2451 * @tc.type: FUNC 2452 * @tc.require: 2453 */ 2454 HWTEST_F(MMIServerTest, MMIService_EnableCombineKey_001, TestSize.Level1) 2455 { 2456 CALL_TEST_DEBUG; 2457 MMIService mmiService; 2458 ErrCode ret = mmiService.EnableCombineKey(true); 2459 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 2460 } 2461 2462 /** 2463 * @tc.name: MMIService_EnableCombineKey_002 2464 * @tc.desc: Non-system application calls EnableCombineKey and returns ERROR_NOT_SYSAPI 2465 * @tc.type: FUNC 2466 * @tc.require: 2467 */ 2468 HWTEST_F(MMIServerTest, MMIService_EnableCombineKey_002, TestSize.Level1) 2469 { 2470 CALL_TEST_DEBUG; 2471 MMIService mmiService; 2472 int32_t ret = mmiService.EnableCombineKey(true); 2473 EXPECT_NE(ret, RET_ERR); 2474 } 2475 2476 /** 2477 * @tc.name: MMIService_EnableCombineKey_003 2478 * @tc.desc: When MMIService is not running, EnableCombineKey returns MMISERVICE_NOT_RUNNING 2479 * @tc.type: FUNC 2480 * @tc.require: 2481 */ 2482 HWTEST_F(MMIServerTest, MMIService_EnableCombineKey_003, TestSize.Level1) 2483 { 2484 CALL_TEST_DEBUG; 2485 MMIService mmiService; 2486 int32_t ret = mmiService.EnableCombineKey(true); 2487 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 2488 } 2489 2490 /** 2491 * @tc.name: MMIService_UpdateSettingsXml_001 2492 * @tc.desc: Normally calling UpdateSettingsXml is expected to return RET_OK or a business layer return code 2493 * @tc.type: FUNC 2494 * @tc.require: 2495 */ 2496 HWTEST_F(MMIServerTest, MMIService_UpdateSettingsXml_001, TestSize.Level1) 2497 { 2498 CALL_TEST_DEBUG; 2499 MMIService mmiService; 2500 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 2501 std::string businessId = "com.example.setting"; 2502 int32_t delay = 300; 2503 int32_t ret = mmiService.UpdateSettingsXml(businessId, delay); 2504 MMI_HILOGI("UpdateSettingsXml return code: %{public}d", ret); 2505 EXPECT_TRUE(ret == RET_OK || ret == RET_ERR || ret > 0); 2506 } 2507 2508 /** 2509 * @tc.name: MMIService_UpdateSettingsXml_002 2510 * @tc.desc: Pass an empty business ID and check the function's processing result 2511 * @tc.type: FUNC 2512 * @tc.require: 2513 */ 2514 HWTEST_F(MMIServerTest, MMIService_UpdateSettingsXml_002, TestSize.Level1) 2515 { 2516 CALL_TEST_DEBUG; 2517 MMIService mmiService; 2518 std::string businessId = ""; 2519 int32_t delay = 100; 2520 int32_t ret = mmiService.UpdateSettingsXml(businessId, delay); 2521 MMI_HILOGI("UpdateSettingsXml with empty businessId, return code: %{public}d", ret); 2522 EXPECT_TRUE(ret == RET_OK || ret == RET_ERR || ret > 0); 2523 } 2524 2525 /** 2526 * @tc.name: MMIService_UpdateSettingsXml_003 2527 * @tc.desc: Pass a negative number delay, check the function's processing result 2528 * @tc.type: FUNC 2529 * @tc.require: 2530 */ 2531 HWTEST_F(MMIServerTest, MMIService_UpdateSettingsXml_003, TestSize.Level1) 2532 { 2533 CALL_TEST_DEBUG; 2534 MMIService mmiService; 2535 std::string businessId = "com.example.delay"; 2536 int32_t delay = -100; 2537 int32_t ret = mmiService.UpdateSettingsXml(businessId, delay); 2538 EXPECT_TRUE(ret == RET_OK || ret == RET_ERR || ret > 0); 2539 } 2540 2541 /** 2542 * @tc.name: MMIService_SetKeyDownDuration_001 2543 * @tc.desc: Service not running, expect MMISERVICE_NOT_RUNNING 2544 * @tc.type: FUNC 2545 * @tc.require: 2546 */ 2547 HWTEST_F(MMIServerTest, MMIService_SetKeyDownDuration_001, TestSize.Level1) 2548 { 2549 CALL_TEST_DEBUG; 2550 MMIService mmiService; 2551 ErrCode ret = mmiService.SetKeyDownDuration("testBusiness", 100); 2552 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 2553 } 2554 2555 /** 2556 * @tc.name: MMIService_SetKeyDownDuration_002 2557 * @tc.desc: PostSyncTask runs (success or fail), service running 2558 * @tc.type: FUNC 2559 * @tc.require: 2560 */ 2561 HWTEST_F(MMIServerTest, MMIService_SetKeyDownDuration_002, TestSize.Level1) 2562 { 2563 CALL_TEST_DEBUG; 2564 MMIService mmiService; 2565 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 2566 ErrCode ret = mmiService.SetKeyDownDuration("realBiz", 300); 2567 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL); 2568 } 2569 2570 /** 2571 * @tc.name: MMIService_ReadTouchpadScrollSwich_001 2572 * @tc.desc: Verify ReadTouchpadScrollSwich returns RET_OK 2573 * @tc.type: FUNC 2574 * @tc.require: 2575 */ 2576 HWTEST_F(MMIServerTest, MMIService_ReadTouchpadScrollSwich_001, TestSize.Level1) 2577 { 2578 MMIService mmiService; 2579 bool value = false; 2580 int32_t ret = mmiService.ReadTouchpadScrollSwich(value); 2581 EXPECT_EQ(ret, RET_OK); 2582 } 2583 2584 /** 2585 * @tc.name: MMIService_ReadTouchpadScrollDirection_001 2586 * @tc.desc: Verify ReadTouchpadScrollDirection returns RET_OK 2587 * @tc.type: FUNC 2588 * @tc.require: 2589 */ 2590 HWTEST_F(MMIServerTest, MMIService_ReadTouchpadScrollDirection_001, TestSize.Level1) 2591 { 2592 MMIService mmiService; 2593 bool value = false; 2594 int32_t ret = mmiService.ReadTouchpadScrollDirection(value); 2595 EXPECT_EQ(ret, RET_OK); 2596 } 2597 2598 /** 2599 * @tc.name: MMIService_ReadTouchpadTapSwitch_001 2600 * @tc.desc: Verify ReadTouchpadTapSwitch returns RET_OK 2601 * @tc.type: FUNC 2602 * @tc.require: 2603 */ 2604 HWTEST_F(MMIServerTest, MMIService_ReadTouchpadTapSwitch_001, TestSize.Level1) 2605 { 2606 MMIService mmiService; 2607 bool value = false; 2608 int32_t ret = mmiService.ReadTouchpadTapSwitch(value); 2609 EXPECT_EQ(ret, RET_OK); 2610 } 2611 2612 /** 2613 * @tc.name: MMIService_ReadTouchpadPointerSpeed_001 2614 * @tc.desc: Verify ReadTouchpadPointerSpeed returns RET_OK 2615 * @tc.type: FUNC 2616 * @tc.require: 2617 */ 2618 HWTEST_F(MMIServerTest, MMIService_ReadTouchpadPointerSpeed_001, TestSize.Level1) 2619 { 2620 MMIService mmiService; 2621 int32_t speed = -1; 2622 int32_t ret = mmiService.ReadTouchpadPointerSpeed(speed); 2623 EXPECT_EQ(ret, RET_OK); 2624 } 2625 2626 /** 2627 * @tc.name: MMIService_ReadTouchpadPinchSwitch_001 2628 * @tc.desc: Verify ReadTouchpadPinchSwitch returns RET_OK 2629 * @tc.type: FUNC 2630 * @tc.require: 2631 */ 2632 HWTEST_F(MMIServerTest, MMIService_ReadTouchpadPinchSwitch_001, TestSize.Level1) 2633 { 2634 MMIService mmiService; 2635 bool value = false; 2636 int32_t ret = mmiService.ReadTouchpadPinchSwitch(value); 2637 EXPECT_EQ(ret, RET_OK); 2638 } 2639 2640 /** 2641 * @tc.name: MMIService_ReadTouchpadSwipeSwitch_001 2642 * @tc.desc: Verify ReadTouchpadSwipeSwitch returns RET_OK 2643 * @tc.type: FUNC 2644 * @tc.require: 2645 */ 2646 HWTEST_F(MMIServerTest, MMIService_ReadTouchpadSwipeSwitch_001, TestSize.Level1) 2647 { 2648 MMIService mmiService; 2649 bool value = false; 2650 int32_t ret = mmiService.ReadTouchpadSwipeSwitch(value); 2651 EXPECT_EQ(ret, RET_OK); 2652 } 2653 2654 /** 2655 * @tc.name: MMIService_ReadTouchpadRightMenuType_001 2656 * @tc.desc: Verify ReadTouchpadRightMenuType returns RET_OK 2657 * @tc.type: FUNC 2658 * @tc.require: 2659 */ 2660 HWTEST_F(MMIServerTest, MMIService_ReadTouchpadRightMenuType_001, TestSize.Level1) 2661 { 2662 MMIService mmiService; 2663 int32_t type = -1; 2664 int32_t ret = mmiService.ReadTouchpadRightMenuType(type); 2665 EXPECT_EQ(ret, RET_OK); 2666 } 2667 2668 /** 2669 * @tc.name: MMIService_ReadTouchpadRotateSwitch_001 2670 * @tc.desc: Verify ReadTouchpadRotateSwitch returns RET_OK 2671 * @tc.type: FUNC 2672 * @tc.require: 2673 */ 2674 HWTEST_F(MMIServerTest, MMIService_ReadTouchpadRotateSwitch_001, TestSize.Level1) 2675 { 2676 MMIService mmiService; 2677 bool value = false; 2678 int32_t ret = mmiService.ReadTouchpadRotateSwitch(value); 2679 EXPECT_EQ(ret, RET_OK); 2680 } 2681 2682 /** 2683 * @tc.name: MMIService_ReadTouchpadDoubleTapAndDragState_001 2684 * @tc.desc: Verify ReadTouchpadDoubleTapAndDragState returns RET_OK 2685 * @tc.type: FUNC 2686 * @tc.require: 2687 */ 2688 HWTEST_F(MMIServerTest, MMIService_ReadTouchpadDoubleTapAndDragState_001, TestSize.Level1) 2689 { 2690 MMIService mmiService; 2691 bool value = false; 2692 int32_t ret = mmiService.ReadTouchpadDoubleTapAndDragState(value); 2693 EXPECT_EQ(ret, RET_OK); 2694 } 2695 2696 /** 2697 * @tc.name: MMIService_SetTouchpadScrollSwitch_001 2698 * @tc.desc: Verify SetTouchpadScrollSwitch returns RET_OK or ETASKS_POST_SYNCTASK_FAIL 2699 * @tc.type: FUNC 2700 * @tc.require: 2701 */ 2702 HWTEST_F(MMIServerTest, MMIService_SetTouchpadScrollSwitch_001, TestSize.Level1) 2703 { 2704 MMIService mmiService; 2705 bool switchFlag = true; 2706 int32_t ret = mmiService.SetTouchpadScrollSwitch(switchFlag); 2707 EXPECT_NE(ret, RET_OK); 2708 } 2709 2710 /** 2711 * @tc.name: MMIService_SetTouchpadScrollSwitch_002 2712 * @tc.desc: Verify SetTouchpadScrollSwitch returns MMISERVICE_NOT_RUNNING when service is not running 2713 * @tc.type: FUNC 2714 * @tc.require: 2715 */ 2716 HWTEST_F(MMIServerTest, MMIService_SetTouchpadScrollSwitch_002, TestSize.Level1) 2717 { 2718 MMIService mmiService; 2719 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 2720 bool switchFlag = false; 2721 int32_t ret = mmiService.SetTouchpadScrollSwitch(switchFlag); 2722 EXPECT_NE(ret, RET_OK); 2723 } 2724 2725 /** 2726 * @tc.name: MMIService_GetTouchpadScrollSwitch_001 2727 * @tc.desc: GetTouchpadScrollSwitch should return RET_OK or ETASKS_POST_SYNCTASK_FAIL when service is running 2728 * @tc.type: FUNC 2729 * @tc.require: 2730 */ 2731 HWTEST_F(MMIServerTest, MMIService_GetTouchpadScrollSwitch_001, TestSize.Level1) 2732 { 2733 MMIService mmiService; 2734 bool switchFlag = false; 2735 int32_t ret = mmiService.GetTouchpadScrollSwitch(switchFlag); 2736 EXPECT_NE(ret, RET_OK); 2737 } 2738 2739 /** 2740 * @tc.name: MMIService_GetTouchpadScrollSwitch_002 2741 * @tc.desc: GetTouchpadScrollSwitch should return MMISERVICE_NOT_RUNNING when service is not running 2742 * @tc.type: FUNC 2743 * @tc.require: 2744 */ 2745 HWTEST_F(MMIServerTest, MMIService_GetTouchpadScrollSwitch_002, TestSize.Level1) 2746 { 2747 MMIService mmiService; 2748 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 2749 bool switchFlag = false; 2750 int32_t ret = mmiService.GetTouchpadScrollSwitch(switchFlag); 2751 EXPECT_NE(ret, RET_OK); 2752 } 2753 2754 /** 2755 * @tc.name: MMIService_SetTouchpadScrollDirection_001 2756 * @tc.desc: SetTouchpadScrollDirection should succeed or fail due to PostSyncTask failure 2757 * @tc.type: FUNC 2758 * @tc.require: 2759 */ 2760 HWTEST_F(MMIServerTest, MMIService_SetTouchpadScrollDirection_001, TestSize.Level1) 2761 { 2762 MMIService mmiService; 2763 bool state = true; 2764 int32_t ret = mmiService.SetTouchpadScrollDirection(state); 2765 EXPECT_NE(ret, RET_OK); 2766 } 2767 2768 /** 2769 * @tc.name: MMIService_SetTouchpadScrollDirection_002 2770 * @tc.desc: SetTouchpadScrollDirection should fail when service is not running 2771 * @tc.type: FUNC 2772 * @tc.require: 2773 */ 2774 HWTEST_F(MMIServerTest, MMIService_SetTouchpadScrollDirection_002, TestSize.Level1) 2775 { 2776 MMIService mmiService; 2777 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 2778 bool state = false; 2779 int32_t ret = mmiService.SetTouchpadScrollDirection(state); 2780 EXPECT_NE(ret, RET_OK); 2781 } 2782 2783 /** 2784 * @tc.name: MMIService_GetTouchpadScrollDirection_001 2785 * @tc.desc: Verify return RET_OK when service is running and permission is valid 2786 * @tc.type: FUNC 2787 */ 2788 HWTEST_F(MMIServerTest, MMIService_GetTouchpadScrollDirection_001, TestSize.Level1) 2789 { 2790 CALL_TEST_DEBUG; 2791 MMIService mmiService; 2792 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 2793 bool switchFlag = false; 2794 ErrCode ret = mmiService.GetTouchpadScrollDirection(switchFlag); 2795 EXPECT_NE(ret, RET_OK); 2796 } 2797 2798 /** 2799 * @tc.name: MMIService_GetTouchpadScrollDirection_002 2800 * @tc.desc: Test GetTouchpadScrollDirection when service is not running 2801 * @tc.type: FUNC 2802 * @tc.require: 2803 */ 2804 HWTEST_F(MMIServerTest, MMIService_GetTouchpadScrollDirection_002, TestSize.Level1) 2805 { 2806 CALL_TEST_DEBUG; 2807 MMIService mmiService; 2808 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 2809 bool direction = false; 2810 ErrCode ret = mmiService.GetTouchpadScrollDirection(direction); 2811 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 2812 } 2813 2814 /** 2815 * @tc.name: MMIService_SetTouchpadTapSwitch_001 2816 * @tc.desc: Verify SetTouchpadTapSwitch returns MMISERVICE_NOT_RUNNING when service not running 2817 * @tc.type: FUNC 2818 * @tc.require: 2819 */ 2820 HWTEST_F(MMIServerTest, MMIService_SetTouchpadTapSwitch_001, TestSize.Level1) 2821 { 2822 CALL_TEST_DEBUG; 2823 MMIService mmiService; 2824 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 2825 bool value = false; 2826 ErrCode ret = mmiService.SetTouchpadTapSwitch(value); 2827 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 2828 } 2829 2830 /** 2831 * @tc.name: MMIService_SetTouchpadTapSwitch_002 2832 * @tc.desc: Verify SetTouchpadTapSwitch returns RET_OK or ETASKS_POST_SYNCTASK_FAIL on normal condition 2833 * @tc.type: FUNC 2834 * @tc.require: 2835 */ 2836 HWTEST_F(MMIServerTest, MMIService_SetTouchpadTapSwitch_002, TestSize.Level1) 2837 { 2838 CALL_TEST_DEBUG; 2839 MMIService mmiService; 2840 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 2841 bool value = true; 2842 ErrCode ret = mmiService.SetTouchpadTapSwitch(value); 2843 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL); 2844 } 2845 2846 /** 2847 * @tc.name: MMIService_GetTouchpadTapSwitch_001 2848 * @tc.desc: Verify GetTouchpadTapSwitch returns MMISERVICE_NOT_RUNNING when service is not running 2849 * @tc.type: FUNC 2850 * @tc.require: 2851 */ 2852 HWTEST_F(MMIServerTest, MMIService_GetTouchpadTapSwitch_001, TestSize.Level1) 2853 { 2854 CALL_TEST_DEBUG; 2855 MMIService mmiService; 2856 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 2857 bool switchFlag = false; 2858 ErrCode ret = mmiService.GetTouchpadTapSwitch(switchFlag); 2859 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 2860 } 2861 2862 /** 2863 * @tc.name: MMIService_GetTouchpadTapSwitch_002 2864 * @tc.desc: Verify GetTouchpadTapSwitch returns RET_OK or ETASKS_POST_SYNCTASK_FAIL under normal condition 2865 * @tc.type: FUNC 2866 * @tc.require: 2867 */ 2868 HWTEST_F(MMIServerTest, MMIService_GetTouchpadTapSwitch_002, TestSize.Level1) 2869 { 2870 CALL_TEST_DEBUG; 2871 MMIService mmiService; 2872 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 2873 bool switchFlag = false; 2874 ErrCode ret = mmiService.GetTouchpadTapSwitch(switchFlag); 2875 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL); 2876 } 2877 2878 /** 2879 * @tc.name: MMIService_SetTouchpadPointerSpeed_001 2880 * @tc.desc: Service not running, expect MMISERVICE_NOT_RUNNING 2881 * @tc.type: FUNC 2882 * @tc.require: 2883 */ 2884 HWTEST_F(MMIServerTest, MMIService_SetTouchpadPointerSpeed_001, TestSize.Level1) 2885 { 2886 CALL_TEST_DEBUG; 2887 MMIService mmiService; 2888 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 2889 int32_t speed = 3; 2890 ErrCode ret = mmiService.SetTouchpadPointerSpeed(speed); 2891 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 2892 } 2893 2894 /** 2895 * @tc.name: MMIService_SetTouchpadPointerSpeed_002 2896 * @tc.desc: Normal call with speed clipping, expect RET_OK or ETASKS_POST_SYNCTASK_FAIL 2897 * @tc.type: FUNC 2898 * @tc.require: 2899 */ 2900 HWTEST_F(MMIServerTest, MMIService_SetTouchpadPointerSpeed_002, TestSize.Level1) 2901 { 2902 CALL_TEST_DEBUG; 2903 MMIService mmiService; 2904 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 2905 std::vector<int32_t> testSpeeds = { -10, 0, 1, 3, 5, 10, 999 }; 2906 for (int32_t speed : testSpeeds) { 2907 ErrCode ret = mmiService.SetTouchpadPointerSpeed(speed); 2908 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL) << "Failed at speed=" << speed; 2909 } 2910 } 2911 2912 /** 2913 * @tc.name: MMIService_GetTouchpadPointerSpeed_001 2914 * @tc.desc: Service is not running, expect MMISERVICE_NOT_RUNNING 2915 * @tc.type: FUNC 2916 * @tc.require: 2917 */ 2918 HWTEST_F(MMIServerTest, MMIService_GetTouchpadPointerSpeed_001, TestSize.Level1) 2919 { 2920 CALL_TEST_DEBUG; 2921 MMIService mmiService; 2922 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 2923 int32_t speed = 0; 2924 ErrCode ret = mmiService.GetTouchpadPointerSpeed(speed); 2925 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 2926 } 2927 2928 /** 2929 * @tc.name: MMIService_GetTouchpadPointerSpeed_002 2930 * @tc.desc: Valid request, expect RET_OK or ETASKS_POST_SYNCTASK_FAIL 2931 * @tc.type: FUNC 2932 * @tc.require: 2933 */ 2934 HWTEST_F(MMIServerTest, MMIService_GetTouchpadPointerSpeed_002, TestSize.Level1) 2935 { 2936 CALL_TEST_DEBUG; 2937 MMIService mmiService; 2938 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 2939 int32_t speed = -1; 2940 ErrCode ret = mmiService.GetTouchpadPointerSpeed(speed); 2941 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL); 2942 } 2943 2944 /** 2945 * @tc.name: MMIService_SetTouchpadPinchSwitch_001 2946 * @tc.desc: Service not running, expect MMISERVICE_NOT_RUNNING 2947 * @tc.type: FUNC 2948 * @tc.require: 2949 */ 2950 HWTEST_F(MMIServerTest, MMIService_SetTouchpadPinchSwitch_001, TestSize.Level1) 2951 { 2952 CALL_TEST_DEBUG; 2953 MMIService mmiService; 2954 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 2955 ErrCode ret = mmiService.SetTouchpadPinchSwitch(true); 2956 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 2957 } 2958 2959 /** 2960 * @tc.name: MMIService_SetTouchpadPinchSwitch_002 2961 * @tc.desc: Valid call, expect RET_OK or ETASKS_POST_SYNCTASK_FAIL 2962 * @tc.type: FUNC 2963 * @tc.require: 2964 */ 2965 HWTEST_F(MMIServerTest, MMIService_SetTouchpadPinchSwitch_002, TestSize.Level1) 2966 { 2967 CALL_TEST_DEBUG; 2968 MMIService mmiService; 2969 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 2970 ErrCode ret = mmiService.SetTouchpadPinchSwitch(true); 2971 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL); 2972 } 2973 2974 /** 2975 * @tc.name: MMIService_GetTouchpadPinchSwitch_001 2976 * @tc.desc: Service not running, expect MMISERVICE_NOT_RUNNING 2977 * @tc.type: FUNC 2978 * @tc.require: 2979 */ 2980 HWTEST_F(MMIServerTest, MMIService_GetTouchpadPinchSwitch_001, TestSize.Level1) 2981 { 2982 CALL_TEST_DEBUG; 2983 MMIService mmiService; 2984 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 2985 bool switchFlag = false; 2986 ErrCode ret = mmiService.GetTouchpadPinchSwitch(switchFlag); 2987 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 2988 } 2989 2990 /** 2991 * @tc.name: MMIService_GetTouchpadPinchSwitch_002 2992 * @tc.desc: Valid call, expect RET_OK or ETASKS_POST_SYNCTASK_FAIL 2993 * @tc.type: FUNC 2994 * @tc.require: 2995 */ 2996 HWTEST_F(MMIServerTest, MMIService_GetTouchpadPinchSwitch_002, TestSize.Level1) 2997 { 2998 CALL_TEST_DEBUG; 2999 MMIService mmiService; 3000 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 3001 bool switchFlag = false; 3002 ErrCode ret = mmiService.GetTouchpadPinchSwitch(switchFlag); 3003 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL); 3004 } 3005 3006 /** 3007 * @tc.name: MMIService_SetTouchpadSwipeSwitch_001 3008 * @tc.desc: Service is not running, expect MMISERVICE_NOT_RUNNING 3009 * @tc.type: FUNC 3010 * @tc.require: 3011 */ 3012 HWTEST_F(MMIServerTest, MMIService_SetTouchpadSwipeSwitch_001, TestSize.Level1) 3013 { 3014 CALL_TEST_DEBUG; 3015 MMIService mmiService; 3016 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 3017 ErrCode ret = mmiService.SetTouchpadSwipeSwitch(true); 3018 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 3019 } 3020 3021 /** 3022 * @tc.name: MMIService_SetTouchpadSwipeSwitch_002 3023 * @tc.desc: Valid call with running service, expect RET_OK or ETASKS_POST_SYNCTASK_FAIL 3024 * @tc.type: FUNC 3025 * @tc.require: 3026 */ 3027 HWTEST_F(MMIServerTest, MMIService_SetTouchpadSwipeSwitch_002, TestSize.Level1) 3028 { 3029 CALL_TEST_DEBUG; 3030 MMIService mmiService; 3031 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 3032 ErrCode ret = mmiService.SetTouchpadSwipeSwitch(false); 3033 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL); 3034 } 3035 3036 /** 3037 * @tc.name: MMIService_GetTouchpadSwipeSwitch_001 3038 * @tc.desc: Service is not running, expect MMISERVICE_NOT_RUNNING 3039 * @tc.type: FUNC 3040 * @tc.require: 3041 */ 3042 HWTEST_F(MMIServerTest, MMIService_GetTouchpadSwipeSwitch_001, TestSize.Level1) 3043 { 3044 CALL_TEST_DEBUG; 3045 MMIService mmiService; 3046 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 3047 bool switchFlag = false; 3048 ErrCode ret = mmiService.GetTouchpadSwipeSwitch(switchFlag); 3049 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 3050 } 3051 3052 /** 3053 * @tc.name: MMIService_GetTouchpadSwipeSwitch_002 3054 * @tc.desc: Valid call with running service, expect RET_OK or ETASKS_POST_SYNCTASK_FAIL 3055 * @tc.type: FUNC 3056 * @tc.require: 3057 */ 3058 HWTEST_F(MMIServerTest, MMIService_GetTouchpadSwipeSwitch_002, TestSize.Level1) 3059 { 3060 CALL_TEST_DEBUG; 3061 MMIService mmiService; 3062 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 3063 bool switchFlag = false; 3064 ErrCode ret = mmiService.GetTouchpadSwipeSwitch(switchFlag); 3065 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL); 3066 } 3067 3068 /** 3069 * @tc.name: MMIService_IsValidType_001 3070 * @tc.desc: Valid type TOUCHPAD_RIGHT_BUTTON, expect true 3071 * @tc.type: FUNC 3072 * @tc.require: 3073 */ 3074 HWTEST_F(MMIServerTest, MMIService_IsValidType_001, TestSize.Level1) 3075 { 3076 CALL_TEST_DEBUG; 3077 MMIService mmiService; 3078 EXPECT_TRUE(mmiService.IsValidType(RightClickType::TOUCHPAD_RIGHT_BUTTON)); 3079 } 3080 3081 /** 3082 * @tc.name: MMIService_IsValidType_002 3083 * @tc.desc: Valid type TOUCHPAD_LEFT_BUTTON, expect true 3084 * @tc.type: FUNC 3085 * @tc.require: 3086 */ 3087 HWTEST_F(MMIServerTest, MMIService_IsValidType_002, TestSize.Level1) 3088 { 3089 CALL_TEST_DEBUG; 3090 MMIService mmiService; 3091 EXPECT_TRUE(mmiService.IsValidType(RightClickType::TOUCHPAD_LEFT_BUTTON)); 3092 } 3093 3094 /** 3095 * @tc.name: MMIService_IsValidType_003 3096 * @tc.desc: Valid type TOUCHPAD_TWO_FINGER_TAP, expect true 3097 * @tc.type: FUNC 3098 * @tc.require: 3099 */ 3100 HWTEST_F(MMIServerTest, MMIService_IsValidType_003, TestSize.Level1) 3101 { 3102 CALL_TEST_DEBUG; 3103 MMIService mmiService; 3104 EXPECT_TRUE(mmiService.IsValidType(RightClickType::TOUCHPAD_TWO_FINGER_TAP)); 3105 } 3106 3107 /** 3108 * @tc.name: MMIService_IsValidType_004 3109 * @tc.desc: Valid type TOUCHPAD_TWO_FINGER_TAP_OR_RIGHT_BUTTON, expect true 3110 * @tc.type: FUNC 3111 * @tc.require: 3112 */ 3113 HWTEST_F(MMIServerTest, MMIService_IsValidType_004, TestSize.Level1) 3114 { 3115 CALL_TEST_DEBUG; 3116 MMIService mmiService; 3117 EXPECT_TRUE(mmiService.IsValidType(RightClickType::TOUCHPAD_TWO_FINGER_TAP_OR_RIGHT_BUTTON)); 3118 } 3119 3120 /** 3121 * @tc.name: MMIService_IsValidType_005 3122 * @tc.desc: Valid type TOUCHPAD_TWO_FINGER_TAP_OR_LEFT_BUTTON, expect true 3123 * @tc.type: FUNC 3124 * @tc.require: 3125 */ 3126 HWTEST_F(MMIServerTest, MMIService_IsValidType_005, TestSize.Level1) 3127 { 3128 CALL_TEST_DEBUG; 3129 MMIService mmiService; 3130 EXPECT_TRUE(mmiService.IsValidType(RightClickType::TOUCHPAD_TWO_FINGER_TAP_OR_LEFT_BUTTON)); 3131 } 3132 3133 /** 3134 * @tc.name: MMIService_IsValidType_006 3135 * @tc.desc: Invalid type -1, expect false 3136 * @tc.type: FUNC 3137 * @tc.require: 3138 */ 3139 HWTEST_F(MMIServerTest, MMIService_IsValidType_006, TestSize.Level1) 3140 { 3141 CALL_TEST_DEBUG; 3142 MMIService mmiService; 3143 EXPECT_FALSE(mmiService.IsValidType(-1)); 3144 } 3145 3146 /** 3147 * @tc.name: MMIService_IsValidType_007 3148 * @tc.desc: Invalid type 1000, expect false 3149 * @tc.type: FUNC 3150 * @tc.require: 3151 */ 3152 HWTEST_F(MMIServerTest, MMIService_IsValidType_007, TestSize.Level1) 3153 { 3154 CALL_TEST_DEBUG; 3155 MMIService mmiService; 3156 EXPECT_FALSE(mmiService.IsValidType(1000)); 3157 } 3158 3159 /** 3160 * @tc.name: MMIService_SetTouchpadRightClickType_001 3161 * @tc.desc: Service not running, expect MMISERVICE_NOT_RUNNING 3162 * @tc.type: FUNC 3163 * @tc.require: 3164 */ 3165 HWTEST_F(MMIServerTest, MMIService_SetTouchpadRightClickType_001, TestSize.Level1) 3166 { 3167 CALL_TEST_DEBUG; 3168 MMIService mmiService; 3169 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 3170 int32_t type = RightClickType::TOUCHPAD_RIGHT_BUTTON; 3171 ErrCode ret = mmiService.SetTouchpadRightClickType(type); 3172 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 3173 } 3174 3175 /** 3176 * @tc.name: MMIService_SetTouchpadRightClickType_002 3177 * @tc.desc: Invalid right click type, expect RET_ERR 3178 * @tc.type: FUNC 3179 * @tc.require: 3180 */ 3181 HWTEST_F(MMIServerTest, MMIService_SetTouchpadRightClickType_002, TestSize.Level1) 3182 { 3183 CALL_TEST_DEBUG; 3184 MMIService mmiService; 3185 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 3186 int32_t type = -999; 3187 ErrCode ret = mmiService.SetTouchpadRightClickType(type); 3188 EXPECT_EQ(ret, RET_ERR); 3189 } 3190 3191 /** 3192 * @tc.name: MMIService_SetTouchpadRightClickType_003 3193 * @tc.desc: Valid call, expect RET_OK or ETASKS_POST_SYNCTASK_FAIL 3194 * @tc.type: FUNC 3195 * @tc.require: 3196 */ 3197 HWTEST_F(MMIServerTest, MMIService_SetTouchpadRightClickType_003, TestSize.Level1) 3198 { 3199 CALL_TEST_DEBUG; 3200 MMIService mmiService; 3201 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 3202 int32_t type = RightClickType::TOUCHPAD_RIGHT_BUTTON; 3203 ErrCode ret = mmiService.SetTouchpadRightClickType(type); 3204 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL); 3205 } 3206 3207 /** 3208 * @tc.name: MMIService_GetTouchpadRightClickType_001 3209 * @tc.desc: Service not running, expect MMISERVICE_NOT_RUNNING 3210 * @tc.type: FUNC 3211 * @tc.require: 3212 */ 3213 HWTEST_F(MMIServerTest, MMIService_GetTouchpadRightClickType_001, TestSize.Level1) 3214 { 3215 CALL_TEST_DEBUG; 3216 MMIService mmiService; 3217 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 3218 int32_t type = 0; 3219 ErrCode ret = mmiService.GetTouchpadRightClickType(type); 3220 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 3221 } 3222 3223 /** 3224 * @tc.name: MMIService_GetTouchpadRightClickType_002 3225 * @tc.desc: Valid case, expect RET_OK or ETASKS_POST_SYNCTASK_FAIL 3226 * @tc.type: FUNC 3227 * @tc.require: 3228 */ 3229 HWTEST_F(MMIServerTest, MMIService_GetTouchpadRightClickType_002, TestSize.Level1) 3230 { 3231 CALL_TEST_DEBUG; 3232 MMIService mmiService; 3233 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 3234 int32_t type = 0; 3235 ErrCode ret = mmiService.GetTouchpadRightClickType(type); 3236 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL); 3237 } 3238 3239 /** 3240 * @tc.name: MMIService_SetTouchpadRotateSwitch_001 3241 * @tc.desc: Service not running, expect MMISERVICE_NOT_RUNNING 3242 * @tc.type: FUNC 3243 * @tc.require: 3244 */ 3245 HWTEST_F(MMIServerTest, MMIService_SetTouchpadRotateSwitch_001, TestSize.Level1) 3246 { 3247 CALL_TEST_DEBUG; 3248 MMIService mmiService; 3249 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 3250 bool rotateSwitch = true; 3251 ErrCode ret = mmiService.SetTouchpadRotateSwitch(rotateSwitch); 3252 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 3253 } 3254 3255 /** 3256 * @tc.name: MMIService_SetTouchpadRotateSwitch_002 3257 * @tc.desc: Valid call, expect RET_OK or ETASKS_POST_SYNCTASK_FAIL 3258 * @tc.type: FUNC 3259 * @tc.require: 3260 */ 3261 HWTEST_F(MMIServerTest, MMIService_SetTouchpadRotateSwitch_002, TestSize.Level1) 3262 { 3263 CALL_TEST_DEBUG; 3264 MMIService mmiService; 3265 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 3266 bool rotateSwitch = true; 3267 ErrCode ret = mmiService.SetTouchpadRotateSwitch(rotateSwitch); 3268 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL); 3269 } 3270 3271 /** 3272 * @tc.name: MMIService_GetTouchpadRotateSwitch_001 3273 * @tc.desc: Service not running, expect MMISERVICE_NOT_RUNNING 3274 * @tc.type: FUNC 3275 * @tc.require: 3276 */ 3277 HWTEST_F(MMIServerTest, MMIService_GetTouchpadRotateSwitch_001, TestSize.Level1) 3278 { 3279 CALL_TEST_DEBUG; 3280 MMIService mmiService; 3281 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 3282 bool rotateSwitch = false; 3283 ErrCode ret = mmiService.GetTouchpadRotateSwitch(rotateSwitch); 3284 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 3285 } 3286 3287 /** 3288 * @tc.name: MMIService_GetTouchpadRotateSwitch_002 3289 * @tc.desc: Valid call, expect RET_OK or ETASKS_POST_SYNCTASK_FAIL 3290 * @tc.type: FUNC 3291 * @tc.require: 3292 */ 3293 HWTEST_F(MMIServerTest, MMIService_GetTouchpadRotateSwitch_002, TestSize.Level1) 3294 { 3295 CALL_TEST_DEBUG; 3296 MMIService mmiService; 3297 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 3298 bool rotateSwitch = false; 3299 ErrCode ret = mmiService.GetTouchpadRotateSwitch(rotateSwitch); 3300 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL); 3301 } 3302 3303 /** 3304 * @tc.name: MMIService_SetTouchpadDoubleTapAndDragState_001 3305 * @tc.desc: Service not running, expect MMISERVICE_NOT_RUNNING 3306 * @tc.type: FUNC 3307 * @tc.require: 3308 */ 3309 HWTEST_F(MMIServerTest, MMIService_SetTouchpadDoubleTapAndDragState_001, TestSize.Level1) 3310 { 3311 CALL_TEST_DEBUG; 3312 MMIService mmiService; 3313 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 3314 ErrCode ret = mmiService.SetTouchpadDoubleTapAndDragState(true); 3315 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 3316 } 3317 3318 /** 3319 * @tc.name: MMIService_SetTouchpadDoubleTapAndDragState_002 3320 * @tc.desc: Valid call, expect RET_OK or ETASKS_POST_SYNCTASK_FAIL 3321 * @tc.type: FUNC 3322 * @tc.require: 3323 */ 3324 HWTEST_F(MMIServerTest, MMIService_SetTouchpadDoubleTapAndDragState_002, TestSize.Level1) 3325 { 3326 CALL_TEST_DEBUG; 3327 MMIService mmiService; 3328 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 3329 ErrCode ret = mmiService.SetTouchpadDoubleTapAndDragState(true); 3330 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL); 3331 } 3332 3333 /** 3334 * @tc.name: MMIService_GetTouchpadDoubleTapAndDragState_001 3335 * @tc.desc: Service not running, expect MMISERVICE_NOT_RUNNING 3336 * @tc.type: FUNC 3337 * @tc.require: 3338 */ 3339 HWTEST_F(MMIServerTest, MMIService_GetTouchpadDoubleTapAndDragState_001, TestSize.Level1) 3340 { 3341 CALL_TEST_DEBUG; 3342 MMIService mmiService; 3343 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 3344 bool switchFlag = false; 3345 ErrCode ret = mmiService.GetTouchpadDoubleTapAndDragState(switchFlag); 3346 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 3347 } 3348 3349 /** 3350 * @tc.name: MMIService_GetTouchpadDoubleTapAndDragState_002 3351 * @tc.desc: Valid call, expect RET_OK or ETASKS_POST_SYNCTASK_FAIL 3352 * @tc.type: FUNC 3353 * @tc.require: 3354 */ 3355 HWTEST_F(MMIServerTest, MMIService_GetTouchpadDoubleTapAndDragState_002, TestSize.Level1) 3356 { 3357 CALL_TEST_DEBUG; 3358 MMIService mmiService; 3359 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 3360 bool switchFlag = false; 3361 ErrCode ret = mmiService.GetTouchpadDoubleTapAndDragState(switchFlag); 3362 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL); 3363 } 3364 3365 /** 3366 * @tc.name: MMIService_GetKeyState_001 3367 * @tc.desc: GetKeyState returns RET_OK or ETASKS_POST_SYNCTASK_FAIL 3368 * @tc.type: FUNC 3369 * @tc.require: 3370 */ 3371 HWTEST_F(MMIServerTest, MMIService_GetKeyState_001, TestSize.Level1) 3372 { 3373 CALL_TEST_DEBUG; 3374 MMIService mmiService; 3375 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 3376 3377 std::vector<int32_t> pressedKeys; 3378 std::unordered_map<int32_t, int32_t> specialKeysState; 3379 ErrCode ret = mmiService.GetKeyState(pressedKeys, specialKeysState); 3380 3381 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL); 3382 } 3383 3384 /** 3385 * @tc.name: MMIService_Authorize_001 3386 * @tc.desc: Service fails system app check, expect ERROR_NOT_SYSAPI 3387 * @tc.type: FUNC 3388 * @tc.require: 3389 */ 3390 HWTEST_F(MMIServerTest, MMIService_Authorize_001, TestSize.Level1) 3391 { 3392 CALL_TEST_DEBUG; 3393 MMIService mmiService; 3394 ErrCode ret = mmiService.Authorize(true); 3395 EXPECT_NE(ret, RET_OK); 3396 } 3397 3398 /** 3399 * @tc.name: MMIService_CancelInjection_001 3400 * @tc.desc: PostSyncTask fails, expect ETASKS_POST_SYNCTASK_FAIL 3401 * @tc.type: FUNC 3402 * @tc.require: 3403 */ 3404 HWTEST_F(MMIServerTest, MMIService_CancelInjection_001, TestSize.Level1) 3405 { 3406 CALL_TEST_DEBUG; 3407 MMIService mmiService; 3408 ErrCode ret = mmiService.CancelInjection(); 3409 EXPECT_EQ(ret, ETASKS_POST_SYNCTASK_FAIL); 3410 } 3411 3412 /** 3413 * @tc.name: MMIService_CancelInjection_002 3414 * @tc.desc: PostSyncTask success, expect RET_OK 3415 * @tc.type: FUNC 3416 * @tc.require: 3417 */ 3418 HWTEST_F(MMIServerTest, MMIService_CancelInjection_002, TestSize.Level1) 3419 { 3420 CALL_TEST_DEBUG; 3421 MMIService mmiService; 3422 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 3423 ErrCode ret = mmiService.CancelInjection(); 3424 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL); 3425 } 3426 3427 /** 3428 * @tc.name: MMIService_HasIrEmitter_001 3429 * @tc.desc: Verify system app failed, expect ERROR_NOT_SYSAPI 3430 * @tc.type: FUNC 3431 * @tc.require: 3432 */ 3433 HWTEST_F(MMIServerTest, MMIService_HasIrEmitter_001, TestSize.Level1) 3434 { 3435 CALL_TEST_DEBUG; 3436 MMIService mmiService; 3437 bool hasIrEmitter = false; 3438 ErrCode ret = mmiService.HasIrEmitter(hasIrEmitter); 3439 EXPECT_NE(ret, RET_OK); 3440 } 3441 3442 /** 3443 * @tc.name: MMIService_HasIrEmitter_002 3444 * @tc.desc: Verify valid path, expect RET_OK or ETASKS_POST_SYNCTASK_FAIL 3445 * @tc.type: FUNC 3446 * @tc.require: 3447 */ 3448 HWTEST_F(MMIServerTest, MMIService_HasIrEmitter_002, TestSize.Level1) 3449 { 3450 CALL_TEST_DEBUG; 3451 MMIService mmiService; 3452 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 3453 bool hasIrEmitter = false; 3454 ErrCode ret = mmiService.HasIrEmitter(hasIrEmitter); 3455 EXPECT_NE(ret, RET_OK); 3456 } 3457 3458 /** 3459 * @tc.name: MMIService_RequestInjection_001 3460 * @tc.desc: Verify sync task failure path, expect ETASKS_POST_SYNCTASK_FAIL 3461 * @tc.type: FUNC 3462 * @tc.require: 3463 */ 3464 HWTEST_F(MMIServerTest, MMIService_RequestInjection_001, TestSize.Level1) 3465 { 3466 CALL_TEST_DEBUG; 3467 MMIService mmiService; 3468 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 3469 int32_t status = -1; 3470 int32_t reqId = -1; 3471 ErrCode ret = mmiService.RequestInjection(status, reqId); 3472 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL); 3473 } 3474 3475 /** 3476 * @tc.name: MMIService_RequestInjection_002 3477 * @tc.desc: Validate output parameters are unchanged if task fails 3478 * @tc.type: FUNC 3479 * @tc.require: 3480 */ 3481 HWTEST_F(MMIServerTest, MMIService_RequestInjection_002, TestSize.Level1) 3482 { 3483 CALL_TEST_DEBUG; 3484 MMIService mmiService; 3485 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 3486 int32_t status = 100; 3487 int32_t reqId = 200; 3488 ErrCode ret = mmiService.RequestInjection(status, reqId); 3489 if (ret != RET_OK) { 3490 EXPECT_EQ(ret, ETASKS_POST_SYNCTASK_FAIL); 3491 EXPECT_EQ(status, 100); 3492 EXPECT_EQ(reqId, 200); 3493 } 3494 } 3495 3496 /** 3497 * @tc.name: MMIService_QueryAuthorizedStatus_001 3498 * @tc.desc: PostSyncTask fails, expect ETASKS_POST_SYNCTASK_FAIL 3499 * @tc.type: FUNC 3500 * @tc.require: 3501 */ 3502 HWTEST_F(MMIServerTest, MMIService_QueryAuthorizedStatus_001, TestSize.Level1) 3503 { 3504 CALL_TEST_DEBUG; 3505 MMIService mmiService; 3506 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 3507 int32_t status = -1; 3508 ErrCode ret = mmiService.QueryAuthorizedStatus(status); 3509 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL); 3510 } 3511 3512 /** 3513 * @tc.name: MMIService_QueryAuthorizedStatus_002 3514 * @tc.desc: Validate status unchanged on failure 3515 * @tc.type: FUNC 3516 * @tc.require: 3517 */ 3518 HWTEST_F(MMIServerTest, MMIService_QueryAuthorizedStatus_002, TestSize.Level1) 3519 { 3520 CALL_TEST_DEBUG; 3521 MMIService mmiService; 3522 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 3523 int32_t status = 1234; 3524 ErrCode ret = mmiService.QueryAuthorizedStatus(status); 3525 if (ret != RET_OK) { 3526 EXPECT_EQ(ret, ETASKS_POST_SYNCTASK_FAIL); 3527 EXPECT_EQ(status, 1234); 3528 } 3529 } 3530 3531 /** 3532 * @tc.name: MMIService_GetInfraredFrequencies_001 3533 * @tc.desc: CheckInfraredEmmit permission denied, expect ERROR_NO_PERMISSION 3534 * @tc.type: FUNC 3535 * @tc.require: 3536 */ 3537 HWTEST_F(MMIServerTest, MMIService_GetInfraredFrequencies_001, TestSize.Level1) 3538 { 3539 CALL_TEST_DEBUG; 3540 MMIService mmiService; 3541 std::vector<InfraredFrequency> frequencies; 3542 ErrCode ret = mmiService.GetInfraredFrequencies(frequencies); 3543 EXPECT_FALSE(ret == ERROR_NO_PERMISSION || ret == RET_OK); 3544 if (ret == RET_OK) { 3545 #ifndef OHOS_BUILD_ENABLE_WATCH 3546 EXPECT_GE(frequencies.size(), 0); 3547 #endif 3548 } else { 3549 EXPECT_EQ(frequencies.size(), 0); 3550 } 3551 } 3552 3553 /** 3554 * @tc.name: MMIService_GetInfraredFrequencies_002 3555 * @tc.desc: Normal case, verify return value and content 3556 * @tc.type: FUNC 3557 * @tc.require: 3558 */ 3559 HWTEST_F(MMIServerTest, MMIService_GetInfraredFrequencies_002, TestSize.Level1) 3560 { 3561 CALL_TEST_DEBUG; 3562 MMIService mmiService; 3563 std::vector<InfraredFrequency> frequencies; 3564 ErrCode ret = mmiService.GetInfraredFrequencies(frequencies); 3565 EXPECT_NE(ret, RET_OK); 3566 #ifndef OHOS_BUILD_ENABLE_WATCH 3567 for (auto &freq : frequencies) { 3568 EXPECT_GE(freq.min_, 0); 3569 EXPECT_GE(freq.max_, freq.min_); 3570 } 3571 #endif 3572 } 3573 3574 /** 3575 * @tc.name: MMIService_TransmitInfrared_001 3576 * @tc.desc: Permission check fails, expect ERROR_NO_PERMISSION 3577 * @tc.type: FUNC 3578 * @tc.require: 3579 */ 3580 HWTEST_F(MMIServerTest, MMIService_TransmitInfrared_001, TestSize.Level1) 3581 { 3582 CALL_TEST_DEBUG; 3583 MMIService mmiService; 3584 std::vector<int64_t> pattern = {1000, 1000}; 3585 ErrCode ret = mmiService.TransmitInfrared(38000, pattern); 3586 EXPECT_FALSE(ret == ERROR_NO_PERMISSION || ret == RET_OK); 3587 } 3588 3589 /** 3590 * @tc.name: MMIService_TransmitInfrared_002 3591 * @tc.desc: Invalid pattern length (0), expect RET_ERR 3592 * @tc.type: FUNC 3593 * @tc.require: 3594 */ 3595 HWTEST_F(MMIServerTest, MMIService_TransmitInfrared_002, TestSize.Level1) 3596 { 3597 CALL_TEST_DEBUG; 3598 MMIService mmiService; 3599 std::vector<int64_t> pattern; 3600 ErrCode ret = mmiService.TransmitInfrared(38000, pattern); 3601 EXPECT_EQ(ret, RET_ERR); 3602 } 3603 3604 /** 3605 * @tc.name: MMIService_TransmitInfrared_003 3606 * @tc.desc: Invalid pattern length (超限), expect RET_ERR 3607 * @tc.type: FUNC 3608 * @tc.require: 3609 */ 3610 HWTEST_F(MMIServerTest, MMIService_TransmitInfrared_003, TestSize.Level1) 3611 { 3612 CALL_TEST_DEBUG; 3613 MMIService mmiService; 3614 std::vector<int64_t> pattern(1024 + 1, 1000); 3615 ErrCode ret = mmiService.TransmitInfrared(38000, pattern); 3616 EXPECT_EQ(ret, RET_ERR); 3617 } 3618 3619 /** 3620 * @tc.name: MMIService_TransmitInfrared_004 3621 * @tc.desc: Invalid number (负值), expect RET_ERR 3622 * @tc.type: FUNC 3623 * @tc.require: 3624 */ 3625 HWTEST_F(MMIServerTest, MMIService_TransmitInfrared_004, TestSize.Level1) 3626 { 3627 CALL_TEST_DEBUG; 3628 MMIService mmiService; 3629 std::vector<int64_t> pattern = {1000, 1000}; 3630 ErrCode ret = mmiService.TransmitInfrared(-1, pattern); 3631 EXPECT_EQ(ret, RET_ERR); 3632 } 3633 3634 /** 3635 * @tc.name: MMIService_TransmitInfrared_005 3636 * @tc.desc: Valid parameters, expect RET_OK or RET_ERR depending on hardware 3637 * @tc.type: FUNC 3638 * @tc.require: 3639 */ 3640 HWTEST_F(MMIServerTest, MMIService_TransmitInfrared_005, TestSize.Level1) 3641 { 3642 CALL_TEST_DEBUG; 3643 MMIService mmiService; 3644 std::vector<int64_t> pattern = {1000, 2000, 1000, 2000}; 3645 ErrCode ret = mmiService.TransmitInfrared(38000, pattern); 3646 EXPECT_TRUE(ret == RET_OK || ret == RET_ERR); 3647 } 3648 3649 /** 3650 * @tc.name: MMIService_OnHasIrEmitter_001 3651 * @tc.desc: The service normally calls OnHasIrEmitter, expecting it to return false and succeed 3652 * @tc.type: FUNC 3653 * @tc.require: 3654 */ 3655 HWTEST_F(MMIServerTest, MMIService_OnHasIrEmitter_001, TestSize.Level1) 3656 { 3657 CALL_TEST_DEBUG; 3658 MMIService mmiService; 3659 bool hasIrEmitter = true; 3660 int32_t ret = mmiService.OnHasIrEmitter(hasIrEmitter); 3661 EXPECT_EQ(ret, RET_OK); 3662 EXPECT_FALSE(hasIrEmitter); 3663 } 3664 3665 /** 3666 * @tc.name: MMIService_SetPixelMapData_001 3667 * @tc.desc: Non-system applications calling SetPixelMapData are expected to return ERROR_NOT_SYSAPI 3668 * @tc.type: FUNC 3669 * @tc.require: 3670 */ 3671 HWTEST_F(MMIServerTest, MMIService_SetPixelMapData_001, TestSize.Level1) 3672 { 3673 CALL_TEST_DEBUG; 3674 MMIService mmiService; 3675 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 3676 CursorPixelMap pixelMap; 3677 pixelMap.pixelMap = reinterpret_cast<void*>(0x1); 3678 ErrCode ret = mmiService.SetPixelMapData(1, pixelMap); 3679 EXPECT_NE(ret, RET_OK); 3680 } 3681 3682 /** 3683 * @tc.name: MMIService_SetPixelMapData_002 3684 * @tc.desc: The service is not running; SetPixelMapData returned MMISERVICE_NOT_RUNNING 3685 * @tc.type: FUNC 3686 * @tc.require: 3687 */ 3688 HWTEST_F(MMIServerTest, MMIService_SetPixelMapData_002, TestSize.Level1) 3689 { 3690 CALL_TEST_DEBUG; 3691 MMIService mmiService; 3692 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 3693 CursorPixelMap pixelMap; 3694 pixelMap.pixelMap = reinterpret_cast<void*>(0x1); 3695 ErrCode ret = mmiService.SetPixelMapData(1, pixelMap); 3696 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 3697 } 3698 3699 /** 3700 * @tc.name: MMIService_SetPixelMapData_003 3701 * @tc.desc: The parameter infoId is invalid (<=0), expecting to return RET_ERR 3702 * @tc.type: FUNC 3703 * @tc.require: 3704 */ 3705 HWTEST_F(MMIServerTest, MMIService_SetPixelMapData_003, TestSize.Level1) 3706 { 3707 CALL_TEST_DEBUG; 3708 MMIService mmiService; 3709 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 3710 CursorPixelMap pixelMap; 3711 pixelMap.pixelMap = reinterpret_cast<void*>(0x1); 3712 ErrCode ret = mmiService.SetPixelMapData(0, pixelMap); 3713 EXPECT_EQ(ret, RET_ERR); 3714 } 3715 3716 /** 3717 * @tc.name: MMIService_SetPixelMapData_004 3718 * @tc.desc: PixelMap is nullptr, expecting to return ERROR_NULL_POINTER 3719 * @tc.type: FUNC 3720 * @tc.require: 3721 */ 3722 HWTEST_F(MMIServerTest, MMIService_SetPixelMapData_004, TestSize.Level1) 3723 { 3724 CALL_TEST_DEBUG; 3725 MMIService mmiService; 3726 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 3727 CursorPixelMap pixelMap; 3728 pixelMap.pixelMap = nullptr; 3729 ErrCode ret = mmiService.SetPixelMapData(1, pixelMap); 3730 EXPECT_EQ(ret, ERROR_NULL_POINTER); 3731 } 3732 3733 /** 3734 * @tc.name: MMIService_SetPixelMapData_005 3735 * @tc.desc: PixelMap setup successful or task dispatch failed 3736 * @tc.type: FUNC 3737 * @tc.require: 3738 */ 3739 HWTEST_F(MMIServerTest, MMIService_SetPixelMapData_005, TestSize.Level1) 3740 { 3741 CALL_TEST_DEBUG; 3742 MMIService mmiService; 3743 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 3744 CursorPixelMap pixelMap; 3745 pixelMap.pixelMap = reinterpret_cast<void*>(0x1); 3746 ErrCode ret = mmiService.SetPixelMapData(1, pixelMap); 3747 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL); 3748 } 3749 3750 /** 3751 * @tc.name: MMIService_SetCurrentUser_001 3752 * @tc.desc: Verify return MMISERVICE_NOT_RUNNING when service not started 3753 * @tc.type: FUNC 3754 * @tc.require: 3755 */ 3756 HWTEST_F(MMIServerTest, MMIService_SetCurrentUser_001, TestSize.Level1) 3757 { 3758 CALL_TEST_DEBUG; 3759 MMIService mmiService; 3760 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 3761 int32_t userId = 100; 3762 ErrCode ret = mmiService.SetCurrentUser(userId); 3763 EXPECT_NE(ret, RET_OK); 3764 } 3765 3766 /** 3767 * @tc.name: MMIService_SetCurrentUser_002 3768 * @tc.desc: Verify normal call, expect RET_OK or RET_ERR based on runtime environment 3769 * @tc.type: FUNC 3770 * @tc.require: 3771 */ 3772 HWTEST_F(MMIServerTest, MMIService_SetCurrentUser_002, TestSize.Level1) 3773 { 3774 CALL_TEST_DEBUG; 3775 MMIService mmiService; 3776 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 3777 int32_t userId = 1; 3778 ErrCode ret = mmiService.SetCurrentUser(userId); 3779 EXPECT_TRUE(ret == RET_OK || ret == RET_ERR); 3780 } 3781 3782 /** 3783 * @tc.name: MMIService_SetTouchpadThreeFingersTapSwitch_001 3784 * @tc.desc: Verify return ERROR_NOT_SYSAPI when permission check fails 3785 * @tc.type: FUNC 3786 * @tc.require: 3787 */ 3788 HWTEST_F(MMIServerTest, MMIService_SetTouchpadThreeFingersTapSwitch_001, TestSize.Level1) 3789 { 3790 CALL_TEST_DEBUG; 3791 MMIService mmiService; 3792 bool switchFlag = true; 3793 ErrCode ret = mmiService.SetTouchpadThreeFingersTapSwitch(switchFlag); 3794 EXPECT_NE(ret, RET_OK); 3795 } 3796 3797 /** 3798 * @tc.name: MMIService_SetTouchpadThreeFingersTapSwitch_002 3799 * @tc.desc: Verify return RET_OK or ETASKS_POST_SYNCTASK_FAIL if permission granted and task posted 3800 * @tc.type: FUNC 3801 * @tc.require: 3802 */ 3803 HWTEST_F(MMIServerTest, MMIService_SetTouchpadThreeFingersTapSwitch_002, TestSize.Level1) 3804 { 3805 CALL_TEST_DEBUG; 3806 MMIService mmiService; 3807 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 3808 bool switchFlag = false; 3809 ErrCode ret = mmiService.SetTouchpadThreeFingersTapSwitch(switchFlag); 3810 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL || ret == ERROR_NOT_SYSAPI); 3811 } 3812 3813 /** 3814 * @tc.name: MMIService_GetTouchpadThreeFingersTapSwitch_001 3815 * @tc.desc: Verify return ERROR_NOT_SYSAPI when not a system app 3816 * @tc.type: FUNC 3817 * @tc.require: 3818 */ 3819 HWTEST_F(MMIServerTest, MMIService_GetTouchpadThreeFingersTapSwitch_001, TestSize.Level1) 3820 { 3821 CALL_TEST_DEBUG; 3822 MMIService mmiService; 3823 bool switchFlag = false; 3824 ErrCode ret = mmiService.GetTouchpadThreeFingersTapSwitch(switchFlag); 3825 EXPECT_NE(ret, RET_OK); 3826 } 3827 3828 /** 3829 * @tc.name: MMIService_GetTouchpadThreeFingersTapSwitch_002 3830 * @tc.desc: Verify return RET_OK or ETASKS_POST_SYNCTASK_FAIL when called as system app 3831 * @tc.type: FUNC 3832 * @tc.require: 3833 */ 3834 HWTEST_F(MMIServerTest, MMIService_GetTouchpadThreeFingersTapSwitch_002, TestSize.Level1) 3835 { 3836 CALL_TEST_DEBUG; 3837 MMIService mmiService; 3838 bool switchFlag = false; 3839 ErrCode ret = mmiService.GetTouchpadThreeFingersTapSwitch(switchFlag); 3840 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL || ret == ERROR_NOT_SYSAPI); 3841 } 3842 3843 /** 3844 * @tc.name: MMIService_AddVirtualInputDevice_001 3845 * @tc.desc: Not system app, expect ERROR_NOT_SYSAPI 3846 * @tc.type: FUNC 3847 * @tc.require: 3848 */ 3849 HWTEST_F(MMIServerTest, MMIService_AddVirtualInputDevice_001, TestSize.Level1) 3850 { 3851 CALL_TEST_DEBUG; 3852 MMIService mmiService; 3853 InputDevice device {}; 3854 int32_t deviceId = -1; 3855 ErrCode ret = mmiService.AddVirtualInputDevice(device, deviceId); 3856 EXPECT_NE(ret, RET_OK); 3857 } 3858 3859 /** 3860 * @tc.name: MMIService_AddVirtualInputDevice_002 3861 * @tc.desc: Normal case, expect RET_OK or ETASKS_POST_SYNCTASK_FAIL 3862 * @tc.type: FUNC 3863 * @tc.require: 3864 */ 3865 HWTEST_F(MMIServerTest, MMIService_AddVirtualInputDevice_002, TestSize.Level1) 3866 { 3867 CALL_TEST_DEBUG; 3868 MMIService mmiService; 3869 InputDevice device {}; 3870 int32_t deviceId = -1; 3871 ErrCode ret = mmiService.AddVirtualInputDevice(device, deviceId); 3872 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL || ret == ERROR_NOT_SYSAPI); 3873 } 3874 3875 /** 3876 * @tc.name: MMIService_RemoveVirtualInputDevice_001 3877 * @tc.desc: Not system app, expect ERROR_NOT_SYSAPI 3878 * @tc.type: FUNC 3879 * @tc.require: 3880 */ 3881 HWTEST_F(MMIServerTest, MMIService_RemoveVirtualInputDevice_001, TestSize.Level1) 3882 { 3883 CALL_TEST_DEBUG; 3884 MMIService mmiService; 3885 int32_t deviceId = 100; 3886 ErrCode ret = mmiService.RemoveVirtualInputDevice(deviceId); 3887 EXPECT_NE(ret, RET_OK); 3888 } 3889 3890 /** 3891 * @tc.name: MMIService_RemoveVirtualInputDevice_002 3892 * @tc.desc: Invalid deviceId, expect RET_ERR 3893 * @tc.type: FUNC 3894 * @tc.require: 3895 */ 3896 HWTEST_F(MMIServerTest, MMIService_RemoveVirtualInputDevice_002, TestSize.Level1) 3897 { 3898 CALL_TEST_DEBUG; 3899 MMIService mmiService; 3900 int32_t deviceId = -1; 3901 ErrCode ret = mmiService.RemoveVirtualInputDevice(deviceId); 3902 EXPECT_EQ(ret, RET_ERR); 3903 } 3904 3905 /** 3906 * @tc.name: MMIService_RemoveVirtualInputDevice_003 3907 * @tc.desc: Normal case, expect RET_OK or ETASKS_POST_SYNCTASK_FAIL or ERROR_NOT_SYSAPI 3908 * @tc.type: FUNC 3909 * @tc.require: 3910 */ 3911 HWTEST_F(MMIServerTest, MMIService_RemoveVirtualInputDevice_003, TestSize.Level1) 3912 { 3913 CALL_TEST_DEBUG; 3914 MMIService mmiService; 3915 int32_t deviceId = 123; 3916 ErrCode ret = mmiService.RemoveVirtualInputDevice(deviceId); 3917 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL || ret == ERROR_NOT_SYSAPI); 3918 } 3919 3920 /** 3921 * @tc.name: MMIService_EnableHardwareCursorStats_001 3922 * @tc.desc: Normal enable case, expect RET_OK or ETASKS_POST_SYNCTASK_FAIL 3923 * @tc.type: FUNC 3924 * @tc.require: 3925 */ 3926 HWTEST_F(MMIServerTest, MMIService_EnableHardwareCursorStats_001, TestSize.Level1) 3927 { 3928 CALL_TEST_DEBUG; 3929 MMIService mmiService; 3930 bool enable = true; 3931 ErrCode ret = mmiService.EnableHardwareCursorStats(enable); 3932 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL); 3933 } 3934 3935 /** 3936 * @tc.name: MMIService_EnableHardwareCursorStats_002 3937 * @tc.desc: Disable hardware cursor stats, expect RET_OK or ETASKS_POST_SYNCTASK_FAIL 3938 * @tc.type: FUNC 3939 * @tc.require: 3940 */ 3941 HWTEST_F(MMIServerTest, MMIService_EnableHardwareCursorStats_002, TestSize.Level1) 3942 { 3943 CALL_TEST_DEBUG; 3944 MMIService mmiService; 3945 bool enable = false; 3946 ErrCode ret = mmiService.EnableHardwareCursorStats(enable); 3947 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL); 3948 } 3949 3950 /** 3951 * @tc.name: MMIService_GetHardwareCursorStats_001 3952 * @tc.desc: Normal case, expect RET_OK or ETASKS_POST_SYNCTASK_FAIL 3953 * @tc.type: FUNC 3954 * @tc.require: 3955 */ 3956 HWTEST_F(MMIServerTest, MMIService_GetHardwareCursorStats_001, TestSize.Level1) 3957 { 3958 CALL_TEST_DEBUG; 3959 MMIService mmiService; 3960 uint32_t frameCount = 0; 3961 uint32_t vsyncCount = 0; 3962 ErrCode ret = mmiService.GetHardwareCursorStats(frameCount, vsyncCount); 3963 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL); 3964 } 3965 3966 /** 3967 * @tc.name: MMIService_SetTouchpadScrollRows_001 3968 * @tc.desc: Service not running, expect MMISERVICE_NOT_RUNNING 3969 * @tc.type: FUNC 3970 * @tc.require: 3971 */ 3972 HWTEST_F(MMIServerTest, MMIService_SetTouchpadScrollRows_001, TestSize.Level1) 3973 { 3974 CALL_TEST_DEBUG; 3975 MMIService mmiService; 3976 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 3977 int32_t rows = 3; 3978 ErrCode ret = mmiService.SetTouchpadScrollRows(rows); 3979 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 3980 } 3981 3982 /** 3983 * @tc.name: MMIService_SetTouchpadScrollRows_002 3984 * @tc.desc: Valid input within range, expect RET_OK or PostSyncTask fail 3985 * @tc.type: FUNC 3986 * @tc.require: 3987 */ 3988 HWTEST_F(MMIServerTest, MMIService_SetTouchpadScrollRows_002, TestSize.Level1) 3989 { 3990 CALL_TEST_DEBUG; 3991 MMIService mmiService; 3992 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 3993 int32_t rows = 3; 3994 ErrCode ret = mmiService.SetTouchpadScrollRows(rows); 3995 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL || ret == ERROR_NOT_SYSAPI); 3996 } 3997 3998 /** 3999 * @tc.name: MMIService_SetTouchpadScrollRows_003 4000 * @tc.desc: Input less than MIN_ROWS, should be clamped, expect RET_OK or fail 4001 * @tc.type: FUNC 4002 * @tc.require: 4003 */ 4004 HWTEST_F(MMIServerTest, MMIService_SetTouchpadScrollRows_003, TestSize.Level1) 4005 { 4006 CALL_TEST_DEBUG; 4007 MMIService mmiService; 4008 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 4009 int32_t rows = -100; // invalid, expect clamped to MIN_ROWS 4010 ErrCode ret = mmiService.SetTouchpadScrollRows(rows); 4011 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL || ret == ERROR_NOT_SYSAPI); 4012 } 4013 4014 /** 4015 * @tc.name: MMIService_SetTouchpadScrollRows_004 4016 * @tc.desc: Input greater than MAX_ROWS, should be clamped, expect RET_OK or fail 4017 * @tc.type: FUNC 4018 * @tc.require: 4019 */ 4020 HWTEST_F(MMIServerTest, MMIService_SetTouchpadScrollRows_004, TestSize.Level1) 4021 { 4022 CALL_TEST_DEBUG; 4023 MMIService mmiService; 4024 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 4025 int32_t rows = 9999; 4026 ErrCode ret = mmiService.SetTouchpadScrollRows(rows); 4027 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL || ret == ERROR_NOT_SYSAPI); 4028 } 4029 4030 /** 4031 * @tc.name: MMIService_GetTouchpadScrollRows_001 4032 * @tc.desc: Service not running, expect MMISERVICE_NOT_RUNNING 4033 * @tc.type: FUNC 4034 * @tc.require: 4035 */ 4036 HWTEST_F(MMIServerTest, MMIService_GetTouchpadScrollRows_001, TestSize.Level1) 4037 { 4038 CALL_TEST_DEBUG; 4039 MMIService mmiService; 4040 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 4041 int32_t rows = 0; 4042 ErrCode ret = mmiService.GetTouchpadScrollRows(rows); 4043 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 4044 } 4045 4046 /** 4047 * @tc.name: MMIService_GetTouchpadScrollRows_002 4048 * @tc.desc: Service running, expect RET_OK or PostSyncTask failure 4049 * @tc.type: FUNC 4050 * @tc.require: 4051 */ 4052 HWTEST_F(MMIServerTest, MMIService_GetTouchpadScrollRows_002, TestSize.Level1) 4053 { 4054 CALL_TEST_DEBUG; 4055 MMIService mmiService; 4056 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 4057 int32_t rows = 0; 4058 ErrCode ret = mmiService.GetTouchpadScrollRows(rows); 4059 EXPECT_TRUE(ret == RET_OK || ret == ETASKS_POST_SYNCTASK_FAIL || ret == ERROR_NOT_SYSAPI); 4060 } 4061 4062 /** 4063 * @tc.name: MMIService_GetTouchpadScrollRows_003 4064 * @tc.desc: Get rows and verify it's within expected range if success 4065 * @tc.type: FUNC 4066 * @tc.require: 4067 */ 4068 HWTEST_F(MMIServerTest, MMIService_GetTouchpadScrollRows_003, TestSize.Level1) 4069 { 4070 CALL_TEST_DEBUG; 4071 MMIService mmiService; 4072 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 4073 int32_t rows = -1; 4074 ErrCode ret = mmiService.GetTouchpadScrollRows(rows); 4075 if (ret == RET_OK) { 4076 EXPECT_GE(rows, 1); 4077 EXPECT_LE(rows, 100); 4078 } else { 4079 EXPECT_TRUE(ret == ETASKS_POST_SYNCTASK_FAIL || ret == ERROR_NOT_SYSAPI); 4080 } 4081 } 4082 4083 #ifdef OHOS_BUILD_ENABLE_ANCO 4084 /** 4085 * @tc.name: MMIService_AncoAddChannel_001 4086 * @tc.desc: Verify system app failed, expect ERROR_NOT_SYSAPI 4087 * @tc.type: FUNC 4088 * @tc.require: 4089 */ 4090 HWTEST_F(MMIServerTest, MMIService_AncoAddChannel_001, TestSize.Level1) 4091 { 4092 CALL_TEST_DEBUG; 4093 MMIService mmiService; 4094 sptr<IAncoChannel> channel = nullptr; 4095 ErrCode ret = mmiService.AncoAddChannel(channel); 4096 EXPECT_NE(ret, RET_OK); 4097 } 4098 #endif 4099 4100 /** 4101 * @tc.name: MMIService_TransferBinderClientSrv_001 4102 * @tc.desc: Transfer binder client with nullptr, expect RET_ERR or PostSyncTask error 4103 * @tc.type: FUNC 4104 * @tc.require: 4105 */ 4106 HWTEST_F(MMIServerTest, MMIService_TransferBinderClientSrv_001, TestSize.Level1) 4107 { 4108 CALL_TEST_DEBUG; 4109 MMIService mmiService; 4110 sptr<IRemoteObject> remoteObj = nullptr; 4111 ErrCode ret = mmiService.TransferBinderClientSrv(remoteObj); 4112 EXPECT_TRUE(ret == RET_OK || ret == RET_ERR || ret == ETASKS_POST_SYNCTASK_FAIL); 4113 } 4114 4115 /** 4116 * @tc.name: MMIService_CalculateFuntionRunningTime_001 4117 * @tc.desc: Verify the normal execution path of CalculateFunctionRunningTime 4118 * @tc.type: FUNC 4119 * @tc.require: 4120 */ 4121 HWTEST_F(MMIServerTest, MMIService_CalculateFuntionRunningTime_001, TestSize.Level1) 4122 { 4123 CALL_TEST_DEBUG; 4124 MMIService mmiService; 4125 std::string flag = "TestCalcFuncTime"; 4126 bool executed = false; __anon587fc7840202() 4127 auto testFunc = [&executed]() { 4128 usleep(50000); 4129 executed = true; 4130 }; 4131 mmiService.CalculateFuntionRunningTime(testFunc, flag); 4132 EXPECT_TRUE(executed); 4133 } 4134 4135 /** 4136 * @tc.name: MMIService_PrintLog_001 4137 * @tc.desc: Verify whether the PrintLog function can execute properly and call the DumpCatch interface 4138 * @tc.type: FUNC 4139 * @tc.require: 4140 */ 4141 HWTEST_F(MMIServerTest, MMIService_PrintLog_001, TestSize.Level1) 4142 { 4143 CALL_TEST_DEBUG; 4144 MMIService mmiService; 4145 std::string flag = "PrintLogTest"; 4146 int32_t duration = 5; 4147 int32_t pid = getpid(); 4148 int32_t tid = gettid(); 4149 ASSERT_NO_FATAL_FAILURE(mmiService.PrintLog(flag, duration, pid, tid)); 4150 } 4151 4152 /** 4153 * @tc.name: MMIService_SkipPointerLayer_001 4154 * @tc.desc: Permission verification failed, returning ERROR_NOT_SYSAPI 4155 * @tc.type: FUNC 4156 * @tc.require: 4157 */ 4158 HWTEST_F(MMIServerTest, MMIService_SkipPointerLayer_001, TestSize.Level1) 4159 { 4160 CALL_TEST_DEBUG; 4161 MMIService mmiService; 4162 ErrCode ret = mmiService.SkipPointerLayer(true); 4163 EXPECT_NE(ret, RET_OK); 4164 } 4165 4166 /** 4167 * @tc.name: MMIService_OnSessionDelete_001 4168 * @tc.desc: No action will be taken when the session is empty 4169 * @tc.type: FUNC 4170 * @tc.require: 4171 */ 4172 HWTEST_F(MMIServerTest, MMIService_OnSessionDelete_001, TestSize.Level1) 4173 { 4174 CALL_TEST_DEBUG; 4175 MMIService mmiService; 4176 SessionPtr session = nullptr; 4177 ASSERT_NO_FATAL_FAILURE(mmiService.OnSessionDelete(session)); 4178 } 4179 4180 /** 4181 * @tc.name: MMIService_SetClientInfo_001 4182 * @tc.desc: Error returned when service is not running 4183 * @tc.type: FUNC 4184 * @tc.require: 4185 */ 4186 HWTEST_F(MMIServerTest, MMIService_SetClientInfo_001, TestSize.Level1) 4187 { 4188 CALL_TEST_DEBUG; 4189 MMIService mmiService; 4190 int32_t pid = 12345; 4191 uint64_t readThreadId = 100; 4192 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 4193 ErrCode ret = mmiService.SetClientInfo(pid, readThreadId); 4194 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 4195 } 4196 4197 /** 4198 * @tc.name: MMIService_SetClientInfo_002 4199 * @tc.desc: readThreadId is invalid, returning an error 4200 * @tc.type: FUNC 4201 * @tc.require: 4202 */ 4203 HWTEST_F(MMIServerTest, MMIService_SetClientInfo_002, TestSize.Level1) 4204 { 4205 CALL_TEST_DEBUG; 4206 MMIService mmiService; 4207 int32_t pid = 12345; 4208 uint64_t readThreadId = static_cast<uint64_t>(-1); 4209 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 4210 ErrCode ret = mmiService.SetClientInfo(pid, readThreadId); 4211 EXPECT_NE(ret, RET_OK); 4212 } 4213 4214 /** 4215 * @tc.name: MMIService_InitPrintClientInfo_001 4216 * @tc.desc: Verify whether InitPrintClientInfo successfully sets the timer and callback 4217 * @tc.type: FUNC 4218 * @tc.require: 4219 */ 4220 HWTEST_F(MMIServerTest, MMIService_InitPrintClientInfo_001, TestSize.Level1) 4221 { 4222 CALL_TEST_DEBUG; 4223 MMIService mmiService; 4224 { 4225 std::lock_guard<std::mutex> lock(mmiService.mutex_); 4226 mmiService.clientInfos_["com.test.same"] = { 4227 .pid = 1234, 4228 .readThreadId = 1234 4229 }; 4230 mmiService.clientInfos_["com.test.diff"] = { 4231 .pid = 5678, 4232 .readThreadId = 8765 4233 }; 4234 } 4235 ASSERT_NO_FATAL_FAILURE(mmiService.InitPrintClientInfo()); 4236 } 4237 4238 /** 4239 * @tc.name: MMIService_GetIntervalSinceLastInput_001 4240 * @tc.desc: Verify that the input interval time returned under normal conditions is greater than or equal to 0 4241 * @tc.type: FUNC 4242 * @tc.require: 4243 */ 4244 HWTEST_F(MMIServerTest, MMIService_GetIntervalSinceLastInput_001, TestSize.Level1) 4245 { 4246 CALL_TEST_DEBUG; 4247 MMIService mmiService; 4248 int64_t timeInterval = -1; 4249 ErrCode ret = mmiService.GetIntervalSinceLastInput(timeInterval); 4250 EXPECT_NE(ret, RET_OK); 4251 EXPECT_GE(timeInterval, 0); 4252 } 4253 4254 /** 4255 * @tc.name: MMIService_GetAllSystemHotkeys_001 4256 * @tc.desc: The verification call was successful 4257 * @tc.type: FUNC 4258 * @tc.require: 4259 */ 4260 HWTEST_F(MMIServerTest, MMIService_GetAllSystemHotkeys_001, TestSize.Level1) 4261 { 4262 CALL_TEST_DEBUG; 4263 MMIService mmiService; 4264 std::vector<KeyOption> keyOptions; 4265 ErrCode ret = mmiService.GetAllSystemHotkeys(keyOptions); 4266 EXPECT_NE(ret, RET_OK); 4267 for (const auto& keyOpt : keyOptions) { 4268 EXPECT_GE(keyOpt.GetFinalKey(), 0); 4269 EXPECT_GE(keyOpt.GetPriority(), 0); 4270 } 4271 } 4272 4273 /** 4274 * @tc.name: MMIService_GetAllSystemHotkeys_002 4275 * @tc.desc: When SHORTCUT_KEY_MANAGER_ENABLED is undefined, it returns ERROR_UNSUPPORTED 4276 * @tc.type: FUNC 4277 * @tc.require: 4278 */ 4279 HWTEST_F(MMIServerTest, MMIService_GetAllSystemHotkeys_002, TestSize.Level1) 4280 { 4281 #if !defined(SHORTCUT_KEY_MANAGER_ENABLED) 4282 CALL_TEST_DEBUG; 4283 MMIService mmiService; 4284 std::vector<KeyOption> keyOptions; 4285 ErrCode ret = mmiService.GetAllSystemHotkeys(keyOptions); 4286 EXPECT_NE(ret, RET_OK); 4287 EXPECT_TRUE(keyOptions.empty()); 4288 #else 4289 GTEST_SKIP() << "SHORTCUT_KEY_MANAGER_ENABLED is defined, skip this test"; 4290 #endif 4291 } 4292 4293 /** 4294 * @tc.name: MMIService_SetInputDeviceEnable_IllegalSession_001 4295 * @tc.desc: Return failure when SessionPtr is null 4296 * @tc.type: FUNC 4297 * @tc.require: 4298 */ 4299 HWTEST_F(MMIServerTest, MMIService_SetInputDeviceEnable_001, TestSize.Level1) 4300 { 4301 CALL_TEST_DEBUG; 4302 MMIService mmiService; 4303 int32_t deviceId = 1; 4304 int32_t index = 0; 4305 int32_t pid = 0; 4306 SessionPtr nullSession = nullptr; 4307 ErrCode ret = mmiService.SetInputDeviceEnable(deviceId, true, index, pid, nullSession); 4308 EXPECT_EQ(ret, RET_ERR); 4309 } 4310 4311 /** 4312 * @tc.name: MMIService_SetInputDeviceEnabled_001 4313 * @tc.desc: Test SetInputDeviceEnabled when service is not running 4314 * @tc.type: FUNC 4315 * @tc.require: 4316 */ 4317 HWTEST_F(MMIServerTest, MMIService_SetInputDeviceEnabled_001, TestSize.Level1) 4318 { 4319 CALL_TEST_DEBUG; 4320 MMIService mmiService; 4321 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 4322 int32_t deviceId = 1; 4323 int32_t index = 0; 4324 ErrCode ret = mmiService.SetInputDeviceEnabled(deviceId, true, index); 4325 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 4326 } 4327 4328 /** 4329 * @tc.name: MMIService_SetInputDeviceEnabled_002 4330 * @tc.desc: Test SetInputDeviceEnabled when service is running but not system app 4331 * @tc.type: FUNC 4332 * @tc.require: 4333 */ 4334 HWTEST_F(MMIServerTest, MMIService_SetInputDeviceEnabled_002, TestSize.Level1) 4335 { 4336 CALL_TEST_DEBUG; 4337 MMIService mmiService; 4338 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 4339 int32_t deviceId = 1; 4340 int32_t index = 0; 4341 ErrCode ret = mmiService.SetInputDeviceEnabled(deviceId, true, index); 4342 EXPECT_NE(ret, RET_OK); 4343 } 4344 4345 /** 4346 * @tc.name: MMIService_ShiftAppPointerEvent_001 4347 * @tc.desc: ShiftAppPointerEvent when service is not running 4348 * @tc.type: FUNC 4349 * @tc.require: 4350 */ 4351 HWTEST_F(MMIServerTest, MMIService_ShiftAppPointerEvent_001, TestSize.Level1) 4352 { 4353 CALL_TEST_DEBUG; 4354 MMIService mmiService; 4355 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 4356 ShiftWindowParam param {}; 4357 bool autoGenDown = false; 4358 ErrCode ret = mmiService.ShiftAppPointerEvent(param, autoGenDown); 4359 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 4360 } 4361 4362 /** 4363 * @tc.name: MMIService_ShiftAppPointerEvent_002 4364 * @tc.desc: ShiftAppPointerEvent when service is running but not system app 4365 * @tc.type: FUNC 4366 * @tc.require: 4367 */ 4368 HWTEST_F(MMIServerTest, MMIService_ShiftAppPointerEvent_002, TestSize.Level1) 4369 { 4370 CALL_TEST_DEBUG; 4371 MMIService mmiService; 4372 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 4373 ShiftWindowParam param {}; 4374 bool autoGenDown = true; 4375 ErrCode ret = mmiService.ShiftAppPointerEvent(param, autoGenDown); 4376 EXPECT_NE(ret, RET_OK); 4377 } 4378 4379 /** 4380 * @tc.name: MMIService_SetCustomCursor_001 4381 * @tc.desc: SetCustomCursor when service is not running 4382 * @tc.type: FUNC 4383 * @tc.require: 4384 */ 4385 HWTEST_F(MMIServerTest, MMIService_SetCustomCursor_001, TestSize.Level1) 4386 { 4387 CALL_TEST_DEBUG; 4388 MMIService mmiService; 4389 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 4390 CustomCursorParcel cursorParcel; 4391 CursorOptionsParcel optionParcel; 4392 ErrCode ret = mmiService.SetCustomCursor(1, cursorParcel, optionParcel); 4393 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 4394 } 4395 4396 /** 4397 * @tc.name: MMIService_SetCustomCursor_002 4398 * @tc.desc: SetCustomCursor when window permission denied 4399 * @tc.type: FUNC 4400 * @tc.require: 4401 */ 4402 HWTEST_F(MMIServerTest, MMIService_SetCustomCursor_002, TestSize.Level1) 4403 { 4404 CALL_TEST_DEBUG; 4405 MMIService mmiService; 4406 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 4407 CustomCursorParcel cursorParcel; 4408 CursorOptionsParcel optionParcel; 4409 int32_t invalidWindowId = -100; 4410 ErrCode ret = mmiService.SetCustomCursor(invalidWindowId, cursorParcel, optionParcel); 4411 EXPECT_NE(ret, RET_OK); 4412 } 4413 4414 #ifdef OHOS_BUILD_ENABLE_ANCO 4415 /** 4416 * @tc.name: MMIService_CheckKnuckleEvent_001 4417 * @tc.desc: CheckKnuckleEvent without modifying system app permission, default should be denied 4418 * @tc.type: FUNC 4419 * @tc.require: 4420 */ 4421 HWTEST_F(MMIServerTest, MMIService_CheckKnuckleEvent_001, TestSize.Level1) 4422 { 4423 CALL_TEST_DEBUG; 4424 MMIService mmiService; 4425 float pointX = 100.0f; 4426 float pointY = 200.0f; 4427 bool isKnuckleType = false; 4428 ErrCode ret = mmiService.CheckKnuckleEvent(pointX, pointY, isKnuckleType); 4429 EXPECT_NE(ret, RET_OK); 4430 } 4431 4432 /** 4433 * @tc.name: MMIService_SyncKnuckleStatus_001 4434 * @tc.desc: SyncKnuckleStatus returns RET_OK when delegateTasks_ runs normally 4435 * @tc.type: FUNC 4436 * @tc.require: 4437 */ 4438 HWTEST_F(MMIServerTest, MMIService_SyncKnuckleStatus_001, TestSize.Level1) 4439 { 4440 CALL_TEST_DEBUG; 4441 MMIService mmiService; 4442 int32_t ret = mmiService.SyncKnuckleStatus(); 4443 EXPECT_NE(ret, RET_OK); 4444 } 4445 #endif 4446 4447 /** 4448 * @tc.name: MMIService_SetMultiWindowScreenId_001 4449 * @tc.desc: Test SetMultiWindowScreenId returns ERROR_NOT_SYSAPI when caller is not system app 4450 * @tc.type: FUNC 4451 * @tc.require: 4452 */ 4453 HWTEST_F(MMIServerTest, MMIService_SetMultiWindowScreenId_001, TestSize.Level1) 4454 { 4455 CALL_TEST_DEBUG; 4456 MMIService mmiService; 4457 uint64_t screenId = 1; 4458 uint64_t displayNodeScreenId = 2; 4459 ErrCode ret = mmiService.SetMultiWindowScreenId(screenId, displayNodeScreenId); 4460 EXPECT_NE(ret, RET_OK); 4461 } 4462 4463 /** 4464 * @tc.name: MMIService_SetKnuckleSwitch_001 4465 * @tc.desc: Test SetKnuckleSwitch returns ERROR_NOT_SYSAPI when uid is not 7011 or not system app 4466 * @tc.type: FUNC 4467 * @tc.require: 4468 */ 4469 HWTEST_F(MMIServerTest, MMIService_SetKnuckleSwitch_001, TestSize.Level1) 4470 { 4471 CALL_TEST_DEBUG; 4472 MMIService mmiService; 4473 bool knuckleSwitch = true; 4474 ErrCode ret = mmiService.SetKnuckleSwitch(knuckleSwitch); 4475 EXPECT_NE(ret, RET_OK); 4476 } 4477 4478 /** 4479 * @tc.name: MMIService_LaunchAiScreenAbility_001 4480 * @tc.desc: Test LaunchAiScreenAbility when keyHandler is nullptr 4481 * @tc.type: FUNC 4482 * @tc.require: 4483 */ 4484 HWTEST_F(MMIServerTest, MMIService_LaunchAiScreenAbility_001, TestSize.Level1) 4485 { 4486 CALL_TEST_DEBUG; 4487 MMIService mmiService; 4488 ErrCode ret = mmiService.LaunchAiScreenAbility(); 4489 EXPECT_NE(ret, RET_OK); 4490 } 4491 4492 /** 4493 * @tc.name: MMIService_GetMaxMultiTouchPointNum_001 4494 * @tc.desc: Test GetMaxMultiTouchPointNum returns expected value 4495 * @tc.type: FUNC 4496 * @tc.require: 4497 */ 4498 HWTEST_F(MMIServerTest, MMIService_GetMaxMultiTouchPointNum_001, TestSize.Level1) 4499 { 4500 CALL_TEST_DEBUG; 4501 MMIService mmiService; 4502 int32_t pointNum = 0; 4503 ErrCode ret = mmiService.GetMaxMultiTouchPointNum(pointNum); 4504 EXPECT_NE(ret, RET_OK); 4505 } 4506 4507 /** 4508 * @tc.name: MMIService_DealConsumers_001 4509 * @tc.desc: Test DealConsumers adds consumer name when UID matches 4510 * @tc.type: FUNC 4511 * @tc.require: 4512 */ 4513 HWTEST_F(MMIServerTest, MMIService_DealConsumers_001, TestSize.Level1) 4514 { 4515 CALL_TEST_DEBUG; 4516 MMIService mmiService; 4517 int32_t callingUid = 0; 4518 DeviceConsumer consumer; 4519 consumer.name = "TestConsumer"; 4520 consumer.uids.push_back(callingUid); 4521 std::vector<std::string> filterNames; 4522 mmiService.DealConsumers(filterNames, consumer); 4523 ASSERT_EQ(filterNames.size(), 1); 4524 EXPECT_EQ(filterNames[0], "TestConsumer"); 4525 } 4526 4527 /** 4528 * @tc.name: MMIService_DealConsumers_002 4529 * @tc.desc: Test DealConsumers does not add name when UID does not match 4530 * @tc.type: FUNC 4531 * @tc.require: 4532 */ 4533 HWTEST_F(MMIServerTest, MMIService_DealConsumers_002, TestSize.Level1) 4534 { 4535 CALL_TEST_DEBUG; 4536 MMIService mmiService; 4537 int32_t callingUid = 1; 4538 DeviceConsumer consumer; 4539 consumer.name = "TestConsumer"; 4540 consumer.uids.push_back(callingUid + 1000); 4541 std::vector<std::string> filterNames; 4542 mmiService.DealConsumers(filterNames, consumer); 4543 ASSERT_TRUE(filterNames.empty()); 4544 } 4545 4546 /** 4547 * @tc.name: MMIService_FilterConsumers_001 4548 * @tc.desc: Test FilterConsumers returns matched consumer name with correct UID 4549 * @tc.type: FUNC 4550 * @tc.require: 4551 */ 4552 HWTEST_F(MMIServerTest, MMIService_FilterConsumers_001, TestSize.Level1) 4553 { 4554 CALL_TEST_DEBUG; 4555 MMIService mmiService; 4556 int32_t uid = 0; 4557 DeviceConsumer consumer; 4558 consumer.name = "DeviceA"; 4559 consumer.uids.push_back(uid); 4560 mmiService.consumersData_.consumers.push_back(consumer); 4561 std::vector<std::string> deviceNames = { "DeviceA" }; 4562 std::vector<std::string> result = mmiService.FilterConsumers(deviceNames); 4563 ASSERT_EQ(result.size(), 1); 4564 EXPECT_EQ(result[0], "DeviceA"); 4565 } 4566 4567 /** 4568 * @tc.name: MMIService_FilterConsumers_002 4569 * @tc.desc: Test FilterConsumers ignores consumer if UID doesn't match 4570 * @tc.type: FUNC 4571 * @tc.require: 4572 */ 4573 HWTEST_F(MMIServerTest, MMIService_FilterConsumers_002, TestSize.Level1) 4574 { 4575 CALL_TEST_DEBUG; 4576 MMIService mmiService; 4577 int32_t uid = 1; 4578 DeviceConsumer consumer; 4579 consumer.name = "DeviceB"; 4580 consumer.uids.push_back(uid + 10000); 4581 mmiService.consumersData_.consumers.push_back(consumer); 4582 std::vector<std::string> deviceNames = { "DeviceB" }; 4583 std::vector<std::string> result = mmiService.FilterConsumers(deviceNames); 4584 EXPECT_TRUE(result.empty()); 4585 } 4586 4587 /** 4588 * @tc.name: MMIService_FilterConsumers_003 4589 * @tc.desc: Test FilterConsumers with no matching device name 4590 * @tc.type: FUNC 4591 * @tc.require: 4592 */ 4593 HWTEST_F(MMIServerTest, MMIService_FilterConsumers_003, TestSize.Level1) 4594 { 4595 CALL_TEST_DEBUG; 4596 MMIService mmiService; 4597 int32_t uid = 1; 4598 DeviceConsumer consumer; 4599 consumer.name = "DeviceC"; 4600 consumer.uids.push_back(uid); 4601 mmiService.consumersData_.consumers.push_back(consumer); 4602 std::vector<std::string> deviceNames = { "NonExistDevice" }; 4603 std::vector<std::string> result = mmiService.FilterConsumers(deviceNames); 4604 EXPECT_TRUE(result.empty()); 4605 } 4606 4607 /** 4608 * @tc.name: MMIService_UpdateConsumers_001 4609 * @tc.desc: Parse valid JSON and store name and uids correctly 4610 * @tc.type: FUNC 4611 * @tc.require: 4612 */ 4613 HWTEST_F(MMIServerTest, MMIService_UpdateConsumers_001, TestSize.Level1) 4614 { 4615 CALL_TEST_DEBUG; 4616 MMIService mmiService; 4617 const char *jsonStr = R"({ 4618 "name": "DeviceTest", 4619 "uids": [1001, 1002] 4620 })"; 4621 cJSON *json = cJSON_Parse(jsonStr); 4622 ASSERT_NE(json, nullptr); 4623 mmiService.UpdateConsumers(json); 4624 ASSERT_EQ(mmiService.consumersData_.consumers.size(), 1); 4625 const auto &consumer = mmiService.consumersData_.consumers[0]; 4626 EXPECT_EQ(consumer.name, "DeviceTest"); 4627 EXPECT_EQ(consumer.uids.size(), 2); 4628 EXPECT_EQ(consumer.uids[0], 1001); 4629 EXPECT_EQ(consumer.uids[1], 1002); 4630 cJSON_Delete(json); 4631 } 4632 4633 /** 4634 * @tc.name: MMIService_UpdateConsumers_002 4635 * @tc.desc: JSON without name, should skip name assignment 4636 * @tc.type: FUNC 4637 * @tc.require: 4638 */ 4639 HWTEST_F(MMIServerTest, MMIService_UpdateConsumers_002, TestSize.Level1) 4640 { 4641 CALL_TEST_DEBUG; 4642 MMIService mmiService; 4643 const char *jsonStr = R"({ 4644 "uids": [2001, 2002] 4645 })"; 4646 cJSON *json = cJSON_Parse(jsonStr); 4647 ASSERT_NE(json, nullptr); 4648 mmiService.UpdateConsumers(json); 4649 ASSERT_EQ(mmiService.consumersData_.consumers.size(), 1); 4650 const auto &consumer = mmiService.consumersData_.consumers[0]; 4651 EXPECT_EQ(consumer.name, ""); 4652 EXPECT_EQ(consumer.uids.size(), 2); 4653 EXPECT_EQ(consumer.uids[0], 2001); 4654 EXPECT_EQ(consumer.uids[1], 2002); 4655 cJSON_Delete(json); 4656 } 4657 4658 /** 4659 * @tc.name: MMIService_UpdateConsumers_003 4660 * @tc.desc: JSON without uids, should keep uids empty 4661 * @tc.type: FUNC 4662 * @tc.require: 4663 */ 4664 HWTEST_F(MMIServerTest, MMIService_UpdateConsumers_003, TestSize.Level1) 4665 { 4666 CALL_TEST_DEBUG; 4667 MMIService mmiService; 4668 const char *jsonStr = R"({ 4669 "name": "DeviceOnly" 4670 })"; 4671 cJSON *json = cJSON_Parse(jsonStr); 4672 ASSERT_NE(json, nullptr); 4673 mmiService.UpdateConsumers(json); 4674 ASSERT_EQ(mmiService.consumersData_.consumers.size(), 1); 4675 const auto &consumer = mmiService.consumersData_.consumers[0]; 4676 EXPECT_EQ(consumer.name, "DeviceOnly"); 4677 EXPECT_TRUE(consumer.uids.empty()); 4678 cJSON_Delete(json); 4679 } 4680 4681 /** 4682 * @tc.name: MMIService_UpdateConsumers_004 4683 * @tc.desc: uids array includes non-numeric value, should ignore them 4684 * @tc.type: FUNC 4685 * @tc.require: 4686 */ 4687 HWTEST_F(MMIServerTest, MMIService_UpdateConsumers_004, TestSize.Level1) 4688 { 4689 CALL_TEST_DEBUG; 4690 MMIService mmiService; 4691 const char *jsonStr = R"({ 4692 "name": "MixedUID", 4693 "uids": [3001, "notANumber", 3002] 4694 })"; 4695 cJSON *json = cJSON_Parse(jsonStr); 4696 ASSERT_NE(json, nullptr); 4697 mmiService.UpdateConsumers(json); 4698 ASSERT_EQ(mmiService.consumersData_.consumers.size(), 1); 4699 const auto &consumer = mmiService.consumersData_.consumers[0]; 4700 EXPECT_EQ(consumer.name, "MixedUID"); 4701 ASSERT_EQ(consumer.uids.size(), 2); 4702 EXPECT_EQ(consumer.uids[0], 3001); 4703 EXPECT_EQ(consumer.uids[1], 3002); 4704 4705 cJSON_Delete(json); 4706 } 4707 4708 /** 4709 * @tc.name: MMIService_SetInputDeviceConsumer_001 4710 * @tc.desc: deviceNames size > MAX_DEVICE_NUM returns RET_ERR 4711 * @tc.type: FUNC 4712 * @tc.require: 4713 */ 4714 HWTEST_F(MMIServerTest, MMIService_SetInputDeviceConsumer_001, TestSize.Level1) 4715 { 4716 CALL_TEST_DEBUG; 4717 MMIService mmiService; 4718 std::vector<std::string> deviceNames(10 + 5, "testDevice"); 4719 ErrCode ret = mmiService.SetInputDeviceConsumer(deviceNames); 4720 EXPECT_EQ(ret, RET_ERR); 4721 } 4722 4723 /** 4724 * @tc.name: MMIService_SetInputDeviceConsumer_002 4725 * @tc.desc: config parse fails (no config file), returns ERROR_NO_PERMISSION 4726 * @tc.type: FUNC 4727 * @tc.require: 4728 */ 4729 HWTEST_F(MMIServerTest, MMIService_SetInputDeviceConsumer_002, TestSize.Level1) 4730 { 4731 CALL_TEST_DEBUG; 4732 MMIService mmiService; 4733 std::vector<std::string> deviceNames = {"keyboard"}; 4734 ErrCode ret = mmiService.SetInputDeviceConsumer(deviceNames); 4735 EXPECT_EQ(ret, ERROR_NO_PERMISSION); 4736 } 4737 4738 /** 4739 * @tc.name: MMIService_SetInputDeviceConsumer_003 4740 * @tc.desc: deviceNames empty, FilterConsumers returns empty, returns ERROR_NO_PERMISSION 4741 * @tc.type: FUNC 4742 * @tc.require: 4743 */ 4744 HWTEST_F(MMIServerTest, MMIService_SetInputDeviceConsumer_003, TestSize.Level1) 4745 { 4746 CALL_TEST_DEBUG; 4747 MMIService mmiService; 4748 std::vector<std::string> deviceNames = {}; 4749 ErrCode ret = mmiService.SetInputDeviceConsumer(deviceNames); 4750 EXPECT_EQ(ret, ERROR_NO_PERMISSION); 4751 } 4752 4753 /** 4754 * @tc.name: MMIService_SetInputDeviceConsumer_004 4755 * @tc.desc: session is null, returns ERROR_NULL_POINTER 4756 * @tc.type: FUNC 4757 * @tc.require: 4758 */ 4759 HWTEST_F(MMIServerTest, MMIService_SetInputDeviceConsumer_004, TestSize.Level1) 4760 { 4761 CALL_TEST_DEBUG; 4762 MMIService mmiService; 4763 std::vector<std::string> deviceNames = {"keyboard"}; 4764 ErrCode ret = mmiService.SetInputDeviceConsumer(deviceNames); 4765 EXPECT_NE(ret, RET_OK); 4766 } 4767 4768 /** 4769 * @tc.name: MMIService_ParseDeviceConsumerConfig_001 4770 * @tc.desc: GetOneCfgFile returns nullptr 4771 * @tc.type: FUNC 4772 * @tc.require: 4773 */ 4774 HWTEST_F(MMIServerTest, MMIService_ParseDeviceConsumerConfig_001, TestSize.Level1) 4775 { 4776 CALL_TEST_DEBUG; 4777 MMIService mmiService; 4778 bool result = mmiService.ParseDeviceConsumerConfig(); 4779 EXPECT_FALSE(result); 4780 } 4781 4782 /** 4783 * @tc.name: MMIService_ClearInputDeviceConsumer_001 4784 * @tc.desc: deviceNames.size > MAX_DEVICE_NUM should return RET_ERR 4785 * @tc.type: FUNC 4786 * @tc.require: 4787 */ 4788 HWTEST_F(MMIServerTest, MMIService_ClearInputDeviceConsumer_001, TestSize.Level1) 4789 { 4790 CALL_TEST_DEBUG; 4791 MMIService mmiService; 4792 std::vector<std::string> deviceNames(10 + 10, "device"); 4793 ErrCode ret = mmiService.ClearInputDeviceConsumer(deviceNames); 4794 EXPECT_EQ(ret, RET_ERR); 4795 } 4796 4797 /** 4798 * @tc.name: MMIService_ClearInputDeviceConsumer_002 4799 * @tc.desc: ParseDeviceConsumerConfig returns false, should return ERROR_NO_PERMISSION 4800 * @tc.type: FUNC 4801 * @tc.require: 4802 */ 4803 HWTEST_F(MMIServerTest, MMIService_ClearInputDeviceConsumer_002, TestSize.Level1) 4804 { 4805 CALL_TEST_DEBUG; 4806 MMIService mmiService; 4807 std::vector<std::string> deviceNames = {"keyboard"}; 4808 ErrCode ret = mmiService.ClearInputDeviceConsumer(deviceNames); 4809 EXPECT_EQ(ret, ERROR_NO_PERMISSION); 4810 } 4811 4812 /** 4813 * @tc.name: MMIService_ClearInputDeviceConsumer_003 4814 * @tc.desc: FilterConsumers returns empty, should return ERROR_NO_PERMISSION 4815 * @tc.type: FUNC 4816 * @tc.require: 4817 */ 4818 HWTEST_F(MMIServerTest, MMIService_ClearInputDeviceConsumer_003, TestSize.Level1) 4819 { 4820 CALL_TEST_DEBUG; 4821 MMIService mmiService; 4822 std::vector<std::string> deviceNames = {}; 4823 ErrCode ret = mmiService.ClearInputDeviceConsumer(deviceNames); 4824 EXPECT_EQ(ret, ERROR_NO_PERMISSION); 4825 } 4826 4827 /** 4828 * @tc.name: MMIService_ClearInputDeviceConsumer_004 4829 * @tc.desc: session not registered, PostSyncTask fails 4830 * @tc.type: FUNC 4831 * @tc.require: 4832 */ 4833 HWTEST_F(MMIServerTest, MMIService_ClearInputDeviceConsumer_004, TestSize.Level1) 4834 { 4835 CALL_TEST_DEBUG; 4836 MMIService mmiService; 4837 std::vector<std::string> deviceNames = {"keyboard"}; 4838 ErrCode ret = mmiService.ClearInputDeviceConsumer(deviceNames); 4839 EXPECT_EQ(ret, ERROR_NO_PERMISSION); 4840 } 4841 4842 /** 4843 * @tc.name: MMIService_SubscribeInputActive_001 4844 * @tc.desc: VerifySystemApp returns false → return ERROR_NOT_SYSAPI 4845 * @tc.type: FUNC 4846 * @tc.require: 4847 */ 4848 HWTEST_F(MMIServerTest, MMIService_SubscribeInputActive_001, TestSize.Level1) 4849 { 4850 CALL_TEST_DEBUG; 4851 MMIService mmiService; 4852 ErrCode ret = mmiService.SubscribeInputActive(1, 1000); 4853 EXPECT_NE(ret, RET_OK); 4854 } 4855 4856 /** 4857 * @tc.name: MMIService_SubscribeInputActive_002 4858 * @tc.desc: Service not running → return MMISERVICE_NOT_RUNNING 4859 * @tc.type: FUNC 4860 * @tc.require: 4861 */ 4862 HWTEST_F(MMIServerTest, MMIService_SubscribeInputActive_002, TestSize.Level1) 4863 { 4864 CALL_TEST_DEBUG; 4865 MMIService mmiService; 4866 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 4867 ErrCode ret = mmiService.SubscribeInputActive(2, 1000); 4868 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 4869 } 4870 4871 /** 4872 * @tc.name: MMIService_SubscribeInputActive_003 4873 * @tc.desc: GetSessionByPid returns nullptr → return RET_ERR 4874 * @tc.type: FUNC 4875 * @tc.require: 4876 */ 4877 HWTEST_F(MMIServerTest, MMIService_SubscribeInputActive_003, TestSize.Level1) 4878 { 4879 CALL_TEST_DEBUG; 4880 MMIService mmiService; 4881 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 4882 ErrCode ret = mmiService.SubscribeInputActive(3, 500); 4883 EXPECT_EQ(ret, ETASKS_POST_SYNCTASK_FAIL); 4884 } 4885 4886 /** 4887 * @tc.name: MMIService_UnsubscribeInputActive_001 4888 * @tc.desc: Permission denied, VerifySystemApp returns false 4889 * @tc.type: FUNC 4890 * @tc.require: 4891 */ 4892 HWTEST_F(MMIServerTest, MMIService_UnsubscribeInputActive_001, TestSize.Level1) 4893 { 4894 CALL_TEST_DEBUG; 4895 MMIService mmiService; 4896 ErrCode ret = mmiService.UnsubscribeInputActive(1); 4897 EXPECT_NE(ret, RET_OK); 4898 } 4899 4900 /** 4901 * @tc.name: MMIService_UnsubscribeInputActive_002 4902 * @tc.desc: Service not running, return MMISERVICE_NOT_RUNNING 4903 * @tc.type: FUNC 4904 * @tc.require: 4905 */ 4906 HWTEST_F(MMIServerTest, MMIService_UnsubscribeInputActive_002, TestSize.Level1) 4907 { 4908 CALL_TEST_DEBUG; 4909 MMIService mmiService; 4910 mmiService.state_ = ServiceRunningState::STATE_NOT_START; 4911 ErrCode ret = mmiService.UnsubscribeInputActive(2); 4912 EXPECT_EQ(ret, MMISERVICE_NOT_RUNNING); 4913 } 4914 4915 /** 4916 * @tc.name: MMIService_UnsubscribeInputActive_003 4917 * @tc.desc: Invalid subscribeId (negative), return RET_ERR 4918 * @tc.type: FUNC 4919 * @tc.require: 4920 */ 4921 HWTEST_F(MMIServerTest, MMIService_UnsubscribeInputActive_003, TestSize.Level1) 4922 { 4923 CALL_TEST_DEBUG; 4924 MMIService mmiService; 4925 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 4926 ErrCode ret = mmiService.UnsubscribeInputActive(-1); 4927 EXPECT_EQ(ret, RET_ERR); 4928 } 4929 4930 /** 4931 * @tc.name: MMIService_UnsubscribeInputActive_004 4932 * @tc.desc: No session registered, GetSessionByPid returns null 4933 * @tc.type: FUNC 4934 * @tc.require: 4935 */ 4936 HWTEST_F(MMIServerTest, MMIService_UnsubscribeInputActive_004, TestSize.Level1) 4937 { 4938 CALL_TEST_DEBUG; 4939 MMIService mmiService; 4940 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 4941 ErrCode ret = mmiService.UnsubscribeInputActive(4); 4942 EXPECT_EQ(ret, ETASKS_POST_SYNCTASK_FAIL); 4943 } 4944 4945 /** 4946 * @tc.name: MMIService_SetMouseAccelerateMotionSwitch_001 4947 * @tc.desc: Permission denied → RequestFromShell returns false 4948 * @tc.type: FUNC 4949 * @tc.require: 4950 */ 4951 HWTEST_F(MMIServerTest, MMIService_SetMouseAccelerateMotionSwitch_001, TestSize.Level1) 4952 { 4953 CALL_TEST_DEBUG; 4954 MMIService mmiService; 4955 int32_t deviceId = 0; 4956 bool enable = true; 4957 ErrCode ret = mmiService.SetMouseAccelerateMotionSwitch(deviceId, enable); 4958 EXPECT_NE(ret, RET_OK); 4959 } 4960 4961 /** 4962 * @tc.name: MMIService_SetMouseAccelerateMotionSwitch_002 4963 * @tc.desc: Permission granted, but PostSyncTask fails 4964 * @tc.type: FUNC 4965 * @tc.require: 4966 */ 4967 HWTEST_F(MMIServerTest, MMIService_SetMouseAccelerateMotionSwitch_002, TestSize.Level1) 4968 { 4969 CALL_TEST_DEBUG; 4970 MMIService mmiService; 4971 int32_t deviceId = 1; 4972 bool enable = false; 4973 ErrCode ret = mmiService.SetMouseAccelerateMotionSwitch(deviceId, enable); 4974 EXPECT_TRUE(ret == ERROR_NO_PERMISSION || ret == ETASKS_POST_SYNCTASK_FAIL); 4975 } 4976 4977 /** 4978 * @tc.name: MMIService_SwitchScreenCapturePermission_001 4979 * @tc.desc: Not system app, should return ERROR_NOT_SYSAPI 4980 * @tc.type: FUNC 4981 * @tc.require: 4982 */ 4983 HWTEST_F(MMIServerTest, MMIService_SwitchScreenCapturePermission_001, TestSize.Level1) 4984 { 4985 CALL_TEST_DEBUG; 4986 MMIService mmiService; 4987 ErrCode ret = mmiService.SwitchScreenCapturePermission(1, true); 4988 EXPECT_NE(ret, RET_OK); 4989 } 4990 4991 /** 4992 * @tc.name: MMIService_SwitchScreenCapturePermission_002 4993 * @tc.desc: Uid not in {PENGLAI_UID, GAME_UID}, return ERROR_NO_PERMISSION 4994 * @tc.type: FUNC 4995 * @tc.require: 4996 */ 4997 HWTEST_F(MMIServerTest, MMIService_SwitchScreenCapturePermission_002, TestSize.Level1) 4998 { 4999 CALL_TEST_DEBUG; 5000 MMIService mmiService; 5001 mmiService.state_ = ServiceRunningState::STATE_RUNNING; 5002 ErrCode ret = mmiService.SwitchScreenCapturePermission(2, false); 5003 EXPECT_EQ(ret, ERROR_NO_PERMISSION); 5004 } 5005 5006 /** 5007 * @tc.name: MMIService_ClearMouseHideFlag_001 5008 * @tc.desc: App is not a system app, return ERROR_NOT_SYSAPI 5009 * @tc.type: FUNC 5010 * @tc.require: 5011 */ 5012 HWTEST_F(MMIServerTest, MMIService_ClearMouseHideFlag_001, TestSize.Level1) 5013 { 5014 CALL_TEST_DEBUG; 5015 MMIService mmiService; 5016 int32_t eventId = 100; 5017 ErrCode ret = mmiService.ClearMouseHideFlag(eventId); 5018 EXPECT_NE(ret, RET_OK); 5019 } 5020 5021 /** 5022 * @tc.name: MMIService_ClearMouseHideFlag_002 5023 * @tc.desc: Uid not SYNERGY_UID, return ERROR_NO_PERMISSION 5024 * @tc.type: FUNC 5025 * @tc.require: 5026 */ 5027 HWTEST_F(MMIServerTest, MMIService_ClearMouseHideFlag_002, TestSize.Level1) 5028 { 5029 CALL_TEST_DEBUG; 5030 MMIService mmiService; 5031 int32_t eventId = 101; 5032 ErrCode ret = mmiService.ClearMouseHideFlag(eventId); 5033 EXPECT_TRUE(ret == ERROR_NOT_SYSAPI || ret == ERROR_NO_PERMISSION || ret == ETASKS_POST_SYNCTASK_FAIL); 5034 } 5035 5036 /** 5037 * @tc.name: MMIService_QueryPointerRecord_001 5038 * @tc.desc: Not system app, should return ERROR_NOT_SYSAPI 5039 * @tc.type: FUNC 5040 * @tc.require: 5041 */ 5042 HWTEST_F(MMIServerTest, MMIService_QueryPointerRecord_001, TestSize.Level1) 5043 { 5044 CALL_TEST_DEBUG; 5045 MMIService mmiService; 5046 std::vector<std::shared_ptr<PointerEvent>> pointerList; 5047 ErrCode ret = mmiService.QueryPointerRecord(5, pointerList); 5048 EXPECT_NE(ret, RET_OK); 5049 } 5050 5051 /** 5052 * @tc.name: MMIService_QueryPointerRecord_002 5053 * @tc.desc: No monitor permission, should return ERROR_NO_PERMISSION 5054 * @tc.type: FUNC 5055 * @tc.require: 5056 */ 5057 HWTEST_F(MMIServerTest, MMIService_QueryPointerRecord_002, TestSize.Level1) 5058 { 5059 CALL_TEST_DEBUG; 5060 MMIService mmiService; 5061 std::vector<std::shared_ptr<PointerEvent>> pointerList; 5062 ErrCode ret = mmiService.QueryPointerRecord(10, pointerList); 5063 EXPECT_TRUE(ret == ERROR_NOT_SYSAPI || ret == ERROR_NO_PERMISSION || ret == ETASKS_POST_SYNCTASK_FAIL); 5064 } 5065 } // namespace MMI 5066 } // namespace OHOS