From d668f60ab9a898679ec352de800a3689b57647a0 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Mon, 3 Sep 2018 23:26:19 -0700 Subject: [PATCH] Creates snapshot folder. --- tools/auto-tester/src/TestRunner.cpp | 41 +++++++++++++--------------- tools/auto-tester/src/TestRunner.h | 14 ++++++---- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/tools/auto-tester/src/TestRunner.cpp b/tools/auto-tester/src/TestRunner.cpp index ca3d3147bf..bd427dd66b 100644 --- a/tools/auto-tester/src/TestRunner.cpp +++ b/tools/auto-tester/src/TestRunner.cpp @@ -1,7 +1,7 @@ // // TestRunner.cpp // -// Created by Nissim Hadar on 1 Sep 2018. +// Created by Nissim Hadar on 1 Sept 2018. // Copyright 2013 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. @@ -19,28 +19,23 @@ TestRunner::TestRunner(QObject *parent) : QObject(parent) { } void TestRunner::run() { - selectTemporaryFolder(); - runInstaller(); - - - - saveExistingHighFidelityAppDataFolder(); selectTemporaryFolder(); QStringList urls; - urls << "http://builds.highfidelity.com/HighFidelity-Beta-latest-dev.exe"; + urls << INSTALLER_URL; QStringList filenames; - filenames << _installerFilename; + filenames << INSTALLER_FILENAME; - autoTester->downloadFiles(urls, _tempDirectory, filenames, (void *)this); + autoTester->downloadFiles(urls, _tempFolder, filenames, (void *)this); - // Will continue after download complete + // installerDownloadComplete will run after download complete } void TestRunner::installerDownloadComplete() { runInstaller(); + createSnapshotFolder(); restoreHighFidelityAppDataFolder(); } @@ -48,14 +43,12 @@ void TestRunner::installerDownloadComplete() { 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(_tempDirectory) }; + QStringList arguments{ QStringList() << QString("/S") << QString("/D=") + QDir::toNativeSeparators(_tempFolder) }; - QString installerFullPath = _tempDirectory + "/" + _installerFilename; - QString commandLine = installerFullPath + " /S /D=" + QDir::toNativeSeparators(_tempDirectory); + QString installerFullPath = _tempFolder + "/" + INSTALLER_FILENAME; + QString commandLine = QDir::toNativeSeparators(installerFullPath + " /S /D=" + _tempFolder); + system(commandLine.toStdString().c_str()); - int i = 34; - //qint64 pid; - //QProcess::startDetached(installerFullPath, arguments, QString(), &pid); } void TestRunner::saveExistingHighFidelityAppDataFolder() { @@ -74,7 +67,7 @@ void TestRunner::saveExistingHighFidelityAppDataFolder() { } // The original folder is saved in a unique name - _savedAppDataFolder = dataDirectory + "/" + _uniqueFolderName; + _savedAppDataFolder = dataDirectory + "/" + UNIQUE_FOLDER_NAME; _appDataFolder.rename(_appDataFolder.path(), _savedAppDataFolder.path()); QDir().mkdir(_appDataFolder.path()); @@ -87,18 +80,22 @@ void TestRunner::restoreHighFidelityAppDataFolder() { } void TestRunner::selectTemporaryFolder() { - QString previousSelection = _tempDirectory; + QString previousSelection = _tempFolder; QString parent = previousSelection.left(previousSelection.lastIndexOf('/')); if (!parent.isNull() && parent.right(1) != "/") { parent += "/"; } - _tempDirectory = + _tempFolder = QFileDialog::getExistingDirectory(nullptr, "Please select a temporary folder for installation", parent, QFileDialog::ShowDirsOnly); // If user canceled then restore previous selection and return - if (_tempDirectory == "") { - _tempDirectory = previousSelection; + if (_tempFolder == "") { + _tempFolder = previousSelection; return; } +} + +void TestRunner::createSnapshotFolder() { + QDir().mkdir(_tempFolder + "/" + SNAPSHOT_FOLDER_NAME); } \ No newline at end of file diff --git a/tools/auto-tester/src/TestRunner.h b/tools/auto-tester/src/TestRunner.h index e9cd8bbfc0..69445e0ba4 100644 --- a/tools/auto-tester/src/TestRunner.h +++ b/tools/auto-tester/src/TestRunner.h @@ -1,7 +1,7 @@ // // Downloader.h // -// Created by Nissim Hadar on 1 Sep 2018. +// Created by Nissim Hadar on 1 Sept 2018. // Copyright 2013 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. @@ -29,17 +29,21 @@ public: void saveExistingHighFidelityAppDataFolder(); void restoreHighFidelityAppDataFolder(); void selectTemporaryFolder(); + void createSnapshotFolder(); -private: + private: QDir _appDataFolder; QDir _savedAppDataFolder; - QString _tempDirectory; + QString _tempFolder; Downloader* _downloader; - const QString _uniqueFolderName{ "fgadhcUDHSFaidsfh3478JJJFSDFIUSOEIrf" }; - const QString _installerFilename{ "HighFidelity-Beta-latest-dev.exe" }; + 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" }; BusyWindow _busyWindow; };