• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <gtest/gtest.h>
17 
18 #define private public
19 #define protected public
20 #include "ability_command.h"
21 #include "shell_command.h"
22 #undef protected
23 #undef private
24 #include "mock_ability_manager_stub.h"
25 #define private public
26 #include "ability_manager_client.h"
27 #undef private
28 #include "ability_manager_interface.h"
29 #include "ability_state.h"
30 #include "hilog_tag_wrapper.h"
31 
32 using namespace testing::ext;
33 using namespace OHOS;
34 using namespace OHOS::AAFwk;
35 
36 class AaCommandFirstTest : public ::testing::Test {
37 public:
38     static void SetUpTestCase();
39     static void TearDownTestCase();
40     void SetUp() override;
41     void TearDown() override;
42 
43     void MakeMockObjects() const;
44     std::string cmd_ = "stop-service";
45     const std::string STRING_BUNDLE_NAME = "bundleName";
46     const std::string STRING_APP_DEBUG = "appdebug";
47 };
48 
SetUpTestCase()49 void AaCommandFirstTest::SetUpTestCase()
50 {}
51 
TearDownTestCase()52 void AaCommandFirstTest::TearDownTestCase()
53 {}
54 
SetUp()55 void AaCommandFirstTest::SetUp()
56 {
57     // reset optind to 0
58     optind = 0;
59 
60     // make mock objects
61     MakeMockObjects();
62 }
63 
TearDown()64 void AaCommandFirstTest::TearDown()
65 {}
66 
MakeMockObjects() const67 void AaCommandFirstTest::MakeMockObjects() const
68 {
69     // mock a stub
70     auto managerStubPtr = sptr<IAbilityManager>(new MockAbilityManagerStub());
71 
72     // set the mock stub
73     auto managerClientPtr = AbilityManagerClient::GetInstance();
74     managerClientPtr->proxy_ = managerStubPtr;
75 }
76 
77 /**
78  * @tc.number: Aa_Command_1001
79  * @tc.name: RunAsForceStop
80  * @tc.desc: Verify RunAsForceStop Function.
81  */
82 HWTEST_F(AaCommandFirstTest, Aa_Command_1001, Function | MediumTest | Level1)
83 {
84     TAG_LOGI(AAFwkTag::TEST, "Aa_Command_1001 is called");
85     char* argv[] = {
86         (char*)TOOL_NAME.c_str(),
87         (char*)cmd_.c_str(),
88         (char*)"-p",
89         (char*)"-r",
90         };
91     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
92     AbilityManagerShellCommand cmd(argc, argv);
93     cmd.argList_.clear();
94     EXPECT_EQ(cmd.RunAsForceStop(), ERR_INVALID_VALUE);
95 }
96 
97 /**
98  * @tc.number: Aa_Command_1002
99  * @tc.name: RunAsForceStop
100  * @tc.desc: Verify RunAsForceStop Function.
101  */
102 HWTEST_F(AaCommandFirstTest, Aa_Command_1002, Function | MediumTest | Level1)
103 {
104     TAG_LOGI(AAFwkTag::TEST, "Aa_Command_1002 is called");
105     char* argv[] = {
106         (char*)TOOL_NAME.c_str(),
107         (char*)cmd_.c_str(),
108         (char*)"-p",
109         (char*)"-r",
110         };
111     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
112     AbilityManagerShellCommand cmd(argc, argv);
113     ErrCode result = cmd.RunAsForceStop();
114     EXPECT_EQ(cmd.resultReceiver_, STRING_FORCE_STOP_OK + "\n");
115     EXPECT_EQ(result, ERR_OK);
116 }
117 
118 /**
119  * @tc.number: Aa_Command_1003
120  * @tc.name: RunAsForceStop
121  * @tc.desc: Verify RunAsForceStop Function.
122  */
123 HWTEST_F(AaCommandFirstTest, Aa_Command_1003, Function | MediumTest | Level1)
124 {
125     TAG_LOGI(AAFwkTag::TEST, "Aa_Command_1003 is called");
126     char* argv[] = {
127         (char*)TOOL_NAME.c_str(),
128         (char*)cmd_.c_str(),
129         (char*)"-p",
130         (char*)"-r",
131         };
132     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
133     AbilityManagerShellCommand cmd(argc, argv);
134     auto managerClientPtr = AbilityManagerClient::GetInstance();
135     auto mockAbilityManagerStub = sptr<MockAbilityManagerStub>(new MockAbilityManagerStub());
136     ASSERT_NE(mockAbilityManagerStub, nullptr);
137     EXPECT_CALL(*mockAbilityManagerStub, KillProcess(testing::_, testing::_, testing::_))
138         .Times(1)
139         .WillOnce(testing::Return(-1));
140     managerClientPtr->proxy_ = static_cast<IAbilityManager*>(mockAbilityManagerStub);
141     ErrCode result = cmd.RunAsForceStop();
142     EXPECT_NE(result, ERR_OK);
143     testing::Mock::AllowLeak(mockAbilityManagerStub);
144 }
145 
146 /**
147  * @tc.number: Aa_Command_1004
148  * @tc.name: MakeWantFromCmd
149  * @tc.desc: Verify MakeWantFromCmd Function.
150  */
151 HWTEST_F(AaCommandFirstTest, Aa_Command_1004, Function | MediumTest | Level1)
152 {
153     TAG_LOGI(AAFwkTag::TEST, "Aa_Command_1004 is called");
154     char* argv[] = {
155         (char*)TOOL_NAME.c_str(),
156         (char*)"start",
157         (char*)"-e",
158         (char*)"com.example.myapplication",
159     };
160     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
161 
162     AbilityManagerShellCommand cmd(argc, argv);
163     Want want;
164     std::string windowMode;
165     EXPECT_EQ(cmd.MakeWantFromCmd(want, windowMode), OHOS::ERR_INVALID_VALUE);
166 }
167 
168 /**
169  * @tc.number: Aa_Command_1005
170  * @tc.name: MakeWantFromCmd
171  * @tc.desc: Verify MakeWantFromCmd Function.
172  */
173 HWTEST_F(AaCommandFirstTest, Aa_Command_1005, Function | MediumTest | Level1)
174 {
175     TAG_LOGI(AAFwkTag::TEST, "Aa_Command_1005 is called");
176     char* argv[] = {
177         (char*)TOOL_NAME.c_str(),
178         (char*)"start",
179         (char*)"-t",
180         (char*)"com.example.myapplication",
181     };
182     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
183 
184     AbilityManagerShellCommand cmd(argc, argv);
185     Want want;
186     std::string windowMode;
187     EXPECT_EQ(cmd.MakeWantFromCmd(want, windowMode), OHOS::ERR_INVALID_VALUE);
188 }
189 
190 /**
191  * @tc.number: Aa_Command_1006
192  * @tc.name: MakeWantFromCmd
193  * @tc.desc: Verify MakeWantFromCmd Function.
194  */
195 HWTEST_F(AaCommandFirstTest, Aa_Command_1006, Function | MediumTest | Level1)
196 {
197     TAG_LOGI(AAFwkTag::TEST, "Aa_Command_1006 is called");
198     char* argv[] = {
199         (char*)TOOL_NAME.c_str(),
200         (char*)"start",
201         (char*)"-s",
202         (char*)"com.example.myapplication",
203     };
204     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
205 
206     AbilityManagerShellCommand cmd(argc, argv);
207     Want want;
208     std::string windowMode;
209     EXPECT_EQ(cmd.MakeWantFromCmd(want, windowMode), OHOS::ERR_INVALID_VALUE);
210 }
211 
212 /**
213  * @tc.number: Aa_Command_1007
214  * @tc.name: MakeWantFromCmd
215  * @tc.desc: Verify MakeWantFromCmd Function.
216  */
217 HWTEST_F(AaCommandFirstTest, Aa_Command_1007, Function | MediumTest | Level1)
218 {
219     TAG_LOGI(AAFwkTag::TEST, "Aa_Command_1007 is called");
220     char* argv[] = {
221         (char*)TOOL_NAME.c_str(),
222         (char*)"stop-service",
223         (char*)"-s",
224         (char*)"com.example.myapplication",
225     };
226     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
227 
228     AbilityManagerShellCommand cmd(argc, argv);
229     Want want;
230     std::string windowMode;
231     EXPECT_EQ(cmd.MakeWantFromCmd(want, windowMode), OHOS::ERR_INVALID_VALUE);
232 }
233 
234 /**
235  * @tc.number: Aa_Command_1008
236  * @tc.name: MakeWantFromCmd
237  * @tc.desc: Verify MakeWantFromCmd Function.
238  */
239 HWTEST_F(AaCommandFirstTest, Aa_Command_1008, Function | MediumTest | Level1)
240 {
241     TAG_LOGI(AAFwkTag::TEST, "Aa_Command_1008 is called");
242     char* argv[] = {
243         (char*)TOOL_NAME.c_str(),
244         (char*)"stop-service",
245         (char*)"-m",
246         (char*)"com.example.myapplication",
247     };
248     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
249 
250     AbilityManagerShellCommand cmd(argc, argv);
251     Want want;
252     std::string windowMode;
253     EXPECT_EQ(cmd.MakeWantFromCmd(want, windowMode), OHOS::ERR_INVALID_VALUE);
254 }
255 
256 /**
257  * @tc.number: Aa_Command_1009
258  * @tc.name: MakeWantFromCmd
259  * @tc.desc: Verify MakeWantFromCmd Function.
260  */
261 HWTEST_F(AaCommandFirstTest, Aa_Command_1009, Function | MediumTest | Level1)
262 {
263     TAG_LOGI(AAFwkTag::TEST, "Aa_Command_1009 is called");
264     char* argv[] = {
265         (char*)TOOL_NAME.c_str(),
266         (char*)"start",
267         (char*)"-m",
268         (char*)"com.example.myapplication",
269     };
270     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
271 
272     AbilityManagerShellCommand cmd(argc, argv);
273     Want want;
274     std::string windowMode;
275     EXPECT_EQ(cmd.MakeWantFromCmd(want, windowMode), OHOS::ERR_INVALID_VALUE);
276 }
277 
278 /**
279  * @tc.number: Aa_Command_Ability_CovertExitReason_0001
280  * @tc.name: CovertExitReason
281  * @tc.desc: Verify the CovertExitReason function.
282  */
283 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_CovertExitReason_0001,
284          Function | MediumTest | Level1) {
285     TAG_LOGI(AAFwkTag::TEST, "CovertExitReason_0001 is called");
286     char* argv[] = {(char*)TOOL_NAME.c_str()};
287     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
288     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
289     std::string reasonStr = "";
290     EXPECT_EQ(cmd->CovertExitReason(reasonStr), Reason::REASON_UNKNOWN);
291     TAG_LOGI(AAFwkTag::TEST, "CovertExitReason_0001 is end");
292 }
293 
294 /**
295  * @tc.number: Aa_Command_Ability_CovertExitReason_0002
296  * @tc.name: CovertExitReason
297  * @tc.desc: Verify the CovertExitReason function.
298  */
299 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_CovertExitReason_0002,
300          Function | MediumTest | Level1) {
301     TAG_LOGI(AAFwkTag::TEST, "CovertExitReason_0002 is called");
302     char* argv[] = {(char*)TOOL_NAME.c_str()};
303     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
304     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
305     std::string reasonStr = "UNKNOWN";
306     EXPECT_EQ(cmd->CovertExitReason(reasonStr), Reason::REASON_UNKNOWN);
307     TAG_LOGI(AAFwkTag::TEST, "CovertExitReason_0002 is end");
308 }
309 
310 /**
311  * @tc.number: Aa_Command_Ability_CovertExitReason_0003
312  * @tc.name: CovertExitReason
313  * @tc.desc: Verify the CovertExitReason function.
314  */
315 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_CovertExitReason_0003,
316          Function | MediumTest | Level1) {
317     TAG_LOGI(AAFwkTag::TEST, "CovertExitReason_0002 is called");
318     char* argv[] = {(char*)TOOL_NAME.c_str()};
319     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
320     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
321     std::string reasonStr = "NORMAL";
322     EXPECT_EQ(cmd->CovertExitReason(reasonStr), Reason::REASON_NORMAL);
323     TAG_LOGI(AAFwkTag::TEST, "CovertExitReason_0003 is end");
324 }
325 
326 /**
327  * @tc.number: Aa_Command_Ability_CovertExitReason_0004
328  * @tc.name: CovertExitReason
329  * @tc.desc: Verify the CovertExitReason function.
330  */
331 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_CovertExitReason_0004,
332          Function | MediumTest | Level1) {
333     TAG_LOGI(AAFwkTag::TEST, "CovertExitReason_0004 is called");
334     char* argv[] = {(char*)TOOL_NAME.c_str()};
335     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
336     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
337     std::string reasonStr = "CPP_CRASH";
338     EXPECT_EQ(cmd->CovertExitReason(reasonStr), Reason::REASON_CPP_CRASH);
339     TAG_LOGI(AAFwkTag::TEST, "CovertExitReason_0004 is end");
340 }
341 
342 /**
343  * @tc.number: Aa_Command_Ability_CovertExitReason_0005
344  * @tc.name: CovertExitReason
345  * @tc.desc: Verify the CovertExitReason function.
346  */
347 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_CovertExitReason_0005,
348          Function | MediumTest | Level1) {
349     TAG_LOGI(AAFwkTag::TEST, "CovertExitReason_0004 is called");
350     char* argv[] = {(char*)TOOL_NAME.c_str()};
351     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
352     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
353     std::string reasonStr = "JS_ERROR";
354     EXPECT_EQ(cmd->CovertExitReason(reasonStr), Reason::REASON_JS_ERROR);
355     TAG_LOGI(AAFwkTag::TEST, "CovertExitReason_0005 is end");
356 }
357 
358 /**
359  * @tc.number: Aa_Command_Ability_CovertExitReason_0006
360  * @tc.name: CovertExitReason
361  * @tc.desc: Verify the CovertExitReason function.
362  */
363 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_CovertExitReason_0006,
364          Function | MediumTest | Level1) {
365     TAG_LOGI(AAFwkTag::TEST, "CovertExitReason_0006 is called");
366     char* argv[] = {(char*)TOOL_NAME.c_str()};
367     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
368     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
369     std::string reasonStr = "APP_FREEZE";
370     EXPECT_EQ(cmd->CovertExitReason(reasonStr), Reason::REASON_APP_FREEZE);
371     TAG_LOGI(AAFwkTag::TEST, "CovertExitReason_0006 is end");
372 }
373 
374 /**
375  * @tc.number: Aa_Command_Ability_CovertExitReason_0007
376  * @tc.name: CovertExitReason
377  * @tc.desc: Verify the CovertExitReason function.
378  */
379 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_CovertExitReason_0007,
380          Function | MediumTest | Level1) {
381     TAG_LOGI(AAFwkTag::TEST, "CovertExitReason_0007 is called");
382     char* argv[] = {(char*)TOOL_NAME.c_str()};
383     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
384     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
385     std::string reasonStr = "PERFORMANCE_CONTROL";
386     EXPECT_EQ(cmd->CovertExitReason(reasonStr),
387             Reason::REASON_PERFORMANCE_CONTROL);
388     TAG_LOGI(AAFwkTag::TEST, "CovertExitReason_0007 is end");
389 }
390 
391 /**
392  * @tc.number: Aa_Command_Ability_CovertExitReason
393  * @tc.name: CovertExitReason
394  * @tc.desc: Verify the CovertExitReason function.
395  */
396 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_CovertExitReason_0008,
397          Function | MediumTest | Level1) {
398     TAG_LOGI(AAFwkTag::TEST, "CovertExitReason_0008 is called");
399     char* argv[] = {(char*)TOOL_NAME.c_str()};
400     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
401     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
402     std::string reasonStr = "RESOURCE_CONTROL";
403     EXPECT_EQ(cmd->CovertExitReason(reasonStr), Reason::REASON_RESOURCE_CONTROL);
404     TAG_LOGI(AAFwkTag::TEST, "CovertExitReason_0008 is end");
405 }
406 
407 /**
408  * @tc.number: Aa_Command_Ability_CovertExitReason_0009
409  * @tc.name: CovertExitReason
410  * @tc.desc: Verify the CovertExitReason function.
411  */
412 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_CovertExitReason_0009,
413          Function | MediumTest | Level1) {
414     TAG_LOGI(AAFwkTag::TEST, "CovertExitReason_0009 is called");
415     char* argv[] = {(char*)TOOL_NAME.c_str()};
416     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
417     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
418     std::string reasonStr = "UPGRADE";
419     EXPECT_EQ(cmd->CovertExitReason(reasonStr), Reason::REASON_UPGRADE);
420     TAG_LOGI(AAFwkTag::TEST, "CovertExitReason_0009 is end");
421 }
422 
423 /**
424  * @tc.number: Aa_Command_Ability_CovertExitReason_0010
425  * @tc.name: CovertExitReason
426  * @tc.desc: Verify the CovertExitReason function.
427  */
428 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_CovertExitReason_0010,
429          Function | MediumTest | Level1) {
430     TAG_LOGI(AAFwkTag::TEST, "CovertExitReason_0010 is called");
431     char* argv[] = {(char*)TOOL_NAME.c_str()};
432     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
433     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
434     std::string reasonStr = "null";
435     EXPECT_EQ(cmd->CovertExitReason(reasonStr), Reason::REASON_UNKNOWN);
436     TAG_LOGI(AAFwkTag::TEST, "CovertExitReason_0010 is end");
437 }
438 
439 /**
440  * @tc.number: Aa_Command_Ability_MakeWantForProcess_0001
441  * @tc.name: MakeWantForProcess
442  * @tc.desc: Verify the MakeWantForProcess function.
443  */
444 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_MakeWantForProcess_0001,
445          Function | MediumTest | Level1) {
446     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0001 is called");
447     char* argv[] = {
448         (char*)TOOL_NAME.c_str(),
449         (char*)"process",
450         (char*)"",
451     };
452     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
453     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
454     Want want;
455     EXPECT_EQ(cmd->MakeWantForProcess(want), OHOS::ERR_INVALID_VALUE);
456     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0001 is end");
457 }
458 
459 /**
460  * @tc.number: Aa_Command_Ability_MakeWantForProcess_0002
461  * @tc.name: MakeWantForProcess
462  * @tc.desc: Verify the MakeWantForProcess function.
463  */
464 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_MakeWantForProcess_0002,
465          Function | MediumTest | Level1) {
466     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0002 is called");
467     char* argv[] = {
468         (char*)TOOL_NAME.c_str(),
469         (char*)"process",
470         (char*)"-a",
471         (char*)"",
472     };
473     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
474     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
475     Want want;
476     EXPECT_EQ(cmd->MakeWantForProcess(want), OHOS::ERR_INVALID_VALUE);
477     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0002 is end");
478 }
479 
480 /**
481  * @tc.number: Aa_Command_Ability_MakeWantForProcess_0003
482  * @tc.name: MakeWantForProcess
483  * @tc.desc: Verify the MakeWantForProcess function.
484  */
485 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_MakeWantForProcess_0003,
486          Function | MediumTest | Level1) {
487     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0003 is called");
488     char* argv[] = {
489         (char*)TOOL_NAME.c_str(),
490         (char*)"process",
491         (char*)"--x",
492         (char*)"",
493     };
494     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
495     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
496     Want want;
497     EXPECT_EQ(cmd->MakeWantForProcess(want), OHOS::ERR_INVALID_VALUE);
498     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0003 is end");
499 }
500 
501 /**
502  * @tc.number: Aa_Command_Ability_MakeWantForProcess_0004
503  * @tc.name: MakeWantForProcess
504  * @tc.desc: Verify the MakeWantForProcess function.
505  */
506 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_MakeWantForProcess_0004,
507          Function | MediumTest | Level1) {
508     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0004 is called");
509     char* argv[] = {
510         (char*)TOOL_NAME.c_str(),
511         (char*)"process",
512         (char*)"-b",
513         (char*)"",
514     };
515     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
516     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
517     Want want;
518     EXPECT_EQ(cmd->MakeWantForProcess(want), OHOS::ERR_INVALID_VALUE);
519     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0004 is end");
520 }
521 
522 /**
523  * @tc.number: Aa_Command_Ability_MakeWantForProcess_0005
524  * @tc.name: MakeWantForProcess
525  * @tc.desc: Verify the MakeWantForProcess function.
526  */
527 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_MakeWantForProcess_0005,
528          Function | MediumTest | Level1) {
529     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0005 is called");
530     char* argv[] = {
531         (char*)TOOL_NAME.c_str(),
532         (char*)"process",
533         (char*)"-m",
534         (char*)"",
535     };
536     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
537     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
538     Want want;
539     EXPECT_EQ(cmd->MakeWantForProcess(want), OHOS::ERR_INVALID_VALUE);
540     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0005 is end");
541 }
542 
543 /**
544  * @tc.number: Aa_Command_Ability_MakeWantForProcess_0006
545  * @tc.name: MakeWantForProcess
546  * @tc.desc: Verify the MakeWantForProcess function.
547  */
548 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_MakeWantForProcess_0006,
549          Function | MediumTest | Level1) {
550     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0006 is called");
551     char* argv[] = {
552         (char*)TOOL_NAME.c_str(),
553         (char*)"process",
554         (char*)"-p",
555         (char*)"",
556     };
557     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
558     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
559     Want want;
560     EXPECT_EQ(cmd->MakeWantForProcess(want), OHOS::ERR_INVALID_VALUE);
561     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0006 is end");
562 }
563 
564 /**
565  * @tc.number: Aa_Command_Ability_MakeWantForProcess_0007
566  * @tc.name: MakeWantForProcess
567  * @tc.desc: Verify the MakeWantForProcess function.
568  */
569 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_MakeWantForProcess_0007,
570          Function | MediumTest | Level1) {
571     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0007 is called");
572     char* argv[] = {
573         (char*)TOOL_NAME.c_str(),
574         (char*)"process",
575         (char*)"-D",
576         (char*)"",
577     };
578     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
579     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
580     Want want;
581     EXPECT_EQ(cmd->MakeWantForProcess(want), OHOS::ERR_INVALID_VALUE);
582     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0007 is end");
583 }
584 
585 /**
586  * @tc.number: Aa_Command_Ability_MakeWantForProcess_0008
587  * @tc.name: MakeWantForProcess
588  * @tc.desc: Verify the MakeWantForProcess function.
589  */
590 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_MakeWantForProcess_0008,
591          Function | MediumTest | Level1) {
592     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0008 is called");
593     char* argv[] = {
594         (char*)TOOL_NAME.c_str(),
595         (char*)"process",
596         (char*)"-h",
597         (char*)"",
598     };
599     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
600     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
601     Want want;
602     EXPECT_EQ(cmd->MakeWantForProcess(want), OHOS::ERR_INVALID_VALUE);
603     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0008 is end");
604 }
605 
606 /**
607  * @tc.number: Aa_Command_Ability_MakeWantForProcess_0009
608  * @tc.name: MakeWantForProcess
609  * @tc.desc: Verify the MakeWantForProcess function.
610  */
611 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_MakeWantForProcess_0009,
612          Function | MediumTest | Level1) {
613     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0009 is called");
614     char* argv[] = {
615         (char*)TOOL_NAME.c_str(),
616         (char*)"process",
617         (char*)"--help",
618         (char*)"",
619     };
620     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
621     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
622     Want want;
623     EXPECT_EQ(cmd->MakeWantForProcess(want), OHOS::ERR_INVALID_VALUE);
624     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0009 is end");
625 }
626 
627 /**
628  * @tc.number: Aa_Command_Ability_MakeWantForProcess_0010
629  * @tc.name: MakeWantForProcess
630  * @tc.desc: Verify the MakeWantForProcess function.
631  */
632 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_MakeWantForProcess_0010,
633          Function | MediumTest | Level1) {
634     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0010 is called");
635     char* argv[] = {
636         (char*)TOOL_NAME.c_str(),
637         (char*)"process",
638         (char*)"-p",
639         (char*)"xxx",
640         (char*)"",
641 
642     };
643     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
644     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
645     Want want;
646     EXPECT_EQ(cmd->MakeWantForProcess(want), OHOS::ERR_INVALID_VALUE);
647     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0010 is end");
648 }
649 
650 /**
651  * @tc.number: Aa_Command_Ability_MakeWantForProcess_0011
652  * @tc.name: MakeWantForProcess
653  * @tc.desc: Verify the MakeWantForProcess function.
654  */
655 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_MakeWantForProcess_0011,
656          Function | MediumTest | Level1) {
657     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0011 is called");
658     char* argv[] = {
659         (char*)TOOL_NAME.c_str(),
660         (char*)"process",
661         (char*)"-b",
662         (char*)"xxx",
663         (char*)"",
664     };
665     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
666     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
667     Want want;
668     EXPECT_EQ(cmd->MakeWantForProcess(want), OHOS::ERR_INVALID_VALUE);
669     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0011 is end");
670 }
671 
672 /**
673  * @tc.number: Aa_Command_Ability_MakeWantForProcess_0012
674  * @tc.name: MakeWantForProcess
675  * @tc.desc: Verify the MakeWantForProcess function.
676  */
677 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_MakeWantForProcess_0012,
678          Function | MediumTest | Level1) {
679     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0012 is called");
680     char* argv[] = {
681         (char*)TOOL_NAME.c_str(),
682         (char*)"process",
683         (char*)"-m",
684         (char*)"xxx",
685         (char*)"",
686     };
687     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
688     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
689     Want want;
690     EXPECT_EQ(cmd->MakeWantForProcess(want), OHOS::ERR_INVALID_VALUE);
691     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0012 is end");
692 }
693 
694 /**
695  * @tc.number: Aa_Command_Ability_MakeWantForProcess_0013
696  * @tc.name: MakeWantForProcess
697  * @tc.desc: Verify the MakeWantForProcess function.
698  */
699 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_MakeWantForProcess_0013,
700          Function | MediumTest | Level1) {
701     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0013 is called");
702     char* argv[] = {
703         (char*)TOOL_NAME.c_str(),
704         (char*)"process",
705         (char*)"-p",
706         (char*)"xxx",
707         (char*)"",
708     };
709     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
710     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
711     Want want;
712     EXPECT_EQ(cmd->MakeWantForProcess(want), OHOS::ERR_INVALID_VALUE);
713     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0013 is end");
714 }
715 
716 /**
717  * @tc.number: Aa_Command_Ability_MakeWantForProcess_0014
718  * @tc.name: MakeWantForProcess
719  * @tc.desc: Verify the MakeWantForProcess function.
720  */
721 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_MakeWantForProcess_0014,
722          Function | MediumTest | Level1) {
723     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0014 is called");
724     char* argv[] = {
725         (char*)TOOL_NAME.c_str(),
726         (char*)"process",
727         (char*)"-D",
728         (char*)"xxx",
729         (char*)"",
730     };
731     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
732     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
733     Want want;
734     EXPECT_EQ(cmd->MakeWantForProcess(want), OHOS::ERR_INVALID_VALUE);
735     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0014 is end");
736 }
737 
738 /**
739  * @tc.number: Aa_Command_Ability_MakeWantForProcess_0015
740  * @tc.name: MakeWantForProcess
741  * @tc.desc: Verify the MakeWantForProcess function.
742  */
743 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_MakeWantForProcess_0015,
744          Function | MediumTest | Level1) {
745     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0015 is called");
746     char* argv[] = {
747         (char*)TOOL_NAME.c_str(),
748         (char*)"process",
749         (char*)"-S",
750         (char*)"xxx",
751         (char*)"",
752     };
753     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
754     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
755     Want want;
756     EXPECT_EQ(cmd->MakeWantForProcess(want), OHOS::ERR_INVALID_VALUE);
757     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0015 is end");
758 }
759 
760 /**
761  * @tc.number: Aa_Command_Ability_MakeWantForProcess_0016
762  * @tc.name: MakeWantForProcess
763  * @tc.desc: Verify the MakeWantForProcess function.
764  */
765 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_MakeWantForProcess_0016,
766          Function | MediumTest | Level1) {
767     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0016 is called");
768     char* argv[] = {
769         (char*)TOOL_NAME.c_str(),
770         (char*)"process",
771         (char*)"-a",
772         (char*)"MyAbility",
773         (char*)"-b",
774         (char*)"com.example.app",
775         (char*)"-p",
776         (char*)"my_perf_command",
777         (char*)"",
778     };
779     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
780     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
781     Want want;
782     EXPECT_EQ(cmd->MakeWantForProcess(want), OHOS::ERR_OK);
783     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0016 is end");
784 }
785 
786 /**
787  * @tc.number: Aa_Command_Ability_MakeWantForProcess_0017
788  * @tc.name: MakeWantForProcess
789  * @tc.desc: Verify the MakeWantForProcess function.
790  */
791 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_MakeWantForProcess_0017,
792          Function | MediumTest | Level1) {
793     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0017 is called");
794     char* argv[] = {
795         (char*)TOOL_NAME.c_str(),
796         (char*)"process",
797         (char*)"-a",
798         (char*)"MyAbility",
799         (char*)"-b",
800         (char*)"com.example.app",
801         (char*)"-D",
802         (char*)"my_perf_command",
803         (char*)"",
804     };
805     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
806     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
807     Want want;
808     EXPECT_EQ(cmd->MakeWantForProcess(want), OHOS::ERR_OK);
809     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0017 is end");
810 }
811 
812 /**
813  * @tc.number: Aa_Command_Ability_MakeWantForProcess_0018
814  * @tc.name: MakeWantForProcess
815  * @tc.desc: Verify the MakeWantForProcess function.
816  */
817 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_MakeWantForProcess_0018,
818          Function | MediumTest | Level1) {
819     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0018 is called");
820     char* argv[] = {
821         (char*)TOOL_NAME.c_str(),
822         (char*)"process",
823         (char*)"-a",
824         (char*)"MyAbility",
825         (char*)"-b",
826         (char*)"com.example.app",
827         (char*)"-D",
828         (char*)"my_perf_command",
829         (char*)"-S",
830         (char*)"",
831     };
832     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
833     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
834     Want want;
835     EXPECT_EQ(cmd->MakeWantForProcess(want), OHOS::ERR_OK);
836     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0018 is end");
837 }
838 
839 /**
840  * @tc.number: Aa_Command_Ability_MakeWantForProcess_0019
841  * @tc.name: MakeWantForProcess
842  * @tc.desc: Verify the MakeWantForProcess function.
843  */
844 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_MakeWantForProcess_0019,
845          Function | MediumTest | Level1) {
846     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0019 is called");
847     char* argv[] = {
848         (char*)TOOL_NAME.c_str(),
849         (char*)"process",
850         (char*)"-a",
851         (char*)"MyAbility",
852         (char*)"-b",
853         (char*)"com.example.app",
854         (char*)"-m",
855         (char*)"MyModule",
856         (char*)"-D",
857         (char*)"my_perf_command",
858         (char*)"",
859     };
860     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
861     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
862     Want want;
863     EXPECT_EQ(cmd->MakeWantForProcess(want), OHOS::ERR_OK);
864     TAG_LOGI(AAFwkTag::TEST, "MakeWantForProcess_0019 is end");
865 }
866 
867 /**
868  * @tc.number: Aa_Command_Ability_First_0001
869  * @tc.name: ConvertPid
870  * @tc.desc: Verify ConvertPid Function.
871  */
872 HWTEST_F(AaCommandFirstTest, AaCommandAbility_ConvertPid_0001, Function | MediumTest | Level1)
873 {
874     TAG_LOGI(AAFwkTag::TEST, "AaCommandAbility_ConvertPid_0001 is called");
875     char* argv[] = { (char*)TOOL_NAME.c_str() };
876     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
877 
878     AbilityManagerShellCommand cmd(argc, argv);
879     std::string inputPid;
880     pid_t pid = 0;
881     EXPECT_EQ(cmd.ConvertPid(inputPid), pid);
882 }
883 
884 /**
885  * @tc.number: Aa_Command_Ability_First_SwitchOptionForAppDebug_0001
886  * @tc.name: SwitchOptionForAppDebug
887  * @tc.desc: Verify SwitchOptionForAppDebug Function.
888  */
889 HWTEST_F(AaCommandFirstTest, AaCommandAbility_SwitchOptionForAppDebug_0001, Function | MediumTest | Level1)
890 {
891     TAG_LOGI(AAFwkTag::TEST, "AaCommandAbility_SwitchOptionForAppDebug_0001 is called");
892     char* argv[] = { (char*)TOOL_NAME.c_str(), (char*)STRING_APP_DEBUG.c_str(), };
893     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
894 
895     AbilityManagerShellCommand cmd(argc, argv);
896     int32_t option = 'h';
897     std::string bundleName;
898     bool isPersist;
899     bool isCancel;
900     bool isGet;
901     EXPECT_EQ(cmd.SwitchOptionForAppDebug(option, bundleName, isPersist, isCancel, isGet), true);
902 }
903 
904 /**
905  * @tc.number: Aa_Command_Ability_First_SwitchOptionForAppDebug_0002
906  * @tc.name: SwitchOptionForAppDebug
907  * @tc.desc: Verify SwitchOptionForAppDebug Function.
908  */
909 HWTEST_F(AaCommandFirstTest, AaCommandAbility_SwitchOptionForAppDebug_0002, Function | MediumTest | Level1)
910 {
911     TAG_LOGI(AAFwkTag::TEST, "AaCommandAbility_SwitchOptionForAppDebug_0002 is called");
912     char* argv[] = { (char*)TOOL_NAME.c_str(), (char*)STRING_APP_DEBUG.c_str(), };
913     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
914 
915     AbilityManagerShellCommand cmd(argc, argv);
916     int32_t option = 'p';
917     std::string bundleName;
918     bool isPersist;
919     bool isCancel;
920     bool isGet;
921     EXPECT_EQ(cmd.SwitchOptionForAppDebug(option, bundleName, isPersist, isCancel, isGet), false);
922     EXPECT_EQ(isPersist, true);
923 }
924 
925 /**
926  * @tc.number: Aa_Command_Ability_First_SwitchOptionForAppDebug_0003
927  * @tc.name: SwitchOptionForAppDebug
928  * @tc.desc: Verify SwitchOptionForAppDebug Function.
929  */
930 HWTEST_F(AaCommandFirstTest, AaCommandAbility_SwitchOptionForAppDebug_0003, Function | MediumTest | Level1)
931 {
932     TAG_LOGI(AAFwkTag::TEST, "AaCommandAbility_SwitchOptionForAppDebug_0003 is called");
933     char* argv[] = { (char*)TOOL_NAME.c_str(), (char*)STRING_APP_DEBUG.c_str(), };
934     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
935 
936     AbilityManagerShellCommand cmd(argc, argv);
937     int32_t option = 'c';
938     std::string bundleName;
939     bool isPersist;
940     bool isCancel;
941     bool isGet;
942     EXPECT_EQ(cmd.SwitchOptionForAppDebug(option, bundleName, isPersist, isCancel, isGet), true);
943     std::cout<<"isCancel = "<<isCancel<<std::endl;
944     EXPECT_EQ(isCancel, true);
945 }
946 
947 /**
948  * @tc.number: Aa_Command_Ability_First_SwitchOptionForAppDebug_0004
949  * @tc.name: SwitchOptionForAppDebug
950  * @tc.desc: Verify SwitchOptionForAppDebug Function.
951  */
952 HWTEST_F(AaCommandFirstTest, AaCommandAbility_SwitchOptionForAppDebug_0004, Function | MediumTest | Level1)
953 {
954     TAG_LOGI(AAFwkTag::TEST, "AaCommandAbility_SwitchOptionForAppDebug_0004 is called");
955     char* argv[] = { (char*)TOOL_NAME.c_str(), (char*)STRING_APP_DEBUG.c_str(), };
956     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
957 
958     AbilityManagerShellCommand cmd(argc, argv);
959     int32_t option = 'g';
960     std::string bundleName;
961     bool isPersist;
962     bool isCancel;
963     bool isGet;
964     EXPECT_EQ(cmd.SwitchOptionForAppDebug(option, bundleName, isPersist, isCancel, isGet), true);
965     std::cout<<"isGet = "<<isGet<<std::endl;
966     EXPECT_EQ(isGet, true);
967 }
968 
969 /**
970  * @tc.number: Aa_Command_Ability_First_SwitchOptionForAppDebug_0005
971  * @tc.name: SwitchOptionForAppDebug
972  * @tc.desc: Verify SwitchOptionForAppDebug Function.
973  */
974 HWTEST_F(AaCommandFirstTest, AaCommandAbility_SwitchOptionForAppDebug_0005, Function | MediumTest | Level1)
975 {
976     TAG_LOGI(AAFwkTag::TEST, "AaCommandAbility_SwitchOptionForAppDebug_0005 is called");
977     char* argv[] = { (char*)TOOL_NAME.c_str(), (char*)STRING_APP_DEBUG.c_str(), };
978     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
979 
980     AbilityManagerShellCommand cmd(argc, argv);
981     int32_t option = 0;
982     std::string bundleName;
983     bool isPersist;
984     bool isCancel;
985     bool isGet;
986     EXPECT_EQ(cmd.SwitchOptionForAppDebug(option, bundleName, isPersist, isCancel, isGet), true);
987 }
988 
989 /**
990  * @tc.number: Aa_Command_Ability_RunAsProcessCommand_0001
991  * @tc.name: RunAsProcessCommand
992  * @tc.desc: Verify the MakeWantForProcess function.
993  */
994 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_RunAsProcessCommand_0001,
995          Function | MediumTest | Level1) {
996     TAG_LOGI(AAFwkTag::TEST, "RunAsProcessCommand_0001 is called");
997     char* argv[] = {
998         (char*)TOOL_NAME.c_str(),
999         (char*)"stop-service",
1000         (char*)"-m",
1001         (char*)"com.example.myapplication",
1002     };
1003     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1004     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
1005     EXPECT_EQ(cmd->RunAsProcessCommand(), OHOS::ERR_INVALID_VALUE);
1006     TAG_LOGI(AAFwkTag::TEST, "RunAsProcessCommand_0001 is end");
1007 }
1008 
1009 /**
1010  * @tc.number: Aa_Command_Ability_RunAsProcessCommand_0002
1011  * @tc.name: MakeWantForProcess
1012  * @tc.desc: Verify the MakeWantForProcess function.
1013  */
1014 HWTEST_F(AaCommandFirstTest, Aa_Command_Ability_RunAsProcessCommand_0002,
1015          Function | MediumTest | Level1) {
1016     TAG_LOGI(AAFwkTag::TEST, "RunAsProcessCommand_0002 is called");
1017     char* argv[] = {
1018         (char*)TOOL_NAME.c_str(),
1019         (char*)"process",
1020         (char*)"-a",
1021         (char*)"MyAbility",
1022         (char*)"-b",
1023         (char*)"com.example.app",
1024         (char*)"-p",
1025         (char*)"my_perf_command",
1026         (char*)"",
1027     };
1028     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1029     auto cmd = std::make_shared<AbilityManagerShellCommand>(argc, argv);
1030 
1031     ErrCode result = cmd->RunAsProcessCommand();
1032     EXPECT_EQ(result, OHOS::ERR_INVALID_OPERATION);
1033     EXPECT_NE(cmd->resultReceiver_.find(STRING_START_NATIVE_PROCESS_NG), string::npos);
1034     TAG_LOGI(AAFwkTag::TEST, "RunAsProcessCommand_0002 is end");
1035 }
1036 
1037 /**
1038  * @tc.number: Aa_Command_RunAsAppDebugDebugCommand_0100
1039  * @tc.name: Parse bundleName from argv[]
1040  * @tc.desc: Verify that returns ERR_INVALID_VALUE.
1041  */
1042 HWTEST_F(AaCommandFirstTest, RunAsAppDebugDebugCommand_0100, TestSize.Level1)
1043 {
1044     GTEST_LOG_(INFO) << "Aa_Command_RunAsAppDebugDebugCommand_0100";
1045 
1046     char* argv[] = {
1047         (char*)TOOL_NAME.c_str(),
1048         (char*)STRING_APP_DEBUG.c_str(),
1049         (char*)"-b",
1050         (char*)"",
1051     };
1052     int32_t argc = sizeof(argv) / sizeof(argv[0]) - 1;
1053 
1054     AbilityManagerShellCommand cmd(argc, argv);
1055     cmd.RunAsAttachDebugCommand();
1056     EXPECT_EQ(cmd.RunAsAttachDebugCommand(), OHOS::ERR_INVALID_VALUE);
1057 }
1058 
1059 /**
1060  * @tc.number: Aa_Command_RunAsAppDebugDebugCommand_0200
1061  * @tc.name: RunAsAppDebugDebugCommand
1062  * @tc.desc: Verify that isCancel is true and returns ERR_OK.
1063  */
1064 HWTEST_F(AaCommandFirstTest, RunAsAppDebugDebugCommand_0200, Function | MediumTest | Level1)
1065 {
1066     GTEST_LOG_(INFO) << "RunAsAppDebugDebugCommand_0200 start";
1067     char* argv[] = {
1068         (char*)TOOL_NAME.c_str(),
1069         (char*)STRING_APP_DEBUG.c_str(),
1070         (char*)"-c",
1071         (char*)"",
1072     };
1073     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1074 
1075     AbilityManagerShellCommand cmd(argc, argv);
1076     EXPECT_EQ(cmd.RunAsAppDebugDebugCommand(), OHOS::ERR_OK);
1077 }
1078 
1079 /**
1080  * @tc.number: Aa_Command_RunAsAppDebugDebugCommand_0300
1081  * @tc.name: RunAsAppDebugDebugCommand
1082  * @tc.desc: Verify that isGet is true and returns ERR_OK.
1083  */
1084 HWTEST_F(AaCommandFirstTest, RunAsAppDebugDebugCommand_0300, Function | MediumTest | Level1)
1085 {
1086     GTEST_LOG_(INFO) << "RunAsAppDebugDebugCommand_0300 start";
1087     char* argv[] = {
1088         (char*)TOOL_NAME.c_str(),
1089         (char*)STRING_APP_DEBUG.c_str(),
1090         (char*)"-g",
1091         (char*)"",
1092     };
1093     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1094     AbilityManagerShellCommand cmd(argc, argv);
1095     EXPECT_EQ(cmd.RunAsAppDebugDebugCommand(), OHOS::ERR_OK);
1096 }
1097 
1098 /**
1099  * @tc.number: Aa_Command_RunAsAppDebugDebugCommand_0400
1100  * @tc.name: RunAsAppDebugDebugCommand
1101  * @tc.desc: Verify that bundleName is not empty and returns ERR_OK.
1102  */
1103 HWTEST_F(AaCommandFirstTest, RunAsAppDebugDebugCommand_0400, Function | MediumTest | Level1)
1104 {
1105     GTEST_LOG_(INFO) << "RunAsAppDebugDebugCommand_0400 start";
1106     char* argv[] = {
1107         (char*)TOOL_NAME.c_str(),
1108         (char*)STRING_APP_DEBUG.c_str(),
1109         (char*)"-b",
1110         (char*)STRING_BUNDLE_NAME.c_str(),
1111         (char*)"",
1112     };
1113     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1114 
1115     AbilityManagerShellCommand cmd(argc, argv);
1116     EXPECT_EQ(cmd.RunAsAppDebugDebugCommand(), OHOS::AAFwk::ERR_NOT_DEBUG_APP);
1117 }
1118 
1119 /**
1120  * @tc.number: Aa_Command_RunAsAppDebugDebugCommand_0500
1121  * @tc.name: RunAsAppDebugDebugCommand
1122  * @tc.desc: Verify that bundleName is empty ,isCancel is false , isGet is false and returns ERR_OK.
1123  */
1124 HWTEST_F(AaCommandFirstTest, RunAsAppDebugDebugCommand_0500, Function | MediumTest | Level1)
1125 {
1126     GTEST_LOG_(INFO) << "RunAsAppDebugDebugCommand_0500 start";
1127     char* argv[] = {
1128         (char*)TOOL_NAME.c_str(),
1129         (char*)STRING_APP_DEBUG.c_str(),
1130         (char*)"-h",
1131         (char*)"",
1132     };
1133     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1134 
1135     AbilityManagerShellCommand cmd(argc, argv);
1136     EXPECT_EQ(cmd.RunAsAppDebugDebugCommand(), OHOS::ERR_OK);
1137 }
1138 
1139 /**
1140  * @tc.number: Aa_Command_RunAsAppDebugDebugCommand_0600
1141  * @tc.name: RunAsAppDebugDebugCommand
1142  * @tc.desc: Verify that ParseAppDebugParameter is false and return ERR_INVALID_VALUE.
1143  */
1144 HWTEST_F(AaCommandFirstTest, RunAsAppDebugDebugCommand_0600, Function | MediumTest | Level1)
1145 {
1146     GTEST_LOG_(INFO) << "RunAsAppDebugDebugCommand_0600 start";
1147     char* argv[] = {
1148         (char*)TOOL_NAME.c_str(),
1149         (char*)STRING_APP_DEBUG.c_str(),
1150         (char*)"",
1151     };
1152     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1153     AbilityManagerShellCommand cmd(argc, argv);
1154     EXPECT_EQ(cmd.RunAsAppDebugDebugCommand(), OHOS::ERR_INVALID_VALUE);
1155 }
1156 
1157 /**
1158  * @tc.number: Aa_Command_ParseAppDebugParameter_0100
1159  * @tc.name: ParseAppDebugParameter
1160  * @tc.desc: Verify that SwitchOptionForAppDebug return true.
1161  */
1162 HWTEST_F(AaCommandFirstTest, ParseAppDebugParameter_0100, TestSize.Level1)
1163 {
1164     GTEST_LOG_(INFO) << "Aa_Command_ParseAppDebugParameter_0100 start";
1165     char* argv[] = {
1166         (char*)TOOL_NAME.c_str(),
1167         (char*)STRING_APP_DEBUG.c_str(),
1168         (char*)"-h",
1169         (char*)" ",
1170     };
1171     int32_t argc = sizeof(argv) / sizeof(argv[0]) - 1;
1172     AbilityManagerShellCommand cmd(argc, argv);
1173     bool isPersist;
1174     bool isCancel;
1175     bool isGet;
1176     std::string bundleName = STRING_BUNDLE_NAME;
1177     EXPECT_EQ(cmd.ParseAppDebugParameter(bundleName, isPersist, isCancel, isGet), true);
1178 }
1179 
1180 /**
1181  * @tc.number: Aa_Command_ParseAppDebugParameter_0200
1182  * @tc.name: ParseAppDebugParameter
1183  * @tc.desc: Verify aa error and return false.
1184  */
1185 HWTEST_F(AaCommandFirstTest, ParseAppDebugParameter_0200, TestSize.Level1)
1186 {
1187     GTEST_LOG_(INFO) << "Aa_Command_ParseAppDebugParameter_0200 start";
1188     char* argv[] = {
1189         (char*)TOOL_NAME.c_str(),
1190         (char*)STRING_APP_DEBUG.c_str(),
1191         (char*)"",
1192     };
1193     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1194     AbilityManagerShellCommand cmd(argc, argv);
1195     bool isPersist;
1196     bool isCancel;
1197     bool isGet;
1198     std::string bundleName = STRING_BUNDLE_NAME;
1199     EXPECT_EQ(cmd.ParseAppDebugParameter(bundleName, isPersist, isCancel, isGet), false);
1200 }
1201 
1202 /**
1203  * @tc.number: Aa_Command_ParseAppDebugParameter_0300
1204  * @tc.name: ParseAppDebugParameter
1205  * @tc.desc: Verify return true.
1206  */
1207 HWTEST_F(AaCommandFirstTest, ParseAppDebugParameter_0300, TestSize.Level1)
1208 {
1209     GTEST_LOG_(INFO) << "Aa_Command_ParseAppDebugParameter_0300 start";
1210     char* argv[] = {
1211         (char*)TOOL_NAME.c_str(),
1212         (char*)STRING_APP_DEBUG.c_str(),
1213         (char*)"-b",
1214         (char*)STRING_BUNDLE_NAME.c_str(),
1215         (char*)"",
1216     };
1217     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1218     AbilityManagerShellCommand cmd(argc, argv);
1219     bool isPersist;
1220     bool isCancel;
1221     bool isGet;
1222     std::string bundleName = STRING_BUNDLE_NAME;
1223     EXPECT_EQ(cmd.ParseAppDebugParameter(bundleName, isPersist, isCancel, isGet), true);
1224 }
1225 
1226 /**
1227  * @tc.number: Aa_Command_ParseAppDebugParameter_0400
1228  * @tc.name: ParseAppDebugParameter
1229  * @tc.desc: Verify aa appdebug -b' with no argument.
1230  */
1231 HWTEST_F(AaCommandFirstTest, ParseAppDebugParameter_0400, TestSize.Level1)
1232 {
1233     GTEST_LOG_(INFO) << "Aa_Command_ParseAppDebugParameter_0400 start";
1234     char* argv[] = {
1235         (char*)TOOL_NAME.c_str(),
1236         (char*)STRING_APP_DEBUG.c_str(),
1237         (char*)"-b",
1238         (char*)"",
1239     };
1240     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1241     AbilityManagerShellCommand cmd(argc, argv);
1242     bool isPersist;
1243     bool isCancel;
1244     bool isGet;
1245     std::string bundleName = STRING_BUNDLE_NAME;
1246     EXPECT_EQ(cmd.ParseAppDebugParameter(bundleName, isPersist, isCancel, isGet), false);
1247 }
1248 
1249 /**
1250  * @tc.number: Aa_Command_ParseAppDebugParameter_0500
1251  * @tc.name: ParseAppDebugParameter
1252  * @tc.desc: Verify aa appdebug -b' with an unknown option.
1253  */
1254 HWTEST_F(AaCommandFirstTest, ParseAppDebugParameter_0500, TestSize.Level1)
1255 {
1256     GTEST_LOG_(INFO) << "Aa_Command_ParseAppDebugParameter_0500 start";
1257     char* argv[] = {
1258         (char*)TOOL_NAME.c_str(),
1259         (char*)STRING_APP_DEBUG.c_str(),
1260         (char*)"-xx",
1261         (char*)"",
1262     };
1263     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
1264     AbilityManagerShellCommand cmd(argc, argv);
1265     bool isPersist;
1266     bool isCancel;
1267     bool isGet;
1268     std::string bundleName = STRING_BUNDLE_NAME;
1269     EXPECT_EQ(cmd.ParseAppDebugParameter(bundleName, isPersist, isCancel, isGet), false);
1270 }
1271