1 /* 2 * Copyright (c) 2023 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 "key_event.h" 19 #include "key_event_value_transformation.h" 20 #include "mmi_log.h" 21 22 #undef MMI_LOG_TAG 23 #define MMI_LOG_TAG "KeyEventValueTransformationTest" 24 namespace OHOS { 25 namespace MMI { 26 namespace { 27 using namespace testing::ext; 28 constexpr int32_t KEY_ITEM_SIZE = 2; 29 } // namespace 30 31 class KeyEventValueTransformationTest : public testing::Test { 32 public: SetUpTestCase(void)33 static void SetUpTestCase(void) {} TearDownTestCase(void)34 static void TearDownTestCase(void) {} 35 }; 36 37 /** 38 * @tc.name: KeyEventValueTransformationTest_KeyIntention_001 39 * @tc.desc: Verify key intention 40 * @tc.type: FUNC 41 * @tc.require:SR000HQ0RR 42 */ 43 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_KeyIntention_001, TestSize.Level1) 44 { 45 CALL_DEBUG_ENTER; 46 auto KeyEvent = KeyEvent::Create(); 47 ASSERT_NE(KeyEvent, nullptr); 48 KeyEvent::KeyItem item; 49 item.SetKeyCode(KeyEvent::KEYCODE_UNKNOWN); 50 KeyEvent->AddKeyItem(item); 51 int32_t keyIntention = KeyItemsTransKeyIntention(KeyEvent->GetKeyItems()); 52 ASSERT_EQ(keyIntention, KeyEvent::INTENTION_UNKNOWN); 53 } 54 55 /** 56 * @tc.name: KeyEventValueTransformationTest_KeyIntention_002 57 * @tc.desc: Verify key intention 58 * @tc.type: FUNC 59 * @tc.require:SR000HQ0RR 60 */ 61 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_KeyIntention_002, TestSize.Level1) 62 { 63 CALL_DEBUG_ENTER; 64 auto KeyEvent = KeyEvent::Create(); 65 ASSERT_NE(KeyEvent, nullptr); 66 KeyEvent::KeyItem item; 67 item.SetKeyCode(KeyEvent::KEYCODE_DPAD_UP); 68 KeyEvent->AddKeyItem(item); 69 int32_t keyIntention = KeyItemsTransKeyIntention(KeyEvent->GetKeyItems()); 70 ASSERT_EQ(keyIntention, KeyEvent::INTENTION_UP); 71 } 72 73 /** 74 * @tc.name: KeyEventValueTransformationTest_KeyIntention_003 75 * @tc.desc: Verify key intention 76 * @tc.type: FUNC 77 * @tc.require:SR000HQ0RR 78 */ 79 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_KeyIntention_003, TestSize.Level1) 80 { 81 CALL_DEBUG_ENTER; 82 auto KeyEvent = KeyEvent::Create(); 83 ASSERT_NE(KeyEvent, nullptr); 84 KeyEvent::KeyItem item; 85 item.SetKeyCode(KeyEvent::KEYCODE_DPAD_DOWN); 86 KeyEvent->AddKeyItem(item); 87 int32_t keyIntention = KeyItemsTransKeyIntention(KeyEvent->GetKeyItems()); 88 ASSERT_EQ(keyIntention, KeyEvent::INTENTION_DOWN); 89 } 90 91 /** 92 * @tc.name: KeyEventValueTransformationTest_KeyIntention_004 93 * @tc.desc: Verify key intention 94 * @tc.type: FUNC 95 * @tc.require:SR000HQ0RR 96 */ 97 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_KeyIntention_004, TestSize.Level1) 98 { 99 CALL_DEBUG_ENTER; 100 auto KeyEvent = KeyEvent::Create(); 101 ASSERT_NE(KeyEvent, nullptr); 102 KeyEvent::KeyItem item; 103 item.SetKeyCode(KeyEvent::KEYCODE_DPAD_LEFT); 104 KeyEvent->AddKeyItem(item); 105 int32_t keyIntention = KeyItemsTransKeyIntention(KeyEvent->GetKeyItems()); 106 ASSERT_EQ(keyIntention, KeyEvent::INTENTION_LEFT); 107 } 108 109 /** 110 * @tc.name: KeyEventValueTransformationTest_KeyIntention_005 111 * @tc.desc: Verify key intention 112 * @tc.type: FUNC 113 * @tc.require:SR000HQ0RR 114 */ 115 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_KeyIntention_005, TestSize.Level1) 116 { 117 CALL_DEBUG_ENTER; 118 auto KeyEvent = KeyEvent::Create(); 119 ASSERT_NE(KeyEvent, nullptr); 120 KeyEvent::KeyItem item; 121 item.SetKeyCode(KeyEvent::KEYCODE_DPAD_RIGHT); 122 KeyEvent->AddKeyItem(item); 123 int32_t keyIntention = KeyItemsTransKeyIntention(KeyEvent->GetKeyItems()); 124 ASSERT_EQ(keyIntention, KeyEvent::INTENTION_RIGHT); 125 } 126 127 /** 128 * @tc.name: KeyEventValueTransformationTest_KeyIntention_006 129 * @tc.desc: Verify key intention 130 * @tc.type: FUNC 131 * @tc.require:SR000HQ0RR 132 */ 133 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_KeyIntention_006, TestSize.Level1) 134 { 135 CALL_DEBUG_ENTER; 136 auto KeyEvent = KeyEvent::Create(); 137 ASSERT_NE(KeyEvent, nullptr); 138 KeyEvent::KeyItem item; 139 item.SetKeyCode(KeyEvent::KEYCODE_SPACE); 140 KeyEvent->AddKeyItem(item); 141 int32_t keyIntention = KeyItemsTransKeyIntention(KeyEvent->GetKeyItems()); 142 ASSERT_EQ(keyIntention, KeyEvent::INTENTION_SELECT); 143 } 144 145 /** 146 * @tc.name: KeyEventValueTransformationTest_KeyIntention_007 147 * @tc.desc: Verify key intention 148 * @tc.type: FUNC 149 * @tc.require:SR000HQ0RR 150 */ 151 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_KeyIntention_007, TestSize.Level1) 152 { 153 CALL_DEBUG_ENTER; 154 auto KeyEvent = KeyEvent::Create(); 155 ASSERT_NE(KeyEvent, nullptr); 156 KeyEvent::KeyItem item; 157 item.SetKeyCode(KeyEvent::KEYCODE_ESCAPE); 158 KeyEvent->AddKeyItem(item); 159 int32_t keyIntention = KeyItemsTransKeyIntention(KeyEvent->GetKeyItems()); 160 ASSERT_EQ(keyIntention, KeyEvent::INTENTION_ESCAPE); 161 } 162 163 /** 164 * @tc.name: KeyEventValueTransformationTest_KeyIntention_008 165 * @tc.desc: Verify key intention 166 * @tc.type: FUNC 167 * @tc.require:SR000HQ0RR 168 */ 169 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_KeyIntention_008, TestSize.Level1) 170 { 171 CALL_DEBUG_ENTER; 172 auto KeyEvent = KeyEvent::Create(); 173 ASSERT_NE(KeyEvent, nullptr); 174 KeyEvent::KeyItem item[KEY_ITEM_SIZE]; 175 item[0].SetKeyCode(KeyEvent::KEYCODE_ALT_LEFT); 176 KeyEvent->AddKeyItem(item[0]); 177 item[1].SetKeyCode(KeyEvent::KEYCODE_DPAD_LEFT); 178 KeyEvent->AddKeyItem(item[1]); 179 int32_t keyIntention = KeyItemsTransKeyIntention(KeyEvent->GetKeyItems()); 180 ASSERT_EQ(keyIntention, KeyEvent::INTENTION_BACK); 181 } 182 183 /** 184 * @tc.name: KeyEventValueTransformationTest_KeyIntention_009 185 * @tc.desc: Verify key intention 186 * @tc.type: FUNC 187 * @tc.require:SR000HQ0RR 188 */ 189 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_KeyIntention_009, TestSize.Level1) 190 { 191 CALL_DEBUG_ENTER; 192 auto KeyEvent = KeyEvent::Create(); 193 ASSERT_NE(KeyEvent, nullptr); 194 KeyEvent::KeyItem item[KEY_ITEM_SIZE]; 195 item[0].SetKeyCode(KeyEvent::KEYCODE_ALT_RIGHT); 196 KeyEvent->AddKeyItem(item[0]); 197 item[1].SetKeyCode(KeyEvent::KEYCODE_DPAD_LEFT); 198 KeyEvent->AddKeyItem(item[1]); 199 int32_t keyIntention = KeyItemsTransKeyIntention(KeyEvent->GetKeyItems()); 200 ASSERT_EQ(keyIntention, KeyEvent::INTENTION_BACK); 201 } 202 203 /** 204 * @tc.name: KeyEventValueTransformationTest_KeyIntention_010 205 * @tc.desc: Verify key intention 206 * @tc.type: FUNC 207 * @tc.require:SR000HQ0RR 208 */ 209 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_KeyIntention_010, TestSize.Level1) 210 { 211 CALL_DEBUG_ENTER; 212 auto KeyEvent = KeyEvent::Create(); 213 ASSERT_NE(KeyEvent, nullptr); 214 KeyEvent::KeyItem item[KEY_ITEM_SIZE]; 215 item[0].SetKeyCode(KeyEvent::KEYCODE_ALT_LEFT); 216 KeyEvent->AddKeyItem(item[0]); 217 item[1].SetKeyCode(KeyEvent::KEYCODE_DPAD_RIGHT); 218 KeyEvent->AddKeyItem(item[1]); 219 int32_t keyIntention = KeyItemsTransKeyIntention(KeyEvent->GetKeyItems()); 220 ASSERT_EQ(keyIntention, KeyEvent::INTENTION_FORWARD); 221 } 222 223 /** 224 * @tc.name: KeyEventValueTransformationTest_KeyIntention_011 225 * @tc.desc: Verify key intention 226 * @tc.type: FUNC 227 * @tc.require:SR000HQ0RR 228 */ 229 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_KeyIntention_011, TestSize.Level1) 230 { 231 CALL_DEBUG_ENTER; 232 auto KeyEvent = KeyEvent::Create(); 233 ASSERT_NE(KeyEvent, nullptr); 234 KeyEvent::KeyItem item[KEY_ITEM_SIZE]; 235 item[0].SetKeyCode(KeyEvent::KEYCODE_ALT_RIGHT); 236 KeyEvent->AddKeyItem(item[0]); 237 item[1].SetKeyCode(KeyEvent::KEYCODE_DPAD_RIGHT); 238 KeyEvent->AddKeyItem(item[1]); 239 int32_t keyIntention = KeyItemsTransKeyIntention(KeyEvent->GetKeyItems()); 240 ASSERT_EQ(keyIntention, KeyEvent::INTENTION_FORWARD); 241 } 242 243 /** 244 * @tc.name: KeyEventValueTransformationTest_KeyIntention_012 245 * @tc.desc: Verify key intention 246 * @tc.type: FUNC 247 * @tc.require:SR000HQ0RR 248 */ 249 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_KeyIntention_012, TestSize.Level1) 250 { 251 CALL_DEBUG_ENTER; 252 auto KeyEvent = KeyEvent::Create(); 253 ASSERT_NE(KeyEvent, nullptr); 254 KeyEvent::KeyItem item[KEY_ITEM_SIZE]; 255 item[0].SetKeyCode(KeyEvent::KEYCODE_SHIFT_LEFT); 256 KeyEvent->AddKeyItem(item[0]); 257 item[1].SetKeyCode(KeyEvent::KEYCODE_F10); 258 KeyEvent->AddKeyItem(item[1]); 259 int32_t keyIntention = KeyItemsTransKeyIntention(KeyEvent->GetKeyItems()); 260 ASSERT_EQ(keyIntention, KeyEvent::INTENTION_MENU); 261 } 262 263 /** 264 * @tc.name: KeyEventValueTransformationTest_KeyIntention_013 265 * @tc.desc: Verify key intention 266 * @tc.type: FUNC 267 * @tc.require:SR000HQ0RR 268 */ 269 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_KeyIntention_013, TestSize.Level1) 270 { 271 CALL_DEBUG_ENTER; 272 auto KeyEvent = KeyEvent::Create(); 273 ASSERT_NE(KeyEvent, nullptr); 274 KeyEvent::KeyItem item[KEY_ITEM_SIZE]; 275 item[0].SetKeyCode(KeyEvent::KEYCODE_SHIFT_RIGHT); 276 KeyEvent->AddKeyItem(item[0]); 277 item[1].SetKeyCode(KeyEvent::KEYCODE_F10); 278 KeyEvent->AddKeyItem(item[1]); 279 int32_t keyIntention = KeyItemsTransKeyIntention(KeyEvent->GetKeyItems()); 280 ASSERT_EQ(keyIntention, KeyEvent::INTENTION_MENU); 281 } 282 283 /** 284 * @tc.name: KeyEventValueTransformationTest_KeyIntention_014 285 * @tc.desc: Verify key intention 286 * @tc.type: FUNC 287 * @tc.require:SR000HQ0RR 288 */ 289 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_KeyIntention_014, TestSize.Level1) 290 { 291 CALL_DEBUG_ENTER; 292 auto KeyEvent = KeyEvent::Create(); 293 ASSERT_NE(KeyEvent, nullptr); 294 KeyEvent::KeyItem item; 295 item.SetKeyCode(KeyEvent::KEYCODE_PAGE_UP); 296 KeyEvent->AddKeyItem(item); 297 int32_t keyIntention = KeyItemsTransKeyIntention(KeyEvent->GetKeyItems()); 298 ASSERT_EQ(keyIntention, KeyEvent::INTENTION_PAGE_UP); 299 } 300 301 /** 302 * @tc.name: KeyEventValueTransformationTest_KeyIntention_015 303 * @tc.desc: Verify key intention 304 * @tc.type: FUNC 305 * @tc.require:SR000HQ0RR 306 */ 307 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_KeyIntention_015, TestSize.Level1) 308 { 309 CALL_DEBUG_ENTER; 310 auto KeyEvent = KeyEvent::Create(); 311 ASSERT_NE(KeyEvent, nullptr); 312 KeyEvent::KeyItem item; 313 item.SetKeyCode(KeyEvent::KEYCODE_PAGE_DOWN); 314 KeyEvent->AddKeyItem(item); 315 int32_t keyIntention = KeyItemsTransKeyIntention(KeyEvent->GetKeyItems()); 316 ASSERT_EQ(keyIntention, KeyEvent::INTENTION_PAGE_DOWN); 317 } 318 319 /** 320 * @tc.name: KeyEventValueTransformationTest_KeyIntention_016 321 * @tc.desc: Verify key intention 322 * @tc.type: FUNC 323 * @tc.require:SR000HQ0RR 324 */ 325 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_KeyIntention_016, TestSize.Level1) 326 { 327 CALL_DEBUG_ENTER; 328 auto KeyEvent = KeyEvent::Create(); 329 ASSERT_NE(KeyEvent, nullptr); 330 KeyEvent::KeyItem item[KEY_ITEM_SIZE]; 331 item[0].SetKeyCode(KeyEvent::KEYCODE_CTRL_LEFT); 332 KeyEvent->AddKeyItem(item[0]); 333 item[1].SetKeyCode(KeyEvent::KEYCODE_PLUS); 334 KeyEvent->AddKeyItem(item[1]); 335 int32_t keyIntention = KeyItemsTransKeyIntention(KeyEvent->GetKeyItems()); 336 ASSERT_EQ(keyIntention, KeyEvent::INTENTION_ZOOM_OUT); 337 } 338 339 /** 340 * @tc.name: KeyEventValueTransformationTest_KeyIntention_017 341 * @tc.desc: Verify key intention 342 * @tc.type: FUNC 343 * @tc.require:SR000HQ0RR 344 */ 345 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_KeyIntention_017, TestSize.Level1) 346 { 347 CALL_DEBUG_ENTER; 348 auto KeyEvent = KeyEvent::Create(); 349 ASSERT_NE(KeyEvent, nullptr); 350 KeyEvent::KeyItem item[KEY_ITEM_SIZE]; 351 item[0].SetKeyCode(KeyEvent::KEYCODE_CTRL_RIGHT); 352 KeyEvent->AddKeyItem(item[0]); 353 item[1].SetKeyCode(KeyEvent::KEYCODE_PLUS); 354 KeyEvent->AddKeyItem(item[1]); 355 int32_t keyIntention = KeyItemsTransKeyIntention(KeyEvent->GetKeyItems()); 356 ASSERT_EQ(keyIntention, KeyEvent::INTENTION_ZOOM_OUT); 357 } 358 359 /** 360 * @tc.name: KeyEventValueTransformationTest_KeyIntention_018 361 * @tc.desc: Verify key intention 362 * @tc.type: FUNC 363 * @tc.require:SR000HQ0RR 364 */ 365 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_KeyIntention_018, TestSize.Level1) 366 { 367 CALL_DEBUG_ENTER; 368 auto KeyEvent = KeyEvent::Create(); 369 ASSERT_NE(KeyEvent, nullptr); 370 KeyEvent::KeyItem item[KEY_ITEM_SIZE]; 371 item[0].SetKeyCode(KeyEvent::KEYCODE_CTRL_LEFT); 372 KeyEvent->AddKeyItem(item[0]); 373 item[1].SetKeyCode(KeyEvent::KEYCODE_NUMPAD_ADD); 374 KeyEvent->AddKeyItem(item[1]); 375 int32_t keyIntention = KeyItemsTransKeyIntention(KeyEvent->GetKeyItems()); 376 ASSERT_EQ(keyIntention, KeyEvent::INTENTION_ZOOM_OUT); 377 } 378 379 /** 380 * @tc.name: KeyEventValueTransformationTest_KeyIntention_019 381 * @tc.desc: Verify key intention 382 * @tc.type: FUNC 383 * @tc.require:SR000HQ0RR 384 */ 385 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_KeyIntention_019, TestSize.Level1) 386 { 387 CALL_DEBUG_ENTER; 388 auto KeyEvent = KeyEvent::Create(); 389 ASSERT_NE(KeyEvent, nullptr); 390 KeyEvent::KeyItem item[KEY_ITEM_SIZE]; 391 item[0].SetKeyCode(KeyEvent::KEYCODE_CTRL_RIGHT); 392 KeyEvent->AddKeyItem(item[0]); 393 item[1].SetKeyCode(KeyEvent::KEYCODE_NUMPAD_ADD); 394 KeyEvent->AddKeyItem(item[1]); 395 int32_t keyIntention = KeyItemsTransKeyIntention(KeyEvent->GetKeyItems()); 396 ASSERT_EQ(keyIntention, KeyEvent::INTENTION_ZOOM_OUT); 397 } 398 399 /** 400 * @tc.name: KeyEventValueTransformationTest_KeyIntention_020 401 * @tc.desc: Verify key intention 402 * @tc.type: FUNC 403 * @tc.require:SR000HQ0RR 404 */ 405 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_KeyIntention_020, TestSize.Level1) 406 { 407 CALL_DEBUG_ENTER; 408 auto KeyEvent = KeyEvent::Create(); 409 ASSERT_NE(KeyEvent, nullptr); 410 KeyEvent::KeyItem item[KEY_ITEM_SIZE]; 411 item[0].SetKeyCode(KeyEvent::KEYCODE_CTRL_LEFT); 412 KeyEvent->AddKeyItem(item[0]); 413 item[1].SetKeyCode(KeyEvent::KEYCODE_MINUS); 414 KeyEvent->AddKeyItem(item[1]); 415 int32_t keyIntention = KeyItemsTransKeyIntention(KeyEvent->GetKeyItems()); 416 ASSERT_EQ(keyIntention, KeyEvent::INTENTION_ZOOM_IN); 417 } 418 419 /** 420 * @tc.name: KeyEventValueTransformationTest_KeyIntention_021 421 * @tc.desc: Verify key intention 422 * @tc.type: FUNC 423 * @tc.require:SR000HQ0RR 424 */ 425 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_KeyIntention_021, TestSize.Level1) 426 { 427 CALL_DEBUG_ENTER; 428 auto KeyEvent = KeyEvent::Create(); 429 ASSERT_NE(KeyEvent, nullptr); 430 KeyEvent::KeyItem item[KEY_ITEM_SIZE]; 431 item[0].SetKeyCode(KeyEvent::KEYCODE_CTRL_RIGHT); 432 KeyEvent->AddKeyItem(item[0]); 433 item[1].SetKeyCode(KeyEvent::KEYCODE_MINUS); 434 KeyEvent->AddKeyItem(item[1]); 435 int32_t keyIntention = KeyItemsTransKeyIntention(KeyEvent->GetKeyItems()); 436 ASSERT_EQ(keyIntention, KeyEvent::INTENTION_ZOOM_IN); 437 } 438 439 /** 440 * @tc.name: KeyEventValueTransformationTest_KeyIntention_022 441 * @tc.desc: Verify key intention 442 * @tc.type: FUNC 443 * @tc.require:SR000HQ0RR 444 */ 445 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_KeyIntention_022, TestSize.Level1) 446 { 447 CALL_DEBUG_ENTER; 448 auto KeyEvent = KeyEvent::Create(); 449 ASSERT_NE(KeyEvent, nullptr); 450 KeyEvent::KeyItem item[KEY_ITEM_SIZE]; 451 item[0].SetKeyCode(KeyEvent::KEYCODE_CTRL_LEFT); 452 KeyEvent->AddKeyItem(item[0]); 453 item[1].SetKeyCode(KeyEvent::KEYCODE_NUMPAD_SUBTRACT); 454 KeyEvent->AddKeyItem(item[1]); 455 int32_t keyIntention = KeyItemsTransKeyIntention(KeyEvent->GetKeyItems()); 456 ASSERT_EQ(keyIntention, KeyEvent::INTENTION_ZOOM_IN); 457 } 458 459 /** 460 * @tc.name: KeyEventValueTransformationTest_KeyIntention_023 461 * @tc.desc: Verify key intention 462 * @tc.type: FUNC 463 * @tc.require:SR000HQ0RR 464 */ 465 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_KeyIntention_023, TestSize.Level1) 466 { 467 CALL_DEBUG_ENTER; 468 auto KeyEvent = KeyEvent::Create(); 469 ASSERT_NE(KeyEvent, nullptr); 470 KeyEvent::KeyItem item[KEY_ITEM_SIZE]; 471 item[0].SetKeyCode(KeyEvent::KEYCODE_CTRL_RIGHT); 472 KeyEvent->AddKeyItem(item[0]); 473 item[1].SetKeyCode(KeyEvent::KEYCODE_NUMPAD_SUBTRACT); 474 KeyEvent->AddKeyItem(item[1]); 475 int32_t keyIntention = KeyItemsTransKeyIntention(KeyEvent->GetKeyItems()); 476 ASSERT_EQ(keyIntention, KeyEvent::INTENTION_ZOOM_IN); 477 } 478 479 /** 480 * @tc.name: KeyEventValueTransformationTest_TransferKeyValue_001 481 * @tc.desc: Transfer key value 482 * @tc.type: FUNC 483 * @tc.require:SR000HQ0RR 484 */ 485 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_TransferKeyValue_001, TestSize.Level1) 486 { 487 CALL_DEBUG_ENTER; 488 auto KeyEvent = KeyEvent::Create(); 489 ASSERT_NE(KeyEvent, nullptr); 490 int32_t nonExistingKeyValue = 999; 491 KeyEventValueTransformation result = TransferKeyValue(nonExistingKeyValue); 492 } 493 494 /** 495 * @tc.name: KeyEventValueTransformationTest_InputTransformationKeyValue_001 496 * @tc.desc: Input transformationKey value 497 * @tc.type: FUNC 498 * @tc.require:SR000HQ0RR 499 */ 500 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_InputTransformationKeyValue_001, 501 TestSize.Level1) 502 { 503 CALL_DEBUG_ENTER; 504 auto KeyEvent = KeyEvent::Create(); 505 ASSERT_NE(KeyEvent, nullptr); 506 int32_t result = InputTransformationKeyValue(0); 507 ASSERT_EQ(result, 240); 508 } 509 } // namespace MMI 510 } // namespace OHOS 511