diff options
Diffstat (limited to 'tests/auto/qml/qqmllanguage/data')
4 files changed, 159 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.1.qml b/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.1.qml new file mode 100644 index 0000000000..acd5463a3c --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.1.qml @@ -0,0 +1,37 @@ +import QtQuick 2.0 + +Item { + property bool success: false + + Component { + id: internal + + Item { + } + } + + property bool expectNull: null + + function setExpectNull(b) { + success = false; + expectNull = b; + } + + property QtObject obj: null + onObjChanged: success = (expectNull ? obj == null : obj != null) + + Component.onCompleted: { + setExpectNull(false) + obj = internal.createObject(null, {}) + if (!success) return + + // Replace with a different object + setExpectNull(false) + obj = internal.createObject(null, {}) + } + + function destroyObject() { + setExpectNull(true) + obj.destroy(); + } +} diff --git a/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.2.qml b/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.2.qml new file mode 100644 index 0000000000..ed0e0d10f0 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.2.qml @@ -0,0 +1,37 @@ +import QtQuick 2.0 + +Item { + property bool success: false + + Component { + id: internal + + Item { + } + } + + property bool expectNull: null + + function setExpectNull(b) { + success = false; + expectNull = b; + } + + property variant obj: null + onObjChanged: success = (expectNull ? obj == null : obj != null) + + Component.onCompleted: { + setExpectNull(false) + obj = internal.createObject(null, {}) + if (!success) return + + // Replace with a different object + setExpectNull(false) + obj = internal.createObject(null, {}) + } + + function destroyObject() { + setExpectNull(true) + obj.destroy(); + } +} diff --git a/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.3.qml b/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.3.qml new file mode 100644 index 0000000000..f5e94ba715 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.3.qml @@ -0,0 +1,37 @@ +import QtQuick 2.0 + +Item { + property bool success: false + + Component { + id: internal + + Item { + } + } + + property bool expectNull: null + + function setExpectNull(b) { + success = false; + expectNull = b; + } + + property var obj: null + onObjChanged: success = (expectNull ? obj == null : obj != null) + + Component.onCompleted: { + setExpectNull(false) + obj = internal.createObject(null, {}) + if (!success) return + + // Replace with a different object + setExpectNull(false) + obj = internal.createObject(null, {}) + } + + function destroyObject() { + setExpectNull(true) + obj.destroy(); + } +} diff --git a/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.4.qml b/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.4.qml new file mode 100644 index 0000000000..ccfda01644 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.4.qml @@ -0,0 +1,48 @@ +import QtQuick 2.0 + +Item { + property bool success: false + + Component { + id: internal + + Item { + } + } + + property var expectNull: null + + function setExpectNull(b) { + success = false; + expectNull = b; + } + + function setExpectNoChange() { + success = true; + expectNull = null; + } + + property var obj: null + onObjChanged: success = (expectNull == null) ? false : (expectNull ? obj == null : obj != null) + + property var temp: null + + Component.onCompleted: { + // Set obj to contain an object + setExpectNull(false) + obj = internal.createObject(null, {}) + if (!success) return + + // Use temp variable to keep object reference alive + temp = obj + + // Change obj to contain a string + setExpectNull(false) + obj = 'hello' + } + + function destroyObject() { + setExpectNoChange() + temp.destroy(); + } +} |