iOS: Move app URL gathering from devicectl to a function

And add a test to document what we expect from devicectl.

Change-Id: I2f5312ebadef60239b77308acb7114f1d55143b4
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Eike Ziller
2024-01-29 16:25:13 +01:00
parent 759ea7695f
commit 2898e09bb4
4 changed files with 76 additions and 11 deletions

View File

@@ -146,19 +146,12 @@ GroupItem DeviceCtlRunner::findApp(const QString &bundleIdentifier, Storage<AppI
reportFailure(Tr::tr("Failed to run devicectl: %1.").arg(process.errorString()));
return DoneResult::Error;
}
const Utils::expected_str<QJsonValue> resultValue = parseDevicectlResult(
process.rawStdOut());
if (resultValue) {
const QJsonArray apps = (*resultValue)["apps"].toArray();
for (const QJsonValue &app : apps) {
if (app["bundleIdentifier"].toString() == bundleIdentifier) {
appInfo->pathOnDevice = QUrl(app["url"].toString());
break;
}
}
const expected_str<QUrl> pathOnDevice = parseAppInfo(process.rawStdOut(), bundleIdentifier);
if (pathOnDevice) {
appInfo->pathOnDevice = *pathOnDevice;
return DoneResult::Success;
}
reportFailure(resultValue.error());
reportFailure(pathOnDevice.error());
return DoneResult::Error;
};
return ProcessTask(onSetup, onDone);