blob: 384971b59ce06d73153e57f125d4419155eebf29 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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 singletonTypeTypeHasOwnProperty
property bool singletonTypePropertyTypeHasOwnProperty
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.
singletonTypeTypeHasOwnProperty = !QtTestQObjectApi.QObject.hasOwnProperty("nonexistentpropertyname");
singletonTypePropertyTypeHasOwnProperty = !QtTestQObjectApi.QObject.qobjectTestProperty.hasOwnProperty("nonexistentpropertyname");
}
property bool enumNonValueHasOwnProperty
function testHasOwnPropertyFailureOne() {
enumNonValueHasOwnProperty = !MyTypeObject.NonexistentEnumVal.hasOwnProperty("nonexistentpropertyname");
}
property bool singletonTypeNonPropertyHasOwnProperty
function testHasOwnPropertyFailureTwo() {
singletonTypeNonPropertyHasOwnProperty = !QtTestQObjectApi.QObject.someNonexistentProperty.hasOwnProperty("nonexistentpropertyname");
}
property bool listAtInvalidHasOwnProperty
function testHasOwnPropertyFailureThree() {
listAtInvalidHasOwnProperty = !typeObj.listProperty[5].hasOwnProperty("nonexistentpropertyname");
}
}
}
|