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

@@ -83,4 +83,17 @@ expected_str<QMap<QString, QString>> parseDeviceInfo(const QByteArray &rawOutput
return make_unexpected(QLatin1String("Device is not handled by devicectl"));
}
Utils::expected_str<QUrl> parseAppInfo(const QByteArray &rawOutput, const QString &bundleIdentifier)
{
const Utils::expected_str<QJsonValue> result = parseDevicectlResult(rawOutput);
if (!result)
return make_unexpected(result.error());
const QJsonArray apps = (*result)["apps"].toArray();
for (const QJsonValue &app : apps) {
if (app["bundleIdentifier"].toString() == bundleIdentifier)
return QUrl(app["url"].toString());
}
return {};
}
} // namespace Ios::Internal