summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/kernel')
-rw-r--r--tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp b/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp
index 3540df17ac..fd20a1cf5d 100644
--- a/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp
+++ b/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp
@@ -63,6 +63,8 @@ private slots:
void disconnect();
void castDuringDestruction();
void threadSafety();
+
+ void qvariantCast();
};
void tst_QPointer::constructors()
@@ -348,6 +350,41 @@ void tst_QPointer::threadSafety()
owner.wait();
}
+void tst_QPointer::qvariantCast()
+{
+ QPointer<QFile> tracking = new QFile;
+ tracking->setObjectName("A test name");
+ QVariant v = QVariant::fromValue(tracking);
+
+ {
+ QPointer<QObject> other = qPointerFromVariant<QObject>(v);
+ QCOMPARE(other->objectName(), QString::fromLatin1("A test name"));
+ }
+ {
+ QPointer<QIODevice> other = qPointerFromVariant<QIODevice>(v);
+ QCOMPARE(other->objectName(), QString::fromLatin1("A test name"));
+ }
+ {
+ QPointer<QFile> other = qPointerFromVariant<QFile>(v);
+ QCOMPARE(other->objectName(), QString::fromLatin1("A test name"));
+ }
+ {
+ QPointer<QThread> other = qPointerFromVariant<QThread>(v);
+ QVERIFY(!other);
+ }
+ {
+ QPointer<QFile> toBeDeleted = new QFile;
+ QVariant deletedVariant = QVariant::fromValue(toBeDeleted);
+ delete toBeDeleted;
+ QPointer<QObject> deleted = qPointerFromVariant<QObject>(deletedVariant);
+ QVERIFY(!deleted);
+ }
+
+ // Intentionally does not compile.
+// QPointer<int> sop = qPointerFromVariant<int>(v);
+}
+
+
QTEST_MAIN(tst_QPointer)
#include "tst_qpointer.moc"