Heart/HeartTests/tst_testprotockol.cpp

95 lines
1.9 KiB
C++
Raw Normal View History

2020-09-27 12:40:11 +03:00
/*
* Copyright (C) 2018-2021 QuasarApp.
2020-09-27 12:40:11 +03:00
* Distributed under the lgplv3 software license, see the accompanying
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
2020-09-15 21:16:35 +03:00
#include <QtTest>
2020-09-15 22:33:48 +03:00
#if HEART_BUILD_LVL >= 0
2020-09-15 21:16:35 +03:00
#include "abstractnodetest.h"
#endif
2020-09-15 22:33:48 +03:00
#if HEART_BUILD_LVL >= 1
2020-09-15 21:16:35 +03:00
#include <basenodetest.h>
2021-10-02 22:12:39 +03:00
#include <bigdatatest.h>
#include <singleservertest.h>
2020-09-15 21:16:35 +03:00
#endif
2020-09-15 22:33:48 +03:00
#if HEART_BUILD_LVL >= 2
2020-10-24 21:40:29 +03:00
#include <networknodetest.h>
2020-09-15 21:16:35 +03:00
#endif
#define TestCase(name, testClass) \
void name() { \
initTest(new testClass()); \
}
2020-09-15 21:16:35 +03:00
class testProtockol : public QObject
{
Q_OBJECT
public:
testProtockol();
~testProtockol();
private slots:
// BEGIN TESTS CASES
2020-09-15 22:33:48 +03:00
#if HEART_BUILD_LVL >= 0
TestCase(abstractNodeTest, AbstractNodeTest)
2021-10-02 22:12:39 +03:00
TestCase(bigDataTest, BigDataTest);
2020-09-15 21:16:35 +03:00
#endif
2020-09-15 22:33:48 +03:00
#if HEART_BUILD_LVL >= 1
TestCase(baseNodeTest, BaseNodeTest)
TestCase(singleNodeTest, SingleServerTest)
2020-09-15 21:16:35 +03:00
#endif
2020-09-15 22:33:48 +03:00
#if HEART_BUILD_LVL >= 2
TestCase(networkNodeTest, NetworkNodeTest)
2020-09-15 21:16:35 +03:00
#endif
// END TEST CASES
2020-09-15 21:16:35 +03:00
private:
void initTest(Test* test);
2020-09-15 21:16:35 +03:00
QCoreApplication *_app = nullptr;
};
testProtockol::testProtockol() {
QH::init();
2020-09-15 21:16:35 +03:00
// init xample unit test
2020-09-15 21:16:35 +03:00
int argc =0;
char * argv[] = {nullptr};
_app = new QCoreApplication(argc, argv);
QCoreApplication::setApplicationName("testHeart");
2020-09-15 21:16:35 +03:00
QCoreApplication::setOrganizationName("QuasarApp");
auto path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
QDir(path).removeRecursively();
}
2020-09-15 21:16:35 +03:00
testProtockol::~testProtockol() {
_app->exit(0);
delete _app;
}
2020-09-15 21:16:35 +03:00
void testProtockol::initTest(Test *test) {
QTimer::singleShot(0, this, [this, test]() {
test->test();
delete test;
_app->exit(0);
2020-09-15 21:16:35 +03:00
});
_app->exec();
2020-09-15 21:16:35 +03:00
}
QTEST_APPLESS_MAIN(testProtockol)
#include "tst_testprotockol.moc"