diff --git a/tools/nitpick/src/Nitpick.cpp b/tools/nitpick/src/Nitpick.cpp index d495d19e93..63afbf3947 100644 --- a/tools/nitpick/src/Nitpick.cpp +++ b/tools/nitpick/src/Nitpick.cpp @@ -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() { diff --git a/tools/nitpick/src/TestRunner.cpp b/tools/nitpick/src/TestRunner.cpp new file mode 100644 index 0000000000..1f4b3f847d --- /dev/null +++ b/tools/nitpick/src/TestRunner.cpp @@ -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 + +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)); +} diff --git a/tools/nitpick/src/TestRunner.h b/tools/nitpick/src/TestRunner.h new file mode 100644 index 0000000000..a852aafaa7 --- /dev/null +++ b/tools/nitpick/src/TestRunner.h @@ -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 + +class TestRunner { +public: + void setWorkingFolder(QLabel* workingFolderLabel); + +private: + QString _workingFolder; +}; +#endif diff --git a/tools/nitpick/src/TestRunnerDesktop.cpp b/tools/nitpick/src/TestRunnerDesktop.cpp index 6434690a9f..67a7932fde 100644 --- a/tools/nitpick/src/TestRunnerDesktop.cpp +++ b/tools/nitpick/src/TestRunnerDesktop.cpp @@ -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())); diff --git a/tools/nitpick/src/TestRunnerDesktop.h b/tools/nitpick/src/TestRunnerDesktop.h index 4331e1b82d..5e11c79944 100644 --- a/tools/nitpick/src/TestRunnerDesktop.h +++ b/tools/nitpick/src/TestRunnerDesktop.h @@ -21,6 +21,8 @@ #include #include +#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 dayCheckboxes, @@ -44,7 +46,7 @@ public: ~TestRunnerDesktop(); - void setWorkingFolder(); + void setWorkingFolderAndEnableControls(); void run(); diff --git a/tools/nitpick/src/TestRunnerMobile.cpp b/tools/nitpick/src/TestRunnerMobile.cpp index 3dc55e3a08..66e7ab1c05 100644 --- a/tools/nitpick/src/TestRunnerMobile.cpp +++ b/tools/nitpick/src/TestRunnerMobile.cpp @@ -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); } diff --git a/tools/nitpick/src/TestRunnerMobile.h b/tools/nitpick/src/TestRunnerMobile.h index 3380542461..7279e1276e 100644 --- a/tools/nitpick/src/TestRunnerMobile.h +++ b/tools/nitpick/src/TestRunnerMobile.h @@ -10,17 +10,20 @@ #ifndef hifi_testRunnerMobile_h #define hifi_testRunnerMobile_h + #include #include #include -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: