diff options
Diffstat (limited to 'tests/auto/qmltest')
4 files changed, 81 insertions, 0 deletions
diff --git a/tests/auto/qmltest/itemgrabber/tst_itemgrabber.qml b/tests/auto/qmltest/itemgrabber/tst_itemgrabber.qml index 53ed3658c2..af1b4db0e0 100644 --- a/tests/auto/qmltest/itemgrabber/tst_itemgrabber.qml +++ b/tests/auto/qmltest/itemgrabber/tst_itemgrabber.qml @@ -40,6 +40,10 @@ Item { when: imageOnDisk.ready && imageOnDiskSmall.ready function test_endresult_disk() { + if ((Qt.platform.pluginName === "offscreen") + || (Qt.platform.pluginName === "minimal")) + skip("grabImage does not work on offscreen/minimal platforms"); + var image = grabImage(root); // imageOnDisk at (0, 0) - (100x100) @@ -73,6 +77,10 @@ Item { } function test_endresult_cache(data) { + if ((Qt.platform.pluginName === "offscreen") + || (Qt.platform.pluginName === "minimal")) + skip("grabImage does not work on offscreen/minimal platforms"); + imageInCache.cache = data.cache; imageInCache.sourceSize = data.sourceSize; imageInCache.fillMode = data.fillMode; diff --git a/tests/auto/qmltest/listmodel/tst_listmodel.qml b/tests/auto/qmltest/listmodel/tst_listmodel.qml index 11f2019e08..2867897b0c 100644 --- a/tests/auto/qmltest/listmodel/tst_listmodel.qml +++ b/tests/auto/qmltest/listmodel/tst_listmodel.qml @@ -61,6 +61,16 @@ Item { ListModel { id: secondmodel; ListElement { name: "SecondModelElement0" } ListElement { name: "SecondModelElement1" } } ListModel { id: altermodel; ListElement { name: "AlterModelElement0" } ListElement { name: "AlterModelElement1" } } + property string funcResult + ListModel { + id: funcModel + property string modelProp + ListElement { friendlyText: "one"; action: function(obj) { funcResult = obj.friendlyText } } + ListElement { friendlyText: "two"; action: function() {} } + ListElement { friendlyText: "three"; action: function() { modelProp = "fail" } } + ListElement { friendlyText: "four"; action: function() { funcResult = friendlyText } } + } + TestCase { name: "ListModel" @@ -138,5 +148,51 @@ Item { tryCompare(altermodel, 'count', 0) compare(altermodel.get(0), undefined) } + + function test_functions() { + // test different ways of calling + funcModel.get(0).action(funcModel.get(0)) + compare(funcResult, "one") + funcModel.get(0).action.call(this, { friendlyText: "seven" }) + compare(funcResult, "seven") + + // test different ways of setting + funcResult = "" + funcModel.get(1).action() + compare(funcResult, "") + + funcModel.set(1, { friendlyText: "two", action: function() { funcResult = "set" } }) + funcModel.get(1).action() + compare(funcResult, "set") + + funcModel.setProperty(1, "action", function() { top.funcResult = "setProperty" }) + funcModel.get(1).action() + compare(funcResult, "setProperty") + + funcModel.get(1).action = function() { funcResult = "jsSet" } + funcModel.get(1).action() + compare(funcResult, "jsSet") + + // test unsupported features + var didThrow = false + try { + funcModel.get(2).action() + } catch(ex) { + verify(ex.toString().includes("Error: Invalid write to global property")) + didThrow = true + } + verify(didThrow) + + didThrow = false + try { + funcModel.get(3).action() + } catch(ex) { + verify(ex.toString().includes("ReferenceError: friendlyText is not defined")) + didThrow = true + } + verify(didThrow) + + + } } } diff --git a/tests/auto/qmltest/listview/tst_listview.qml b/tests/auto/qmltest/listview/tst_listview.qml index 2b5246b116..f7a34cbce2 100644 --- a/tests/auto/qmltest/listview/tst_listview.qml +++ b/tests/auto/qmltest/listview/tst_listview.qml @@ -161,6 +161,15 @@ Item { } } + ListView { + id: viewWithActionModel + property string funcResult + model: ListModel { ListElement { friendlyText: "one"; action: function(text) { viewWithActionModel.funcResult = text } } } + delegate: Item { + Component.onCompleted: action(model.friendlyText) + } + } + Component { id: delegateModelAfterCreateComponent Rectangle { @@ -350,5 +359,9 @@ Item { singleElementList.heightForDelegate = 200; compare(singleElementList.contentHeightOnDelegateResize, 200); } + + function test_viewWithAction() { + compare(viewWithActionModel.funcResult, "one") + } } } diff --git a/tests/auto/qmltest/shadersource/tst_DynamicallyCreatedSource.qml b/tests/auto/qmltest/shadersource/tst_DynamicallyCreatedSource.qml index 2c6d4cc28f..74dc63a972 100644 --- a/tests/auto/qmltest/shadersource/tst_DynamicallyCreatedSource.qml +++ b/tests/auto/qmltest/shadersource/tst_DynamicallyCreatedSource.qml @@ -67,6 +67,10 @@ Item { when: root.source != undefined function test_endresult() { + if ((Qt.platform.pluginName === "offscreen") + || (Qt.platform.pluginName === "minimal")) + skip("grabImage does not work on offscreen/minimal platforms"); + var image = grabImage(root); compare(image.red(0,0), 255); compare(image.green(0,0), 0); |