summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/dbus.pro2
-rw-r--r--tests/auto/qdbusmarshall/common.h69
-rw-r--r--tests/auto/qdbusmarshall/qdbusmarshall.pro2
-rw-r--r--tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp94
-rw-r--r--tests/auto/qdbusperformance/qdbusperformance.pro8
-rw-r--r--tests/auto/qdbustype/qdbustype.pro10
-rw-r--r--tests/auto/qdbustype/tst_qdbustype.cpp273
-rw-r--r--tests/auto/qsslkey/tst_qsslkey.cpp4
-rw-r--r--tests/benchmarks/benchmarks.pro1
-rw-r--r--tests/benchmarks/dbus/dbus.pro4
-rw-r--r--tests/benchmarks/dbus/qdbusperformance/.gitignore (renamed from tests/auto/qdbusperformance/.gitignore)0
-rw-r--r--tests/benchmarks/dbus/qdbusperformance/qdbusperformance.pro4
-rw-r--r--tests/benchmarks/dbus/qdbusperformance/server/server.cpp (renamed from tests/auto/qdbusperformance/server/server.cpp)0
-rw-r--r--tests/benchmarks/dbus/qdbusperformance/server/server.pro (renamed from tests/auto/qdbusperformance/server/server.pro)0
-rw-r--r--tests/benchmarks/dbus/qdbusperformance/serverobject.h (renamed from tests/auto/qdbusperformance/serverobject.h)0
-rw-r--r--tests/benchmarks/dbus/qdbusperformance/test/test.pro (renamed from tests/auto/qdbusperformance/test/test.pro)0
-rw-r--r--tests/benchmarks/dbus/qdbusperformance/tst_qdbusperformance.cpp (renamed from tests/auto/qdbusperformance/tst_qdbusperformance.cpp)0
-rw-r--r--tests/benchmarks/dbus/qdbustype/main.cpp115
-rw-r--r--tests/benchmarks/dbus/qdbustype/qdbustype.pro8
19 files changed, 582 insertions, 12 deletions
diff --git a/tests/auto/dbus.pro b/tests/auto/dbus.pro
index e5f87e3..31b46a3 100644
--- a/tests/auto/dbus.pro
+++ b/tests/auto/dbus.pro
@@ -11,9 +11,9 @@ SUBDIRS=\
qdbusmetatype \
qdbuspendingcall \
qdbuspendingreply \
- qdbusperformance \
qdbusreply \
qdbusservicewatcher \
+ qdbustype \
qdbusthreading \
qdbusxmlparser \
diff --git a/tests/auto/qdbusmarshall/common.h b/tests/auto/qdbusmarshall/common.h
index 532394a..8f7f3c3 100644
--- a/tests/auto/qdbusmarshall/common.h
+++ b/tests/auto/qdbusmarshall/common.h
@@ -39,6 +39,22 @@
**
****************************************************************************/
#include <math.h> // isnan
+#include <qvariant.h>
+
+#ifdef Q_OS_UNIX
+# include <private/qcore_unix_p.h>
+
+static bool compareFileDescriptors(int fd1, int fd2)
+{
+ QT_STATBUF st1, st2;
+ if (QT_FSTAT(fd1, &st1) == -1 || QT_FSTAT(fd2, &st2) == -1) {
+ perror("fstat");
+ return false;
+ }
+
+ return (st1.st_dev == st2.st_dev) && (st1.st_ino == st2.st_ino);
+}
+#endif
Q_DECLARE_METATYPE(QVariant)
Q_DECLARE_METATYPE(QList<bool>)
@@ -77,6 +93,22 @@ Q_DECLARE_METATYPE(ObjectPathStringMap)
Q_DECLARE_METATYPE(LLDateTimeMap)
Q_DECLARE_METATYPE(SignatureStringMap)
+static bool compare(const QDBusUnixFileDescriptor &t1, const QDBusUnixFileDescriptor &t2)
+{
+ int fd1 = t1.fileDescriptor();
+ int fd2 = t2.fileDescriptor();
+ if ((fd1 == -1 || fd2 == -1) && fd1 != fd2) {
+ // one is valid, the other isn't
+ return false;
+ }
+
+#ifdef Q_OS_UNIX
+ return compareFileDescriptors(fd1, fd2);
+#else
+ return true;
+#endif
+}
+
struct MyStruct
{
int i;
@@ -130,6 +162,32 @@ const QDBusArgument &operator>>(const QDBusArgument &arg, MyVariantMapStruct &ms
return arg;
}
+struct MyFileDescriptorStruct
+{
+ QDBusUnixFileDescriptor fd;
+
+ inline bool operator==(const MyFileDescriptorStruct &other) const
+ { return compare(fd, other.fd); }
+};
+Q_DECLARE_METATYPE(MyFileDescriptorStruct)
+Q_DECLARE_METATYPE(QList<MyFileDescriptorStruct>)
+
+QDBusArgument &operator<<(QDBusArgument &arg, const MyFileDescriptorStruct &ms)
+{
+ arg.beginStructure();
+ arg << ms.fd;
+ arg.endStructure();
+ return arg;
+}
+
+const QDBusArgument &operator>>(const QDBusArgument &arg, MyFileDescriptorStruct &ms)
+{
+ arg.beginStructure();
+ arg >> ms.fd;
+ arg.endStructure();
+ return arg;
+}
+
void commonInit()
{
@@ -157,6 +215,8 @@ void commonInit()
qDBusRegisterMetaType<MyStruct>();
qDBusRegisterMetaType<MyVariantMapStruct>();
qDBusRegisterMetaType<QList<MyVariantMapStruct> >();
+ qDBusRegisterMetaType<MyFileDescriptorStruct>();
+ qDBusRegisterMetaType<QList<MyFileDescriptorStruct> >();
}
#ifdef USE_PRIVATE_CODE
#include "private/qdbusintrospection_p.h"
@@ -467,6 +527,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);
@@ -511,6 +573,10 @@ bool compareToArgument(const QDBusArgument &arg, const QVariant &v2)
return compare<MyVariantMapStruct>(arg, v2);
else if (id == qMetaTypeId<QList<MyVariantMapStruct> >())
return compare<QList<MyVariantMapStruct> >(arg, v2);
+ else if (id == qMetaTypeId<MyFileDescriptorStruct>())
+ return compare<MyFileDescriptorStruct>(arg, v2);
+ else if (id == qMetaTypeId<QList<MyFileDescriptorStruct> >())
+ return compare<QList<MyFileDescriptorStruct> >(arg, v2);
}
qWarning() << "Unexpected QVariant type" << v2.userType()
@@ -563,6 +629,9 @@ template<> bool compare(const QVariant &v1, const QVariant &v2)
else if (id == qMetaTypeId<QDBusSignature>())
return qvariant_cast<QDBusSignature>(v1).signature() == qvariant_cast<QDBusSignature>(v2).signature();
+ else if (id == qMetaTypeId<QDBusUnixFileDescriptor>())
+ return compare(qvariant_cast<QDBusUnixFileDescriptor>(v1), qvariant_cast<QDBusUnixFileDescriptor>(v2));
+
else if (id == qMetaTypeId<QDBusVariant>())
return compare(qvariant_cast<QDBusVariant>(v1).variant(), qvariant_cast<QDBusVariant>(v2).variant());
diff --git a/tests/auto/qdbusmarshall/qdbusmarshall.pro b/tests/auto/qdbusmarshall/qdbusmarshall.pro
index f8e0875..ad40c0d 100644
--- a/tests/auto/qdbusmarshall/qdbusmarshall.pro
+++ b/tests/auto/qdbusmarshall/qdbusmarshall.pro
@@ -3,6 +3,8 @@ contains(QT_CONFIG,dbus): {
TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS = qpong test
+
+ requires(contains(QT_CONFIG,private_tests))
} else {
SOURCES += dummy.cpp
}
diff --git a/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp
index 9bae6af..737f0cf 100644
--- a/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp
+++ b/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp
@@ -42,6 +42,7 @@
#include <QtTest/QtTest>
#include <QtDBus/QtDBus>
#include <QtDBus/private/qdbusutil_p.h>
+#include <QtDBus/private/qdbusconnection_p.h>
#include "common.h"
#include <limits>
@@ -93,7 +94,11 @@ private slots:
void receiveUnknownType();
private:
+ int fileDescriptorForTest();
+
QProcess proc;
+ QTemporaryFile tempFile;
+ bool fileDescriptorPassing;
};
class QDBusMessageSpy: public QObject
@@ -116,6 +121,7 @@ void tst_QDBusMarshall::initTestCase()
{
commonInit();
QDBusConnection con = QDBusConnection::sessionBus();
+ fileDescriptorPassing = con.connectionCapabilities() & QDBusConnection::UnixFileDescriptorPassing;
#ifdef Q_OS_WIN
proc.start("qpong");
#else
@@ -144,6 +150,15 @@ void tst_QDBusMarshall::cleanupTestCase()
proc.waitForFinished(200);
}
+int tst_QDBusMarshall::fileDescriptorForTest()
+{
+ if (!tempFile.isOpen()) {
+ tempFile.setFileTemplate(QDir::tempPath() + "/qdbusmarshalltestXXXXXX.tmp");
+ tempFile.open();
+ }
+ return tempFile.handle();
+}
+
void tst_QDBusMarshall::sendBasic_data()
{
QTest::addColumn<QVariant>("value");
@@ -167,6 +182,9 @@ void tst_QDBusMarshall::sendBasic_data()
QTest::newRow("signature") << qVariantFromValue(QDBusSignature("g")) << "g" << "[Signature: g]";
QTest::newRow("emptystring") << QVariant("") << "s" << "\"\"";
QTest::newRow("nullstring") << QVariant(QString()) << "s" << "\"\"";
+
+ if (fileDescriptorPassing)
+ QTest::newRow("file-descriptor") << qVariantFromValue(QDBusUnixFileDescriptor(fileDescriptorForTest())) << "h" << "[Unix FD: valid]";
#endif
}
@@ -255,6 +273,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(fileDescriptorForTest()) << 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)
@@ -456,6 +486,12 @@ void tst_QDBusMarshall::sendMaps_data()
QTest::newRow("gs-map") << qVariantFromValue(gsmap) << "a{gs}"
<< "[Argument: a{gs} {[Signature: a{gs}] = \"array of dict_entry of (signature, string)\", [Signature: i] = \"int32\", [Signature: s] = \"string\"}]";
+ if (fileDescriptorPassing) {
+ svmap["zzfiledescriptor"] = qVariantFromValue(QDBusUnixFileDescriptor(fileDescriptorForTest()));
+ QTest::newRow("sv-map1-fd") << qVariantFromValue(svmap) << "a{sv}"
+ << "[Argument: a{sv} {\"a\" = [Variant(int): 1], \"b\" = [Variant(QByteArray): {99}], \"c\" = [Variant(QString): \"b\"], \"d\" = [Variant(uint): 42], \"e\" = [Variant(short): -47], \"f\" = [Variant: [Variant(int): 0]], \"zzfiledescriptor\" = [Variant(QDBusUnixFileDescriptor): [Unix FD: valid]]}]";
+ }
+
svmap.clear();
svmap["ismap"] = qVariantFromValue(ismap);
svmap["ssmap"] = qVariantFromValue(ssmap);
@@ -509,6 +545,18 @@ void tst_QDBusMarshall::sendStructs_data()
QTest::newRow("empty-list-of-string-variantmap") << qVariantFromValue(list) << "a(sa{sv})" << "[Argument: a(sa{sv}) {}]";
list << mvms;
QTest::newRow("list-of-string-variantmap") << qVariantFromValue(list) << "a(sa{sv})" << "[Argument: a(sa{sv}) {[Argument: (sa{sv}) \"Hello, World\", [Argument: a{sv} {\"bytearray\" = [Variant(QByteArray): {72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100}], \"int\" = [Variant(int): 42], \"short\" = [Variant(short): -47], \"uint\" = [Variant(uint): 42]}]]}]";
+
+ if (fileDescriptorPassing) {
+ MyFileDescriptorStruct fds;
+ fds.fd = QDBusUnixFileDescriptor(fileDescriptorForTest());
+ QTest::newRow("fdstruct") << qVariantFromValue(fds) << "(h)" << "[Argument: (h) [Unix FD: valid]]";
+
+ QList<MyFileDescriptorStruct> fdlist;
+ QTest::newRow("empty-list-of-fdstruct") << qVariantFromValue(fdlist) << "a(h)" << "[Argument: a(h) {}]";
+
+ fdlist << fds;
+ QTest::newRow("list-of-fdstruct") << qVariantFromValue(fdlist) << "a(h)" << "[Argument: a(h) {[Argument: (h) [Unix FD: valid]]}]";
+ }
}
void tst_QDBusMarshall::sendComplex_data()
@@ -642,6 +690,12 @@ void tst_QDBusMarshall::sendArgument_data()
arg << QString();
QTest::newRow("nullstring") << qVariantFromValue(arg) << "s" << int(QDBusArgument::BasicType);
+ if (fileDescriptorPassing) {
+ arg = QDBusArgument();
+ arg << QDBusUnixFileDescriptor(fileDescriptorForTest());
+ QTest::newRow("filedescriptor") << qVariantFromValue(arg) << "h" << int(QDBusArgument::BasicType);
+ }
+
arg = QDBusArgument();
arg << QDBusVariant(1);
QTest::newRow("variant") << qVariantFromValue(arg) << "v" << int(QDBusArgument::VariantType);
@@ -902,6 +956,27 @@ void tst_QDBusMarshall::sendCallErrors_data()
<< "Marshalling failed: Unregistered type UnregisteredType passed in arguments"
<< QString("QDBusMarshaller: type `UnregisteredType' (%1) is not registered with D-BUS. Use qDBusRegisterMetaType to register it")
.arg(qMetaTypeId<UnregisteredType>());
+
+ QTest::newRow("invalid-object-path-arg") << serviceName << objectPath << interfaceName << "ping"
+ << (QVariantList() << qVariantFromValue(QDBusObjectPath()))
+ << "org.freedesktop.DBus.Error.Failed"
+ << "Marshalling failed: Invalid object path passed in arguments"
+ << "";
+
+ QTest::newRow("invalid-signature-arg") << serviceName << objectPath << interfaceName << "ping"
+ << (QVariantList() << qVariantFromValue(QDBusSignature()))
+ << "org.freedesktop.DBus.Error.Failed"
+ << "Marshalling failed: Invalid signature passed in arguments"
+ << "";
+
+ // invalid file descriptor
+ if (fileDescriptorPassing) {
+ QTest::newRow("invalid-file-descriptor") << serviceName << objectPath << interfaceName << "ping"
+ << (QVariantList() << qVariantFromValue(QDBusUnixFileDescriptor(-1)))
+ << "org.freedesktop.DBus.Error.Failed"
+ << "Marshalling failed: Invalid file descriptor passed in arguments"
+ << "";
+ }
}
void tst_QDBusMarshall::sendCallErrors()
@@ -967,6 +1042,21 @@ typedef QScopedPointer<DBusConnection, DisconnectRawDBus> ScopedDBusConnection;
typedef QScopedPointer<DBusMessage, GenericUnref<DBusMessage, dbus_message_unref> > ScopedDBusMessage;
typedef QScopedPointer<DBusPendingCall, GenericUnref<DBusPendingCall, dbus_pending_call_unref> > ScopedDBusPendingCall;
+template <typename T> struct SetResetValue
+{
+ const T oldValue;
+ T &value;
+public:
+ SetResetValue(T &v, T newValue) : oldValue(v), value(v)
+ {
+ value = newValue;
+ }
+ ~SetResetValue()
+ {
+ value = oldValue;
+ }
+};
+
void tst_QDBusMarshall::receiveUnknownType()
{
#ifndef DBUS_TYPE_UNIX_FD
@@ -986,6 +1076,10 @@ void tst_QDBusMarshall::receiveUnknownType()
if (!dbus_connection_can_send_type(rawcon.data(), DBUS_TYPE_UNIX_FD))
QSKIP("Your session bus does not allow sending Unix file descriptors", SkipAll);
+ // make sure this QDBusConnection won't handle Unix file descriptors
+ QDBusConnection::ConnectionCapabilities &capabRef = QDBusConnectionPrivate::d(con)->capabilities;
+ SetResetValue<QDBusConnection::ConnectionCapabilities> resetter(capabRef, capabRef & ~QDBusConnection::UnixFileDescriptorPassing);
+
if (qstrcmp(QTest::currentDataTag(), "in-call") == 0) {
// create a call back to us containing a file descriptor
QDBusMessageSpy spy;
diff --git a/tests/auto/qdbusperformance/qdbusperformance.pro b/tests/auto/qdbusperformance/qdbusperformance.pro
deleted file mode 100644
index 6880518..0000000
--- a/tests/auto/qdbusperformance/qdbusperformance.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,dbus): {
- TEMPLATE = subdirs
- CONFIG += ordered
- SUBDIRS = server test
-} else {
- SOURCES += ../qdbusmarshall/dummy.cpp
-}
diff --git a/tests/auto/qdbustype/qdbustype.pro b/tests/auto/qdbustype/qdbustype.pro
new file mode 100644
index 0000000..e2f0c90
--- /dev/null
+++ b/tests/auto/qdbustype/qdbustype.pro
@@ -0,0 +1,10 @@
+load(qttest_p4)
+QT = core
+contains(QT_CONFIG,dbus): {
+ SOURCES += tst_qdbustype.cpp
+ QT += dbus
+ QMAKE_CXXFLAGS += $$QT_CFLAGS_DBUS
+ LIBS_PRIVATE += $$QT_LIBS_DBUS
+} else {
+ SOURCES += ../qdbusmarshall/dummy.cpp
+}
diff --git a/tests/auto/qdbustype/tst_qdbustype.cpp b/tests/auto/qdbustype/tst_qdbustype.cpp
new file mode 100644
index 0000000..676a904
--- /dev/null
+++ b/tests/auto/qdbustype/tst_qdbustype.cpp
@@ -0,0 +1,273 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the FOO module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtCore/QCoreApplication>
+
+#include <QtDBus/private/qdbusutil_p.h>
+
+#include <dbus/dbus.h>
+
+class tst_QDBusType : public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+ void isValidFixedType_data();
+ void isValidFixedType();
+ void isValidBasicType_data();
+ void isValidBasicType();
+ void isValidSingleSignature_data();
+ void isValidSingleSignature();
+ void isValidArray_data();
+ void isValidArray();
+ void isValidSignature_data();
+ void isValidSignature();
+};
+
+enum { Invalid = false, Valid = true };
+
+static void addColumns()
+{
+ // All tests use these two columns only
+ QTest::addColumn<QString>("data");
+ QTest::addColumn<bool>("result");
+ QTest::addColumn<bool>("isValid");
+}
+
+// ---- type adds ---
+static void addFixedTypes()
+{
+ QTest::newRow("bool") << DBUS_TYPE_BOOLEAN_AS_STRING << true << true;
+ QTest::newRow("byte") << DBUS_TYPE_BYTE_AS_STRING << true << true;
+ QTest::newRow("int16") << DBUS_TYPE_INT16_AS_STRING << true << true;
+ QTest::newRow("uint16") << DBUS_TYPE_UINT16_AS_STRING << true << true;
+ QTest::newRow("int32") << DBUS_TYPE_INT32_AS_STRING << true << true;
+ QTest::newRow("uint32") << DBUS_TYPE_UINT32_AS_STRING << true << true;
+ QTest::newRow("int64") << DBUS_TYPE_INT64_AS_STRING << true << true;
+ QTest::newRow("uint64") << DBUS_TYPE_UINT64_AS_STRING << true << true;
+ QTest::newRow("double") << DBUS_TYPE_DOUBLE_AS_STRING << true << true;
+#ifdef DBUS_TYPE_UNIX_FD_AS_STRING
+ QTest::newRow("unixfd") << DBUS_TYPE_UNIX_FD_AS_STRING << true << true;
+#endif
+}
+
+static void addInvalidSingleLetterTypes()
+{
+ QChar nulString[] = { 0 };
+ QTest::newRow("nul") << QString(nulString, 1) << false << false;
+ QTest::newRow("tilde") << "~" << false << false;
+ QTest::newRow("struct-begin") << "(" << false << false;
+ QTest::newRow("struct-end") << ")" << false << false;
+ QTest::newRow("dict-entry-begin") << "{" << false << false;
+ QTest::newRow("dict-entry-end") << "}" << false << false;
+ QTest::newRow("array-no-element") << "a" << false << false;
+}
+
+static void addBasicTypes(bool basicsAreValid)
+{
+ addFixedTypes();
+ QTest::newRow("string") << DBUS_TYPE_STRING_AS_STRING << basicsAreValid << true;
+ QTest::newRow("object-path") << DBUS_TYPE_OBJECT_PATH_AS_STRING << basicsAreValid << true;
+ QTest::newRow("signature") << DBUS_TYPE_SIGNATURE_AS_STRING << basicsAreValid << true;
+}
+
+static void addVariant(bool variantIsValid)
+{
+ QTest::newRow("variant") << "v" << variantIsValid << true;
+}
+
+static void addSingleSignatures()
+{
+ addBasicTypes(Valid);
+ addVariant(Valid);
+ QTest::newRow("struct-1") << "(y)" << true;
+ QTest::newRow("struct-2") << "(yy)" << true;
+ QTest::newRow("struct-3") << "(yyv)" << true;
+
+ QTest::newRow("struct-nested-1") << "((y))" << true;
+ QTest::newRow("struct-nested-2") << "((yy))" << true;
+ QTest::newRow("struct-nested-3") << "(y(y))" << true;
+ QTest::newRow("struct-nested-4") << "((y)y)" << true;
+ QTest::newRow("struct-nested-5") << "(y(y)y)" << true;
+ QTest::newRow("struct-nested-6") << "((y)(y))" << true;
+
+ QTest::newRow("array-1") << "as" << true;
+ QTest::newRow("struct-array-1") << "(as)" << true;
+ QTest::newRow("struct-array-2") << "(yas)" << true;
+ QTest::newRow("struct-array-3") << "(asy)" << true;
+ QTest::newRow("struct-array-4") << "(yasy)" << true;
+
+ QTest::newRow("dict-1") << "a{sy}" << true;
+ QTest::newRow("dict-2") << "a{sv}" << true;
+ QTest::newRow("dict-struct-1") << "a{s(y)}" << true;
+ QTest::newRow("dict-struct-2") << "a{s(yyyy)}" << true;
+ QTest::newRow("dict-struct-array") << "a{s(ay)}" << true;
+ QTest::newRow("dict-array") << "a{sas}" << true;
+ QTest::newRow("dict-array-struct") << "a{sa(y)}" << true;
+
+ addInvalidSingleLetterTypes();
+ QTest::newRow("naked-dict-empty") << "{}" << false;
+ QTest::newRow("naked-dict-missing-value") << "{i}" << false;
+
+ QTest::newRow("dict-empty") << "a{}" << false;
+ QTest::newRow("dict-missing-value") << "a{i}" << false;
+ QTest::newRow("dict-non-basic-key") << "a{vi}" << false;
+ QTest::newRow("dict-struct-key") << "a{(y)y}" << false;
+ QTest::newRow("dict-missing-close") << "a{sv" << false;
+ QTest::newRow("dict-mismatched-close") << "a{sv)" << false;
+ QTest::newRow("dict-missing-value-close") << "a{s" << false;
+
+ QTest::newRow("empty-struct") << "()" << false;
+ QTest::newRow("struct-missing-close") << "(s" << false;
+ QTest::newRow("struct-nested-missing-close-1") << "((s)" << false;
+ QTest::newRow("struct-nested-missing-close-2") << "((s" << false;
+
+ QTest::newRow("struct-ending-array-no-element") << "(a)" << false;
+}
+
+static void addNakedDictEntry()
+{
+ QTest::newRow("naked-dict-entry") << "{sv}" << false;
+}
+
+// ---- tests ----
+
+void tst_QDBusType::isValidFixedType_data()
+{
+ addColumns();
+ addFixedTypes();
+ addBasicTypes(Invalid);
+ addVariant(Invalid);
+ addInvalidSingleLetterTypes();
+}
+
+void tst_QDBusType::isValidFixedType()
+{
+ QFETCH(QString, data);
+ QFETCH(bool, result);
+ QFETCH(bool, isValid);
+ Q_ASSERT_X(data.length() == 1, "tst_QDBusType", "Test is malformed, this function must test only one-letter types");
+ Q_ASSERT(isValid || (!isValid && !result));
+
+ int type = data.at(0).unicode();
+ if (isValid)
+ QCOMPARE(bool(dbus_type_is_fixed(type)), result);
+ QCOMPARE(QDBusUtil::isValidFixedType(type), result);
+}
+
+void tst_QDBusType::isValidBasicType_data()
+{
+ addColumns();
+ addBasicTypes(Valid);
+ addVariant(Invalid);
+ addInvalidSingleLetterTypes();
+}
+
+void tst_QDBusType::isValidBasicType()
+{
+ QFETCH(QString, data);
+ QFETCH(bool, result);
+ QFETCH(bool, isValid);
+ Q_ASSERT_X(data.length() == 1, "tst_QDBusType", "Test is malformed, this function must test only one-letter types");
+ Q_ASSERT(isValid || (!isValid && !result));
+
+ int type = data.at(0).unicode();
+ if (isValid)
+ QCOMPARE(bool(dbus_type_is_basic(type)), result);
+ QCOMPARE(QDBusUtil::isValidBasicType(type), result);
+}
+
+void tst_QDBusType::isValidSingleSignature_data()
+{
+ addColumns();
+ addSingleSignatures();
+ addNakedDictEntry();
+}
+
+void tst_QDBusType::isValidSingleSignature()
+{
+ QFETCH(QString, data);
+ QFETCH(bool, result);
+
+ QCOMPARE(bool(dbus_signature_validate_single(data.toLatin1(), 0)), result);
+ QCOMPARE(QDBusUtil::isValidSingleSignature(data), result);
+}
+
+void tst_QDBusType::isValidArray_data()
+{
+ addColumns();
+ addSingleSignatures();
+}
+
+void tst_QDBusType::isValidArray()
+{
+ QFETCH(QString, data);
+ QFETCH(bool, result);
+
+ data.prepend("a");
+ QCOMPARE(bool(dbus_signature_validate_single(data.toLatin1(), 0)), result);
+ QCOMPARE(QDBusUtil::isValidSingleSignature(data), result);
+
+ data.prepend("a");
+ QCOMPARE(bool(dbus_signature_validate_single(data.toLatin1(), 0)), result);
+ QCOMPARE(QDBusUtil::isValidSingleSignature(data), result);
+}
+
+void tst_QDBusType::isValidSignature_data()
+{
+ isValidSingleSignature_data();
+}
+
+void tst_QDBusType::isValidSignature()
+{
+ QFETCH(QString, data);
+ QFETCH(bool, result);
+
+ data.append(data);
+ if (data.at(0).unicode())
+ QCOMPARE(bool(dbus_signature_validate(data.toLatin1(), 0)), result);
+ QCOMPARE(QDBusUtil::isValidSignature(data), result);
+}
+
+QTEST_MAIN(tst_QDBusType)
+
+#include "tst_qdbustype.moc"
diff --git a/tests/auto/qsslkey/tst_qsslkey.cpp b/tests/auto/qsslkey/tst_qsslkey.cpp
index e7b4740..86da09e 100644
--- a/tests/auto/qsslkey/tst_qsslkey.cpp
+++ b/tests/auto/qsslkey/tst_qsslkey.cpp
@@ -108,10 +108,8 @@ tst_QSslKey::tst_QSslKey()
#ifdef Q_WS_MAC
// applicationDirPath() points to a path inside the app bundle on Mac.
QDir dir(qApp->applicationDirPath() + QLatin1String("/../../../keys"));
-#elif defined(Q_OS_WIN) || defined (Q_OS_SYMBIAN)
- QDir dir(SRCDIR + QLatin1String("/keys")); // prefer this way to avoid ifdeffery and support shadow builds?
#else
- QDir dir(qApp->applicationDirPath() + QLatin1String("/keys"));
+ QDir dir(SRCDIR + QLatin1String("/keys")); // prefer this way to avoid ifdeffery and support shadow builds?
#endif
QFileInfoList fileInfoList = dir.entryInfoList(QDir::Files | QDir::Readable);
QRegExp rx(QLatin1String("^(rsa|dsa)-(pub|pri)-(\\d+)\\.(pem|der)$"));
diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro
index 00a1b37..b5e3a4b 100644
--- a/tests/benchmarks/benchmarks.pro
+++ b/tests/benchmarks/benchmarks.pro
@@ -7,6 +7,7 @@ SUBDIRS = \
svg
contains(QT_CONFIG, opengl): SUBDIRS += opengl
contains(QT_CONFIG, declarative): SUBDIRS += declarative
+contains(QT_CONFIG, dbus): SUBDIRS += dbus
check-trusted.CONFIG += recursive
QMAKE_EXTRA_TARGETS += check-trusted
diff --git a/tests/benchmarks/dbus/dbus.pro b/tests/benchmarks/dbus/dbus.pro
new file mode 100644
index 0000000..989a0db
--- /dev/null
+++ b/tests/benchmarks/dbus/dbus.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+SUBDIRS = \
+ qdbusperformance \
+ qdbustype
diff --git a/tests/auto/qdbusperformance/.gitignore b/tests/benchmarks/dbus/qdbusperformance/.gitignore
index 4cd8399..4cd8399 100644
--- a/tests/auto/qdbusperformance/.gitignore
+++ b/tests/benchmarks/dbus/qdbusperformance/.gitignore
diff --git a/tests/benchmarks/dbus/qdbusperformance/qdbusperformance.pro b/tests/benchmarks/dbus/qdbusperformance/qdbusperformance.pro
new file mode 100644
index 0000000..90f88a7
--- /dev/null
+++ b/tests/benchmarks/dbus/qdbusperformance/qdbusperformance.pro
@@ -0,0 +1,4 @@
+load(qttest_p4)
+TEMPLATE = subdirs
+CONFIG += ordered
+SUBDIRS = server test
diff --git a/tests/auto/qdbusperformance/server/server.cpp b/tests/benchmarks/dbus/qdbusperformance/server/server.cpp
index 3bd5efc..3bd5efc 100644
--- a/tests/auto/qdbusperformance/server/server.cpp
+++ b/tests/benchmarks/dbus/qdbusperformance/server/server.cpp
diff --git a/tests/auto/qdbusperformance/server/server.pro b/tests/benchmarks/dbus/qdbusperformance/server/server.pro
index 30f81dd..30f81dd 100644
--- a/tests/auto/qdbusperformance/server/server.pro
+++ b/tests/benchmarks/dbus/qdbusperformance/server/server.pro
diff --git a/tests/auto/qdbusperformance/serverobject.h b/tests/benchmarks/dbus/qdbusperformance/serverobject.h
index 6f85bb4..6f85bb4 100644
--- a/tests/auto/qdbusperformance/serverobject.h
+++ b/tests/benchmarks/dbus/qdbusperformance/serverobject.h
diff --git a/tests/auto/qdbusperformance/test/test.pro b/tests/benchmarks/dbus/qdbusperformance/test/test.pro
index 9f5712e..9f5712e 100644
--- a/tests/auto/qdbusperformance/test/test.pro
+++ b/tests/benchmarks/dbus/qdbusperformance/test/test.pro
diff --git a/tests/auto/qdbusperformance/tst_qdbusperformance.cpp b/tests/benchmarks/dbus/qdbusperformance/tst_qdbusperformance.cpp
index a5b4b98..a5b4b98 100644
--- a/tests/auto/qdbusperformance/tst_qdbusperformance.cpp
+++ b/tests/benchmarks/dbus/qdbusperformance/tst_qdbusperformance.cpp
diff --git a/tests/benchmarks/dbus/qdbustype/main.cpp b/tests/benchmarks/dbus/qdbustype/main.cpp
new file mode 100644
index 0000000..abaae7e
--- /dev/null
+++ b/tests/benchmarks/dbus/qdbustype/main.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the FOO module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtCore/QCoreApplication>
+
+#include <QtDBus/private/qdbusutil_p.h>
+
+#include <dbus/dbus.h>
+
+class tst_QDBusType: public QObject
+{
+ Q_OBJECT
+private Q_SLOTS:
+ void benchmarkSignature_data();
+ void benchmarkSignature();
+};
+
+static inline void benchmarkAddRow(const char *name, const char *data)
+{
+ QTest::newRow(QByteArray("native-") + name) << data << true;
+ QTest::newRow(name) << data << false;
+}
+
+void tst_QDBusType::benchmarkSignature_data()
+{
+ QTest::addColumn<QString>("data");
+ QTest::addColumn<bool>("useNative");
+
+ for (int loopCount = 0; loopCount < 2; ++loopCount) {
+ bool useNative = loopCount;
+ QByteArray prefix = useNative ? "native-" : "";
+
+ benchmarkAddRow("single-invalid", "~");
+ benchmarkAddRow("single-invalid-array", "a~");
+ benchmarkAddRow("single-invalid-struct", "(.)");
+
+ benchmarkAddRow("single-char", "b");
+ benchmarkAddRow("single-array", "as");
+ benchmarkAddRow("single-simplestruct", "(y)");
+ benchmarkAddRow("single-simpledict", "a{sv}");
+ benchmarkAddRow("single-complexdict", "a{s(aya{io})}");
+
+ benchmarkAddRow("multiple-char", "ssg");
+ benchmarkAddRow("multiple-arrays", "asasay");
+
+ benchmarkAddRow("struct-missingclose", "(ayyyy");
+ benchmarkAddRow("longstruct", "(yyyyyyayasy)");
+ benchmarkAddRow("invalid-longstruct", "(yyyyyyayas.y)");
+ benchmarkAddRow("complexstruct", "(y(aasay)oga{sv})");
+ benchmarkAddRow("multiple-simple-structs", "(y)(y)(y)");
+ }
+}
+
+void tst_QDBusType::benchmarkSignature()
+{
+ QFETCH(QString, data);
+ QFETCH(bool, useNative);
+
+ bool result;
+ if (useNative) {
+ dbus_signature_validate(data.toLatin1(), 0);
+ QBENCHMARK {
+ result = dbus_signature_validate(data.toLatin1(), 0);
+ }
+ } else {
+ QDBusUtil::isValidSignature(data);
+ QBENCHMARK {
+ result = QDBusUtil::isValidSignature(data);
+ }
+ }
+ Q_UNUSED(result);
+}
+
+QTEST_MAIN(tst_QDBusType)
+
+#include "main.moc"
diff --git a/tests/benchmarks/dbus/qdbustype/qdbustype.pro b/tests/benchmarks/dbus/qdbustype/qdbustype.pro
new file mode 100644
index 0000000..d480a05
--- /dev/null
+++ b/tests/benchmarks/dbus/qdbustype/qdbustype.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+TARGET = tst_bench_qdbustype
+QT -= gui
+QT += dbus
+QMAKE_CXXFLAGS += $$QT_CFLAGS_DBUS
+LIBS_PRIVATE += $$QT_LIBS_DBUS
+
+SOURCES += main.cpp