diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml | 5 | ||||
-rw-r--r-- | tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml | 46 |
2 files changed, 51 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml b/tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml index b0cae69fe3..e49f0ac462 100644 --- a/tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml +++ b/tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml @@ -25,6 +25,11 @@ TestCase { return []; } + function renderStrategyToString(renderStrategy) { + return renderStrategy === Canvas.Immediate ? "Canvas.Immediate" : + (renderStrategy === Canvas.Threaded ? "Canvas.Threaded" : "Canvas.Cooperative"); + } + function createCanvasObject(data) { return component.createObject(testCase, data.properties); } diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml b/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml index 31413c23cd..79c89bb2fc 100644 --- a/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml +++ b/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml @@ -595,5 +595,51 @@ CanvasTestCase { canvas.destroy(); } + + function test_getContextOnDestruction_data() { + // We want to test all possible combinations deemed valid by the testcase, + // but we can't test FramebufferObject due to difficulties ignoring the "available" warning. + var allData = testData("2d"); + var ourData = []; + + for (var i = 0; i < allData.length; ++i) { + if (allData[i].properties.renderTarget !== Canvas.FramebufferObject) { + var row = allData[i].properties; + row.tag = allData[i].tag; + ourData.push(row); + } + } + + return ourData; + } + + function test_getContextOnDestruction(data) { + try { + var canvasWindow = Qt.createQmlObject(" + import QtQuick 2.4\n + import QtQuick.Window 2.2\n + Window {\n + function test() {\n + loader.active = true\n + loader.active = false\n + }\n + Loader {\n + id: loader\n + active: false\n + sourceComponent: Canvas {\n + renderStrategy: " + renderStrategyToString(data.renderStrategy) + "\n + Component.onDestruction: getContext(\"2d\") + }\n + }\n + }\n", + testCase); + verify(canvasWindow); + canvasWindow.test(); + // Shouldn't crash when destruction is done. + wait(0); + } catch (exception) { + fail(exception.message); + } + } } |