dbus/test/qt Makefile.am, 1.5, 1.6 common.h, 1.1, 1.2 ping.cpp, 1.1, 1.2 qpong.cpp, 1.1, 1.2 tst_qdbusabstractadaptor.cpp, 1.1, 1.2 tst_qdbusconnection.cpp, 1.5, 1.6 tst_qdbusinterface.cpp, 1.2, 1.3 tst_qdbusobject.cpp, 1.2, NONE tst_qdbustype.cpp, 1.2, NONE tst_qdbusxmlparser.cpp, 1.2, NONE

Thiago J. Macieira thiago at kemper.freedesktop.org
Tue Mar 28 10:59:00 PST 2006


Update of /cvs/dbus/dbus/test/qt
In directory kemper:/tmp/cvs-serv23600/test/qt

Modified Files:
	Makefile.am common.h ping.cpp qpong.cpp 
	tst_qdbusabstractadaptor.cpp tst_qdbusconnection.cpp 
	tst_qdbusinterface.cpp 
Removed Files:
	tst_qdbusobject.cpp tst_qdbustype.cpp tst_qdbusxmlparser.cpp 
Log Message:
	* test/qt/*: Sync with KDE Subversion revision 523647.
        Update the testcases to the new API. Remove testcases for
        classes that are no longer public or have been removed.


Index: Makefile.am
===================================================================
RCS file: /cvs/dbus/dbus/test/qt/Makefile.am,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Makefile.am	6 Mar 2006 14:30:52 -0000	1.5
+++ Makefile.am	28 Mar 2006 18:58:58 -0000	1.6
@@ -1,33 +1,26 @@
 INCLUDES=-I$(top_srcdir) -I$(top_srcdir)/qt $(DBUS_CLIENT_CFLAGS) $(DBUS_QT_CFLAGS) $(DBUS_QTESTLIB_CFLAGS) -DDBUS_COMPILATION
 
 if DBUS_BUILD_TESTS
-TEST_BINARIES=qdbustype qdbusxmlparser qdbusconnection qpong ping qdbusobject qdbusinterface qdbusabstractadaptor hal
+TEST_BINARIES=qdbusconnection qpong ping qdbusinterface qdbusabstractadaptor hal
 TESTS=
 else
 TEST_BINARIES=
 TESTS=
 endif
 
-
 noinst_PROGRAMS= $(TEST_BINARIES)
 
 qpong_SOURCES= qpong.cpp
 ping_SOURCES= ping.cpp
 qdbusconnection_SOURCES= tst_qdbusconnection.cpp
-qdbusobject_SOURCES= tst_qdbusobject.cpp
 qdbusinterface_SOURCES= tst_qdbusinterface.cpp
-qdbustype_SOURCES= tst_qdbustype.cpp
-qdbusxmlparser_SOURCES= tst_qdbusxmlparser.cpp common.h
 qdbusabstractadaptor_SOURCES= tst_qdbusabstractadaptor.cpp common.h
 hal_SOURCES = tst_hal.cpp
 
 qpong.o: qpong.moc
 ping.o: ping.moc
 tst_qdbusconnection.o: tst_qdbusconnection.moc
-tst_qdbusobject.o: tst_qdbusobject.moc
 tst_qdbusinterface.o: tst_qdbusinterface.moc
-tst_qdbustype.o: tst_qdbustype.moc
-tst_qdbusxmlparser.o: tst_qdbusxmlparser.moc
 tst_qdbusabstractadaptor.o: tst_qdbusabstractadaptor.moc
 tst_hal.o: tst_hal.moc
 
@@ -38,4 +31,5 @@
 
 LDADD=$(TEST_LIBS)
 
-CLEANFILES=tst_qdbusconnection.moc
+clean-local:
+	-rm *.moc

Index: common.h
===================================================================
RCS file: /cvs/dbus/dbus/test/qt/common.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- common.h	6 Mar 2006 14:30:52 -0000	1.1
+++ common.h	28 Mar 2006 18:58:58 -0000	1.2
@@ -1,3 +1,17 @@
+#include <math.h>               // isnan
+
+Q_DECLARE_METATYPE(QVariant)
+Q_DECLARE_METATYPE(QList<bool>)
+Q_DECLARE_METATYPE(QList<short>)
+Q_DECLARE_METATYPE(QList<ushort>)
+Q_DECLARE_METATYPE(QList<int>)
+Q_DECLARE_METATYPE(QList<uint>)
+Q_DECLARE_METATYPE(QList<qlonglong>)
+Q_DECLARE_METATYPE(QList<qulonglong>)
+Q_DECLARE_METATYPE(QList<double>)
+#if 0
+#include "../qdbusintrospection_p.h"
+
 // just to make it easier:
 typedef QDBusIntrospection::Interfaces InterfaceMap;
 typedef QDBusIntrospection::Objects ObjectMap;
@@ -17,7 +31,7 @@
 inline QDBusIntrospection::Argument arg(const char* type, const char *name = 0)
 {
     QDBusIntrospection::Argument retval;
-    retval.type = QDBusType(type);
+    retval.type = QLatin1String(type);
     retval.name = QLatin1String(name);
     return retval;
 }
@@ -40,12 +54,10 @@
     QString result = "method " + m.name + "(";
     foreach (QDBusIntrospection::Argument arg, m.inputArgs)
         result += QString("in %1 %2, ")
-        .arg(arg.type.toString(QDBusType::ConventionalNames))
-        .arg(arg.name);
+        .arg(arg.type, arg.name);
     foreach (QDBusIntrospection::Argument arg, m.outputArgs)
         result += QString("out %1 %2, ")
-        .arg(arg.type.toString(QDBusType::ConventionalNames))
-        .arg(arg.name);
+        .arg(arg.type, arg.name);
     AnnotationsMap::const_iterator it = m.annotations.begin();
     for ( ; it != m.annotations.end(); ++it)
         result += QString("%1 \"%2\", ").arg(it.key()).arg(it.value());
@@ -59,8 +71,7 @@
     QString result = "signal " + s.name + "(";
     foreach (QDBusIntrospection::Argument arg, s.outputArgs)
         result += QString("out %1 %2, ")
-        .arg(arg.type.toString(QDBusType::ConventionalNames))
-        .arg(arg.name);
+        .arg(arg.type, arg.name);
     AnnotationsMap::const_iterator it = s.annotations.begin();
     for ( ; it != s.annotations.end(); ++it)
         result += QString("%1 \"%2\", ").arg(it.key()).arg(it.value());
@@ -78,7 +89,7 @@
         result = "property write %1 %2, ";
     else
         result = "property readwrite %1 %2, ";
-    result = result.arg(p.type.toString(QDBusType::ConventionalNames)).arg(p.name);
+    result = result.arg(p.type, p.name);
     
     AnnotationsMap::const_iterator it = p.annotations.begin();
     for ( ; it != p.annotations.end(); ++it)
@@ -125,3 +136,109 @@
         return printableMap(map);
     }
 }
+#endif
+bool compare(const QVariantList &l1, const QVariantList &l2);
+bool compare(const QVariantMap &m1, const QVariantMap &m2);
+bool compare(const QVariant &v1, const QVariant &v2);
+
+bool compare(const QList<double> &l1, const QList<double> &l2)
+{
+    if (l1.count() != l2.count())
+        return false;
+
+    QList<double>::ConstIterator it1 = l1.constBegin();
+    QList<double>::ConstIterator it2 = l2.constBegin();
+    QList<double>::ConstIterator end = l1.constEnd();
+    for ( ; it1 != end; ++it1, ++it2)
+        if (isnan(*it1) && isnan(*it2))
+            continue;
+        else if (*it1 != *it2)
+            return false;
+    return true;
+}
+
+bool compare(const QVariant &v1, const QVariant &v2)
+{
+    if (v1.userType() != v2.userType())
+        return false;
+
+    int id = v1.userType();
+    if (id == QVariant::List)
+        return compare(v1.toList(), v2.toList());
+
+    else if (id == QVariant::Map)
+        return compare(v1.toMap(), v2.toMap());
+
+    else if (id < int(QVariant::UserType)) // yes, v1.type()
+        // QVariant can compare
+        return v1 == v2;
+
+    else if (id == QMetaType::UChar)
+        return qvariant_cast<uchar>(v1) == qvariant_cast<uchar>(v2);
+
+    else if (id == QMetaType::Short)
+        return qvariant_cast<short>(v1) == qvariant_cast<short>(v2);
+
+    else if (id == QMetaType::UShort)
+        return qvariant_cast<ushort>(v1) == qvariant_cast<ushort>(v2);
+    
+    else if (id == qMetaTypeId<QVariant>())
+        return compare(qvariant_cast<QVariant>(v1), qvariant_cast<QVariant>(v2));
+
+    else if (id == qMetaTypeId<QList<bool> >()) 
+        return qvariant_cast<QList<bool> >(v1) == qvariant_cast<QList<bool> >(v2);
+
+    else if (id == qMetaTypeId<QList<short> >())
+        return qvariant_cast<QList<short> >(v1) == qvariant_cast<QList<short> >(v2);
+
+    else if (id == qMetaTypeId<QList<ushort> >())
+        return qvariant_cast<QList<ushort> >(v1) == qvariant_cast<QList<ushort> >(v2);
+
+    else if (id == qMetaTypeId<QList<int> >())
+        return qvariant_cast<QList<int> >(v1) == qvariant_cast<QList<int> >(v2);
+
+    else if (id == qMetaTypeId<QList<uint> >())
+        return qvariant_cast<QList<uint> >(v1) == qvariant_cast<QList<uint> >(v2);
+
+    else if (id == qMetaTypeId<QList<qlonglong> >())
+        return qvariant_cast<QList<qlonglong> >(v1) == qvariant_cast<QList<qlonglong> >(v2);
+
+    else if (id == qMetaTypeId<QList<qulonglong> >())
+        return qvariant_cast<QList<qulonglong> >(v2) == qvariant_cast<QList<qulonglong> >(v2);
+
+    else if (id == qMetaTypeId<QList<double> >())
+        return compare(qvariant_cast<QList<double> >(v1), qvariant_cast<QList<double> >(v2));
+
+    else
+        return false;           // unknown type
+}
+
+bool compare(const QVariantList &l1, const QVariantList &l2)
+{
+    if (l1.count() != l2.size())
+        return false;
+    QVariantList::ConstIterator i1 = l1.constBegin();
+    QVariantList::ConstIterator i2 = l2.constBegin();
+    QVariantList::ConstIterator end = l1.constEnd();
+    for ( ; i1 != end; ++i1, ++i2) {
+        if (!compare(*i1, *i2))
+            return false;
+    }
+    return true;
+}
+
+bool compare(const QVariantMap &m1, const QVariantMap &m2)
+{
+    if (m1.count() != m2.size())
+        return false;
+    QVariantMap::ConstIterator i1 = m1.constBegin();
+    QVariantMap::ConstIterator end = m1.constEnd();
+    for ( ; i1 != end; ++i1) {
+        QVariantMap::ConstIterator i2 = m2.find(i1.key());
+        if (i2 == m2.constEnd())
+            return false;
+        if (!compare(*i1, *i2))
+            return false;
+    }
+    return true;
+}

Index: ping.cpp
===================================================================
RCS file: /cvs/dbus/dbus/test/qt/ping.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ping.cpp	6 Mar 2006 14:30:52 -0000	1.1
+++ ping.cpp	28 Mar 2006 18:58:58 -0000	1.2
@@ -1,8 +1,9 @@
-#define DBUS_API_SUBJECT_TO_CHANGE
 #include <QtCore/QtCore>
 #include <QtTest/QtTest>
 #include <dbus/qdbus.h>
 
+#include "common.h"
+
 class Ping: public QObject
 {
     Q_OBJECT
@@ -12,8 +13,23 @@
     void cleanupTestCase();
 
 private slots:
-    void sendPing_data();
-    void sendPing();
+    void sendBasic_data();
+    void sendBasic();
+
+    void sendVariant_data();
+    void sendVariant();
+
+    void sendArrays_data();
+    void sendArrays();
+
+    void sendArrayOfArrays_data();
+    void sendArrayOfArrays();
+
+    void sendStringMap_data();
+    void sendStringMap();
+
+    void sendStringMapOfMap_data();
+    void sendStringMapOfMap();
 
 private:
     QProcess proc;
@@ -31,75 +47,137 @@
     proc.close();
 }
 
-Q_DECLARE_METATYPE(QVariant)
-
-void Ping::sendPing_data()
+void Ping::sendBasic_data()
 {
     QTest::addColumn<QVariant>("value");
+    QTest::addColumn<QString>("sig");
 
-    QTest::newRow("string") << QVariant("ping");
-    QTest::newRow("int") << QVariant(1);
-    QTest::newRow("double") << QVariant(42.5);
+    // basic types:
+    QTest::newRow("bool") << QVariant(false) << "b";
+    QTest::newRow("bool2") << QVariant(true) << "b";
+    QTest::newRow("byte") << qVariantFromValue(uchar(1)) << "y";
+    QTest::newRow("int16") << qVariantFromValue(short(2)) << "n";
+    QTest::newRow("uint16") << qVariantFromValue(ushort(3)) << "q";
+    QTest::newRow("int") << QVariant(1) << "i";
+    QTest::newRow("uint") << QVariant(2U) << "u";
+    QTest::newRow("int64") << QVariant(Q_INT64_C(3)) << "x";
+    QTest::newRow("uint64") << QVariant(Q_UINT64_C(4)) << "t";
+    QTest::newRow("double") << QVariant(42.5) << "d";
+    QTest::newRow("string") << QVariant("ping") << "s";
+    QTest::newRow("emptystring") << QVariant("") << "s";
+}
+
+void Ping::sendVariant_data()
+{
+    sendBasic_data();
+
+    // add a few more:
+    QVariant nested(1);
+    QTest::newRow("variant") << nested << "v";
+
+    QVariant nested2;
+    qVariantSetValue(nested2, nested);
+    QTest::newRow("variant-variant") << nested2 << "v";
+}
 
+void Ping::sendArrays_data()
+{
+    QTest::addColumn<QVariant>("value");
+    QTest::addColumn<QString>("sig");
+
+    // arrays:
     QStringList strings;
+    QTest::newRow("emptystringlist") << QVariant(strings) << "as";
     strings << "hello" << "world";
-    QTest::newRow("stringlist") << QVariant(strings);
+    QTest::newRow("stringlist") << QVariant(strings) << "as";
 
-    QList<QVariant> ints;
-    ints << 42 << -43 << 44 << 45;
-    QTest::newRow("intlist") << QVariant(ints);
+    QByteArray bytearray("");   // empty, not null
+    QTest::newRow("emptybytearray") << QVariant(bytearray) << "ay";
+    bytearray = "foo";
+    QTest::newRow("bytearray") << QVariant(bytearray) << "ay";
 
-    QList<QVariant> uints;
-    uints << uint(12) << uint(13) << uint(14);
-    QTest::newRow("uintlist") << QVariant(uints);
+    QList<bool> bools; 
+    QTest::newRow("emptyboollist") << qVariantFromValue(bools) << "ab";
+    bools << false << true << false;
+    QTest::newRow("boollist") << qVariantFromValue(bools) << "ab";
 
-    QList<QVariant> llints;
-    llints << Q_INT64_C(99) << Q_INT64_C(-100);
-    QTest::newRow("llintlist") << QVariant(llints);
+    QList<short> shorts;
+    QTest::newRow("emptyshortlist") << qVariantFromValue(shorts) << "an";
+    shorts << 42 << -43 << 44 << 45 << -32768 << 32767;
+    QTest::newRow("shortlist") << qVariantFromValue(shorts) << "an";
 
-    QList<QVariant> ullints;
-    ullints << Q_UINT64_C(66) << Q_UINT64_C(67);
-    QTest::newRow("ullintlist") << QVariant(ullints);
+    QList<ushort> ushorts;
+    QTest::newRow("emptyushortlist") << qVariantFromValue(ushorts) << "aq";
+    ushorts << 12u << 13u << 14u << 15 << 65535;
+    QTest::newRow("ushortlist") << qVariantFromValue(ushorts) << "aq";
 
-    QList<QVariant> doubles;
-    doubles << 1.2 << 2.2 << 4.4;
-    QTest::newRow("doublelist") << QVariant(doubles);
+    QList<int> ints;
+    QTest::newRow("emptyintlist") << qVariantFromValue(ints) << "ai";
+    ints << 42 << -43 << 44 << 45 << 2147483647 << -2147483647-1;
+    QTest::newRow("intlist") << qVariantFromValue(ints) << "ai";
 
-    QList<QVariant> stackedInts;
-    stackedInts << 4 << ints << 5;
-    QTest::newRow("stackedInts") << QVariant(stackedInts);
+    QList<uint> uints;
+    QTest::newRow("emptyuintlist") << qVariantFromValue(uints) << "au";
+    uints << uint(12) << uint(13) << uint(14) << 4294967295U;
+    QTest::newRow("uintlist") << qVariantFromValue(uints) << "au";
 
-    QList<QVariant> stackedUInts;
-    stackedUInts << uint(3) << uints << uint(4);
-    QTest::newRow("stackedUInts") << QVariant(stackedUInts);
+    QList<qlonglong> llints;
+    QTest::newRow("emptyllintlist") << qVariantFromValue(llints) << "ax";
+    llints << Q_INT64_C(99) << Q_INT64_C(-100)
+           << Q_INT64_C(-9223372036854775807)-1 << Q_INT64_C(9223372036854775807);
+    QTest::newRow("llintlist") << qVariantFromValue(llints) << "ax";
 
-    QList<QVariant> stackedLlints;
-    stackedLlints << Q_INT64_C(49) << llints << Q_INT64_C(-160);
-    QTest::newRow("stackedLlintlist") << QVariant(stackedLlints);
+    QList<qulonglong> ullints;
+    QTest::newRow("emptyullintlist") << qVariantFromValue(ullints) << "at";
+    ullints << Q_UINT64_C(66) << Q_UINT64_C(67)
+            << Q_UINT64_C(18446744073709551615);
+    QTest::newRow("ullintlist") << qVariantFromValue(ullints) << "at";
 
-    QList<QVariant> stackedUllints;
-    stackedUllints << Q_UINT64_C(56) << ullints << Q_UINT64_C(57);
-    QTest::newRow("stackedullintlist") << QVariant(stackedUllints);
+    QList<double> doubles;
+    QTest::newRow("emptydoublelist") << qVariantFromValue(doubles) << "ad";
+    doubles << 1.2 << 2.2 << 4.4
+            << -std::numeric_limits<double>::infinity()
+            << std::numeric_limits<double>::infinity()
+            << std::numeric_limits<double>::quiet_NaN();
+    QTest::newRow("doublelist") << qVariantFromValue(doubles) << "ad";
 
-    QList<QVariant> stackedDoubles;
-    stackedDoubles << 6.2 << doubles << 6.4;
-    QTest::newRow("stackedDoublelist") << QVariant(stackedDoubles);
+    QVariantList variants;
+    QTest::newRow("emptyvariantlist") << QVariant(variants) << "av";
+    variants << QString("Hello") << QByteArray("World") << 42 << -43.0 << 44U << Q_INT64_C(-45)
+             << Q_UINT64_C(46) << true << qVariantFromValue(short(-47));
+    for (int i = 0; i < variants.count(); ++i) {
+        QVariant tmp = variants.at(i);
+        qVariantSetValue(variants[i], tmp);
+    }
+    QTest::newRow("variantlist") << QVariant(variants) << "av";
+}
 
-    QMap<QString, QVariant> map;
-    map["foo"] = "bar";
-    map["kde"] = "great";
-    QTest::newRow("map") << QVariant(map);
-    
-    QList<QVariant> byteArrays;
-    byteArrays << QByteArray("test1") << QByteArray("t2");
-    QTest::newRow("bytearray") << QVariant(byteArrays);
-    
-    QList<QVariant> lists;
-    lists << QVariant(byteArrays) << QVariant(byteArrays);
-    QTest::newRow("listoflists") << QVariant(lists);
+void Ping::sendArrayOfArrays_data()
+{
+    sendArrays_data();
 }
 
-void Ping::sendPing()
+void Ping::sendStringMap_data()
+{
+    sendBasic_data();
+
+    QVariant nested;
+    qVariantSetValue(nested, QVariant(1));
+    QTest::newRow("variant") << nested << "v";
+
+    QVariant nested2;
+    qVariantSetValue(nested2, nested);
+    QTest::newRow("variant-variant") << nested2 << "v";
+
+    sendArrays_data();
+}
+
+void Ping::sendStringMapOfMap_data()
+{
+    sendStringMap_data();
+}
+
+void Ping::sendBasic()
 {
     QFETCH(QVariant, value);
 
@@ -115,9 +193,134 @@
  //   qDebug() << reply;
 
     QCOMPARE(reply.count(), msg.count());
+    QTEST(reply.signature(), "sig");
     for (int i = 0; i < reply.count(); ++i)
-        QCOMPARE(reply.at(i), msg.at(i));
+        QVERIFY(compare(reply.at(i), msg.at(i)));
+}
+
+void Ping::sendVariant()
+{
+    QFETCH(QVariant, value);
+    QVariant tmp = value;
+    qVariantSetValue(value, tmp);
+
+    QDBusConnection &con = QDBus::sessionBus();
+
+    QVERIFY(con.isConnected());
+
+    QDBusMessage msg = QDBusMessage::methodCall("org.kde.selftest",
+            "/org/kde/selftest", "org.kde.selftest", "ping");
+    msg << value;
+
+    QDBusMessage reply = con.sendWithReply(msg);
+ //   qDebug() << reply;
+
+    QCOMPARE(reply.count(), msg.count());
+    QCOMPARE(reply.signature(), QString("v"));
+    for (int i = 0; i < reply.count(); ++i)
+        QVERIFY(compare(reply.at(i), msg.at(i)));
 }
 
+void Ping::sendArrays()
+{
+    QFETCH(QVariant, value);
+
+    QDBusConnection &con = QDBus::sessionBus();
+
+    QVERIFY(con.isConnected());
+
+    QDBusMessage msg = QDBusMessage::methodCall("org.kde.selftest",
+            "/org/kde/selftest", "org.kde.selftest", "ping");
+    msg << value;
+
+    QDBusMessage reply = con.sendWithReply(msg);
+ //   qDebug() << reply;
+
+    QCOMPARE(reply.count(), msg.count());
+    QTEST(reply.signature(), "sig");
+    for (int i = 0; i < reply.count(); ++i)
+        QVERIFY(compare(reply.at(i), msg.at(i)));
+}
+
+void Ping::sendArrayOfArrays()
+{
+    QFETCH(QVariant, value);
+
+    QDBusConnection &con = QDBus::sessionBus();
+
+    QVERIFY(con.isConnected());
+
+    QDBusMessage msg = QDBusMessage::methodCall("org.kde.selftest",
+            "/org/kde/selftest", "org.kde.selftest", "ping");
+    msg << QVariant(QVariantList() << value << value);
+
+    QDBusMessage reply = con.sendWithReply(msg);
+ //   qDebug() << reply;
+
+    QCOMPARE(reply.count(), msg.count());
+    QFETCH(QString, sig);
+    QCOMPARE(reply.signature(), "a" + sig);
+    for (int i = 0; i < reply.count(); ++i)
+        QVERIFY(compare(reply.at(i), msg.at(i)));
+}
+
+void Ping::sendStringMap()
+{
+    QFETCH(QVariant, value);
+
+    QDBusConnection &con = QDBus::sessionBus();
+
+    QVERIFY(con.isConnected());
+
+    QDBusMessage msg = QDBusMessage::methodCall("org.kde.selftest",
+            "/org/kde/selftest", "org.kde.selftest", "ping");
+
+    QVariantMap map;
+    map["foo"] = value;
+    map["bar"] = value;
+    msg << QVariant(map);
+
+    QDBusMessage reply = con.sendWithReply(msg);
+ //   qDebug() << reply;
+
+    QCOMPARE(reply.count(), msg.count());
+    QFETCH(QString, sig);
+    QCOMPARE(reply.signature(), "a{s" + sig + "}");
+    for (int i = 0; i < reply.count(); ++i)
+        QVERIFY(compare(reply.at(i), msg.at(i)));
+}
+
+void Ping::sendStringMapOfMap()
+{
+    QFETCH(QVariant, value);
+
+    QDBusConnection &con = QDBus::sessionBus();
+
+    QVERIFY(con.isConnected());
+
+    QDBusMessage msg = QDBusMessage::methodCall("org.kde.selftest",
+            "/org/kde/selftest", "org.kde.selftest", "ping");
+
+    QVariantMap map;
+    map["foo"] = value;
+    map["bar"] = value;
+
+    QVariantMap map2;
+    map2["foo"] = map;
+    msg << QVariant(map2);
+
+    QDBusMessage reply = con.sendWithReply(msg);
+ //   qDebug() << reply;
+
+    QCOMPARE(reply.count(), msg.count());
+    QFETCH(QString, sig);
+    QCOMPARE(reply.signature(), "a{sa{s" + sig + "}}");
+
+    QEXPECT_FAIL("", "libdbus returns an empty set for un unknown reason", Abort);
+    for (int i = 0; i < reply.count(); ++i)
+        QVERIFY(compare(reply.at(i), msg.at(i)));
+}
+
+
 QTEST_MAIN(Ping)
 #include "ping.moc"

Index: qpong.cpp
===================================================================
RCS file: /cvs/dbus/dbus/test/qt/qpong.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- qpong.cpp	6 Mar 2006 14:30:52 -0000	1.1
+++ qpong.cpp	28 Mar 2006 18:58:58 -0000	1.2
@@ -1,6 +1,6 @@
-#define DBUS_API_SUBJECT_TO_CHANGE
 #include <QtCore/QtCore>
 #include <dbus/qdbus.h>
+#include <dbus/dbus.h>
 
 class Pong: public QObject
 {
@@ -11,6 +11,7 @@
     {
         QDBusMessage reply = QDBusMessage::methodReply(msg);
         reply << static_cast<QList<QVariant> >(msg);
+        reply.setSignature(msg.signature());
         if (!msg.connection().send(reply))
             exit(1);
     }
@@ -21,7 +22,13 @@
     QCoreApplication app(argc, argv);
 
     QDBusConnection &con = QDBus::sessionBus();
-    if (!con.requestName("org.kde.selftest"))
+    QDBusMessage msg = QDBusMessage::methodCall(DBUS_SERVICE_DBUS,
+                                                DBUS_PATH_DBUS,
+                                                DBUS_INTERFACE_DBUS,
+                                                "RequestName");
+    msg << "org.kde.selftest" << 0U;
+    msg = con.sendWithReply(msg);
+    if (msg.type() != QDBusMessage::ReplyMessage)
         exit(2);
 
     Pong pong;

Index: tst_qdbusabstractadaptor.cpp
===================================================================
RCS file: /cvs/dbus/dbus/test/qt/tst_qdbusabstractadaptor.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- tst_qdbusabstractadaptor.cpp	6 Mar 2006 14:30:52 -0000	1.1
+++ tst_qdbusabstractadaptor.cpp	28 Mar 2006 18:58:58 -0000	1.2
@@ -3,15 +3,12 @@
 
 #include <QtTest/QtTest>
 
-#define DBUS_API_SUBJECT_TO_CHANGE
 #include <dbus/qdbus.h>
 
 #include "common.h"
 
-Q_DECLARE_METATYPE(QVariant)
-
 const char *slotSpy;
-QString propSpy;
+QString valueSpy;
 
 namespace QTest {
     char *toString(QDBusMessage::MessageType t)
@@ -39,8 +36,6 @@
     Q_OBJECT
 
 private slots:
-    void initTestCase();
-
     void methodCalls_data();
     void methodCalls();
     void signalEmissions_data();
@@ -50,9 +45,9 @@
     void overloadedSignalEmission();
     void readProperties();
     void writeProperties();
-    void adaptorIntrospection_data();
-    void adaptorIntrospection();
-    void objectTreeIntrospection();
+
+    void typeMatching_data();
+    void typeMatching();
 };
 
 class QDBusSignalSpy: public QObject
@@ -88,10 +83,6 @@
 public:
     Interface1(QObject *parent) : QDBusAbstractAdaptor(parent)
     { }
-
-    static QDBusIntrospection::Methods methodData;
-    static QDBusIntrospection::Signals signalData;
-    static QDBusIntrospection::Properties propertyData;
 };
 
 class Interface2: public QDBusAbstractAdaptor
@@ -111,7 +102,7 @@
     { return __PRETTY_FUNCTION__; }
 
     void setProp2(const QString &value)
-    { slotSpy = __PRETTY_FUNCTION__; propSpy = value; }
+    { slotSpy = __PRETTY_FUNCTION__; valueSpy = value; }
 
     void emitSignal(const QString &, const QVariant &)
     { emit signal(); }
@@ -121,11 +112,6 @@
 
 signals:
     void signal();
-
-public:
-    static QDBusIntrospection::Methods methodData;
-    static QDBusIntrospection::Signals signalData;
-    static QDBusIntrospection::Properties propertyData;    
 };
 
 class Interface3: public QDBusAbstractAdaptor
@@ -145,7 +131,7 @@
     { return __PRETTY_FUNCTION__; }
 
     void setProp2(const QString &value)
-    { slotSpy = __PRETTY_FUNCTION__; propSpy = value; }
+    { slotSpy = __PRETTY_FUNCTION__; valueSpy = value; }
 
     void emitSignal(const QString &name, const QVariant &value)
     {
@@ -166,11 +152,6 @@
     void signalVoid();
     void signalInt(int);
     void signalString(const QString &);
-
-public:
-    static QDBusIntrospection::Methods methodData;
-    static QDBusIntrospection::Signals signalData;
-    static QDBusIntrospection::Properties propertyData;    
 };
 
 class Interface4: public QDBusAbstractAdaptor
@@ -190,7 +171,7 @@
     { return __PRETTY_FUNCTION__; }
 
     void setProp2(const QString &value)
-    { slotSpy = __PRETTY_FUNCTION__; propSpy = value; }
+    { slotSpy = __PRETTY_FUNCTION__; valueSpy = value; }
 
     void emitSignal(const QString &, const QVariant &value)
     {
@@ -219,84 +200,228 @@
     void signal();
     void signal(int);
     void signal(const QString &);
-
-public:
-    static QDBusIntrospection::Methods methodData;
-    static QDBusIntrospection::Signals signalData;
-    static QDBusIntrospection::Properties propertyData;    
 };
 
+class MyObject: public QObject
+{
+    Q_OBJECT
+public:
+    Interface1 *if1;
+    Interface2 *if2;
+    Interface3 *if3;
+    Interface4 *if4;
 
-QDBusIntrospection::Methods Interface1::methodData;
-QDBusIntrospection::Signals Interface1::signalData;
-QDBusIntrospection::Properties Interface1::propertyData;    
-QDBusIntrospection::Methods Interface2::methodData;
-QDBusIntrospection::Signals Interface2::signalData;
-QDBusIntrospection::Properties Interface2::propertyData;    
-QDBusIntrospection::Methods Interface3::methodData;
-QDBusIntrospection::Signals Interface3::signalData;
-QDBusIntrospection::Properties Interface3::propertyData;    
-QDBusIntrospection::Methods Interface4::methodData;
-QDBusIntrospection::Signals Interface4::signalData;
-QDBusIntrospection::Properties Interface4::propertyData;
+    MyObject(int n = 4)
+        : if1(0), if2(0), if3(0), if4(0)
+    {
+        switch (n)
+        {
+        case 4:
+            if4 = new Interface4(this);
+        case 3:
+            if3 = new Interface3(this);
+        case 2:
+            if2 = new Interface2(this);
+        case 1:
+            if1 = new Interface1(this);
+        }
+    }
+};        
 
-void tst_QDBusAbstractAdaptor::initTestCase()
+class TypesInterface: public QDBusAbstractAdaptor
 {
-    QDBusIntrospection::Method method;
-    method.name = "Method";
-    Interface2::methodData << method;
-    Interface4::methodData << method;
-    method.inputArgs << arg("i");
-    Interface4::methodData << method;
-    method.inputArgs.clear();
-    method.inputArgs << arg("s");
-    Interface4::methodData << method;
+    Q_OBJECT
+    Q_CLASSINFO("D-Bus Interface", "local.TypesInterface")
+public:
+    TypesInterface(QObject *parent)
+        : QDBusAbstractAdaptor(parent)
+    { }
 
-    method.name = "MethodVoid";
-    method.inputArgs.clear();
-    Interface3::methodData << method;
-    method.name = "MethodInt";
-    method.inputArgs << arg("i");
-    Interface3::methodData << method;
-    method.name = "MethodString";
-    method.inputArgs.clear();
-    method.inputArgs << arg("s");
-    Interface3::methodData << method;
+    union
+    {
+        bool b;
+        uchar uc;
+        short s;
+        ushort us;
+        int i;
+        uint ui;
+        qlonglong ll;
+        qulonglong ull;
+        double d;
+    } dataSpy;
+    QVariant variantSpy;
+    QString stringSpy;
+    QVariantList listSpy;
+    QStringList stringlistSpy;
+    QByteArray bytearraySpy;
+    QVariantMap mapSpy;
 
-    QDBusIntrospection::Signal signal;
-    signal.name = "Signal";
-    Interface2::signalData << signal;
-    Interface4::signalData << signal;
-    signal.outputArgs << arg("i");
-    Interface4::signalData << signal;
-    signal.outputArgs.clear();
-    signal.outputArgs << arg("s");
-    Interface4::signalData << signal;
+public slots:
+    void methodBool(bool b)
+    {
+        slotSpy = __PRETTY_FUNCTION__;
+        dataSpy.b = b;
+    }
 
-    signal.name = "SignalVoid";
-    signal.outputArgs.clear();
-    Interface3::signalData << signal;
-    signal.name = "SignalInt";
-    signal.outputArgs << arg("i");
-    Interface3::signalData << signal;
-    signal.name = "SignalString";
-    signal.outputArgs.clear();
-    signal.outputArgs << arg("s");
-    Interface3::signalData << signal;
+    void methodUChar(uchar uc)
+    {
+        slotSpy = __PRETTY_FUNCTION__;
+        dataSpy.uc = uc;
+    }
 
-    QDBusIntrospection::Property prop;
-    prop.name = "Prop1";
-    prop.type = QDBusType('s');
-    prop.access = QDBusIntrospection::Property::Read;
-    Interface2::propertyData << prop;
-    Interface3::propertyData << prop;
-    Interface4::propertyData << prop;
-    prop.name = "Prop2";
-    prop.access = QDBusIntrospection::Property::ReadWrite;
-    Interface2::propertyData << prop;
-    Interface3::propertyData << prop;
-    Interface4::propertyData << prop;
-}
+    void methodShort(short s)
+    {
+        slotSpy = __PRETTY_FUNCTION__;
+        dataSpy.s = s;
+    }
+
+    void methodUShort(ushort us)
+    {
+        slotSpy = __PRETTY_FUNCTION__;
+        dataSpy.us = us;
+    }
+    
+    void methodInt(int i)
+    {
+        slotSpy = __PRETTY_FUNCTION__;
+        dataSpy.i = i;
+    }
+
+    void methodUInt(uint ui)
+    {
+        slotSpy = __PRETTY_FUNCTION__;
+        dataSpy.ui = ui;
+    }
+
+    void methodLongLong(qlonglong ll)
+    {
+        slotSpy = __PRETTY_FUNCTION__;
+        dataSpy.ll = ll;
+    }
+
+    void methodULongLong(qulonglong ull)
+    {
+        slotSpy = __PRETTY_FUNCTION__;
+        dataSpy.ull = ull;
+    }
+
+    void methodDouble(double d)
+    {
+        slotSpy = __PRETTY_FUNCTION__;
+        dataSpy.d = d;
+    }
+    
+    void methodString(const QString &s)
+    {
+        slotSpy = __PRETTY_FUNCTION__;
+        stringSpy = s;
+    }
+
+    void methodVariant(const QVariant &v)
+    {
+        slotSpy = __PRETTY_FUNCTION__;
+        variantSpy = v;
+    }
+
+    void methodList(const QVariantList &l)
+    {
+        slotSpy = __PRETTY_FUNCTION__;
+        listSpy = l;
+    }
+
+    void methodStringList(const QStringList &sl)
+    {
+        slotSpy = __PRETTY_FUNCTION__;
+        stringlistSpy = sl;
+    }
+
+    void methodByteArray(const QByteArray &ba)
+    {
+        slotSpy = __PRETTY_FUNCTION__;
+        bytearraySpy = ba;
+    }
+    
+    void methodMap(const QVariantMap &m)
+    {
+        slotSpy = __PRETTY_FUNCTION__;
+        mapSpy = m;
+    }
+    
+    bool retrieveBool()
+    {
+        return dataSpy.b;
+    }
+
+    uchar retrieveUChar()
+    {
+        return dataSpy.uc;
+    }
+
+    short retrieveShort()
+    {
+        return dataSpy.s;
+    }
+
+    ushort retrieveUShort()
+    {
+        return dataSpy.us;
+    }
+    
+    int retrieveInt()
+    {
+        return dataSpy.i;
+    }
+
+    uint retrieveUInt()
+    {
+        return dataSpy.ui;
+    }
+
+    qlonglong retrieveLongLong()
+    {
+        return dataSpy.ll;
+    }
+
+    qulonglong retrieveULongLong()
+    {
+        return dataSpy.ull;
+    }
+
+    double retrieveDouble()
+    {
+        return dataSpy.d;
+    }
+    
+    QString retrieveString()
+    {
+        return stringSpy;
+    }
+
+    QVariant retrieveVariant()
+    {
+        return variantSpy;
+    }
+
+    QVariantList retrieveList()
+    {
+        return listSpy;
+    }
+
+    QStringList retrieveStringList()
+    {
+        return stringlistSpy;
+    }
+
+    QByteArray retrieveByteArray()
+    {
+        return bytearraySpy;
+    }
+    
+    QVariantMap retrieveMap()
+    {
+        return mapSpy;
+    }
+};
 
 void tst_QDBusAbstractAdaptor::methodCalls_data()
 {
@@ -313,93 +438,78 @@
     QDBusConnection &con = QDBus::sessionBus();
     QVERIFY(con.isConnected());
 
-    QDBusObject dobj = con.findObject(con.baseService(), "/");
-    QVERIFY(dobj.isValid());
+    //QDBusInterface *empty = con.findInterface(con.baseService(), "/", QString());
+    QDBusInterface *if1 = con.findInterface(con.baseService(), "/", "local.Interface1");
+    QDBusInterface *if2 = con.findInterface(con.baseService(), "/", "local.Interface2");
+    QDBusInterface *if3 = con.findInterface(con.baseService(), "/", "local.Interface3");
+    QDBusInterface *if4 = con.findInterface(con.baseService(), "/", "local.Interface4");
 
-    //QDBusInterface empty(dobj, QString());
-    QDBusInterface if1(dobj, "local.Interface1");
-    QDBusInterface if2(dobj, "local.Interface2");
-    QDBusInterface if3(dobj, "local.Interface3");
-    QDBusInterface if4(dobj, "local.Interface4");
+    QObject deleter;
+    if1->setParent(&deleter);
+    if2->setParent(&deleter);
+    if3->setParent(&deleter);
+    if4->setParent(&deleter);
 
     // must fail: no object
-    //QCOMPARE(empty.call("method").type(), QDBusMessage::ErrorMessage);
-    QCOMPARE(if1.call("method").type(), QDBusMessage::ErrorMessage);
-
-    QObject obj;
-    con.registerObject("/", &obj);
+    //QCOMPARE(empty->call("method").type(), QDBusMessage::ErrorMessage);
+    QCOMPARE(if1->call("method").type(), QDBusMessage::ErrorMessage);
 
     QFETCH(int, nInterfaces);
-    switch (nInterfaces)
-    {
-    case 4:
-        new Interface4(&obj);
-    case 3:
-        new Interface3(&obj);
-    case 2:
-        new Interface2(&obj);
-    case 1:
-        new Interface1(&obj);
-    }
+    MyObject obj(nInterfaces);
+    con.registerObject("/", &obj);
 
     // must fail: no such method
-    QCOMPARE(if1.call("method").type(), QDBusMessage::ErrorMessage);
+    QCOMPARE(if1->call("method").type(), QDBusMessage::ErrorMessage);
     if (!nInterfaces--)
         return;
     if (!nInterfaces--)
         return;
 
     // simple call: one such method exists
-    QCOMPARE(if2.call("method").type(), QDBusMessage::ReplyMessage);
+    QCOMPARE(if2->call("method").type(), QDBusMessage::ReplyMessage);
     QCOMPARE(slotSpy, "void Interface2::method()");
     if (!nInterfaces--)
         return;
 
     // multiple methods in multiple interfaces, no name overlap
-    QCOMPARE(if1.call("methodVoid").type(), QDBusMessage::ErrorMessage);
-    QCOMPARE(if1.call("methodInt").type(), QDBusMessage::ErrorMessage);
-    QCOMPARE(if1.call("methodString").type(), QDBusMessage::ErrorMessage);
-    QCOMPARE(if2.call("methodVoid").type(), QDBusMessage::ErrorMessage);
-    QCOMPARE(if2.call("methodInt").type(), QDBusMessage::ErrorMessage);
-    QCOMPARE(if2.call("methodString").type(), QDBusMessage::ErrorMessage);
+    QCOMPARE(if1->call("methodVoid").type(), QDBusMessage::ErrorMessage);
+    QCOMPARE(if1->call("methodInt").type(), QDBusMessage::ErrorMessage);
+    QCOMPARE(if1->call("methodString").type(), QDBusMessage::ErrorMessage);
+    QCOMPARE(if2->call("methodVoid").type(), QDBusMessage::ErrorMessage);
+    QCOMPARE(if2->call("methodInt").type(), QDBusMessage::ErrorMessage);
+    QCOMPARE(if2->call("methodString").type(), QDBusMessage::ErrorMessage);
 
-    QCOMPARE(if3.call("methodVoid").type(), QDBusMessage::ReplyMessage);
+    QCOMPARE(if3->call("methodVoid").type(), QDBusMessage::ReplyMessage);
     QCOMPARE(slotSpy, "void Interface3::methodVoid()");
-    QCOMPARE(if3.call("methodInt", 42).type(), QDBusMessage::ReplyMessage);
+    QCOMPARE(if3->call("methodInt", 42).type(), QDBusMessage::ReplyMessage);
     QCOMPARE(slotSpy, "void Interface3::methodInt(int)");
-    QCOMPARE(if3.call("methodString", QString("")).type(), QDBusMessage::ReplyMessage);
+    QCOMPARE(if3->call("methodString", QString("")).type(), QDBusMessage::ReplyMessage);
     QCOMPARE(slotSpy, "void Interface3::methodString(QString)");
 
     if (!nInterfaces--)
         return;
 
     // method overloading: different interfaces
-    QCOMPARE(if4.call("method").type(), QDBusMessage::ReplyMessage);
+    QCOMPARE(if4->call("method").type(), QDBusMessage::ReplyMessage);
     QCOMPARE(slotSpy, "void Interface4::method()");
 
     // method overloading: different parameters
-    QCOMPARE(if4.call("method.i", 42).type(), QDBusMessage::ReplyMessage);
+    QCOMPARE(if4->call("method.i", 42).type(), QDBusMessage::ReplyMessage);
     QCOMPARE(slotSpy, "void Interface4::method(int)");
-    QCOMPARE(if4.call("method.s", QString()).type(), QDBusMessage::ReplyMessage);
+    QCOMPARE(if4->call("method.s", QString()).type(), QDBusMessage::ReplyMessage);
     QCOMPARE(slotSpy, "void Interface4::method(QString)");
     
 }
 
-static void emitSignal(QDBusConnection &con, const QString &iface, const QString &name,
+static void emitSignal(MyObject *obj, const QString &iface, const QString &name,
                        const QVariant &parameter)
 {
-    QObject obj;
-    Interface2 *if2 = new Interface2(&obj);
-    Interface3 *if3 = new Interface3(&obj);
-    Interface4 *if4 = new Interface4(&obj);
-    con.registerObject("/",&obj);
-
     if (iface.endsWith('2'))
-        if2->emitSignal(name, parameter);
+        obj->if2->emitSignal(name, parameter);
     else if (iface.endsWith('3'))
-        if3->emitSignal(name, parameter);
+        obj->if3->emitSignal(name, parameter);
     else if (iface.endsWith('4'))
-        if4->emitSignal(name, parameter);
+        obj->if4->emitSignal(name, parameter);
     
     QTest::qWait(200);
 }
@@ -426,22 +536,29 @@
     QDBusConnection &con = QDBus::sessionBus();
     QVERIFY(con.isConnected());
 
-    QDBusObject dobj = con.findObject(con.baseService(), "/");
-    QVERIFY(dobj.isValid());
+    MyObject obj(3);
+    con.registerObject("/", &obj);
 
-    //QDBusInterface empty(dobj, QString());
-    QDBusInterface if2(dobj, "local.Interface2");
-    QDBusInterface if3(dobj, "local.Interface3");
+    //QDBusInterface empty = con.findInterface(con.baseService(), "/", QString());
+    QDBusInterface *if2 = con.findInterface(con.baseService(), "/", "local.Interface2");
+    QDBusInterface *if3 = con.findInterface(con.baseService(), "/", "local.Interface3");
+    QObject deleter;
+    if2->setParent(&deleter);
+    if3->setParent(&deleter);
 
     // connect all signals and emit only one
     {
         QDBusSignalSpy spy;
-        if2.connect("signal", &spy, SLOT(slot(QDBusMessage)));
-        if3.connect("signalVoid", &spy, SLOT(slot(QDBusMessage)));
-        if3.connect("signalInt", &spy, SLOT(slot(QDBusMessage)));
-        if3.connect("signalString", &spy, SLOT(slot(QDBusMessage)));
+        con.connect(con.baseService(), "/", "local.Interface2", "signal",
+                    &spy, SLOT(slot(QDBusMessage)));
+        con.connect(con.baseService(), "/", "local.Interface3", "signalVoid",
+                    &spy, SLOT(slot(QDBusMessage)));
+        con.connect(con.baseService(), "/", "local.Interface3", "signalInt",
+                    &spy, SLOT(slot(QDBusMessage)));
+        con.connect(con.baseService(), "/", "local.Interface3", "signalString",
+                    &spy, SLOT(slot(QDBusMessage)));
         
-        emitSignal(con, interface, name, parameter);
+        emitSignal(&obj, interface, name, parameter);
         
         QCOMPARE(spy.count, 1);
         QCOMPARE(spy.interface, interface);
@@ -454,10 +571,10 @@
     {
         QDBusSignalSpy spy;
         con.connect(con.baseService(), "/", interface, name, &spy, SLOT(slot(QDBusMessage)));
-        emitSignal(con, "local.Interface2", "signal", QVariant());
-        emitSignal(con, "local.Interface3", "signalVoid", QVariant());
-        emitSignal(con, "local.Interface3", "signalInt", QVariant(1));
-        emitSignal(con, "local.Interface3", "signalString", QVariant("foo"));
+        emitSignal(&obj, "local.Interface2", "signal", QVariant());
+        emitSignal(&obj, "local.Interface3", "signalVoid", QVariant());
+        emitSignal(&obj, "local.Interface3", "signalInt", QVariant(1));
+        emitSignal(&obj, "local.Interface3", "signalString", QVariant("foo"));
         
         QCOMPARE(spy.count, 1);
         QCOMPARE(spy.interface, interface);
@@ -472,15 +589,14 @@
     QDBusConnection &con = QDBus::sessionBus();
     QVERIFY(con.isConnected());
 
-    QObject obj;
-    Interface2 *if2 = new Interface2(&obj);
+    MyObject obj(2);
 
     con.registerObject("/p1",&obj);
     con.registerObject("/p2",&obj);
 
     QDBusSignalSpy spy;
     con.connect(con.baseService(), "/p1", "local.Interface2", "signal", &spy, SLOT(slot(QDBusMessage)));
-    if2->emitSignal(QString(), QVariant());
+    obj.if2->emitSignal(QString(), QVariant());
     QTest::qWait(200);
     
     QCOMPARE(spy.count, 1);
@@ -491,7 +607,7 @@
     // now connect the other one
     spy.count = 0;
     con.connect(con.baseService(), "/p2", "local.Interface2", "signal", &spy, SLOT(slot(QDBusMessage)));
-    if2->emitSignal(QString(), QVariant());
+    obj.if2->emitSignal(QString(), QVariant());
     QTest::qWait(200);
     
     QCOMPARE(spy.count, 2);
@@ -511,19 +627,25 @@
     QDBusConnection &con = QDBus::sessionBus();
     QVERIFY(con.isConnected());
 
+    MyObject obj;
+    con.registerObject("/", &obj);
+
     QString interface = "local.Interface4";
     QString name = "signal";
     QFETCH(QVariant, parameter);
-    QDBusInterface if4 = con.findInterface(con.baseService(), "/", interface);
+    //QDBusInterface *if4 = con.findInterface(con.baseService(), "/", interface);
     
     // connect all signals and emit only one
     {
         QDBusSignalSpy spy;
-        if4.connect("signal.", &spy, SLOT(slot(QDBusMessage)));
-        if4.connect("signal.i", &spy, SLOT(slot(QDBusMessage)));
-        if4.connect("signal.s", &spy, SLOT(slot(QDBusMessage)));
+        con.connect(con.baseService(), "/", "local.Interface4", "signal", "",
+                    &spy, SLOT(slot(QDBusMessage)));
+        con.connect(con.baseService(), "/", "local.Interface4", "signal", "i",
+                    &spy, SLOT(slot(QDBusMessage)));
+        con.connect(con.baseService(), "/", "local.Interface4", "signal", "s",
+                    &spy, SLOT(slot(QDBusMessage)));
         
-        emitSignal(con, interface, name, parameter);
+        emitSignal(&obj, interface, name, parameter);
         
         QCOMPARE(spy.count, 1);
         QCOMPARE(spy.interface, interface);
@@ -537,9 +659,9 @@
     {
         QDBusSignalSpy spy;
         con.connect(con.baseService(), "/", interface, name, signature, &spy, SLOT(slot(QDBusMessage)));
-        emitSignal(con, "local.Interface4", "signal", QVariant());
-        emitSignal(con, "local.Interface4", "signal", QVariant(1));
-        emitSignal(con, "local.Interface4", "signal", QVariant("foo"));
+        emitSignal(&obj, "local.Interface4", "signal", QVariant());
+        emitSignal(&obj, "local.Interface4", "signal", QVariant(1));
+        emitSignal(&obj, "local.Interface4", "signal", QVariant("foo"));
         
         QCOMPARE(spy.count, 1);
         QCOMPARE(spy.interface, interface);
@@ -554,24 +676,21 @@
     QDBusConnection &con = QDBus::sessionBus();
     QVERIFY(con.isConnected());
 
-    QObject obj;
-    new Interface2(&obj);
-    new Interface3(&obj);
-    new Interface4(&obj);
+    MyObject obj;
     con.registerObject("/", &obj);
 
     for (int i = 2; i <= 4; ++i) {
         QString name = QString("Interface%1").arg(i);
-        QDBusInterface iface = con.findInterface(con.baseService(), "/", "local." + name);
+        QDBusInterface *iface = con.findInterface(con.baseService(), "/", "local." + name);
 
         for (int j = 1; j <= 2; ++j) {
             QString propname = QString("prop%1").arg(j);
-            QDBusVariant value = iface.property(propname);
+            QVariant value = iface->property(propname.toLatin1());
 
-            QVERIFY(value.type == QDBusType('s'));
-            QVERIFY(value.value.type() == QVariant::String);
-            QCOMPARE(value.value.toString(), QString("QString %1::%2() const").arg(name, propname));
+            QCOMPARE(value.userType(), int(QVariant::String));
+            QCOMPARE(value.toString(), QString("QString %1::%2() const").arg(name, propname));
         }
+        iface->deleteLater();
     }
 }
 
@@ -580,28 +699,28 @@
     QDBusConnection &con = QDBus::sessionBus();
     QVERIFY(con.isConnected());
 
-    QObject obj;
-    new Interface2(&obj);
-    new Interface3(&obj);
-    new Interface4(&obj);
+    MyObject obj;
     con.registerObject("/", &obj);
 
     for (int i = 2; i <= 4; ++i) {
         QString name = QString("Interface%1").arg(i);
-        QDBusInterface iface = con.findInterface(con.baseService(), "/", "local." + name);
+        QDBusInterface *iface = con.findInterface(con.baseService(), "/", "local." + name);
 
-        QDBusVariant value(name);
+        QVariant value(name);
 
-        propSpy.clear();
-        iface.setProperty("prop1", value);
-        QVERIFY(propSpy.isEmpty()); // call mustn't have succeeded
+        valueSpy.clear();
+        iface->setProperty("prop1", value);
+        QVERIFY(valueSpy.isEmpty()); // call mustn't have succeeded
 
-        iface.setProperty("prop2", value);
-        QCOMPARE(propSpy, name);
+        iface->setProperty("prop2", value);
+        QCOMPARE(valueSpy, name);
         QCOMPARE(QString(slotSpy), QString("void %1::setProp2(const QString&)").arg(name));
+
+        iface->deleteLater();
     }
 }
 
+#if 0
 void tst_QDBusAbstractAdaptor::adaptorIntrospection_data()
 {
     methodCalls_data();
@@ -785,7 +904,79 @@
             QDBusIntrospection::parseObject(xml);
         QVERIFY(!tree.childObjects.contains("q"));
     }
-}    
+}
+#endif
+
+static inline QVariant nest(const QVariant& v)
+{
+    QVariant ret;
+    qVariantSetValue(ret, v);
+    return ret;
+}
+
+void tst_QDBusAbstractAdaptor::typeMatching_data()
+{
+    QTest::addColumn<QString>("basename");
+    QTest::addColumn<QString>("signature");
+    QTest::addColumn<QVariant>("value");
+
+    QTest::newRow("bool") << "Bool" << "b" << QVariant(true);
+    QTest::newRow("byte") << "UChar" << "y" << qVariantFromValue(uchar(42));
+    QTest::newRow("short") << "Short" << "n" << qVariantFromValue(short(-43));
+    QTest::newRow("ushort") << "UShort" << "q" << qVariantFromValue(ushort(44));
+    QTest::newRow("int") << "Int" << "i" << QVariant(42);
+    QTest::newRow("uint") << "UInt" << "u" << QVariant(42U);
+    QTest::newRow("qlonglong") << "LongLong" << "x" << QVariant(Q_INT64_C(42));
+    QTest::newRow("qulonglong") << "ULongLong" << "t" << QVariant(Q_UINT64_C(42));
+    QTest::newRow("double") << "Double" << "d" << QVariant(2.5);
+    QTest::newRow("string") << "String" << "s" << QVariant("Hello, World!");
+
+    QTest::newRow("variant") << "Variant" << "v" << nest(QVariant("Hello again!"));
+    QTest::newRow("list") << "List" << "av" << QVariant(QVariantList()
+                                                        << nest(42)
+                                                        << nest(QString("foo"))
+                                                        << nest(QByteArray("bar"))
+                                                        << nest(nest(QString("baz"))));
+    QTest::newRow("stringlist") << "StringList" << "as" << QVariant(QStringList() << "Hello" << "world");
+    QTest::newRow("bytearray") << "ByteArray" << "ay" << QVariant(QByteArray("foo"));
+
+    QVariantMap map;
+    map["one"] = nest(1);       // int
+    map["The answer to life, the Universe and everything"] = nest(42u); // uint
+    map["In the beginning..."] = nest(QString("There was nothing")); // string
+    map["but Unix came and said"] = nest(QByteArray("\"Hello, World\"")); // bytearray
+    map["two"] = nest(qVariantFromValue(short(2))); // short
+    QTest::newRow("map") << "Map" << "a{sv}" << QVariant(map);
+}
+
+void tst_QDBusAbstractAdaptor::typeMatching()
+{
+    QObject obj;
+    new TypesInterface(&obj);
+
+    QDBusConnection &con = QDBus::sessionBus();
+    con.registerObject("/types", &obj);
+
+    QFETCH(QString, basename);
+    QFETCH(QString, signature);
+    QFETCH(QVariant, value);
+
+    QDBusMessage reply;
+    QDBusInterface *iface = con.findInterface(con.baseService(), "/types", "local.TypesInterface");
+
+    reply = iface->callWithArgs("method" + basename + '.' + signature, QVariantList() << value);
+    QCOMPARE(reply.type(), QDBusMessage::ReplyMessage);
+
+    reply = iface->call("retrieve" + basename);
+    QCOMPARE(reply.type(), QDBusMessage::ReplyMessage);
+    QCOMPARE(reply.count(), 1);
+
+    const QVariant &retval = reply.at(0);
+    QCOMPARE(retval.userType(), value.userType());
+    QVERIFY(compare(retval, value));
+
+    iface->deleteLater();
+}
 
 QTEST_MAIN(tst_QDBusAbstractAdaptor)
 

Index: tst_qdbusconnection.cpp
===================================================================
RCS file: /cvs/dbus/dbus/test/qt/tst_qdbusconnection.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- tst_qdbusconnection.cpp	6 Mar 2006 14:30:52 -0000	1.5
+++ tst_qdbusconnection.cpp	28 Mar 2006 18:58:58 -0000	1.6
@@ -3,7 +3,6 @@
 
 #include <QtTest/QtTest>
 
-#define DBUS_API_SUBJECT_TO_CHANGE
 #include <dbus/qdbus.h>
 
 class MyObject: public QObject
@@ -28,12 +27,6 @@
     void send();
     void sendAsync();
     void sendSignal();
-    void requestName_data();
-    void requestName();
-    void getNameOwner_data();
-    void getNameOwner();
-    void releaseName_data();
-    void releaseName();
 
     void registerObject();
 
@@ -159,89 +152,6 @@
     }
 }
 
-void tst_QDBusConnection::requestName_data()
-{
-    QTest::addColumn<QString>("requestedName");
-    QTest::addColumn<int>("flags");
-    QTest::addColumn<bool>("expectedResult");
-
-    QTest::newRow("null") << QString() << (int)QDBusConnection::NoReplace << false;
-    QTest::newRow("empty") << QString("") << (int)QDBusConnection::NoReplace << false;
-    QTest::newRow("invalid") << "./invalid name" << (int)QDBusConnection::NoReplace << false;
-//    QTest::newRow("existing") << "org.freedesktop.DBus"
-//                              << (int)QDBusConnection::NoReplace << false;
-
-    QTest::newRow("ok1") << "com.trolltech.QtDBUS.tst_qdbusconnection"
-                         << (int)QDBusConnection::NoReplace << true;
-}
-
-void tst_QDBusConnection::requestName()
-{
-    QDBusConnection &con = QDBus::sessionBus();
-
-    QVERIFY(con.isConnected());
-    
-    QFETCH(QString, requestedName);
-    QFETCH(int, flags);
-    QFETCH(bool, expectedResult);
-
-    bool result = con.requestName(requestedName, (QDBusConnection::NameRequestMode)flags);
-
-//    QEXPECT_FAIL("existing", "For whatever reason, the bus lets us replace this name", Abort);
-    QCOMPARE(result, expectedResult);
-}
-
-void tst_QDBusConnection::getNameOwner_data()
-{
-    QTest::addColumn<QString>("name");
-    QTest::addColumn<QString>("expectedResult");
-
-    QTest::newRow("null") << QString() << QString();
-    QTest::newRow("empty") << QString("") << QString();
-
-    QTest::newRow("invalid") << ".invalid" << QString();
-    QTest::newRow("non-existent") << "com.trolltech.QtDBUS.foo" << QString();
-
-    QTest::newRow("bus") << "org.freedesktop.DBus" << "org.freedesktop.DBus";
-
-    QString base = QDBus::sessionBus().baseService();
-    QTest::newRow("address") << base << base;
-    QTest::newRow("self") << "com.trolltech.QtDBUS.tst_qdbusconnection" << base;
-}
-
-void tst_QDBusConnection::getNameOwner()
-{
-    QFETCH(QString, name);
-    QFETCH(QString, expectedResult);
-
-    QDBusConnection &con = QDBus::sessionBus();
-    QVERIFY(con.isConnected());
-
-    QString result = con.getNameOwner(name);
-
-    QCOMPARE(result, expectedResult);
-}
-
-void tst_QDBusConnection::releaseName_data()
-{
-    requestName_data();
-}
-
-void tst_QDBusConnection::releaseName()
-{
-    QDBusConnection &con = QDBus::sessionBus();
-
-    QVERIFY(con.isConnected());
-    
-    QFETCH(QString, requestedName);
-    //QFETCH(int, flags);
-    QFETCH(bool, expectedResult);
-
-    bool result = con.releaseName(requestedName);
-
-    QCOMPARE(result, expectedResult);
-}
-
 void tst_QDBusConnection::registerObject()
 {
     QDBusConnection &con = QDBus::sessionBus();

Index: tst_qdbusinterface.cpp
===================================================================
RCS file: /cvs/dbus/dbus/test/qt/tst_qdbusinterface.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- tst_qdbusinterface.cpp	6 Mar 2006 14:30:52 -0000	1.2
+++ tst_qdbusinterface.cpp	28 Mar 2006 18:58:58 -0000	1.3
@@ -20,7 +20,6 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
  */
-#define DBUS_API_SUBJECT_TO_CHANGE 1
 #include <qcoreapplication.h>
 #include <qmetatype.h>
 #include <QtTest/QtTest>
@@ -28,10 +27,11 @@
 #include <dbus/qdbus.h>
 #include <QtCore/qvariant.h>
 
+#include "common.h"
+
 Q_DECLARE_METATYPE(QVariantList)
 
 #define TEST_INTERFACE_NAME "com.trolltech.QtDBus.MyObject"
-#define TEST_SERVICE_NAME "com.trolltech.QtDBus.tst_qdbusinterface"
 #define TEST_SIGNAL_NAME "somethingHappened"
 
 const char introspectionData[] =
@@ -142,7 +142,6 @@
     void call_data();
     void call();
 
-    void introspect_data();
     void introspect();
 
     void signal();
@@ -152,7 +151,6 @@
 {
     QDBusConnection &con = QDBus::sessionBus();
     QVERIFY(con.isConnected());
-    QVERIFY(con.requestName( TEST_SERVICE_NAME ));
 
     con.registerObject("/", &obj, QDBusConnection::ExportAdaptors | QDBusConnection::ExportSlots);
 }
@@ -169,16 +167,21 @@
     input << qVariantFromValue(1);
     QTest::newRow("int") << "ping" << input << input;
     QTest::newRow("int-int") << "ping.i" << input << input;
-    QTest::newRow("int-int16") << "ping.n" << input << input;
+    QTest::newRow("int-int16") << "ping.n" << input << (QVariantList() << qVariantFromValue(short(1)));
 
     // try doing some conversions
     QVariantList output;
     output << qVariantFromValue(1U);
     QTest::newRow("int-uint") << "ping.u" << input << output;
+
+#if QT_VERSION >= 0x040200
+    output.clear();
+    output << qVariantFromValue(ushort(1));
     QTest::newRow("int-uint16") << "ping.q" << input << output;
+#endif
 
-    QTest::newRow("int-int64") << "ping.x" << input << (QVariantList() << qVariantFromValue(1LL));
-    QTest::newRow("int-uint64") << "ping.t" << input << (QVariantList() << qVariantFromValue(1ULL));
+    QTest::newRow("int-int64") << "ping.x" << input << (QVariantList() << qVariantFromValue(Q_INT64_C(1)));
+    QTest::newRow("int-uint64") << "ping.t" << input << (QVariantList() << qVariantFromValue(Q_UINT64_C(1)));
     QTest::newRow("int-double") << "ping.d" << input << (QVariantList() << qVariantFromValue(1.0));
 
     output.clear();
@@ -192,13 +195,23 @@
 
     output.clear();
     output << qVariantFromValue(1);
-    QTest::newRow("string-int") << "ping.i" << input << input;
+    QTest::newRow("string-int") << "ping.i" << input << output;
+
+#if QT_VERSION >= 0x040200
+    output.clear();
+    output << qVariantFromValue(short(1));
     QTest::newRow("string-int16") << "ping.n" << input << input;
+#endif
 
     output.clear();
     output << qVariantFromValue(1U);
     QTest::newRow("string-uint") << "ping.u" << input << output;
+
+#if QT_VERSION >= 0x040200
+    output.clear();
+    output << qVariantFromValue(ushort(1));
     QTest::newRow("string-uint16") << "ping.q" << input << output;
+#endif
 
     QTest::newRow("string-int64") << "ping.x" << input << (QVariantList() << qVariantFromValue(1LL));
     QTest::newRow("string-uint64") << "ping.t" << input << (QVariantList() << qVariantFromValue(1ULL));
@@ -219,8 +232,8 @@
 void tst_QDBusInterface::call()
 {
     QDBusConnection &con = QDBus::sessionBus();
-    QDBusInterface iface = con.findInterface(con.baseService(), QLatin1String("/"),
-                                             TEST_INTERFACE_NAME);
+    QDBusInterface *iface = con.findInterface(con.baseService(), QLatin1String("/"),
+                                              TEST_INTERFACE_NAME);
 
     QFETCH(QString, method);
     QFETCH(QVariantList, input);
@@ -228,30 +241,30 @@
     
     QDBusMessage reply;
     // try first callWithArgs:
-    reply = iface.callWithArgs(method, input);
+    reply = iface->callWithArgs(method, input);
 
     QCOMPARE(reply.type(), QDBusMessage::ReplyMessage);
     if (!output.isEmpty()) {
         QCOMPARE(reply.count(), output.count());
-        QCOMPARE(static_cast<QVariantList>(reply), output);
+        QVERIFY(compare(reply, output));
     }
 
     // try the template methods
     if (input.isEmpty())
-        reply = iface.call(method);
+        reply = iface->call(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(method, input.at(0).toInt());
             break;
 
         case QVariant::UInt:
-            reply = iface.call(method, input.at(0).toUInt());
+            reply = iface->call(method, input.at(0).toUInt());
             break;
 
         case QVariant::String:
-            reply = iface.call(method, input.at(0).toString());
+            reply = iface->call(method, input.at(0).toString());
             break;
 
         default:
@@ -259,73 +272,50 @@
             break;
         }
     else
-        reply = iface.call(method, input.at(0).toString(), input.at(1).toString());
+        reply = iface->call(method, input.at(0).toString(), input.at(1).toString());
 
     QCOMPARE(reply.type(), QDBusMessage::ReplyMessage);
     if (!output.isEmpty()) {
         QCOMPARE(reply.count(), output.count());
-        QCOMPARE(static_cast<QVariantList>(reply), output);
+        QVERIFY(compare(reply, output));
     }
 }
 
-void tst_QDBusInterface::introspect_data()
-{
-    QTest::addColumn<QString>("service");
-    QTest::newRow("base") << QDBus::sessionBus().baseService();
-    QTest::newRow("name") << TEST_SERVICE_NAME;
-}
-
 void tst_QDBusInterface::introspect()
 {
-    QFETCH(QString, service);
     QDBusConnection &con = QDBus::sessionBus();
-    QDBusInterface iface = con.findInterface(service, QLatin1String("/"),
-                                             TEST_INTERFACE_NAME);
+    QDBusInterface *iface = con.findInterface(QDBus::sessionBus().baseService(), QLatin1String("/"),
+                                              TEST_INTERFACE_NAME);
 
-    QDBusIntrospection::Methods mm = iface.methodData();
-    QVERIFY(mm.count() == 2);
+    const QMetaObject *mo = iface->metaObject();
 
-    QDBusIntrospection::Signals sm = iface.signalData();
-    QVERIFY(sm.count() == 1);
-    QVERIFY(sm.contains(TEST_SIGNAL_NAME));
+    qDebug("Improve to a better testcase of QDBusMetaObject");
+    QCOMPARE(mo->methodCount() - mo->methodOffset(), 3);
+    QVERIFY(mo->indexOfSignal(TEST_SIGNAL_NAME "(QString)") != -1);
 
-    QDBusIntrospection::Properties pm = iface.propertyData();
-    QVERIFY(pm.count() == 1);
-    QVERIFY(pm.contains("prop1"));
+    QCOMPARE(mo->propertyCount() - mo->propertyOffset(), 1);
+    QVERIFY(mo->indexOfProperty("prop1") != -1);
+
+    iface->deleteLater();
 }
 
 void tst_QDBusInterface::signal()
 {
     QDBusConnection &con = QDBus::sessionBus();
-    QDBusInterface iface = con.findInterface(con.baseService(), QLatin1String("/"),
-                                             TEST_INTERFACE_NAME);
-
-    QString signalName = TEST_SIGNAL_NAME;
+    QDBusInterface *iface = con.findInterface(con.baseService(), QLatin1String("/"),
+                                              TEST_INTERFACE_NAME);
 
     QString arg = "So long and thanks for all the fish";
     {
         Spy spy;
-        iface.connect(signalName, &spy, SLOT(spySlot(QString)));
+        spy.connect(iface, SIGNAL(somethingHappened(QString)), SLOT(spySlot(QString)));
 
-        emitSignal(TEST_INTERFACE_NAME, signalName, arg);
-        QVERIFY(spy.count == 1);
+        emitSignal(TEST_INTERFACE_NAME, TEST_SIGNAL_NAME, arg);
+        QCOMPARE(spy.count, 1);
         QCOMPARE(spy.received, arg);
     }
 
-    QDBusIntrospection::Signals sm = iface.signalData();
-    QVERIFY(sm.contains(signalName));
-
-    const QDBusIntrospection::Signal& signal = sm.value(signalName);
-    QCOMPARE(signal.name, signalName);
-    QVERIFY(!signal.outputArgs.isEmpty());
-    {
-        Spy spy;
-        iface.connect(signal, &spy, SLOT(spySlot(QString)));
-
-        emitSignal(TEST_INTERFACE_NAME, signalName, arg);
-        QVERIFY(spy.count == 1);
-        QCOMPARE(spy.received, arg);
-    }
+    iface->deleteLater();
 }
 
 QTEST_MAIN(tst_QDBusInterface)

--- tst_qdbusobject.cpp DELETED ---

--- tst_qdbustype.cpp DELETED ---

--- tst_qdbusxmlparser.cpp DELETED ---



More information about the dbus-commit mailing list