summaryrefslogtreecommitdiffstats
path: root/tests/auto/dbus
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/dbus')
-rw-r--r--tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp
index ac8b5c1416..8ce456bf0e 100644
--- a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp
+++ b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp
@@ -99,6 +99,9 @@ private slots:
void demarshallStrings_data();
void demarshallStrings();
+ void demarshallInvalidStringList_data();
+ void demarshallInvalidStringList();
+
private:
int fileDescriptorForTest();
@@ -1375,5 +1378,54 @@ void tst_QDBusMarshall::demarshallStrings()
QVERIFY(receiveArg.atEnd());
}
+void tst_QDBusMarshall::demarshallInvalidStringList_data()
+{
+ addBasicTypesColumns();
+
+ // None of the basic types should demarshall to a string list
+ basicNumericTypes_data();
+ basicStringTypes_data();
+
+ // Arrays of non-string type should not demarshall to a string list
+ QList<bool> bools;
+ QTest::newRow("emptyboollist") << qVariantFromValue(bools);
+ bools << false << true << false;
+ QTest::newRow("boollist") << qVariantFromValue(bools);
+
+ // Structures should not demarshall to a QByteArray
+ QTest::newRow("struct of strings")
+ << qVariantFromValue(QVariantList() << QString("foo") << QString("bar"));
+ QTest::newRow("struct of mixed types")
+ << qVariantFromValue(QVariantList() << QString("foo") << int(42) << double(3.14));
+}
+
+void tst_QDBusMarshall::demarshallInvalidStringList()
+{
+ QFETCH(QVariant, value);
+
+ QDBusConnection con = QDBusConnection::sessionBus();
+
+ QVERIFY(con.isConnected());
+
+ QDBusMessage msg = QDBusMessage::createMethodCall(serviceName, objectPath,
+ interfaceName, "ping");
+ QDBusArgument sendArg;
+ sendArg.beginStructure();
+ sendArg.appendVariant(value);
+ sendArg.endStructure();
+ msg.setArguments(QVariantList() << qVariantFromValue(sendArg));
+ QDBusMessage reply = con.call(msg);
+
+ const QDBusArgument receiveArg = qvariant_cast<QDBusArgument>(reply.arguments().at(0));
+ receiveArg.beginStructure();
+
+ QStringList receiveValue;
+ receiveArg >> receiveValue;
+ QCOMPARE(receiveValue, QStringList());
+
+ receiveArg.endStructure();
+ QVERIFY(receiveArg.atEnd());
+}
+
QTEST_MAIN(tst_QDBusMarshall)
#include "tst_qdbusmarshall.moc"