Added common class to simplify code.

This commit is contained in:
NissimHadar 2019-01-23 09:15:27 -08:00
parent 089c71b047
commit b7a0fae00e
7 changed files with 70 additions and 41 deletions

View file

@ -165,7 +165,7 @@ void Nitpick::on_createTestRailRunButton_clicked() {
} }
void Nitpick::on_setWorkingFolderRunOnDesktopButton_clicked() { void Nitpick::on_setWorkingFolderRunOnDesktopButton_clicked() {
_testRunnerDesktop->setWorkingFolder(); _testRunnerDesktop->setWorkingFolderAndEnableControls();
} }
void Nitpick::enableRunTabControls() { void Nitpick::enableRunTabControls() {
@ -324,7 +324,7 @@ void Nitpick::appendLogWindow(const QString& message) {
} }
void Nitpick::on_setWorkingFolderRunOnMobileButton_clicked() { void Nitpick::on_setWorkingFolderRunOnMobileButton_clicked() {
_testRunnerMobile->setWorkingFolder(); _testRunnerMobile->setWorkingFolderAndEnableControls();
} }
void Nitpick::on_readDeviceButton_clicked() { void Nitpick::on_readDeviceButton_clicked() {

View file

@ -0,0 +1,32 @@
//
// TestRunner.cpp
//
// Created by Nissim Hadar on 23 Jan 2019.
// 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 <QFileDialog>
void TestRunner::setWorkingFolder(QLabel* workingFolderLabel) {
// Everything will be written to this folder
QString previousSelection = _workingFolder;
QString parent = previousSelection.left(previousSelection.lastIndexOf('/'));
if (!parent.isNull() && parent.right(1) != "/") {
parent += "/";
}
_workingFolder = QFileDialog::getExistingDirectory(nullptr, "Please select a working folder for temporary files", parent,
QFileDialog::ShowDirsOnly);
// If user canceled then restore previous selection and return
if (_workingFolder == "") {
_workingFolder = previousSelection;
return;
}
workingFolderLabel->setText(QDir::toNativeSeparators(_workingFolder));
}

View file

@ -0,0 +1,23 @@
//
// TestRunner.h
//
// Created by Nissim Hadar on 23 Jan 2019.
// 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 <QLabel>
class TestRunner {
public:
void setWorkingFolder(QLabel* workingFolderLabel);
private:
QString _workingFolder;
};
#endif

View file

@ -69,22 +69,8 @@ TestRunnerDesktop::~TestRunnerDesktop() {
} }
} }
void TestRunnerDesktop::setWorkingFolder() { void TestRunnerDesktop::setWorkingFolderAndEnableControls() {
// Everything will be written to this folder setWorkingFolder(_workingFolderLabel);
QString previousSelection = _workingFolder;
QString parent = previousSelection.left(previousSelection.lastIndexOf('/'));
if (!parent.isNull() && parent.right(1) != "/") {
parent += "/";
}
_workingFolder = QFileDialog::getExistingDirectory(nullptr, "Please select a temporary folder for installation", parent,
QFileDialog::ShowDirsOnly);
// If user canceled then restore previous selection and return
if (_workingFolder == "") {
_workingFolder = previousSelection;
return;
}
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
_installationFolder = _workingFolder + "/High Fidelity"; _installationFolder = _workingFolder + "/High Fidelity";
@ -95,7 +81,6 @@ void TestRunnerDesktop::setWorkingFolder() {
_logFile.setFileName(_workingFolder + "/log.txt"); _logFile.setFileName(_workingFolder + "/log.txt");
nitpick->enableRunTabControls(); nitpick->enableRunTabControls();
_workingFolderLabel->setText(QDir::toNativeSeparators(_workingFolder));
_timer = new QTimer(this); _timer = new QTimer(this);
connect(_timer, SIGNAL(timeout()), this, SLOT(checkTime())); connect(_timer, SIGNAL(timeout()), this, SLOT(checkTime()));

View file

@ -21,6 +21,8 @@
#include <QTimeEdit> #include <QTimeEdit>
#include <QTimer> #include <QTimer>
#include "TestRunner.h"
class BuildInformation { class BuildInformation {
public: public:
QString build; QString build;
@ -29,7 +31,7 @@ public:
class Worker; class Worker;
class TestRunnerDesktop : public QObject { class TestRunnerDesktop : public QObject, public TestRunner {
Q_OBJECT Q_OBJECT
public: public:
explicit TestRunnerDesktop(std::vector<QCheckBox*> dayCheckboxes, explicit TestRunnerDesktop(std::vector<QCheckBox*> dayCheckboxes,
@ -44,7 +46,7 @@ public:
~TestRunnerDesktop(); ~TestRunnerDesktop();
void setWorkingFolder(); void setWorkingFolderAndEnableControls();
void run(); void run();

View file

@ -24,24 +24,8 @@ TestRunnerMobile::TestRunnerMobile(QLabel* workingFolderLabel, QPushButton *read
TestRunnerMobile::~TestRunnerMobile() { TestRunnerMobile::~TestRunnerMobile() {
} }
void TestRunnerMobile::setWorkingFolder() { void TestRunnerMobile::setWorkingFolderAndEnableControls() {
// Everything will be written to this folder setWorkingFolder(_workingFolderLabel);
QString previousSelection = _workingFolder;
QString parent = previousSelection.left(previousSelection.lastIndexOf('/'));
if (!parent.isNull() && parent.right(1) != "/") {
parent += "/";
}
_workingFolder = QFileDialog::getExistingDirectory(nullptr, "Please select a working folder for temporary files", parent,
QFileDialog::ShowDirsOnly);
// If user canceled then restore previous selection and return
if (_workingFolder == "") {
_workingFolder = previousSelection;
return;
}
_workingFolderLabel->setText(QDir::toNativeSeparators(_workingFolder));
_readDeviceButton->setEnabled(true); _readDeviceButton->setEnabled(true);
} }

View file

@ -10,17 +10,20 @@
#ifndef hifi_testRunnerMobile_h #ifndef hifi_testRunnerMobile_h
#define hifi_testRunnerMobile_h #define hifi_testRunnerMobile_h
#include <QLabel> #include <QLabel>
#include <QObject> #include <QObject>
#include <QPushButton> #include <QPushButton>
class TestRunnerMobile : public QObject { #include "TestRunner.h"
class TestRunnerMobile : public QObject, public TestRunner {
Q_OBJECT Q_OBJECT
public: public:
explicit TestRunnerMobile(QLabel* workingFolderLabel, QPushButton *readDeviceButton, QObject* parent = 0); explicit TestRunnerMobile(QLabel* workingFolderLabel, QPushButton *readDeviceButton, QObject* parent = 0);
~TestRunnerMobile(); ~TestRunnerMobile();
void setWorkingFolder(); void setWorkingFolderAndEnableControls();
void readDevice(); void readDevice();
private: private: