• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <gtest/gtest.h>
17 
18 #define private public
19 #include "notification_shell_command.h"
20 #undef private
21 #include "ans_inner_errors.h"
22 #include "ans_manager_interface.h"
23 #include "mock_ans_manager_stub.h"
24 #include "singleton.h"
25 
26 using namespace testing::ext;
27 using namespace OHOS;
28 using namespace OHOS::Notification;
29 
30 namespace {
31 static char g_dumpHelpMsg[] =
32 "request a option 'A' or 'R' or 'D'\n"
33 "usage: anm dump [<options>]\n"
34 "options list:\n"
35 "  --help, -h                   help menu\n"
36 "  --active,  -A                 list all active notifications\n"
37 "  --recent,  -R                 list recent notifications\n"
38 "  --bundle,  -b  <name>         dump the info filter by the specified bundle name\n"
39 "  --user-id, -u  <userId>       dump the info filter by the specified userId\n"
40 "  --receiver, -r  <userId>       dump the info filter by the specified receiver userId\n";
41 
42 static char g_dumpActiveBound[] =
43 "error: option 'b' requires a value.\n"
44 "usage: anm dump [<options>]\noptions list:\n"
45 "  --help, -h                   help menu\n"
46 "  --active,  -A                 list all active notifications\n"
47 "  --recent,  -R                 list recent notifications\n"
48 "  --bundle,  -b  <name>         dump the info filter by the specified bundle name\n"
49 "  --user-id, -u  <userId>       dump the info filter by the specified userId\n"
50 "  --receiver, -r  <userId>       dump the info filter by the specified receiver userId\n";
51 
52 static char g_dumpActiveUser[] =
53 "error: option 'u' requires a value.\n"
54 "usage: anm dump [<options>]\n"
55 "options list:\n"
56 "  --help, -h                   help menu\n"
57 "  --active,  -A                 list all active notifications\n"
58 "  --recent,  -R                 list recent notifications\n"
59 "  --bundle,  -b  <name>         dump the info filter by the specified bundle name\n"
60 "  --user-id, -u  <userId>       dump the info filter by the specified userId\n"
61 "  --receiver, -r  <userId>       dump the info filter by the specified receiver userId\n";
62 
63 static char g_enableErrorInformation[] =
64 "error: option 'e' requires a value.\n"
65 "usage: anm setting [<options>]\n"
66 "options list:\n"
67 "  --help, -h                   help menu\n"
68 "  --recent-count -c <number>   set the max count of recent notifications keeping in memory\n"
69 "  --enable-notification -e <bundleName:uid:enable> set notification enabled for the bundle, "
70 "eg: -e com.example:10100:1\n"
71 "  --set-device-status -d <device:status> set device status, eg: -d device:1\n"
72 "  --collaboration-switch -k <device:enable> set collaboration status, eg: -k wearable:1\n"
73 "  --collaboration-switch-bundle -b <device:bundleName:bundleUid:status> set bundle collaboration switch status\n"
74 "      eg: -b wearable:example:10100:1\n"
75 "  --collaboration-switch-slot -o <device:slotType:status> set slot collaboration switch status\n"
76 "  --get-device-status -o <device> set device status\n"
77 "      eg: -o wearable:0:1\n";
78 
79 static char g_enableBundleNameNull[] =
80 "error: setting information error\n"
81 "usage: anm setting [<options>]\n"
82 "options list:\n  --help, -h                   help menu\n"
83 "  --recent-count -c <number>   set the max count of recent notifications keeping in memory\n  --enable-notification"
84 " -e <bundleName:uid:enable> set notification enabled for the bundle, eg: -e com.example:10100:1\n  --set-device-status"
85 " -d <device:status> set device status, eg: -d device:1\n"
86 "  --collaboration-switch -k <device:enable> set collaboration status, eg: -k wearable:1\n"
87 "  --collaboration-switch-bundle -b <device:bundleName:bundleUid:status> set bundle collaboration switch status\n"
88 "      eg: -b wearable:example:10100:1\n"
89 "  --collaboration-switch-slot -o <device:slotType:status> set slot collaboration switch status\n"
90 "  --get-device-status -o <device> set device status\n"
91 "      eg: -o wearable:0:1\n";
92 
93 static char g_enableObjectNull[] =
94 "error: object is null\n"
95 "error: object is null\n"
96 "usage: anm setting [<options>]\n"
97 "options list:\n  --help, -h                   help menu\n"
98 "  --recent-count -c <number>   set the max count of recent notifications keeping in memory\n  --enable-notification"
99 " -e <bundleName:uid:enable> set notification enabled for the bundle, eg: -e com.example:10100:1\n  --set-device-status"
100 " -d <device:status> set device status, eg: -d device:1\n"
101 "  --collaboration-switch -k <device:enable> set collaboration status, eg: -k wearable:1\n"
102 "  --collaboration-switch-bundle -b <device:bundleName:bundleUid:status> set bundle collaboration switch status\n"
103 "      eg: -b wearable:example:10100:1\n"
104 "  --collaboration-switch-slot -o <device:slotType:status> set slot collaboration switch status\n"
105 "  --get-device-status -o <device> set device status\n"
106 "      eg: -o wearable:0:1\n";
107 
108 static char g_unknownOption[] =
109 "error: unknown option.\n"
110 "usage: anm dump [<options>]\n"
111 "options list:\n"
112 "  --help, -h                   help menu\n"
113 "  --active,  -A                 list all active notifications\n"
114 "  --recent,  -R                 list recent notifications\n"
115 "  --bundle,  -b  <name>         dump the info filter by the specified bundle name\n"
116 "  --user-id, -u  <userId>       dump the info filter by the specified userId\n"
117 "  --receiver, -r  <userId>       dump the info filter by the specified receiver userId\n";
118 
119 static char g_dumpActiveCount[] =
120 "error: option 'c' requires a value.\n"
121 "usage: anm setting [<options>]\n"
122 "options list:\n"
123 "  --help, -h                   help menu\n"
124 "  --recent-count -c <number>   set the max count of recent notifications keeping in memory\n  --enable-notification"
125 " -e <bundleName:uid:enable> set notification enabled for the bundle, eg: -e com.example:10100:1\n  --set-device-status"
126 " -d <device:status> set device status, eg: -d device:1\n"
127 "  --collaboration-switch -k <device:enable> set collaboration status, eg: -k wearable:1\n"
128 "  --collaboration-switch-bundle -b <device:bundleName:bundleUid:status> set bundle collaboration switch status\n"
129 "      eg: -b wearable:example:10100:1\n"
130 "  --collaboration-switch-slot -o <device:slotType:status> set slot collaboration switch status\n"
131 "  --get-device-status -o <device> set device status\n"
132 "      eg: -o wearable:0:1\n";
133 
134 static char g_helpMsg[] =
135 "error: unknown option.\n"
136 "usage: anm dump [<options>]\n"
137 "options list:\n"
138 "  --help, -h                   help menu\n"
139 "  --active,  -A                 list all active notifications\n"
140 "  --recent,  -R                 list recent notifications\n"
141 "  --bundle,  -b  <name>         dump the info filter by the specified bundle name\n"
142 "  --user-id, -u  <userId>       dump the info filter by the specified userId\n"
143 "  --receiver, -r  <userId>       dump the info filter by the specified receiver userId\n"
144 "usage: anm dump [<options>]\n"
145 "options list:\n"
146 "  --help, -h                   help menu\n"
147 "  --active,  -A                 list all active notifications\n"
148 "  --recent,  -R                 list recent notifications\n"
149 "  --bundle,  -b  <name>         dump the info filter by the specified bundle name\n"
150 "  --user-id, -u  <userId>       dump the info filter by the specified userId\n"
151 "  --receiver, -r  <userId>       dump the info filter by the specified receiver userId\n";
152 
153 class AnmManagerDumpTest : public testing::Test {
154 public:
155     static void SetUpTestCase();
156     static void TearDownTestCase();
157     void SetUp() override;
158     void TearDown() override;
159 
160     void MakeMockObjects();
161 
162     std::string cmd_ = "dump";
163     std::string enable_ = "setting";
164     std::string toolName_ = "anm";
165     sptr<AnsManagerInterface> proxyPtr_;
166     sptr<MockAnsManagerStub> stubPtr_;
167 };
168 
SetUpTestCase()169 void AnmManagerDumpTest::SetUpTestCase()
170 {}
171 
TearDownTestCase()172 void AnmManagerDumpTest::TearDownTestCase()
173 {}
174 
SetUp()175 void AnmManagerDumpTest::SetUp()
176 {
177     // reset optind to 0
178     optind = 0;
179 
180     // make mock objects
181     MakeMockObjects();
182 }
183 
TearDown()184 void AnmManagerDumpTest::TearDown()
185 {}
186 
MakeMockObjects()187 void AnmManagerDumpTest::MakeMockObjects()
188 {
189     // mock a stub
190     stubPtr_ = new (std::nothrow) MockAnsManagerStub();
191 
192     // mock a proxy
193     proxyPtr_ = iface_cast<AnsManagerInterface>(stubPtr_);
194 
195     // set the mock proxy
196     auto ansNotificationPtr = DelayedSingleton<AnsNotification>::GetInstance();
197 }
198 
199 /**
200  * @tc.number: Anm_Command_Dump_0100
201  * @tc.name: ExecCommand
202  * @tc.desc: Verify the "anm dump -h" command.
203  */
204 HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_0100, Function | MediumTest | Level1)
205 {
206     char *argv[] = {
207         (char *)toolName_.c_str(),
208         (char *)cmd_.c_str(),
209         (char *)"-h",
210         (char *)"",
211     };
212     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
213 
214     NotificationShellCommand cmd(argc, argv);
215 
216     EXPECT_EQ(cmd.ExecCommand(), g_dumpHelpMsg);
217 }
218 
219 /**
220  * @tc.number: Anm_Command_Dump_0200
221  * @tc.name: ExecCommand
222  * @tc.desc: Verify the "anm dump -A" command.
223  */
224 HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_0200, Function | MediumTest | Level1)
225 {
226     char *argv[] = {
227         (char *)toolName_.c_str(),
228         (char *)cmd_.c_str(),
229         (char *)"-A",
230         (char *)"",
231     };
232     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
233 
234     NotificationShellCommand cmd(argc, argv);
235 
236     cmd.ExecCommand();
237 
238     EXPECT_EQ(stubPtr_->GetCmd(), "");
239 }
240 
241 /**
242  * @tc.number: Anm_Command_Dump_0300
243  * @tc.name: ExecCommand
244  * @tc.desc: Verify the "anm dump -R" command.
245  */
246 HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_0300, Function | MediumTest | Level1)
247 {
248     char *argv[] = {
249         (char *)toolName_.c_str(),
250         (char *)cmd_.c_str(),
251         (char *)"-R",
252         (char *)"",
253     };
254     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
255 
256     NotificationShellCommand cmd(argc, argv);
257 
258     cmd.ExecCommand();
259 
260     EXPECT_EQ(stubPtr_->GetCmd(), "");
261 }
262 
263 /**
264  * @tc.number: Anm_Command_Dump_0400
265  * @tc.name: ExecCommand
266  * @tc.desc: Verify the "anm dump -R -b" command.
267  */
268 HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_0400, Function | MediumTest | Level1)
269 {
270     char *argv[] = {
271         (char *)toolName_.c_str(),
272         (char *)cmd_.c_str(),
273         (char *)"-R",
274         (char *)"-b",
275         (char *)"",
276     };
277     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
278 
279     NotificationShellCommand cmd(argc, argv);
280 
281     EXPECT_EQ(cmd.ExecCommand(), g_dumpActiveBound);
282 }
283 
284 /**
285  * @tc.number: Anm_Command_Dump_0500
286  * @tc.name: ExecCommand
287  * @tc.desc: Verify the "anm dump -A -b example" command.
288  */
289 HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_0500, Function | MediumTest | Level1)
290 {
291     char *argv[] = {
292         (char *)toolName_.c_str(),
293         (char *)cmd_.c_str(),
294         (char *)"-A",
295         (char *)"-b",
296         (char *)"example",
297         (char *)"",
298     };
299     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
300 
301     NotificationShellCommand cmd(argc, argv);
302 
303     cmd.ExecCommand();
304 
305     EXPECT_EQ(stubPtr_->GetCmd(), "");
306     EXPECT_EQ(stubPtr_->GetBundle(), "");
307 }
308 
309 /**
310  * @tc.number: Anm_Command_Dump_0600
311  * @tc.name: ExecCommand
312  * @tc.desc: Verify the "anm dump -A -b" command.
313  */
314 HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_0600, Function | MediumTest | Level1)
315 {
316     char *argv[] = {
317         (char *)toolName_.c_str(),
318         (char *)cmd_.c_str(),
319         (char *)"-A",
320         (char *)"-b",
321         (char *)"",
322     };
323     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
324 
325     NotificationShellCommand cmd(argc, argv);
326 
327     EXPECT_EQ(cmd.ExecCommand(), g_dumpActiveBound);
328 }
329 
330 /**
331  * @tc.number: Anm_Command_Dump_0700
332  * @tc.name: ExecCommand
333  * @tc.desc: Verify the "anm dump -R -b example" command.
334  */
335 HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_0700, Function | MediumTest | Level1)
336 {
337     char *argv[] = {
338         (char *)toolName_.c_str(),
339         (char *)cmd_.c_str(),
340         (char *)"-R",
341         (char *)"-b",
342         (char *)"example",
343         (char *)"",
344     };
345     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
346 
347     NotificationShellCommand cmd(argc, argv);
348 
349     cmd.ExecCommand();
350 
351     EXPECT_EQ(stubPtr_->GetCmd(), "");
352     EXPECT_EQ(stubPtr_->GetBundle(), "");
353 }
354 
355 /**
356  * @tc.number: Anm_Command_Dump_0800
357  * @tc.name: ExecCommand
358  * @tc.desc: Verify the "anm dump -R -u" command.
359  */
360 HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_0800, Function | MediumTest | Level1)
361 {
362     char *argv[] = {
363         (char *)toolName_.c_str(),
364         (char *)cmd_.c_str(),
365         (char *)"-R",
366         (char *)"-u",
367         (char *)"",
368     };
369     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
370 
371     NotificationShellCommand cmd(argc, argv);
372 
373     EXPECT_EQ(cmd.ExecCommand(), g_dumpActiveUser);
374 }
375 
376 /**
377  * @tc.number: Anm_Command_Dump_0900
378  * @tc.name: ExecCommand
379  * @tc.desc: Verify the "anm dump -A -u" command.
380  */
381 HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_0900, Function | MediumTest | Level1)
382 {
383     char *argv[] = {
384         (char *)toolName_.c_str(),
385         (char *)cmd_.c_str(),
386         (char *)"-A",
387         (char *)"-u",
388         (char *)"",
389     };
390     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
391 
392     NotificationShellCommand cmd(argc, argv);
393 
394     EXPECT_EQ(cmd.ExecCommand(), g_dumpActiveUser);
395 }
396 
397 /**
398  * @tc.number: Anm_Command_Dump_1000
399  * @tc.name: ExecCommand
400  * @tc.desc: Verify the "anm dump -A -u 33" command.
401  */
402 HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_1000, Function | MediumTest | Level1)
403 {
404     char *argv[] = {
405         (char *)toolName_.c_str(),
406         (char *)cmd_.c_str(),
407         (char *)"-A",
408         (char *)"-u",
409         (char *)"33",
410         (char *)"",
411     };
412     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
413 
414     NotificationShellCommand cmd(argc, argv);
415 
416     cmd.ExecCommand();
417 
418     EXPECT_EQ(stubPtr_->GetCmd(), "");
419     EXPECT_EQ(stubPtr_->GetUserId(), 0);
420 }
421 
422 /**
423  * @tc.number: Anm_Command_Dump_1100
424  * @tc.name: ExecCommand
425  * @tc.desc: Verify the "anm dump -R -u 33" command.
426  */
427 HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_1100, Function | MediumTest | Level1)
428 {
429     char *argv[] = {
430         (char *)toolName_.c_str(),
431         (char *)cmd_.c_str(),
432         (char *)"-R",
433         (char *)"-u",
434         (char *)"33",
435         (char *)"",
436     };
437     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
438 
439     NotificationShellCommand cmd(argc, argv);
440 
441     cmd.ExecCommand();
442 
443     EXPECT_EQ(stubPtr_->GetCmd(), "");
444     EXPECT_EQ(stubPtr_->GetUserId(), 0);
445 }
446 
447 /**
448  * @tc.number: Anm_Command_Dump_1200
449  * @tc.name: RunAsSettingCommand
450  * @tc.desc: test RunAsSettingCommand function
451  */
452 HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_1200, Function | MediumTest | Level1)
453 {
454     char *argv[] = {
455         (char *)toolName_.c_str(),
456         (char *)cmd_.c_str(),
457         (char *)"-h",
458         (char *)"",
459     };
460     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
461 
462     NotificationShellCommand cmd(argc, argv);
463 
464     EXPECT_EQ(cmd.RunAsSettingCommand(), ERR_INVALID_VALUE);
465 }
466 
467 /**
468  * @tc.number: Anm_Command_Dump_1300
469  * @tc.name: RunSetEnableCmd
470  * @tc.desc: test RunSetEnableCmd function
471  */
472 HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_1300, Function | MediumTest | Level1)
473 {
474     char *argv[] = {
475         (char *)toolName_.c_str(),
476         (char *)cmd_.c_str(),
477         (char *)"-h",
478         (char *)"",
479     };
480     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
481 
482     NotificationShellCommand cmd(argc, argv);
483 
484     EXPECT_EQ(cmd.RunSetEnableCmd(), ERR_ANS_SERVICE_NOT_CONNECTED);
485 }
486 
487 /**
488  * @tc.number: Anm_Command_Dump_1400
489  * @tc.name: GetCommandErrorMsg
490  * @tc.desc: test GetCommandErrorMsg function
491  */
492 HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_1400, Function | MediumTest | Level1)
493 {
494     char *argv[] = {
495         (char *)toolName_.c_str(),
496         (char *)cmd_.c_str(),
497         (char *)"-h",
498         (char *)"",
499     };
500     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
501 
502     NotificationShellCommand cmd(argc, argv);
503 
504     EXPECT_EQ(cmd.GetCommandErrorMsg(), "anm_dump: 'dump' is not a valid anm_dump command. See 'anm_dump help'.\n");
505 }
506 
507 /**
508  * @tc.number: Anm_Command_Dump_1500
509  * @tc.name: GetUnknownOptionMsg
510  * @tc.desc: test GetUnknownOptionMsg function
511  */
512 HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_1500, Function | MediumTest | Level1)
513 {
514     char *argv[] = {
515         (char *)toolName_.c_str(),
516         (char *)cmd_.c_str(),
517         (char *)"-h",
518         (char *)"",
519     };
520     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
521 
522     NotificationShellCommand cmd(argc, argv);
523 
524     std::string unknownOption = "aa";
525 
526     EXPECT_EQ(cmd.GetUnknownOptionMsg(unknownOption), "error: unknown option.\n");
527 }
528 
529 /**
530  * @tc.number: Anm_Command_Dump_1600
531  * @tc.name: GetMessageFromCode
532  * @tc.desc: test GetMessageFromCode function
533  */
534 HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_1600, Function | MediumTest | Level1)
535 {
536     char *argv[] = {
537         (char *)toolName_.c_str(),
538         (char *)cmd_.c_str(),
539         (char *)"-h",
540         (char *)"",
541     };
542     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
543 
544     NotificationShellCommand cmd(argc, argv);
545 
546     int32_t code = 11;
547 
548     EXPECT_EQ(cmd.GetMessageFromCode(code), "");
549 }
550 
551 /**
552  * @tc.number: Anm_Command_Dump_1700
553  * @tc.name: RunAsSettingCommand
554  * @tc.desc: Verify the "anm setting -e bundleName:uid:enable" command.
555  */
556 HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_1700, Function | MediumTest | Level1)
557 {
558     char *argv[] = {
559         (char *)toolName_.c_str(),
560         (char *)enable_.c_str(),
561         (char *)"-e",
562         (char *)"dd:ss:aa",
563         (char *)"",
564     };
565     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
566 
567     NotificationShellCommand cmd(argc, argv);
568 
569     EXPECT_EQ(cmd.ExecCommand(), "set notification enabled failed\n");
570 }
571 
572 /**
573  * @tc.number: Anm_Command_Dump_1800
574  * @tc.name: RunAsSettingCommand
575  * @tc.desc: Verify the "anm setting -e" command.
576  */
577 HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_1800, Function | MediumTest | Level1)
578 {
579     char *argv[] = {
580         (char *)toolName_.c_str(),
581         (char *)enable_.c_str(),
582         (char *)"-e",
583         (char *)"",
584     };
585     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
586 
587     NotificationShellCommand cmd(argc, argv);
588 
589     EXPECT_EQ(cmd.ExecCommand(), g_enableErrorInformation);
590 }
591 
592 /**
593  * @tc.number: Anm_Command_Dump_1900
594  * @tc.name: RunAsSettingCommand
595  * @tc.desc: Verify the "anm setting -e bundleName:uid" command.
596  */
597 HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_1900, Function | MediumTest | Level1)
598 {
599     char *argv[] = {
600         (char *)toolName_.c_str(),
601         (char *)enable_.c_str(),
602         (char *)"-e",
603         (char *)"dd:ss",
604         (char *)"",
605     };
606     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
607 
608     NotificationShellCommand cmd(argc, argv);
609 
610     EXPECT_EQ(cmd.ExecCommand(), g_enableBundleNameNull);
611 }
612 
613 /**
614  * @tc.number: Anm_Command_Dump_2000
615  * @tc.name: RunAsSettingCommand
616  * @tc.desc: Verify the "anm setting -e bundleName:uid:enable" command.
617  */
618 HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_2000, Function | MediumTest | Level1)
619 {
620     char *argv[] = {
621         (char *)toolName_.c_str(),
622         (char *)enable_.c_str(),
623         (char *)"-e",
624         (char *)"22",
625         (char *)"",
626     };
627     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
628 
629     NotificationShellCommand cmd(argc, argv);
630 
631     EXPECT_EQ(cmd.RunSetEnableCmd(), cmd.RunAsSettingCommand());
632     EXPECT_EQ(cmd.ExecCommand(), g_enableObjectNull);
633 }
634 
635 /**
636  * @tc.number: Anm_Command_Dump_2100
637  * @tc.name: RunAsSettingCommand
638  * @tc.desc: Verify the "anm setting -e bundleName:uid:enable" command.
639  */
640 HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_2100, Function | MediumTest | Level1)
641 {
642     char *argv[] = {
643         (char *)toolName_.c_str(),
644         (char *)enable_.c_str(),
645         (char *)"-e",
646         (char *)"gg:ss:aa",
647         (char *)"22",
648         (char *)"",
649     };
650     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
651 
652     NotificationShellCommand cmd(argc, argv);
653 
654     EXPECT_EQ(cmd.ExecCommand(), "set notification enabled success\n");
655 }
656 
657 /**
658  * @tc.number: Anm_Command_Dump_2200
659  * @tc.name: ExecCommand
660  * @tc.desc: Verify the "anm dump -A -s" command.
661  */
662 HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_2200, Function | MediumTest | Level1)
663 {
664     char *argv[] = {
665         (char *)toolName_.c_str(),
666         (char *)cmd_.c_str(),
667         (char *)"-A",
668         (char *)"-s",
669         (char *)"",
670     };
671     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
672 
673     NotificationShellCommand cmd(argc, argv);
674 
675     EXPECT_EQ(cmd.ExecCommand(), g_unknownOption);
676 }
677 
678 /**
679  * @tc.number: Anm_Command_Dump_2300
680  * @tc.name: RunAsSettingCommand
681  * @tc.desc: Verify the "anm setting -e" command.
682  */
683 HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_2300, Function | MediumTest | Level1)
684 {
685     char *argv[] = {
686         (char *)toolName_.c_str(),
687         (char *)enable_.c_str(),
688         (char *)"-c",
689         (char *)"",
690     };
691     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
692 
693     NotificationShellCommand cmd(argc, argv);
694 
695     EXPECT_EQ(cmd.ExecCommand(), g_dumpActiveCount);
696 }
697 
698 /**
699  * @tc.number: Anm_Command_Dump_2400
700  * @tc.name: ExecCommand
701  * @tc.desc: Verify the "anm dump -D" command.
702  */
703 HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_0240, Function | MediumTest | Level1)
704 {
705     char *argv[] = {
706         (char *)toolName_.c_str(),
707         (char *)cmd_.c_str(),
708         (char *)"-D",
709         (char *)"",
710     };
711     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
712 
713     NotificationShellCommand cmd(argc, argv);
714 
715     cmd.ExecCommand();
716 
717     EXPECT_EQ(cmd.ExecCommand(), g_helpMsg);
718 }
719 
720 /**
721  * @tc.number: Anm_Command_Dump_2500
722  * @tc.name: ExecCommand
723  * @tc.desc: Verify the "anm dump -D" command.
724  */
725 HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_0250, Function | MediumTest | Level1)
726 {
727     char *argv[] = {
728         (char *)toolName_.c_str(),
729         (char *)cmd_.c_str(),
730         (char *)"-p",
731         (char *)"",
732     };
733     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
734 
735     NotificationShellCommand cmd(argc, argv);
736 
737     cmd.ExecCommand();
738 
739     EXPECT_EQ(cmd.ExecCommand(), g_helpMsg);
740 }
741 }  // namespace