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 } // namespace
44
45 class AaCommandStartTest : public ::testing::Test {
46 public:
47 static void SetUpTestCase();
48 static void TearDownTestCase();
49 void SetUp() override;
50 void TearDown() override;
51
52 void MakeMockObjects() const;
53
54 std::string cmd_ = "start";
55 };
56
SetUpTestCase()57 void AaCommandStartTest::SetUpTestCase()
58 {}
59
TearDownTestCase()60 void AaCommandStartTest::TearDownTestCase()
61 {}
62
SetUp()63 void AaCommandStartTest::SetUp()
64 {
65 // reset optind to 0
66 optind = 0;
67
68 // make mock objects
69 MakeMockObjects();
70 }
71
TearDown()72 void AaCommandStartTest::TearDown()
73 {}
74
MakeMockObjects() const75 void AaCommandStartTest::MakeMockObjects() const
76 {
77 // mock a stub
78 auto managerStubPtr = sptr<IAbilityManager>(new MockAbilityManagerStub());
79
80 // set the mock stub
81 auto managerClientPtr = AbilityManagerClient::GetInstance();
82 managerClientPtr->proxy_ = managerStubPtr;
83 }
84
85 /**
86 * @tc.number: Aa_Command_Start_0100
87 * @tc.name: ExecCommand
88 * @tc.desc: Verify the "aa start" command.
89 */
90 HWTEST_F(AaCommandStartTest, Aa_Command_Start_0100, Function | MediumTest | Level1)
91 {
92 HILOG_INFO("Aa_Command_Start_0100");
93
94 char* argv[] = {
95 (char*)TOOL_NAME.c_str(),
96 (char*)cmd_.c_str(),
97 (char*)"",
98 };
99 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
100
101 AbilityManagerShellCommand cmd(argc, argv);
102 EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_NO_OPTION + "\n" + HELP_MSG_START);
103 }
104
105 /**
106 * @tc.number: Aa_Command_Start_0200
107 * @tc.name: ExecCommand
108 * @tc.desc: Verify the "aa start xxx" command.
109 */
110 HWTEST_F(AaCommandStartTest, Aa_Command_Start_0200, Function | MediumTest | Level1)
111 {
112 HILOG_INFO("Aa_Command_Start_0200");
113
114 char* argv[] = {
115 (char*)TOOL_NAME.c_str(),
116 (char*)cmd_.c_str(),
117 (char*)"xxx",
118 (char*)"",
119 };
120 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
121
122 AbilityManagerShellCommand cmd(argc, argv);
123 EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_NO_OPTION + "\n" + HELP_MSG_START);
124 }
125
126 /**
127 * @tc.number: Aa_Command_Start_0300
128 * @tc.name: ExecCommand
129 * @tc.desc: Verify the "aa start -x" command.
130 */
131 HWTEST_F(AaCommandStartTest, Aa_Command_Start_0300, Function | MediumTest | Level1)
132 {
133 HILOG_INFO("Aa_Command_Start_0300");
134
135 char* argv[] = {
136 (char*)TOOL_NAME.c_str(),
137 (char*)cmd_.c_str(),
138 (char*)"-x",
139 (char*)"",
140 };
141 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
142
143 AbilityManagerShellCommand cmd(argc, argv);
144 EXPECT_EQ(cmd.ExecCommand(), "error: unknown option.\n" + HELP_MSG_START);
145 }
146
147 /**
148 * @tc.number: Aa_Command_Start_0400
149 * @tc.name: ExecCommand
150 * @tc.desc: Verify the "aa start -xxx" command.
151 */
152 HWTEST_F(AaCommandStartTest, Aa_Command_Start_0400, Function | MediumTest | Level1)
153 {
154 HILOG_INFO("Aa_Command_Start_0400");
155
156 char* argv[] = {
157 (char*)TOOL_NAME.c_str(),
158 (char*)cmd_.c_str(),
159 (char*)"-xxx",
160 (char*)"",
161 };
162 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
163
164 AbilityManagerShellCommand cmd(argc, argv);
165 EXPECT_EQ(cmd.ExecCommand(), "error: unknown option.\n" + HELP_MSG_START);
166 }
167
168 /**
169 * @tc.number: Aa_Command_Start_0500
170 * @tc.name: ExecCommand
171 * @tc.desc: Verify the "aa start --x" command.
172 */
173 HWTEST_F(AaCommandStartTest, Aa_Command_Start_0500, Function | MediumTest | Level1)
174 {
175 HILOG_INFO("Aa_Command_Start_0500");
176
177 char* argv[] = {
178 (char*)TOOL_NAME.c_str(),
179 (char*)cmd_.c_str(),
180 (char*)"--x",
181 (char*)"",
182 };
183 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
184
185 AbilityManagerShellCommand cmd(argc, argv);
186 EXPECT_EQ(cmd.ExecCommand(), "error: unknown option.\n" + HELP_MSG_START);
187 }
188
189 /**
190 * @tc.number: Aa_Command_Start_0600
191 * @tc.name: ExecCommand
192 * @tc.desc: Verify the "aa start --xxx" command.
193 */
194 HWTEST_F(AaCommandStartTest, Aa_Command_Start_0600, Function | MediumTest | Level1)
195 {
196 HILOG_INFO("Aa_Command_Start_0600");
197
198 char* argv[] = {
199 (char*)TOOL_NAME.c_str(),
200 (char*)cmd_.c_str(),
201 (char*)"--xxx",
202 (char*)"",
203 };
204 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
205
206 AbilityManagerShellCommand cmd(argc, argv);
207 EXPECT_EQ(cmd.ExecCommand(), "error: unknown option.\n" + HELP_MSG_START);
208 }
209
210 /**
211 * @tc.number: Aa_Command_Start_0700
212 * @tc.name: ExecCommand
213 * @tc.desc: Verify the "aa start -h" command.
214 */
215 HWTEST_F(AaCommandStartTest, Aa_Command_Start_0700, Function | MediumTest | Level1)
216 {
217 HILOG_INFO("Aa_Command_Start_0700");
218
219 char* argv[] = {
220 (char*)TOOL_NAME.c_str(),
221 (char*)cmd_.c_str(),
222 (char*)"-h",
223 (char*)"",
224 };
225 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
226
227 AbilityManagerShellCommand cmd(argc, argv);
228 EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_START);
229 }
230
231 /**
232 * @tc.number: Aa_Command_Start_0800
233 * @tc.name: ExecCommand
234 * @tc.desc: Verify the "aa start --help" command.
235 */
236 HWTEST_F(AaCommandStartTest, Aa_Command_Start_0800, Function | MediumTest | Level1)
237 {
238 HILOG_INFO("Aa_Command_Start_0800");
239
240 char* argv[] = {
241 (char*)TOOL_NAME.c_str(),
242 (char*)cmd_.c_str(),
243 (char*)"--help",
244 (char*)"",
245 };
246 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
247
248 AbilityManagerShellCommand cmd(argc, argv);
249 EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_START);
250 }
251
252 /**
253 * @tc.number: Aa_Command_Start_0900
254 * @tc.name: ExecCommand
255 * @tc.desc: Verify the "aa start -d" command.
256 */
257 HWTEST_F(AaCommandStartTest, Aa_Command_Start_0900, Function | MediumTest | Level1)
258 {
259 HILOG_INFO("Aa_Command_Start_0900");
260
261 char* argv[] = {
262 (char*)TOOL_NAME.c_str(),
263 (char*)cmd_.c_str(),
264 (char*)"-d",
265 (char*)"",
266 };
267 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
268
269 AbilityManagerShellCommand cmd(argc, argv);
270 EXPECT_EQ(cmd.ExecCommand(), "error: option requires a value.\n" + HELP_MSG_START);
271 }
272
273 /**
274 * @tc.number: Aa_Command_Start_1000
275 * @tc.name: ExecCommand
276 * @tc.desc: Verify the "aa start -d <device-id>" command.
277 */
278 HWTEST_F(AaCommandStartTest, Aa_Command_Start_1000, Function | MediumTest | Level1)
279 {
280 HILOG_INFO("Aa_Command_Start_1000");
281
282 char* argv[] = {
283 (char*)TOOL_NAME.c_str(),
284 (char*)cmd_.c_str(),
285 (char*)"-d",
286 (char*)STRING_DEVICE.c_str(),
287 (char*)"",
288 };
289 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
290
291 AbilityManagerShellCommand cmd(argc, argv);
292 EXPECT_EQ(cmd.ExecCommand(),
293 HELP_MSG_NO_ABILITY_NAME_OPTION + "\n" + HELP_MSG_NO_BUNDLE_NAME_OPTION + "\n" + HELP_MSG_START);
294 }
295
296 /**
297 * @tc.number: Aa_Command_Start_1100
298 * @tc.name: ExecCommand
299 * @tc.desc: Verify the "aa start -d <device-id> -a" command.
300 */
301 HWTEST_F(AaCommandStartTest, Aa_Command_Start_1100, Function | MediumTest | Level1)
302 {
303 HILOG_INFO("Aa_Command_Start_1100");
304
305 char* argv[] = {
306 (char*)TOOL_NAME.c_str(),
307 (char*)cmd_.c_str(),
308 (char*)"-d",
309 (char*)STRING_DEVICE.c_str(),
310 (char*)"-a",
311 (char*)"",
312 };
313 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
314
315 AbilityManagerShellCommand cmd(argc, argv);
316 EXPECT_EQ(cmd.ExecCommand(), "error: option requires a value.\n" + HELP_MSG_START);
317 }
318
319 /**
320 * @tc.number: Aa_Command_Start_1200
321 * @tc.name: ExecCommand
322 * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name>" command.
323 */
324 HWTEST_F(AaCommandStartTest, Aa_Command_Start_1200, Function | MediumTest | Level1)
325 {
326 HILOG_INFO("Aa_Command_Start_1200");
327
328 char* argv[] = {
329 (char*)TOOL_NAME.c_str(),
330 (char*)cmd_.c_str(),
331 (char*)"-d",
332 (char*)STRING_DEVICE.c_str(),
333 (char*)"-a",
334 (char*)STRING_ABILITY_NAME.c_str(),
335 (char*)"",
336 };
337 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
338
339 AbilityManagerShellCommand cmd(argc, argv);
340 EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_NO_BUNDLE_NAME_OPTION + "\n" + HELP_MSG_START);
341 }
342
343 /**
344 * @tc.number: Aa_Command_Start_1300
345 * @tc.name: ExecCommand
346 * @tc.desc: Verify the "aa start -d <device-id> -b" command.
347 */
348 HWTEST_F(AaCommandStartTest, Aa_Command_Start_1300, Function | MediumTest | Level1)
349 {
350 HILOG_INFO("Aa_Command_Start_1300");
351
352 char* argv[] = {
353 (char*)TOOL_NAME.c_str(),
354 (char*)cmd_.c_str(),
355 (char*)"-d",
356 (char*)STRING_DEVICE.c_str(),
357 (char*)"-b",
358 (char*)"",
359 };
360 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
361
362 AbilityManagerShellCommand cmd(argc, argv);
363 EXPECT_EQ(cmd.ExecCommand(), "error: option requires a value.\n" + HELP_MSG_START);
364 }
365
366 /**
367 * @tc.number: Aa_Command_Start_1400
368 * @tc.name: ExecCommand
369 * @tc.desc: Verify the "aa start -d <device-id> -b <bundle-name>" command.
370 */
371 HWTEST_F(AaCommandStartTest, Aa_Command_Start_1400, Function | MediumTest | Level1)
372 {
373 HILOG_INFO("Aa_Command_Start_1400");
374
375 char* argv[] = {
376 (char*)TOOL_NAME.c_str(),
377 (char*)cmd_.c_str(),
378 (char*)"-d",
379 (char*)STRING_DEVICE.c_str(),
380 (char*)"-b",
381 (char*)STRING_BUNDLE_NAME.c_str(),
382 (char*)"",
383 };
384 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
385
386 AbilityManagerShellCommand cmd(argc, argv);
387 EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_NO_ABILITY_NAME_OPTION + "\n" + HELP_MSG_START);
388 }
389
390 /**
391 * @tc.number: Aa_Command_Start_1500
392 * @tc.name: ExecCommand
393 * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name> -b" command.
394 */
395 HWTEST_F(AaCommandStartTest, Aa_Command_Start_1500, Function | MediumTest | Level1)
396 {
397 HILOG_INFO("Aa_Command_Start_1500");
398
399 char* argv[] = {
400 (char*)TOOL_NAME.c_str(),
401 (char*)cmd_.c_str(),
402 (char*)"-d",
403 (char*)STRING_DEVICE.c_str(),
404 (char*)"-a",
405 (char*)STRING_ABILITY_NAME.c_str(),
406 (char*)"-b",
407 (char*)"",
408 };
409 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
410
411 AbilityManagerShellCommand cmd(argc, argv);
412 EXPECT_EQ(cmd.ExecCommand(), "error: option requires a value.\n" + HELP_MSG_START);
413 }
414
415 /**
416 * @tc.number: Aa_Command_Start_1600
417 * @tc.name: ExecCommand
418 * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name> -b <bundle-name>" command.
419 */
420 HWTEST_F(AaCommandStartTest, Aa_Command_Start_1600, Function | MediumTest | Level1)
421 {
422 HILOG_INFO("Aa_Command_Start_1600");
423
424 char* argv[] = {
425 (char*)TOOL_NAME.c_str(),
426 (char*)cmd_.c_str(),
427 (char*)"-d",
428 (char*)STRING_DEVICE.c_str(),
429 (char*)"-a",
430 (char*)STRING_ABILITY_NAME.c_str(),
431 (char*)"-b",
432 (char*)STRING_BUNDLE_NAME.c_str(),
433 (char*)"",
434 };
435 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
436
437 AbilityManagerShellCommand cmd(argc, argv);
438 EXPECT_EQ(cmd.ExecCommand(), STRING_START_ABILITY_OK + "\n");
439 }
440
441 /**
442 * @tc.number: Aa_Command_Start_1700
443 * @tc.name: ExecCommand
444 * @tc.desc: Verify the "aa start -a" command.
445 */
446 HWTEST_F(AaCommandStartTest, Aa_Command_Start_1700, Function | MediumTest | Level1)
447 {
448 HILOG_INFO("Aa_Command_Start_1700");
449
450 char* argv[] = {
451 (char*)TOOL_NAME.c_str(),
452 (char*)cmd_.c_str(),
453 (char*)"-a",
454 (char*)"",
455 };
456 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
457
458 AbilityManagerShellCommand cmd(argc, argv);
459 EXPECT_EQ(cmd.ExecCommand(), "error: option requires a value.\n" + HELP_MSG_START);
460 }
461
462 /**
463 * @tc.number: Aa_Command_Start_1800
464 * @tc.name: ExecCommand
465 * @tc.desc: Verify the "aa start -a <ability-name> -b" command.
466 */
467 HWTEST_F(AaCommandStartTest, Aa_Command_Start_1800, Function | MediumTest | Level1)
468 {
469 HILOG_INFO("Aa_Command_Start_1800");
470
471 char* argv[] = {
472 (char*)TOOL_NAME.c_str(),
473 (char*)cmd_.c_str(),
474 (char*)"-a",
475 (char*)STRING_ABILITY_NAME.c_str(),
476 (char*)"-b",
477 (char*)"",
478 };
479 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
480
481 AbilityManagerShellCommand cmd(argc, argv);
482 EXPECT_EQ(cmd.ExecCommand(), "error: option requires a value.\n" + HELP_MSG_START);
483 }
484
485 /**
486 * @tc.number: Aa_Command_Start_1900
487 * @tc.name: ExecCommand
488 * @tc.desc: Verify the "aa start -a <ability-name> -b <bundle-name>" command.
489 */
490 HWTEST_F(AaCommandStartTest, Aa_Command_Start_1900, Function | MediumTest | Level1)
491 {
492 HILOG_INFO("Aa_Command_Start_1900");
493
494 char* argv[] = {
495 (char*)TOOL_NAME.c_str(),
496 (char*)cmd_.c_str(),
497 (char*)"-a",
498 (char*)STRING_ABILITY_NAME.c_str(),
499 (char*)"-b",
500 (char*)STRING_BUNDLE_NAME.c_str(),
501 (char*)"",
502 };
503 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
504
505 AbilityManagerShellCommand cmd(argc, argv);
506 EXPECT_EQ(cmd.ExecCommand(), STRING_START_ABILITY_OK + "\n");
507 }
508
509 /**
510 * @tc.number: Aa_Command_Start_2000
511 * @tc.name: ExecCommand
512 * @tc.desc: Verify the "aa start -a <ability-name> -b <bundle-name> -D" command.
513 */
514 HWTEST_F(AaCommandStartTest, Aa_Command_Start_2000, Function | MediumTest | Level1)
515 {
516 HILOG_INFO("Aa_Command_Start_2000");
517
518 char* argv[] = {
519 (char*)TOOL_NAME.c_str(),
520 (char*)cmd_.c_str(),
521 (char*)"-a",
522 (char*)STRING_ABILITY_NAME.c_str(),
523 (char*)"-b",
524 (char*)STRING_BUNDLE_NAME.c_str(),
525 (char*)"-D",
526 (char*)"",
527 };
528 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
529
530 AbilityManagerShellCommand cmd(argc, argv);
531 EXPECT_EQ(cmd.ExecCommand(), STRING_START_ABILITY_OK + "\n");
532 }
533
534 /**
535 * @tc.number: Aa_Command_Start_2100
536 * @tc.name: ExecCommand
537 * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name> -b <bundle-name>" command.
538 */
539 HWTEST_F(AaCommandStartTest, Aa_Command_Start_2100, Function | MediumTest | Level1)
540 {
541 HILOG_INFO("Aa_Command_Start_2100");
542
543 char* argv[] = {
544 (char*)TOOL_NAME.c_str(),
545 (char*)cmd_.c_str(),
546 (char*)"-d",
547 (char*)STRING_DEVICE.c_str(),
548 (char*)"-a",
549 (char*)STRING_ABILITY_NAME_INVALID.c_str(),
550 (char*)"-b",
551 (char*)STRING_BUNDLE_NAME.c_str(),
552 (char*)"",
553 };
554 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
555
556 AbilityManagerShellCommand cmd(argc, argv);
557 EXPECT_EQ(cmd.ExecCommand(), STRING_START_ABILITY_NG + "\n" + cmd.messageMap_.at(RESOLVE_ABILITY_ERR) + "\n");
558 }
559
560 /**
561 * @tc.number: Aa_Command_Start_2200
562 * @tc.name: ExecCommand
563 * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name> -b <bundle-name>" command.
564 */
565 HWTEST_F(AaCommandStartTest, Aa_Command_Start_2200, Function | MediumTest | Level1)
566 {
567 HILOG_INFO("Aa_Command_Start_2200");
568
569 char* argv[] = {
570 (char*)TOOL_NAME.c_str(),
571 (char*)cmd_.c_str(),
572 (char*)"-d",
573 (char*)STRING_DEVICE.c_str(),
574 (char*)"-a",
575 (char*)STRING_ABILITY_NAME.c_str(),
576 (char*)"-b",
577 (char*)STRING_BUNDLE_NAME_INVALID.c_str(),
578 (char*)"",
579 };
580 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
581
582 AbilityManagerShellCommand cmd(argc, argv);
583 EXPECT_EQ(cmd.ExecCommand(), STRING_START_ABILITY_NG + "\n" + cmd.messageMap_.at(RESOLVE_APP_ERR) + "\n");
584 }
585
586 /**
587 * @tc.number: Aa_Command_Start_2300
588 * @tc.name: ExecCommand
589 * @tc.desc: Verify the "aa start -D" command.
590 * @tc.type: FUNC
591 * @tc.require: SR000GH1HD
592 */
593 HWTEST_F(AaCommandStartTest, Aa_Command_Start_2300, Function | MediumTest | Level1)
594 {
595 HILOG_INFO("Aa_Command_Start_2300");
596
597 char* argv[] = {
598 (char*)TOOL_NAME.c_str(),
599 (char*)cmd_.c_str(),
600 (char*)"-D",
601 (char*)"",
602 };
603 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
604
605 AbilityManagerShellCommand cmd(argc, argv);
606 EXPECT_EQ(cmd.ExecCommand(), "error: -a <ability-name> is expected\nerror: -b <bundle-name> is expected\n"
607 + HELP_MSG_START);
608 }
609
610 /**
611 * @tc.number: Aa_Command_Start_2400
612 * @tc.name: ExecCommand
613 * @tc.desc: Verify the "aa start -d <device-id> -D" command.
614 * @tc.type: FUNC
615 * @tc.require: AR000GJUN4
616 */
617 HWTEST_F(AaCommandStartTest, Aa_Command_Start_2400, Function | MediumTest | Level1)
618 {
619 HILOG_INFO("Aa_Command_Start_2400");
620
621 char* argv[] = {
622 (char*)TOOL_NAME.c_str(),
623 (char*)cmd_.c_str(),
624 (char*)"-d",
625 (char*)STRING_DEVICE.c_str(),
626 (char*)"-D",
627 (char*)"",
628 };
629 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
630
631 AbilityManagerShellCommand cmd(argc, argv);
632 EXPECT_EQ(cmd.ExecCommand(), "error: -a <ability-name> is expected\nerror: -b <bundle-name> is expected\n"
633 + HELP_MSG_START);
634 }
635
636 /**
637 * @tc.number: Aa_Command_Start_2500
638 * @tc.name: ExecCommand
639 * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name> -D" command.
640 * @tc.type: FUNC
641 * @tc.require: AR000GJUN4
642 */
643 HWTEST_F(AaCommandStartTest, Aa_Command_Start_2500, Function | MediumTest | Level1)
644 {
645 HILOG_INFO("Aa_Command_Start_2500");
646
647 char* argv[] = {
648 (char*)TOOL_NAME.c_str(),
649 (char*)cmd_.c_str(),
650 (char*)"-d",
651 (char*)STRING_DEVICE.c_str(),
652 (char*)"-a",
653 (char*)STRING_ABILITY_NAME.c_str(),
654 (char*)"-D",
655 (char*)"",
656 };
657 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
658
659 AbilityManagerShellCommand cmd(argc, argv);
660 EXPECT_EQ(cmd.ExecCommand(), "error: -b <bundle-name> is expected\n" + HELP_MSG_START);
661 }
662
663 /**
664 * @tc.number: Aa_Command_Start_2600
665 * @tc.name: ExecCommand
666 * @tc.desc: Verify the "aa start -d <device-id> -b <bundle-name> -D" command.
667 * @tc.type: FUNC
668 * @tc.require: AR000GJUN4
669 */
670 HWTEST_F(AaCommandStartTest, Aa_Command_Start_2600, Function | MediumTest | Level1)
671 {
672 HILOG_INFO("Aa_Command_Start_2600");
673
674 char* argv[] = {
675 (char*)TOOL_NAME.c_str(),
676 (char*)cmd_.c_str(),
677 (char*)"-d",
678 (char*)STRING_DEVICE.c_str(),
679 (char*)"-b",
680 (char*)STRING_BUNDLE_NAME.c_str(),
681 (char*)"-D",
682 (char*)"",
683 };
684 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
685
686 AbilityManagerShellCommand cmd(argc, argv);
687 EXPECT_EQ(cmd.ExecCommand(), "error: -a <ability-name> is expected\n" + HELP_MSG_START);
688 }
689
690 /**
691 * @tc.number: Aa_Command_Start_2700
692 * @tc.name: ExecCommand
693 * @tc.desc: Verify the "aa start -d <device-id> -a <ability-name> -b <bundle-name> -D" command.
694 * @tc.type: FUNC
695 * @tc.require: AR000GJUN4
696 */
697 HWTEST_F(AaCommandStartTest, Aa_Command_Start_2700, Function | MediumTest | Level1)
698 {
699 HILOG_INFO("Aa_Command_Start_2700");
700
701 char* argv[] = {
702 (char*)TOOL_NAME.c_str(),
703 (char*)cmd_.c_str(),
704 (char*)"-d",
705 (char*)STRING_DEVICE.c_str(),
706 (char*)"-a",
707 (char*)STRING_ABILITY_NAME.c_str(),
708 (char*)"-b",
709 (char*)STRING_BUNDLE_NAME.c_str(),
710 (char*)"-D",
711 (char*)"",
712 };
713 int argc = sizeof(argv) / sizeof(argv[0]) - 1;
714
715 AbilityManagerShellCommand cmd(argc, argv);
716 EXPECT_EQ(cmd.ExecCommand(), STRING_START_ABILITY_OK + "\n");
717 }
718