mirror of
https://github.com/QuasarApp/Heart.git
synced 2025-05-11 17:09:41 +00:00
backport last changes from CMakeProjects
This commit is contained in:
parent
dcb4566d59
commit
cced6fc316
@ -19,23 +19,39 @@
|
|||||||
#include <networknodetest.h>
|
#include <networknodetest.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TestCase(name, testClass) \
|
||||||
|
void name() { \
|
||||||
|
initTest(new testClass()); \
|
||||||
|
}
|
||||||
|
|
||||||
class testProtockol : public QObject
|
class testProtockol : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
|
||||||
QList<Test*> _tests;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
testProtockol();
|
testProtockol();
|
||||||
|
|
||||||
~testProtockol();
|
~testProtockol();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void initTestCase();
|
// BEGIN TESTS CASES
|
||||||
void unitTests();
|
#if HEART_BUILD_LVL >= 0
|
||||||
|
|
||||||
|
TestCase(abstractNodeTest, AbstractNodeTest)
|
||||||
|
#endif
|
||||||
|
#if HEART_BUILD_LVL >= 1
|
||||||
|
TestCase(baseNodeTest, BaseNodeTest)
|
||||||
|
TestCase(singleNodeTest, SingleServerTest)
|
||||||
|
#endif
|
||||||
|
#if HEART_BUILD_LVL >= 2
|
||||||
|
TestCase(networkNodeTest, NetworkNodeTest)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// END TEST CASES
|
||||||
|
|
||||||
|
private:
|
||||||
|
void initTest(Test* test);
|
||||||
|
|
||||||
|
QCoreApplication *_app = nullptr;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -43,49 +59,32 @@ testProtockol::testProtockol() {
|
|||||||
|
|
||||||
QH::init();
|
QH::init();
|
||||||
|
|
||||||
#if HEART_BUILD_LVL >= 0
|
// init xample unit test
|
||||||
_tests.push_back(new AbstractNodeTest);
|
|
||||||
#endif
|
|
||||||
#if HEART_BUILD_LVL >= 1
|
|
||||||
_tests.push_back(new BaseNodeTest);
|
|
||||||
_tests.push_back(new SingleServerTest);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#if HEART_BUILD_LVL >= 2
|
|
||||||
_tests.push_back(new NetworkNodeTest);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
testProtockol::~testProtockol() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void testProtockol::initTestCase() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void testProtockol::unitTests() {
|
|
||||||
int argc =0;
|
int argc =0;
|
||||||
char * argv[] = {nullptr};
|
char * argv[] = {nullptr};
|
||||||
|
|
||||||
QCoreApplication app(argc, argv);
|
_app = new QCoreApplication(argc, argv);
|
||||||
QCoreApplication::setApplicationName("TestQNP");
|
QCoreApplication::setApplicationName("testHeart");
|
||||||
QCoreApplication::setOrganizationName("QuasarApp");
|
QCoreApplication::setOrganizationName("QuasarApp");
|
||||||
|
|
||||||
auto path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
auto path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||||
|
|
||||||
QDir(path).removeRecursively();
|
QDir(path).removeRecursively();
|
||||||
|
}
|
||||||
|
|
||||||
QTimer::singleShot(0, this, [this, &app]() {
|
testProtockol::~testProtockol() {
|
||||||
|
_app->exit(0);
|
||||||
|
delete _app;
|
||||||
|
}
|
||||||
|
|
||||||
for (auto test : qAsConst(_tests) ) {
|
void testProtockol::initTest(Test *test) {
|
||||||
test->test();
|
QTimer::singleShot(0, this, [this, test]() {
|
||||||
delete test;
|
test->test();
|
||||||
}
|
delete test;
|
||||||
|
_app->exit(0);
|
||||||
app.exit(0);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.exec();
|
_app->exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
QTEST_APPLESS_MAIN(testProtockol)
|
QTEST_APPLESS_MAIN(testProtockol)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user