mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 09:15:50 +02:00
Implemented creation of allTests.js
This commit is contained in:
parent
51f7a03ecc
commit
346c691f0c
5 changed files with 81 additions and 23 deletions
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include <assert.h>
|
||||
#include <QtCore/QTextStream>
|
||||
#include <QDirIterator>
|
||||
|
||||
Test::Test() {
|
||||
snapshotFilenameFormat = QRegularExpression("hifi-snap-by-.+-on-\\d\\d\\d\\d-\\d\\d-\\d\\d_\\d\\d-\\d\\d-\\d\\d.jpg");
|
||||
|
@ -105,7 +106,45 @@ void Test::evaluateTests() {
|
|||
messageBox.information(0, "Failure", "One or more images are not as expected");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Creates a single script in a user-selected folder.
|
||||
// This script will run all text.js scripts in every applicable sub-folder
|
||||
void Test::createRecursiveScript() {
|
||||
// Select folder to start recursing from
|
||||
QString topLevelDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select folder that will contain the top level test script", ".", QFileDialog::ShowDirsOnly);
|
||||
QDirIterator it(topLevelDirectory.toStdString().c_str(), QDirIterator::Subdirectories);
|
||||
|
||||
QFile allTestsFilename(topLevelDirectory + "/" + "allTests.js");
|
||||
if (!allTestsFilename.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
messageBox.critical(0,
|
||||
"Internal Error",
|
||||
"Failed to create \"allTests.js\" in directory \"" + topLevelDirectory + "\"");
|
||||
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
QTextStream textStream(&allTestsFilename);
|
||||
textStream << "// This is an automatically generated file, created by auto-tester" << endl;
|
||||
|
||||
const QString testFilename{ "test.js" };
|
||||
while (it.hasNext()) {
|
||||
QString directory = it.next();
|
||||
if (directory[directory.length() - 1] == '.') {
|
||||
continue; // ignore '.', '..' directories
|
||||
}
|
||||
|
||||
const QString testPathname{ directory + "/" + testFilename };
|
||||
|
||||
QFileInfo fileInfo(testPathname);
|
||||
if (fileInfo.exists()) {
|
||||
// Current folder contains a test
|
||||
textStream << "Script.include(\"" << testPathname << "/" << " ? raw = true\")" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
allTestsFilename.close();
|
||||
}
|
||||
|
||||
void Test::createTest() {
|
||||
// Rename files sequentially, as ExpectedResult_1.jpeg, ExpectedResult_2.jpg and so on
|
||||
// Any existing expected result images will be deleted
|
||||
|
@ -130,7 +169,7 @@ void Test::createTest() {
|
|||
}
|
||||
|
||||
void Test::createListOfAllJPEGimagesInDirectory() {
|
||||
// get list of JPEG images in folder, sorted by name
|
||||
// Get list of JPEG images in folder, sorted by name
|
||||
pathToImageDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select folder containing the test images", ".", QFileDialog::ShowDirsOnly);
|
||||
|
||||
imageDirectory = QDir(pathToImageDirectory);
|
||||
|
|
|
@ -24,6 +24,7 @@ public:
|
|||
Test();
|
||||
|
||||
void evaluateTests();
|
||||
void createRecursiveScript();
|
||||
void createTest();
|
||||
|
||||
void createListOfAllJPEGimagesInDirectory();
|
||||
|
|
|
@ -16,17 +16,23 @@ AutoTester::AutoTester(QWidget *parent)
|
|||
ui.setupUi(this);
|
||||
}
|
||||
|
||||
void AutoTester::on_closeButton_clicked()
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void AutoTester::on_evaluateTestsButton_clicked()
|
||||
{
|
||||
test.evaluateTests();
|
||||
}
|
||||
|
||||
void AutoTester::on_createRecursiveScriptButton_clicked()
|
||||
{
|
||||
test.createRecursiveScript();
|
||||
}
|
||||
|
||||
void AutoTester::on_createTestButton_clicked()
|
||||
{
|
||||
test.createTest();
|
||||
}
|
||||
|
||||
void AutoTester::on_closeButton_clicked()
|
||||
{
|
||||
exit(0);
|
||||
}
|
|
@ -24,6 +24,7 @@ public:
|
|||
|
||||
private slots:
|
||||
void on_evaluateTestsButton_clicked();
|
||||
void on_createRecursiveScriptButton_clicked();
|
||||
void on_createTestButton_clicked();
|
||||
void on_closeButton_clicked();
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>261</width>
|
||||
<height>330</height>
|
||||
<width>277</width>
|
||||
<height>351</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -17,10 +17,10 @@
|
|||
<widget class="QPushButton" name="closeButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>80</x>
|
||||
<y>210</y>
|
||||
<width>100</width>
|
||||
<height>23</height>
|
||||
<x>60</x>
|
||||
<y>240</y>
|
||||
<width>159</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -30,10 +30,10 @@
|
|||
<widget class="QPushButton" name="createTestButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>80</x>
|
||||
<y>160</y>
|
||||
<width>100</width>
|
||||
<height>23</height>
|
||||
<x>60</x>
|
||||
<y>180</y>
|
||||
<width>160</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -43,23 +43,36 @@
|
|||
<widget class="QPushButton" name="evaluateTestsButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>80</x>
|
||||
<x>60</x>
|
||||
<y>20</y>
|
||||
<width>100</width>
|
||||
<height>23</height>
|
||||
<width>160</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Evaulate Tests</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="createRecursiveScriptButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>120</y>
|
||||
<width>160</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Create Recursive Script</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>261</width>
|
||||
<width>277</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -75,8 +88,6 @@
|
|||
<widget class="QStatusBar" name="statusBar"/>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources>
|
||||
<include location="../src/AutoTester.qrc"/>
|
||||
</resources>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
Loading…
Reference in a new issue