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() {
_testRunnerDesktop->setWorkingFolder();
_testRunnerDesktop->setWorkingFolderAndEnableControls();
}
void Nitpick::enableRunTabControls() {
@ -324,7 +324,7 @@ void Nitpick::appendLogWindow(const QString& message) {
}
void Nitpick::on_setWorkingFolderRunOnMobileButton_clicked() {
_testRunnerMobile->setWorkingFolder();
_testRunnerMobile->setWorkingFolderAndEnableControls();
}
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() {
// 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 temporary folder for installation", parent,
QFileDialog::ShowDirsOnly);
// If user canceled then restore previous selection and return
if (_workingFolder == "") {
_workingFolder = previousSelection;
return;
}
void TestRunnerDesktop::setWorkingFolderAndEnableControls() {
setWorkingFolder(_workingFolderLabel);
#ifdef Q_OS_WIN
_installationFolder = _workingFolder + "/High Fidelity";
@ -95,7 +81,6 @@ void TestRunnerDesktop::setWorkingFolder() {
_logFile.setFileName(_workingFolder + "/log.txt");
nitpick->enableRunTabControls();
_workingFolderLabel->setText(QDir::toNativeSeparators(_workingFolder));
_timer = new QTimer(this);
connect(_timer, SIGNAL(timeout()), this, SLOT(checkTime()));

View file

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

View file

@ -24,24 +24,8 @@ TestRunnerMobile::TestRunnerMobile(QLabel* workingFolderLabel, QPushButton *read
TestRunnerMobile::~TestRunnerMobile() {
}
void TestRunnerMobile::setWorkingFolder() {
// 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));
void TestRunnerMobile::setWorkingFolderAndEnableControls() {
setWorkingFolder(_workingFolderLabel);
_readDeviceButton->setEnabled(true);
}

View file

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