aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2012-04-17 13:54:20 +1000
committerQt by Nokia <qt-info@nokia.com>2012-05-09 00:56:16 +0200
commitc4fab1011b9de42f43a95d598743da505847e139 (patch)
tree64ca12106f9a624fcd9bd7dee0ceb8928b77895e /tests
parent3b04bbde6356797368114fce1b45b85271e9fed8 (diff)
Remove QQmlData::objectNameChanged callback.
The objectName property now has a proper NOTIFY signal. Also remove the objectName accessor, as it is no longer required. Task-number: QTBUG-23526 Change-Id: Ib18ba7335bf62a2fe2a9e489cb4c0f1fb142d74c Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlecmascript/data/destroyedSignal.qml6
-rw-r--r--tests/auto/qml/qqmlecmascript/data/objectNameChangedSignal.qml8
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp24
3 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/destroyedSignal.qml b/tests/auto/qml/qqmlecmascript/data/destroyedSignal.qml
new file mode 100644
index 0000000000..ac2df17ae8
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/destroyedSignal.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.0
+
+QtObject {
+ id: root
+ onDestroyed: {} //this should cause an error (destroyed should be hidden)
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/objectNameChangedSignal.qml b/tests/auto/qml/qqmlecmascript/data/objectNameChangedSignal.qml
new file mode 100644
index 0000000000..a2ac7019e4
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/objectNameChangedSignal.qml
@@ -0,0 +1,8 @@
+import QtQuick 2.0
+
+QtObject {
+ id: root
+ property bool test: false
+
+ onObjectNameChanged: test = true
+}
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 435724cbf7..3740d73415 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -215,6 +215,8 @@ private slots:
void qobjectConnectionListExceptionHandling();
void nonscriptable();
void deleteLater();
+ void objectNameChangedSignal();
+ void destroyedSignal();
void in();
void typeOf();
void qtbug_24448();
@@ -5848,6 +5850,28 @@ void tst_qqmlecmascript::deleteLater()
delete o;
}
+// objectNameChanged() should be usable from QML
+void tst_qqmlecmascript::objectNameChangedSignal()
+{
+ QQmlComponent component(&engine, testFileUrl("objectNameChangedSignal.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test").toBool(), false);
+ o->setObjectName("obj");
+ QCOMPARE(o->property("test").toBool(), true);
+ delete o;
+}
+
+// destroyed() should not be usable from QML
+void tst_qqmlecmascript::destroyedSignal()
+{
+ QQmlComponent component(&engine, testFileUrl("destroyedSignal.qml"));
+ QVERIFY(component.isError());
+
+ QString expectedErrorString = component.url().toString() + QLatin1String(":5:5: Cannot assign to non-existent property \"onDestroyed\"");
+ QCOMPARE(component.errors().at(0).toString(), expectedErrorString);
+}
+
void tst_qqmlecmascript::in()
{
QQmlComponent component(&engine, testFileUrl("in.qml"));