Added new class.

This commit is contained in:
NissimHadar 2018-09-01 19:48:43 -07:00
parent 4e677c85f6
commit fb80e9c395
4 changed files with 87 additions and 29 deletions

View file

@ -921,35 +921,7 @@ void Test::createTestRailRun() {
}
void Test::runNow() {
// Rename the existing data directory, and create an empty one
QString dataDirectory{ "NOT FOUND" };
#ifdef Q_OS_WIN
dataDirectory = qgetenv("USERPROFILE") + "\\AppData\\Roaming";
#endif
QDir highfidelityDirectory{ dataDirectory + "\\High Fidelity" };
if (!highfidelityDirectory.exists()) {
QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__),
"The High Fidelity data folder was not found in " + dataDirectory);
exit(-1);
}
// The original folder is saved in a unique name
QDir savedDataFolder{ dataDirectory + "/fgadhcUDHSFaidsfh3478JJJFSDFIUSOEIrf" };
highfidelityDirectory.rename(QDir::fromNativeSeparators(highfidelityDirectory.path()),
QDir::toNativeSeparators(savedDataFolder.path()));
QDir().mkdir(highfidelityDirectory.path());
////////////////////////////////////////////////////////////////////////////////
// Finally - restore the data folder
QDir().rmdir(highfidelityDirectory.path());
highfidelityDirectory.rename(QDir::fromNativeSeparators(savedDataFolder.path()),
QDir::toNativeSeparators(highfidelityDirectory.path()));
testRunner.run();
}
void Test::updateTestRailRunResult() {

View file

@ -19,6 +19,7 @@
#include "ImageComparer.h"
#include "ui/MismatchWindow.h"
#include "TestRailInterface.h"
#include "TestRunner.h"
class Step {
public:
@ -107,6 +108,8 @@ private:
ImageComparer _imageComparer;
TestRunner testRunner;
QString _testResultsFolderPath;
int _index { 1 };

View file

@ -0,0 +1,51 @@
//
// Downloader.cpp
//
// Created by Nissim Hadar on 1 Sep 2018.
// Copyright 2013 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "TestRunner.h"
#include <QtWidgets/QMessageBox>
TestRunner::TestRunner(QObject *parent) : QObject(parent) {
}
void TestRunner::run() {
saveExistingHighFidelityAppDataFolder();
////////////////////////////////////////////////////////////////////////////////
restoreHighFidelityAppDataFolder();
}
void TestRunner::saveExistingHighFidelityAppDataFolder() {
QString dataDirectory{ "NOT FOUND" };
#ifdef Q_OS_WIN
dataDirectory = qgetenv("USERPROFILE") + "\\AppData\\Roaming";
#endif
appDataFolder = dataDirectory + "\\High Fidelity";
if (!appDataFolder.exists()) {
QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__),
"The High Fidelity data folder was not found in " + dataDirectory);
exit(-1);
}
// The original folder is saved in a unique name
savedAppDataFolder = dataDirectory + "/fgadhcUDHSFaidsfh3478JJJFSDFIUSOEIrf";
appDataFolder.rename(QDir::fromNativeSeparators(appDataFolder.path()), QDir::toNativeSeparators(savedAppDataFolder.path()));
QDir().mkdir(appDataFolder.path());
}
void TestRunner::restoreHighFidelityAppDataFolder() {
QDir().rmdir(appDataFolder.path());
appDataFolder.rename(QDir::fromNativeSeparators(savedAppDataFolder.path()), QDir::toNativeSeparators(appDataFolder.path()));
}

View file

@ -0,0 +1,32 @@
//
// Downloader.h
//
// Created by Nissim Hadar on 1 Sep 2018.
// Copyright 2013 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_testRunner_h
#define hifi_testRunner_h
#include <QObject>
#include <QDirIterator>
class TestRunner : public QObject {
Q_OBJECT
public:
explicit TestRunner(QObject *parent = 0);
void run();
void saveExistingHighFidelityAppDataFolder();
void restoreHighFidelityAppDataFolder();
private:
QDir appDataFolder;
QDir savedAppDataFolder;
};
#endif // hifi_testRunner_h