diff options
author | commit-queue@webkit.org <commit-queue@webkit.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538> | 2012-02-24 20:07:12 +0000 |
---|---|---|
committer | commit-queue@webkit.org <commit-queue@webkit.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538> | 2012-02-24 20:07:12 +0000 |
commit | a6c02a4245e3e3079f2c9f23c72d898fc6702481 (patch) | |
tree | 0b6a5b0cb0a5b2c799bd0b5960e663cf549521e5 | |
parent | 8fe4e3bb71629852b32c4d3b27afed5d189c5b0c (diff) | |
download | chromium_src-a6c02a4245e3e3079f2c9f23c72d898fc6702481.zip chromium_src-a6c02a4245e3e3079f2c9f23c72d898fc6702481.tar.gz chromium_src-a6c02a4245e3e3079f2c9f23c72d898fc6702481.tar.bz2 |
Make fast/canvas/canvas-strokePath-shadow.html allow for pixel tolerance
https://bugs.webkit.org/show_bug.cgi?id=79488
Patch by Elliot Poger <epoger@google.com> on 2012-02-24
Reviewed by Adam Barth.
* fast/canvas/script-tests/canvas-strokePath-shadow.js:
(shouldBeAlmost):
* fast/js/resources/js-test-pre.js:
(shouldBeCloseTo):
git-svn-id: svn://svn.chromium.org/blink/trunk@108835 bbb929c8-8fbe-4397-9dbb-9b2b20218538
4 files changed, 106 insertions, 64 deletions
diff --git a/third_party/WebKit/LayoutTests/ChangeLog b/third_party/WebKit/LayoutTests/ChangeLog index 2701af1..427f814 100644 --- a/third_party/WebKit/LayoutTests/ChangeLog +++ b/third_party/WebKit/LayoutTests/ChangeLog @@ -1,3 +1,15 @@ +2012-02-24 Elliot Poger <epoger@google.com> + + Make fast/canvas/canvas-strokePath-shadow.html allow for pixel tolerance + https://bugs.webkit.org/show_bug.cgi?id=79488 + + Reviewed by Adam Barth. + + * fast/canvas/script-tests/canvas-strokePath-shadow.js: + (shouldBeAlmost): + * fast/js/resources/js-test-pre.js: + (shouldBeCloseTo): + 2012-02-24 Tim Horton <timothy_horton@apple.com> SVG should be supported in Dashboard compatibility mode diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-strokePath-shadow-expected.txt b/third_party/WebKit/LayoutTests/fast/canvas/canvas-strokePath-shadow-expected.txt index 552bdaf..6fb239d 100644 --- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-strokePath-shadow-expected.txt +++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-strokePath-shadow-expected.txt @@ -3,34 +3,34 @@ Ensure correct behavior of canvas with path stroke shadow On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". -PASS data[0] is 255 -PASS data[1] is 20 -PASS data[2] is 0 -PASS data[0] is 255 -PASS data[1] is 20 -PASS data[2] is 0 -PASS data[0] is 255 -PASS data[1] is 20 -PASS data[2] is 0 -PASS data[0] is 255 -PASS data[1] is 20 -PASS data[2] is 0 -PASS data[0] is 255 -PASS data[1] is 0 -PASS data[2] is 0 -PASS data[3] should not be 255 and it's not. -PASS data[0] is 255 -PASS data[1] is 0 -PASS data[2] is 0 -PASS data[3] should not be 255 and it's not. -PASS data[0] is 255 -PASS data[1] is 0 -PASS data[2] is 0 -PASS data[3] should not be 255 and it's not. -PASS data[0] is 255 -PASS data[1] is 0 -PASS data[2] is 0 -PASS data[3] should not be 255 and it's not. +PASS data[0] is within 2 of 255 +PASS data[1] is within 2 of 20 +PASS data[2] is within 2 of 0 +PASS data[0] is within 2 of 255 +PASS data[1] is within 2 of 20 +PASS data[2] is within 2 of 0 +PASS data[0] is within 2 of 255 +PASS data[1] is within 2 of 20 +PASS data[2] is within 2 of 0 +PASS data[0] is within 2 of 255 +PASS data[1] is within 2 of 20 +PASS data[2] is within 2 of 0 +PASS data[0] is within 2 of 255 +PASS data[1] is within 2 of 0 +PASS data[2] is within 2 of 0 +PASS data[3] is not 255 +PASS data[0] is within 2 of 255 +PASS data[1] is within 2 of 0 +PASS data[2] is within 2 of 0 +PASS data[3] is not 255 +PASS data[0] is within 2 of 255 +PASS data[1] is within 2 of 0 +PASS data[2] is within 2 of 0 +PASS data[3] is not 255 +PASS data[0] is within 2 of 255 +PASS data[1] is within 2 of 0 +PASS data[2] is within 2 of 0 +PASS data[3] is not 255 PASS successfullyParsed is true TEST COMPLETE diff --git a/third_party/WebKit/LayoutTests/fast/canvas/script-tests/canvas-strokePath-shadow.js b/third_party/WebKit/LayoutTests/fast/canvas/script-tests/canvas-strokePath-shadow.js index 70798ce..01f43c1 100644 --- a/third_party/WebKit/LayoutTests/fast/canvas/script-tests/canvas-strokePath-shadow.js +++ b/third_party/WebKit/LayoutTests/fast/canvas/script-tests/canvas-strokePath-shadow.js @@ -10,19 +10,10 @@ function print(message, color) document.getElementById("console").appendChild(paragraph); } -function shouldNotBe(a, b) +// Level of tolerance we expect of most pixel comparisons in this test. +function shouldBeAlmost(_a, _b) { - var evalA; - try { - evalA = eval(a); - } catch(e) { - evalA = e; - } - - if (evalA != b) - print("PASS " + a + " should not be " + b + " and it's not.", "green") - else - print("FAIL " + a + " should not be " + b + " but it is.", "red"); + shouldBeCloseTo(_a, _b, 2); } var canvas = document.createElement('canvas'); @@ -62,53 +53,53 @@ var imageData, data; // Verify solid shadow. imageData = ctx.getImageData(650, 300, 1, 1); data = imageData.data; -shouldBe('data[0]', '255'); -shouldBe('data[1]', '20'); -shouldBe('data[2]', '0'); +shouldBeAlmost('data[0]', 255); +shouldBeAlmost('data[1]', 20); +shouldBeAlmost('data[2]', 0); imageData = ctx.getImageData(650, 50, 1, 1); data = imageData.data; -shouldBe('data[0]', '255'); -shouldBe('data[1]', '20'); -shouldBe('data[2]', '0'); +shouldBeAlmost('data[0]', 255); +shouldBeAlmost('data[1]', 20); +shouldBeAlmost('data[2]', 0); imageData = ctx.getImageData(380, 30, 1, 1); data = imageData.data; -shouldBe('data[0]', '255'); -shouldBe('data[1]', '20'); -shouldBe('data[2]', '0'); +shouldBeAlmost('data[0]', 255); +shouldBeAlmost('data[1]', 20); +shouldBeAlmost('data[2]', 0); imageData = ctx.getImageData(400, 40, 1, 1); data = imageData.data; -shouldBe('data[0]', '255'); -shouldBe('data[1]', '20'); -shouldBe('data[2]', '0'); +shouldBeAlmost('data[0]', 255); +shouldBeAlmost('data[1]', 20); +shouldBeAlmost('data[2]', 0); // Verify blurry shadow. imageData = ctx.getImageData(640, 640, 1, 1); data = imageData.data; -shouldBe('data[0]', '255'); -shouldBe('data[1]', '0'); -shouldBe('data[2]', '0'); +shouldBeAlmost('data[0]', 255); +shouldBeAlmost('data[1]', 0); +shouldBeAlmost('data[2]', 0); shouldNotBe('data[3]', '255'); imageData = ctx.getImageData(650, 400, 1, 1); data = imageData.data; -shouldBe('data[0]', '255'); -shouldBe('data[1]', '0'); -shouldBe('data[2]', '0'); +shouldBeAlmost('data[0]', 255); +shouldBeAlmost('data[1]', 0); +shouldBeAlmost('data[2]', 0); shouldNotBe('data[3]', '255'); imageData = ctx.getImageData(380, 380, 1, 1); data = imageData.data; -shouldBe('data[0]', '255'); -shouldBe('data[1]', '0'); -shouldBe('data[2]', '0'); +shouldBeAlmost('data[0]', 255); +shouldBeAlmost('data[1]', 0); +shouldBeAlmost('data[2]', 0); shouldNotBe('data[3]', '255'); imageData = ctx.getImageData(350, 380, 1, 1); data = imageData.data; -shouldBe('data[0]', '255'); -shouldBe('data[1]', '0'); -shouldBe('data[2]', '0'); +shouldBeAlmost('data[0]', 255); +shouldBeAlmost('data[1]', 0); +shouldBeAlmost('data[2]', 0); shouldNotBe('data[3]', '255'); diff --git a/third_party/WebKit/LayoutTests/fast/js/resources/js-test-pre.js b/third_party/WebKit/LayoutTests/fast/js/resources/js-test-pre.js index cad0057..492ff8c 100644 --- a/third_party/WebKit/LayoutTests/fast/js/resources/js-test-pre.js +++ b/third_party/WebKit/LayoutTests/fast/js/resources/js-test-pre.js @@ -187,6 +187,45 @@ function shouldBe(_a, _b, quiet) testFailed(_a + " should be " + _bv + " (of type " + typeof _bv + "). Was " + _av + " (of type " + typeof _av + ")."); } +// Variant of shouldBe()--confirms that result of eval(_to_eval) is within +// numeric _tolerance of numeric _target. +function shouldBeCloseTo(_to_eval, _target, _tolerance, quiet) +{ + if (typeof _to_eval != "string") { + testFailed("shouldBeCloseTo() requires string argument _to_eval. was type " + typeof _to_eval); + return; + } + if (typeof _target != "number") { + testFailed("shouldBeCloseTo() requires numeric argument _target. was type " + typeof _target); + return; + } + if (typeof _tolerance != "number") { + testFailed("shouldBeCloseTo() requires numeric argument _tolerance. was type " + typeof _tolerance); + return; + } + + var _result; + try { + _result = eval(_to_eval); + } catch (e) { + testFailed(_to_eval + " should be within " + _tolerance + " of " + + _target + ". Threw exception " + e); + return; + } + + if (typeof(_result) != typeof(_target)) { + testFailed(_to_eval + " should be of type " + typeof _target + + " but was of type " + typeof _result); + } else if (Math.abs(_result - _target) <= _tolerance) { + if (!quiet) { + testPassed(_to_eval + " is within " + _tolerance + " of " + _target); + } + } else { + testFailed(_to_eval + " should be within " + _tolerance + " of " + _target + + ". Was " + _result + "."); + } +} + function shouldNotBe(_a, _b, quiet) { if (typeof _a != "string" || typeof _b != "string") |