guhtestbase -> nymeatestbase

This commit is contained in:
Michael Zanetti 2018-01-30 11:59:38 +01:00
parent 1442691029
commit 34d68ab38a
23 changed files with 73 additions and 73 deletions

View File

@ -53,7 +53,7 @@ class NymeaConfiguration;
class NymeaCore : public QObject
{
Q_OBJECT
friend class GuhTestBase;
friend class NymeaTestBase;
public:
static NymeaCore* instance();

View File

@ -19,7 +19,7 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h"
#include "nymeatestbase.h"
#include "devicemanager.h"
#include "mocktcpserver.h"
@ -33,7 +33,7 @@
using namespace guhserver;
class TestActions: public GuhTestBase
class TestActions: public NymeaTestBase
{
Q_OBJECT

View File

@ -10,9 +10,9 @@ LIBS += -L$$top_builddir/libnymea/ -lnymea \
-L$$top_builddir/plugins/mock/ \
-lssl -lcrypto -laws-iot-sdk-cpp -lavahi-common -lavahi-client
SOURCES += ../guhtestbase.cpp \
SOURCES += ../nymeatestbase.cpp \
HEADERS += ../guhtestbase.h \
HEADERS += ../nymeatestbase.h \
target.path = /usr/tests
INSTALLS += target

View File

@ -19,7 +19,7 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h"
#include "nymeatestbase.h"
#include "devicemanager.h"
#include "mocktcpserver.h"
#include "nymeacore.h"
@ -34,7 +34,7 @@
using namespace guhserver;
class TestConfigurations: public GuhTestBase
class TestConfigurations: public NymeaTestBase
{
Q_OBJECT

View File

@ -19,7 +19,7 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h"
#include "nymeatestbase.h"
#include "nymeacore.h"
#include "devicemanager.h"
#include "nymeasettings.h"
@ -33,7 +33,7 @@
using namespace guhserver;
class TestDevices : public GuhTestBase
class TestDevices : public NymeaTestBase
{
Q_OBJECT

View File

@ -19,7 +19,7 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h"
#include "nymeatestbase.h"
#include "nymeacore.h"
#include "devicemanager.h"
#include "mocktcpserver.h"
@ -34,7 +34,7 @@
using namespace guhserver;
class TestEvents: public GuhTestBase
class TestEvents: public NymeaTestBase
{
Q_OBJECT

View File

@ -19,7 +19,7 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h"
#include "nymeatestbase.h"
#include "nymeacore.h"
#include "devicemanager.h"
#include "mocktcpserver.h"
@ -36,7 +36,7 @@
using namespace guhserver;
class TestJSONRPC: public GuhTestBase
class TestJSONRPC: public NymeaTestBase
{
Q_OBJECT

View File

@ -19,7 +19,7 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h"
#include "nymeatestbase.h"
#include "nymeacore.h"
#include "devicemanager.h"
#include "nymeasettings.h"
@ -35,7 +35,7 @@
using namespace guhserver;
class TestLogging : public GuhTestBase
class TestLogging : public NymeaTestBase
{
Q_OBJECT

View File

@ -19,7 +19,7 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h"
#include "nymeatestbase.h"
#include "mocktcpserver.h"
#include "nymeacore.h"
#include "nymeasettings.h"
@ -111,7 +111,7 @@ static void loggingCategoryFilter(QLoggingCategory *category)
}
}
GuhTestBase::GuhTestBase(QObject *parent) :
NymeaTestBase::NymeaTestBase(QObject *parent) :
QObject(parent),
m_commandId(0)
{
@ -124,9 +124,9 @@ GuhTestBase::GuhTestBase(QObject *parent) :
QCoreApplication::instance()->setOrganizationName("nymea-test");
}
void GuhTestBase::initTestCase()
void NymeaTestBase::initTestCase()
{
qDebug() << "GuhTestBase starting.";
qDebug() << "NymeaTestBase starting.";
// If testcase asserts cleanup won't do. Lets clear any previous test run settings leftovers
qDebug() << "Reset test settings";
@ -214,12 +214,12 @@ void GuhTestBase::initTestCase()
}
}
void GuhTestBase::cleanupTestCase()
void NymeaTestBase::cleanupTestCase()
{
NymeaCore::instance()->destroy();
}
void GuhTestBase::cleanup()
void NymeaTestBase::cleanup()
{
// In case a test deleted the mock device, lets recreate it.
if (NymeaCore::instance()->deviceManager()->findConfiguredDevices(mockDeviceClassId).count() == 0) {
@ -227,7 +227,7 @@ void GuhTestBase::cleanup()
}
}
QVariant GuhTestBase::injectAndWait(const QString &method, const QVariantMap &params, const QUuid &clientId)
QVariant NymeaTestBase::injectAndWait(const QString &method, const QVariantMap &params, const QUuid &clientId)
{
QVariantMap call;
call.insert("id", m_commandId);
@ -267,7 +267,7 @@ QVariant GuhTestBase::injectAndWait(const QString &method, const QVariantMap &pa
return QVariant();
}
QVariant GuhTestBase::checkNotification(const QSignalSpy &spy, const QString &notification)
QVariant NymeaTestBase::checkNotification(const QSignalSpy &spy, const QString &notification)
{
//qDebug() << "Got" << spy.count() << "notifications while waiting for" << notification;
for (int i = 0; i < spy.count(); i++) {
@ -287,7 +287,7 @@ QVariant GuhTestBase::checkNotification(const QSignalSpy &spy, const QString &no
return QVariant();
}
QVariantList GuhTestBase::checkNotifications(const QSignalSpy &spy, const QString &notification)
QVariantList NymeaTestBase::checkNotifications(const QSignalSpy &spy, const QString &notification)
{
//qDebug() << "Got" << spy.count() << "notifications while waiting for" << notification;
QVariantList notificationList;
@ -308,7 +308,7 @@ QVariantList GuhTestBase::checkNotifications(const QSignalSpy &spy, const QStrin
return notificationList;
}
QVariant GuhTestBase::getAndWait(const QNetworkRequest &request, const int &expectedStatus)
QVariant NymeaTestBase::getAndWait(const QNetworkRequest &request, const int &expectedStatus)
{
QNetworkAccessManager nam;
connect(&nam, &QNetworkAccessManager::sslErrors, [this, &nam](QNetworkReply *reply, const QList<QSslError> &) {
@ -344,7 +344,7 @@ QVariant GuhTestBase::getAndWait(const QNetworkRequest &request, const int &expe
return jsonDoc.toVariant();
}
QVariant GuhTestBase::deleteAndWait(const QNetworkRequest &request, const int &expectedStatus)
QVariant NymeaTestBase::deleteAndWait(const QNetworkRequest &request, const int &expectedStatus)
{
QNetworkAccessManager nam;
connect(&nam, &QNetworkAccessManager::sslErrors, [this, &nam](QNetworkReply *reply, const QList<QSslError> &) {
@ -379,7 +379,7 @@ QVariant GuhTestBase::deleteAndWait(const QNetworkRequest &request, const int &e
return jsonDoc.toVariant();
}
QVariant GuhTestBase::postAndWait(const QNetworkRequest &request, const QVariant &params, const int &expectedStatus)
QVariant NymeaTestBase::postAndWait(const QNetworkRequest &request, const QVariant &params, const int &expectedStatus)
{
QNetworkAccessManager nam;
connect(&nam, &QNetworkAccessManager::sslErrors, [this, &nam](QNetworkReply *reply, const QList<QSslError> &) {
@ -419,7 +419,7 @@ QVariant GuhTestBase::postAndWait(const QNetworkRequest &request, const QVariant
}
QVariant GuhTestBase::putAndWait(const QNetworkRequest &request, const QVariant &params, const int &expectedStatus)
QVariant NymeaTestBase::putAndWait(const QNetworkRequest &request, const QVariant &params, const int &expectedStatus)
{
QNetworkAccessManager nam;
connect(&nam, &QNetworkAccessManager::sslErrors, [this, &nam](QNetworkReply *reply, const QList<QSslError> &) {
@ -456,7 +456,7 @@ QVariant GuhTestBase::putAndWait(const QNetworkRequest &request, const QVariant
return jsonDoc.toVariant();
}
void GuhTestBase::verifyReply(QNetworkReply *reply, const QByteArray &data, const int &expectedStatus)
void NymeaTestBase::verifyReply(QNetworkReply *reply, const QByteArray &data, const int &expectedStatus)
{
int statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
QCOMPARE(statusCode, expectedStatus);
@ -470,7 +470,7 @@ void GuhTestBase::verifyReply(QNetworkReply *reply, const QByteArray &data, cons
// }
}
bool GuhTestBase::enableNotifications()
bool NymeaTestBase::enableNotifications()
{
QVariantMap notificationParams;
notificationParams.insert("enabled", true);
@ -482,7 +482,7 @@ bool GuhTestBase::enableNotifications()
return true;
}
bool GuhTestBase::disableNotifications()
bool NymeaTestBase::disableNotifications()
{
QVariantMap notificationParams;
notificationParams.insert("enabled", false);
@ -494,7 +494,7 @@ bool GuhTestBase::disableNotifications()
return true;
}
void GuhTestBase::restartServer()
void NymeaTestBase::restartServer()
{
// Destroy and recreate the core instance...
NymeaCore::instance()->destroy();
@ -506,12 +506,12 @@ void GuhTestBase::restartServer()
m_mockTcpServer->clientConnected(m_clientId);
}
void GuhTestBase::clearLoggingDatabase()
void NymeaTestBase::clearLoggingDatabase()
{
NymeaCore::instance()->logEngine()->clearDatabase();
}
void GuhTestBase::createMockDevice()
void NymeaTestBase::createMockDevice()
{
QVariantMap params;
params.insert("name", "Test Mock Device");

View File

@ -19,8 +19,8 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef GUHTESTBASE_H
#define GUHTESTBASE_H
#ifndef NYMEATESTBASE_H
#define NYMEATESTBASE_H
#include "typeutils.h"
#include "logging/logging.h"
@ -96,11 +96,11 @@ using namespace guhserver;
class MockTcpServer;
class GuhTestBase : public QObject
class NymeaTestBase : public QObject
{
Q_OBJECT
public:
explicit GuhTestBase(QObject *parent = 0);
explicit NymeaTestBase(QObject *parent = 0);
protected slots:
void initTestCase();
@ -201,4 +201,4 @@ protected:
};
#endif // GUHTESTBASE_H
#endif // NYMEATESTBASE_H

View File

@ -19,7 +19,7 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h"
#include "nymeatestbase.h"
#include "devicemanager.h"
#include "mocktcpserver.h"
@ -33,7 +33,7 @@
using namespace guhserver;
class TestPlugins: public GuhTestBase
class TestPlugins: public NymeaTestBase
{
Q_OBJECT

View File

@ -18,7 +18,7 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h"
#include "nymeatestbase.h"
#include "nymeacore.h"
#include "devicemanager.h"
#include "mocktcpserver.h"
@ -37,7 +37,7 @@
using namespace guhserver;
class TestRestDeviceClasses: public GuhTestBase
class TestRestDeviceClasses: public NymeaTestBase
{
Q_OBJECT
@ -66,7 +66,7 @@ private slots:
void TestRestDeviceClasses::initTestCase()
{
GuhTestBase::initTestCase();
NymeaTestBase::initTestCase();
foreach (const WebServerConfiguration &config, NymeaCore::instance()->configuration()->webServerConfigurations()) {
if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) {

View File

@ -18,7 +18,7 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h"
#include "nymeatestbase.h"
#include "nymeacore.h"
#include "devicemanager.h"
#include "mocktcpserver.h"
@ -37,7 +37,7 @@
using namespace guhserver;
class TestRestDevices: public GuhTestBase
class TestRestDevices: public NymeaTestBase
{
Q_OBJECT
@ -76,7 +76,7 @@ private slots:
void TestRestDevices::initTestCase()
{
GuhTestBase::initTestCase();
NymeaTestBase::initTestCase();
foreach (const WebServerConfiguration &config, NymeaCore::instance()->configuration()->webServerConfigurations()) {
if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) {
qDebug() << "Already have a webserver listening on 127.0.0.1:3333";

View File

@ -19,7 +19,7 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h"
#include "nymeatestbase.h"
#include "nymeacore.h"
#include "devicemanager.h"
#include "plugin/deviceplugin.h"
@ -32,7 +32,7 @@
using namespace guhserver;
class TestRestLogging : public GuhTestBase
class TestRestLogging : public NymeaTestBase
{
Q_OBJECT
@ -58,7 +58,7 @@ private slots:
void TestRestLogging::initTestCase()
{
GuhTestBase::initTestCase();
NymeaTestBase::initTestCase();
foreach (const WebServerConfiguration &config, NymeaCore::instance()->configuration()->webServerConfigurations()) {
if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) {

View File

@ -18,7 +18,7 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h"
#include "nymeatestbase.h"
#include "nymeacore.h"
#include "devicemanager.h"
#include "mocktcpserver.h"
@ -37,7 +37,7 @@
using namespace guhserver;
class TestRestPlugins: public GuhTestBase
class TestRestPlugins: public NymeaTestBase
{
Q_OBJECT
@ -59,7 +59,7 @@ private slots:
void TestRestPlugins::initTestCase()
{
GuhTestBase::initTestCase();
NymeaTestBase::initTestCase();
foreach (const WebServerConfiguration &config, NymeaCore::instance()->configuration()->webServerConfigurations()) {
if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) {

View File

@ -18,7 +18,7 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h"
#include "nymeatestbase.h"
#include "nymeacore.h"
#include "devicemanager.h"
#include "mocktcpserver.h"
@ -37,7 +37,7 @@
using namespace guhserver;
class TestRestRules: public GuhTestBase
class TestRestRules: public NymeaTestBase
{
Q_OBJECT
@ -80,7 +80,7 @@ private slots:
void TestRestRules::initTestCase()
{
GuhTestBase::initTestCase();
NymeaTestBase::initTestCase();
foreach (const WebServerConfiguration &config, NymeaCore::instance()->configuration()->webServerConfigurations()) {
if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) {

View File

@ -18,7 +18,7 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h"
#include "nymeatestbase.h"
#include "nymeacore.h"
#include "devicemanager.h"
#include "mocktcpserver.h"
@ -37,7 +37,7 @@
using namespace guhserver;
class TestRestVendors: public GuhTestBase
class TestRestVendors: public NymeaTestBase
{
Q_OBJECT
@ -54,7 +54,7 @@ private slots:
void TestRestVendors::initTestCase()
{
GuhTestBase::initTestCase();
NymeaTestBase::initTestCase();
foreach (const WebServerConfiguration &config, NymeaCore::instance()->configuration()->webServerConfigurations()) {
if (config.port == 3333 && (config.address == QHostAddress("127.0.0.1") || config.address == QHostAddress("0.0.0.0"))) {

View File

@ -19,7 +19,7 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h"
#include "nymeatestbase.h"
#include "devicemanager.h"
#include "nymeasettings.h"
#include "mocktcpserver.h"
@ -34,7 +34,7 @@
using namespace guhserver;
class TestRules: public GuhTestBase
class TestRules: public NymeaTestBase
{
Q_OBJECT

View File

@ -19,7 +19,7 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h"
#include "nymeatestbase.h"
#include "nymeacore.h"
#include "devicemanager.h"
#include "mocktcpserver.h"
@ -34,7 +34,7 @@
using namespace guhserver;
class TestStates: public GuhTestBase
class TestStates: public NymeaTestBase
{
Q_OBJECT

View File

@ -19,7 +19,7 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h"
#include "nymeatestbase.h"
#include "nymeacore.h"
#include "time/timemanager.h"
#include "devicemanager.h"
@ -36,7 +36,7 @@
using namespace guhserver;
class TestTimeManager: public GuhTestBase
class TestTimeManager: public NymeaTestBase
{
Q_OBJECT

View File

@ -18,7 +18,7 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h"
#include "nymeatestbase.h"
#include "devicemanager.h"
#include "mocktcpserver.h"
@ -32,7 +32,7 @@
using namespace guhserver;
class TestVersioning: public GuhTestBase
class TestVersioning: public NymeaTestBase
{
Q_OBJECT

View File

@ -18,7 +18,7 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h"
#include "nymeatestbase.h"
#include "nymeacore.h"
#include "devicemanager.h"
#include "mocktcpserver.h"
@ -38,7 +38,7 @@
using namespace guhserver;
class TestWebserver: public GuhTestBase
class TestWebserver: public NymeaTestBase
{
Q_OBJECT
@ -81,7 +81,7 @@ public slots:
void TestWebserver::initTestCase()
{
GuhTestBase::initTestCase();
NymeaTestBase::initTestCase();
qDebug() << "TestWebserver starting";
foreach (const WebServerConfiguration &config, NymeaCore::instance()->configuration()->webServerConfigurations()) {

View File

@ -18,7 +18,7 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "guhtestbase.h"
#include "nymeatestbase.h"
#include "nymeacore.h"
#include "devicemanager.h"
#include "mocktcpserver.h"
@ -35,7 +35,7 @@
using namespace guhserver;
class TestWebSocketServer: public GuhTestBase
class TestWebSocketServer: public NymeaTestBase
{
Q_OBJECT
@ -67,7 +67,7 @@ private:
void TestWebSocketServer::initTestCase()
{
GuhTestBase::initTestCase();
NymeaTestBase::initTestCase();
ServerConfiguration config;
foreach (const ServerConfiguration &c, NymeaCore::instance()->configuration()->webSocketServerConfigurations()) {