Can download the High Fidelity installer.

This commit is contained in:
NissimHadar 2018-09-01 22:46:49 -07:00
parent fb80e9c395
commit 1ffd005b77
9 changed files with 97 additions and 67 deletions

View file

@ -11,20 +11,20 @@
#include <QtWidgets/QMessageBox> #include <QtWidgets/QMessageBox>
Downloader::Downloader(QUrl imageUrl, QObject *parent) : QObject(parent) { Downloader::Downloader(QUrl fileURL, QObject *parent) : QObject(parent) {
connect( connect(
&_networkAccessManager, SIGNAL (finished(QNetworkReply*)), &_networkAccessManager, SIGNAL (finished(QNetworkReply*)),
this, SLOT (fileDownloaded(QNetworkReply*)) this, SLOT (fileDownloaded(QNetworkReply*))
); );
QNetworkRequest request(imageUrl); QNetworkRequest request(fileURL);
_networkAccessManager.get(request); _networkAccessManager.get(request);
} }
void Downloader::fileDownloaded(QNetworkReply* reply) { void Downloader::fileDownloaded(QNetworkReply* reply) {
QNetworkReply::NetworkError error = reply->error(); QNetworkReply::NetworkError error = reply->error();
if (error != QNetworkReply::NetworkError::NoError) { if (error != QNetworkReply::NetworkError::NoError) {
QMessageBox::information(0, "Test Aborted", "Failed to download image: " + reply->errorString()); QMessageBox::information(0, "Test Aborted", "Failed to download file: " + reply->errorString());
return; return;
} }

View file

@ -30,7 +30,7 @@
class Downloader : public QObject { class Downloader : public QObject {
Q_OBJECT Q_OBJECT
public: public:
explicit Downloader(QUrl imageUrl, QObject *parent = 0); explicit Downloader(QUrl fileURL, QObject *parent = 0);
QByteArray downloadedData() const; QByteArray downloadedData() const;

View file

@ -238,7 +238,7 @@ void Test::startTestsEvaluation(const QString& testFolder, const QString& branch
} }
} }
autoTester->downloadImages(expectedImagesURLs, _snapshotDirectory, _expectedImagesFilenames); autoTester->downloadFiles(expectedImagesURLs, _snapshotDirectory, _expectedImagesFilenames);
} }
void Test::finishTestsEvaluation(bool isRunningFromCommandline, bool interactiveMode, QProgressBar* progressBar) { void Test::finishTestsEvaluation(bool isRunningFromCommandline, bool interactiveMode, QProgressBar* progressBar) {
@ -314,7 +314,7 @@ void Test::createTests() {
_snapshotDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select folder containing the test images", parent, _snapshotDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select folder containing the test images", parent,
QFileDialog::ShowDirsOnly); QFileDialog::ShowDirsOnly);
// If user cancelled then restore previous selection and return // If user canceled then restore previous selection and return
if (_snapshotDirectory == "") { if (_snapshotDirectory == "") {
_snapshotDirectory = previousSelection; _snapshotDirectory = previousSelection;
return; return;
@ -329,7 +329,7 @@ void Test::createTests() {
_testsRootDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select test root folder", parent, _testsRootDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select test root folder", parent,
QFileDialog::ShowDirsOnly); QFileDialog::ShowDirsOnly);
// If user cancelled then restore previous selection and return // If user canceled then restore previous selection and return
if (_testsRootDirectory == "") { if (_testsRootDirectory == "") {
_testsRootDirectory = previousSelection; _testsRootDirectory = previousSelection;
return; return;
@ -456,7 +456,7 @@ bool Test::createFileSetup() {
_testDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select folder containing the test", parent, _testDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select folder containing the test", parent,
QFileDialog::ShowDirsOnly); QFileDialog::ShowDirsOnly);
// If user cancelled then restore previous selection and return // If user canceled then restore previous selection and return
if (_testDirectory == "") { if (_testDirectory == "") {
_testDirectory = previousSelection; _testDirectory = previousSelection;
return false; return false;
@ -798,7 +798,7 @@ void Test::createTestsOutline() {
_testDirectory = _testDirectory =
QFileDialog::getExistingDirectory(nullptr, "Please select the tests root folder", parent, QFileDialog::ShowDirsOnly); QFileDialog::getExistingDirectory(nullptr, "Please select the tests root folder", parent, QFileDialog::ShowDirsOnly);
// If user cancelled then restore previous selection and return // If user canceled then restore previous selection and return
if (_testDirectory == "") { if (_testDirectory == "") {
_testDirectory = previousSelection; _testDirectory = previousSelection;
return; return;
@ -920,10 +920,6 @@ void Test::createTestRailRun() {
_testRailInterface.createTestRailRun(outputDirectory); _testRailInterface.createTestRailRun(outputDirectory);
} }
void Test::runNow() {
testRunner.run();
}
void Test::updateTestRailRunResult() { void Test::updateTestRailRunResult() {
QString testResults = QFileDialog::getOpenFileName(nullptr, "Please select the zipped test results to update from", nullptr, QString testResults = QFileDialog::getOpenFileName(nullptr, "Please select the zipped test results to update from", nullptr,
"Zipped Test Results (*.zip)"); "Zipped Test Results (*.zip)");

View file

@ -19,7 +19,6 @@
#include "ImageComparer.h" #include "ImageComparer.h"
#include "ui/MismatchWindow.h" #include "ui/MismatchWindow.h"
#include "TestRailInterface.h" #include "TestRailInterface.h"
#include "TestRunner.h"
class Step { class Step {
public: public:
@ -65,8 +64,6 @@ public:
void createTestRailTestCases(); void createTestRailTestCases();
void createTestRailRun(); void createTestRailRun();
void runNow();
void updateTestRailRunResult(); void updateTestRailRunResult();
void createRecursiveScript(); void createRecursiveScript();
@ -108,8 +105,6 @@ private:
ImageComparer _imageComparer; ImageComparer _imageComparer;
TestRunner testRunner;
QString _testResultsFolderPath; QString _testResultsFolderPath;
int _index { 1 }; int _index { 1 };

View file

@ -1,5 +1,5 @@
// //
// Downloader.cpp // TestRunner.cpp
// //
// Created by Nissim Hadar on 1 Sep 2018. // Created by Nissim Hadar on 1 Sep 2018.
// Copyright 2013 High Fidelity, Inc. // Copyright 2013 High Fidelity, Inc.
@ -10,14 +10,26 @@
#include "TestRunner.h" #include "TestRunner.h"
#include <QtWidgets/QMessageBox> #include <QtWidgets/QMessageBox>
#include <QtWidgets/QFileDialog>
#include "ui/AutoTester.h"
extern AutoTester* autoTester;
TestRunner::TestRunner(QObject *parent) : QObject(parent) { TestRunner::TestRunner(QObject *parent) : QObject(parent) {
} }
void TestRunner::run() { void TestRunner::run() {
saveExistingHighFidelityAppDataFolder(); saveExistingHighFidelityAppDataFolder();
selectTemporaryFolder();
QStringList urls;
urls << "http://builds.highfidelity.com/HighFidelity-Beta-latest-dev.exe";
QStringList filenames;
filenames << "HighFidelity-Beta-latest-dev.exe";
autoTester->downloadFiles(urls, _tempDirectory, filenames);
////////////////////////////////////////////////////////////////////////////////
restoreHighFidelityAppDataFolder(); restoreHighFidelityAppDataFolder();
} }
@ -48,4 +60,21 @@ void TestRunner::restoreHighFidelityAppDataFolder() {
QDir().rmdir(appDataFolder.path()); QDir().rmdir(appDataFolder.path());
appDataFolder.rename(QDir::fromNativeSeparators(savedAppDataFolder.path()), QDir::toNativeSeparators(appDataFolder.path())); appDataFolder.rename(QDir::fromNativeSeparators(savedAppDataFolder.path()), QDir::toNativeSeparators(appDataFolder.path()));
}
void TestRunner::selectTemporaryFolder() {
QString previousSelection = _tempDirectory;
QString parent = previousSelection.left(previousSelection.lastIndexOf('/'));
if (!parent.isNull() && parent.right(1) != "/") {
parent += "/";
}
_tempDirectory =
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;
return;
}
} }

View file

@ -12,7 +12,9 @@
#define hifi_testRunner_h #define hifi_testRunner_h
#include <QObject> #include <QObject>
#include <QDirIterator> #include <QDir>
#include "Downloader.h"
class TestRunner : public QObject { class TestRunner : public QObject {
Q_OBJECT Q_OBJECT
@ -23,10 +25,15 @@ public:
void saveExistingHighFidelityAppDataFolder(); void saveExistingHighFidelityAppDataFolder();
void restoreHighFidelityAppDataFolder(); void restoreHighFidelityAppDataFolder();
void selectTemporaryFolder();
private: private:
QDir appDataFolder; QDir appDataFolder;
QDir savedAppDataFolder; QDir savedAppDataFolder;
QString _tempDirectory;
Downloader* _downloader;
}; };
#endif // hifi_testRunner_h #endif // hifi_testRunner_h

View file

@ -32,7 +32,7 @@ AutoTester::AutoTester(QWidget* parent) : QMainWindow(parent) {
_ui.tabWidget->setTabEnabled(3, false); _ui.tabWidget->setTabEnabled(3, false);
#endif #endif
// helpWindow.textBrowser->setText() // _helpWindow.textBrowser->setText()
} }
void AutoTester::setup() { void AutoTester::setup() {
@ -99,7 +99,7 @@ void AutoTester::on_createTestRailRunButton_clicked() {
} }
void AutoTester::on_runNowButton_clicked() { void AutoTester::on_runNowButton_clicked() {
_test->runNow(); _testRunner.run();
} }
void AutoTester::on_updateTestRailRunResultsButton_clicked() { void AutoTester::on_updateTestRailRunResultsButton_clicked() {
@ -142,7 +142,7 @@ void AutoTester::on_createXMLScriptRadioButton_clicked() {
_test->setTestRailCreateMode(XML); _test->setTestRailCreateMode(XML);
} }
void AutoTester::downloadImage(const QUrl& url) { void AutoTester::downloadFile(const QUrl& url) {
_downloaders.emplace_back(new Downloader(url, this)); _downloaders.emplace_back(new Downloader(url, this));
connect(_downloaders[_index], SIGNAL(downloaded()), _signalMapper, SLOT(map())); connect(_downloaders[_index], SIGNAL(downloaded()), _signalMapper, SLOT(map()));
@ -151,47 +151,46 @@ void AutoTester::downloadImage(const QUrl& url) {
++_index; ++_index;
} }
void AutoTester::downloadImages(const QStringList& URLs, const QString& directoryName, const QStringList& filenames) { void AutoTester::downloadFiles(const QStringList& URLs, const QString& directoryName, const QStringList& filenames) {
_directoryName = directoryName; _directoryName = directoryName;
_filenames = filenames; _filenames = filenames;
_numberOfImagesToDownload = URLs.size(); _numberOfFilesToDownload = URLs.size();
_numberOfImagesDownloaded = 0; _numberOfFilesDownloaded = 0;
_index = 0; _index = 0;
_ui.progressBar->setMinimum(0); _ui.progressBar->setMinimum(0);
_ui.progressBar->setMaximum(_numberOfImagesToDownload - 1); _ui.progressBar->setMaximum(_numberOfFilesToDownload - 1);
_ui.progressBar->setValue(0); _ui.progressBar->setValue(0);
_ui.progressBar->setVisible(true); _ui.progressBar->setVisible(true);
_downloaders.clear(); _downloaders.clear();
for (int i = 0; i < _numberOfImagesToDownload; ++i) { for (int i = 0; i < _numberOfFilesToDownload; ++i) {
QUrl imageURL(URLs[i]); downloadFile(URLs[i]);
downloadImage(imageURL);
} }
connect(_signalMapper, SIGNAL(mapped(int)), this, SLOT(saveImage(int))); connect(_signalMapper, SIGNAL(mapped(int)), this, SLOT(saveFile(int)));
} }
void AutoTester::saveImage(int index) { void AutoTester::saveFile(int index) {
try { try {
QFile file(_directoryName + "/" + _filenames[index]); QFile file(_directoryName + "/" + _filenames[index]);
file.open(QIODevice::WriteOnly); file.open(QIODevice::WriteOnly);
file.write(_downloaders[index]->downloadedData()); file.write(_downloaders[index]->downloadedData());
file.close(); file.close();
} catch (...) { } catch (...) {
QMessageBox::information(0, "Test Aborted", "Failed to save image: " + _filenames[index]); QMessageBox::information(0, "Test Aborted", "Failed to save file: " + _filenames[index]);
_ui.progressBar->setVisible(false); _ui.progressBar->setVisible(false);
return; return;
} }
++_numberOfImagesDownloaded; ++_numberOfFilesDownloaded;
if (_numberOfImagesDownloaded == _numberOfImagesToDownload) { if (_numberOfFilesDownloaded == _numberOfFilesToDownload) {
disconnect(_signalMapper, SIGNAL(mapped(int)), this, SLOT(saveImage(int))); disconnect(_signalMapper, SIGNAL(mapped(int)), this, SLOT(saveFile(int)));
_test->finishTestsEvaluation(_isRunningFromCommandline, _ui.checkBoxInteractiveMode->isChecked(), _ui.progressBar); _test->finishTestsEvaluation(_isRunningFromCommandline, _ui.checkBoxInteractiveMode->isChecked(), _ui.progressBar);
} else { } else {
_ui.progressBar->setValue(_numberOfImagesDownloaded); _ui.progressBar->setValue(_numberOfFilesDownloaded);
} }
} }
@ -200,7 +199,7 @@ void AutoTester::about() {
} }
void AutoTester::content() { void AutoTester::content() {
helpWindow.show(); _helpWindow.show();
} }
void AutoTester::setUserText(const QString& user) { void AutoTester::setUserText(const QString& user) {

View file

@ -19,6 +19,8 @@
#include "../Test.h" #include "../Test.h"
#include "HelpWindow.h" #include "HelpWindow.h"
#include "../TestRunner.h"
class AutoTester : public QMainWindow { class AutoTester : public QMainWindow {
Q_OBJECT Q_OBJECT
@ -30,8 +32,8 @@ public:
void runFromCommandLine(const QString& testFolder, const QString& branch, const QString& user); void runFromCommandLine(const QString& testFolder, const QString& branch, const QString& user);
void downloadImage(const QUrl& url); void downloadFile(const QUrl& url);
void downloadImages(const QStringList& URLs, const QString& directoryName, const QStringList& filenames); void downloadFiles(const QStringList& URLs, const QString& directoryName, const QStringList& filenames);
void setUserText(const QString& user); void setUserText(const QString& user);
QString getSelectedUser(); QString getSelectedUser();
@ -70,7 +72,7 @@ private slots:
void on_closeButton_clicked(); void on_closeButton_clicked();
void saveImage(int index); void saveFile(int index);
void about(); void about();
void content(); void content();
@ -88,13 +90,15 @@ private:
// Used to enable passing a parameter to slots // Used to enable passing a parameter to slots
QSignalMapper* _signalMapper; QSignalMapper* _signalMapper;
int _numberOfImagesToDownload { 0 }; int _numberOfFilesToDownload { 0 };
int _numberOfImagesDownloaded { 0 }; int _numberOfFilesDownloaded { 0 };
int _index { 0 }; int _index { 0 };
bool _isRunningFromCommandline { false }; bool _isRunningFromCommandline { false };
HelpWindow helpWindow; HelpWindow _helpWindow;
TestRunner _testRunner;
}; };
#endif // hifi_AutoTester_h #endif // hifi_AutoTester_h

View file

@ -23,7 +23,7 @@
<widget class="QPushButton" name="closeButton"> <widget class="QPushButton" name="closeButton">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>235</x> <x>430</x>
<y>620</y> <y>620</y>
<width>100</width> <width>100</width>
<height>40</height> <height>40</height>
@ -43,7 +43,7 @@
</rect> </rect>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>2</number>
</property> </property>
<widget class="QWidget" name="tab_1"> <widget class="QWidget" name="tab_1">
<attribute name="title"> <attribute name="title">
@ -176,25 +176,12 @@
<attribute name="title"> <attribute name="title">
<string>Evaluate</string> <string>Evaluate</string>
</attribute> </attribute>
<widget class="QProgressBar" name="progressBar">
<property name="geometry">
<rect>
<x>150</x>
<y>230</y>
<width>255</width>
<height>23</height>
</rect>
</property>
<property name="value">
<number>24</number>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxInteractiveMode"> <widget class="QCheckBox" name="checkBoxInteractiveMode">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>150</x> <x>130</x>
<y>180</y> <y>180</y>
<width>131</width> <width>120</width>
<height>20</height> <height>20</height>
</rect> </rect>
</property> </property>
@ -327,9 +314,9 @@
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>160</x> <x>120</x>
<y>80</y> <y>80</y>
<width>81</width> <width>110</width>
<height>16</height> <height>16</height>
</rect> </rect>
</property> </property>
@ -365,9 +352,9 @@
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_4">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>160</x> <x>120</x>
<y>40</y> <y>40</y>
<width>81</width> <width>110</width>
<height>16</height> <height>16</height>
</rect> </rect>
</property> </property>
@ -380,6 +367,19 @@
<string>GitHub User</string> <string>GitHub User</string>
</property> </property>
</widget> </widget>
<widget class="QProgressBar" name="progressBar">
<property name="geometry">
<rect>
<x>80</x>
<y>630</y>
<width>255</width>
<height>23</height>
</rect>
</property>
<property name="value">
<number>24</number>
</property>
</widget>
</widget> </widget>
<widget class="QMenuBar" name="menuBar"> <widget class="QMenuBar" name="menuBar">
<property name="geometry"> <property name="geometry">
@ -387,7 +387,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>582</width> <width>582</width>
<height>21</height> <height>26</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">