Adapt to aa test dynamic key-value parameters

Signed-off-by: njupthan <hanhaibin@huawei.com>
This commit is contained in:
njupthan 2022-03-04 14:24:40 +00:00
parent e8ac6d7f87
commit 7f01b79cf2
3 changed files with 14 additions and 20 deletions

View File

@ -28,16 +28,10 @@ AbilityDelegatorArgs::AbilityDelegatorArgs()
AbilityDelegatorArgs::AbilityDelegatorArgs(const AAFwk::Want &want)
{
bundleName_ = want.GetStringParam(AbilityDelegatorArgs::KEY_TEST_BUNDLE_NAME);
params_[AbilityDelegatorArgs::KEY_TEST_BUNDLE_NAME] =
want.GetStringParam(AbilityDelegatorArgs::KEY_TEST_BUNDLE_NAME);
params_[AbilityDelegatorArgs::KEY_TEST_RUNNER_CLASS] =
want.GetStringParam(AbilityDelegatorArgs::KEY_TEST_RUNNER_CLASS);
if (!want.GetStringParam(AbilityDelegatorArgs::KEY_TEST_CASE).empty()) {
params_[AbilityDelegatorArgs::KEY_TEST_CASE] = want.GetStringParam(AbilityDelegatorArgs::KEY_TEST_CASE);
}
if (!want.GetStringParam(AbilityDelegatorArgs::KEY_TEST_WAIT_TIMEOUT).empty()) {
params_[AbilityDelegatorArgs::KEY_TEST_WAIT_TIMEOUT] =
want.GetStringParam(AbilityDelegatorArgs::KEY_TEST_WAIT_TIMEOUT);
auto wantParams = want.GetParams();
std::set<std::string> keys = wantParams.KeySet();
for (auto key : keys) {
params_[key] = want.GetStringParam(key);
}
}

View File

@ -85,14 +85,18 @@ const std::string HELP_MSG_DUMPSYS = "usage: aa dump <options>\n"
" The original -s parameter is invalid\n"
" The original -m parameter is invalid\n";
const std::string HELP_MSG_TEST =
"usage: aa test <options>\n"
"options list:\n"
" -h, --help \
list available commands\n"
" -p <bundle-name> -s unittest <test-runner> [-s class <test-class>] [-w <wait-time>] \
start the test framework with options\n";
" -h, --help list available commands\n"
" -p <bundle-name> -s unittest <test-runner> start the test framework with options\n"
" [-s class <test-class>]\n"
" [-s level <test-level>]\n"
" [-s size <test-size>]\n"
" [-s testType <test-testType>]\n"
" [-s timeout <test-timeout>]\n"
" [-s <any-key> <any-value>]\n"
" [-w <wait-time>]\n";
const std::string HELP_MSG_FORCE_STOP = "usage: aa force-stop <bundle-name>\n";
const std::string HELP_MSG_FORCE_TIMEOUT =

View File

@ -1239,14 +1239,10 @@ ErrCode AbilityManagerShellCommand::RunAsTestCommand()
params[opt] = argv;
} else if (opt == "-s") {
if (i >= argc_ - USER_TEST_COMMAND_PARAMS_NUM) {
return TestCommandError(
"error: option Should be [-s unittest <test-runner>] or [-s class <test-class>].\n");
return TestCommandError("error: option [-s] is incorrect.\n");
}
std::string argKey = argv_[++i];
std::string argValue = argv_[++i];
if (!(argKey == "unittest" || argKey == "class")) {
return TestCommandError("error: option Should be [-s unittest] or [-s class].\n");
}
params[opt + " " + argKey] = argValue;
} else if (opt.at(0) == '-') {
return TestCommandError("error: unknown option: " + opt + "\n");