summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-12-01 10:48:39 +1000
committerQt Continuous Integration System <qt-info@nokia.com>2011-12-01 10:48:39 +1000
commitf122bdc3014e9db00a747ad58042314cd868a762 (patch)
tree7df70d5049d76f0fe89a28e322e0c4a7beed4ce8 /tests
parentbb033b56ed2cd58fd51c891e759618cbe3b02c96 (diff)
parente20eaed5c1968e32eca97cf449fa588cfab35a5d (diff)
downloadqt4-tools-f122bdc3014e9db00a747ad58042314cd868a762.tar.gz
Merge branch 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1: Fix stack overwrite in QDBusDemarshaller Qt Linguist: Fix crashes fixed error generating wrong introspection string in header output file
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp82
1 files changed, 82 insertions, 0 deletions
diff --git a/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp
index cca212e278..9754a845c6 100644
--- a/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp
+++ b/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp
@@ -93,6 +93,9 @@ private slots:
void receiveUnknownType_data();
void receiveUnknownType();
+ void demarshallPrimitives_data();
+ void demarshallPrimitives();
+
private:
int fileDescriptorForTest();
@@ -1168,5 +1171,84 @@ void tst_QDBusMarshall::receiveUnknownType()
#endif
}
+void tst_QDBusMarshall::demarshallPrimitives_data()
+{
+ sendBasic_data();
+}
+
+template<class T>
+QVariant demarshallPrimitiveAs(const QDBusArgument& dbusArg)
+{
+ T val;
+ dbusArg >> val;
+ return qVariantFromValue(val);
+}
+
+QVariant demarshallPrimitiveAs(int typeIndex, const QDBusArgument& dbusArg)
+{
+ switch (typeIndex) {
+ case 0:
+ return demarshallPrimitiveAs<uchar>(dbusArg);
+ case 1:
+ return demarshallPrimitiveAs<bool>(dbusArg);
+ case 2:
+ return demarshallPrimitiveAs<short>(dbusArg);
+ case 3:
+ return demarshallPrimitiveAs<ushort>(dbusArg);
+ case 4:
+ return demarshallPrimitiveAs<int>(dbusArg);
+ case 5:
+ return demarshallPrimitiveAs<uint>(dbusArg);
+ case 6:
+ return demarshallPrimitiveAs<qlonglong>(dbusArg);
+ case 7:
+ return demarshallPrimitiveAs<qulonglong>(dbusArg);
+ case 8:
+ return demarshallPrimitiveAs<double>(dbusArg);
+ default:
+ return QVariant();
+ }
+}
+
+void tst_QDBusMarshall::demarshallPrimitives()
+{
+ QFETCH(QVariant, value);
+ QFETCH(QString, sig);
+
+ QDBusConnection con = QDBusConnection::sessionBus();
+
+ QVERIFY(con.isConnected());
+
+ // Demarshall each test data value to all primitive types to test
+ // demarshalling to the wrong type does not cause a crash
+ for (int typeIndex = 0; true; ++typeIndex) {
+ 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();
+ QCOMPARE(receiveArg.currentSignature(), sig);
+
+ const QVariant receiveValue = demarshallPrimitiveAs(typeIndex, receiveArg);
+ if (receiveValue.type() == value.type()) {
+ // Value type is the same, compare the values
+ QCOMPARE(receiveValue, value);
+ QVERIFY(receiveArg.atEnd());
+ }
+
+ receiveArg.endStructure();
+ QVERIFY(receiveArg.atEnd());
+
+ if (!receiveValue.isValid())
+ break;
+ }
+}
+
QTEST_MAIN(tst_QDBusMarshall)
#include "tst_qdbusmarshall.moc"