• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-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 "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_TransferKeyValue_002
496  * @tc.desc: Transfer F1 key value
497  * @tc.type: FUNC
498  * @tc.require:
499  */
500 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_TransferKeyValue_002, TestSize.Level1)
501 {
502     CALL_DEBUG_ENTER;
503     auto KeyEvent = KeyEvent::Create();
504     ASSERT_NE(KeyEvent, nullptr);
505     int32_t keyValue = 59;
506     KeyEventValueTransformation result = TransferKeyValue(keyValue);
507     EXPECT_EQ(result.sysKeyValue, KeyEvent::KEYCODE_F1);
508 }
509 
510 /**
511  * @tc.name: KeyEventValueTransformationTest_TransferKeyValue_003
512  * @tc.desc: Transfer F2 key value
513  * @tc.type: FUNC
514  * @tc.require:
515  */
516 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_TransferKeyValue_003, TestSize.Level1)
517 {
518     CALL_DEBUG_ENTER;
519     auto KeyEvent = KeyEvent::Create();
520     ASSERT_NE(KeyEvent, nullptr);
521     int32_t keyValue = 60;
522     KeyEventValueTransformation result = TransferKeyValue(keyValue);
523     EXPECT_EQ(result.sysKeyValue, KeyEvent::KEYCODE_F2);
524 }
525 
526 /**
527  * @tc.name: KeyEventValueTransformationTest_TransferKeyValue_004
528  * @tc.desc: Transfer F3 key value
529  * @tc.type: FUNC
530  * @tc.require:
531  */
532 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_TransferKeyValue_004, TestSize.Level1)
533 {
534     CALL_DEBUG_ENTER;
535     auto KeyEvent = KeyEvent::Create();
536     ASSERT_NE(KeyEvent, nullptr);
537     int32_t keyValue = 61;
538     KeyEventValueTransformation result = TransferKeyValue(keyValue);
539     EXPECT_EQ(result.sysKeyValue, KeyEvent::KEYCODE_F3);
540 }
541 
542 /**
543  * @tc.name: KeyEventValueTransformationTest_TransferKeyValue_005
544  * @tc.desc: Transfer F4 key value
545  * @tc.type: FUNC
546  * @tc.require:
547  */
548 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_TransferKeyValue_005, TestSize.Level1)
549 {
550     CALL_DEBUG_ENTER;
551     auto KeyEvent = KeyEvent::Create();
552     ASSERT_NE(KeyEvent, nullptr);
553     int32_t keyValue = 62;
554     KeyEventValueTransformation result = TransferKeyValue(keyValue);
555     EXPECT_EQ(result.sysKeyValue, KeyEvent::KEYCODE_F4);
556 }
557 
558 /**
559  * @tc.name: KeyEventValueTransformationTest_TransferKeyValue_006
560  * @tc.desc: Transfer F5 key value
561  * @tc.type: FUNC
562  * @tc.require:
563  */
564 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_TransferKeyValue_006, TestSize.Level1)
565 {
566     CALL_DEBUG_ENTER;
567     auto KeyEvent = KeyEvent::Create();
568     ASSERT_NE(KeyEvent, nullptr);
569     int32_t keyValue = 63;
570     KeyEventValueTransformation result = TransferKeyValue(keyValue);
571     EXPECT_EQ(result.sysKeyValue, KeyEvent::KEYCODE_F5);
572 }
573 
574 /**
575  * @tc.name: KeyEventValueTransformationTest_TransferKeyValue_007
576  * @tc.desc: Transfer F6 key value
577  * @tc.type: FUNC
578  * @tc.require:
579  */
580 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_TransferKeyValue_007, TestSize.Level1)
581 {
582     CALL_DEBUG_ENTER;
583     auto KeyEvent = KeyEvent::Create();
584     ASSERT_NE(KeyEvent, nullptr);
585     int32_t keyValue = 64;
586     KeyEventValueTransformation result = TransferKeyValue(keyValue);
587     EXPECT_EQ(result.sysKeyValue, KeyEvent::KEYCODE_F6);
588 }
589 
590 /**
591  * @tc.name: KeyEventValueTransformationTest_TransferKeyValue_008
592  * @tc.desc: Transfer F7 key value
593  * @tc.type: FUNC
594  * @tc.require:
595  */
596 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_TransferKeyValue_008, TestSize.Level1)
597 {
598     CALL_DEBUG_ENTER;
599     auto KeyEvent = KeyEvent::Create();
600     ASSERT_NE(KeyEvent, nullptr);
601     int32_t keyValue = 65;
602     KeyEventValueTransformation result = TransferKeyValue(keyValue);
603     EXPECT_EQ(result.sysKeyValue, KeyEvent::KEYCODE_F7);
604 }
605 
606 /**
607  * @tc.name: KeyEventValueTransformationTest_TransferKeyValue_009
608  * @tc.desc: Transfer F8 key value
609  * @tc.type: FUNC
610  * @tc.require:
611  */
612 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_TransferKeyValue_009, TestSize.Level1)
613 {
614     CALL_DEBUG_ENTER;
615     auto KeyEvent = KeyEvent::Create();
616     ASSERT_NE(KeyEvent, nullptr);
617     int32_t keyValue = 66;
618     KeyEventValueTransformation result = TransferKeyValue(keyValue);
619     EXPECT_EQ(result.sysKeyValue, KeyEvent::KEYCODE_F8);
620 }
621 
622 /**
623  * @tc.name: KeyEventValueTransformationTest_TransferKeyValue_010
624  * @tc.desc: Transfer F9 key value
625  * @tc.type: FUNC
626  * @tc.require:
627  */
628 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_TransferKeyValue_010, TestSize.Level1)
629 {
630     CALL_DEBUG_ENTER;
631     auto KeyEvent = KeyEvent::Create();
632     ASSERT_NE(KeyEvent, nullptr);
633     int32_t keyValue = 67;
634     KeyEventValueTransformation result = TransferKeyValue(keyValue);
635     EXPECT_EQ(result.sysKeyValue, KeyEvent::KEYCODE_F9);
636 }
637 
638 /**
639  * @tc.name: KeyEventValueTransformationTest_TransferKeyValue_011
640  * @tc.desc: Transfer F10 key value
641  * @tc.type: FUNC
642  * @tc.require:
643  */
644 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_TransferKeyValue_011, TestSize.Level1)
645 {
646     CALL_DEBUG_ENTER;
647     auto KeyEvent = KeyEvent::Create();
648     ASSERT_NE(KeyEvent, nullptr);
649     int32_t keyValue = 68;
650     KeyEventValueTransformation result = TransferKeyValue(keyValue);
651     EXPECT_EQ(result.sysKeyValue, KeyEvent::KEYCODE_F10);
652 }
653 
654 /**
655  * @tc.name: KeyEventValueTransformationTest_TransferKeyValue_012
656  * @tc.desc: Transfer F11 key value
657  * @tc.type: FUNC
658  * @tc.require:
659  */
660 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_TransferKeyValue_012, TestSize.Level1)
661 {
662     CALL_DEBUG_ENTER;
663     auto KeyEvent = KeyEvent::Create();
664     ASSERT_NE(KeyEvent, nullptr);
665     int32_t keyValue = 87;
666     KeyEventValueTransformation result = TransferKeyValue(keyValue);
667     EXPECT_EQ(result.sysKeyValue, KeyEvent::KEYCODE_F11);
668 }
669 
670 /**
671  * @tc.name: KeyEventValueTransformationTest_TransferKeyValue_013
672  * @tc.desc: Transfer F12 key value
673  * @tc.type: FUNC
674  * @tc.require:
675  */
676 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_TransferKeyValue_013, TestSize.Level1)
677 {
678     CALL_DEBUG_ENTER;
679     auto KeyEvent = KeyEvent::Create();
680     ASSERT_NE(KeyEvent, nullptr);
681     int32_t keyValue = 88;
682     KeyEventValueTransformation result = TransferKeyValue(keyValue);
683     EXPECT_EQ(result.sysKeyValue, KeyEvent::KEYCODE_F12);
684 }
685 
686 /**
687  * @tc.name: KeyEventValueTransformationTest_TransferKeyValue_014
688  * @tc.desc: Transfer Brightness Down key value
689  * @tc.type: FUNC
690  * @tc.require:
691  */
692 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_TransferKeyValue_014, TestSize.Level1)
693 {
694     CALL_DEBUG_ENTER;
695     auto KeyEvent = KeyEvent::Create();
696     ASSERT_NE(KeyEvent, nullptr);
697     int32_t keyValue = 224;
698     KeyEventValueTransformation result = TransferKeyValue(keyValue);
699     EXPECT_EQ(result.sysKeyValue, KeyEvent::KEYCODE_BRIGHTNESS_DOWN);
700 }
701 
702 /**
703  * @tc.name: KeyEventValueTransformationTest_TransferKeyValue_015
704  * @tc.desc: Transfer Brightness Up key value
705  * @tc.type: FUNC
706  * @tc.require:
707  */
708 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_TransferKeyValue_015, TestSize.Level1)
709 {
710     CALL_DEBUG_ENTER;
711     auto KeyEvent = KeyEvent::Create();
712     ASSERT_NE(KeyEvent, nullptr);
713     int32_t keyValue = 225;
714     KeyEventValueTransformation result = TransferKeyValue(keyValue);
715     EXPECT_EQ(result.sysKeyValue, KeyEvent::KEYCODE_BRIGHTNESS_UP);
716 }
717 
718 /**
719  * @tc.name: KeyEventValueTransformationTest_TransferKeyValue_016
720  * @tc.desc: Transfer Volume Mute key value
721  * @tc.type: FUNC
722  * @tc.require:
723  */
724 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_TransferKeyValue_016, TestSize.Level1)
725 {
726     CALL_DEBUG_ENTER;
727     auto KeyEvent = KeyEvent::Create();
728     ASSERT_NE(KeyEvent, nullptr);
729     int32_t keyValue = 113;
730     KeyEventValueTransformation result = TransferKeyValue(keyValue);
731     EXPECT_EQ(result.sysKeyValue, KeyEvent::KEYCODE_VOLUME_MUTE);
732 }
733 
734 /**
735  * @tc.name: KeyEventValueTransformationTest_TransferKeyValue_017
736  * @tc.desc: Transfer Volume Down key value
737  * @tc.type: FUNC
738  * @tc.require:
739  */
740 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_TransferKeyValue_017, TestSize.Level1)
741 {
742     CALL_DEBUG_ENTER;
743     auto KeyEvent = KeyEvent::Create();
744     ASSERT_NE(KeyEvent, nullptr);
745     int32_t keyValue = 114;
746     KeyEventValueTransformation result = TransferKeyValue(keyValue);
747     EXPECT_EQ(result.sysKeyValue, KeyEvent::KEYCODE_VOLUME_DOWN);
748 }
749 
750 /**
751  * @tc.name: KeyEventValueTransformationTest_TransferKeyValue_018
752  * @tc.desc: Transfer Volume Up key value
753  * @tc.type: FUNC
754  * @tc.require:
755  */
756 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_TransferKeyValue_018, TestSize.Level1)
757 {
758     CALL_DEBUG_ENTER;
759     auto KeyEvent = KeyEvent::Create();
760     ASSERT_NE(KeyEvent, nullptr);
761     int32_t keyValue = 115;
762     KeyEventValueTransformation result = TransferKeyValue(keyValue);
763     EXPECT_EQ(result.sysKeyValue, KeyEvent::KEYCODE_VOLUME_UP);
764 }
765 
766 /**
767  * @tc.name: KeyEventValueTransformationTest_TransferKeyValue_019
768  * @tc.desc: Transfer Mute key value
769  * @tc.type: FUNC
770  * @tc.require:
771  */
772 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_TransferKeyValue_019, TestSize.Level1)
773 {
774     CALL_DEBUG_ENTER;
775     auto KeyEvent = KeyEvent::Create();
776     ASSERT_NE(KeyEvent, nullptr);
777     int32_t keyValue = 248;
778     KeyEventValueTransformation result = TransferKeyValue(keyValue);
779     EXPECT_EQ(result.sysKeyValue, KeyEvent::KEYCODE_MUTE);
780 }
781 
782 /**
783  * @tc.name: KeyEventValueTransformationTest_TransferKeyValue_020
784  * @tc.desc: Transfer Switch Video Mode key value
785  * @tc.type: FUNC
786  * @tc.require:
787  */
788 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_TransferKeyValue_020, TestSize.Level1)
789 {
790     CALL_DEBUG_ENTER;
791     auto KeyEvent = KeyEvent::Create();
792     ASSERT_NE(KeyEvent, nullptr);
793     int32_t keyValue = 595;
794     KeyEventValueTransformation result = TransferKeyValue(keyValue);
795     EXPECT_EQ(result.sysKeyValue, KeyEvent::KEYCODE_SWITCHVIDEOMODE);
796 }
797 
798 /**
799  * @tc.name: KeyEventValueTransformationTest_TransferKeyValue_021
800  * @tc.desc: Transfer Search key value
801  * @tc.type: FUNC
802  * @tc.require:
803  */
804 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_TransferKeyValue_021, TestSize.Level1)
805 {
806     CALL_DEBUG_ENTER;
807     auto KeyEvent = KeyEvent::Create();
808     ASSERT_NE(KeyEvent, nullptr);
809     int32_t keyValue = 594;
810     KeyEventValueTransformation result = TransferKeyValue(keyValue);
811     EXPECT_EQ(result.sysKeyValue, KeyEvent::KEYCODE_SEARCH);
812 }
813 
814 /**
815  * @tc.name: KeyEventValueTransformationTest_TransferKeyValue_022
816  * @tc.desc: Transfer Media Record key value
817  * @tc.type: FUNC
818  * @tc.require:
819  */
820 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_TransferKeyValue_022, TestSize.Level1)
821 {
822     CALL_DEBUG_ENTER;
823     auto KeyEvent = KeyEvent::Create();
824     ASSERT_NE(KeyEvent, nullptr);
825     int32_t keyValue = 597;
826     KeyEventValueTransformation result = TransferKeyValue(keyValue);
827     EXPECT_EQ(result.sysKeyValue, KeyEvent::KEYCODE_MEDIA_RECORD);
828 }
829 
830 /**
831  * @tc.name: KeyEventValueTransformationTest_TransferKeyValue_023
832  * @tc.desc: Transfer Sysrq key value
833  * @tc.type: FUNC
834  * @tc.require:
835  */
836 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_TransferKeyValue_023, TestSize.Level1)
837 {
838     CALL_DEBUG_ENTER;
839     auto KeyEvent = KeyEvent::Create();
840     ASSERT_NE(KeyEvent, nullptr);
841     int32_t keyValue = 99;
842     KeyEventValueTransformation result = TransferKeyValue(keyValue);
843     EXPECT_EQ(result.sysKeyValue, KeyEvent::KEYCODE_SYSRQ);
844 }
845 
846 /**
847  * @tc.name: KeyEventValueTransformationTest_TransferKeyValue_024
848  * @tc.desc: Transfer Insert key value
849  * @tc.type: FUNC
850  * @tc.require:
851  */
852 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_TransferKeyValue_024, TestSize.Level1)
853 {
854     CALL_DEBUG_ENTER;
855     auto KeyEvent = KeyEvent::Create();
856     ASSERT_NE(KeyEvent, nullptr);
857     int32_t keyValue = 110;
858     KeyEventValueTransformation result = TransferKeyValue(keyValue);
859     EXPECT_EQ(result.sysKeyValue, KeyEvent::KEYCODE_INSERT);
860 }
861 
862 /**
863  * @tc.name: KeyEventValueTransformationTest_TransferKeyValue_025
864  * @tc.desc: Transfer Sound key value
865  * @tc.type: FUNC
866  * @tc.require:
867  */
868 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_TransferKeyValue_025, TestSize.Level1)
869 {
870     CALL_DEBUG_ENTER;
871     auto KeyEvent = KeyEvent::Create();
872     ASSERT_NE(KeyEvent, nullptr);
873     int32_t keyValue = 249;
874     KeyEventValueTransformation result = TransferKeyValue(keyValue);
875     EXPECT_EQ(result.sysKeyValue, KeyEvent::KEYCODE_SOUND);
876 }
877 
878 /**
879  * @tc.name: KeyEventValueTransformationTest_TransferKeyValue_026
880  * @tc.desc: Transfer Assistant key value
881  * @tc.type: FUNC
882  * @tc.require:
883  */
884 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_TransferKeyValue_026, TestSize.Level1)
885 {
886     CALL_DEBUG_ENTER;
887     auto KeyEvent = KeyEvent::Create();
888     ASSERT_NE(KeyEvent, nullptr);
889     int32_t keyValue = 251;
890     KeyEventValueTransformation result = TransferKeyValue(keyValue);
891     EXPECT_EQ(result.sysKeyValue, KeyEvent::KEYCODE_ASSISTANT);
892 }
893 
894 /**
895  * @tc.name: KeyEventValueTransformationTest_InputTransformationKeyValue_001
896  * @tc.desc: Input transformationKey value
897  * @tc.type: FUNC
898  * @tc.require:SR000HQ0RR
899  */
900 HWTEST_F(KeyEventValueTransformationTest, KeyEventValueTransformationTest_InputTransformationKeyValue_001,
901      TestSize.Level1)
902 {
903     CALL_DEBUG_ENTER;
904     auto KeyEvent = KeyEvent::Create();
905     ASSERT_NE(KeyEvent, nullptr);
906     int32_t result = InputTransformationKeyValue(0);
907     ASSERT_EQ(result, 240);
908 }
909 } // namespace MMI
910 } // namespace OHOS
911