tests/auto/qdbuspendingreply/tst_qdbuspendingreply.cpp
changeset 0 1918ee327afb
child 3 41300fa6a67c
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the test suite of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 #include <QtCore/QObject>
       
    42 #include <QtCore/QVariant>
       
    43 #include <QtCore/QList>
       
    44 #include <QtCore/QVector>
       
    45 #include <QtTest/QtTest>
       
    46 #ifndef QT_NO_DBUS
       
    47 #include <QtDBus>
       
    48 
       
    49 typedef QMap<int,QString> IntStringMap;
       
    50 Q_DECLARE_METATYPE(IntStringMap)
       
    51 
       
    52 struct MyStruct
       
    53 {
       
    54     int i;
       
    55     QString s;
       
    56 
       
    57     MyStruct() : i(1), s("String") { }
       
    58     bool operator==(const MyStruct &other) const
       
    59     { return i == other.i && s == other.s; }
       
    60 };
       
    61 Q_DECLARE_METATYPE(MyStruct)
       
    62 
       
    63 QDBusArgument &operator<<(QDBusArgument &arg, const MyStruct &ms)
       
    64 {
       
    65     arg.beginStructure();
       
    66     arg << ms.i << ms.s;
       
    67     arg.endStructure();
       
    68     return arg;
       
    69 }
       
    70 
       
    71 const QDBusArgument &operator>>(const QDBusArgument &arg, MyStruct &ms)
       
    72 {
       
    73     arg.beginStructure();
       
    74     arg >> ms.i >> ms.s;
       
    75     arg.endStructure();
       
    76     return arg;
       
    77 }
       
    78 
       
    79 class TypesInterface;
       
    80 class tst_QDBusPendingReply: public QObject
       
    81 {
       
    82     Q_OBJECT
       
    83     QDBusInterface *iface;
       
    84     TypesInterface *adaptor;
       
    85 public:
       
    86     tst_QDBusPendingReply();
       
    87 
       
    88 private slots:
       
    89     void initTestCase()
       
    90     {
       
    91         qDBusRegisterMetaType<IntStringMap>();
       
    92         qDBusRegisterMetaType<MyStruct>();
       
    93     }
       
    94 
       
    95     void init();
       
    96     void simpleTypes();
       
    97     void complexTypes();
       
    98     void wrongTypes();
       
    99     void multipleTypes();
       
   100 
       
   101     void synchronousSimpleTypes();
       
   102 
       
   103     void errors();
       
   104 };
       
   105 
       
   106 class TypesInterface: public QDBusAbstractAdaptor
       
   107 {
       
   108     Q_OBJECT
       
   109     Q_CLASSINFO("D-Bus Interface", "com.trolltech.Qt.Autotests.TypesInterface")
       
   110 public:
       
   111     TypesInterface(QObject *parent)
       
   112         : QDBusAbstractAdaptor(parent)
       
   113     { }
       
   114 
       
   115 public slots:
       
   116     void retrieveVoid()
       
   117     { }
       
   118 
       
   119     bool retrieveBool()
       
   120     {
       
   121         return true;
       
   122     }
       
   123 
       
   124     uchar retrieveUChar()
       
   125     {
       
   126         return 'A';
       
   127     }
       
   128 
       
   129     short retrieveShort()
       
   130     {
       
   131         return -47;
       
   132     }
       
   133 
       
   134     ushort retrieveUShort()
       
   135     {
       
   136         return 42U;
       
   137     }
       
   138 
       
   139     int retrieveInt()
       
   140     {
       
   141         return -470000;
       
   142     }
       
   143 
       
   144     void retrieveIntInt(int &i1, int &i2)
       
   145     {
       
   146         i1 = -424242;
       
   147         i2 = 434343;
       
   148     }
       
   149 
       
   150     uint retrieveUInt()
       
   151     {
       
   152         return 42424242;
       
   153     }
       
   154 
       
   155     qlonglong retrieveLongLong()
       
   156     {
       
   157         return -(Q_INT64_C(1) << 32);
       
   158     }
       
   159 
       
   160     qulonglong retrieveULongLong()
       
   161     {
       
   162         return Q_INT64_C(1) << 32;
       
   163     }
       
   164 
       
   165     double retrieveDouble()
       
   166     {
       
   167         return 1.5;
       
   168     }
       
   169 
       
   170     QString retrieveString()
       
   171     {
       
   172         return "This string you should see";
       
   173     }
       
   174 
       
   175     QDBusObjectPath retrieveObjectPath()
       
   176     {
       
   177         return QDBusObjectPath("/");
       
   178     }
       
   179 
       
   180     QDBusSignature retrieveSignature()
       
   181     {
       
   182         return QDBusSignature("g");
       
   183     }
       
   184 
       
   185     QDBusVariant retrieveVariant()
       
   186     {
       
   187         return QDBusVariant(retrieveString());
       
   188     }
       
   189 
       
   190     QStringList retrieveStringList()
       
   191     {
       
   192         return QStringList() << "one" << "two";
       
   193     }
       
   194 
       
   195     QByteArray retrieveByteArray()
       
   196     {
       
   197         return "Hello, World";
       
   198     }
       
   199 
       
   200     QVariantList retrieveList()
       
   201     {
       
   202         return QVariantList() << retrieveInt() << retrieveString()
       
   203                               << retrieveByteArray();
       
   204     }
       
   205 
       
   206     QVariantMap retrieveMap()
       
   207     {
       
   208         QVariantMap map;
       
   209         map["one"] = 1;
       
   210         map["two"] = 2U;
       
   211         map["string"] = retrieveString();
       
   212         map["stringlist"] = retrieveStringList();
       
   213         return map;
       
   214     }
       
   215 
       
   216     IntStringMap retrieveIntStringMap()
       
   217     {
       
   218         IntStringMap map;
       
   219         map[1] = "1";
       
   220         map[2] = "2";
       
   221         map[-1231456] = "foo";
       
   222         return map;
       
   223     }
       
   224 
       
   225     MyStruct retrieveStruct()
       
   226     {
       
   227         return MyStruct();
       
   228     }
       
   229 
       
   230     void sendError(const QDBusMessage &msg)
       
   231     {
       
   232         msg.setDelayedReply(true);
       
   233         QDBusConnection::sessionBus()
       
   234             .send(msg.createErrorReply("local.AnErrorName", "You've got an error!"));
       
   235     }
       
   236 };
       
   237 
       
   238 tst_QDBusPendingReply::tst_QDBusPendingReply()
       
   239 {
       
   240     adaptor = new TypesInterface(this);
       
   241     QDBusConnection::sessionBus().registerObject("/", this);
       
   242 
       
   243     iface = new QDBusInterface(QDBusConnection::sessionBus().baseService(), "/",
       
   244                                "com.trolltech.Qt.Autotests.TypesInterface",
       
   245                                QDBusConnection::sessionBus(),
       
   246                                this);
       
   247 }
       
   248 
       
   249 void tst_QDBusPendingReply::init()
       
   250 {
       
   251     QVERIFY(iface);
       
   252     QVERIFY(iface->isValid());
       
   253 }
       
   254 
       
   255 void tst_QDBusPendingReply::simpleTypes()
       
   256 {
       
   257     QDBusPendingReply<> rvoid = iface->asyncCall("retrieveVoid");
       
   258     rvoid.waitForFinished();
       
   259     QVERIFY(rvoid.isFinished());
       
   260     QVERIFY(!rvoid.isError());
       
   261 
       
   262     QDBusPendingReply<bool> rbool = iface->asyncCall("retrieveBool");
       
   263     rbool.waitForFinished();
       
   264     QVERIFY(rbool.isFinished());
       
   265     QCOMPARE(rbool.argumentAt<0>(), adaptor->retrieveBool());
       
   266 
       
   267     QDBusPendingReply<uchar> ruchar = iface->asyncCall("retrieveUChar");
       
   268     ruchar.waitForFinished();
       
   269     QVERIFY(ruchar.isFinished());
       
   270     QCOMPARE(ruchar.argumentAt<0>(), adaptor->retrieveUChar());
       
   271 
       
   272     QDBusPendingReply<short> rshort = iface->asyncCall("retrieveShort");
       
   273     rshort.waitForFinished();
       
   274     QVERIFY(rshort.isFinished());
       
   275     QCOMPARE(rshort.argumentAt<0>(), adaptor->retrieveShort());
       
   276 
       
   277     QDBusPendingReply<ushort> rushort = iface->asyncCall("retrieveUShort");
       
   278     rushort.waitForFinished();
       
   279     QVERIFY(rushort.isFinished());
       
   280     QCOMPARE(rushort.argumentAt<0>(), adaptor->retrieveUShort());
       
   281 
       
   282     QDBusPendingReply<int> rint = iface->asyncCall("retrieveInt");
       
   283     rint.waitForFinished();
       
   284     QVERIFY(rint.isFinished());
       
   285     QCOMPARE(rint.argumentAt<0>(), adaptor->retrieveInt());
       
   286 
       
   287     QDBusPendingReply<uint> ruint = iface->asyncCall("retrieveUInt");
       
   288     ruint.waitForFinished();
       
   289     QVERIFY(ruint.isFinished());
       
   290     QCOMPARE(ruint.argumentAt<0>(), adaptor->retrieveUInt());
       
   291 
       
   292     QDBusPendingReply<qlonglong> rqlonglong = iface->asyncCall("retrieveLongLong");
       
   293     rqlonglong.waitForFinished();
       
   294     QVERIFY(rqlonglong.isFinished());
       
   295     QCOMPARE(rqlonglong.argumentAt<0>(), adaptor->retrieveLongLong());
       
   296 
       
   297     QDBusPendingReply<qulonglong> rqulonglong = iface->asyncCall("retrieveULongLong");
       
   298     rqulonglong.waitForFinished();
       
   299     QVERIFY(rqulonglong.isFinished());
       
   300     QCOMPARE(rqulonglong.argumentAt<0>(), adaptor->retrieveULongLong());
       
   301 
       
   302     QDBusPendingReply<double> rdouble = iface->asyncCall("retrieveDouble");
       
   303     rdouble.waitForFinished();
       
   304     QVERIFY(rdouble.isFinished());
       
   305     QCOMPARE(rdouble.argumentAt<0>(), adaptor->retrieveDouble());
       
   306 
       
   307     QDBusPendingReply<QString> rstring = iface->asyncCall("retrieveString");
       
   308     rstring.waitForFinished();
       
   309     QVERIFY(rstring.isFinished());
       
   310     QCOMPARE(rstring.argumentAt<0>(), adaptor->retrieveString());
       
   311 
       
   312     QDBusPendingReply<QDBusObjectPath> robjectpath = iface->asyncCall("retrieveObjectPath");
       
   313     robjectpath.waitForFinished();
       
   314     QVERIFY(robjectpath.isFinished());
       
   315     QCOMPARE(robjectpath.argumentAt<0>().path(), adaptor->retrieveObjectPath().path());
       
   316 
       
   317     QDBusPendingReply<QDBusSignature> rsignature = iface->asyncCall("retrieveSignature");
       
   318     rsignature.waitForFinished();
       
   319     QVERIFY(rsignature.isFinished());
       
   320     QCOMPARE(rsignature.argumentAt<0>().signature(), adaptor->retrieveSignature().signature());
       
   321 
       
   322     QDBusPendingReply<QDBusVariant> rdbusvariant = iface->asyncCall("retrieveVariant");
       
   323     rdbusvariant.waitForFinished();
       
   324     QVERIFY(rdbusvariant.isFinished());
       
   325     QCOMPARE(rdbusvariant.argumentAt<0>().variant(), adaptor->retrieveVariant().variant());
       
   326 
       
   327     QDBusPendingReply<QVariant> rvariant = iface->asyncCall("retrieveVariant");
       
   328     rvariant.waitForFinished();
       
   329     QVERIFY(rvariant.isFinished());
       
   330     QCOMPARE(rvariant.argumentAt<0>(), adaptor->retrieveVariant().variant());
       
   331 
       
   332     QDBusPendingReply<QByteArray> rbytearray = iface->asyncCall("retrieveByteArray");
       
   333     rbytearray.waitForFinished();
       
   334     QVERIFY(rbytearray.isFinished());
       
   335     QCOMPARE(rbytearray.argumentAt<0>(), adaptor->retrieveByteArray());
       
   336 
       
   337     QDBusPendingReply<QStringList> rstringlist = iface->asyncCall("retrieveStringList");
       
   338     rstringlist.waitForFinished();
       
   339     QVERIFY(rstringlist.isFinished());
       
   340     QCOMPARE(rstringlist.argumentAt<0>(), adaptor->retrieveStringList());
       
   341 }
       
   342 
       
   343 void tst_QDBusPendingReply::complexTypes()
       
   344 {
       
   345     QDBusPendingReply<QVariantList> rlist = iface->asyncCall("retrieveList");
       
   346     rlist.waitForFinished();
       
   347     QVERIFY(rlist.isFinished());
       
   348     QCOMPARE(rlist.argumentAt<0>(), adaptor->retrieveList());
       
   349 
       
   350     QDBusPendingReply<QVariantMap> rmap = iface->asyncCall("retrieveMap");
       
   351     rmap.waitForFinished();
       
   352     QVERIFY(rmap.isFinished());
       
   353     QCOMPARE(rmap.argumentAt<0>(), adaptor->retrieveMap());
       
   354 
       
   355     QDBusPendingReply<IntStringMap> rismap = iface->asyncCall("retrieveIntStringMap");
       
   356     rismap.waitForFinished();
       
   357     QVERIFY(rismap.isFinished());
       
   358     QCOMPARE(rismap.argumentAt<0>(), adaptor->retrieveIntStringMap());
       
   359 
       
   360     QDBusPendingReply<MyStruct> rstruct = iface->asyncCall("retrieveStruct");
       
   361     rstruct.waitForFinished();
       
   362     QVERIFY(rstruct.isFinished());
       
   363     QCOMPARE(rstruct.argumentAt<0>(), adaptor->retrieveStruct());
       
   364 }
       
   365 
       
   366 #define VERIFY_WRONG_TYPE(error)                                \
       
   367     QVERIFY(error.isValid());                                   \
       
   368     QCOMPARE(error.type(), QDBusError::InvalidSignature)
       
   369 
       
   370 void tst_QDBusPendingReply::wrongTypes()
       
   371 {
       
   372     QDBusError error;
       
   373 
       
   374     QDBusPendingReply<bool> rbool = iface->asyncCall("retrieveInt");
       
   375     rbool.waitForFinished();
       
   376     QVERIFY(rbool.isFinished());
       
   377     QVERIFY(rbool.isError());
       
   378     error = rbool.error();
       
   379     VERIFY_WRONG_TYPE(error);
       
   380 
       
   381     rbool = iface->asyncCall("retrieveShort");
       
   382     rbool.waitForFinished();
       
   383     QVERIFY(rbool.isFinished());
       
   384     QVERIFY(rbool.isError());
       
   385     error = rbool.error();
       
   386     VERIFY_WRONG_TYPE(error);
       
   387 
       
   388     rbool = iface->asyncCall("retrieveStruct");
       
   389     rbool.waitForFinished();
       
   390     QVERIFY(rbool.isFinished());
       
   391     QVERIFY(rbool.isError());
       
   392     error = rbool.error();
       
   393     VERIFY_WRONG_TYPE(error);
       
   394 
       
   395     QDBusPendingReply<short> rshort = iface->asyncCall("retrieveInt");
       
   396     rshort.waitForFinished();
       
   397     QVERIFY(rshort.isFinished());
       
   398     QVERIFY(rshort.isError());
       
   399     error = rshort.error();
       
   400     VERIFY_WRONG_TYPE(error);
       
   401 
       
   402     rshort = iface->asyncCall("retrieveBool");
       
   403     rshort.waitForFinished();
       
   404     QVERIFY(rshort.isFinished());
       
   405     QVERIFY(rshort.isError());
       
   406     error = rshort.error();
       
   407     VERIFY_WRONG_TYPE(error);
       
   408 
       
   409     rshort = iface->asyncCall("retrieveStruct");
       
   410     rshort.waitForFinished();
       
   411     QVERIFY(rshort.isFinished());
       
   412     QVERIFY(rshort.isError());
       
   413     error = rshort.error();
       
   414     VERIFY_WRONG_TYPE(error);
       
   415 
       
   416     QDBusPendingReply<MyStruct> rstruct = iface->asyncCall("retrieveInt");
       
   417     rstruct.waitForFinished();
       
   418     QVERIFY(rstruct.isFinished());
       
   419     QVERIFY(rstruct.isError());
       
   420     error = rstruct.error();
       
   421     VERIFY_WRONG_TYPE(error);
       
   422 
       
   423     rstruct = iface->asyncCall("retrieveShort");
       
   424     rstruct.waitForFinished();
       
   425     QVERIFY(rstruct.isFinished());
       
   426     QVERIFY(rstruct.isError());
       
   427     error = rstruct.error();
       
   428     VERIFY_WRONG_TYPE(error);
       
   429 
       
   430     rstruct = iface->asyncCall("retrieveIntStringMap");
       
   431     rstruct.waitForFinished();
       
   432     QVERIFY(rstruct.isFinished());
       
   433     QVERIFY(rstruct.isError());
       
   434     error = rstruct.error();
       
   435     VERIFY_WRONG_TYPE(error);
       
   436 }
       
   437 
       
   438 void tst_QDBusPendingReply::multipleTypes()
       
   439 {
       
   440     QDBusPendingReply<int, int> rintint = iface->asyncCall("retrieveIntInt");
       
   441     rintint.waitForFinished();
       
   442     QVERIFY(rintint.isFinished());
       
   443     QVERIFY(!rintint.isError());
       
   444 
       
   445     int i1, i2;
       
   446     adaptor->retrieveIntInt(i1, i2);
       
   447     QCOMPARE(rintint.argumentAt<0>(), i1);
       
   448     QCOMPARE(rintint.argumentAt<1>(), i2);
       
   449 }
       
   450 
       
   451 void tst_QDBusPendingReply::synchronousSimpleTypes()
       
   452 {
       
   453     QDBusPendingReply<bool> rbool = iface->call("retrieveBool");
       
   454     rbool.waitForFinished();
       
   455     QVERIFY(rbool.isFinished());
       
   456     QCOMPARE(rbool.argumentAt<0>(), adaptor->retrieveBool());
       
   457 
       
   458     QDBusPendingReply<uchar> ruchar = iface->call("retrieveUChar");
       
   459     ruchar.waitForFinished();
       
   460     QVERIFY(ruchar.isFinished());
       
   461     QCOMPARE(ruchar.argumentAt<0>(), adaptor->retrieveUChar());
       
   462 
       
   463     QDBusPendingReply<short> rshort = iface->call("retrieveShort");
       
   464     rshort.waitForFinished();
       
   465     QVERIFY(rshort.isFinished());
       
   466     QCOMPARE(rshort.argumentAt<0>(), adaptor->retrieveShort());
       
   467 
       
   468     QDBusPendingReply<ushort> rushort = iface->call("retrieveUShort");
       
   469     rushort.waitForFinished();
       
   470     QVERIFY(rushort.isFinished());
       
   471     QCOMPARE(rushort.argumentAt<0>(), adaptor->retrieveUShort());
       
   472 
       
   473     QDBusPendingReply<int> rint = iface->call("retrieveInt");
       
   474     rint.waitForFinished();
       
   475     QVERIFY(rint.isFinished());
       
   476     QCOMPARE(rint.argumentAt<0>(), adaptor->retrieveInt());
       
   477 
       
   478     QDBusPendingReply<uint> ruint = iface->call("retrieveUInt");
       
   479     ruint.waitForFinished();
       
   480     QVERIFY(ruint.isFinished());
       
   481     QCOMPARE(ruint.argumentAt<0>(), adaptor->retrieveUInt());
       
   482 
       
   483     QDBusPendingReply<qlonglong> rqlonglong = iface->call("retrieveLongLong");
       
   484     rqlonglong.waitForFinished();
       
   485     QVERIFY(rqlonglong.isFinished());
       
   486     QCOMPARE(rqlonglong.argumentAt<0>(), adaptor->retrieveLongLong());
       
   487 
       
   488     QDBusPendingReply<qulonglong> rqulonglong = iface->call("retrieveULongLong");
       
   489     rqulonglong.waitForFinished();
       
   490     QVERIFY(rqulonglong.isFinished());
       
   491     QCOMPARE(rqulonglong.argumentAt<0>(), adaptor->retrieveULongLong());
       
   492 
       
   493     QDBusPendingReply<double> rdouble = iface->call("retrieveDouble");
       
   494     rdouble.waitForFinished();
       
   495     QVERIFY(rdouble.isFinished());
       
   496     QCOMPARE(rdouble.argumentAt<0>(), adaptor->retrieveDouble());
       
   497 
       
   498     QDBusPendingReply<QString> rstring = iface->call("retrieveString");
       
   499     rstring.waitForFinished();
       
   500     QVERIFY(rstring.isFinished());
       
   501     QCOMPARE(rstring.argumentAt<0>(), adaptor->retrieveString());
       
   502 
       
   503     QDBusPendingReply<QDBusObjectPath> robjectpath = iface->call("retrieveObjectPath");
       
   504     robjectpath.waitForFinished();
       
   505     QVERIFY(robjectpath.isFinished());
       
   506     QCOMPARE(robjectpath.argumentAt<0>().path(), adaptor->retrieveObjectPath().path());
       
   507 
       
   508     QDBusPendingReply<QDBusSignature> rsignature = iface->call("retrieveSignature");
       
   509     rsignature.waitForFinished();
       
   510     QVERIFY(rsignature.isFinished());
       
   511     QCOMPARE(rsignature.argumentAt<0>().signature(), adaptor->retrieveSignature().signature());
       
   512 
       
   513     QDBusPendingReply<QDBusVariant> rdbusvariant = iface->call("retrieveVariant");
       
   514     rdbusvariant.waitForFinished();
       
   515     QVERIFY(rdbusvariant.isFinished());
       
   516     QCOMPARE(rdbusvariant.argumentAt<0>().variant(), adaptor->retrieveVariant().variant());
       
   517 
       
   518     QDBusPendingReply<QByteArray> rbytearray = iface->call("retrieveByteArray");
       
   519     rbytearray.waitForFinished();
       
   520     QVERIFY(rbytearray.isFinished());
       
   521     QCOMPARE(rbytearray.argumentAt<0>(), adaptor->retrieveByteArray());
       
   522 
       
   523     QDBusPendingReply<QStringList> rstringlist = iface->call("retrieveStringList");
       
   524     rstringlist.waitForFinished();
       
   525     QVERIFY(rstringlist.isFinished());
       
   526     QCOMPARE(rstringlist.argumentAt<0>(), adaptor->retrieveStringList());
       
   527 }
       
   528 
       
   529 #define VERIFY_ERROR(error)                                     \
       
   530     QVERIFY(error.isValid());                                   \
       
   531     QCOMPARE(error.name(), QString("local.AnErrorName"));       \
       
   532     QCOMPARE(error.type(), QDBusError::Other)
       
   533 
       
   534 void tst_QDBusPendingReply::errors()
       
   535 {
       
   536     QDBusError error;
       
   537 
       
   538     QDBusPendingReply<> rvoid = iface->asyncCall("sendError");
       
   539     rvoid.waitForFinished();
       
   540     QVERIFY(rvoid.isFinished());
       
   541     QVERIFY(rvoid.isError());
       
   542     error = rvoid.error();
       
   543     VERIFY_ERROR(error);
       
   544 
       
   545     QDBusPendingReply<int> rint = iface->asyncCall("sendError");
       
   546     rint.waitForFinished();
       
   547     QVERIFY(rint.isFinished());
       
   548     QVERIFY(rint.isError());
       
   549     error = rint.error();
       
   550     VERIFY_ERROR(error);
       
   551 
       
   552     QDBusPendingReply<int,int> rintint = iface->asyncCall("sendError");
       
   553     rintint.waitForFinished();
       
   554     QVERIFY(rintint.isFinished());
       
   555     QVERIFY(rintint.isError());
       
   556     error = rintint.error();
       
   557     VERIFY_ERROR(error);
       
   558 
       
   559     QDBusPendingReply<QString> rstring = iface->asyncCall("sendError");
       
   560     rstring.waitForFinished();
       
   561     QVERIFY(rstring.isFinished());
       
   562     QVERIFY(rstring.isError());
       
   563     error = rstring.error();
       
   564     VERIFY_ERROR(error);
       
   565 }
       
   566 
       
   567 QTEST_MAIN(tst_QDBusPendingReply)
       
   568 
       
   569 #include "tst_qdbuspendingreply.moc"
       
   570 #else
       
   571 QTEST_NOOP_MAIN
       
   572 #endif