2016-09-26 12:40:09 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
|
|
|
|
**
|
|
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
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-10-17 18:22:54 +02:00
|
|
|
QT_BEGIN_NAMESPACE
|
2016-09-26 12:40:09 +02:00
|
|
|
class QProcess;
|
2016-10-17 18:22:54 +02:00
|
|
|
QT_END_NAMESPACE
|
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 {};
|
|
|
|
|
|
2016-11-04 17:39:39 +01:00
|
|
|
class SimulatorControl : public QObject
|
2016-09-26 12:40:09 +02:00
|
|
|
{
|
2016-11-04 17:39:39 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit SimulatorControl(QObject* parent = nullptr);
|
2018-11-12 19:55:59 +01:00
|
|
|
~SimulatorControl() override;
|
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:
|
2016-12-19 18:41:00 +01:00
|
|
|
QFuture<ResponseData> startSimulator(const QString &simUdid) const;
|
2019-05-28 13:49:26 +02:00
|
|
|
QFuture<ResponseData> installApp(const QString &simUdid, const Utils::FilePath &bundlePath) const;
|
2016-11-04 17:39:39 +01:00
|
|
|
QFuture<ResponseData> launchApp(const QString &simUdid, const QString &bundleIdentifier,
|
2016-12-21 18:28:42 +01:00
|
|
|
bool waitForDebugger, const QStringList &extraArgs,
|
|
|
|
|
const QString& stdoutPath = QString(),
|
|
|
|
|
const QString& stderrPath = QString()) const;
|
2017-01-23 15:39:01 +01:00
|
|
|
QFuture<ResponseData> deleteSimulator(const QString &simUdid) const;
|
|
|
|
|
QFuture<ResponseData> resetSimulator(const QString &simUdid) const;
|
|
|
|
|
QFuture<ResponseData> renameSimulator(const QString &simUdid, const QString &newName) const;
|
|
|
|
|
QFuture<ResponseData> createSimulator(const QString &name,
|
|
|
|
|
const DeviceTypeInfo &deviceType,
|
|
|
|
|
const RuntimeInfo &runtime);
|
|
|
|
|
QFuture<ResponseData> takeSceenshot(const QString &simUdid, const QString &filePath);
|
2016-09-26 12:40:09 +02:00
|
|
|
|
|
|
|
|
private:
|
2016-11-04 17:39:39 +01:00
|
|
|
SimulatorControlPrivate *d;
|
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)
|