mirror of
https://github.com/status-im/dotherside.git
synced 2025-02-12 12:46:24 +00:00
53 lines
1.6 KiB
C++
53 lines
1.6 KiB
C++
#include <QTest>
|
|
#include <QSignalSpy>
|
|
#include "../src/DynamicQObject.h"
|
|
|
|
class TestDynamicQObject : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
private slots:
|
|
void memoryLeakTest() {
|
|
DynamicQObject<QObject> dynamicQObject;
|
|
}
|
|
|
|
void testRegisterSignal() {
|
|
DynamicQObject<QObject> dynamicQObject;
|
|
int index;
|
|
dynamicQObject.registerSignal("fooSignal", {}, index);
|
|
QCOMPARE(index != -1, true);
|
|
|
|
QSignalSpy signalSpy(&dynamicQObject, SIGNAL(fooSignal()));
|
|
dynamicQObject.emitSignal("fooSignal", {});
|
|
QCOMPARE(signalSpy.count(), 1);
|
|
}
|
|
|
|
void testRegisterSlot() {
|
|
DynamicQObject<QObject> dynamicQObject;
|
|
int index;
|
|
dynamicQObject.registerSlot("fooSlot", QMetaType::Void, {}, index);
|
|
QCOMPARE(index != -1, true);
|
|
}
|
|
|
|
void testRegisterProperty() {
|
|
DynamicQObject<QObject> dynamicQObject;
|
|
int index = -1;
|
|
bool result = false;
|
|
result = dynamicQObject.registerSlot("foo", QMetaType::Int, {}, index);
|
|
QCOMPARE(index != -1, true);
|
|
QCOMPARE(result, true);
|
|
result = dynamicQObject.registerSlot("setFoo", QMetaType::Void, {QMetaType::Int}, index);
|
|
QCOMPARE(index != -1, true);
|
|
QCOMPARE(result, true);
|
|
result = dynamicQObject.registerSignal("fooChanged", {QMetaType::Int}, index);
|
|
QCOMPARE(index != -1, true);
|
|
QCOMPARE(result, true);
|
|
result = dynamicQObject.registerProperty("foo", QMetaType::Int, "foo", "setFoo", "fooChanged");
|
|
QCOMPARE(result, true);
|
|
}
|
|
};
|
|
|
|
QTEST_MAIN(TestDynamicQObject)
|
|
|
|
#include "test_dynamicqobject.moc"
|