diff options
author | Mathias Hasselmann <mathias.hasselmann@kdab.com> | 2013-10-19 21:48:48 +0200 |
---|---|---|
committer | Mathias Hasselmann <mathias.hasselmann@kdab.com> | 2013-10-19 23:18:12 +0200 |
commit | 05c12c6d9af430c3637d43866059e88af28c034b (patch) | |
tree | b67b6e8eacb2fb73824b7c9a530e7ff64f18a8e3 /tests |
Initial version
Diffstat (limited to 'tests')
-rw-r--r-- | tests/tests.pro | 4 | ||||
-rw-r--r-- | tests/tst_wrapping/tst_wrapping.pro | 14 | ||||
-rw-r--r-- | tests/tst_wrapping/tst_wrappingtest.cpp | 85 |
3 files changed, 103 insertions, 0 deletions
diff --git a/tests/tests.pro b/tests/tests.pro new file mode 100644 index 0000000..d9d63e7 --- /dev/null +++ b/tests/tests.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + tst_wrapping diff --git a/tests/tst_wrapping/tst_wrapping.pro b/tests/tst_wrapping/tst_wrapping.pro new file mode 100644 index 0000000..ab907c5 --- /dev/null +++ b/tests/tst_wrapping/tst_wrapping.pro @@ -0,0 +1,14 @@ +TEMPLATE = app + +QT += testlib +QT -= gui + +CONFIG += c++11 link_pkgconfig +PKGCONFIG += gstreamer-1.0 + +LIBS += -Wl,-rpath,$$OUT_PWD/../../src -L../../src -lqtquickstreamerplugin + +INCLUDEPATH += ../../src + +SOURCES += tst_wrappingtest.cpp +DEFINES += SRCDIR=\\\"$$PWD/\\\" diff --git a/tests/tst_wrapping/tst_wrappingtest.cpp b/tests/tst_wrapping/tst_wrappingtest.cpp new file mode 100644 index 0000000..4e0a2d2 --- /dev/null +++ b/tests/tst_wrapping/tst_wrappingtest.cpp @@ -0,0 +1,85 @@ +#include <QString> +#include <QtTest> + +#include "object.h" + +#include <gst/gst.h> + +class WrappingTest : public QObject +{ + Q_OBJECT + +public: + WrappingTest() + { + gst_init(Q_NULLPTR, Q_NULLPTR); + } + +private slots: + void testCase1(); + + void elementNameProperty() + { + GstElement *const target = gst_pipeline_new(Q_NULLPTR); + auto *wrapper = QQuickStreamer::wrap<QQuickStreamer::Object>(GST_OBJECT(target)); + QVERIFY(wrapper != Q_NULLPTR); + + QSignalSpy spy(wrapper, SIGNAL(nameChanged())); + + QCOMPARE(wrapper->property("name").toString(), QStringLiteral("pipeline0")); + QCOMPARE(spy.count(), 0); + + wrapper->setProperty("name", QStringLiteral("dummy0")); + + QCOMPARE(wrapper->property("name").toString(), QStringLiteral("dummy0")); + QCOMPARE(spy.count(), 1); + + wrapper->setProperty("name", QStringLiteral("dummy1")); + + QCOMPARE(wrapper->property("name").toString(), QStringLiteral("dummy1")); + QCOMPARE(spy.count(), 2); + } +}; + +void WrappingTest::testCase1() +{ + GstElement *const target = gst_pipeline_new("wrapping_test"); + + auto *wrapper1 = QQuickStreamer::wrap<QQuickStreamer::Object>(GST_OBJECT(target)); + QVERIFY(wrapper1 != Q_NULLPTR); + + auto *wrapper2 = QQuickStreamer::wrap<QQuickStreamer::Object>(GST_OBJECT(target)); + QCOMPARE(wrapper1, wrapper2); + + auto *metaObject = wrapper1->metaObject(); + QVERIFY(metaObject != Q_NULLPTR); + + qDebug() << G_OBJECT_TYPE_NAME(target); + qDebug() << metaObject->className() + << metaObject->propertyCount() + << metaObject->methodCount() + << metaObject->enumeratorCount(); + + for (int i = 0; i < metaObject->propertyCount(); ++i) { + qDebug() << "P" << i << metaObject->property(i).name() + << metaObject->property(i).typeName() + << (metaObject->property(i).isReadable() ? "read" : "") + << (metaObject->property(i).isWritable() ? "write" : "") + << (metaObject->property(i).isEnumType() ? "emum" : "") + << (metaObject->property(i).isFlagType() ? "flag" : ""); + QVERIFY(metaObject->property(i).hasNotifySignal()); + QCOMPARE(i, metaObject->indexOfProperty(metaObject->property(i).name())); + } + + for (int i = 0; i < metaObject->methodCount(); ++i) { + qDebug() << "M" << i << metaObject->method(i).methodSignature() + << metaObject->method(i).methodType(); + } + + for (int i = 0; i < metaObject->enumeratorCount(); ++i) + qDebug() << "E" << i << metaObject->enumerator(i).name(); +} + +QTEST_MAIN(WrappingTest) + +#include "tst_wrappingtest.moc" |