From cea4ae150bef0f24b0e8385d47b06a9f6b8197c3 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 23 Mar 2011 15:37:41 +0100 Subject: 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 --- tests/auto/qvariant/tst_qvariant.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp index 62babdb..2e57264 100644 --- a/tests/auto/qvariant/tst_qvariant.cpp +++ b/tests/auto/qvariant/tst_qvariant.cpp @@ -2660,7 +2660,10 @@ void tst_QVariant::qvariant_cast_QObject_data() { QTest::addColumn("data"); QTest::addColumn("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; } @@ -2672,6 +2675,9 @@ void tst_QVariant::qvariant_cast_QObject() { QObject *o = qvariant_cast(data); QCOMPARE(o != 0, success); + if (success) { + QCOMPARE(o->objectName(), QString::fromLatin1("Hello")); + } } Q_DECLARE_METATYPE(qint8); -- cgit v0.12