summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2011-02-16 14:30:49 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2011-04-13 12:56:23 (GMT)
commit376239da147f7954f49e1c18dd53afcd57c3f771 (patch)
tree1ffd1e4d4e18879672fa54bb280beead710758ec
parent6d325d6f70c419d1fee49da1738633a3e03b46d4 (diff)
downloadQt-376239da147f7954f49e1c18dd53afcd57c3f771.zip
Qt-376239da147f7954f49e1c18dd53afcd57c3f771.tar.gz
Qt-376239da147f7954f49e1c18dd53afcd57c3f771.tar.bz2
Autotest: Test QDBusUnixFileDescriptor support in arrays
Task-number: QTBUG-17477
-rw-r--r--tests/auto/qdbusmarshall/common.h2
-rw-r--r--tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp16
2 files changed, 17 insertions, 1 deletions
diff --git a/tests/auto/qdbusmarshall/common.h b/tests/auto/qdbusmarshall/common.h
index b32b581..dfa5206 100644
--- a/tests/auto/qdbusmarshall/common.h
+++ b/tests/auto/qdbusmarshall/common.h
@@ -475,6 +475,8 @@ bool compareToArgument(const QDBusArgument &arg, const QVariant &v2)
return compare<QList<QDBusObjectPath> >(arg, v2);
else if (id == qMetaTypeId<QList<QDBusSignature> >())
return compare<QList<QDBusSignature> >(arg, v2);
+ else if (id == qMetaTypeId<QList<QDBusUnixFileDescriptor> >())
+ return compare<QList<QDBusUnixFileDescriptor> >(arg, v2);
else if (id == qMetaTypeId<QList<QDateTime> >())
return compare<QList<QDateTime> >(arg, v2);
diff --git a/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp
index 828a807..df31ca2 100644
--- a/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp
+++ b/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp
@@ -95,6 +95,7 @@ private slots:
private:
QProcess proc;
+ bool fileDescriptorPassing;
};
class QDBusMessageSpy: public QObject
@@ -117,6 +118,7 @@ void tst_QDBusMarshall::initTestCase()
{
commonInit();
QDBusConnection con = QDBusConnection::sessionBus();
+ fileDescriptorPassing = con.connectionCapabilities() & QDBusConnection::UnixFileDescriptorPassing;
#ifdef Q_OS_WIN
proc.start("qpong");
#else
@@ -169,7 +171,7 @@ void tst_QDBusMarshall::sendBasic_data()
QTest::newRow("emptystring") << QVariant("") << "s" << "\"\"";
QTest::newRow("nullstring") << QVariant(QString()) << "s" << "\"\"";
- if (QDBusConnection::sessionBus().connectionCapabilities() & QDBusConnection::UnixFileDescriptorPassing)
+ if (fileDescriptorPassing)
QTest::newRow("file-descriptor") << qVariantFromValue(QDBusUnixFileDescriptor(0)) << "h" << "[Unix FD: valid]";
#endif
}
@@ -259,6 +261,18 @@ void tst_QDBusMarshall::sendArrays_data()
<< std::numeric_limits<double>::quiet_NaN();
QTest::newRow("doublelist") << qVariantFromValue(doubles) << "ad" << "[Argument: ad {1.2, 2.2, 4.4, -inf, inf, nan}]";
+ QList<QDBusObjectPath> objectPaths;
+ QTest::newRow("emptyobjectpathlist") << qVariantFromValue(objectPaths) << "ao" << "[Argument: ao {}]";
+ objectPaths << QDBusObjectPath("/") << QDBusObjectPath("/foo");
+ QTest::newRow("objectpathlist") << qVariantFromValue(objectPaths) << "ao" << "[Argument: ao {[ObjectPath: /], [ObjectPath: /foo]}]";
+
+ if (fileDescriptorPassing) {
+ QList<QDBusUnixFileDescriptor> fileDescriptors;
+ QTest::newRow("emptyfiledescriptorlist") << qVariantFromValue(fileDescriptors) << "ah" << "[Argument: ah {}]";
+ fileDescriptors << QDBusUnixFileDescriptor(0) << QDBusUnixFileDescriptor(1);
+ QTest::newRow("filedescriptorlist") << qVariantFromValue(fileDescriptors) << "ah" << "[Argument: ah {[Unix FD: valid], [Unix FD: valid]}]";
+ }
+
QVariantList variants;
QTest::newRow("emptyvariantlist") << QVariant(variants) << "av" << "[Argument: av {}]";
variants << QString("Hello") << QByteArray("World") << 42 << -43.0 << 44U << Q_INT64_C(-45)