mirror of https://github.com/nymea/nymea.git
Add tests for the scriptengine
parent
dd70129a4d
commit
24cecf9d47
|
|
@ -61,6 +61,7 @@ Depends: libqt5network5,
|
|||
tar,
|
||||
iputils-tracepath,
|
||||
iputils-ping,
|
||||
qml-module-qtquick2,
|
||||
dnsutils,
|
||||
nymea-translations,
|
||||
libnymea1 (= ${binary:Version}),
|
||||
|
|
|
|||
|
|
@ -607,6 +607,12 @@ RuleEngine *NymeaCore::ruleEngine() const
|
|||
return m_ruleEngine;
|
||||
}
|
||||
|
||||
/*! Returns a pointer to the \l{ScriptEngine} instance owned by NymeaCore.*/
|
||||
ScriptEngine *NymeaCore::scriptEngine() const
|
||||
{
|
||||
return m_scriptEngine;
|
||||
}
|
||||
|
||||
/*! Returns a pointer to the \l{TimeManager} instance owned by NymeaCore.*/
|
||||
TimeManager *NymeaCore::timeManager() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ public:
|
|||
JsonRPCServerImplementation *jsonRPCServer() const;
|
||||
DeviceManager *deviceManager() const;
|
||||
RuleEngine *ruleEngine() const;
|
||||
ScriptEngine *scriptEngine() const;
|
||||
TimeManager *timeManager() const;
|
||||
ServerManager *serverManager() const;
|
||||
BluetoothServer *bluetoothServer() const;
|
||||
|
|
|
|||
|
|
@ -91,8 +91,10 @@ bool ScriptAlarm::active() const
|
|||
void ScriptAlarm::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
|
||||
QTime now = QTime::currentTime();
|
||||
|
||||
|
||||
updateActive();
|
||||
|
||||
if (!m_weekDays.testFlag(today())) {
|
||||
|
|
|
|||
|
|
@ -371,8 +371,6 @@ bool ScriptEngine::loadScript(Script *script)
|
|||
|
||||
QString name = jsonDoc.toVariant().toMap().value("name").toString();
|
||||
|
||||
qCWarning(dcScriptEngine()) << "Loading script";
|
||||
|
||||
script->errors.clear();
|
||||
|
||||
script->component = new QQmlComponent(m_engine, QUrl::fromLocalFile(fileName), this);
|
||||
|
|
|
|||
|
|
@ -20,4 +20,5 @@ SUBDIRS = versioning \
|
|||
usermanager \
|
||||
mqttbroker \
|
||||
tags \
|
||||
scripts \
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
#include "testhelper.h"
|
||||
|
||||
TestHelper* TestHelper::s_instance = nullptr;
|
||||
|
||||
TestHelper *TestHelper::instance()
|
||||
{
|
||||
if (!s_instance) {
|
||||
s_instance = new TestHelper();
|
||||
}
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
void TestHelper::logEvent(const QString &deviceId, const QString &eventId, const QVariantMap ¶ms)
|
||||
{
|
||||
emit eventLogged(DeviceId(deviceId), eventId, params);
|
||||
}
|
||||
|
||||
void TestHelper::logStateChange(const QString &deviceId, const QString &stateId, const QVariant &value)
|
||||
{
|
||||
emit stateChangeLogged(DeviceId(deviceId), stateId, value);
|
||||
}
|
||||
|
||||
TestHelper::TestHelper(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef TESTHELPER_H
|
||||
#define TESTHELPER_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "typeutils.h"
|
||||
|
||||
class TestHelper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static TestHelper* instance();
|
||||
|
||||
Q_INVOKABLE void logEvent(const QString &deviceId, const QString &eventId, const QVariantMap ¶ms);
|
||||
Q_INVOKABLE void logStateChange(const QString &deviceId, const QString &stateId, const QVariant &value);
|
||||
|
||||
signals:
|
||||
void setState(const QVariant &value);
|
||||
void executeAction(const QVariantMap ¶ms);
|
||||
|
||||
void eventLogged(const DeviceId &deviceId, const QString &eventId, const QVariantMap ¶ms);
|
||||
void stateChangeLogged(const DeviceId &deviceId, const QString stateId, const QVariant &value);
|
||||
private:
|
||||
explicit TestHelper(QObject *parent = nullptr);
|
||||
static TestHelper* s_instance;
|
||||
};
|
||||
|
||||
#endif // TESTHELPER_H
|
||||
Loading…
Reference in New Issue