• 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 private public
19 #include "bundle_command.h"
20 #undef private
21 #include "bundle_constants.h"
22 #include "bundle_installer_interface.h"
23 #include "iremote_broker.h"
24 #include "iremote_object.h"
25 #include "mock_bundle_mgr_host.h"
26 #include "mock_bundle_installer_host.h"
27 
28 using namespace testing::ext;
29 using namespace OHOS;
30 using namespace OHOS::AAFwk;
31 using namespace OHOS::AppExecFwk;
32 
33 namespace OHOS {
34 class BmCommandInstallTest : public ::testing::Test {
35 public:
36     static void SetUpTestCase();
37     static void TearDownTestCase();
38     void SetUp() override;
39     void TearDown() override;
40 
41     void MakeMockObjects();
42     void SetMockObjects(BundleManagerShellCommand &cmd) const;
43 
44     std::string cmd_ = "install";
45     sptr<IBundleMgr> mgrProxyPtr_;
46     sptr<IBundleInstaller> installerProxyPtr_;
47 };
48 
SetUpTestCase()49 void BmCommandInstallTest::SetUpTestCase()
50 {}
51 
TearDownTestCase()52 void BmCommandInstallTest::TearDownTestCase()
53 {}
54 
SetUp()55 void BmCommandInstallTest::SetUp()
56 {
57     // reset optind to 0
58     optind = 0;
59 
60     // make mock objects
61     MakeMockObjects();
62 }
63 
TearDown()64 void BmCommandInstallTest::TearDown()
65 {}
66 
MakeMockObjects()67 void BmCommandInstallTest::MakeMockObjects()
68 {
69     // mock a mgr host
70     auto mgrHostPtr = sptr<IRemoteObject>(new MockBundleMgrHost());
71     // mock a mgr proxy
72     mgrProxyPtr_ = iface_cast<IBundleMgr>(mgrHostPtr);
73 
74     // mock a installer host
75     auto installerHostPtr = sptr<IRemoteObject>(new MockBundleInstallerHost());
76     // mock a installer proxy
77     installerProxyPtr_ = iface_cast<IBundleInstaller>(installerHostPtr);
78 }
79 
SetMockObjects(BundleManagerShellCommand & cmd) const80 void BmCommandInstallTest::SetMockObjects(BundleManagerShellCommand &cmd) const
81 {
82     // set the mock mgr proxy
83     cmd.bundleMgrProxy_ = mgrProxyPtr_;
84 
85     // set the mock installer proxy
86     cmd.bundleInstallerProxy_ = installerProxyPtr_;
87 }
88 
89 /**
90  * @tc.number: Bm_Command_Install_0100
91  * @tc.name: ExecCommand
92  * @tc.desc: Verify the "bm install" command.
93  */
94 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_0100, Function | MediumTest | Level1)
95 {
96     char *argv[] = {
97         const_cast<char*>(TOOL_NAME.c_str()),
98         const_cast<char*>(cmd_.c_str()),
99         const_cast<char*>(""),
100     };
101     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
102 
103     BundleManagerShellCommand cmd(argc, argv);
104 
105     // set the mock objects
106     SetMockObjects(cmd);
107 
108     EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_NO_OPTION + "\n" + HELP_MSG_INSTALL);
109 }
110 
111 /**
112  * @tc.number: Bm_Command_Install_0200
113  * @tc.name: ExecCommand
114  * @tc.desc: Verify the "bm install xxx" command.
115  */
116 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_0200, Function | MediumTest | Level1)
117 {
118     char *argv[] = {
119         const_cast<char*>(TOOL_NAME.c_str()),
120         const_cast<char*>(cmd_.c_str()),
121         const_cast<char*>("xxx"),
122         const_cast<char*>(""),
123     };
124     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
125 
126     BundleManagerShellCommand cmd(argc, argv);
127 
128     // set the mock objects
129     SetMockObjects(cmd);
130 
131     EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_NO_OPTION + "\n" + HELP_MSG_INSTALL);
132 }
133 
134 /**
135  * @tc.number: Bm_Command_Install_0300
136  * @tc.name: ExecCommand
137  * @tc.desc: Verify the "bm install -x" command.
138  */
139 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_0300, Function | MediumTest | Level1)
140 {
141     char *argv[] = {
142         const_cast<char*>(TOOL_NAME.c_str()),
143         const_cast<char*>(cmd_.c_str()),
144         const_cast<char*>("-x"),
145         const_cast<char*>(""),
146     };
147     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
148 
149     BundleManagerShellCommand cmd(argc, argv);
150 
151     // set the mock objects
152     SetMockObjects(cmd);
153 
154     EXPECT_EQ(cmd.ExecCommand(), "error: unknown option.\n" + HELP_MSG_INSTALL);
155 }
156 
157 /**
158  * @tc.number: Bm_Command_Install_0400
159  * @tc.name: ExecCommand
160  * @tc.desc: Verify the "bm install -xxx" command.
161  */
162 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_0400, Function | MediumTest | Level1)
163 {
164     char *argv[] = {
165         const_cast<char*>(TOOL_NAME.c_str()),
166         const_cast<char*>(cmd_.c_str()),
167         const_cast<char*>("-xxx"),
168         const_cast<char*>(""),
169     };
170     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
171 
172     BundleManagerShellCommand cmd(argc, argv);
173 
174     // set the mock objects
175     SetMockObjects(cmd);
176 
177     EXPECT_EQ(cmd.ExecCommand(), "error: unknown option.\n" + HELP_MSG_INSTALL);
178 }
179 
180 /**
181  * @tc.number: Bm_Command_Install_0500
182  * @tc.name: ExecCommand
183  * @tc.desc: Verify the "bm install --x" command.
184  */
185 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_0500, Function | MediumTest | Level1)
186 {
187     char *argv[] = {
188         const_cast<char*>(TOOL_NAME.c_str()),
189         const_cast<char*>(cmd_.c_str()),
190         const_cast<char*>("--x"),
191         const_cast<char*>(""),
192     };
193     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
194 
195     BundleManagerShellCommand cmd(argc, argv);
196 
197     // set the mock objects
198     SetMockObjects(cmd);
199 
200     EXPECT_EQ(cmd.ExecCommand(), "error: unknown option.\n" + HELP_MSG_INSTALL);
201 }
202 
203 /**
204  * @tc.number: Bm_Command_Install_0600
205  * @tc.name: ExecCommand
206  * @tc.desc: Verify the "bm install --xxx" command.
207  */
208 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_0600, Function | MediumTest | Level1)
209 {
210     char *argv[] = {
211         const_cast<char*>(TOOL_NAME.c_str()),
212         const_cast<char*>(cmd_.c_str()),
213         const_cast<char*>("--xxx"),
214         const_cast<char*>(""),
215     };
216     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
217 
218     BundleManagerShellCommand cmd(argc, argv);
219 
220     // set the mock objects
221     SetMockObjects(cmd);
222 
223     EXPECT_EQ(cmd.ExecCommand(), "error: unknown option.\n" + HELP_MSG_INSTALL);
224 }
225 
226 /**
227  * @tc.number: Bm_Command_Install_0700
228  * @tc.name: ExecCommand
229  * @tc.desc: Verify the "bm install --h" command.
230  */
231 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_0700, Function | MediumTest | Level1)
232 {
233     char *argv[] = {
234         const_cast<char*>(TOOL_NAME.c_str()),
235         const_cast<char*>(cmd_.c_str()),
236         const_cast<char*>("-h"),
237         const_cast<char*>(""),
238     };
239     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
240 
241     BundleManagerShellCommand cmd(argc, argv);
242 
243     // set the mock objects
244     SetMockObjects(cmd);
245 
246     EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_INSTALL);
247 }
248 
249 /**
250  * @tc.number: Bm_Command_Install_0800
251  * @tc.name: ExecCommand
252  * @tc.desc: Verify the "bm install --help" command.
253  */
254 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_0800, Function | MediumTest | Level1)
255 {
256     char *argv[] = {
257         const_cast<char*>(TOOL_NAME.c_str()),
258         const_cast<char*>(cmd_.c_str()),
259         const_cast<char*>("--help"),
260         const_cast<char*>(""),
261     };
262     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
263 
264     BundleManagerShellCommand cmd(argc, argv);
265 
266     // set the mock objects
267     SetMockObjects(cmd);
268 
269     EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_INSTALL);
270 }
271 
272 /**
273  * @tc.number: Bm_Command_Install_0900
274  * @tc.name: ExecCommand
275  * @tc.desc: Verify the "bm install -p" command.
276  */
277 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_0900, Function | MediumTest | Level1)
278 {
279     char *argv[] = {
280         const_cast<char*>(TOOL_NAME.c_str()),
281         const_cast<char*>(cmd_.c_str()),
282         const_cast<char*>("-p"),
283         const_cast<char*>(""),
284     };
285     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
286 
287     BundleManagerShellCommand cmd(argc, argv);
288 
289     // set the mock objects
290     SetMockObjects(cmd);
291 
292     EXPECT_EQ(cmd.ExecCommand(), STRING_REQUIRE_CORRECT_VALUE + HELP_MSG_INSTALL);
293 }
294 
295 /**
296  * @tc.number: Bm_Command_Install_1000
297  * @tc.name: ExecCommand
298  * @tc.desc: Verify the "bm install -r" command.
299  */
300 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_1000, Function | MediumTest | Level1)
301 {
302     char *argv[] = {
303         const_cast<char*>(TOOL_NAME.c_str()),
304         const_cast<char*>(cmd_.c_str()),
305         const_cast<char*>("-r"),
306         const_cast<char*>(""),
307     };
308     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
309 
310     BundleManagerShellCommand cmd(argc, argv);
311 
312     // set the mock objects
313     SetMockObjects(cmd);
314 
315     EXPECT_EQ(
316         cmd.ExecCommand(), "error: you must specify a bundle path with '-p' or '--bundle-path'.\n" + HELP_MSG_INSTALL);
317 }
318 
319 /**
320  * @tc.number: Bm_Command_Install_1100
321  * @tc.name: ExecCommand
322  * @tc.desc: Verify the "bm install -p <bundle-path>" command.
323  */
324 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_1100, Function | MediumTest | Level1)
325 {
326     // install a bundle
327     char *argv[] = {
328         const_cast<char*>(TOOL_NAME.c_str()),
329         const_cast<char*>(cmd_.c_str()),
330         const_cast<char*>("-p"),
331         const_cast<char*>(STRING_BUNDLE_PATH.c_str()),
332         const_cast<char*>(""),
333     };
334     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
335 
336     BundleManagerShellCommand cmd(argc, argv);
337 
338     // set the mock objects
339     SetMockObjects(cmd);
340 
341     EXPECT_EQ(cmd.ExecCommand(), STRING_INSTALL_BUNDLE_OK + "\n");
342 }
343 
344 /**
345  * @tc.number: Bm_Command_Install_1200
346  * @tc.name: ExecCommand
347  * @tc.desc: Verify the "bm install -p <bundle-path> -r" command.
348  */
349 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_1200, Function | MediumTest | Level1)
350 {
351     // install a bundle
352     char *argv[] = {
353         const_cast<char*>(TOOL_NAME.c_str()),
354         const_cast<char*>(cmd_.c_str()),
355         const_cast<char*>("-p"),
356         const_cast<char*>(STRING_BUNDLE_PATH.c_str()),
357         const_cast<char*>("-r"),
358         const_cast<char*>(""),
359     };
360     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
361 
362     BundleManagerShellCommand cmd(argc, argv);
363 
364     // set the mock objects
365     SetMockObjects(cmd);
366 
367     EXPECT_EQ(cmd.ExecCommand(), STRING_INSTALL_BUNDLE_OK + "\n");
368 }
369 
370 /**
371  * @tc.number: Bm_Command_Install_1300
372  * @tc.name: ExecCommand
373  * @tc.desc: Verify the "bm install -r -p <bundle-path>" command.
374  */
375 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_1300, Function | MediumTest | Level1)
376 {
377     // install a bundle
378     char *argv[] = {
379         const_cast<char*>(TOOL_NAME.c_str()),
380         const_cast<char*>(cmd_.c_str()),
381         const_cast<char*>("-r"),
382         const_cast<char*>("-p"),
383         const_cast<char*>(STRING_BUNDLE_PATH.c_str()),
384         const_cast<char*>(""),
385     };
386     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
387 
388     BundleManagerShellCommand cmd(argc, argv);
389 
390     // set the mock objects
391     SetMockObjects(cmd);
392 
393     EXPECT_EQ(cmd.ExecCommand(), STRING_INSTALL_BUNDLE_OK + "\n");
394 }
395 
396 /**
397  * @tc.number: Bm_Command_Install_1600
398  * @tc.name: ExecCommand
399  * @tc.desc: Verify the "bm install -p <bundle-path> <bundle-path>" command.
400  */
401 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_1600, Function | MediumTest | Level1)
402 {
403     // install a bundle
404     char *argv[] = {
405         const_cast<char*>(TOOL_NAME.c_str()),
406         const_cast<char*>(cmd_.c_str()),
407         const_cast<char*>("-p"),
408         const_cast<char*>(STRING_BUNDLE_PATH.c_str()),
409         const_cast<char*>(STRING_OTHER_BUNDLE_PATH.c_str()),
410         const_cast<char*>(""),
411     };
412     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
413 
414     BundleManagerShellCommand cmd(argc, argv);
415 
416     // set the mock objects
417     SetMockObjects(cmd);
418 
419     EXPECT_EQ(cmd.ExecCommand(), STRING_INSTALL_BUNDLE_OK + "\n");
420 }
421 
422 /**
423  * @tc.number: Bm_Command_Install_1700
424  * @tc.name: ExecCommand
425  * @tc.desc: Verify the "bm install -p <bundle-path>" command.
426  */
427 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_1700, Function | MediumTest | Level1)
428 {
429     // install a bundle
430     char *argv[] = {
431         const_cast<char*>(TOOL_NAME.c_str()),
432         const_cast<char*>(cmd_.c_str()),
433         const_cast<char*>("-p"),
434         const_cast<char*>(STRING_BUNDLE_INSTALL_PATH1.c_str()),
435         const_cast<char*>(STRING_BUNDLE_INSTALL_PATH2.c_str()),
436         const_cast<char*>(""),
437     };
438     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
439 
440     BundleManagerShellCommand cmd(argc, argv);
441 
442     // set the mock objects
443     SetMockObjects(cmd);
444 
445     EXPECT_EQ(cmd.ExecCommand(), STRING_INSTALL_BUNDLE_OK + "\n");
446 }
447 
448 /**
449  * @tc.number: Bm_Command_Install_1800
450  * @tc.name: ExecCommand
451  * @tc.desc: Verify the "bm install -p <bundle-path>" command.
452  */
453 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_1800, Function | MediumTest | Level1)
454 {
455     // install a bundle
456     char *argv[] = {
457         const_cast<char*>(TOOL_NAME.c_str()),
458         const_cast<char*>(cmd_.c_str()),
459         const_cast<char*>("-p"),
460         const_cast<char*>(STRING_BUNDLE_PATH.c_str()),
461         const_cast<char*>(STRING_BUNDLE_INSTALL_PATH2.c_str()),
462         const_cast<char*>(""),
463     };
464     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
465 
466     BundleManagerShellCommand cmd(argc, argv);
467 
468     // set the mock objects
469     SetMockObjects(cmd);
470 
471     EXPECT_EQ(cmd.ExecCommand(), STRING_INSTALL_BUNDLE_OK + "\n");
472 }
473 
474 /**
475  * @tc.number: Bm_Command_Install_1900
476  * @tc.name: ExecCommand
477  * @tc.desc: Verify the "bm install --bundle-path <bundle-path> <bundle-path>" command.
478  */
479 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_1900, Function | MediumTest | Level1)
480 {
481     // install a bundle
482     char *argv[] = {
483         const_cast<char*>(TOOL_NAME.c_str()),
484         const_cast<char*>(cmd_.c_str()),
485         const_cast<char*>("--bundle-path"),
486         const_cast<char*>(STRING_BUNDLE_PATH.c_str()),
487         const_cast<char*>(STRING_OTHER_BUNDLE_PATH.c_str()),
488         const_cast<char*>(""),
489     };
490     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
491 
492     BundleManagerShellCommand cmd(argc, argv);
493 
494     // set the mock objects
495     SetMockObjects(cmd);
496 
497     EXPECT_EQ(cmd.ExecCommand(), STRING_INSTALL_BUNDLE_OK + "\n");
498 }
499 
500 /**
501  * @tc.number: Bm_Command_Install_2000
502  * @tc.name: ExecCommand
503  * @tc.desc: Verify the "bm install -p <bundle-path>" command.
504  */
505 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_2000, Function | MediumTest | Level1)
506 {
507     // install a bundle
508     char *argv[] = {
509         const_cast<char*>(TOOL_NAME.c_str()),
510         const_cast<char*>(cmd_.c_str()),
511         const_cast<char*>("--bundle-path"),
512         const_cast<char*>(STRING_BUNDLE_INSTALL_PATH1.c_str()),
513         const_cast<char*>(STRING_BUNDLE_INSTALL_PATH2.c_str()),
514         const_cast<char*>(""),
515     };
516     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
517 
518     BundleManagerShellCommand cmd(argc, argv);
519 
520     // set the mock objects
521     SetMockObjects(cmd);
522 
523     EXPECT_EQ(cmd.ExecCommand(), STRING_INSTALL_BUNDLE_OK + "\n");
524 }
525 
526 /**
527  * @tc.number: Bm_Command_Install_2100
528  * @tc.name: ExecCommand
529  * @tc.desc: Verify the "bm install -p <bundle-path>" command.
530  */
531 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_2100, Function | MediumTest | Level1)
532 {
533     // install a bundle
534     char *argv[] = {
535         const_cast<char*>(TOOL_NAME.c_str()),
536         const_cast<char*>(cmd_.c_str()),
537         const_cast<char*>("--bundle-path"),
538         const_cast<char*>(STRING_BUNDLE_PATH.c_str()),
539         const_cast<char*>(STRING_BUNDLE_INSTALL_PATH2.c_str()),
540         const_cast<char*>(""),
541     };
542     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
543 
544     BundleManagerShellCommand cmd(argc, argv);
545 
546     // set the mock objects
547     SetMockObjects(cmd);
548 
549     EXPECT_EQ(cmd.ExecCommand(), STRING_INSTALL_BUNDLE_OK + "\n");
550 }
551 
552 /**
553  * @tc.number: Bm_Command_Install_2300
554  * @tc.name: ExecCommand
555  * @tc.desc: Verify the "bm install -p <bundle-path> <bundle-path> -r" command.
556  */
557 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_2300, Function | MediumTest | Level1)
558 {
559     // install a bundle
560     char *argv[] = {
561         const_cast<char*>(TOOL_NAME.c_str()),
562         const_cast<char*>(cmd_.c_str()),
563         const_cast<char*>("-p"),
564         const_cast<char*>(STRING_BUNDLE_PATH.c_str()),
565         const_cast<char*>(STRING_OTHER_BUNDLE_PATH.c_str()),
566         const_cast<char*>("-r"),
567         const_cast<char*>(""),
568     };
569     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
570 
571     BundleManagerShellCommand cmd(argc, argv);
572 
573     // set the mock objects
574     SetMockObjects(cmd);
575 
576     EXPECT_EQ(cmd.ExecCommand(), STRING_INSTALL_BUNDLE_OK + "\n");
577 }
578 
579 /**
580  * @tc.number: Bm_Command_Install_2400
581  * @tc.name: ExecCommand
582  * @tc.desc: Verify the "bm install -r -p <bundle-path> <bundle-path>" command.
583  */
584 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_2400, Function | MediumTest | Level1)
585 {
586     // install a bundle
587     char *argv[] = {
588         const_cast<char*>(TOOL_NAME.c_str()),
589         const_cast<char*>(cmd_.c_str()),
590         const_cast<char*>("-r"),
591         const_cast<char*>("-p"),
592         const_cast<char*>(STRING_BUNDLE_PATH.c_str()),
593         const_cast<char*>(STRING_OTHER_BUNDLE_PATH.c_str()),
594         const_cast<char*>(""),
595     };
596     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
597 
598     BundleManagerShellCommand cmd(argc, argv);
599 
600     // set the mock objects
601     SetMockObjects(cmd);
602 
603     EXPECT_EQ(cmd.ExecCommand(), STRING_INSTALL_BUNDLE_OK + "\n");
604 }
605 
606 /**
607  * @tc.number: Bm_Command_Install_2600
608  * @tc.name: ExecCommand
609  * @tc.desc: Verify the "bm install -p -r <bundle-path> <bundle-path>" command.
610  */
611 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_2600, Function | MediumTest | Level1)
612 {
613     // install a bundle
614     char *argv[] = {
615         const_cast<char*>(TOOL_NAME.c_str()),
616         const_cast<char*>(cmd_.c_str()),
617         const_cast<char*>("-p"),
618         const_cast<char*>("-r"),
619         const_cast<char*>(STRING_BUNDLE_PATH.c_str()),
620         const_cast<char*>(STRING_OTHER_BUNDLE_PATH.c_str()),
621         const_cast<char*>(""),
622     };
623     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
624 
625     BundleManagerShellCommand cmd(argc, argv);
626 
627     // set the mock objects
628     SetMockObjects(cmd);
629 
630     EXPECT_EQ(cmd.ExecCommand(), STRING_REQUIRE_CORRECT_VALUE);
631 }
632 
633 /**
634  * @tc.number: Bm_Command_Install_2700
635  * @tc.name: ExecCommand
636  * @tc.desc: Verify the "bm install -p <bundle-path> <bundle-path> -u xxx" command.
637  */
638 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_2700, Function | MediumTest | Level1)
639 {
640     // install a bundle
641     char *argv[] = {
642         const_cast<char*>(TOOL_NAME.c_str()),
643         const_cast<char*>(cmd_.c_str()),
644         const_cast<char*>("-p"),
645         const_cast<char*>(STRING_BUNDLE_PATH.c_str()),
646         const_cast<char*>(STRING_OTHER_BUNDLE_PATH.c_str()),
647         const_cast<char*>("-u"),
648         const_cast<char*>("xxx"),
649         const_cast<char*>(""),
650     };
651     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
652 
653     BundleManagerShellCommand cmd(argc, argv);
654 
655     // set the mock objects
656     SetMockObjects(cmd);
657 
658     EXPECT_EQ(cmd.ExecCommand(), STRING_REQUIRE_CORRECT_VALUE);
659 }
660 
661 /**
662  * @tc.number: Bm_Command_Install_2800
663  * @tc.name: ExecCommand
664  * @tc.desc: Verify the "bm install -p <bundle-path> <bundle-path> -u" command.
665  */
666 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_2800, Function | MediumTest | Level1)
667 {
668     // install a bundle
669     char *argv[] = {
670         const_cast<char*>(TOOL_NAME.c_str()),
671         const_cast<char*>(cmd_.c_str()),
672         const_cast<char*>("-p"),
673         const_cast<char*>(STRING_BUNDLE_PATH.c_str()),
674         const_cast<char*>(STRING_OTHER_BUNDLE_PATH.c_str()),
675         const_cast<char*>("-u"),
676         const_cast<char*>(""),
677     };
678     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
679 
680     BundleManagerShellCommand cmd(argc, argv);
681 
682     // set the mock objects
683     SetMockObjects(cmd);
684 
685     EXPECT_EQ(cmd.ExecCommand(), STRING_REQUIRE_CORRECT_VALUE + HELP_MSG_INSTALL);
686 }
687 
688 /**
689  * @tc.number: Bm_Command_Install_2900
690  * @tc.name: ExecCommand
691  * @tc.desc: Verify the "bm install -p <bundle-path> <bundle-path> -u" command.
692  */
693 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_2900, Function | MediumTest | Level1)
694 {
695     // install a bundle
696     char *argv[] = {
697         const_cast<char*>(TOOL_NAME.c_str()),
698         const_cast<char*>(cmd_.c_str()),
699         const_cast<char*>("-p"),
700         const_cast<char*>(STRING_BUNDLE_PATH.c_str()),
701         const_cast<char*>(STRING_OTHER_BUNDLE_PATH.c_str()),
702         const_cast<char*>("-u"),
703         const_cast<char*>(DEFAULT_USER_ID.c_str()),
704         const_cast<char*>(""),
705     };
706     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
707 
708     BundleManagerShellCommand cmd(argc, argv);
709 
710     // set the mock objects
711     SetMockObjects(cmd);
712 
713     EXPECT_EQ(cmd.ExecCommand(), STRING_INSTALL_BUNDLE_OK + "\n");
714 }
715 
716 /**
717  * @tc.number: Bm_Command_Install_3000
718  * @tc.name: ExecCommand
719  * @tc.desc: Verify the "bm install -p <bundle-path> -w" command.
720  */
721 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_3000, Function | MediumTest | Level1)
722 {
723     // install a bundle
724     char *argv[] = {
725         const_cast<char*>(TOOL_NAME.c_str()),
726         const_cast<char*>(cmd_.c_str()),
727         const_cast<char*>("-p"),
728         const_cast<char*>(STRING_BUNDLE_PATH.c_str()),
729         const_cast<char*>("-w"),
730         const_cast<char*>(""),
731     };
732     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
733 
734     BundleManagerShellCommand cmd(argc, argv);
735 
736     // set the mock objects
737     SetMockObjects(cmd);
738 
739     EXPECT_EQ(cmd.ExecCommand(), STRING_REQUIRE_CORRECT_VALUE + HELP_MSG_INSTALL);
740 }
741 
742 /**
743  * @tc.number: Bm_Command_Install_3100
744  * @tc.name: ExecCommand
745  * @tc.desc: Verify the "bm install -p <bundle-path> -w <waitting-time>" command.
746  */
747 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_3100, Function | MediumTest | Level1)
748 {
749     // install a bundle
750     char *argv[] = {
751         const_cast<char*>(TOOL_NAME.c_str()),
752         const_cast<char*>(cmd_.c_str()),
753         const_cast<char*>("-p"),
754         const_cast<char*>(STRING_BUNDLE_PATH.c_str()),
755         const_cast<char*>("-w"),
756         const_cast<char*>(DEFAULT_WAIT_TIME.c_str()),
757         const_cast<char*>(""),
758     };
759     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
760 
761     BundleManagerShellCommand cmd(argc, argv);
762 
763     // set the mock objects
764     SetMockObjects(cmd);
765 
766     EXPECT_EQ(cmd.ExecCommand(), STRING_INSTALL_BUNDLE_OK + "\n");
767 }
768 
769 /**
770  * @tc.number: Bm_Command_Install_3200
771  * @tc.name: ExecCommand
772  * @tc.desc: Verify the "bm install -p <bundle-path> -XXX <user-id>" command.
773  */
774 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_3200, Function | MediumTest | Level1)
775 {
776     // install a bundle
777     char *argv[] = {
778         const_cast<char*>(TOOL_NAME.c_str()),
779         const_cast<char*>(cmd_.c_str()),
780         const_cast<char*>("-p"),
781         const_cast<char*>(STRING_BUNDLE_PATH.c_str()),
782         const_cast<char*>(STRING_OTHER_BUNDLE_PATH.c_str()),
783         const_cast<char*>("-XXX"),
784         const_cast<char*>(DEFAULT_USER_ID.c_str()),
785         const_cast<char*>(""),
786     };
787     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
788 
789     BundleManagerShellCommand cmd(argc, argv);
790 
791     // set the mock objects
792     SetMockObjects(cmd);
793 
794     EXPECT_EQ(cmd.ExecCommand(), "error: unknown option.\n" + HELP_MSG_INSTALL);
795 }
796 
797 /**
798  * @tc.number: Bm_Command_Install_3300
799  * @tc.name: ExecCommand
800  * @tc.desc: Verify the "bm install -p <bundle-path> -w <waitting-time>" command.
801  */
802 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_3300, Function | MediumTest | Level1)
803 {
804     // install a bundle
805     char *argv[] = {
806         const_cast<char*>(TOOL_NAME.c_str()),
807         const_cast<char*>(cmd_.c_str()),
808         const_cast<char*>("-p"),
809         const_cast<char*>(STRING_BUNDLE_PATH.c_str()),
810         const_cast<char*>("-w"),
811         const_cast<char*>(MINIMUMT_WAIT_TIME.c_str()),
812         const_cast<char*>(""),
813     };
814     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
815 
816     BundleManagerShellCommand cmd(argc, argv);
817 
818     // set the mock objects
819     SetMockObjects(cmd);
820 
821     EXPECT_EQ(cmd.ExecCommand(), "error: option requires a correct value.\n");
822 }
823 
824 /**
825  * @tc.number: Bm_Command_Install_3400
826  * @tc.name: ExecCommand
827  * @tc.desc: Verify the "bm install -p <bundle-path> -w <waitting-time>" command.
828  */
829 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_3400, Function | MediumTest | Level1)
830 {
831     // install a bundle
832     char *argv[] = {
833         const_cast<char*>(TOOL_NAME.c_str()),
834         const_cast<char*>(cmd_.c_str()),
835         const_cast<char*>("-p"),
836         const_cast<char*>(STRING_BUNDLE_PATH.c_str()),
837         const_cast<char*>("-w"),
838         const_cast<char*>(MAXIMUM_WAIT_TIME.c_str()),
839         const_cast<char*>(""),
840     };
841     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
842 
843     BundleManagerShellCommand cmd(argc, argv);
844 
845     // set the mock objects
846     SetMockObjects(cmd);
847 
848     EXPECT_EQ(cmd.ExecCommand(), "error: option requires a correct value.\n");
849 }
850 
851 /**
852  * @tc.number: Bm_Command_Install_3500
853  * @tc.name: ExecCommand
854  * @tc.desc: Verify the "bm install" command.
855  */
856 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_3500, Function | MediumTest | Level1)
857 {
858     char *argv[] = {
859         const_cast<char*>(TOOL_NAME.c_str()),
860         const_cast<char*>(cmd_.c_str()),
861         const_cast<char*>("-cc"),
862         const_cast<char*>(STRING_BUNDLE_PATH.c_str()),
863         const_cast<char*>(""),
864     };
865     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
866 
867     BundleManagerShellCommand cmd(argc, argv);
868 
869     // set the mock objects
870     SetMockObjects(cmd);
871 
872     EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_INSTALL);
873 }
874 
875 /**
876  * @tc.number: Bm_Command_Install_3600
877  * @tc.name: ExecCommand
878  * @tc.desc: Verify the "bm install -s <bundle-path>" command.
879  */
880 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_3600, Function | MediumTest | Level1)
881 {
882     // install a bundle
883     char *argv[] = {
884         const_cast<char*>(TOOL_NAME.c_str()),
885         const_cast<char*>(cmd_.c_str()),
886         const_cast<char*>("-s"),
887         const_cast<char*>(STRING_BUNDLE_PATH.c_str()),
888         const_cast<char*>(""),
889     };
890     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
891 
892     BundleManagerShellCommand cmd(argc, argv);
893 
894     // set the mock objects
895     SetMockObjects(cmd);
896 
897     EXPECT_EQ(cmd.ExecCommand(), STRING_INSTALL_BUNDLE_OK + "\n");
898 }
899 
900 /**
901  * @tc.number: Bm_Command_Install_3700
902  * @tc.name: ExecCommand
903  * @tc.desc: Verify the "bm install -s <bundle-path>" command.
904  */
905 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_3700, Function | MediumTest | Level1)
906 {
907     // install a bundle
908     char *argv[] = {
909         const_cast<char*>(TOOL_NAME.c_str()),
910         const_cast<char*>(cmd_.c_str()),
911         const_cast<char*>("--shared-bundle-dir-path"),
912         const_cast<char*>(STRING_BUNDLE_PATH.c_str()),
913         const_cast<char*>(""),
914     };
915     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
916 
917     BundleManagerShellCommand cmd(argc, argv);
918 
919     // set the mock objects
920     SetMockObjects(cmd);
921 
922     EXPECT_EQ(cmd.ExecCommand(), STRING_INSTALL_BUNDLE_OK + "\n");
923 }
924 
925 /**
926  * @tc.number: Bm_Command_Install_3800
927  * @tc.name: ExecCommand
928  * @tc.desc: Verify the "bm install -s <bundle-path>" command.
929  */
930 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_3800, Function | MediumTest | Level1)
931 {
932     // install a bundle
933     char *argv[] = {
934         const_cast<char*>(TOOL_NAME.c_str()),
935         const_cast<char*>(cmd_.c_str()),
936         const_cast<char*>("-s"),
937         const_cast<char*>("-r"),
938         const_cast<char*>("xxx"),
939         const_cast<char*>(""),
940     };
941     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
942 
943     BundleManagerShellCommand cmd(argc, argv);
944 
945     // set the mock objects
946     SetMockObjects(cmd);
947 
948     EXPECT_EQ(cmd.ExecCommand(), STRING_REQUIRE_CORRECT_VALUE);
949 }
950 
951 /**
952  * @tc.number: Bm_Command_Install_3900
953  * @tc.name: ExecCommand
954  * @tc.desc: Verify the "bm install -s <bundle-path>" command.
955  */
956 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_3900, Function | MediumTest | Level1)
957 {
958     // install a bundle
959     char *argv[] = {
960         const_cast<char*>(TOOL_NAME.c_str()),
961         const_cast<char*>(cmd_.c_str()),
962         const_cast<char*>("-s"),
963         const_cast<char*>("--replace"),
964         const_cast<char*>("xxx"),
965         const_cast<char*>(""),
966     };
967     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
968 
969     BundleManagerShellCommand cmd(argc, argv);
970 
971     // set the mock objects
972     SetMockObjects(cmd);
973 
974     EXPECT_EQ(cmd.ExecCommand(), STRING_REQUIRE_CORRECT_VALUE);
975 }
976 
977 /**
978  * @tc.number: Bm_Command_Install_4000
979  * @tc.name: ExecCommand
980  * @tc.desc: Verify the "bm install -s <bundle-path>" command.
981  */
982 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_4000, Function | MediumTest | Level1)
983 {
984     // install a bundle
985     char *argv[] = {
986         const_cast<char*>(TOOL_NAME.c_str()),
987         const_cast<char*>(cmd_.c_str()),
988         const_cast<char*>("-s"),
989         const_cast<char*>("-p"),
990         const_cast<char*>("xxx"),
991         const_cast<char*>(""),
992     };
993     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
994 
995     BundleManagerShellCommand cmd(argc, argv);
996 
997     // set the mock objects
998     SetMockObjects(cmd);
999 
1000     EXPECT_EQ(cmd.ExecCommand(), STRING_REQUIRE_CORRECT_VALUE);
1001 }
1002 
1003 /**
1004  * @tc.number: Bm_Command_Install_4100
1005  * @tc.name: ExecCommand
1006  * @tc.desc: Verify the "bm install -s <bundle-path>" command.
1007  */
1008 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_4100, Function | MediumTest | Level1)
1009 {
1010     // install a bundle
1011     char *argv[] = {
1012         const_cast<char*>(TOOL_NAME.c_str()),
1013         const_cast<char*>(cmd_.c_str()),
1014         const_cast<char*>("-s"),
1015         const_cast<char*>("--bundle-path"),
1016         const_cast<char*>("xxx"),
1017         const_cast<char*>(""),
1018     };
1019     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1020 
1021     BundleManagerShellCommand cmd(argc, argv);
1022 
1023     // set the mock objects
1024     SetMockObjects(cmd);
1025 
1026     EXPECT_EQ(cmd.ExecCommand(), STRING_REQUIRE_CORRECT_VALUE);
1027 }
1028 
1029 /**
1030  * @tc.number: Bm_Command_Install_4200
1031  * @tc.name: ExecCommand
1032  * @tc.desc: Verify the "bm install -s <bundle-path>" command.
1033  */
1034 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_4200, Function | MediumTest | Level1)
1035 {
1036     // install a bundle
1037     char *argv[] = {
1038         const_cast<char*>(TOOL_NAME.c_str()),
1039         const_cast<char*>(cmd_.c_str()),
1040         const_cast<char*>("-s"),
1041         const_cast<char*>("-u"),
1042         const_cast<char*>("xxx"),
1043         const_cast<char*>(""),
1044     };
1045     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1046 
1047     BundleManagerShellCommand cmd(argc, argv);
1048 
1049     // set the mock objects
1050     SetMockObjects(cmd);
1051 
1052     EXPECT_EQ(cmd.ExecCommand(), STRING_REQUIRE_CORRECT_VALUE);
1053 }
1054 
1055 /**
1056  * @tc.number: Bm_Command_Install_4300
1057  * @tc.name: ExecCommand
1058  * @tc.desc: Verify the "bm install -s <bundle-path>" command.
1059  */
1060 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_4300, Function | MediumTest | Level1)
1061 {
1062     // install a bundle
1063     char *argv[] = {
1064         const_cast<char*>(TOOL_NAME.c_str()),
1065         const_cast<char*>(cmd_.c_str()),
1066         const_cast<char*>("-s"),
1067         const_cast<char*>("--user-id"),
1068         const_cast<char*>("xxx"),
1069         const_cast<char*>(""),
1070     };
1071     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1072 
1073     BundleManagerShellCommand cmd(argc, argv);
1074 
1075     // set the mock objects
1076     SetMockObjects(cmd);
1077 
1078     EXPECT_EQ(cmd.ExecCommand(), STRING_REQUIRE_CORRECT_VALUE);
1079 }
1080 
1081 /**
1082  * @tc.number: Bm_Command_Install_4400
1083  * @tc.name: ExecCommand
1084  * @tc.desc: Verify the "bm install -s <bundle-path>" command.
1085  */
1086 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_4400, Function | MediumTest | Level1)
1087 {
1088     // install a bundle
1089     char *argv[] = {
1090         const_cast<char*>(TOOL_NAME.c_str()),
1091         const_cast<char*>(cmd_.c_str()),
1092         const_cast<char*>("-s"),
1093         const_cast<char*>("-w"),
1094         const_cast<char*>("xxx"),
1095         const_cast<char*>(""),
1096     };
1097     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1098 
1099     BundleManagerShellCommand cmd(argc, argv);
1100 
1101     // set the mock objects
1102     SetMockObjects(cmd);
1103 
1104     EXPECT_EQ(cmd.ExecCommand(), STRING_REQUIRE_CORRECT_VALUE);
1105 }
1106 
1107 /**
1108  * @tc.number: Bm_Command_Install_4500
1109  * @tc.name: ExecCommand
1110  * @tc.desc: Verify the "bm install -s <bundle-path>" command.
1111  */
1112 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_4500, Function | MediumTest | Level1)
1113 {
1114     // install a bundle
1115     char *argv[] = {
1116         const_cast<char*>(TOOL_NAME.c_str()),
1117         const_cast<char*>(cmd_.c_str()),
1118         const_cast<char*>("-s"),
1119         const_cast<char*>("--waitting-time"),
1120         const_cast<char*>("xxx"),
1121         const_cast<char*>(""),
1122     };
1123     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1124 
1125     BundleManagerShellCommand cmd(argc, argv);
1126 
1127     // set the mock objects
1128     SetMockObjects(cmd);
1129 
1130     EXPECT_EQ(cmd.ExecCommand(), STRING_REQUIRE_CORRECT_VALUE);
1131 }
1132 
1133 /**
1134  * @tc.number: Bm_Command_Install_4600
1135  * @tc.name: ExecCommand
1136  * @tc.desc: Verify the "bm install -v" command.
1137  */
1138 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_4600, Function | MediumTest | Level1)
1139 {
1140     // install a bundle
1141     char *argv[] = {
1142         const_cast<char*>(TOOL_NAME.c_str()),
1143         const_cast<char*>(cmd_.c_str()),
1144         const_cast<char*>("-v"),
1145         const_cast<char*>(""),
1146     };
1147     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1148 
1149     BundleManagerShellCommand cmd(argc, argv);
1150 
1151     // set the mock objects
1152     SetMockObjects(cmd);
1153 
1154     EXPECT_EQ(cmd.ExecCommand(), STRING_REQUIRE_CORRECT_VALUE + HELP_MSG_INSTALL);
1155 }
1156 
1157 /**
1158  * @tc.number: Bm_Command_Install_4700
1159  * @tc.name: ExecCommand
1160  * @tc.desc: Verify the "bm install -v <signature-file-path>" command.
1161  */
1162 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_4700, Function | MediumTest | Level1)
1163 {
1164     // install a bundle
1165     char *argv[] = {
1166         const_cast<char*>(TOOL_NAME.c_str()),
1167         const_cast<char*>(cmd_.c_str()),
1168         const_cast<char*>("-v"),
1169         const_cast<char*>(STRING_SIGNATURE_FILE_PATH.c_str()),
1170         const_cast<char*>(""),
1171     };
1172     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1173 
1174     BundleManagerShellCommand cmd(argc, argv);
1175 
1176     // set the mock objects
1177     SetMockObjects(cmd);
1178 
1179     EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_NO_BUNDLE_PATH_OPTION + "\n" + HELP_MSG_INSTALL);
1180 }
1181 
1182 /**
1183  * @tc.number: Bm_Command_Install_4800
1184  * @tc.name: ExecCommand
1185  * @tc.desc: Verify the "bm install -p <bundle_path> -v <signature-file-path>" command.
1186  */
1187 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_4800, Function | MediumTest | Level1)
1188 {
1189     // install a bundle
1190     char *argv[] = {
1191         const_cast<char*>(TOOL_NAME.c_str()),
1192         const_cast<char*>(cmd_.c_str()),
1193         const_cast<char*>("-p"),
1194         const_cast<char*>("-v"),
1195         const_cast<char*>(STRING_SIGNATURE_FILE_PATH.c_str()),
1196         const_cast<char*>(""),
1197     };
1198     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1199 
1200     BundleManagerShellCommand cmd(argc, argv);
1201 
1202     // set the mock objects
1203     SetMockObjects(cmd);
1204 
1205     EXPECT_EQ(cmd.ExecCommand(), STRING_REQUIRE_CORRECT_VALUE);
1206 }
1207 
1208 /**
1209  * @tc.number: Bm_Command_Install_4900
1210  * @tc.name: ExecCommand
1211  * @tc.desc: Verify the "bm install -p <bundle_path> -v <signature-file-path>" command.
1212  */
1213 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_4900, Function | MediumTest | Level1)
1214 {
1215     // install a bundle
1216     char *argv[] = {
1217         const_cast<char*>(TOOL_NAME.c_str()),
1218         const_cast<char*>(cmd_.c_str()),
1219         const_cast<char*>("-p"),
1220         const_cast<char*>(STRING_TEST_BUNDLE_PATH.c_str()),
1221         const_cast<char*>("-v"),
1222         const_cast<char*>(STRING_SIGNATURE_FILE_PATH.c_str()),
1223         const_cast<char*>(""),
1224     };
1225     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1226 
1227     BundleManagerShellCommand cmd(argc, argv);
1228 
1229     // set the mock objects
1230     SetMockObjects(cmd);
1231 
1232     EXPECT_EQ(cmd.ExecCommand(), STRING_INSTALL_BUNDLE_OK + "\n");
1233 }
1234 
1235 /**
1236  * @tc.number: Bm_Command_Install_5000
1237  * @tc.name: ExecCommand
1238  * @tc.desc: Verify the "bm install -p <bundle_path> <bundle_path> -v <signature-file-path>" command.
1239  */
1240 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_5000, Function | MediumTest | Level1)
1241 {
1242     // install a bundle
1243     char *argv[] = {
1244         const_cast<char*>(TOOL_NAME.c_str()),
1245         const_cast<char*>(cmd_.c_str()),
1246         const_cast<char*>("-p"),
1247         const_cast<char*>(STRING_BUNDLE_PATH.c_str()),
1248         const_cast<char*>(STRING_OTHER_BUNDLE_PATH.c_str()),
1249         const_cast<char*>("-v"),
1250         const_cast<char*>(STRING_SIGNATURE_FILE_PATH.c_str()),
1251         const_cast<char*>(""),
1252     };
1253     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1254 
1255     BundleManagerShellCommand cmd(argc, argv);
1256 
1257     // set the mock objects
1258     SetMockObjects(cmd);
1259 
1260     EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_NOT_SUPPORT_MULTI_HAP_OR_HSP_INSTALLATION + HELP_MSG_INSTALL);
1261 }
1262 
1263 /**
1264  * @tc.number: Bm_Command_Install_5100
1265  * @tc.name: ExecCommand
1266  * @tc.desc: Verify the "bm install -p <bundle_path_dir> -v <signature-file-path>" command.
1267  */
1268 HWTEST_F(BmCommandInstallTest, Bm_Command_Install_5100, Function | MediumTest | Level1)
1269 {
1270     // install a bundle
1271     char *argv[] = {
1272         const_cast<char*>(TOOL_NAME.c_str()),
1273         const_cast<char*>(cmd_.c_str()),
1274         const_cast<char*>("-p"),
1275         const_cast<char*>(STRING_EMPTY.c_str()),
1276         const_cast<char*>("-v"),
1277         const_cast<char*>(STRING_SIGNATURE_FILE_PATH.c_str()),
1278         const_cast<char*>(""),
1279     };
1280     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1281 
1282     BundleManagerShellCommand cmd(argc, argv);
1283 
1284     // set the mock objects
1285     SetMockObjects(cmd);
1286 
1287     EXPECT_EQ(cmd.ExecCommand(), STRING_REQUIRE_CORRECT_VALUE);
1288 }
1289 } // OHOS