summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2011-03-23 15:37:41 +0100
committerQt Commercial Integration <QtCommercial@digia.com>2012-01-31 12:24:38 +0200
commit1d490aa71dae1041cf51053c4e12800388ca92be (patch)
treeb7c03dceb5b7af2cc75eea6bd7daf91e7dd8b10d /tests
parent1a3b988c03544e5652b30025c56fd307952b5b0d (diff)
Fix tst_QVariant::qvariant_cast_QObject
qvariant_cast_QObject_data was creating the QVariant wrong, The QVariant(int, void*) constructor take a pointer to the value of the type ObjectStar (hence a pointer to a pointer) Task-number: QTBUG-18257
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qvariant/tst_qvariant.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp
index 165207e8b7..96ceac2c01 100644
--- a/tests/auto/qvariant/tst_qvariant.cpp
+++ b/tests/auto/qvariant/tst_qvariant.cpp
@@ -2649,7 +2649,10 @@ void tst_QVariant::qvariant_cast_QObject_data() {
QTest::addColumn<QVariant>("data");
QTest::addColumn<bool>("success");
- QTest::newRow("from QObject") << QVariant(QMetaType::QObjectStar, new QObject(this)) << true;
+ QObject *obj = new QObject(this);
+ obj->setObjectName(QString::fromLatin1("Hello"));
+ QTest::newRow("from QObject") << QVariant(QMetaType::QObjectStar, &obj) << true;
+ QTest::newRow("from QObject2") << QVariant::fromValue(obj) << true;
QTest::newRow("from String") << QVariant(QLatin1String("1, 2, 3")) << false;
QTest::newRow("from int") << QVariant((int) 123) << false;
}
@@ -2661,6 +2664,9 @@ void tst_QVariant::qvariant_cast_QObject() {
QObject *o = qvariant_cast<QObject *>(data);
QCOMPARE(o != 0, success);
+ if (success) {
+ QCOMPARE(o->objectName(), QString::fromLatin1("Hello"));
+ }
}
Q_DECLARE_METATYPE(qint8);