diff options
author | Martin Wolf <ext-martin.2.wolf@nokia.com> | 2010-02-03 10:13:44 +0200 |
---|---|---|
committer | Martin Wolf <ext-martin.2.wolf@nokia.com> | 2010-02-03 10:13:44 +0200 |
commit | 06644af1a621f2afbd42957afc9cfda24056df54 (patch) | |
tree | dac557aab7a7bff21ad7b7c0ccc877bf42f5303e /tests | |
parent | 8bff62c335842b4c850cc09716e79c2f556247c7 (diff) |
Added debian packaging info and libdbus-qeventloop library
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-dbus-ping/test-dbus-ping.cpp | 36 | ||||
-rw-r--r-- | tests/test-dbus-ping/test-dbus-ping.pro | 19 | ||||
-rw-r--r-- | tests/test-dbus-pong/pong.h | 13 | ||||
-rw-r--r-- | tests/test-dbus-pong/test-dbus-pong.cpp | 41 | ||||
-rw-r--r-- | tests/test-dbus-pong/test-dbus-pong.pro | 20 | ||||
-rw-r--r-- | tests/test-dbus-qeventloop/test-dbus-qeventloop.cpp | 20 | ||||
-rw-r--r-- | tests/test-dbus-qeventloop/test-dbus-qeventloop.pro | 28 | ||||
-rw-r--r-- | tests/test-resource/test-resource.pro | 4 | ||||
-rw-r--r-- | tests/tests.pro | 18 | ||||
-rw-r--r-- | tests/tests.xml | 36 |
10 files changed, 233 insertions, 2 deletions
diff --git a/tests/test-dbus-ping/test-dbus-ping.cpp b/tests/test-dbus-ping/test-dbus-ping.cpp new file mode 100644 index 0000000..ff496e6 --- /dev/null +++ b/tests/test-dbus-ping/test-dbus-ping.cpp @@ -0,0 +1,36 @@ +#include <stdio.h> + +#include <QtCore/QCoreApplication> +#include <QtDBus/QtDBus> + +#define SERVICE_NAME "com.nokia.dbusqeventloop.test" + +int main(int argc, char **argv) +{ + QCoreApplication app(argc, argv); + + if( !QDBusConnection::systemBus().isConnected() ) + { + fprintf(stderr, "Cannot connect to the D-Bus system bus.\n" + "To start it, run:\n" + "\teval `dbus-launch --auto-syntax`\n"); + return 1; + } + + QDBusInterface iface(SERVICE_NAME, "/", "", QDBusConnection::systemBus()); + if( iface.isValid() ) + { + QDBusReply<QString> reply = iface.call("ping", argc > 1 ? argv[1] : ""); + if( reply.isValid() ) + { + printf("Reply was: %s\n", qPrintable(reply.value())); + return 0; + } + + fprintf(stderr, "Call failed: %s\n", qPrintable(reply.error().message())); + return 2; + } + + fprintf(stderr, "%s\n", qPrintable(QDBusConnection::systemBus().lastError().message())); + return 3; +} diff --git a/tests/test-dbus-ping/test-dbus-ping.pro b/tests/test-dbus-ping/test-dbus-ping.pro new file mode 100644 index 0000000..b81bd3d --- /dev/null +++ b/tests/test-dbus-ping/test-dbus-ping.pro @@ -0,0 +1,19 @@ +TEMPLATE = app +TARGET = test-dbus-ping +MOC_DIR = .moc +OBJECTS_DIR = .obj +DEPENDPATH += . +QT = core dbus +CONFIG += console +CONFIG -= app_bundle + +QMAKE_CXXFLAGS += -Wall + +# Input +SOURCES += test-dbus-ping.cpp + +QMAKE_DISTCLEAN += -r .moc .obj + +# Install options +target.path = /usr/lib/libresourceqt-tests/ +INSTALLS = target diff --git a/tests/test-dbus-pong/pong.h b/tests/test-dbus-pong/pong.h new file mode 100644 index 0000000..8656186 --- /dev/null +++ b/tests/test-dbus-pong/pong.h @@ -0,0 +1,13 @@ +#ifndef _PONG_H_ +#define _PONG_H_ + +#include <QtCore/QObject> + +class Pong: public QObject +{ + Q_OBJECT +public slots: + Q_SCRIPTABLE QString ping(const QString &arg); +}; + +#endif // _PONG_H_ diff --git a/tests/test-dbus-pong/test-dbus-pong.cpp b/tests/test-dbus-pong/test-dbus-pong.cpp new file mode 100644 index 0000000..f781004 --- /dev/null +++ b/tests/test-dbus-pong/test-dbus-pong.cpp @@ -0,0 +1,41 @@ +#include <stdio.h> +#include <stdlib.h> + +#include <QtCore/QCoreApplication> +#include <QtCore/QTimer> +#include <QtDBus/QtDBus> + +#include "pong.h" + +#define SERVICE_NAME "com.nokia.dbusqeventloop.test" + +QString Pong::ping(const QString &arg) +{ + QMetaObject::invokeMethod(QCoreApplication::instance(), "quit"); + return QString("ping(\"%1\") got called").arg(arg); +} + +int main(int argc, char **argv) +{ + QCoreApplication app(argc, argv); + + if( !QDBusConnection::systemBus().isConnected() ) + { + fprintf(stderr, "Cannot connect to the D-Bus system bus.\n" + "To start it, run:\n" + "\teval `dbus-launch --auto-syntax`\n"); + return 1; + } + + if( !QDBusConnection::systemBus().registerService(SERVICE_NAME) ) + { + fprintf(stderr, "%s\n", qPrintable(QDBusConnection::systemBus().lastError().message())); + exit(2); + } + + Pong pong; + QDBusConnection::systemBus().registerObject("/", &pong, QDBusConnection::ExportAllSlots); + + app.exec(); + return 0; +} diff --git a/tests/test-dbus-pong/test-dbus-pong.pro b/tests/test-dbus-pong/test-dbus-pong.pro new file mode 100644 index 0000000..ab59e1a --- /dev/null +++ b/tests/test-dbus-pong/test-dbus-pong.pro @@ -0,0 +1,20 @@ +TEMPLATE = app +TARGET = test-dbus-pong +MOC_DIR = .moc +OBJECTS_DIR = .obj +DEPENDPATH += . +QT = core dbus +CONFIG += console +CONFIG -= app_bundle + +QMAKE_CXXFLAGS += -Wall + +# Input +SOURCES += test-dbus-pong.cpp +HEADERS += pong.h + +QMAKE_DISTCLEAN += -r .moc .obj + +# Install options +target.path = /usr/lib/libresourceqt-tests/ +INSTALLS = target diff --git a/tests/test-dbus-qeventloop/test-dbus-qeventloop.cpp b/tests/test-dbus-qeventloop/test-dbus-qeventloop.cpp new file mode 100644 index 0000000..f0385af --- /dev/null +++ b/tests/test-dbus-qeventloop/test-dbus-qeventloop.cpp @@ -0,0 +1,20 @@ +#include "dbusconnectioneventloop.h" +#include <QtTest/QtTest> + +class TestDbusQEventLoop: public QObject +{ + Q_OBJECT + +private slots: + void basicTest() + { + DBusConnection* systemBus = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); + QVERIFY(systemBus != NULL); + + DBUSConnectionEventLoop d; + QVERIFY(d.initConnection(systemBus) == true); + } +}; + +QTEST_MAIN(TestDbusQEventLoop) +#include "test-dbus-qeventloop.moc" diff --git a/tests/test-dbus-qeventloop/test-dbus-qeventloop.pro b/tests/test-dbus-qeventloop/test-dbus-qeventloop.pro new file mode 100644 index 0000000..80066bf --- /dev/null +++ b/tests/test-dbus-qeventloop/test-dbus-qeventloop.pro @@ -0,0 +1,28 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2010-01-18T16:28:34 +# +#------------------------------------------------- + +TEMPLATE = app +TARGET = test-dbus-qeventloop +MOC_DIR = .moc +OBJECTS_DIR = .obj +DEPENDPATH += . +QT = testlib core +CONFIG += console link_pkgconfig +CONFIG -= app_bundle +PKGCONFIG += dbus-1 + +INCLUDEPATH += ../../libdbus-qeventloop +QMAKE_CXXFLAGS += -Wall +LIBS += -L../../libdbus-qeventloop/build -ldbus-qeventloop + +# Input +SOURCES += test-dbus-qeventloop.cpp + +QMAKE_DISTCLEAN += -r .moc .obj + +# Install options +target.path = /usr/lib/libresourceqt-tests/ +INSTALLS = target diff --git a/tests/test-resource/test-resource.pro b/tests/test-resource/test-resource.pro index 7ab2678..6ff2f35 100644 --- a/tests/test-resource/test-resource.pro +++ b/tests/test-resource/test-resource.pro @@ -1,4 +1,4 @@ -BASE = .. +BASE = ../../libresourceqt TEMPLATE = app TARGET = test-resource DESTDIR = build @@ -17,5 +17,5 @@ QT -= gui # Install directives INSTALLBASE = /usr -target.path = $$INSTALLBASE/share/libresourceqt/tests +target.path = $$INSTALLBASE/lib/libresourceqt-tests/ INSTALLS = target diff --git a/tests/tests.pro b/tests/tests.pro new file mode 100644 index 0000000..e5751bb --- /dev/null +++ b/tests/tests.pro @@ -0,0 +1,18 @@ +##################################################################### +# Tests projectfile +##################################################################### + +CONFIG += ordered +TEMPLATE = subdirs + +SUBDIRS = test-dbus-qeventloop \ + test-dbus-ping \ + test-dbus-pong \ + test-resource \ +# test-resource-engine \ + test-resource-set + +# Install options +testsxml.path = /usr/share/libresourceqt-tests/ +testsxml.files = tests.xml +INSTALLS = testsxml diff --git a/tests/tests.xml b/tests/tests.xml new file mode 100644 index 0000000..8cd4f87 --- /dev/null +++ b/tests/tests.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<testdefinition version="0.1"> + <suite name="libresourceqt-tests" domain="Multimedia Middleware"> + <set name="libresourceqt-tests" feature="Resource policy"> + + <case name="test-resource" type="Functional" level="Component" description="Unit tests for libresourceqt" timeout="15"> + <step expected_result="0">/usr/lib/libresourceqt-tests/test-resource</step> + </case> + + <case name="test-resource-set" type="Functional" level="Component" description="Unit tests for libresourceqt" timeout="15"> + <step expected_result="0">/usr/lib/libresourceqt-tests/test-resource-set</step> + </case> + + <environments> + <scratchbox>false</scratchbox> + <hardware>true</hardware> + </environments> + + </set> + </suite> + + <suite name="libdbus-qeventloop-tests" domain="Multimedia Middleware"> + <set name="libdbus-qeventloop-tests" feature="Resource policy"> + + <case name="unit-tests" type="Functional" level="Component" description="Unit tests for libdbus-qeventloop" timeout="15"> + <step expected_result="0">/usr/lib/libresourceqt-tests/test-dbus-qeventloop</step> + </case> + + <environments> + <scratchbox>false</scratchbox> + <hardware>true</hardware> + </environments> + + </set> + </suite> +</testdefinition> |