1 /*
2 * Copyright (c) 2021-2022 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 #include "input_manager.h"
18 #include "input_manager_command.h"
19
20 namespace OHOS {
21 namespace MMI {
22 namespace {
23 using namespace testing::ext;
24 constexpr int32_t KNUCKLE_SIZE = 9;
25 } // namespace
26 class InjectEventTest : public testing::Test {
27 public:
SetUpTestCase(void)28 static void SetUpTestCase(void) {}
TearDownTestCase(void)29 static void TearDownTestCase(void) {}
30 };
31
32 /**
33 * @tc.name:InjectEvent_InjectMouse_001
34 * @tc.desc: test inject mouse move interface
35 * @tc.type: FUNC
36 * @tc.require:AR000GJN3F
37 */
HWTEST_F(InjectEventTest, InjectEvent_InjectMouse_001, TestSize.Level1)38 HWTEST_F(InjectEventTest, InjectEvent_InjectMouse_001, TestSize.Level1)
39 {
40 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>();
41 char command1[] = {"uinput"};
42 char command2[] = {"-M"};
43 char command3[] = {"-m"};
44 char command4[] = {"100"};
45 char command5[] = {"200"};
46 char *argv[] = {command1, command2, command3, command4, command5};
47 int32_t result = inputManagerCommand->ParseCommand(5, argv);
48 EXPECT_EQ(OHOS::ERR_OK, result);
49 }
50
51 /**
52 * @tc.name:InjectEvent_InjectMouse_002
53 * @tc.desc: test inject mouse down interface
54 * @tc.type: FUNC
55 * @tc.require:SR000GGQBJ
56 */
HWTEST_F(InjectEventTest, InjectEvent_InjectMouse_002, TestSize.Level1)57 HWTEST_F(InjectEventTest, InjectEvent_InjectMouse_002, TestSize.Level1)
58 {
59 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>();
60 char command1[] = {"uinput"};
61 char command2[] = {"-M"};
62 char command3[] = {"-d"};
63 char command4[] = {"0"};
64 char *argv[] = {command1, command2, command3, command4};
65 int32_t result = inputManagerCommand->ParseCommand(4, argv);
66 EXPECT_EQ(OHOS::ERR_OK, result);
67 }
68
69 /**
70 * @tc.name:InjectEvent_InjectMouse_003
71 * @tc.desc: test inject mouse up interface
72 * @tc.type: FUNC
73 * @tc.require:SR000GGQBJ
74 */
HWTEST_F(InjectEventTest, InjectEvent_InjectMouse_003, TestSize.Level1)75 HWTEST_F(InjectEventTest, InjectEvent_InjectMouse_003, TestSize.Level1)
76 {
77 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>();
78 char command1[] = {"uinput"};
79 char command2[] = {"-M"};
80 char command3[] = {"-u"};
81 char command4[] = {"0"};
82 char *argv[] = {command1, command2, command3, command4};
83 int32_t result = inputManagerCommand->ParseCommand(4, argv);
84 EXPECT_EQ(OHOS::ERR_OK, result);
85 }
86
87 /**
88 * @tc.name:InjectEvent_InjectMouse_004
89 * @tc.desc: test inject mouse click interface
90 * @tc.type: FUNC
91 * @tc.require:SR000GGQBJ
92 */
HWTEST_F(InjectEventTest, InjectEvent_InjectMouse_004, TestSize.Level1)93 HWTEST_F(InjectEventTest, InjectEvent_InjectMouse_004, TestSize.Level1)
94 {
95 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>();
96 char command1[] = {"uinput"};
97 char command2[] = {"-M"};
98 char command3[] = {"-c"};
99 char command4[] = {"0"};
100 char *argv[] = {command1, command2, command3, command4};
101 int32_t result = inputManagerCommand->ParseCommand(4, argv);
102 EXPECT_EQ(OHOS::ERR_OK, result);
103 }
104
105 /**
106 * @tc.name:InjectEvent_InjectMouse_005
107 * @tc.desc: test inject mouse double click interface
108 * @tc.type: FUNC
109 * @tc.require:SR000GGQBJ
110 */
HWTEST_F(InjectEventTest, InjectEvent_InjectMouse_005, TestSize.Level1)111 HWTEST_F(InjectEventTest, InjectEvent_InjectMouse_005, TestSize.Level1)
112 {
113 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>();
114 char command1[] = {"uinput"};
115 char command2[] = {"-M"};
116 char command3[] = {"-b"};
117 char command4[] = {"200"};
118 char command5[] = {"1250"};
119 char command6[] = {"0"};
120 char command7[] = {"100"};
121 char command8[] = {"300"};
122 char *argv[] = {command1, command2, command3, command4, command5, command6, command7, command8};
123 int32_t result = inputManagerCommand->ParseCommand(8, argv);
124 EXPECT_EQ(OHOS::ERR_OK, result);
125 }
126
127 /**
128 * @tc.name:InjectEvent_InjectMouse_006
129 * @tc.desc: test inject mouse scroll interface
130 * @tc.type: FUNC
131 * @tc.require:SR000GGQBJ
132 */
HWTEST_F(InjectEventTest, InjectEvent_InjectMouse_006, TestSize.Level1)133 HWTEST_F(InjectEventTest, InjectEvent_InjectMouse_006, TestSize.Level1)
134 {
135 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>();
136 char command1[] = {"uinput"};
137 char command2[] = {"-M"};
138 char command3[] = {"-s"};
139 char command4[] = {"50"};
140 char *argv[] = {command1, command2, command3, command4};
141 int32_t result = inputManagerCommand->ParseCommand(4, argv);
142 EXPECT_EQ(OHOS::ERR_OK, result);
143 }
144
145 /**
146 * @tc.name:InjectEvent_InjectMouse_007
147 * @tc.desc: test inject mouse smooth movement interface
148 * @tc.type: FUNC
149 * @tc.require:SR000GGQBJ
150 */
HWTEST_F(InjectEventTest, InjectEvent_InjectMouse_007, TestSize.Level1)151 HWTEST_F(InjectEventTest, InjectEvent_InjectMouse_007, TestSize.Level1)
152 {
153 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>();
154 char command1[] = {"uinput"};
155 char command2[] = {"-M"};
156 char command3[] = {"-m"};
157 char command4[] = {"200"};
158 char command5[] = {"200"};
159 char command6[] = {"200"};
160 char command7[] = {"700"};
161 char command8[] = {"3000"};
162 char command9[] = {"--trace"};
163
164 char *argv[] = {command1, command2, command3, command4, command5, command6, command7, command8, command9};
165 int32_t result = inputManagerCommand->ParseCommand(9, argv);
166 EXPECT_EQ(OHOS::ERR_OK, result);
167 }
168
169 /**
170 * @tc.name:InjectEvent_InjectMouse_008
171 * @tc.desc: test inject mouse soomth drag interface
172 * @tc.type: FUNC
173 * @tc.require:SR000GGQBJ
174 */
HWTEST_F(InjectEventTest, InjectEvent_InjectMouse_008, TestSize.Level1)175 HWTEST_F(InjectEventTest, InjectEvent_InjectMouse_008, TestSize.Level1)
176 {
177 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>();
178 char command1[] = {"uinput"};
179 char command2[] = {"-M"};
180 char command3[] = {"-g"};
181 char command4[] = {"100"};
182 char command5[] = {"200"};
183 char command6[] = {"100"};
184 char command7[] = {"700"};
185 char command8[] = {"3000"};
186
187 char *argv[] = {command1, command2, command3, command4, command5, command6, command7, command8};
188 int32_t result = inputManagerCommand->ParseCommand(8, argv);
189 EXPECT_EQ(OHOS::ERR_OK, result);
190 }
191
192 /**
193 * @tc.name:InjectEvent_InjectKey_001
194 * @tc.desc: test inject key down interface
195 * @tc.type: FUNC
196 * @tc.require:SR000GGQBJ
197 */
HWTEST_F(InjectEventTest, InjectEvent_InjectKey_001, TestSize.Level1)198 HWTEST_F(InjectEventTest, InjectEvent_InjectKey_001, TestSize.Level1)
199 {
200 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>();
201 char command1[] = {"uinput"};
202 char command2[] = {"-K"};
203 char command3[] = {"-d"};
204 char command4[] = {"16"};
205 char *argv[] = {command1, command2, command3, command4};
206 int32_t result = inputManagerCommand->ParseCommand(4, argv);
207 EXPECT_EQ(OHOS::ERR_OK, result);
208 }
209
210 /**
211 * @tc.name:InjectEvent_InjectKey_002
212 * @tc.desc: test inject key up interface
213 * @tc.type: FUNC
214 * @tc.require:SR000GGQBJ
215 */
HWTEST_F(InjectEventTest, InjectEvent_InjectKey_002, TestSize.Level1)216 HWTEST_F(InjectEventTest, InjectEvent_InjectKey_002, TestSize.Level1)
217 {
218 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>();
219 char command1[] = {"uinput"};
220 char command2[] = {"-K"};
221 char command3[] = {"-d"};
222 char command4[] = {"16"};
223 char command5[] = {"-i"};
224 char command6[] = {"1000"};
225 char command7[] = {"-u"};
226 char command8[] = {"16"};
227 char *argv[] = {command1, command2, command3, command4, command5, command6, command7, command8};
228 int32_t result = inputManagerCommand->ParseCommand(8, argv);
229 EXPECT_EQ(OHOS::ERR_OK, result);
230 }
231
232 /**
233 * @tc.name:InjectEvent_InjectKey_003
234 * @tc.desc: test inject press and hold the key interface
235 * @tc.type: FUNC
236 * @tc.require:SR000GGQBJ
237 */
HWTEST_F(InjectEventTest, InjectEvent_InjectKey_003, TestSize.Level1)238 HWTEST_F(InjectEventTest, InjectEvent_InjectKey_003, TestSize.Level1)
239 {
240 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>();
241 char command1[] = {"uinput"};
242 char command2[] = {"-K"};
243 char command3[] = {"-l"};
244 char command4[] = {"17"};
245 char *argv[] = {command1, command2, command3, command4};
246 int32_t result = inputManagerCommand->ParseCommand(4, argv);
247 EXPECT_EQ(OHOS::ERR_OK, result);
248 }
249
250 /**
251 * @tc.name:InjectEvent_InjectKey_004
252 * @tc.desc: test inject another press and hold the key interface, this is pressing '0' and hold 3 seconds
253 * @tc.type: FUNC
254 * @tc.require:
255 */
HWTEST_F(InjectEventTest, InjectEvent_InjectKey_004, TestSize.Level1)256 HWTEST_F(InjectEventTest, InjectEvent_InjectKey_004, TestSize.Level1)
257 {
258 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>();
259 char command1[] = {"uinput"};
260 char command2[] = {"-K"};
261 char command3[] = {"-r"};
262 char command4[] = {"2103"};
263 char *argv[] = {command1, command2, command3, command4};
264 int32_t result = inputManagerCommand->ParseCommand(sizeof(argv) / sizeof(argv[0]), argv);
265 EXPECT_EQ(OHOS::ERR_OK, result);
266 }
267
268 /**
269 * @tc.name:InjectEvent_InjectKey_005
270 * @tc.desc: test inject another press and hold the key interface, this is pressing 'a' and hold 4 seconds
271 * @tc.type: FUNC
272 * @tc.require:
273 */
HWTEST_F(InjectEventTest, InjectEvent_InjectKey_005, TestSize.Level1)274 HWTEST_F(InjectEventTest, InjectEvent_InjectKey_005, TestSize.Level1)
275 {
276 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>();
277 char command1[] = {"uinput"};
278 char command2[] = {"-K"};
279 char command3[] = {"-r"};
280 char command4[] = {"2017"};
281 char command5[] = {"4000"};
282 char *argv[] = {command1, command2, command3, command4, command5};
283 int32_t result = inputManagerCommand->ParseCommand(sizeof(argv) / sizeof(argv[0]), argv);
284 EXPECT_EQ(OHOS::ERR_OK, result);
285 }
286
287 /**
288 * @tc.name:InjectEvent_InjectKey_006
289 * @tc.desc: test inject another press and hold the key interface, this is pressing 'Shift' and hold 3 seconds
290 * @tc.type: FUNC
291 * @tc.require:
292 */
HWTEST_F(InjectEventTest, InjectEvent_InjectKey_006, TestSize.Level1)293 HWTEST_F(InjectEventTest, InjectEvent_InjectKey_006, TestSize.Level1)
294 {
295 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>();
296 char command1[] = {"uinput"};
297 char command2[] = {"-K"};
298 char command3[] = {"-r"};
299 char command4[] = {"2047"};
300 char *argv[] = {command1, command2, command3, command4};
301 int32_t result = inputManagerCommand->ParseCommand(sizeof(argv) / sizeof(argv[0]), argv);
302 EXPECT_EQ(OHOS::ERR_OK, result);
303 }
304
305 /**
306 * @tc.name:InjectEvent_InjectKey_007
307 * @tc.desc: test inject keyevent with the keyintention whether has an expection, this is press 'Ctrl' + '-'
308 * @tc.type: FUNC
309 * @tc.require:
310 */
HWTEST_F(InjectEventTest, InjectEvent_InjectKey_007, TestSize.Level1)311 HWTEST_F(InjectEventTest, InjectEvent_InjectKey_007, TestSize.Level1)
312 {
313 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>();
314 char command1[] = {"uinput"};
315 char command2[] = {"-K"};
316 char command3[] = {"-d"};
317 char command4[] = {"2072"};
318 char command5[] = {"-d"};
319 char command6[] = {"2057"};
320 char *argv[] = {command1, command2, command3, command4, command5, command6};
321 int32_t result = inputManagerCommand->ParseCommand(sizeof(argv) / sizeof(argv[0]), argv);
322 EXPECT_EQ(OHOS::ERR_OK, result);
323 }
324
325 /**
326 * @tc.name:InjectEvent_InjectKey_008
327 * @tc.desc: test inject keyevent with the keyintention whether has an expection, this is press 'Home'
328 * @tc.type: FUNC
329 * @tc.require:
330 */
HWTEST_F(InjectEventTest, InjectEvent_InjectKey_008, TestSize.Level1)331 HWTEST_F(InjectEventTest, InjectEvent_InjectKey_008, TestSize.Level1)
332 {
333 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>();
334 char command1[] = {"uinput"};
335 char command2[] = {"-K"};
336 char command3[] = {"-d"};
337 char command4[] = {"2081"};
338 char *argv[] = {command1, command2, command3, command4};
339 int32_t result = inputManagerCommand->ParseCommand(sizeof(argv) / sizeof(argv[0]), argv);
340 EXPECT_EQ(OHOS::ERR_OK, result);
341 }
342
343 /**
344 * @tc.name:InjectEvent_InjectKey_009
345 * @tc.desc: test inject keyevent of text.
346 * @tc.type: FUNC
347 * @tc.require:
348 */
HWTEST_F(InjectEventTest, InjectEvent_InjectKey_009, TestSize.Level1)349 HWTEST_F(InjectEventTest, InjectEvent_InjectKey_009, TestSize.Level1)
350 {
351 auto inputManagerCommand = std::make_unique<InputManagerCommand>();
352 char command1[] = {"uinput"};
353 char command2[] = {"-K"};
354 char command3[] = {"-t"};
355 char command4[] = {"abc ABC 123 ,-+*/.=~[{}]"};
356 char *argv[] = {command1, command2, command3, command4};
357 int32_t result = inputManagerCommand->ParseCommand(sizeof(argv) / sizeof(argv[0]), argv);
358 EXPECT_EQ(OHOS::ERR_OK, result);
359 }
360
361 /**
362 * @tc.name:InjectEvent_InjectKey_010
363 * @tc.desc: test inject keyevent of illegal character text.
364 * @tc.type: FUNC
365 * @tc.require:
366 */
HWTEST_F(InjectEventTest, InjectEvent_InjectKey_010, TestSize.Level1)367 HWTEST_F(InjectEventTest, InjectEvent_InjectKey_010, TestSize.Level1)
368 {
369 auto inputManagerCommand = std::make_unique<InputManagerCommand>();
370 char command1[] = {"uinput"};
371 char command2[] = {"-K"};
372 char command3[] = {"-t"};
373 char command4[] = {"abc涓€浜屼笁"};
374 char *argv[] = {command1, command2, command3, command4};
375 int32_t result = inputManagerCommand->ParseCommand(sizeof(argv) / sizeof(argv[0]), argv);
376 EXPECT_NE(OHOS::ERR_OK, result);
377 }
378
379 /**
380 * @tc.name:InjectEvent_InjectKey_011
381 * @tc.desc: test inject keyevent of text.
382 * @tc.type: FUNC
383 * @tc.require:
384 */
HWTEST_F(InjectEventTest, InjectEvent_InjectKey_011, TestSize.Level1)385 HWTEST_F(InjectEventTest, InjectEvent_InjectKey_011, TestSize.Level1)
386 {
387 auto inputManagerCommand = std::make_unique<InputManagerCommand>();
388 char command1[] = {"uinput"};
389 char command2[] = {"-K"};
390 char command3[] = {"--text"};
391 char command4[] = {"abc ABC 123 ,-+*/.=~[{}]"};
392 char *argv[] = {command1, command2, command3, command4};
393 int32_t result = inputManagerCommand->ParseCommand(sizeof(argv) / sizeof(argv[0]), argv);
394 EXPECT_EQ(OHOS::ERR_OK, result);
395 }
396
397 /**
398 * @tc.name:InjectEvent_InjectKey_012
399 * @tc.desc: test inject keyevent of illegal character text.
400 * @tc.type: FUNC
401 * @tc.require:
402 */
HWTEST_F(InjectEventTest, InjectEvent_InjectKey_012, TestSize.Level1)403 HWTEST_F(InjectEventTest, InjectEvent_InjectKey_012, TestSize.Level1)
404 {
405 auto inputManagerCommand = std::make_unique<InputManagerCommand>();
406 char command1[] = {"uinput"};
407 char command2[] = {"-K"};
408 char command3[] = {"--text"};
409 char command4[] = {"abc涓€浜屼笁"};
410 char *argv[] = {command1, command2, command3, command4};
411 int32_t result = inputManagerCommand->ParseCommand(sizeof(argv) / sizeof(argv[0]), argv);
412 EXPECT_NE(OHOS::ERR_OK, result);
413 }
414
415 /**
416 * @tc.name:InjectEvent_InjectKey_013
417 * @tc.desc: test inject keyevent of text.
418 * @tc.type: FUNC
419 * @tc.require:
420 */
HWTEST_F(InjectEventTest, InjectEvent_InjectKey_013, TestSize.Level1)421 HWTEST_F(InjectEventTest, InjectEvent_InjectKey_013, TestSize.Level1)
422 {
423 auto inputManagerCommand = std::make_unique<InputManagerCommand>();
424 char command1[] = {"uinput"};
425 char command2[] = {"--keyboard"};
426 char command3[] = {"-t"};
427 char command4[] = {"abc ABC 123 ,-+*/.=~[{}]"};
428 char *argv[] = {command1, command2, command3, command4};
429 int32_t result = inputManagerCommand->ParseCommand(sizeof(argv) / sizeof(argv[0]), argv);
430 EXPECT_EQ(OHOS::ERR_OK, result);
431 }
432
433 /**
434 * @tc.name:InjectEvent_InjectKey_014
435 * @tc.desc: test inject keyevent of text.
436 * @tc.type: FUNC
437 * @tc.require:
438 */
HWTEST_F(InjectEventTest, InjectEvent_InjectKey_014, TestSize.Level1)439 HWTEST_F(InjectEventTest, InjectEvent_InjectKey_014, TestSize.Level1)
440 {
441 auto inputManagerCommand = std::make_unique<InputManagerCommand>();
442 char command1[] = {"uinput"};
443 char command2[] = {"--keyboard"};
444 char command3[] = {"--text"};
445 char command4[] = {"abc ABC 123 ,-+*/.=~[{}]"};
446 char *argv[] = {command1, command2, command3, command4};
447 int32_t result = inputManagerCommand->ParseCommand(sizeof(argv) / sizeof(argv[0]), argv);
448 EXPECT_EQ(OHOS::ERR_OK, result);
449 }
450
451 /**
452 * @tc.name:InjectEvent_InjectKey_015
453 * @tc.desc: test inject keyevent of text.
454 * @tc.type: FUNC
455 * @tc.require:
456 */
HWTEST_F(InjectEventTest, InjectEvent_InjectKey_015, TestSize.Level1)457 HWTEST_F(InjectEventTest, InjectEvent_InjectKey_015, TestSize.Level1)
458 {
459 auto inputManagerCommand = std::make_unique<InputManagerCommand>();
460 char command1[] = {"uinput"};
461 char command2[] = {"-K"};
462 char command3[] = {"-t"};
463 char command4[2002] = { 0 };
464
465 for (int i = 0; i < 2001; ++i) {
466 command4[i] = 'a';
467 }
468 command4[2001] = '\n';
469 char *argv[] = {command1, command2, command3, command4};
470 int32_t result = inputManagerCommand->ParseCommand(4, argv);
471 EXPECT_EQ(OHOS::ERR_OK, result);
472 }
473
474 /**
475 * @tc.name:InjectEvent_InjectKey_016
476 * @tc.desc: test inject keyevent of text. Combined commands is not supported.
477 * @tc.type: FUNC
478 * @tc.require:
479 */
HWTEST_F(InjectEventTest, InjectEvent_InjectKey_016, TestSize.Level1)480 HWTEST_F(InjectEventTest, InjectEvent_InjectKey_016, TestSize.Level1)
481 {
482 auto inputManagerCommand = std::make_unique<InputManagerCommand>();
483 char command1[] = {"uinput"};
484 char command2[] = {"-K"};
485 char command3[] = {"-d"};
486 char command4[] = {"2017"};
487 char command5[] = {"-t"};
488 char command6[] = {"abc"};
489 char *argv[] = {command1, command2, command3, command4, command5, command6};
490 int32_t result = inputManagerCommand->ParseCommand(sizeof(argv) / sizeof(argv[0]), argv);
491 EXPECT_NE(OHOS::ERR_OK, result);
492 }
493
494 /**
495 * @tc.name:InjectEvent_InjectKey_017
496 * @tc.desc: test inject keyevent of text. Combined commands is not supported.
497 * @tc.type: FUNC
498 * @tc.require:
499 */
HWTEST_F(InjectEventTest, InjectEvent_InjectKey_017, TestSize.Level1)500 HWTEST_F(InjectEventTest, InjectEvent_InjectKey_017, TestSize.Level1)
501 {
502 auto inputManagerCommand = std::make_unique<InputManagerCommand>();
503 char command1[] = {"uinput"};
504 char command2[] = {"-K"};
505 char command3[] = {"-t"};
506 char command4[] = {"abc"};
507 char command5[] = {"-d"};
508 char command6[] = {"2017"};
509 char *argv[] = {command1, command2, command3, command4, command5, command6};
510 int32_t result = inputManagerCommand->ParseCommand(sizeof(argv) / sizeof(argv[0]), argv);
511 EXPECT_NE(OHOS::ERR_OK, result);
512 }
513
514 /**
515 * @tc.name:InjectEvent_InjectKey_018
516 * @tc.desc: test inject keyevent of text. Combined commands is not supported.
517 * @tc.type: FUNC
518 * @tc.require:
519 */
HWTEST_F(InjectEventTest, InjectEvent_InjectKey_018, TestSize.Level1)520 HWTEST_F(InjectEventTest, InjectEvent_InjectKey_018, TestSize.Level1)
521 {
522 auto inputManagerCommand = std::make_unique<InputManagerCommand>();
523 char command1[] = {"uinput"};
524 char command2[] = {"-K"};
525 char command3[] = {"-t"};
526 char command4[] = {"abc"};
527 char command5[] = {"-t"};
528 char command6[] = {"def"};
529 char *argv[] = {command1, command2, command3, command4, command5, command6};
530 int32_t result = inputManagerCommand->ParseCommand(sizeof(argv) / sizeof(argv[0]), argv);
531 EXPECT_NE(OHOS::ERR_OK, result);
532 }
533
534 /**
535 * @tc.name:InjectEvent_InjectTouch_001
536 * @tc.desc: test inject touch screen smooth movement interface
537 * @tc.type: FUNC
538 * @tc.require:SR000GGQBJ
539 */
HWTEST_F(InjectEventTest, InjectEvent_InjectTouch_001, TestSize.Level1)540 HWTEST_F(InjectEventTest, InjectEvent_InjectTouch_001, TestSize.Level1)
541 {
542 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>();
543 char command1[] = {"uinput"};
544 char command2[] = {"-T"};
545 char command3[] = {"-m"};
546 char command4[] = {"100"};
547 char command5[] = {"200"};
548 char command6[] = {"100"};
549 char command7[] = {"600"};
550 char command8[] = {"1000"};
551 char *argv[] = {command1, command2, command3, command4, command5, command6, command7, command8};
552 int32_t result = inputManagerCommand->ParseCommand(8, argv);
553 EXPECT_EQ(OHOS::ERR_OK, result);
554 }
555
556 /**
557 * @tc.name:InjectEvent_InjectTouch_002
558 * @tc.desc: test inject touch down interface
559 * @tc.type: FUNC
560 * @tc.require:SR000GGQBJ
561 */
HWTEST_F(InjectEventTest, InjectEvent_InjectTouch_002, TestSize.Level1)562 HWTEST_F(InjectEventTest, InjectEvent_InjectTouch_002, TestSize.Level1)
563 {
564 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>();
565 char command1[] = {"uinput"};
566 char command2[] = {"-T"};
567 char command3[] = {"-d"};
568 char command4[] = {"100"};
569 char command5[] = {"200"};
570 char *argv[] = {command1, command2, command3, command4, command5};
571 int32_t result = inputManagerCommand->ParseCommand(5, argv);
572 EXPECT_EQ(OHOS::ERR_OK, result);
573 }
574
575 /**
576 * @tc.name:InjectEvent_InjectTouch_003
577 * @tc.desc: test inject touch up interface
578 * @tc.type: FUNC
579 * @tc.require:SR000GGQBJ
580 */
HWTEST_F(InjectEventTest, InjectEvent_InjectTouch_003, TestSize.Level1)581 HWTEST_F(InjectEventTest, InjectEvent_InjectTouch_003, TestSize.Level1)
582 {
583 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>();
584 char command1[] = {"uinput"};
585 char command2[] = {"-T"};
586 char command3[] = {"-u"};
587 char command4[] = {"100"};
588 char command5[] = {"200"};
589 char *argv[] = {command1, command2, command3, command4, command5};
590 int32_t result = inputManagerCommand->ParseCommand(5, argv);
591 EXPECT_EQ(OHOS::ERR_OK, result);
592 }
593
594 /**
595 * @tc.name:InjectEvent_InjectTouch_004
596 * @tc.desc: test inject touch click interface
597 * @tc.type: FUNC
598 * @tc.require:SR000GGQBJ
599 */
HWTEST_F(InjectEventTest, InjectEvent_InjectTouch_004, TestSize.Level1)600 HWTEST_F(InjectEventTest, InjectEvent_InjectTouch_004, TestSize.Level1)
601 {
602 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>();
603 char command1[] = {"uinput"};
604 char command2[] = {"-T"};
605 char command3[] = {"-c"};
606 char command4[] = {"200"};
607 char command5[] = {"1250"};
608 char command6[] = {"200"};
609 char *argv[] = {command1, command2, command3, command4, command5, command6};
610 int32_t result = inputManagerCommand->ParseCommand(5, argv);
611 EXPECT_EQ(OHOS::ERR_OK, result);
612 }
613
614 /**
615 * @tc.name:InjectEvent_InjectTouch_005
616 * @tc.desc: test inject touch drag interface
617 * @tc.type: FUNC
618 * @tc.require:SR000GGQBJ
619 */
HWTEST_F(InjectEventTest, InjectEvent_InjectTouch_005, TestSize.Level1)620 HWTEST_F(InjectEventTest, InjectEvent_InjectTouch_005, TestSize.Level1)
621 {
622 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>();
623 char command1[] = {"uinput"};
624 char command2[] = {"-T"};
625 char command3[] = {"-g"};
626 char command4[] = {"100"};
627 char command5[] = {"200"};
628 char command6[] = {"100"};
629 char command7[] = {"600"};
630 char command8[] = {"700"};
631 char command9[] = {"3000"};
632 char *argv[] = {command1, command2, command3, command4, command5, command6, command7, command8, command9};
633 int32_t result = inputManagerCommand->ParseCommand(9, argv);
634 EXPECT_EQ(OHOS::ERR_OK, result);
635 }
636
637 /**
638 * @tc.name:InjectEvent_InjectKnuckle_001
639 * @tc.desc: test inject single knuckle double click interface
640 * @tc.type: FUNC
641 * @tc.require:
642 */
HWTEST_F(InjectEventTest, InjectEvent_InjectKnuckle_001, TestSize.Level1)643 HWTEST_F(InjectEventTest, InjectEvent_InjectKnuckle_001, TestSize.Level1)
644 {
645 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>();
646 char command1[] = {"uinput"};
647 char command2[] = {"-T"};
648 char command3[] = {"-k"};
649 char command4[] = {"-s"};
650 char command5[] = {"100"};
651 char command6[] = {"200"};
652 char command7[] = {"130"};
653 char command8[] = {"230"};
654 char command9[] = {"200"};
655 char *argv[] = {command1, command2, command3, command4, command5, command6, command7, command8, command9};
656 int32_t result = inputManagerCommand->ParseCommand(KNUCKLE_SIZE, argv);
657 EXPECT_EQ(OHOS::ERR_OK, result);
658 }
659
660 /**
661 * @tc.name:InjectEvent_InjectKnuckle_002
662 * @tc.desc: test inject double knuckle double click interface
663 * @tc.type: FUNC
664 * @tc.require:
665 */
HWTEST_F(InjectEventTest, InjectEvent_InjectKnuckle_002, TestSize.Level1)666 HWTEST_F(InjectEventTest, InjectEvent_InjectKnuckle_002, TestSize.Level1)
667 {
668 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>();
669 char command1[] = {"uinput"};
670 char command2[] = {"-T"};
671 char command3[] = {"-k"};
672 char command4[] = {"-d"};
673 char command5[] = {"200"};
674 char command6[] = {"300"};
675 char command7[] = {"230"};
676 char command8[] = {"330"};
677 char command9[] = {"200"};
678 char *argv[] = {command1, command2, command3, command4, command5, command6, command7, command8, command9};
679 int32_t result = inputManagerCommand->ParseCommand(KNUCKLE_SIZE, argv);
680 EXPECT_EQ(OHOS::ERR_OK, result);
681 }
682
683 /**
684 * @tc.name:InjectEvent_InjectTouchPad_001
685 * @tc.desc: test inject touchpad two finger pinch, scale is 2.05
686 * @tc.type: FUNC
687 * @tc.require:
688 */
HWTEST_F(InjectEventTest, InjectEvent_InjectTouchPad_001, TestSize.Level1)689 HWTEST_F(InjectEventTest, InjectEvent_InjectTouchPad_001, TestSize.Level1)
690 {
691 auto inputManagerCommand = std::make_unique<InputManagerCommand>();
692 char command1[] = {"uinput"};
693 char command2[] = {"-P"};
694 char command3[] = {"-p"};
695 char command4[] = {"2"};
696 char command5[] = {"205"};
697 char *argv[] = {command1, command2, command3, command4, command5};
698 int32_t result = inputManagerCommand->ParseCommand(sizeof(argv) / sizeof(argv[0]), argv);
699 EXPECT_NE(OHOS::ERR_OK, result);
700 }
701
702 /**
703 * @tc.name:InjectEvent_InjectTouchPad_002
704 * @tc.desc: test inject touchpad third finger pinch, scale is 3.05
705 * @tc.type: FUNC
706 * @tc.require:
707 */
HWTEST_F(InjectEventTest, InjectEvent_InjectTouchPad_002, TestSize.Level1)708 HWTEST_F(InjectEventTest, InjectEvent_InjectTouchPad_002, TestSize.Level1)
709 {
710 auto inputManagerCommand = std::make_unique<InputManagerCommand>();
711 char command1[] = {"uinput"};
712 char command2[] = {"-P"};
713 char command3[] = {"-p"};
714 char command4[] = {"3"};
715 char command5[] = {"305"};
716 char *argv[] = {command1, command2, command3, command4, command5};
717 int32_t result = inputManagerCommand->ParseCommand(sizeof(argv) / sizeof(argv[0]), argv);
718 EXPECT_EQ(OHOS::ERR_OK, result);
719 }
720
721 /**
722 * @tc.name:InjectEvent_InjectStylus_001
723 * @tc.desc: test inject stylus smooth movement interface
724 * @tc.type: FUNC
725 * @tc.require:
726 */
HWTEST_F(InjectEventTest, InjectEvent_InjectStylus_001, TestSize.Level1)727 HWTEST_F(InjectEventTest, InjectEvent_InjectStylus_001, TestSize.Level1)
728 {
729 auto inputManagerCommand = std::make_unique<InputManagerCommand>();
730 char command1[] = {"uinput"};
731 char command2[] = {"-S"};
732 char command3[] = {"-m"};
733 char command4[] = {"100"};
734 char command5[] = {"200"};
735 char command6[] = {"100"};
736 char command7[] = {"600"};
737 char command8[] = {"1000"};
738 char *argv[] = {command1, command2, command3, command4, command5, command6, command7, command8};
739 int32_t result = inputManagerCommand->ParseCommand(sizeof(argv) / sizeof(argv[0]), argv);
740 EXPECT_EQ(OHOS::ERR_OK, result);
741 }
742
743 /**
744 * @tc.name:InjectEvent_InjectStylus_002
745 * @tc.desc: test inject stylus click interface
746 * @tc.type: FUNC
747 * @tc.require:
748 */
HWTEST_F(InjectEventTest, InjectEvent_InjectStylus_002, TestSize.Level1)749 HWTEST_F(InjectEventTest, InjectEvent_InjectStylus_002, TestSize.Level1)
750 {
751 auto inputManagerCommand = std::make_unique<InputManagerCommand>();
752 char command1[] = {"uinput"};
753 char command2[] = {"-S"};
754 char command3[] = {"-c"};
755 char command4[] = {"200"};
756 char command5[] = {"300"};
757 char *argv[] = {command1, command2, command3, command4, command5};
758 int32_t result = inputManagerCommand->ParseCommand(sizeof(argv) / sizeof(argv[0]), argv);
759 EXPECT_EQ(OHOS::ERR_OK, result);
760 }
761
762 /**
763 * @tc.name:InjectEvent_InjectTouchPad_013
764 * @tc.desc: test touchpad rotate interface
765 * @tc.type: FUNC
766 * @tc.require:
767 */
HWTEST_F(InjectEventTest, InjectEvent_InjectTouchPad_013, TestSize.Level1)768 HWTEST_F(InjectEventTest, InjectEvent_InjectTouchPad_013, TestSize.Level1)
769 {
770 std::unique_ptr<InputManagerCommand> inputManagerCommand = std::make_unique<InputManagerCommand>();
771 char command1[] = {"uinput"};
772 char command2[] = {"-P"};
773 char command3[] = {"-r"};
774 char command4[] = {"90"};
775 char *argv[] = {command1, command2, command3, command4};
776 int32_t result = inputManagerCommand->ParseCommand(sizeof(argv) / sizeof(argv[0]), argv);
777 EXPECT_EQ(OHOS::ERR_OK, result);
778 }
779 } // namespace MMI
780 } // namespace OHOS