diff options
author | Olivier Goffart <olivier.goffart@nokia.com> | 2011-03-23 14:37:41 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2011-03-23 14:39:27 (GMT) |
commit | cea4ae150bef0f24b0e8385d47b06a9f6b8197c3 (patch) | |
tree | dbafc4c5248bd2f7f97b91e78614e6e791fd546c /tests | |
parent | b10199ab328848e954c3701f745043ff697a2c27 (diff) | |
download | Qt-cea4ae150bef0f24b0e8385d47b06a9f6b8197c3.zip Qt-cea4ae150bef0f24b0e8385d47b06a9f6b8197c3.tar.gz Qt-cea4ae150bef0f24b0e8385d47b06a9f6b8197c3.tar.bz2 |
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.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
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<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; } @@ -2672,6 +2675,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); |