• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 #define protected public
19 #include "ability_command.h"
20 #undef protected
21 #include "mock_ability_manager_stub.h"
22 #define private public
23 #include "ability_manager_client.h"
24 #undef private
25 #include "ability_manager_interface.h"
26 
27 using namespace testing::ext;
28 using namespace OHOS;
29 using namespace OHOS::AAFwk;
30 
31 namespace {
32 const std::string STRING_DEVICE = "device";
33 const std::string STRING_ABILITY_NAME = "ability";
34 const std::string STRING_ABILITY_NAME_INVALID = "invalid_ability";
35 const std::string STRING_BUNDLE_NAME = "bundle";
36 const std::string STRING_BUNDLE_NAME_INVALID = "invalid_bundle";
37 const std::string STRING_RECORD_ID = "1024";
38 const std::string STRING_RECORD_ID_INVALID = "2048";
39 const std::string STRING_STATE_ON = "on";
40 const std::string STRING_STATE_ON_INVALID = "invalid_on";
41 const std::string STRING_STATE_OFF = "off";
42 const std::string STRING_STATE_OFF_INVALID = "invalid_off";
43 const std::string STRING_INVALID_PARAMETER_INTEGER_OPTION = "invalid parameter invalid for integer option";
44 const std::string STRING_INVALID_PARAMETER_BOOL_OPTION = "invalid parameter invalid for bool option";
45 const std::string STRING_INVALID_NUMBER_INTEGER_OPTION = "invalid number of parameters for option --pi";
46 const std::string STRING_INVALID_NUMBER_BOOL_OPTION = "invalid number of parameters for option --pb";
47 const std::string STRING_INVALID_NUMBER_STRING_OPTION = "invalid number of parameters for option --ps";
48 const std::string STRING_INVALID_NUMBER_NULL_STRING_OPTION = "invalid number of parameters for option --psn";
49 }  // namespace
50 
51 class AaCommandStartTest : public ::testing::Test {
52 public:
53     static void SetUpTestCase();
54     static void TearDownTestCase();
55     void SetUp() override;
56     void TearDown() override;
57 
58     void MakeMockObjects() const;
59 
60     std::string cmd_ = "start";
61 };
62 
SetUpTestCase()63 void AaCommandStartTest::SetUpTestCase()
64 {}
65 
TearDownTestCase()66 void AaCommandStartTest::TearDownTestCase()
67 {}
68 
SetUp()69 void AaCommandStartTest::SetUp()
70 {
71     // reset optind to 0
72     optind = 0;
73 
74     // make mock objects
75     MakeMockObjects();
76 }
77 
TearDown()78 void AaCommandStartTest::TearDown()
79 {}
80 
MakeMockObjects() const81 void AaCommandStartTest::MakeMockObjects() const
82 {
83     // mock a stub
84     auto managerStubPtr = sptr<IAbilityManager>(new MockAbilityManagerStub());
85 
86     // set the mock stub
87     auto managerClientPtr = AbilityManagerClient::GetInstance();
88     managerClientPtr->proxy_ = managerStubPtr;
89 }
90 
91 /**
92  * @tc.number: Aa_Command_Start_0100
93  * @tc.name: ExecCommand
94  * @tc.desc: Verify the "aa start" command.
95  */
96 HWTEST_F(AaCommandStartTest, Aa_Command_Start_0100, Function | MediumTest | Level1)
97 {
98     HILOG_INFO("Aa_Command_Start_0100");
99 
100     char* argv[] = {
101         (char*)TOOL_NAME.c_str(),
102         (char*)cmd_.c_str(),
103         (char*)"",
104     };
105     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
106 
107     AbilityManagerShellCommand cmd(argc, argv);
108     EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_NO_OPTION + "\n" + HELP_MSG_START);
109 }
110 
111 /**
112  * @tc.number: Aa_Command_Start_0200
113  * @tc.name: ExecCommand
114  * @tc.desc: Verify the "aa start xxx" command.
115  */
116 HWTEST_F(AaCommandStartTest, Aa_Command_Start_0200, Function | MediumTest | Level1)
117 {
118     HILOG_INFO("Aa_Command_Start_0200");
119 
120     char* argv[] = {
121         (char*)TOOL_NAME.c_str(),
122         (char*)cmd_.c_str(),
123         (char*)"xxx",
124         (char*)"",
125     };
126     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
127 
128     AbilityManagerShellCommand cmd(argc, argv);
129     EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_NO_OPTION + "\n" + HELP_MSG_START);
130 }
131 
132 /**
133  * @tc.number: Aa_Command_Start_0300
134  * @tc.name: ExecCommand
135  * @tc.desc: Verify the "aa start -x" command.
136  */
137 HWTEST_F(AaCommandStartTest, Aa_Command_Start_0300, Function | MediumTest | Level1)
138 {
139     HILOG_INFO("Aa_Command_Start_0300");
140 
141     char* argv[] = {
142         (char*)TOOL_NAME.c_str(),
143         (char*)cmd_.c_str(),
144         (char*)"-x",
145         (char*)"",
146     };
147     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
148 
149     AbilityManagerShellCommand cmd(argc, argv);
150     EXPECT_EQ(cmd.ExecCommand(), "fail: unknown option.\n" + HELP_MSG_START);
151 }
152 
153 /**
154  * @tc.number: Aa_Command_Start_0400
155  * @tc.name: ExecCommand
156  * @tc.desc: Verify the "aa start -xxx" command.
157  */
158 HWTEST_F(AaCommandStartTest, Aa_Command_Start_0400, Function | MediumTest | Level1)
159 {
160     HILOG_INFO("Aa_Command_Start_0400");
161 
162     char* argv[] = {
163         (char*)TOOL_NAME.c_str(),
164         (char*)cmd_.c_str(),
165         (char*)"-xxx",
166         (char*)"",
167     };
168     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
169 
170     AbilityManagerShellCommand cmd(argc, argv);
171     EXPECT_EQ(cmd.ExecCommand(), "fail: unknown option.\n" + HELP_MSG_START);
172 }
173 
174 /**
175  * @tc.number: Aa_Command_Start_0500
176  * @tc.name: ExecCommand
177  * @tc.desc: Verify the "aa start --x" command.
178  */
179 HWTEST_F(AaCommandStartTest, Aa_Command_Start_0500, Function | MediumTest | Level1)
180 {
181     HILOG_INFO("Aa_Command_Start_0500");
182 
183     char* argv[] = {
184         (char*)TOOL_NAME.c_str(),
185         (char*)cmd_.c_str(),
186         (char*)"--x",
187         (char*)"",
188     };
189     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
190 
191     AbilityManagerShellCommand cmd(argc, argv);
192     EXPECT_EQ(cmd.ExecCommand(), "fail: unknown option.\n" + HELP_MSG_START);
193 }
194 
195 /**
196  * @tc.number: Aa_Command_Start_0600
197  * @tc.name: ExecCommand
198  * @tc.desc: Verify the "aa start --xxx" command.
199  */
200 HWTEST_F(AaCommandStartTest, Aa_Command_Start_0600, Function | MediumTest | Level1)
201 {
202     HILOG_INFO("Aa_Command_Start_0600");
203 
204     char* argv[] = {
205         (char*)TOOL_NAME.c_str(),
206         (char*)cmd_.c_str(),
207         (char*)"--xxx",
208         (char*)"",
209     };
210     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
211 
212     AbilityManagerShellCommand cmd(argc, argv);
213     EXPECT_EQ(cmd.ExecCommand(), "fail: unknown option.\n" + HELP_MSG_START);
214 }
215 
216 /**
217  * @tc.number: Aa_Command_Start_0700
218  * @tc.name: ExecCommand
219  * @tc.desc: Verify the "aa start -h" command.
220  */
221 HWTEST_F(AaCommandStartTest, Aa_Command_Start_0700, Function | MediumTest | Level1)
222 {
223     HILOG_INFO("Aa_Command_Start_0700");
224 
225     char* argv[] = {
226         (char*)TOOL_NAME.c_str(),
227         (char*)cmd_.c_str(),
228         (char*)"-h",
229         (char*)"",
230     };
231     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
232 
233     AbilityManagerShellCommand cmd(argc, argv);
234     EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_START);
235 }
236 
237 /**
238  * @tc.number: Aa_Command_Start_0800
239  * @tc.name: ExecCommand
240  * @tc.desc: Verify the "aa start --help" command.
241  */
242 HWTEST_F(AaCommandStartTest, Aa_Command_Start_0800, Function | MediumTest | Level1)
243 {
244     HILOG_INFO("Aa_Command_Start_0800");
245 
246     char* argv[] = {
247         (char*)TOOL_NAME.c_str(),
248         (char*)cmd_.c_str(),
249         (char*)"--help",
250         (char*)"",
251     };
252     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
253 
254     AbilityManagerShellCommand cmd(argc, argv);
255     EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_START);
256 }
257 
258 /**
259  * @tc.number: Aa_Command_Start_0900
260  * @tc.name: ExecCommand
261  * @tc.desc: Verify the "aa start -d" command.
262  */
263 HWTEST_F(AaCommandStartTest, Aa_Command_Start_0900, Function | MediumTest | Level1)
264 {
265     HILOG_INFO("Aa_Command_Start_0900");
266 
267     char* argv[] = {
268         (char*)TOOL_NAME.c_str(),
269         (char*)cmd_.c_str(),
270         (char*)"-d",
271         (char*)"",
272     };
273     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
274 
275     AbilityManagerShellCommand cmd(argc, argv);
276     EXPECT_EQ(cmd.ExecCommand(), "error: option requires a value.\n" + HELP_MSG_START);
277 }
278 
279 /**
280  * @tc.number: Aa_Command_Start_1000
281  * @tc.name: ExecCommand
282  * @tc.desc: Verify the "aa start -d <device-id>" command.
283  */
284 HWTEST_F(AaCommandStartTest, Aa_Command_Start_1000, Function | MediumTest | Level1)
285 {
286     HILOG_INFO("Aa_Command_Start_1000");
287 
288     char* argv[] = {
289         (char*)TOOL_NAME.c_str(),
290         (char*)cmd_.c_str(),
291         (char*)"-d",
292         (char*)STRING_DEVICE.c_str(),
293         (char*)"",
294     };
295     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
296 
297     AbilityManagerShellCommand cmd(argc, argv);
298     EXPECT_EQ(cmd.ExecCommand(),
299         HELP_MSG_NO_ABILITY_NAME_OPTION + "\n" + HELP_MSG_NO_BUNDLE_NAME_OPTION + "\n" + HELP_MSG_START);
300 }
301 
302 /**
303  * @tc.number: Aa_Command_Start_1100
304  * @tc.name: ExecCommand
305  * @tc.desc: Verify the "aa start -d <device-id> -a" command.
306  */
307 HWTEST_F(AaCommandStartTest, Aa_Command_Start_1100, Function | MediumTest | Level1)
308 {
309     HILOG_INFO("Aa_Command_Start_1100");
310 
311     char* argv[] = {
312         (char*)TOOL_NAME.c_str(),
313         (char*)cmd_.c_str(),
314         (char*)"-d",
315         (char*)STRING_DEVICE.c_str(),
316         (char*)"-a",
317         (char*)"",
318     };
319     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
320 
321     AbilityManagerShellCommand cmd(argc, argv);
322     EXPECT_EQ(cmd.ExecCommand(), "error: option requires a value.\n" + HELP_MSG_START);
323 }
324 
325 /**
326  * @tc.number: Aa_Command_Start_1200
327  * @tc.name: ExecCommand
328  * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name>" command.
329  */
330 HWTEST_F(AaCommandStartTest, Aa_Command_Start_1200, Function | MediumTest | Level1)
331 {
332     HILOG_INFO("Aa_Command_Start_1200");
333 
334     char* argv[] = {
335         (char*)TOOL_NAME.c_str(),
336         (char*)cmd_.c_str(),
337         (char*)"-d",
338         (char*)STRING_DEVICE.c_str(),
339         (char*)"-a",
340         (char*)STRING_ABILITY_NAME.c_str(),
341         (char*)"",
342     };
343     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
344 
345     AbilityManagerShellCommand cmd(argc, argv);
346     EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_NO_BUNDLE_NAME_OPTION + "\n" + HELP_MSG_START);
347 }
348 
349 /**
350  * @tc.number: Aa_Command_Start_1300
351  * @tc.name: ExecCommand
352  * @tc.desc: Verify the "aa start -d <device-id> -b" command.
353  */
354 HWTEST_F(AaCommandStartTest, Aa_Command_Start_1300, Function | MediumTest | Level1)
355 {
356     HILOG_INFO("Aa_Command_Start_1300");
357 
358     char* argv[] = {
359         (char*)TOOL_NAME.c_str(),
360         (char*)cmd_.c_str(),
361         (char*)"-d",
362         (char*)STRING_DEVICE.c_str(),
363         (char*)"-b",
364         (char*)"",
365     };
366     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
367 
368     AbilityManagerShellCommand cmd(argc, argv);
369     EXPECT_EQ(cmd.ExecCommand(), "error: option requires a value.\n" + HELP_MSG_START);
370 }
371 
372 /**
373  * @tc.number: Aa_Command_Start_1400
374  * @tc.name: ExecCommand
375  * @tc.desc: Verify the "aa start -d <device-id> -b <bundle-name>" command.
376  */
377 HWTEST_F(AaCommandStartTest, Aa_Command_Start_1400, Function | MediumTest | Level1)
378 {
379     HILOG_INFO("Aa_Command_Start_1400");
380 
381     char* argv[] = {
382         (char*)TOOL_NAME.c_str(),
383         (char*)cmd_.c_str(),
384         (char*)"-d",
385         (char*)STRING_DEVICE.c_str(),
386         (char*)"-b",
387         (char*)STRING_BUNDLE_NAME.c_str(),
388         (char*)"",
389     };
390     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
391 
392     AbilityManagerShellCommand cmd(argc, argv);
393     EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_NO_ABILITY_NAME_OPTION + "\n" + HELP_MSG_START);
394 }
395 
396 /**
397  * @tc.number: Aa_Command_Start_1500
398  * @tc.name: ExecCommand
399  * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name> -b" command.
400  */
401 HWTEST_F(AaCommandStartTest, Aa_Command_Start_1500, Function | MediumTest | Level1)
402 {
403     HILOG_INFO("Aa_Command_Start_1500");
404 
405     char* argv[] = {
406         (char*)TOOL_NAME.c_str(),
407         (char*)cmd_.c_str(),
408         (char*)"-d",
409         (char*)STRING_DEVICE.c_str(),
410         (char*)"-a",
411         (char*)STRING_ABILITY_NAME.c_str(),
412         (char*)"-b",
413         (char*)"",
414     };
415     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
416 
417     AbilityManagerShellCommand cmd(argc, argv);
418     EXPECT_EQ(cmd.ExecCommand(), "error: option requires a value.\n" + HELP_MSG_START);
419 }
420 
421 /**
422  * @tc.number: Aa_Command_Start_1600
423  * @tc.name: ExecCommand
424  * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name> -b <bundle-name>" command.
425  */
426 HWTEST_F(AaCommandStartTest, Aa_Command_Start_1600, Function | MediumTest | Level1)
427 {
428     HILOG_INFO("Aa_Command_Start_1600");
429 
430     char* argv[] = {
431         (char*)TOOL_NAME.c_str(),
432         (char*)cmd_.c_str(),
433         (char*)"-d",
434         (char*)STRING_DEVICE.c_str(),
435         (char*)"-a",
436         (char*)STRING_ABILITY_NAME.c_str(),
437         (char*)"-b",
438         (char*)STRING_BUNDLE_NAME.c_str(),
439         (char*)"",
440     };
441     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
442 
443     AbilityManagerShellCommand cmd(argc, argv);
444     EXPECT_EQ(cmd.ExecCommand(), STRING_START_ABILITY_OK + "\n");
445 }
446 
447 /**
448  * @tc.number: Aa_Command_Start_1700
449  * @tc.name: ExecCommand
450  * @tc.desc: Verify the "aa start -a" command.
451  */
452 HWTEST_F(AaCommandStartTest, Aa_Command_Start_1700, Function | MediumTest | Level1)
453 {
454     HILOG_INFO("Aa_Command_Start_1700");
455 
456     char* argv[] = {
457         (char*)TOOL_NAME.c_str(),
458         (char*)cmd_.c_str(),
459         (char*)"-a",
460         (char*)"",
461     };
462     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
463 
464     AbilityManagerShellCommand cmd(argc, argv);
465     EXPECT_EQ(cmd.ExecCommand(), "error: option requires a value.\n" + HELP_MSG_START);
466 }
467 
468 /**
469  * @tc.number: Aa_Command_Start_1800
470  * @tc.name: ExecCommand
471  * @tc.desc: Verify the "aa start -a <ability-name> -b" command.
472  */
473 HWTEST_F(AaCommandStartTest, Aa_Command_Start_1800, Function | MediumTest | Level1)
474 {
475     HILOG_INFO("Aa_Command_Start_1800");
476 
477     char* argv[] = {
478         (char*)TOOL_NAME.c_str(),
479         (char*)cmd_.c_str(),
480         (char*)"-a",
481         (char*)STRING_ABILITY_NAME.c_str(),
482         (char*)"-b",
483         (char*)"",
484     };
485     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
486 
487     AbilityManagerShellCommand cmd(argc, argv);
488     EXPECT_EQ(cmd.ExecCommand(), "error: option requires a value.\n" + HELP_MSG_START);
489 }
490 
491 /**
492  * @tc.number: Aa_Command_Start_1900
493  * @tc.name: ExecCommand
494  * @tc.desc: Verify the "aa start -a <ability-name> -b <bundle-name>" command.
495  */
496 HWTEST_F(AaCommandStartTest, Aa_Command_Start_1900, Function | MediumTest | Level1)
497 {
498     HILOG_INFO("Aa_Command_Start_1900");
499 
500     char* argv[] = {
501         (char*)TOOL_NAME.c_str(),
502         (char*)cmd_.c_str(),
503         (char*)"-a",
504         (char*)STRING_ABILITY_NAME.c_str(),
505         (char*)"-b",
506         (char*)STRING_BUNDLE_NAME.c_str(),
507         (char*)"",
508     };
509     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
510 
511     AbilityManagerShellCommand cmd(argc, argv);
512     EXPECT_EQ(cmd.ExecCommand(), STRING_START_ABILITY_OK + "\n");
513 }
514 
515 /**
516  * @tc.number: Aa_Command_Start_2000
517  * @tc.name: ExecCommand
518  * @tc.desc: Verify the "aa start -a <ability-name> -b <bundle-name> -D" command.
519  */
520 HWTEST_F(AaCommandStartTest, Aa_Command_Start_2000, Function | MediumTest | Level1)
521 {
522     HILOG_INFO("Aa_Command_Start_2000");
523 
524     char* argv[] = {
525         (char*)TOOL_NAME.c_str(),
526         (char*)cmd_.c_str(),
527         (char*)"-a",
528         (char*)STRING_ABILITY_NAME.c_str(),
529         (char*)"-b",
530         (char*)STRING_BUNDLE_NAME.c_str(),
531         (char*)"-D",
532         (char*)"",
533     };
534     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
535 
536     AbilityManagerShellCommand cmd(argc, argv);
537     EXPECT_EQ(cmd.ExecCommand(), STRING_START_ABILITY_OK + "\n");
538 }
539 
540 /**
541  * @tc.number: Aa_Command_Start_2100
542  * @tc.name: ExecCommand
543  * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name> -b <bundle-name>" command.
544  */
545 HWTEST_F(AaCommandStartTest, Aa_Command_Start_2100, Function | MediumTest | Level1)
546 {
547     HILOG_INFO("Aa_Command_Start_2100");
548 
549     char* argv[] = {
550         (char*)TOOL_NAME.c_str(),
551         (char*)cmd_.c_str(),
552         (char*)"-d",
553         (char*)STRING_DEVICE.c_str(),
554         (char*)"-a",
555         (char*)STRING_ABILITY_NAME_INVALID.c_str(),
556         (char*)"-b",
557         (char*)STRING_BUNDLE_NAME.c_str(),
558         (char*)"",
559     };
560     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
561 
562     AbilityManagerShellCommand cmd(argc, argv);
563     EXPECT_EQ(cmd.ExecCommand(), STRING_START_ABILITY_NG + "\n" + cmd.messageMap_.at(RESOLVE_ABILITY_ERR) + "\n");
564 }
565 
566 /**
567  * @tc.number: Aa_Command_Start_2200
568  * @tc.name: ExecCommand
569  * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name> -b <bundle-name>" command.
570  */
571 HWTEST_F(AaCommandStartTest, Aa_Command_Start_2200, Function | MediumTest | Level1)
572 {
573     HILOG_INFO("Aa_Command_Start_2200");
574 
575     char* argv[] = {
576         (char*)TOOL_NAME.c_str(),
577         (char*)cmd_.c_str(),
578         (char*)"-d",
579         (char*)STRING_DEVICE.c_str(),
580         (char*)"-a",
581         (char*)STRING_ABILITY_NAME.c_str(),
582         (char*)"-b",
583         (char*)STRING_BUNDLE_NAME_INVALID.c_str(),
584         (char*)"",
585     };
586     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
587 
588     AbilityManagerShellCommand cmd(argc, argv);
589     EXPECT_EQ(cmd.ExecCommand(), STRING_START_ABILITY_NG + "\n" + cmd.messageMap_.at(RESOLVE_APP_ERR) + "\n");
590 }
591 
592 /**
593  * @tc.number: Aa_Command_Start_2300
594  * @tc.name: ExecCommand
595  * @tc.desc: Verify the "aa start -D" command.
596  * @tc.type: FUNC
597  * @tc.require: SR000GH1HD
598  */
599 HWTEST_F(AaCommandStartTest, Aa_Command_Start_2300, Function | MediumTest | Level1)
600 {
601     HILOG_INFO("Aa_Command_Start_2300");
602 
603     char* argv[] = {
604         (char*)TOOL_NAME.c_str(),
605         (char*)cmd_.c_str(),
606         (char*)"-D",
607         (char*)"",
608     };
609     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
610 
611     AbilityManagerShellCommand cmd(argc, argv);
612     EXPECT_EQ(cmd.ExecCommand(), "error: -a <ability-name> is expected\nerror: -b <bundle-name> is expected\n"
613         + HELP_MSG_START);
614 }
615 
616 /**
617  * @tc.number: Aa_Command_Start_2400
618  * @tc.name: ExecCommand
619  * @tc.desc: Verify the "aa start -d <device-id> -D" command.
620  * @tc.type: FUNC
621  * @tc.require: AR000GJUN4
622  */
623 HWTEST_F(AaCommandStartTest, Aa_Command_Start_2400, Function | MediumTest | Level1)
624 {
625     HILOG_INFO("Aa_Command_Start_2400");
626 
627     char* argv[] = {
628         (char*)TOOL_NAME.c_str(),
629         (char*)cmd_.c_str(),
630         (char*)"-d",
631         (char*)STRING_DEVICE.c_str(),
632         (char*)"-D",
633         (char*)"",
634     };
635     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
636 
637     AbilityManagerShellCommand cmd(argc, argv);
638     EXPECT_EQ(cmd.ExecCommand(), "error: -a <ability-name> is expected\nerror: -b <bundle-name> is expected\n"
639         + HELP_MSG_START);
640 }
641 
642 /**
643  * @tc.number: Aa_Command_Start_2500
644  * @tc.name: ExecCommand
645  * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name> -D" command.
646  * @tc.type: FUNC
647  * @tc.require: AR000GJUN4
648  */
649 HWTEST_F(AaCommandStartTest, Aa_Command_Start_2500, Function | MediumTest | Level1)
650 {
651     HILOG_INFO("Aa_Command_Start_2500");
652 
653     char* argv[] = {
654         (char*)TOOL_NAME.c_str(),
655         (char*)cmd_.c_str(),
656         (char*)"-d",
657         (char*)STRING_DEVICE.c_str(),
658         (char*)"-a",
659         (char*)STRING_ABILITY_NAME.c_str(),
660         (char*)"-D",
661         (char*)"",
662     };
663     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
664 
665     AbilityManagerShellCommand cmd(argc, argv);
666     EXPECT_EQ(cmd.ExecCommand(), "error: -b <bundle-name> is expected\n" + HELP_MSG_START);
667 }
668 
669 /**
670  * @tc.number: Aa_Command_Start_2600
671  * @tc.name: ExecCommand
672  * @tc.desc: Verify the "aa start -d <device-id> -b <bundle-name> -D" command.
673  * @tc.type: FUNC
674  * @tc.require: AR000GJUN4
675  */
676 HWTEST_F(AaCommandStartTest, Aa_Command_Start_2600, Function | MediumTest | Level1)
677 {
678     HILOG_INFO("Aa_Command_Start_2600");
679 
680     char* argv[] = {
681         (char*)TOOL_NAME.c_str(),
682         (char*)cmd_.c_str(),
683         (char*)"-d",
684         (char*)STRING_DEVICE.c_str(),
685         (char*)"-b",
686         (char*)STRING_BUNDLE_NAME.c_str(),
687         (char*)"-D",
688         (char*)"",
689     };
690     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
691 
692     AbilityManagerShellCommand cmd(argc, argv);
693     EXPECT_EQ(cmd.ExecCommand(), "error: -a <ability-name> is expected\n" + HELP_MSG_START);
694 }
695 
696 /**
697  * @tc.number: Aa_Command_Start_2700
698  * @tc.name: ExecCommand
699  * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name> -b <bundle-name> -D" command.
700  * @tc.type: FUNC
701  * @tc.require: AR000GJUN4
702  */
703 HWTEST_F(AaCommandStartTest, Aa_Command_Start_2700, Function | MediumTest | Level1)
704 {
705     HILOG_INFO("Aa_Command_Start_2700");
706 
707     char* argv[] = {
708         (char*)TOOL_NAME.c_str(),
709         (char*)cmd_.c_str(),
710         (char*)"-d",
711         (char*)STRING_DEVICE.c_str(),
712         (char*)"-a",
713         (char*)STRING_ABILITY_NAME.c_str(),
714         (char*)"-b",
715         (char*)STRING_BUNDLE_NAME.c_str(),
716         (char*)"-D",
717         (char*)"",
718     };
719     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
720 
721     AbilityManagerShellCommand cmd(argc, argv);
722     EXPECT_EQ(cmd.ExecCommand(), STRING_START_ABILITY_OK + "\n");
723 }
724 
725 /**
726  * @tc.number: Aa_Command_Start_2800
727  * @tc.name: ExecCommand
728  * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name> -b <bundle-name> --pi <key> <integer-value>" command.
729  * @tc.type: FUNC
730  * @tc.require: AR000GJUN4
731  */
732 HWTEST_F(AaCommandStartTest, Aa_Command_Start_2800, Function | MediumTest | Level1)
733 {
734     HILOG_INFO("Aa_Command_Start_2800");
735 
736     char* argv[] = {
737         (char*)TOOL_NAME.c_str(),
738         (char*)cmd_.c_str(),
739         (char*)"-d",
740         (char*)STRING_DEVICE.c_str(),
741         (char*)"-a",
742         (char*)STRING_ABILITY_NAME.c_str(),
743         (char*)"-b",
744         (char*)STRING_BUNDLE_NAME.c_str(),
745         (char*)"--pi",
746         (char*)"kinteger",
747         (char*)"100",
748         (char*)"",
749     };
750     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
751 
752     AbilityManagerShellCommand cmd(argc, argv);
753     EXPECT_EQ(cmd.ExecCommand(), STRING_START_ABILITY_OK + "\n");
754 }
755 
756 /**
757  * @tc.number: Aa_Command_Start_2900
758  * @tc.name: ExecCommand
759  * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name> -b <bundle-name> --pb <key> <bool-value>" command.
760  * @tc.type: FUNC
761  * @tc.require: AR000GJUN4
762  */
763 HWTEST_F(AaCommandStartTest, Aa_Command_Start_2900, Function | MediumTest | Level1)
764 {
765     HILOG_INFO("Aa_Command_Start_2900");
766 
767     char* argv[] = {
768         (char*)TOOL_NAME.c_str(),
769         (char*)cmd_.c_str(),
770         (char*)"-d",
771         (char*)STRING_DEVICE.c_str(),
772         (char*)"-a",
773         (char*)STRING_ABILITY_NAME.c_str(),
774         (char*)"-b",
775         (char*)STRING_BUNDLE_NAME.c_str(),
776         (char*)"--pb",
777         (char*)"kbool",
778         (char*)"true",
779         (char*)"",
780     };
781     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
782 
783     AbilityManagerShellCommand cmd(argc, argv);
784     EXPECT_EQ(cmd.ExecCommand(), STRING_START_ABILITY_OK + "\n");
785 }
786 
787 /**
788  * @tc.number: Aa_Command_Start_3000
789  * @tc.name: ExecCommand
790  * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name> -b <bundle-name> --ps <key> <value>" command.
791  * @tc.type: FUNC
792  * @tc.require: AR000GJUN4
793  */
794 HWTEST_F(AaCommandStartTest, Aa_Command_Start_3000, Function | MediumTest | Level1)
795 {
796     HILOG_INFO("Aa_Command_Start_3000");
797 
798     char* argv[] = {
799         (char*)TOOL_NAME.c_str(),
800         (char*)cmd_.c_str(),
801         (char*)"-d",
802         (char*)STRING_DEVICE.c_str(),
803         (char*)"-a",
804         (char*)STRING_ABILITY_NAME.c_str(),
805         (char*)"-b",
806         (char*)STRING_BUNDLE_NAME.c_str(),
807         (char*)"--ps",
808         (char*)"kstring",
809         (char*)"stringvalue",
810         (char*)"",
811     };
812     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
813 
814     AbilityManagerShellCommand cmd(argc, argv);
815     EXPECT_EQ(cmd.ExecCommand(), STRING_START_ABILITY_OK + "\n");
816 }
817 
818 /**
819  * @tc.number: Aa_Command_Start_3100
820  * @tc.name: ExecCommand
821  * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name> -b <bundle-name> --psn <key>" command.
822  * @tc.type: FUNC
823  * @tc.require: AR000GJUN4
824  */
825 HWTEST_F(AaCommandStartTest, Aa_Command_Start_3100, Function | MediumTest | Level1)
826 {
827     HILOG_INFO("Aa_Command_Start_3100");
828 
829     char* argv[] = {
830         (char*)TOOL_NAME.c_str(),
831         (char*)cmd_.c_str(),
832         (char*)"-d",
833         (char*)STRING_DEVICE.c_str(),
834         (char*)"-a",
835         (char*)STRING_ABILITY_NAME.c_str(),
836         (char*)"-b",
837         (char*)STRING_BUNDLE_NAME.c_str(),
838         (char*)"--psn",
839         (char*)"knullstring",
840         (char*)"",
841     };
842     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
843 
844     AbilityManagerShellCommand cmd(argc, argv);
845     EXPECT_EQ(cmd.ExecCommand(), STRING_START_ABILITY_OK + "\n");
846 }
847 
848 /**
849  * @tc.number: Aa_Command_Start_3200
850  * @tc.name: ExecCommand
851  * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name> -b <bundle-name> -A <action>" command.
852  * @tc.type: FUNC
853  * @tc.require: AR000GJUN4
854  */
855 HWTEST_F(AaCommandStartTest, Aa_Command_Start_3200, Function | MediumTest | Level1)
856 {
857     HILOG_INFO("Aa_Command_Start_3200");
858 
859     char* argv[] = {
860         (char*)TOOL_NAME.c_str(),
861         (char*)cmd_.c_str(),
862         (char*)"-d",
863         (char*)STRING_DEVICE.c_str(),
864         (char*)"-a",
865         (char*)STRING_ABILITY_NAME.c_str(),
866         (char*)"-b",
867         (char*)STRING_BUNDLE_NAME.c_str(),
868         (char*)"-A",
869         (char*)"some-action",
870         (char*)"",
871     };
872     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
873 
874     AbilityManagerShellCommand cmd(argc, argv);
875     EXPECT_EQ(cmd.ExecCommand(), STRING_START_ABILITY_OK + "\n");
876 }
877 
878 /**
879  * @tc.number: Aa_Command_Start_3300
880  * @tc.name: ExecCommand
881  * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name> -b <bundle-name> -U <URI>" command.
882  * @tc.type: FUNC
883  * @tc.require: AR000GJUN4
884  */
885 HWTEST_F(AaCommandStartTest, Aa_Command_Start_3300, Function | MediumTest | Level1)
886 {
887     HILOG_INFO("Aa_Command_Start_3300");
888 
889     char* argv[] = {
890         (char*)TOOL_NAME.c_str(),
891         (char*)cmd_.c_str(),
892         (char*)"-d",
893         (char*)STRING_DEVICE.c_str(),
894         (char*)"-a",
895         (char*)STRING_ABILITY_NAME.c_str(),
896         (char*)"-b",
897         (char*)STRING_BUNDLE_NAME.c_str(),
898         (char*)"-U",
899         (char*)"some-URI",
900         (char*)"",
901     };
902     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
903 
904     AbilityManagerShellCommand cmd(argc, argv);
905     EXPECT_EQ(cmd.ExecCommand(), STRING_START_ABILITY_OK + "\n");
906 }
907 
908 /**
909  * @tc.number: Aa_Command_Start_3400
910  * @tc.name: ExecCommand
911  * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name> -b <bundle-name> -t <type>" command.
912  * @tc.type: FUNC
913  * @tc.require: AR000GJUN4
914  */
915 HWTEST_F(AaCommandStartTest, Aa_Command_Start_3400, Function | MediumTest | Level1)
916 {
917     HILOG_INFO("Aa_Command_Start_3400");
918 
919     char* argv[] = {
920         (char*)TOOL_NAME.c_str(),
921         (char*)cmd_.c_str(),
922         (char*)"-d",
923         (char*)STRING_DEVICE.c_str(),
924         (char*)"-a",
925         (char*)STRING_ABILITY_NAME.c_str(),
926         (char*)"-b",
927         (char*)STRING_BUNDLE_NAME.c_str(),
928         (char*)"-t",
929         (char*)"some-type",
930         (char*)"",
931     };
932     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
933 
934     AbilityManagerShellCommand cmd(argc, argv);
935     EXPECT_EQ(cmd.ExecCommand(), STRING_START_ABILITY_OK + "\n");
936 }
937 
938 /**
939  * @tc.number: Aa_Command_Start_3500
940  * @tc.name: ExecCommand
941  * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name> -b <bundle-name> -e <entity>" command.
942  * @tc.type: FUNC
943  * @tc.require: AR000GJUN4
944  */
945 HWTEST_F(AaCommandStartTest, Aa_Command_Start_3500, Function | MediumTest | Level1)
946 {
947     HILOG_INFO("Aa_Command_Start_3500");
948 
949     char* argv[] = {
950         (char*)TOOL_NAME.c_str(),
951         (char*)cmd_.c_str(),
952         (char*)"-d",
953         (char*)STRING_DEVICE.c_str(),
954         (char*)"-a",
955         (char*)STRING_ABILITY_NAME.c_str(),
956         (char*)"-b",
957         (char*)STRING_BUNDLE_NAME.c_str(),
958         (char*)"-e",
959         (char*)"entity",
960         (char*)"",
961     };
962     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
963 
964     AbilityManagerShellCommand cmd(argc, argv);
965     EXPECT_EQ(cmd.ExecCommand(), STRING_START_ABILITY_OK + "\n");
966 }
967 
968 /**
969  * @tc.number: Aa_Command_Start_3600
970  * @tc.name: ExecCommand
971  * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name> -b <bundle-name> --pi <key> <integer-value>" command.
972  * @tc.type: FUNC
973  * @tc.require: AR000GJUN4
974  */
975 HWTEST_F(AaCommandStartTest, Aa_Command_Start_3600, Function | MediumTest | Level1)
976 {
977     HILOG_INFO("Aa_Command_Start_3600");
978 
979     char* argv[] = {
980         (char*)TOOL_NAME.c_str(),
981         (char*)cmd_.c_str(),
982         (char*)"-d",
983         (char*)STRING_DEVICE.c_str(),
984         (char*)"-a",
985         (char*)STRING_ABILITY_NAME.c_str(),
986         (char*)"-b",
987         (char*)STRING_BUNDLE_NAME.c_str(),
988         (char*)"--pi",
989         (char*)"kinteger",
990         (char*)"invalid",
991         (char*)"",
992     };
993     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
994 
995     AbilityManagerShellCommand cmd(argc, argv);
996     EXPECT_EQ(cmd.ExecCommand(), STRING_INVALID_PARAMETER_INTEGER_OPTION + "\n" + HELP_MSG_START);
997 }
998 
999 /**
1000  * @tc.number: Aa_Command_Start_3700
1001  * @tc.name: ExecCommand
1002  * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name> -b <bundle-name> --pb <key> <bool-value>" command.
1003  * @tc.type: FUNC
1004  * @tc.require: AR000GJUN4
1005  */
1006 HWTEST_F(AaCommandStartTest, Aa_Command_Start_3700, Function | MediumTest | Level1)
1007 {
1008     HILOG_INFO("Aa_Command_Start_3700");
1009 
1010     char* argv[] = {
1011         (char*)TOOL_NAME.c_str(),
1012         (char*)cmd_.c_str(),
1013         (char*)"-d",
1014         (char*)STRING_DEVICE.c_str(),
1015         (char*)"-a",
1016         (char*)STRING_ABILITY_NAME.c_str(),
1017         (char*)"-b",
1018         (char*)STRING_BUNDLE_NAME.c_str(),
1019         (char*)"--pb",
1020         (char*)"kbool",
1021         (char*)"invalid",
1022         (char*)"",
1023     };
1024     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1025 
1026     AbilityManagerShellCommand cmd(argc, argv);
1027     EXPECT_EQ(cmd.ExecCommand(), STRING_INVALID_PARAMETER_BOOL_OPTION + "\n" + HELP_MSG_START);
1028 }
1029 
1030 /**
1031  * @tc.number: Aa_Command_Start_3800
1032  * @tc.name: ExecCommand
1033  * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name> -b <bundle-name> --ps <key> <value>" command.
1034  * @tc.type: FUNC
1035  * @tc.require: AR000GJUN4
1036  */
1037 HWTEST_F(AaCommandStartTest, Aa_Command_Start_3800, Function | MediumTest | Level1)
1038 {
1039     HILOG_INFO("Aa_Command_Start_3800");
1040 
1041     char* argv[] = {
1042         (char*)TOOL_NAME.c_str(),
1043         (char*)cmd_.c_str(),
1044         (char*)"-d",
1045         (char*)STRING_DEVICE.c_str(),
1046         (char*)"-a",
1047         (char*)STRING_ABILITY_NAME.c_str(),
1048         (char*)"-b",
1049         (char*)STRING_BUNDLE_NAME.c_str(),
1050         (char*)"--ps",
1051         (char*)"kstring",
1052         (char*)"stringvalue1",
1053         (char*)"stringvalue2",
1054         (char*)"",
1055     };
1056     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1057 
1058     AbilityManagerShellCommand cmd(argc, argv);
1059     EXPECT_EQ(cmd.ExecCommand(), STRING_INVALID_NUMBER_STRING_OPTION + "\n" + HELP_MSG_START);
1060 }
1061 
1062 /**
1063  * @tc.number: Aa_Command_Start_3900
1064  * @tc.name: ExecCommand
1065  * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name> -b <bundle-name> --pi <key> <integer-value>" command.
1066  * @tc.type: FUNC
1067  * @tc.require: AR000GJUN4
1068  */
1069 HWTEST_F(AaCommandStartTest, Aa_Command_Start_3900, Function | MediumTest | Level1)
1070 {
1071     HILOG_INFO("Aa_Command_Start_3900");
1072 
1073     char* argv[] = {
1074         (char*)TOOL_NAME.c_str(),
1075         (char*)cmd_.c_str(),
1076         (char*)"-d",
1077         (char*)STRING_DEVICE.c_str(),
1078         (char*)"-a",
1079         (char*)STRING_ABILITY_NAME.c_str(),
1080         (char*)"-b",
1081         (char*)STRING_BUNDLE_NAME.c_str(),
1082         (char*)"--pi",
1083         (char*)"kinteger",
1084         (char*)"100",
1085         (char*)"200",
1086         (char*)"",
1087     };
1088     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1089 
1090     AbilityManagerShellCommand cmd(argc, argv);
1091     EXPECT_EQ(cmd.ExecCommand(), STRING_INVALID_NUMBER_INTEGER_OPTION + "\n" + HELP_MSG_START);
1092 }
1093 
1094 /**
1095  * @tc.number: Aa_Command_Start_4000
1096  * @tc.name: ExecCommand
1097  * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name> -b <bundle-name> --pb <key> <bool-value>" command.
1098  * @tc.type: FUNC
1099  * @tc.require: AR000GJUN4
1100  */
1101 HWTEST_F(AaCommandStartTest, Aa_Command_Start_4000, Function | MediumTest | Level1)
1102 {
1103     HILOG_INFO("Aa_Command_Start_4000");
1104 
1105     char* argv[] = {
1106         (char*)TOOL_NAME.c_str(),
1107         (char*)cmd_.c_str(),
1108         (char*)"-d",
1109         (char*)STRING_DEVICE.c_str(),
1110         (char*)"-a",
1111         (char*)STRING_ABILITY_NAME.c_str(),
1112         (char*)"-b",
1113         (char*)STRING_BUNDLE_NAME.c_str(),
1114         (char*)"--pb",
1115         (char*)"kbool",
1116         (char*)"true",
1117         (char*)"true",
1118         (char*)"",
1119     };
1120     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1121 
1122     AbilityManagerShellCommand cmd(argc, argv);
1123     EXPECT_EQ(cmd.ExecCommand(), STRING_INVALID_NUMBER_BOOL_OPTION + "\n" + HELP_MSG_START);
1124 }
1125 /**
1126  * @tc.number: Aa_Command_Start_4100
1127  * @tc.name: ExecCommand
1128  * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name> -b <bundle-name> --psn <key>" command.
1129  * @tc.type: FUNC
1130  * @tc.require: AR000GJUN4
1131  */
1132 HWTEST_F(AaCommandStartTest, Aa_Command_Start_4100, Function | MediumTest | Level1)
1133 {
1134     HILOG_INFO("Aa_Command_Start_4100");
1135 
1136     char* argv[] = {
1137         (char*)TOOL_NAME.c_str(),
1138         (char*)cmd_.c_str(),
1139         (char*)"-d",
1140         (char*)STRING_DEVICE.c_str(),
1141         (char*)"-a",
1142         (char*)STRING_ABILITY_NAME.c_str(),
1143         (char*)"-b",
1144         (char*)STRING_BUNDLE_NAME.c_str(),
1145         (char*)"--psn",
1146         (char*)"knullstring",
1147         (char*)"invalid",
1148         (char*)"",
1149     };
1150     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1151 
1152     AbilityManagerShellCommand cmd(argc, argv);
1153     EXPECT_EQ(cmd.ExecCommand(), STRING_INVALID_NUMBER_NULL_STRING_OPTION + "\n" + HELP_MSG_START);
1154 }
1155