From 1ffd005b7705a0e0be54f0f2cd4c7df09663c2c4 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Sat, 1 Sep 2018 22:46:49 -0700 Subject: [PATCH] Can download the High Fidelity installer. --- tools/auto-tester/src/Downloader.cpp | 6 ++-- tools/auto-tester/src/Downloader.h | 2 +- tools/auto-tester/src/Test.cpp | 14 +++----- tools/auto-tester/src/Test.h | 5 --- tools/auto-tester/src/TestRunner.cpp | 33 +++++++++++++++++-- tools/auto-tester/src/TestRunner.h | 9 ++++- tools/auto-tester/src/ui/AutoTester.cpp | 35 ++++++++++---------- tools/auto-tester/src/ui/AutoTester.h | 16 +++++---- tools/auto-tester/src/ui/AutoTester.ui | 44 ++++++++++++------------- 9 files changed, 97 insertions(+), 67 deletions(-) diff --git a/tools/auto-tester/src/Downloader.cpp b/tools/auto-tester/src/Downloader.cpp index 530a3b61bd..cb9863f34d 100644 --- a/tools/auto-tester/src/Downloader.cpp +++ b/tools/auto-tester/src/Downloader.cpp @@ -11,20 +11,20 @@ #include -Downloader::Downloader(QUrl imageUrl, QObject *parent) : QObject(parent) { +Downloader::Downloader(QUrl fileURL, QObject *parent) : QObject(parent) { connect( &_networkAccessManager, SIGNAL (finished(QNetworkReply*)), this, SLOT (fileDownloaded(QNetworkReply*)) ); - QNetworkRequest request(imageUrl); + QNetworkRequest request(fileURL); _networkAccessManager.get(request); } void Downloader::fileDownloaded(QNetworkReply* reply) { QNetworkReply::NetworkError error = reply->error(); 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; } diff --git a/tools/auto-tester/src/Downloader.h b/tools/auto-tester/src/Downloader.h index b0ad58fac5..6d1029698f 100644 --- a/tools/auto-tester/src/Downloader.h +++ b/tools/auto-tester/src/Downloader.h @@ -30,7 +30,7 @@ class Downloader : public QObject { Q_OBJECT public: - explicit Downloader(QUrl imageUrl, QObject *parent = 0); + explicit Downloader(QUrl fileURL, QObject *parent = 0); QByteArray downloadedData() const; diff --git a/tools/auto-tester/src/Test.cpp b/tools/auto-tester/src/Test.cpp index 16f06e20e7..c81ddc591f 100644 --- a/tools/auto-tester/src/Test.cpp +++ b/tools/auto-tester/src/Test.cpp @@ -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) { @@ -314,7 +314,7 @@ void Test::createTests() { _snapshotDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select folder containing the test images", parent, QFileDialog::ShowDirsOnly); - // If user cancelled then restore previous selection and return + // If user canceled then restore previous selection and return if (_snapshotDirectory == "") { _snapshotDirectory = previousSelection; return; @@ -329,7 +329,7 @@ void Test::createTests() { _testsRootDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select test root folder", parent, QFileDialog::ShowDirsOnly); - // If user cancelled then restore previous selection and return + // If user canceled then restore previous selection and return if (_testsRootDirectory == "") { _testsRootDirectory = previousSelection; return; @@ -456,7 +456,7 @@ bool Test::createFileSetup() { _testDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select folder containing the test", parent, QFileDialog::ShowDirsOnly); - // If user cancelled then restore previous selection and return + // If user canceled then restore previous selection and return if (_testDirectory == "") { _testDirectory = previousSelection; return false; @@ -798,7 +798,7 @@ void Test::createTestsOutline() { _testDirectory = 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 == "") { _testDirectory = previousSelection; return; @@ -920,10 +920,6 @@ void Test::createTestRailRun() { _testRailInterface.createTestRailRun(outputDirectory); } -void Test::runNow() { - testRunner.run(); -} - void Test::updateTestRailRunResult() { QString testResults = QFileDialog::getOpenFileName(nullptr, "Please select the zipped test results to update from", nullptr, "Zipped Test Results (*.zip)"); diff --git a/tools/auto-tester/src/Test.h b/tools/auto-tester/src/Test.h index f4e7c21408..ce4129ed1c 100644 --- a/tools/auto-tester/src/Test.h +++ b/tools/auto-tester/src/Test.h @@ -19,7 +19,6 @@ #include "ImageComparer.h" #include "ui/MismatchWindow.h" #include "TestRailInterface.h" -#include "TestRunner.h" class Step { public: @@ -65,8 +64,6 @@ public: void createTestRailTestCases(); void createTestRailRun(); - void runNow(); - void updateTestRailRunResult(); void createRecursiveScript(); @@ -108,8 +105,6 @@ private: ImageComparer _imageComparer; - TestRunner testRunner; - QString _testResultsFolderPath; int _index { 1 }; diff --git a/tools/auto-tester/src/TestRunner.cpp b/tools/auto-tester/src/TestRunner.cpp index c1df09762b..1c700c987f 100644 --- a/tools/auto-tester/src/TestRunner.cpp +++ b/tools/auto-tester/src/TestRunner.cpp @@ -1,5 +1,5 @@ // -// Downloader.cpp +// TestRunner.cpp // // Created by Nissim Hadar on 1 Sep 2018. // Copyright 2013 High Fidelity, Inc. @@ -10,14 +10,26 @@ #include "TestRunner.h" #include +#include + +#include "ui/AutoTester.h" +extern AutoTester* autoTester; TestRunner::TestRunner(QObject *parent) : QObject(parent) { } void TestRunner::run() { 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(); } @@ -48,4 +60,21 @@ void TestRunner::restoreHighFidelityAppDataFolder() { QDir().rmdir(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; + } } \ No newline at end of file diff --git a/tools/auto-tester/src/TestRunner.h b/tools/auto-tester/src/TestRunner.h index 1109ef32ce..17fbbaf24d 100644 --- a/tools/auto-tester/src/TestRunner.h +++ b/tools/auto-tester/src/TestRunner.h @@ -12,7 +12,9 @@ #define hifi_testRunner_h #include -#include +#include + +#include "Downloader.h" class TestRunner : public QObject { Q_OBJECT @@ -23,10 +25,15 @@ public: void saveExistingHighFidelityAppDataFolder(); void restoreHighFidelityAppDataFolder(); + void selectTemporaryFolder(); private: QDir appDataFolder; QDir savedAppDataFolder; + + QString _tempDirectory; + + Downloader* _downloader; }; #endif // hifi_testRunner_h \ No newline at end of file diff --git a/tools/auto-tester/src/ui/AutoTester.cpp b/tools/auto-tester/src/ui/AutoTester.cpp index f4b7f22bec..bd8a5068e9 100644 --- a/tools/auto-tester/src/ui/AutoTester.cpp +++ b/tools/auto-tester/src/ui/AutoTester.cpp @@ -32,7 +32,7 @@ AutoTester::AutoTester(QWidget* parent) : QMainWindow(parent) { _ui.tabWidget->setTabEnabled(3, false); #endif - // helpWindow.textBrowser->setText() + // _helpWindow.textBrowser->setText() } void AutoTester::setup() { @@ -99,7 +99,7 @@ void AutoTester::on_createTestRailRunButton_clicked() { } void AutoTester::on_runNowButton_clicked() { - _test->runNow(); + _testRunner.run(); } void AutoTester::on_updateTestRailRunResultsButton_clicked() { @@ -142,7 +142,7 @@ void AutoTester::on_createXMLScriptRadioButton_clicked() { _test->setTestRailCreateMode(XML); } -void AutoTester::downloadImage(const QUrl& url) { +void AutoTester::downloadFile(const QUrl& url) { _downloaders.emplace_back(new Downloader(url, this)); connect(_downloaders[_index], SIGNAL(downloaded()), _signalMapper, SLOT(map())); @@ -151,47 +151,46 @@ void AutoTester::downloadImage(const QUrl& url) { ++_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; _filenames = filenames; - _numberOfImagesToDownload = URLs.size(); - _numberOfImagesDownloaded = 0; + _numberOfFilesToDownload = URLs.size(); + _numberOfFilesDownloaded = 0; _index = 0; _ui.progressBar->setMinimum(0); - _ui.progressBar->setMaximum(_numberOfImagesToDownload - 1); + _ui.progressBar->setMaximum(_numberOfFilesToDownload - 1); _ui.progressBar->setValue(0); _ui.progressBar->setVisible(true); _downloaders.clear(); - for (int i = 0; i < _numberOfImagesToDownload; ++i) { - QUrl imageURL(URLs[i]); - downloadImage(imageURL); + for (int i = 0; i < _numberOfFilesToDownload; ++i) { + downloadFile(URLs[i]); } - 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 { QFile file(_directoryName + "/" + _filenames[index]); file.open(QIODevice::WriteOnly); file.write(_downloaders[index]->downloadedData()); file.close(); } 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); return; } - ++_numberOfImagesDownloaded; + ++_numberOfFilesDownloaded; - if (_numberOfImagesDownloaded == _numberOfImagesToDownload) { - disconnect(_signalMapper, SIGNAL(mapped(int)), this, SLOT(saveImage(int))); + if (_numberOfFilesDownloaded == _numberOfFilesToDownload) { + disconnect(_signalMapper, SIGNAL(mapped(int)), this, SLOT(saveFile(int))); _test->finishTestsEvaluation(_isRunningFromCommandline, _ui.checkBoxInteractiveMode->isChecked(), _ui.progressBar); } else { - _ui.progressBar->setValue(_numberOfImagesDownloaded); + _ui.progressBar->setValue(_numberOfFilesDownloaded); } } @@ -200,7 +199,7 @@ void AutoTester::about() { } void AutoTester::content() { - helpWindow.show(); + _helpWindow.show(); } void AutoTester::setUserText(const QString& user) { diff --git a/tools/auto-tester/src/ui/AutoTester.h b/tools/auto-tester/src/ui/AutoTester.h index f0b5a99bf8..d4f4554fea 100644 --- a/tools/auto-tester/src/ui/AutoTester.h +++ b/tools/auto-tester/src/ui/AutoTester.h @@ -19,6 +19,8 @@ #include "../Test.h" #include "HelpWindow.h" +#include "../TestRunner.h" + class AutoTester : public QMainWindow { Q_OBJECT @@ -30,8 +32,8 @@ public: void runFromCommandLine(const QString& testFolder, const QString& branch, const QString& user); - void downloadImage(const QUrl& url); - void downloadImages(const QStringList& URLs, const QString& directoryName, const QStringList& filenames); + void downloadFile(const QUrl& url); + void downloadFiles(const QStringList& URLs, const QString& directoryName, const QStringList& filenames); void setUserText(const QString& user); QString getSelectedUser(); @@ -70,7 +72,7 @@ private slots: void on_closeButton_clicked(); - void saveImage(int index); + void saveFile(int index); void about(); void content(); @@ -88,13 +90,15 @@ private: // Used to enable passing a parameter to slots QSignalMapper* _signalMapper; - int _numberOfImagesToDownload { 0 }; - int _numberOfImagesDownloaded { 0 }; + int _numberOfFilesToDownload { 0 }; + int _numberOfFilesDownloaded { 0 }; int _index { 0 }; bool _isRunningFromCommandline { false }; - HelpWindow helpWindow; + HelpWindow _helpWindow; + + TestRunner _testRunner; }; #endif // hifi_AutoTester_h \ No newline at end of file diff --git a/tools/auto-tester/src/ui/AutoTester.ui b/tools/auto-tester/src/ui/AutoTester.ui index ca14e417c9..0a68a1754d 100644 --- a/tools/auto-tester/src/ui/AutoTester.ui +++ b/tools/auto-tester/src/ui/AutoTester.ui @@ -23,7 +23,7 @@ - 235 + 430 620 100 40 @@ -43,7 +43,7 @@ - 1 + 2 @@ -176,25 +176,12 @@ Evaluate - - - - 150 - 230 - 255 - 23 - - - - 24 - - - 150 + 130 180 - 131 + 120 20 @@ -327,9 +314,9 @@ - 160 + 120 80 - 81 + 110 16 @@ -365,9 +352,9 @@ - 160 + 120 40 - 81 + 110 16 @@ -380,6 +367,19 @@ GitHub User + + + + 80 + 630 + 255 + 23 + + + + 24 + + @@ -387,7 +387,7 @@ 0 0 582 - 21 + 26