mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-19 08:18:05 +02:00
WIP.
This commit is contained in:
parent
01610a1520
commit
795423beea
8 changed files with 181 additions and 11 deletions
|
@ -5,7 +5,7 @@ project(${TARGET_NAME})
|
|||
SET (CMAKE_AUTOUIC ON)
|
||||
SET (CMAKE_AUTOMOC ON)
|
||||
|
||||
setup_hifi_project (Core Widgets Network)
|
||||
setup_hifi_project (Core Widgets Network Xml)
|
||||
link_hifi_libraries ()
|
||||
|
||||
# FIX: Qt was built with -reduce-relocations
|
||||
|
@ -18,7 +18,7 @@ include_directories (${CMAKE_CURRENT_SOURCE_DIR})
|
|||
include_directories (${Qt5Core_INCLUDE_DIRS})
|
||||
include_directories (${Qt5Widgets_INCLUDE_DIRS})
|
||||
|
||||
set (QT_LIBRARIES Qt5::Core Qt5::Widgets)
|
||||
set (QT_LIBRARIES Qt5::Core Qt5::Widgets QT::Gui Qt5::Xml)
|
||||
|
||||
if (WIN32)
|
||||
# Do not show Console
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <quazip5/quazip.h>
|
||||
#include <quazip5/JlCompress.h>
|
||||
|
||||
#include "TestSuiteCreator.h"
|
||||
#include "ui/AutoTester.h"
|
||||
extern AutoTester* autoTester;
|
||||
|
||||
|
@ -821,6 +822,26 @@ void Test::createTestsOutline() {
|
|||
QMessageBox::information(0, "Success", "Test outline file " + testsOutlineFilename + " has been created");
|
||||
}
|
||||
|
||||
void Test::createTestRailTestSuite() {
|
||||
QString previousSelection = testDirectory;
|
||||
QString parent = previousSelection.left(previousSelection.lastIndexOf('/'));
|
||||
if (!parent.isNull() && parent.right(1) != "/") {
|
||||
parent += "/";
|
||||
}
|
||||
|
||||
testDirectory =
|
||||
QFileDialog::getExistingDirectory(nullptr, "Please select the tests root folder", parent, QFileDialog::ShowDirsOnly);
|
||||
|
||||
// If user cancelled then restore previous selection and return
|
||||
if (testDirectory == "") {
|
||||
testDirectory = previousSelection;
|
||||
return;
|
||||
}
|
||||
|
||||
TestSuiteCreator testSuiteCreator;
|
||||
testSuiteCreator.createTestSuite(testDirectory);
|
||||
}
|
||||
|
||||
QStringList Test::createListOfAll_imagesInDirectory(const QString& imageFormat, const QString& pathToImageDirectory) {
|
||||
imageDirectory = QDir(pathToImageDirectory);
|
||||
QStringList nameFilters;
|
||||
|
|
|
@ -50,6 +50,7 @@ public:
|
|||
void createMDFile(const QString& topLevelDirectory);
|
||||
|
||||
void createTestsOutline();
|
||||
void createTestRailTestSuite();
|
||||
|
||||
bool compareImageLists(bool isInteractiveMode, QProgressBar* progressBar);
|
||||
|
||||
|
@ -64,7 +65,7 @@ public:
|
|||
bool createTestResultsFolderPath(const QString& directory);
|
||||
void zipAndDeleteTestResultsFolder();
|
||||
|
||||
bool isAValidDirectory(const QString& pathname);
|
||||
static bool isAValidDirectory(const QString& pathname);
|
||||
QString extractPathFromTestsDown(const QString& fullPath);
|
||||
QString getExpectedImageDestinationDirectory(const QString& filename);
|
||||
QString getExpectedImagePartialSourceDirectory(const QString& filename);
|
||||
|
|
105
tools/auto-tester/src/TestSuiteCreator.cpp
Normal file
105
tools/auto-tester/src/TestSuiteCreator.cpp
Normal file
|
@ -0,0 +1,105 @@
|
|||
//
|
||||
// TestSuiteCreator.cpp
|
||||
//
|
||||
// Created by Nissim Hadar on 6 Jul 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 "TestSuiteCreator.h"
|
||||
#include "Test.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QFile>
|
||||
#include <QMessageBox>
|
||||
#include <QTextStream>
|
||||
|
||||
void TestSuiteCreator::createTestSuite(const QString& testDirectory) {
|
||||
QDomProcessingInstruction instruction = document.createProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
|
||||
document.appendChild(instruction);
|
||||
|
||||
// root element
|
||||
QDomElement root = document.createElement("suite");
|
||||
document.appendChild(root);
|
||||
|
||||
// id (empty seems to be OK)
|
||||
QDomElement idElement = document.createElement("id");
|
||||
root.appendChild(idElement);
|
||||
|
||||
// name - our tests are in "Rendering"
|
||||
QDomElement nameElement = document.createElement("name");
|
||||
QDomText nameElementText = document.createTextNode("Rendering");
|
||||
nameElement.appendChild(nameElementText);
|
||||
root.appendChild(nameElement);
|
||||
|
||||
// We create a single section, within sections
|
||||
QDomElement topLevelSections = document.createElement("sections");
|
||||
|
||||
QDomElement topLevelSection = document.createElement("section");
|
||||
|
||||
QDomElement suiteName = document.createElement("name");
|
||||
QDomText suiteNameElementElementText = document.createTextNode("Test Suite - " + QDateTime::currentDateTime().toString());
|
||||
suiteName.appendChild(suiteNameElementElementText);
|
||||
topLevelSection.appendChild(suiteName);
|
||||
|
||||
QDomElement secondLevelSections = document.createElement("sections");
|
||||
QDomElement tests = processDirectory(testDirectory, secondLevelSections);
|
||||
topLevelSection.appendChild(tests);
|
||||
|
||||
|
||||
topLevelSection.appendChild(secondLevelSections);
|
||||
topLevelSections.appendChild(topLevelSection);
|
||||
|
||||
root.appendChild(topLevelSections);
|
||||
|
||||
// Write to file
|
||||
const QString testRailsFilename{ "D:/t/TestRailSuite.xml" };
|
||||
QFile file(testRailsFilename);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Could not create XML file");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
QTextStream stream(&file);
|
||||
stream << document.toString();
|
||||
|
||||
file.close();
|
||||
|
||||
QMessageBox::information(0, "Success", "TestRail XML file has been created");
|
||||
}
|
||||
|
||||
QDomElement TestSuiteCreator::processDirectory(const QString& directory, const QDomElement& element) {
|
||||
QDomElement result = element;
|
||||
|
||||
// Loop over all entries in directory
|
||||
QDirIterator it(directory.toStdString().c_str());
|
||||
while (it.hasNext()) {
|
||||
QString directory = it.next();
|
||||
|
||||
// Only process directories
|
||||
QDir dir;
|
||||
if (Test::isAValidDirectory(directory)) {
|
||||
// Ignore the utils directory
|
||||
if (directory.right(5) == "utils") {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Create a section and process it
|
||||
// The directory name appears after the last slash (we are assured there is at least 1).
|
||||
QString directoryName = directory.right(directory.length() - directory.lastIndexOf("/") - 1);
|
||||
|
||||
QDomElement sectionElement = document.createElement("section");
|
||||
|
||||
QDomElement sectionElementName = document.createElement("name");
|
||||
QDomText sectionElementNameText = document.createTextNode(directoryName);
|
||||
sectionElementName.appendChild(sectionElementNameText);
|
||||
sectionElement.appendChild(sectionElementName);
|
||||
|
||||
result.appendChild(sectionElement);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
26
tools/auto-tester/src/TestSuiteCreator.h
Normal file
26
tools/auto-tester/src/TestSuiteCreator.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
//
|
||||
// TestSuiteCreator.h
|
||||
//
|
||||
// Created by Nissim Hadar on 6 Jul 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_test_suite_creator_h
|
||||
#define hifi_test_suite_creator_h
|
||||
|
||||
#include <QDirIterator>
|
||||
#include <QtXml/QDomDocument>
|
||||
#include <QString>
|
||||
|
||||
class TestSuiteCreator {
|
||||
public:
|
||||
void createTestSuite(const QString& testDirectory);
|
||||
QDomElement processDirectory(const QString& directory, const QDomElement& element);
|
||||
private:
|
||||
QDomDocument document;
|
||||
};
|
||||
|
||||
#endif // hifi_test_suite_creator_h
|
|
@ -68,6 +68,10 @@ void AutoTester::on_createTestsOutlineButton_clicked() {
|
|||
test->createTestsOutline();
|
||||
}
|
||||
|
||||
void AutoTester::on_createTestRailTestSuiteButton_clicked() {
|
||||
test->createTestRailTestSuite();
|
||||
}
|
||||
|
||||
// To toggle between show and hide
|
||||
// if (uState & ABS_AUTOHIDE) on_showTaskbarButton_clicked();
|
||||
// else on_hideTaskbarButton_clicked();
|
||||
|
|
|
@ -45,7 +45,7 @@ private slots:
|
|||
void on_createMDFileButton_clicked();
|
||||
void on_createAllMDFilesButton_clicked();
|
||||
void on_createTestsOutlineButton_clicked();
|
||||
|
||||
void on_createTestRailTestSuiteButton_clicked();
|
||||
void on_hideTaskbarButton_clicked();
|
||||
void on_showTaskbarButton_clicked();
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>612</width>
|
||||
<height>537</height>
|
||||
<height>553</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -18,7 +18,7 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>380</x>
|
||||
<y>430</y>
|
||||
<y>450</y>
|
||||
<width>101</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
|
@ -44,7 +44,7 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>430</x>
|
||||
<y>270</y>
|
||||
<y>320</y>
|
||||
<width>101</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
|
@ -57,7 +57,7 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>330</x>
|
||||
<y>110</y>
|
||||
<y>170</y>
|
||||
<width>220</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
|
@ -70,7 +70,7 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>320</x>
|
||||
<y>280</y>
|
||||
<y>330</y>
|
||||
<width>131</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
|
@ -86,7 +86,7 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>320</x>
|
||||
<y>330</y>
|
||||
<y>380</y>
|
||||
<width>255</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
|
@ -99,7 +99,7 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>330</x>
|
||||
<y>170</y>
|
||||
<y>230</y>
|
||||
<width>220</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
|
@ -229,6 +229,19 @@
|
|||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="createTestRailTestSuiteButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>330</x>
|
||||
<y>90</y>
|
||||
<width>220</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Create TestRail Test Suite</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
|
|
Loading…
Reference in a new issue