diff options
Diffstat (limited to 'tests/auto/qml/qqmlecmascript/data')
19 files changed, 356 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/PropertyQJSValueBaseItem.qml b/tests/auto/qml/qqmlecmascript/data/PropertyQJSValueBaseItem.qml new file mode 100644 index 0000000000..4a695a0727 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/PropertyQJSValueBaseItem.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyQmlObject { + qjsvalue: null +} diff --git a/tests/auto/qml/qqmlecmascript/data/functionAssignment.1.qml b/tests/auto/qml/qqmlecmascript/data/functionAssignment.1.qml index 0b1b45b41b..d97613a875 100644 --- a/tests/auto/qml/qqmlecmascript/data/functionAssignment.1.qml +++ b/tests/auto/qml/qqmlecmascript/data/functionAssignment.1.qml @@ -4,4 +4,5 @@ MyQmlObject { property variant a: function myFunction() { return 2; } property variant b: Qt.binding(function() { return 2; }) property var c: Qt.binding(function() { return 2; }) + qjsvalue: Qt.binding(function() { return 2; }) } diff --git a/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.1.qml b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.1.qml new file mode 100644 index 0000000000..4e532ccf36 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.1.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyQmlObject { + id: root + property bool test: false + + qjsvalue: new vehicle(4); + property int wheelCount: qjsvalue.wheels + + function vehicle(wheels) { + this.wheels = wheels; + } + + Component.onCompleted: { + qjsvalue.wheels = 6; // not bindable, wheelCount shouldn't update + + if (qjsvalue.wheels != 6) return; + if (wheelCount != 4) return; + + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.10.qml b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.10.qml new file mode 100644 index 0000000000..39036ea7c6 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.10.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +PropertyQJSValueBaseItem { + property bool test: false + Component.onCompleted: { + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.11.qml b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.11.qml new file mode 100644 index 0000000000..2ccab7345c --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.11.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + property bool test: false + + MyQmlObject { id: fnResultObj; qjsvalue: testFunction(5) } + MyQmlObject { id: f1Obj; qjsvalue: testFunction } + MyQmlObject { id: f2Obj; qjsvalue: testFunction } + + + property alias fnResult: fnResultObj.qjsvalue; + property alias f1: f1Obj.qjsvalue + property alias f2: f2Obj.qjsvalue + + function testFunction(x) { + return x; + } + + Component.onCompleted: { + f2 = testFunction; + if (fnResult != 5) return; + if (f1(6) != 6) return; + if (f2(7) != 7) return; + if (f1 != f2) return; + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.12.qml b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.12.qml new file mode 100644 index 0000000000..78390a0a6d --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.12.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + property bool test: false + + MyQmlObject { id: nullOneObj; qjsvalue: null } + MyQmlObject { id: nullTwoObj; } + MyQmlObject { id: undefOneObj; qjsvalue: undefined } + MyQmlObject { id: undefTwoObj } + + property alias nullOne: nullOneObj.qjsvalue + property alias nullTwo: nullTwoObj.qjsvalue + property alias undefOne: undefOneObj.qjsvalue + property alias undefTwo: undefTwoObj.qjsvalue + + Component.onCompleted: { + nullTwo = null; + undefTwo = undefined; + if (nullOne != null) return; + if (nullOne != nullTwo) return; + if (undefOne != undefined) return; + if (undefOne != undefTwo) return; + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.13.qml b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.13.qml new file mode 100644 index 0000000000..5ece89bd55 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.13.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + property bool test: false + property var f: b + 12 + property int a: 100 + property int b: testFunction() + + function testFunction() { + return a * 3; + } + + Component.onCompleted: { + if (f != 312) return; + a = 120; + if (f != 372) return; + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.14.qml b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.14.qml new file mode 100644 index 0000000000..1c1c038d4c --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.14.qml @@ -0,0 +1,22 @@ + +import QtQuick 2.0 +import Qt.test 1.0 + +MyQmlObject { + property bool test: false + property int a: 100 + property int b + + function testFunction() { + return a * 3; + } + + Component.onCompleted: { + b = Qt.binding(testFunction); + qjsvalue = Qt.binding(function() { return b + 12; }); + if (qjsvalue != 312) return; + a = 120; + if (qjsvalue != 372) return; + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.15.qml b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.15.qml new file mode 100644 index 0000000000..acbfd6e106 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.15.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyQmlObject { + property bool test: false + qjsvalue: [ Qt.binding(function() { return testFunction() + 12; }) ] + property int a: 100 + property int b + + function testFunction() { + return a * 3; + } + + Component.onCompleted: { + b = qjsvalue[0]; + if (b != 312) return; + a = 120; + if (b != 372) return; + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.2.qml b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.2.qml new file mode 100644 index 0000000000..21a3e78da8 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.2.qml @@ -0,0 +1,25 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyQmlObject { + id: root + property bool test: false + + qjsvalue: new vehicle(8); + property int wheelCount: qjsvalue.wheels + + function vehicle(wheels) { + this.wheels = wheels; + } + + Component.onCompleted: { + if (wheelCount != 8) return; + + // not bindable, but wheelCount will update because truck itself changed. + qjsvalue = new vehicle(12); + + if (wheelCount != 12) return; + + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.3.qml b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.3.qml new file mode 100644 index 0000000000..fc0a09ac88 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.3.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyQmlObject { + id: root + property bool test: false + + qjsvalue: 4 + property int bound: qjsvalue + 5 + + Component.onCompleted: { + if (bound != 9) return; + + qjsvalue = qjsvalue + 1; + + if (bound != 10) return; + + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.4.qml b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.4.qml new file mode 100644 index 0000000000..18691d1ea9 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.4.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyQmlObject { + property bool test: false + + qjsvalue: [1, 2, 3, "four", "five"] + property int bound: qjsvalue[0] + + Component.onCompleted: { + if (bound != 1) return; + + qjsvalue[0] = 10 // bound should remain 1 + + if (bound != 1) return; + + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.5.qml b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.5.qml new file mode 100644 index 0000000000..485a5fee7d --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.5.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyQmlObject { + property bool test: false + + qjsvalue: { 'color': 'red', 'width': 100 } + property int bound: qjsvalue.width + + Component.onCompleted: { + if (bound != 100) return; + + qjsvalue.width = 200 // bound should remain 100 + + if (bound != 100) return; + + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.6.qml b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.6.qml new file mode 100644 index 0000000000..255bebfafb --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.6.qml @@ -0,0 +1,31 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + property bool test: false + + MyQmlObject { id: itemsObj; qjsvalue: [1, 2, 3, "four", "five"] } + MyQmlObject { id: funcsObj; qjsvalue: [(function() { return 6; })] } + + property alias items: itemsObj.qjsvalue + property int bound: itemsObj.qjsvalue[0] + property alias funcs: funcsObj.qjsvalue + property int bound2: funcsObj.qjsvalue[0]() + + function returnTwenty() { + return 20; + } + + Component.onCompleted: { + if (bound != 1) return false; + if (bound2 != 6) return false; + + items = [10, 2, 3, "four", "five"] // bound should now be 10 + funcs = [returnTwenty] // bound2 should now be 20 + + if (bound != 10) return false; + if (bound2 != 20) return false; + + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.7.qml b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.7.qml new file mode 100644 index 0000000000..09be338732 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.7.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyQmlObject { + property bool test: false + + qjsvalue: { 'color': 'red', 'width': 100 } + property int bound: qjsvalue.width + + Component.onCompleted: { + if (bound != 100) return; + + qjsvalue = { 'color': 'blue', 'width': 200 } // bound should now be 200 + + if (bound != 200) return; + + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.8.qml b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.8.qml new file mode 100644 index 0000000000..73074ca684 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.8.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyQmlObject { + property bool test: false + + qjsvalue: 6 + + Component.onCompleted: { + if (qjsvalue != 6) return; + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.9.qml b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.9.qml new file mode 100644 index 0000000000..5c776fcc83 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.9.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyQmlObject { + property bool test: false + + property MyQmlObject obj: MyQmlObject { + id: qmlobject + intProperty: 5 + } + qjsvalue: qmlobject + property int bound: qjsvalue.intProperty + + Component.onCompleted: { + if (bound != 5) return; + + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.bindingreset.qml b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.bindingreset.qml new file mode 100644 index 0000000000..598bdd395d --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.bindingreset.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyQmlObject { + id: root + property bool test: false + + property bool doReset: false + qjsvalueWithReset: if (doReset) return undefined; else return 9 + + Component.onCompleted: { + if (qjsvalueWithReset != 9) return; + doReset = true + + if (qjsvalueWithReset != "Reset!") return; + + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.reset.qml b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.reset.qml new file mode 100644 index 0000000000..76685456cc --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.reset.qml @@ -0,0 +1,17 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyQmlObject { + id: root + property bool test: false + + qjsvalueWithReset: 9 + + Component.onCompleted: { + qjsvalueWithReset = undefined + + if (qjsvalueWithReset != "Reset!") return; + + test = true; + } +} |