Can run installer in a thread.

This commit is contained in:
NissimHadar 2018-09-13 15:34:10 -07:00
parent cc9196fc26
commit 35eb019524
2 changed files with 66 additions and 29 deletions

View file

@ -32,6 +32,8 @@ TestRunner::TestRunner(std::vector<QCheckBox*> dayCheckboxes,
_timeEditCheckboxes = timeEditCheckboxes;
_timeEdits = timeEdits;
_workingFolderLabel = workingFolderLabel;
thread = new QThread();
}
TestRunner::~TestRunner() {
@ -103,7 +105,32 @@ void TestRunner::installerDownloadComplete() {
killProcesses();
runInstaller();
}
void TestRunner::runInstaller() {
// Qt cannot start an installation process using QProcess::start (Qt Bug 9761)
// To allow installation, the installer is run using the `system` command
QStringList arguments{ QStringList() << QString("/S") << QString("/D=") + QDir::toNativeSeparators(_installationFolder) };
QString installerFullPath = _workingFolder + "/" + INSTALLER_FILENAME;
QString commandLine =
QDir::toNativeSeparators(installerFullPath) + " /S /D=" + QDir::toNativeSeparators(_installationFolder);
worker = new Worker(commandLine);
worker->moveToThread(thread);
connect(worker, SIGNAL(error(QString)), this, SLOT(errorString(QString)));
connect(thread, SIGNAL(started()), worker, SLOT(process()));
connect(worker, SIGNAL(finished()), this, SLOT(installationComplete()));
connect(worker, SIGNAL(finished()), thread, SLOT(quit()));
connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater()));
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
thread->start();
}
void TestRunner::installationComplete() {
createSnapshotFolder();
updateStatusLabel("Running tests");
@ -117,19 +144,6 @@ void TestRunner::installerDownloadComplete() {
// The High Fidelity AppData folder will be restored after evaluation has completed
}
void TestRunner::runInstaller() {
// Qt cannot start an installation process using QProcess::start (Qt Bug 9761)
// To allow installation, the installer is run using the `system` command
QStringList arguments{ QStringList() << QString("/S") << QString("/D=") + QDir::toNativeSeparators(_installationFolder) };
QString installerFullPath = _workingFolder + "/" + INSTALLER_FILENAME;
QString commandLine =
QDir::toNativeSeparators(installerFullPath) + " /S /D=" + QDir::toNativeSeparators(_installationFolder);
system(commandLine.toStdString().c_str());
}
void TestRunner::saveExistingHighFidelityAppDataFolder() {
QString dataDirectory{ "NOT FOUND" };
@ -414,4 +428,13 @@ void TestRunner::appendLog(const QString& message) {
_logFile.close();
autoTester->appendLogWindow(message);
}
}
Worker::Worker(const QString commandLine) {
_commandLine = commandLine;
}
void Worker::process() {
system(_commandLine.toStdString().c_str());
emit finished();
}

View file

@ -15,11 +15,11 @@
#include <QDir>
#include <QLabel>
#include <QObject>
#include <QProcess>
#include <QThread>
#include <QTimeEdit>
#include <QTimer>
#include "Downloader.h"
class Worker;
class TestRunner : public QObject {
Q_OBJECT
@ -56,29 +56,27 @@ public:
private slots:
void checkTime();
void installationComplete();
private:
bool _automatedTestIsRunning{ false };
QDir _appDataFolder;
QDir _savedAppDataFolder;
QString _workingFolder;
QString _snapshotFolder;
QString _installationFolder;
Downloader* _downloader;
const QString UNIQUE_FOLDER_NAME{ "fgadhcUDHSFaidsfh3478JJJFSDFIUSOEIrf" };
const QString SNAPSHOT_FOLDER_NAME{ "snapshots" };
const QString INSTALLER_URL{ "http://builds.highfidelity.com/HighFidelity-Beta-latest-dev.exe" };
const QString INSTALLER_FILENAME{ "HighFidelity-Beta-latest-dev.exe" };
const QString BUILD_XML_URL{ "https://highfidelity.com/dev-builds.xml" };
const QString BUILD_XML_FILENAME{ "dev-builds.xml" };
QDir _appDataFolder;
QDir _savedAppDataFolder;
QString _workingFolder;
QString _installationFolder;
QString _snapshotFolder;
const QString UNIQUE_FOLDER_NAME{ "fgadhcUDHSFaidsfh3478JJJFSDFIUSOEIrf" };
const QString SNAPSHOT_FOLDER_NAME{ "snapshots" };
QString _branch;
QString _user;
@ -92,6 +90,22 @@ private:
QFile _logFile;
QDateTime _testStartDateTime;
QThread* thread;
Worker* worker;
};
class Worker : public QObject {
Q_OBJECT
public:
Worker(const QString commandLine);
public slots:
void process();
signals:
void finished();
private:
QString _commandLine;
};
#endif // hifi_testRunner_h