aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp')
-rw-r--r--tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp b/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp
index 4189f441a2..40c93fe603 100644
--- a/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp
+++ b/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp
@@ -51,6 +51,7 @@ public:
private slots:
void fastConnect();
+ void fastCast();
};
class MyObject : public QObject {
@@ -101,6 +102,25 @@ void tst_qqmlcpputils::fastConnect()
}
}
+void tst_qqmlcpputils::fastCast()
+{
+ {
+ QObject *myObj = new MyObject;
+ MyObject *obj = qmlobject_cast<MyObject*>(myObj);
+ QVERIFY(obj);
+ QCOMPARE(obj->metaObject(), myObj->metaObject());
+ obj->slot1();
+ QCOMPARE(obj->slotCount, 1);
+ delete myObj;
+ }
+
+ {
+ QObject *nullObj = 0;
+ QObject *obj = qmlobject_cast<QObject *>(nullObj);
+ QCOMPARE(obj, nullObj); // shouldn't crash/assert.
+ }
+}
+
QTEST_MAIN(tst_qqmlcpputils)
#include "tst_qqmlcpputils.moc"