make canvas-lineWidth test pass even if pixel values vary a tiny bit

https://bugs.webkit.org/show_bug.cgi?id=75627

Patch by Elliot Poger <epoger@google.com> on 2012-01-06
Reviewed by Stephen White.

* fast/canvas/canvas-lineWidth.js:
(compareRows):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@104293 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 45a1da04
2012-01-06 Elliot Poger <epoger@google.com>
make canvas-lineWidth test pass even if pixel values vary a tiny bit
https://bugs.webkit.org/show_bug.cgi?id=75627
Reviewed by Stephen White.
* fast/canvas/canvas-lineWidth.js:
(compareRows):
2012-01-06 John Knottenbelt <jknotten@chromium.org>
Rebaseline mac results after r104240.
// Compare sections of a <canvas> to assert they are identical.
function compareRows(ctx, y0, y1, width, height) {
// Compare sections of a <canvas> to assert they are identical, or nearly so.
function compareRows(ctx, y0, y1, width, height, allowableDifference) {
var data0 = ctx.getImageData(0, y0, width, height).data;
var data1 = ctx.getImageData(0, y1, width, height).data;
for (var i = 0, il = data0.length; i < il; ++i) {
if (data0[i] != data1[i]) {
testFailed("Pixel at " + i + " should be " + data0[i] + " but was " + data1[i]);
if (Math.abs(data0[i] - data1[i]) > allowableDifference) {
testFailed("Pixel at " + i + " should be within " + allowableDifference +
" of " + data0[i] + " but was " + data1[i]);
break;
}
}
......@@ -40,6 +41,7 @@ for (var j = 0; j < 3; ++j) {
}
}
// Make sure that all rows are identical.
compareRows(ctx, 0, 100, 600, 100);
compareRows(ctx, 0, 200, 600, 100);
// Make sure that all rows are nearly identical.
// (Tiny variations are OK.)
compareRows(ctx, 0, 100, 600, 100, 1);
compareRows(ctx, 0, 200, 600, 100, 1);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment