aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickcanvasitem
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2014-03-14 13:04:42 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-16 00:53:31 +0100
commit4ef1032a4e5b0e612fb2d440fb3ef82fd5af3c5a (patch)
treecaf5b863665fa7c14c032d974bc9f0f22a3cabe1 /tests/auto/quick/qquickcanvasitem
parent156508dbc058e8d43106afb19d1dee50f5d65b93 (diff)
Canvas: do not emit paint when resized but hidden
It turns out to be a bad idea (as in, breaks the enterprise controls) to block paint() altogether when hidden. The original bug report QTBUG-31830 only complained about paint() being emitted upon resize while _hidden_, so this change solves exactly that. User is still free to call requestPaint() even when hidden, and Canvas now doesn't recklessly ignore the request. Task-number: QTBUG-31830 Change-Id: Icd82188f65406b3ef6ae3b19b5984944576886ff Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com> Reviewed-by: Mitch Curtis <mitch.curtis@digia.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'tests/auto/quick/qquickcanvasitem')
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml1
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml32
2 files changed, 20 insertions, 13 deletions
diff --git a/tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml b/tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml
index e299147b36..70682bed0b 100644
--- a/tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml
@@ -16,7 +16,6 @@ TestCase {
if (type === "2d")
return [
{ tag:"image threaded", properties:{width:100, height:100, renderTarget:Canvas.Image, renderStrategy:Canvas.Threaded}},
- { tag:"image canvas invisible", properties:{visible: false, width:100, height:100, renderTarget:Canvas.Image, renderStrategy:Canvas.Threaded}},
// { tag:"image cooperative", properties:{width:100, height:100, renderTarget:Canvas.Image, renderStrategy:Canvas.Cooperative}},
{ tag:"image immediate", properties:{width:100, height:100, renderTarget:Canvas.Image, renderStrategy:Canvas.Immediate}},
// { tag:"fbo cooperative", properties:{width:100, height:100, renderTarget:Canvas.FramebufferObject, renderStrategy:Canvas.Cooperative}},
diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml b/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml
index b92f6354a5..d90eb3971e 100644
--- a/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml
@@ -180,20 +180,28 @@ CanvasTestCase {
tryCompare(c, "availableChangedCount", 1);
//scene graph could be available immediately
//in this case, we force waiting a short while until the init paint finished
- if (c.visible) {
- tryCompare(c, "paintedCount", 1);
- } else {
- tryCompare(c, "paintedCount", 0);
- }
+ tryCompare(c, "paintedCount", 1);
ctx.fillRect(0, 0, c.width, c.height);
c.toDataURL();
- if (c.visible) {
- tryCompare(c, "paintCount", 1);
- tryCompare(c, "paintedCount", 2);
- } else {
- tryCompare(c, "paintCount", 0);
- tryCompare(c, "paintedCount", 1);
- }
+ tryCompare(c, "paintedCount", 2);
+ tryCompare(c, "paintCount", 1);
+ // implicit repaint when visible and resized
+ testCase.visible = true;
+ c.width += 1;
+ c.height += 1;
+ tryCompare(c, "paintCount", 2);
+ tryCompare(c, "paintedCount", 2);
+ // allow explicit repaint even when hidden
+ testCase.visible = false;
+ c.requestPaint();
+ tryCompare(c, "paintCount", 3);
+ tryCompare(c, "paintedCount", 2);
+ // no implicit repaint when resized but hidden
+ c.width += 1;
+ c.height += 1;
+ waitForRendering(c);
+ compare(c.paintCount, 3);
+ tryCompare(c, "paintedCount", 2);
c.destroy();
}
function test_loadImage(row) {