aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2015-01-12 13:07:38 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2015-01-12 19:19:35 +0100
commitf6e1e92c2ec0279c31d354f5fdf187f09223a705 (patch)
treef502a54f66cb5a769c05698ac68508e4f46c5e81 /tests
parenta33879b811e1c495ce0686edb6ab3a4e3a9539c4 (diff)
Add ability to retrieve QJSEngine for a given QObject
[ChangeLog][QtQml] Added qjsEngine(QObject*) getter similar to qmlEngine(object) that allows retrieving the engine for an exposed object. Change-Id: Id14adec58d45fe58133f65bab773b07d6bc18569 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index b8c5f6081a..13e60fefd9 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -174,6 +174,8 @@ private slots:
void privateMethods();
+ void engineForObject();
+
signals:
void testSignal();
};
@@ -3624,6 +3626,19 @@ void tst_QJSEngine::privateMethods()
}
}
+void tst_QJSEngine::engineForObject()
+{
+ QObject object;
+ {
+ QJSEngine engine;
+ QVERIFY(!qjsEngine(&object));
+ QJSValue wrapper = engine.newQObject(&object);
+ QQmlEngine::setObjectOwnership(&object, QQmlEngine::CppOwnership);
+ QCOMPARE(qjsEngine(&object), wrapper.engine());
+ }
+ QVERIFY(!qjsEngine(&object));
+}
+
QTEST_MAIN(tst_QJSEngine)
#include "tst_qjsengine.moc"