[androidtestrunner] Add option for the AndroidManifest.xml

Allow specifying path AndroidManifest.xml from command line.

Change-Id: I4a2301b98befe32c27602ff63b65aea8a4686123
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
Alexey Edelev 2025-03-10 17:42:08 +01:00
parent ea575585e7
commit 086bb48768

View File

@ -38,6 +38,7 @@ struct Options
int timeoutSecs = 600; // 10 minutes
int resultsPullRetries = 3;
QString buildPath;
QString manifestPath;
QString adbCommand{"adb"_L1};
QString serial;
QString makeCommand;
@ -137,6 +138,11 @@ static bool parseOptions()
g_options.helpRequested = true;
else
g_options.buildPath = arguments.at(++i);
} else if (argument.compare("--manifest"_L1, Qt::CaseInsensitive) == 0) {
if (i + 1 == arguments.size())
g_options.helpRequested = true;
else
g_options.manifestPath = arguments.at(++i);
} else if (argument.compare("--make"_L1, Qt::CaseInsensitive) == 0) {
if (i + 1 == arguments.size())
g_options.helpRequested = true;
@ -208,6 +214,9 @@ static bool parseOptions()
g_options.ndkStackPath = ndkStackPath;
}
if (g_options.manifestPath.isEmpty())
g_options.manifestPath = g_options.buildPath + "/AndroidManifest.xml"_L1;
return true;
}
@ -254,6 +263,8 @@ static void printHelp()
" --pre-test-adb-command <command>: call the adb <command> after\n"
" installation and before the test run.\n"
"\n"
" --manifest <path>: Custom path to the AndroidManifest.xml.\n"
"\n"
" --help: Displays this information.\n",
qPrintable(QCoreApplication::arguments().at(0))
);
@ -860,14 +871,13 @@ int main(int argc, char *argv[])
g_testInfo.userId = userId();
QString manifest = g_options.buildPath + "/AndroidManifest.xml"_L1;
if (!QFile::exists(manifest)) {
qCritical("Unable to find '%s'.", qPrintable(manifest));
if (!QFile::exists(g_options.manifestPath)) {
qCritical("Unable to find '%s'.", qPrintable(g_options.manifestPath));
return EXIT_ERROR;
}
g_options.package = packageNameFromAndroidManifest(manifest);
g_options.package = packageNameFromAndroidManifest(g_options.manifestPath);
if (g_options.activity.isEmpty())
g_options.activity = activityFromAndroidManifest(manifest);
g_options.activity = activityFromAndroidManifest(g_options.manifestPath);
// parseTestArgs depends on g_options.package
if (!parseTestArgs())