forked from qt-creator/qt-creator
Remove code noise
Change-Id: I34d5df0be0a7772f9e08635afb398d6289840a92 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -77,8 +77,8 @@ using ToolChainPair = std::pair<ClangToolChain *, ClangToolChain *>;
|
|||||||
namespace Ios {
|
namespace Ios {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
const QLatin1String SettingsGroup("IosConfigurations");
|
const char SettingsGroup[] = "IosConfigurations";
|
||||||
const QLatin1String ignoreAllDevicesKey("IgnoreAllDevices");
|
const char ignoreAllDevicesKey[] = "IgnoreAllDevices";
|
||||||
const char screenshotDirPathKey[] = "ScreeshotDirPath";
|
const char screenshotDirPathKey[] = "ScreeshotDirPath";
|
||||||
|
|
||||||
const char provisioningTeamsTag[] = "IDEProvisioningTeams";
|
const char provisioningTeamsTag[] = "IDEProvisioningTeams";
|
||||||
@@ -98,9 +98,9 @@ static const QString provisioningProfileDirPath = QDir::homePath() + "/Library/M
|
|||||||
|
|
||||||
static Core::Id deviceId(const QString &sdkName)
|
static Core::Id deviceId(const QString &sdkName)
|
||||||
{
|
{
|
||||||
if (sdkName.toLower().startsWith(QLatin1String("iphoneos")))
|
if (sdkName.startsWith("iphoneos", Qt::CaseInsensitive))
|
||||||
return Constants::IOS_DEVICE_TYPE;
|
return Constants::IOS_DEVICE_TYPE;
|
||||||
else if (sdkName.toLower().startsWith(QLatin1String("iphonesimulator")))
|
else if (sdkName.startsWith("iphonesimulator", Qt::CaseInsensitive))
|
||||||
return Constants::IOS_SIMULATOR_TYPE;
|
return Constants::IOS_SIMULATOR_TYPE;
|
||||||
return Core::Id();
|
return Core::Id();
|
||||||
}
|
}
|
||||||
@@ -124,8 +124,8 @@ static QList<ClangToolChain *> autoDetectedIosToolChains()
|
|||||||
const QList<ClangToolChain *> toolChains = clangToolChains(ToolChainManager::toolChains());
|
const QList<ClangToolChain *> toolChains = clangToolChains(ToolChainManager::toolChains());
|
||||||
return Utils::filtered(toolChains, [](ClangToolChain *toolChain) {
|
return Utils::filtered(toolChains, [](ClangToolChain *toolChain) {
|
||||||
return toolChain->isAutoDetected()
|
return toolChain->isAutoDetected()
|
||||||
&& (toolChain->displayName().startsWith(QLatin1String("iphone"))
|
&& (toolChain->displayName().startsWith("iphone")
|
||||||
|| toolChain->displayName().startsWith(QLatin1String("Apple Clang"))); // TODO tool chains should be marked directly
|
|| toolChain->displayName().startsWith("Apple Clang")); // TODO tool chains should be marked directly
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -53,20 +53,20 @@ Q_LOGGING_CATEGORY(simulatorLog, "qtc.ios.simulator")
|
|||||||
namespace Ios {
|
namespace Ios {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
static int SIMULATOR_START_TIMEOUT = 60000;
|
const int simulatorStartTimeout = 60000;
|
||||||
|
|
||||||
// simctl Json Tags and tokens.
|
// simctl Json Tags and tokens.
|
||||||
static QString DeviceTypeTag = QStringLiteral("devicetypes");
|
const char deviceTypeTag[] = "devicetypes";
|
||||||
static QString DevicesTag = QStringLiteral("devices");
|
const char devicesTag[] = "devices";
|
||||||
static QString AvailabilityTag = QStringLiteral("availability");
|
const char availabilityTag[] = "availability";
|
||||||
static QString UnavailabilityToken = QStringLiteral("unavailable");
|
const char unavailabilityToken[] = "unavailable";
|
||||||
static QString IdentifierTag = QStringLiteral("identifier");
|
const char identifierTag[] = "identifier";
|
||||||
static QString RuntimesTag = QStringLiteral("runtimes");
|
const char runtimesTag[] = "runtimes";
|
||||||
static QString NameTag = QStringLiteral("name");
|
const char nameTag[] = "name";
|
||||||
static QString StateTag = QStringLiteral("state");
|
const char stateTag[] = "state";
|
||||||
static QString UdidTag = QStringLiteral("udid");
|
const char udidTag[] = "udid";
|
||||||
static QString RuntimeVersionTag = QStringLiteral("version");
|
const char runtimeVersionTag[] = "version";
|
||||||
static QString BuildVersionTag = QStringLiteral("buildversion");
|
const char buildVersionTag[] = "buildversion";
|
||||||
|
|
||||||
static bool checkForTimeout(const chrono::high_resolution_clock::time_point &start, int msecs = 10000)
|
static bool checkForTimeout(const chrono::high_resolution_clock::time_point &start, int msecs = 10000)
|
||||||
{
|
{
|
||||||
@@ -89,24 +89,24 @@ static bool runCommand(QString command, const QStringList &args, QByteArray *out
|
|||||||
|
|
||||||
static bool runSimCtlCommand(QStringList args, QByteArray *output)
|
static bool runSimCtlCommand(QStringList args, QByteArray *output)
|
||||||
{
|
{
|
||||||
args.prepend(QStringLiteral("simctl"));
|
args.prepend("simctl");
|
||||||
return runCommand(QStringLiteral("xcrun"), args, output);
|
return runCommand("xcrun", args, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QList<DeviceTypeInfo> getAvailableDeviceTypes()
|
static QList<DeviceTypeInfo> getAvailableDeviceTypes()
|
||||||
{
|
{
|
||||||
QList<DeviceTypeInfo> deviceTypes;
|
QList<DeviceTypeInfo> deviceTypes;
|
||||||
QByteArray output;
|
QByteArray output;
|
||||||
runSimCtlCommand({QLatin1String("list"), QLatin1String("-j"), DeviceTypeTag}, &output);
|
runSimCtlCommand({"list", "-j", deviceTypeTag}, &output);
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(output);
|
QJsonDocument doc = QJsonDocument::fromJson(output);
|
||||||
if (!doc.isNull()) {
|
if (!doc.isNull()) {
|
||||||
const QJsonArray runtimesArray = doc.object().value(DeviceTypeTag).toArray();
|
const QJsonArray runtimesArray = doc.object().value(deviceTypeTag).toArray();
|
||||||
foreach (const QJsonValue deviceTypeValue, runtimesArray) {
|
foreach (const QJsonValue deviceTypeValue, runtimesArray) {
|
||||||
QJsonObject deviceTypeObject = deviceTypeValue.toObject();
|
QJsonObject deviceTypeObject = deviceTypeValue.toObject();
|
||||||
if (!deviceTypeObject.value(AvailabilityTag).toString().contains(UnavailabilityToken)) {
|
if (!deviceTypeObject.value(availabilityTag).toString().contains(unavailabilityToken)) {
|
||||||
DeviceTypeInfo deviceType;
|
DeviceTypeInfo deviceType;
|
||||||
deviceType.name = deviceTypeObject.value(NameTag).toString("unknown");
|
deviceType.name = deviceTypeObject.value(nameTag).toString("unknown");
|
||||||
deviceType.identifier = deviceTypeObject.value(IdentifierTag).toString("unknown");
|
deviceType.identifier = deviceTypeObject.value(identifierTag).toString("unknown");
|
||||||
deviceTypes.append(deviceType);
|
deviceTypes.append(deviceType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,18 +121,18 @@ static QList<RuntimeInfo> getAvailableRuntimes()
|
|||||||
{
|
{
|
||||||
QList<RuntimeInfo> runtimes;
|
QList<RuntimeInfo> runtimes;
|
||||||
QByteArray output;
|
QByteArray output;
|
||||||
runSimCtlCommand({QLatin1String("list"), QLatin1String("-j"), RuntimesTag}, &output);
|
runSimCtlCommand({"list", "-j", runtimesTag}, &output);
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(output);
|
QJsonDocument doc = QJsonDocument::fromJson(output);
|
||||||
if (!doc.isNull()) {
|
if (!doc.isNull()) {
|
||||||
const QJsonArray runtimesArray = doc.object().value(RuntimesTag).toArray();
|
const QJsonArray runtimesArray = doc.object().value(runtimesTag).toArray();
|
||||||
foreach (const QJsonValue runtimeValue, runtimesArray) {
|
foreach (const QJsonValue runtimeValue, runtimesArray) {
|
||||||
QJsonObject runtimeObject = runtimeValue.toObject();
|
QJsonObject runtimeObject = runtimeValue.toObject();
|
||||||
if (!runtimeObject.value(AvailabilityTag).toString().contains(UnavailabilityToken)) {
|
if (!runtimeObject.value(availabilityTag).toString().contains(unavailabilityToken)) {
|
||||||
RuntimeInfo runtime;
|
RuntimeInfo runtime;
|
||||||
runtime.name = runtimeObject.value(NameTag).toString("unknown");
|
runtime.name = runtimeObject.value(nameTag).toString("unknown");
|
||||||
runtime.build = runtimeObject.value(BuildVersionTag).toString("unknown");
|
runtime.build = runtimeObject.value(buildVersionTag).toString("unknown");
|
||||||
runtime.identifier = runtimeObject.value(IdentifierTag).toString("unknown");
|
runtime.identifier = runtimeObject.value(identifierTag).toString("unknown");
|
||||||
runtime.version = runtimeObject.value(RuntimeVersionTag).toString("unknown");
|
runtime.version = runtimeObject.value(runtimeVersionTag).toString("unknown");
|
||||||
runtimes.append(runtime);
|
runtimes.append(runtime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -197,21 +197,21 @@ static QList<SimulatorInfo> getAllSimulatorDevices()
|
|||||||
{
|
{
|
||||||
QList<SimulatorInfo> simulatorDevices;
|
QList<SimulatorInfo> simulatorDevices;
|
||||||
QByteArray output;
|
QByteArray output;
|
||||||
runSimCtlCommand({QLatin1String("list"), QLatin1String("-j"), DevicesTag}, &output);
|
runSimCtlCommand({"list", "-j", devicesTag}, &output);
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(output);
|
QJsonDocument doc = QJsonDocument::fromJson(output);
|
||||||
if (!doc.isNull()) {
|
if (!doc.isNull()) {
|
||||||
const QJsonObject runtimeObject = doc.object().value(DevicesTag).toObject();
|
const QJsonObject runtimeObject = doc.object().value(devicesTag).toObject();
|
||||||
foreach (const QString &runtime, runtimeObject.keys()) {
|
foreach (const QString &runtime, runtimeObject.keys()) {
|
||||||
const QJsonArray devices = runtimeObject.value(runtime).toArray();
|
const QJsonArray devices = runtimeObject.value(runtime).toArray();
|
||||||
foreach (const QJsonValue deviceValue, devices) {
|
foreach (const QJsonValue deviceValue, devices) {
|
||||||
QJsonObject deviceObject = deviceValue.toObject();
|
QJsonObject deviceObject = deviceValue.toObject();
|
||||||
SimulatorInfo device;
|
SimulatorInfo device;
|
||||||
device.identifier = deviceObject.value(UdidTag).toString();
|
device.identifier = deviceObject.value(udidTag).toString();
|
||||||
device.name = deviceObject.value(NameTag).toString();
|
device.name = deviceObject.value(nameTag).toString();
|
||||||
device.runtimeName = runtime;
|
device.runtimeName = runtime;
|
||||||
const QString availableStr = deviceObject.value(AvailabilityTag).toString();
|
const QString availableStr = deviceObject.value(availabilityTag).toString();
|
||||||
device.available = !availableStr.contains(UnavailabilityToken);
|
device.available = !availableStr.contains(unavailabilityToken);
|
||||||
device.state = deviceObject.value(StateTag).toString();
|
device.state = deviceObject.value(stateTag).toString();
|
||||||
simulatorDevices.append(device);
|
simulatorDevices.append(device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -408,7 +408,7 @@ void SimulatorControlPrivate::startSimulator(QFutureInterface<SimulatorControl::
|
|||||||
// interval of closing the previous interval of the simulator. We wait untill the shutdown
|
// interval of closing the previous interval of the simulator. We wait untill the shutdown
|
||||||
// process is complete.
|
// process is complete.
|
||||||
auto start = chrono::high_resolution_clock::now();
|
auto start = chrono::high_resolution_clock::now();
|
||||||
while (simInfo.isShuttingDown() && !checkForTimeout(start, SIMULATOR_START_TIMEOUT)) {
|
while (simInfo.isShuttingDown() && !checkForTimeout(start, simulatorStartTimeout)) {
|
||||||
// Wait till the simulator shuts down, if doing so.
|
// Wait till the simulator shuts down, if doing so.
|
||||||
QThread::currentThread()->msleep(100);
|
QThread::currentThread()->msleep(100);
|
||||||
simInfo = deviceInfo(simUdid);
|
simInfo = deviceInfo(simUdid);
|
||||||
@@ -422,9 +422,9 @@ void SimulatorControlPrivate::startSimulator(QFutureInterface<SimulatorControl::
|
|||||||
|
|
||||||
if (simInfo.isShutdown()) {
|
if (simInfo.isShutdown()) {
|
||||||
const QString cmd = IosConfigurations::developerPath()
|
const QString cmd = IosConfigurations::developerPath()
|
||||||
.appendPath(QStringLiteral("/Applications/Simulator.app/Contents/MacOS/Simulator"))
|
.appendPath("/Applications/Simulator.app/Contents/MacOS/Simulator")
|
||||||
.toString();
|
.toString();
|
||||||
const QStringList args({QStringLiteral("--args"), QStringLiteral("-CurrentDeviceUDID"), simUdid});
|
const QStringList args({"--args", "-CurrentDeviceUDID", simUdid});
|
||||||
|
|
||||||
if (QProcess::startDetached(cmd, args)) {
|
if (QProcess::startDetached(cmd, args)) {
|
||||||
if (fi.isCanceled())
|
if (fi.isCanceled())
|
||||||
@@ -439,7 +439,7 @@ void SimulatorControlPrivate::startSimulator(QFutureInterface<SimulatorControl::
|
|||||||
if (fi.isCanceled())
|
if (fi.isCanceled())
|
||||||
return;
|
return;
|
||||||
} while (!info.isBooted()
|
} while (!info.isBooted()
|
||||||
&& !checkForTimeout(start, SIMULATOR_START_TIMEOUT));
|
&& !checkForTimeout(start, simulatorStartTimeout));
|
||||||
if (info.isBooted()) {
|
if (info.isBooted()) {
|
||||||
response.success = true;
|
response.success = true;
|
||||||
}
|
}
|
||||||
@@ -462,7 +462,7 @@ void SimulatorControlPrivate::installApp(QFutureInterface<SimulatorControl::Resp
|
|||||||
QTC_CHECK(bundlePath.exists());
|
QTC_CHECK(bundlePath.exists());
|
||||||
|
|
||||||
SimulatorControl::ResponseData response(simUdid);
|
SimulatorControl::ResponseData response(simUdid);
|
||||||
response.success = runSimCtlCommand({QStringLiteral("install"), simUdid, bundlePath.toString()},
|
response.success = runSimCtlCommand({"install", simUdid, bundlePath.toString()},
|
||||||
&response.commandOutput);
|
&response.commandOutput);
|
||||||
if (!fi.isCanceled())
|
if (!fi.isCanceled())
|
||||||
fi.reportResult(response);
|
fi.reportResult(response);
|
||||||
@@ -475,17 +475,17 @@ void SimulatorControlPrivate::launchApp(QFutureInterface<SimulatorControl::Respo
|
|||||||
{
|
{
|
||||||
SimulatorControl::ResponseData response(simUdid);
|
SimulatorControl::ResponseData response(simUdid);
|
||||||
if (!bundleIdentifier.isEmpty() && !fi.isCanceled()) {
|
if (!bundleIdentifier.isEmpty() && !fi.isCanceled()) {
|
||||||
QStringList args({QStringLiteral("launch"), simUdid, bundleIdentifier});
|
QStringList args({"launch", simUdid, bundleIdentifier});
|
||||||
|
|
||||||
// simctl usage documentation : Note: Log output is often directed to stderr, not stdout.
|
// simctl usage documentation : Note: Log output is often directed to stderr, not stdout.
|
||||||
if (!stdoutPath.isEmpty())
|
if (!stdoutPath.isEmpty())
|
||||||
args.insert(1, QStringLiteral("--stderr=%1").arg(stdoutPath));
|
args.insert(1, QString("--stderr=%1").arg(stdoutPath));
|
||||||
|
|
||||||
if (!stderrPath.isEmpty())
|
if (!stderrPath.isEmpty())
|
||||||
args.insert(1, QStringLiteral("--stdout=%1").arg(stderrPath));
|
args.insert(1, QString("--stdout=%1").arg(stderrPath));
|
||||||
|
|
||||||
if (waitForDebugger)
|
if (waitForDebugger)
|
||||||
args.insert(1, QStringLiteral("-w"));
|
args.insert(1, "-w");
|
||||||
|
|
||||||
foreach (const QString extraArgument, extraArgs) {
|
foreach (const QString extraArgument, extraArgs) {
|
||||||
if (!extraArgument.trimmed().isEmpty())
|
if (!extraArgument.trimmed().isEmpty())
|
||||||
@@ -509,7 +509,7 @@ void SimulatorControlPrivate::deleteSimulator(QFutureInterface<SimulatorControl:
|
|||||||
const QString &simUdid)
|
const QString &simUdid)
|
||||||
{
|
{
|
||||||
SimulatorControl::ResponseData response(simUdid);
|
SimulatorControl::ResponseData response(simUdid);
|
||||||
response.success = runSimCtlCommand({QStringLiteral("delete"), simUdid}, &response.commandOutput);
|
response.success = runSimCtlCommand({"delete", simUdid}, &response.commandOutput);
|
||||||
|
|
||||||
if (!fi.isCanceled())
|
if (!fi.isCanceled())
|
||||||
fi.reportResult(response);
|
fi.reportResult(response);
|
||||||
@@ -519,7 +519,7 @@ void SimulatorControlPrivate::resetSimulator(QFutureInterface<SimulatorControl::
|
|||||||
const QString &simUdid)
|
const QString &simUdid)
|
||||||
{
|
{
|
||||||
SimulatorControl::ResponseData response(simUdid);
|
SimulatorControl::ResponseData response(simUdid);
|
||||||
response.success = runSimCtlCommand({QStringLiteral("erase"), simUdid}, &response.commandOutput);
|
response.success = runSimCtlCommand({"erase", simUdid}, &response.commandOutput);
|
||||||
|
|
||||||
if (!fi.isCanceled())
|
if (!fi.isCanceled())
|
||||||
fi.reportResult(response);
|
fi.reportResult(response);
|
||||||
@@ -529,7 +529,7 @@ void SimulatorControlPrivate::renameSimulator(QFutureInterface<SimulatorControl:
|
|||||||
const QString &simUdid, const QString &newName)
|
const QString &simUdid, const QString &newName)
|
||||||
{
|
{
|
||||||
SimulatorControl::ResponseData response(simUdid);
|
SimulatorControl::ResponseData response(simUdid);
|
||||||
response.success = runSimCtlCommand({QStringLiteral("rename"), simUdid, newName},
|
response.success = runSimCtlCommand({"rename", simUdid, newName},
|
||||||
&response.commandOutput);
|
&response.commandOutput);
|
||||||
|
|
||||||
if (!fi.isCanceled())
|
if (!fi.isCanceled())
|
||||||
@@ -543,7 +543,7 @@ void SimulatorControlPrivate::createSimulator(QFutureInterface<SimulatorControl:
|
|||||||
{
|
{
|
||||||
SimulatorControl::ResponseData response("Invalid");
|
SimulatorControl::ResponseData response("Invalid");
|
||||||
if (!name.isEmpty()) {
|
if (!name.isEmpty()) {
|
||||||
response.success = runSimCtlCommand({QStringLiteral("create"), name,
|
response.success = runSimCtlCommand({"create", name,
|
||||||
deviceType.identifier,
|
deviceType.identifier,
|
||||||
runtime.identifier},
|
runtime.identifier},
|
||||||
&response.commandOutput);
|
&response.commandOutput);
|
||||||
@@ -559,8 +559,7 @@ void SimulatorControlPrivate::takeSceenshot(QFutureInterface<SimulatorControl::R
|
|||||||
const QString &simUdid, const QString &filePath)
|
const QString &simUdid, const QString &filePath)
|
||||||
{
|
{
|
||||||
SimulatorControl::ResponseData response(simUdid);
|
SimulatorControl::ResponseData response(simUdid);
|
||||||
response.success = runSimCtlCommand({QStringLiteral("io"), simUdid, QStringLiteral("screenshot"),
|
response.success = runSimCtlCommand({"io", simUdid, "screenshot", filePath},
|
||||||
filePath},
|
|
||||||
&response.commandOutput);
|
&response.commandOutput);
|
||||||
if (!fi.isCanceled())
|
if (!fi.isCanceled())
|
||||||
fi.reportResult(response);
|
fi.reportResult(response);
|
||||||
|
@@ -55,9 +55,9 @@ class SimulatorInfo : public SimulatorEntity
|
|||||||
friend QDebug &operator<<(QDebug &, const SimulatorInfo &info);
|
friend QDebug &operator<<(QDebug &, const SimulatorInfo &info);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool isBooted() const { return state.compare(QStringLiteral("Booted")) == 0; }
|
bool isBooted() const { return state == "Booted"; }
|
||||||
bool isShutdown() const { return state.compare(QStringLiteral("Shutdown")) == 0; }
|
|
||||||
bool isShuttingDown() const { return state == "Shutting Down"; }
|
bool isShuttingDown() const { return state == "Shutting Down"; }
|
||||||
|
bool isShutdown() const { return state == "Shutdown"; }
|
||||||
bool operator==(const SimulatorInfo &other) const;
|
bool operator==(const SimulatorInfo &other) const;
|
||||||
bool operator!=(const SimulatorInfo &other) const { return !(*this == other); }
|
bool operator!=(const SimulatorInfo &other) const { return !(*this == other); }
|
||||||
bool available;
|
bool available;
|
||||||
|
Reference in New Issue
Block a user