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