aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlecmascript/data/qmlHasOwnProperty.qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qqmlecmascript/data/qmlHasOwnProperty.qml')
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qmlHasOwnProperty.qml72
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/qmlHasOwnProperty.qml b/tests/auto/qml/qqmlecmascript/data/qmlHasOwnProperty.qml
new file mode 100644
index 0000000000..12598b3b9f
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/qmlHasOwnProperty.qml
@@ -0,0 +1,72 @@
+import QtQuick 2.0
+import Qt.test 1.0
+import Qt.test.qobjectApi 1.0 as QtTestQObjectApi
+
+Item {
+ id: obj
+ objectName: "objName"
+ property int someIntProperty: 10
+ property bool result: false
+
+ function testHasOwnPropertySuccess()
+ {
+ obj.result = obj.hasOwnProperty("someIntProperty");
+ }
+
+ function testHasOwnPropertyFailure()
+ {
+ obj.result = obj.hasOwnProperty("someNonexistentProperty");
+ }
+
+ MyTypeObject {
+ id: typeObj
+ objectName: "typeObj"
+ pointProperty: Qt.point(34, 29)
+ variantProperty: Qt.vector3d(1, 2, 3)
+ stringProperty: "test string"
+ property list<Rectangle> listProperty: [ Rectangle { width: 10; height: 10 } ]
+ property list<Rectangle> emptyListProperty
+
+ property bool valueTypeHasOwnProperty
+ property bool valueTypeHasOwnProperty2
+ property bool variantTypeHasOwnProperty
+ property bool stringTypeHasOwnProperty
+ property bool listTypeHasOwnProperty
+ property bool listAtValidHasOwnProperty
+ property bool emptyListTypeHasOwnProperty
+ property bool enumTypeHasOwnProperty
+ property bool typenameHasOwnProperty
+ property bool typenameHasOwnProperty2
+ property bool moduleApiTypeHasOwnProperty
+ property bool moduleApiPropertyTypeHasOwnProperty
+ function testHasOwnPropertySuccess() {
+ valueTypeHasOwnProperty = !typeObj.pointProperty.hasOwnProperty("nonexistentpropertyname");
+ valueTypeHasOwnProperty2 = typeObj.pointProperty.hasOwnProperty("x"); // should be true
+ variantTypeHasOwnProperty = !typeObj.variantProperty.hasOwnProperty("nonexistentpropertyname");
+ stringTypeHasOwnProperty = !typeObj.stringProperty.hasOwnProperty("nonexistentpropertyname");
+ listTypeHasOwnProperty = !typeObj.listProperty.hasOwnProperty("nonexistentpropertyname");
+ listAtValidHasOwnProperty = !typeObj.listProperty[0].hasOwnProperty("nonexistentpropertyname");
+ emptyListTypeHasOwnProperty = !typeObj.emptyListProperty.hasOwnProperty("nonexistentpropertyname");
+ enumTypeHasOwnProperty = !MyTypeObject.EnumVal1.hasOwnProperty("nonexistentpropertyname");
+ typenameHasOwnProperty = !MyTypeObject.hasOwnProperty("nonexistentpropertyname");
+ typenameHasOwnProperty2 = MyTypeObject.hasOwnProperty("EnumVal1"); // should be true.
+ moduleApiTypeHasOwnProperty = !QtTestQObjectApi.hasOwnProperty("nonexistentpropertyname");
+ moduleApiPropertyTypeHasOwnProperty = !QtTestQObjectApi.qobjectTestProperty.hasOwnProperty("nonexistentpropertyname");
+ }
+
+ property bool enumNonValueHasOwnProperty
+ function testHasOwnPropertyFailureOne() {
+ enumNonValueHasOwnProperty = !MyTypeObject.NonexistentEnumVal.hasOwnProperty("nonexistentpropertyname");
+ }
+
+ property bool moduleApiNonPropertyHasOwnProperty
+ function testHasOwnPropertyFailureTwo() {
+ moduleApiNonPropertyHasOwnProperty = !QtTestQObjectApi.someNonexistentProperty.hasOwnProperty("nonexistentpropertyname");
+ }
+
+ property bool listAtInvalidHasOwnProperty
+ function testHasOwnPropertyFailureThree() {
+ listAtInvalidHasOwnProperty = !typeObj.listProperty[5].hasOwnProperty("nonexistentpropertyname");
+ }
+ }
+}