From abff566ff85eb1fdee12e8a0fffddb7c1ff2dd7c Mon Sep 17 00:00:00 2001 From: Ulf Hermann <ulf.hermann@digia.com> Date: Tue, 16 Sep 2014 12:18:01 +0200 Subject: [PATCH] Make Canvas test case independent of chosen font. 0/0 is not always a red pixel after rendering "Hello" in red. The chosen font has an influence on that. Looking for some red pixel in row 0 is pretty safe. Change-Id: I669548c3c9d8cd25d720998fd9ba31c1f480e4e3 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> --- tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml b/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml index 23fd5192f3..31413c23cd 100644 --- a/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml +++ b/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml @@ -368,7 +368,12 @@ CanvasTestCase { test: function(ctx) { ctx.font = "100px sans-serif"; ctx.fillText("Hello", -10, 10, extra); - comparePixel(ctx, 0, 0, 255, 0, 0, 255); + for (var x = 0; x < 100; ++x) { + var c = ctx.getImageData(x,0,1,1).data; + if (c[0] === 255 && c[1] === 0 && c[2] === 0 && c[3] === 255) + return; + } + qtest_fail("No red pixel found"); } }, { -- GitLab