From fd5ac15ebc643635e436b64cf1e656284380b1a5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 11 Jun 2006 12:18:23 +0000 Subject: * test/qt/*: Update the testcases, including testing the new functionality of sending null QByteArray and QString over the bus. Add new headertest test and restore the old qdbusxmlparser test. --- test/qt/tst_qdbusinterface.cpp | 87 ++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 58 deletions(-) (limited to 'test/qt/tst_qdbusinterface.cpp') diff --git a/test/qt/tst_qdbusinterface.cpp b/test/qt/tst_qdbusinterface.cpp index 46dde97a..a63b8e0b 100644 --- a/test/qt/tst_qdbusinterface.cpp +++ b/test/qt/tst_qdbusinterface.cpp @@ -34,63 +34,33 @@ Q_DECLARE_METATYPE(QVariantList) #define TEST_INTERFACE_NAME "com.trolltech.QtDBus.MyObject" #define TEST_SIGNAL_NAME "somethingHappened" -const char introspectionData[] = - "\n" - "" - - "" - "" - "" - "" - "" - - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - ""; - -class IntrospectionAdaptor: public QDBusAbstractAdaptor -{ - Q_OBJECT - Q_CLASSINFO("D-Bus Interface", "org.freedesktop.DBus.Introspectable") -public: - IntrospectionAdaptor(QObject *parent) - : QDBusAbstractAdaptor(parent) - { } - -public slots: - - void Introspect(const QDBusMessage &msg) - { - QDBusMessage reply = QDBusMessage::methodReply(msg); - reply << ::introspectionData; - if (!msg.connection().send(reply)) - exit(1); - } -}; - class MyObject: public QObject { Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "com.trolltech.QtDBus.MyObject") + Q_CLASSINFO("D-Bus Introspection", "" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" + "") public: MyObject() { - new IntrospectionAdaptor(this); + QObject *subObject = new QObject(this); + subObject->setObjectName("subObject"); } public slots: @@ -152,7 +122,8 @@ void tst_QDBusInterface::initTestCase() QDBusConnection &con = QDBus::sessionBus(); QVERIFY(con.isConnected()); - con.registerObject("/", &obj, QDBusConnection::ExportAdaptors | QDBusConnection::ExportSlots); + con.registerObject("/", &obj, QDBusConnection::ExportAdaptors | QDBusConnection::ExportSlots | + QDBusConnection::ExportChildObjects); } void tst_QDBusInterface::call_data() @@ -241,7 +212,7 @@ void tst_QDBusInterface::call() QDBusMessage reply; // try first callWithArgs: - reply = iface->callWithArgs(method, input); + reply = iface->callWithArgs(method, input, QDBusInterface::UseEventLoop); QCOMPARE(reply.type(), QDBusMessage::ReplyMessage); if (!output.isEmpty()) { @@ -251,20 +222,20 @@ void tst_QDBusInterface::call() // try the template methods if (input.isEmpty()) - reply = iface->call(method); + reply = iface->call(QDBusInterface::UseEventLoop, method); else if (input.count() == 1) switch (input.at(0).type()) { case QVariant::Int: - reply = iface->call(method, input.at(0).toInt()); + reply = iface->call(QDBusInterface::UseEventLoop, method, input.at(0).toInt()); break; case QVariant::UInt: - reply = iface->call(method, input.at(0).toUInt()); + reply = iface->call(QDBusInterface::UseEventLoop, method, input.at(0).toUInt()); break; case QVariant::String: - reply = iface->call(method, input.at(0).toString()); + reply = iface->call(QDBusInterface::UseEventLoop, method, input.at(0).toString()); break; default: @@ -272,7 +243,7 @@ void tst_QDBusInterface::call() break; } else - reply = iface->call(method, input.at(0).toString(), input.at(1).toString()); + reply = iface->call(QDBusInterface::UseEventLoop, method, input.at(0).toString(), input.at(1).toString()); QCOMPARE(reply.type(), QDBusMessage::ReplyMessage); if (!output.isEmpty()) { -- cgit