Can download Build XML in Test on Mobile mode.

This commit is contained in:
NissimHadar 2019-01-24 17:55:00 -08:00
parent f949b9d5b4
commit 50e7adf32c
7 changed files with 70 additions and 24 deletions

View file

@ -88,12 +88,28 @@ void Nitpick::setup() {
if (_testRunnerDesktop) {
delete _testRunnerDesktop;
}
_testRunnerDesktop = new TestRunnerDesktop(dayCheckboxes, timeEditCheckboxes, timeEdits, _ui.workingFolderRunOnDesktopLabel, _ui.checkBoxServerless, _ui.runLatestOnDesktopCheckBox, _ui.urlOnDesktopLineEdit, _ui.runNowPushbutton);
_testRunnerDesktop = new TestRunnerDesktop(
dayCheckboxes,
timeEditCheckboxes,
timeEdits,
_ui.workingFolderRunOnDesktopLabel,
_ui.checkBoxServerless,
_ui.runLatestOnDesktopCheckBox,
_ui.urlOnDesktopLineEdit,
_ui.runNowPushbutton
);
if (_testRunnerMobile) {
delete _testRunnerMobile;
}
_testRunnerMobile = new TestRunnerMobile(_ui.workingFolderRunOnMobileLabel, _ui.connectDevicePushbutton, _ui.pullFolderPushbutton, _ui.detectedDeviceLabel, _ui.folderLineEdit);
_testRunnerMobile = new TestRunnerMobile(
_ui.workingFolderRunOnMobileLabel,
_ui.connectDevicePushbutton,
_ui.pullFolderPushbutton,
_ui.detectedDeviceLabel,
_ui.folderLineEdit,
_ui.downloadAPKPushbutton
);
}
void Nitpick::startTestsEvaluation(const bool isRunningFromCommandLine,
@ -285,7 +301,11 @@ void Nitpick::saveFile(int index) {
_test->finishTestsEvaluation();
} else if (_caller == _testRunnerDesktop) {
_testRunnerDesktop->downloadComplete();
} else if (_caller == _testRunnerMobile) {
_testRunnerMobile->downloadComplete();
}
_ui.progressBar->setVisible(false);
} else {
_ui.progressBar->setValue(_numberOfFilesDownloaded);
}

View file

@ -11,6 +11,9 @@
#include <QFileDialog>
#include "Nitpick.h"
extern Nitpick* nitpick;
void TestRunner::setWorkingFolder(QLabel* workingFolderLabel) {
// Everything will be written to this folder
QString previousSelection = _workingFolder;
@ -31,6 +34,21 @@ void TestRunner::setWorkingFolder(QLabel* workingFolderLabel) {
workingFolderLabel->setText(QDir::toNativeSeparators(_workingFolder));
}
void TestRunner::downloadBuildXml(void* caller) {
// Download the latest High Fidelity build XML.
// Note that this is not needed for PR builds (or whenever `Run Latest` is unchecked)
// It is still downloaded, to simplify the flow
buildXMLDownloaded = false;
QStringList urls;
QStringList filenames;
urls << DEV_BUILD_XML_URL;
filenames << DEV_BUILD_XML_FILENAME;
nitpick->downloadFiles(urls, _workingFolder, filenames, caller);
}
void Worker::setCommandLine(const QString& commandLine) {
_commandLine = commandLine;
}

View file

@ -19,9 +19,15 @@ class Worker;
class TestRunner {
public:
void setWorkingFolder(QLabel* workingFolderLabel);
void downloadBuildXml(void* caller);
protected:
QString _workingFolder;
const QString DEV_BUILD_XML_URL{ "https://highfidelity.com/dev-builds.xml" };
const QString DEV_BUILD_XML_FILENAME{ "dev-builds.xml" };
bool buildXMLDownloaded;
};
class Worker : public QObject {

View file

@ -13,14 +13,14 @@
#include <QtWidgets/QMessageBox>
#include <QtWidgets/QFileDialog>
#include "Nitpick.h"
extern Nitpick* nitpick;
#ifdef Q_OS_WIN
#include <windows.h>
#include <tlhelp32.h>
#endif
#include "Nitpick.h"
extern Nitpick* nitpick;
TestRunnerDesktop::TestRunnerDesktop(std::vector<QCheckBox*> dayCheckboxes,
std::vector<QCheckBox*> timeEditCheckboxes,
std::vector<QTimeEdit*> timeEdits,
@ -176,19 +176,8 @@ void TestRunnerDesktop::run() {
// This will be restored at the end of the tests
saveExistingHighFidelityAppDataFolder();
// Download the latest High Fidelity build XML.
// Note that this is not needed for PR builds (or whenever `Run Latest` is unchecked)
// It is still downloaded, to simplify the flow
QStringList urls;
QStringList filenames;
urls << DEV_BUILD_XML_URL;
filenames << DEV_BUILD_XML_FILENAME;
updateStatusLabel("Downloading Build XML");
buildXMLDownloaded = false;
nitpick->downloadFiles(urls, _workingFolder, filenames, (void*)this);
downloadBuildXml((void*)this);
// `downloadComplete` will run after download has completed
}

View file

@ -102,10 +102,6 @@ private:
QString _installerURL;
QString _installerFilename;
const QString DEV_BUILD_XML_URL{ "https://highfidelity.com/dev-builds.xml" };
const QString DEV_BUILD_XML_FILENAME{ "dev-builds.xml" };
bool buildXMLDownloaded;
QDir _appDataFolder;
QDir _savedAppDataFolder;

View file

@ -22,6 +22,7 @@ TestRunnerMobile::TestRunnerMobile(
QPushButton *pullFolderButton,
QLabel* detectedDeviceLabel,
QLineEdit *folderLineEdit,
QPushButton* downloadAPKPushbutton,
QObject* parent
) : QObject(parent)
{
@ -30,6 +31,7 @@ TestRunnerMobile::TestRunnerMobile(
_pullFolderButton = pullFolderButton;
_detectedDeviceLabel = detectedDeviceLabel;
_folderLineEdit = folderLineEdit;
_downloadAPKPushbutton = downloadAPKPushbutton;
folderLineEdit->setText("/sdcard/DCIM/TEST");
}
@ -41,6 +43,7 @@ void TestRunnerMobile::setWorkingFolderAndEnableControls() {
setWorkingFolder(_workingFolderLabel);
_connectDeviceButton->setEnabled(true);
_downloadAPKPushbutton->setEnabled(true);
// Find ADB (Android Debugging Bridge) before continuing
#ifdef Q_OS_WIN
@ -70,7 +73,7 @@ void TestRunnerMobile::setWorkingFolderAndEnableControls() {
void TestRunnerMobile::connectDevice() {
QString devicesFullFilename{ _workingFolder + "/devices.txt" };
QString command = _adbCommand + " devices > " + devicesFullFilename;
int result = system(command.toStdString().c_str());
system(command.toStdString().c_str());
if (!QFile::exists(devicesFullFilename)) {
QMessageBox::critical(0, "Internal error", "devicesFullFilename not found");
@ -99,9 +102,20 @@ void TestRunnerMobile::connectDevice() {
}
void TestRunnerMobile::downloadAPK() {
downloadBuildXml((void*)this);
}
void TestRunnerMobile::downloadComplete() {
if (!buildXMLDownloaded) {
// Download of Build XML has completed
buildXMLDownloaded = true;
// Download the High Fidelity APK
int df = 546;
}
}
void TestRunnerMobile::pullFolder() {
QString command = _adbCommand + " pull " + _folderLineEdit->text() + " " + _workingFolder + " >" + _workingFolder + "/pullOutput.txt";
int result = system(command.toStdString().c_str());
system(command.toStdString().c_str());
}

View file

@ -26,7 +26,8 @@ public:
QPushButton *connectDeviceButton,
QPushButton *pullFolderButton,
QLabel* detectedDeviceLabel,
QLineEdit *folderLineEdit,
QLineEdit* folderLineEdit,
QPushButton* downloadAPKPushbutton,
QObject* parent = 0
);
~TestRunnerMobile();
@ -34,6 +35,7 @@ public:
void setWorkingFolderAndEnableControls();
void connectDevice();
void downloadAPK();
void downloadComplete();
void pullFolder();
private:
@ -42,6 +44,7 @@ private:
QPushButton* _pullFolderButton;
QLabel* _detectedDeviceLabel;
QLineEdit* _folderLineEdit;
QPushButton* _downloadAPKPushbutton;
#ifdef Q_OS_WIN
const QString _adbExe{ "adb.exe" };