diff options
author | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2015-02-24 17:36:04 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2015-02-24 17:36:04 +0100 |
commit | ad67ec26d0cbc98e3440dd38bb20eef4da2ee96d (patch) | |
tree | 9f8135751df2f995a4f55837ea065a4687245b71 /tests/auto/quick/qquickcanvasitem | |
parent | 83a16630c13969e68cd3a5aaab73335ccb0d4414 (diff) | |
parent | 20d160d0513a04be187ed851a25b029f47c27b27 (diff) |
Merge remote-tracking branch 'origin/5.4' into 5.5
Conflicts:
.qmake.conf
LICENSE.GPLv2
examples/qml/networkaccessmanagerfactory/view.qml
src/qml/jsruntime/qv4runtime.cpp
src/qml/jsruntime/qv4stringobject.cpp
Change-Id: I5d12f436d60995e51d5c2f59d364e9cbc24f8e32
Diffstat (limited to 'tests/auto/quick/qquickcanvasitem')
-rw-r--r-- | tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml | 5 | ||||
-rw-r--r-- | tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml | 84 |
2 files changed, 88 insertions, 1 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..5960e53557 100644 --- a/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml +++ b/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml @@ -1,5 +1,10 @@ import QtQuick 2.0 +Item { + id: container + width: 200 + height: 200 + CanvasTestCase { id:testCase name: "canvas" @@ -595,5 +600,82 @@ 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); + } + } + + property Component implicitlySizedComponent: Item { + implicitWidth: 32 + implicitHeight: implicitWidth + anchors.centerIn: parent + + property alias canvas: canvas + + Canvas { + id: canvas + width: Math.max(1, Math.min(parent.width, parent.height)) + height: width + + onPaint: { + var ctx = getContext("2d"); + ctx.reset(); + ctx.beginPath(); + ctx.fillRect(0, 0, width, height); + } + } + } + + function test_implicitlySizedParent() { + var implicitlySizedItem = implicitlySizedComponent.createObject(container); + verify(implicitlySizedItem); + + var xCenter = implicitlySizedItem.width / 2; + var yCenter = implicitlySizedItem.height / 2; + waitForRendering(implicitlySizedItem); + comparePixel(implicitlySizedItem.canvas.context, xCenter, yCenter, 0, 0, 0, 255); + } +} +} |