4
1
mirror of https://github.com/QuasarApp/Heart.git synced 2025-05-11 17:09:41 +00:00
Heart/HeartTests/tst_testprotockol.cpp
2021-10-11 10:40:22 +03:00

97 lines
1.9 KiB
C++

/*
* Copyright (C) 2018-2021 QuasarApp.
* 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.
*/
#include <QtTest>
#if HEART_BUILD_LVL >= 0
#include "abstractnodetest.h"
#endif
#if HEART_BUILD_LVL >= 1
#include <basenodetest.h>
#include <bigdatatest.h>
#include <singleservertest.h>
#include <upgradedatabasetest.h>
#endif
#if HEART_BUILD_LVL >= 2
#include <networknodetest.h>
#endif
#define TestCase(name, testClass) \
void name() { \
initTest(new testClass()); \
}
class testProtockol : public QObject
{
Q_OBJECT
public:
testProtockol();
~testProtockol();
private slots:
// BEGIN TESTS CASES
#if HEART_BUILD_LVL >= 0
TestCase(abstractNodeTest, AbstractNodeTest)
TestCase(bigDataTest, BigDataTest);
#endif
#if HEART_BUILD_LVL >= 1
TestCase(baseNodeTest, BaseNodeTest)
TestCase(singleNodeTest, SingleServerTest)
TestCase(upgradeDataBaseTest, UpgradeDataBaseTest)
#endif
#if HEART_BUILD_LVL >= 2
TestCase(networkNodeTest, NetworkNodeTest)
#endif
// END TEST CASES
private:
void initTest(Test* test);
QCoreApplication *_app = nullptr;
};
testProtockol::testProtockol() {
QH::init();
// init xample unit test
int argc =0;
char * argv[] = {nullptr};
_app = new QCoreApplication(argc, argv);
QCoreApplication::setApplicationName("testHeart");
QCoreApplication::setOrganizationName("QuasarApp");
auto path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
QDir(path).removeRecursively();
}
testProtockol::~testProtockol() {
_app->exit(0);
delete _app;
}
void testProtockol::initTest(Test *test) {
QTimer::singleShot(0, this, [this, test]() {
test->test();
delete test;
_app->exit(0);
});
_app->exec();
}
QTEST_APPLESS_MAIN(testProtockol)
#include "tst_testprotockol.moc"