2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2016-11-04 17:39:39 +01:00
|
|
|
#pragma once
|
2016-09-26 12:40:09 +02:00
|
|
|
|
2019-01-08 16:05:57 +01:00
|
|
|
#include <utils/fileutils.h>
|
|
|
|
|
|
2016-11-04 17:39:39 +01:00
|
|
|
#include <QObject>
|
|
|
|
|
#include <QFuture>
|
2017-04-28 08:27:10 +02:00
|
|
|
#include <QDebug>
|
2016-11-16 09:45:27 +01:00
|
|
|
#include <memory>
|
|
|
|
|
|
2016-09-26 12:40:09 +02:00
|
|
|
namespace Ios {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class SimulatorControlPrivate;
|
|
|
|
|
|
2017-01-23 15:39:01 +01:00
|
|
|
|
|
|
|
|
class SimulatorEntity {
|
2017-01-24 16:30:26 +01:00
|
|
|
public:
|
|
|
|
|
QString name;
|
|
|
|
|
QString identifier;
|
2017-01-23 15:39:01 +01:00
|
|
|
bool operator <(const SimulatorEntity &o) const
|
2017-01-24 16:30:26 +01:00
|
|
|
{
|
|
|
|
|
return name < o.name;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2017-04-28 08:27:10 +02:00
|
|
|
class SimulatorInfo : public SimulatorEntity
|
|
|
|
|
{
|
|
|
|
|
friend QDebug &operator<<(QDebug &, const SimulatorInfo &info);
|
|
|
|
|
|
2017-01-23 15:39:01 +01:00
|
|
|
public:
|
2017-03-15 17:04:47 +01:00
|
|
|
bool isBooted() const { return state == "Booted"; }
|
2017-04-28 08:27:10 +02:00
|
|
|
bool isShuttingDown() const { return state == "Shutting Down"; }
|
2017-03-15 17:04:47 +01:00
|
|
|
bool isShutdown() const { return state == "Shutdown"; }
|
2017-01-27 11:00:20 +01:00
|
|
|
bool operator==(const SimulatorInfo &other) const;
|
|
|
|
|
bool operator!=(const SimulatorInfo &other) const { return !(*this == other); }
|
2017-01-23 15:39:01 +01:00
|
|
|
bool available;
|
|
|
|
|
QString state;
|
|
|
|
|
QString runtimeName;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class RuntimeInfo : public SimulatorEntity{
|
|
|
|
|
public:
|
|
|
|
|
QString version;
|
|
|
|
|
QString build;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class DeviceTypeInfo : public SimulatorEntity {};
|
|
|
|
|
|
2021-05-25 12:14:56 +02:00
|
|
|
class SimulatorControl
|
2016-09-26 12:40:09 +02:00
|
|
|
{
|
2016-11-04 17:39:39 +01:00
|
|
|
public:
|
|
|
|
|
struct ResponseData {
|
|
|
|
|
ResponseData(const QString & udid):
|
|
|
|
|
simUdid(udid) { }
|
|
|
|
|
|
|
|
|
|
QString simUdid;
|
|
|
|
|
bool success = false;
|
|
|
|
|
qint64 pID = -1;
|
2018-05-23 09:46:12 +02:00
|
|
|
QString commandOutput;
|
2016-11-04 17:39:39 +01:00
|
|
|
};
|
|
|
|
|
|
2016-09-26 12:40:09 +02:00
|
|
|
public:
|
2017-01-23 15:39:01 +01:00
|
|
|
static QList<DeviceTypeInfo> availableDeviceTypes();
|
|
|
|
|
static QFuture<QList<DeviceTypeInfo> > updateDeviceTypes();
|
|
|
|
|
static QList<RuntimeInfo> availableRuntimes();
|
|
|
|
|
static QFuture<QList<RuntimeInfo> > updateRuntimes();
|
2017-01-24 16:30:26 +01:00
|
|
|
static QList<SimulatorInfo> availableSimulators();
|
2017-01-23 15:39:01 +01:00
|
|
|
static QFuture<QList<SimulatorInfo> > updateAvailableSimulators();
|
2016-09-26 12:40:09 +02:00
|
|
|
static bool isSimulatorRunning(const QString &simUdid);
|
2019-05-28 13:49:26 +02:00
|
|
|
static QString bundleIdentifier(const Utils::FilePath &bundlePath);
|
|
|
|
|
static QString bundleExecutable(const Utils::FilePath &bundlePath);
|
2016-11-04 17:39:39 +01:00
|
|
|
|
|
|
|
|
public:
|
2021-05-25 12:14:56 +02:00
|
|
|
static QFuture<ResponseData> startSimulator(const QString &simUdid);
|
|
|
|
|
static QFuture<ResponseData> installApp(const QString &simUdid,
|
|
|
|
|
const Utils::FilePath &bundlePath);
|
|
|
|
|
static QFuture<ResponseData> launchApp(const QString &simUdid,
|
|
|
|
|
const QString &bundleIdentifier,
|
|
|
|
|
bool waitForDebugger,
|
|
|
|
|
const QStringList &extraArgs,
|
|
|
|
|
const QString &stdoutPath = QString(),
|
|
|
|
|
const QString &stderrPath = QString());
|
|
|
|
|
static QFuture<ResponseData> deleteSimulator(const QString &simUdid);
|
|
|
|
|
static QFuture<ResponseData> resetSimulator(const QString &simUdid);
|
|
|
|
|
static QFuture<ResponseData> renameSimulator(const QString &simUdid, const QString &newName);
|
|
|
|
|
static QFuture<ResponseData> createSimulator(const QString &name,
|
|
|
|
|
const DeviceTypeInfo &deviceType,
|
|
|
|
|
const RuntimeInfo &runtime);
|
|
|
|
|
static QFuture<ResponseData> takeSceenshot(const QString &simUdid, const QString &filePath);
|
2016-09-26 12:40:09 +02:00
|
|
|
};
|
2021-05-25 12:14:56 +02:00
|
|
|
|
2016-09-26 12:40:09 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Ios
|
2017-01-24 16:30:26 +01:00
|
|
|
|
2017-01-23 15:39:01 +01:00
|
|
|
Q_DECLARE_METATYPE(Ios::Internal::DeviceTypeInfo)
|
|
|
|
|
Q_DECLARE_METATYPE(Ios::Internal::RuntimeInfo)
|
2017-01-24 16:30:26 +01:00
|
|
|
Q_DECLARE_METATYPE(Ios::Internal::SimulatorInfo)
|