summaryrefslogtreecommitdiff
path: root/tests/test-dbus-pong
diff options
context:
space:
mode:
authorMartin Wolf <ext-martin.2.wolf@nokia.com>2010-02-03 10:13:44 +0200
committerMartin Wolf <ext-martin.2.wolf@nokia.com>2010-02-03 10:13:44 +0200
commit06644af1a621f2afbd42957afc9cfda24056df54 (patch)
treedac557aab7a7bff21ad7b7c0ccc877bf42f5303e /tests/test-dbus-pong
parent8bff62c335842b4c850cc09716e79c2f556247c7 (diff)
Added debian packaging info and libdbus-qeventloop library
Diffstat (limited to 'tests/test-dbus-pong')
-rw-r--r--tests/test-dbus-pong/pong.h13
-rw-r--r--tests/test-dbus-pong/test-dbus-pong.cpp41
-rw-r--r--tests/test-dbus-pong/test-dbus-pong.pro20
3 files changed, 74 insertions, 0 deletions
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