diff --git a/tools/test/unittest/dump/notification_shell_command_dump_test.cpp b/tools/test/unittest/dump/notification_shell_command_dump_test.cpp index 5b009fb014d42920e57940a4b81712bf90474b6b..4fce482942d02f9a5cfecdaab52743721c17877b 100644 --- a/tools/test/unittest/dump/notification_shell_command_dump_test.cpp +++ b/tools/test/unittest/dump/notification_shell_command_dump_test.cpp @@ -57,6 +57,19 @@ static char g_dumpActiveUser[] = " --bundle, -b dump the info filter by the specified bundle name\n" " --user-id, -u dump the info filter by the specified userId\n"; +static char g_enableErrorInformation[] = +"error: option 'e' requires a value.\nusage: anm setting []\noptions list:\n" +" --help, -h help menu\n" +" --recent-count -c set the max count of recent notifications keeping in memory\n --enable-notification" +" -e set notification enabled for the bundle, eg: -e com.example:10100:1\n"; + +static char g_enableBundleNameNull[] = +"error: setting information error\n" +"usage: anm setting []\n" +"options list:\n --help, -h help menu\n" +" --recent-count -c set the max count of recent notifications keeping in memory\n --enable-notification" +" -e set notification enabled for the bundle, eg: -e com.example:10100:1\n"; + static char g_bundleName[] = "example"; static char g_commandActive[] = "active"; static char g_commandRecent[] = "recent"; @@ -71,6 +84,7 @@ public: void MakeMockObjects(); std::string cmd_ = "dump"; + std::string enable_ = "setting"; std::string toolName_ = "anm"; sptr proxyPtr_; sptr stubPtr_; @@ -458,4 +472,66 @@ HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_1600, Function | Medium EXPECT_EQ(cmd.GetMessageFromCode(code), ""); } + +/** + * @tc.number: Anm_Command_Dump_1700 + * @tc.name: RunAsSettingCommand + * @tc.desc: Verify the "anm setting -e bundleName:uid:enable" command. + */ +HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_1700, Function | MediumTest | Level1) +{ + char *argv[] = { + (char *)toolName_.c_str(), + (char *)enable_.c_str(), + (char *)"-e", + (char *)"dd:ss:aa", + (char *)"", + }; + int argc = sizeof(argv) / sizeof(argv[0]) - 1; + + NotificationShellCommand cmd(argc, argv); + + EXPECT_EQ(cmd.ExecCommand(), "set notification enabled failed\n"); +} + +/** + * @tc.number: Anm_Command_Dump_1800 + * @tc.name: RunAsSettingCommand + * @tc.desc: Verify the "anm setting -e" command. + */ +HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_1800, Function | MediumTest | Level1) +{ + char *argv[] = { + (char *)toolName_.c_str(), + (char *)enable_.c_str(), + (char *)"-e", + (char *)"", + }; + int argc = sizeof(argv) / sizeof(argv[0]) - 1; + + NotificationShellCommand cmd(argc, argv); + + EXPECT_EQ(cmd.ExecCommand(), g_enableErrorInformation); +} + +/** + * @tc.number: Anm_Command_Dump_1900 + * @tc.name: RunAsSettingCommand + * @tc.desc: Verify the "anm setting -e bundleName:uid" command. + */ +HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_1900, Function | MediumTest | Level1) +{ + char *argv[] = { + (char *)toolName_.c_str(), + (char *)enable_.c_str(), + (char *)"-e", + (char *)"dd:ss", + (char *)"", + }; + int argc = sizeof(argv) / sizeof(argv[0]) - 1; + + NotificationShellCommand cmd(argc, argv); + + EXPECT_EQ(cmd.ExecCommand(), g_enableBundleNameNull); +} } // namespace \ No newline at end of file