Snake/tests/tstMain.cpp

90 lines
1.7 KiB
C++
Raw Normal View History

//#
2021-06-16 20:41:50 +03:00
//# Copyright (C) 2020-2021 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#include <QtTest>
2021-06-18 17:34:31 +03:00
#include "clasterstest.h"
2021-07-30 13:19:19 +03:00
#include "groupobjecttest.h"
// Use This macros for initialize your own test classes.
// Check exampletests
#define TestCase(name, testClass) \
void name() { \
initTest(new testClass()); \
}
/**
* @brief The tstMain class - this is main test class
*/
class tstMain : public QObject
{
Q_OBJECT
public:
tstMain();
~tstMain();
private slots:
// BEGIN TESTS CASES
2021-06-18 17:34:31 +03:00
TestCase(clastersTest, ClastersTest)
2021-07-30 13:19:19 +03:00
TestCase(groupObjectTest, GroupObjectTest)
2021-06-18 17:34:31 +03:00
// END TEST CASES
private:
/**
* @brief initTest This method prepare @a test for run in the QApplication loop.
* @param test are input test case class.
*/
void initTest(Test* test);
QCoreApplication *_app = nullptr;
};
/**
* @brief tstMain::tstMain
* init all availabel units for testsing
*/
tstMain::tstMain() {
// init xample unit test
int argc =0;
char * argv[] = {nullptr};
_app = new QCoreApplication(argc, argv);
2021-06-16 16:10:14 +03:00
QCoreApplication::setApplicationName("testCrawl");
QCoreApplication::setOrganizationName("QuasarApp");
auto path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
QDir(path).removeRecursively();
}
tstMain::~tstMain() {
_app->exit(0);
delete _app;
}
void tstMain::initTest(Test *test) {
QTimer::singleShot(0, this, [this, test]() {
test->test();
delete test;
_app->exit(0);
});
_app->exec();
}
QTEST_APPLESS_MAIN(tstMain)
#include "tstMain.moc"