diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qdbusabstractinterface/com.trolltech.QtDBus.Pinger.xml | 4 | ||||
-rw-r--r-- | tests/auto/qdbusabstractinterface/interface.cpp | 14 | ||||
-rw-r--r-- | tests/auto/qdbusabstractinterface/interface.h | 1 | ||||
-rw-r--r-- | tests/auto/qdbusabstractinterface/pinger.h | 7 | ||||
-rw-r--r-- | tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp | 92 | ||||
-rw-r--r-- | tests/auto/qfiledialog/qfiledialog.pro | 2 | ||||
-rw-r--r-- | tests/auto/qlistwidget/qlistwidget.pro | 2 | ||||
-rw-r--r-- | tests/auto/qmenu/qmenu.pro | 2 | ||||
-rw-r--r-- | tests/auto/qnetworkreply/test/test.pro | 2 |
9 files changed, 125 insertions, 1 deletions
diff --git a/tests/auto/qdbusabstractinterface/com.trolltech.QtDBus.Pinger.xml b/tests/auto/qdbusabstractinterface/com.trolltech.QtDBus.Pinger.xml index 1667591708..d945ec9b43 100644 --- a/tests/auto/qdbusabstractinterface/com.trolltech.QtDBus.Pinger.xml +++ b/tests/auto/qdbusabstractinterface/com.trolltech.QtDBus.Pinger.xml @@ -15,6 +15,10 @@ <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="RegisteredType"/> </signal> <method name="voidMethod" /> + <method name="sleepMethod"> + <arg type="i" /> + <arg type="i" direction="out"/> + </method> <method name="stringMethod"> <arg type="s" direction="out"/> </method> diff --git a/tests/auto/qdbusabstractinterface/interface.cpp b/tests/auto/qdbusabstractinterface/interface.cpp index 0326177fc0..849db93084 100644 --- a/tests/auto/qdbusabstractinterface/interface.cpp +++ b/tests/auto/qdbusabstractinterface/interface.cpp @@ -40,9 +40,23 @@ ****************************************************************************/ #include "interface.h" +#include <QThread> Interface::Interface() { } +// Export the sleep function +// TODO QT5: remove this class, QThread::msleep is now public +class FriendlySleepyThread : public QThread { +public: + using QThread::msleep; +}; + +int Interface::sleepMethod(int msec) +{ + FriendlySleepyThread::msleep(msec); + return 42; +} + #include "moc_interface.cpp" diff --git a/tests/auto/qdbusabstractinterface/interface.h b/tests/auto/qdbusabstractinterface/interface.h index b840a38e8e..0fb15fe6c5 100644 --- a/tests/auto/qdbusabstractinterface/interface.h +++ b/tests/auto/qdbusabstractinterface/interface.h @@ -101,6 +101,7 @@ public: public slots: Q_SCRIPTABLE void voidMethod() {} + Q_SCRIPTABLE int sleepMethod(int); Q_SCRIPTABLE QString stringMethod() { return "Hello, world"; } Q_SCRIPTABLE RegisteredType complexMethod() { return RegisteredType("Hello, world"); } Q_SCRIPTABLE QString multiOutMethod(int &value) { value = 42; return "Hello, world"; } diff --git a/tests/auto/qdbusabstractinterface/pinger.h b/tests/auto/qdbusabstractinterface/pinger.h index 6245a5a02f..739a14229f 100644 --- a/tests/auto/qdbusabstractinterface/pinger.h +++ b/tests/auto/qdbusabstractinterface/pinger.h @@ -117,6 +117,13 @@ public Q_SLOTS: // METHODS return reply; } + inline QDBusPendingReply<int> sleepMethod(int in0) + { + QList<QVariant> argumentList; + argumentList << qVariantFromValue(in0); + return asyncCallWithArgumentList(QLatin1String("sleepMethod"), argumentList); + } + inline QDBusPendingReply<QString> stringMethod() { QList<QVariant> argumentList; diff --git a/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp b/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp index 00e3a76d15..994df058fa 100644 --- a/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp +++ b/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp @@ -111,6 +111,8 @@ private slots: void makeAsyncComplexCallPeer(); void makeAsyncMultiOutCallPeer(); + void callWithTimeout(); + void stringPropRead(); void stringPropWrite(); void variantPropRead(); @@ -458,6 +460,96 @@ void tst_QDBusAbstractInterface::makeAsyncMultiOutCallPeer() QCoreApplication::instance()->processEvents(); } +static const char server_serviceName[] = "com.trolltech.autotests.dbusserver"; +static const char server_objectPath[] = "/com/trolltech/server"; +static const char server_interfaceName[] = "com.trolltech.QtDBus.Pinger"; + +class DBusServerThread : public QThread +{ +public: + DBusServerThread() { + start(); + m_ready.acquire(); + } + ~DBusServerThread() { + quit(); + wait(); + } + + void run() + { + QDBusConnection con = QDBusConnection::connectToBus(QDBusConnection::SessionBus, "ThreadConnection"); + if (!con.isConnected()) + qWarning("Error registering to DBus"); + if (!con.registerService(server_serviceName)) + qWarning("Error registering service name"); + Interface targetObj; + con.registerObject(server_objectPath, &targetObj, QDBusConnection::ExportScriptableContents); + m_ready.release(); + exec(); + + QDBusConnection::disconnectFromBus( con.name() ); + } +private: + QSemaphore m_ready; +}; + +void tst_QDBusAbstractInterface::callWithTimeout() +{ + QDBusConnection con = QDBusConnection::sessionBus(); + QVERIFY2(con.isConnected(), "Not connected to D-Bus"); + + DBusServerThread serverThread; + + QDBusMessage msg = QDBusMessage::createMethodCall(server_serviceName, + server_objectPath, server_interfaceName, "sleepMethod"); + msg << 100; + + { + // Call with no timeout -> works + QDBusMessage reply = con.call(msg); + QCOMPARE((int)reply.type(), (int)QDBusMessage::ReplyMessage); + QCOMPARE(reply.arguments().at(0).toInt(), 42); + } + + { + // Call with 1 sec timeout -> fails + QDBusMessage reply = con.call(msg, QDBus::Block, 1); + QCOMPARE(reply.type(), QDBusMessage::ErrorMessage); + } + + // Now using QDBusInterface + + QDBusInterface iface(server_serviceName, server_objectPath, server_interfaceName, con); + { + // Call with no timeout + QDBusMessage reply = iface.call("sleepMethod", 100); + QCOMPARE(reply.type(), QDBusMessage::ReplyMessage); + QCOMPARE(reply.arguments().at(0).toInt(), 42); + } + { + // Call with 1 sec timeout -> fails + iface.setTimeout(1); + QDBusMessage reply = iface.call("sleepMethod", 100); + QCOMPARE(reply.type(), QDBusMessage::ErrorMessage); + } + + // Now using generated code + com::trolltech::QtDBus::Pinger p(server_serviceName, server_objectPath, QDBusConnection::sessionBus()); + { + // Call with no timeout + QDBusReply<int> reply = p.sleepMethod(100); + QVERIFY(reply.isValid()); + QCOMPARE(int(reply), 42); + } + { + // Call with 1 sec timeout -> fails + p.setTimeout(1); + QDBusReply<int> reply = p.sleepMethod(100); + QVERIFY(!reply.isValid()); + } +} + void tst_QDBusAbstractInterface::stringPropRead() { Pinger p = getPinger(); diff --git a/tests/auto/qfiledialog/qfiledialog.pro b/tests/auto/qfiledialog/qfiledialog.pro index c58dc0d5e7..2bf215bbba 100644 --- a/tests/auto/qfiledialog/qfiledialog.pro +++ b/tests/auto/qfiledialog/qfiledialog.pro @@ -26,3 +26,5 @@ wince* { } else { DEFINES += SRCDIR=\\\"$$PWD/\\\" } + +qpa:contains(QT_CONFIG,xcb):CONFIG+=insignificant_test diff --git a/tests/auto/qlistwidget/qlistwidget.pro b/tests/auto/qlistwidget/qlistwidget.pro index 51a8e9afd2..7343415e4c 100644 --- a/tests/auto/qlistwidget/qlistwidget.pro +++ b/tests/auto/qlistwidget/qlistwidget.pro @@ -3,4 +3,4 @@ QT += widgets widgets-private QT += core-private gui-private SOURCES += tst_qlistwidget.cpp - +qpa:contains(QT_CONFIG,xcb):CONFIG+=insignificant_test # QTBUG-21098, fails unstably diff --git a/tests/auto/qmenu/qmenu.pro b/tests/auto/qmenu/qmenu.pro index 089d9d516b..1fc1a7ff9d 100644 --- a/tests/auto/qmenu/qmenu.pro +++ b/tests/auto/qmenu/qmenu.pro @@ -1,3 +1,5 @@ load(qttest_p4) QT += widgets SOURCES += tst_qmenu.cpp + +qpa:contains(QT_CONFIG,xcb):CONFIG+=insignificant_test # QTBUG-21100, unstably fails diff --git a/tests/auto/qnetworkreply/test/test.pro b/tests/auto/qnetworkreply/test/test.pro index d415e04451..dba1c69dbb 100644 --- a/tests/auto/qnetworkreply/test/test.pro +++ b/tests/auto/qnetworkreply/test/test.pro @@ -3,6 +3,8 @@ QT -= gui SOURCES += ../tst_qnetworkreply.cpp TARGET = ../tst_qnetworkreply +qpa:contains(QT_CONFIG,xcb): CONFIG+=insignificant_test # unstable, QTBUG-21102 + win32 { CONFIG(debug, debug|release) { TARGET = ../../debug/tst_qnetworkreply |