summaryrefslogtreecommitdiff
path: root/tests/auto/qdbusabstractinterface
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2009-07-01 17:45:17 +0200
committerThiago Macieira <thiago.macieira@nokia.com>2009-07-02 11:43:45 +0200
commit43a760280edd49382d01eb1e23ae2a08933b6bf7 (patch)
tree249412355ba5403fdf594e67fdf59a55bbaf64f2 /tests/auto/qdbusabstractinterface
parent962b7fde5194a08a83609b9b4367425e52f76614 (diff)
downloadqt4-tools-43a760280edd49382d01eb1e23ae2a08933b6bf7.tar.gz
Autotest: add tests for checking variant properties
Diffstat (limited to 'tests/auto/qdbusabstractinterface')
-rw-r--r--tests/auto/qdbusabstractinterface/com.trolltech.QtDBus.Pinger.xml1
-rw-r--r--tests/auto/qdbusabstractinterface/interface.h4
-rw-r--r--tests/auto/qdbusabstractinterface/pinger.h10
-rw-r--r--tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp47
4 files changed, 60 insertions, 2 deletions
diff --git a/tests/auto/qdbusabstractinterface/com.trolltech.QtDBus.Pinger.xml b/tests/auto/qdbusabstractinterface/com.trolltech.QtDBus.Pinger.xml
index 8909675a52..fb2aab811f 100644
--- a/tests/auto/qdbusabstractinterface/com.trolltech.QtDBus.Pinger.xml
+++ b/tests/auto/qdbusabstractinterface/com.trolltech.QtDBus.Pinger.xml
@@ -2,6 +2,7 @@
<node>
<interface name="com.trolltech.QtDBus.Pinger">
<property name="stringProp" type="s" access="readwrite"/>
+ <property name="variantProp" type="v" access="readwrite"/>
<property name="complexProp" type="(s)" access="readwrite">
<annotation name="com.trolltech.QtDBus.QtTypeName" value="RegisteredType"/>
</property>
diff --git a/tests/auto/qdbusabstractinterface/interface.h b/tests/auto/qdbusabstractinterface/interface.h
index 86e0dc437c..f6d34a7f98 100644
--- a/tests/auto/qdbusabstractinterface/interface.h
+++ b/tests/auto/qdbusabstractinterface/interface.h
@@ -80,10 +80,12 @@ class Interface: public QObject
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "com.trolltech.QtDBus.Pinger")
Q_PROPERTY(QString stringProp READ stringProp WRITE setStringProp SCRIPTABLE true)
+ Q_PROPERTY(QDBusVariant variantProp READ variantProp WRITE setVariantProp SCRIPTABLE true)
Q_PROPERTY(RegisteredType complexProp READ complexProp WRITE setComplexProp SCRIPTABLE true)
friend class tst_QDBusAbstractInterface;
QString m_stringProp;
+ QDBusVariant m_variantProp;
RegisteredType m_complexProp;
public:
@@ -91,6 +93,8 @@ public:
QString stringProp() const { return m_stringProp; }
void setStringProp(const QString &s) { m_stringProp = s; }
+ QDBusVariant variantProp() const { return m_variantProp; }
+ void setVariantProp(const QDBusVariant &v) { m_variantProp = v; }
RegisteredType complexProp() const { return m_complexProp; }
void setComplexProp(const RegisteredType &r) { m_complexProp = r; }
diff --git a/tests/auto/qdbusabstractinterface/pinger.h b/tests/auto/qdbusabstractinterface/pinger.h
index 3ff218c589..6e92e65109 100644
--- a/tests/auto/qdbusabstractinterface/pinger.h
+++ b/tests/auto/qdbusabstractinterface/pinger.h
@@ -49,8 +49,8 @@
* Do not edit! All changes made to it will be lost.
*/
-#ifndef PINGER_H_1246371899
-#define PINGER_H_1246371899
+#ifndef PINGER_H_1246460303
+#define PINGER_H_1246460303
#include <QtCore/QObject>
#include <QtCore/QByteArray>
@@ -89,6 +89,12 @@ public:
inline void setStringProp(const QString &value)
{ internalPropSet("stringProp", qVariantFromValue(value)); }
+ Q_PROPERTY(QDBusVariant variantProp READ variantProp WRITE setVariantProp)
+ inline QDBusVariant variantProp() const
+ { return qvariant_cast< QDBusVariant >(internalPropGet("variantProp")); }
+ inline void setVariantProp(const QDBusVariant &value)
+ { internalPropSet("variantProp", qVariantFromValue(value)); }
+
public Q_SLOTS: // METHODS
inline QDBusPendingReply<RegisteredType> complexMethod()
{
diff --git a/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp b/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp
index 4aee089a90..fa5e332130 100644
--- a/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp
+++ b/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp
@@ -84,11 +84,15 @@ private slots:
void stringPropRead();
void stringPropWrite();
+ void variantPropRead();
+ void variantPropWrite();
void complexPropRead();
void complexPropWrite();
void stringPropDirectRead();
void stringPropDirectWrite();
+ void variantPropDirectRead();
+ void variantPropDirectWrite();
void complexPropDirectRead();
void complexPropDirectWrite();
@@ -242,6 +246,29 @@ void tst_QDBusAbstractInterface::stringPropWrite()
QCOMPARE(targetObj.m_stringProp, expectedValue);
}
+void tst_QDBusAbstractInterface::variantPropRead()
+{
+ Pinger p = getPinger();
+ QVERIFY2(p, "Not connected to D-Bus");
+
+ QDBusVariant expectedValue = targetObj.m_variantProp = QDBusVariant(QVariant(42));
+ QVariant v = p->property("variantProp");
+ QVERIFY(v.isValid());
+ QDBusVariant value = v.value<QDBusVariant>();
+ QCOMPARE(value.variant().userType(), expectedValue.variant().userType());
+ QCOMPARE(value.variant(), expectedValue.variant());
+}
+
+void tst_QDBusAbstractInterface::variantPropWrite()
+{
+ Pinger p = getPinger();
+ QVERIFY2(p, "Not connected to D-Bus");
+
+ QDBusVariant expectedValue = QDBusVariant(Q_INT64_C(-47));
+ QVERIFY(p->setProperty("variantProp", qVariantFromValue(expectedValue)));
+ QCOMPARE(targetObj.m_variantProp.variant(), expectedValue.variant());
+}
+
void tst_QDBusAbstractInterface::complexPropRead()
{
Pinger p = getPinger();
@@ -282,6 +309,26 @@ void tst_QDBusAbstractInterface::stringPropDirectWrite()
QCOMPARE(targetObj.m_stringProp, expectedValue);
}
+void tst_QDBusAbstractInterface::variantPropDirectRead()
+{
+ Pinger p = getPinger();
+ QVERIFY2(p, "Not connected to D-Bus");
+
+ QDBusVariant expectedValue = targetObj.m_variantProp = QDBusVariant(42);
+ QCOMPARE(p->variantProp().variant(), expectedValue.variant());
+}
+
+void tst_QDBusAbstractInterface::variantPropDirectWrite()
+{
+ Pinger p = getPinger();
+ QVERIFY2(p, "Not connected to D-Bus");
+
+ QDBusVariant expectedValue = QDBusVariant(Q_INT64_C(-47));
+ p->setVariantProp(expectedValue);
+ QCOMPARE(targetObj.m_variantProp.variant().userType(), expectedValue.variant().userType());
+ QCOMPARE(targetObj.m_variantProp.variant(), expectedValue.variant());
+}
+
void tst_QDBusAbstractInterface::complexPropDirectRead()
{
Pinger p = getPinger();