diff options
Diffstat (limited to 'tests/auto/qml/qqmlqt/data')
-rw-r--r-- | tests/auto/qml/qqmlqt/data/LaterComponent.qml | 14 | ||||
-rw-r--r-- | tests/auto/qml/qqmlqt/data/LaterComponent2.qml | 13 | ||||
-rw-r--r-- | tests/auto/qml/qqmlqt/data/LaterComponent3.qml | 14 | ||||
-rw-r--r-- | tests/auto/qml/qqmlqt/data/LaterComponent4.qml | 12 | ||||
-rw-r--r-- | tests/auto/qml/qqmlqt/data/exit.qml | 7 | ||||
-rw-r--r-- | tests/auto/qml/qqmlqt/data/later.qml | 124 | ||||
-rw-r--r-- | tests/auto/qml/qqmlqt/data/timeRoundtrip.qml | 8 |
7 files changed, 192 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlqt/data/LaterComponent.qml b/tests/auto/qml/qqmlqt/data/LaterComponent.qml new file mode 100644 index 0000000000..7dbd81d93d --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/LaterComponent.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 +import LaterImports 1.0 + +TestElement { + id: deleteme + function testFn() { + gc(); // at this point, obj is deleted. + dangerousFunction(); // calling this function will throw an exeption + // because this object has been deleted and its context is not available + + // which means that we shouldn't get to this line. + row.test10_1 = 1; + } +} diff --git a/tests/auto/qml/qqmlqt/data/LaterComponent2.qml b/tests/auto/qml/qqmlqt/data/LaterComponent2.qml new file mode 100644 index 0000000000..56bcc0235b --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/LaterComponent2.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +Item { + id: deleteme2 + function testFn() { + // this function shouldn't be called, + // since the object will have been deleted. + var crashy = Qt.createQmlObject("import QtQuick 2.0; Item { }", deleteme2) // invalid calling context if invoked after gc + row.test11_1 = 2; + } + + Component.onDestruction: row.test11_1 = 1; // success == the object was deleted, but testFn wasn't called. +} diff --git a/tests/auto/qml/qqmlqt/data/LaterComponent3.qml b/tests/auto/qml/qqmlqt/data/LaterComponent3.qml new file mode 100644 index 0000000000..c6f445253a --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/LaterComponent3.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 +import LaterImports 1.0 + +TestElement { + id: deleteme3 + function testFn() { + gc(); // at this point, obj is deleted. + dangerousFunction(); // calling this function will throw an exeption + // because this object has been deleted and its context is not available + + // which means that we shouldn't get to this line. + row.test12_1 = 1; + } +} diff --git a/tests/auto/qml/qqmlqt/data/LaterComponent4.qml b/tests/auto/qml/qqmlqt/data/LaterComponent4.qml new file mode 100644 index 0000000000..0c53bd368b --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/LaterComponent4.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Item { + id: deleteme4 + function testFn() { + // this function shouldn't be called, + // since the object will have been deleted. + row.test13_1 = 2; + } + + Component.onDestruction: row.test13_1 = 1; // success == the object was deleted, but testFn wasn't called. +} diff --git a/tests/auto/qml/qqmlqt/data/exit.qml b/tests/auto/qml/qqmlqt/data/exit.qml new file mode 100644 index 0000000000..12727d9f04 --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/exit.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +QtObject { + property int returnCode: -1 + Component.onCompleted: Qt.exit(returnCode) +} + diff --git a/tests/auto/qml/qqmlqt/data/later.qml b/tests/auto/qml/qqmlqt/data/later.qml new file mode 100644 index 0000000000..a90f3aba9f --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/later.qml @@ -0,0 +1,124 @@ +import QtQuick 2.0 +import LaterImports 1.0 + +Row { + id: row + Repeater { + id: repeater + model: 5 + delegate: Item { } + } + + property bool test1_1: false + property bool test1_2: row.focus + property bool test2_1: false + property bool test2_2: (firstFunctionCallCounter == 1 && secondFunctionCallCounter == 1 && signalCallCounter == 1) + + property int firstFunctionCallCounter: 0 + property int secondFunctionCallCounter: 0 + property int signalCallCounter: 0 + + signal testSignal + onTestSignal: { + signalCallCounter++; + } + + onChildrenChanged: { + Qt.callLater(row.forceActiveFocus); // built-in function + Qt.callLater(row.firstFunction); // JS function + Qt.callLater(row.testSignal); // signal + } + + function firstFunction() { + firstFunctionCallCounter++; + } + + function secondFunction() { + secondFunctionCallCounter++; + } + + Component.onCompleted: { + test1_1 = !row.focus; + test2_1 = (firstFunctionCallCounter == 0); + + Qt.callLater(secondFunction); + Qt.callLater(firstFunction); + Qt.callLater(secondFunction); + } + + function test2() { + repeater.model = 2; + } + + function test3() { + Qt.callLater(test3_recursive); + } + + property int recursion: 0 + property bool test3_1: (recursion == 1) + property bool test3_2: (recursion == 2) + property bool test3_3: (recursion == 3) + function test3_recursive() { + if (recursion < 3) { + Qt.callLater(test3_recursive); + Qt.callLater(test3_recursive); + } + recursion++; + } + + function test4() { + Qt.callLater(functionThatDoesNotExist); + } + + property bool test5_1: false + function test5() { + Qt.callLater(functionWithArguments, "THESE", "ARGS", "WILL", "BE", "OVERWRITTEN") + Qt.callLater(functionWithArguments, "firstArg", 2, "thirdArg") + } + + function functionWithArguments(firstStr, secondInt, thirdString) { + test5_1 = (firstStr == "firstArg" && secondInt == 2 && thirdString == "thirdArg"); + } + + + property bool test6_1: (callOrder_Later == "TWO THREE ") // not "THREE TWO " + function test6() { + Qt.callLater(test6Function1, "ONE"); + Qt.callLater(test6Function2, "TWO"); + Qt.callLater(test6Function1, "THREE"); + } + + property string callOrder_Later + function test6Function1(arg) { callOrder_Later += arg + " "; } + function test6Function2(arg) { callOrder_Later += arg + " "; } + + property int test9_1: SingletonType.intProp; + function test9() { + SingletonType.resetIntProp(); + Qt.callLater(SingletonType.testFunc) + Qt.callLater(SingletonType.testFunc) + Qt.callLater(SingletonType.testFunc) + Qt.callLater(SingletonType.testFunc) + // should only get called once. + } + + property int test10_1: 0 + function test10() { + var c = Qt.createComponent("LaterComponent.qml"); + var obj = c.createObject(); // QML ownership. + Qt.callLater(obj.testFn); + // note: obj will be cleaned up during next gc(). + } + + property int test11_1: 0 + function test11() { + var c = Qt.createComponent("LaterComponent2.qml"); + var obj = c.createObject(); // QML ownership. + Qt.callLater(obj.testFn); + gc(); // this won't actually collect the obj, we need to trigger gc manually in the test. + } + + function test14() { + Qt.callLater(console.log, "success") + } +} diff --git a/tests/auto/qml/qqmlqt/data/timeRoundtrip.qml b/tests/auto/qml/qqmlqt/data/timeRoundtrip.qml new file mode 100644 index 0000000000..9d73640c87 --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/timeRoundtrip.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +QtObject { + Component.onCompleted: { + var t = tp.time; + tp.time = t; + } +} |