Log Message
Make fast/canvas/canvas-strokePath-shadow.html allow for pixel tolerance https://bugs.webkit.org/show_bug.cgi?id=79488
Patch by Elliot Poger <[email protected]> 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):
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (108834 => 108835)
--- trunk/LayoutTests/ChangeLog 2012-02-24 19:41:12 UTC (rev 108834)
+++ trunk/LayoutTests/ChangeLog 2012-02-24 20:07:12 UTC (rev 108835)
@@ -1,3 +1,15 @@
+2012-02-24 Elliot Poger <[email protected]>
+
+ 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 <[email protected]>
SVG should be supported in Dashboard compatibility mode
Modified: trunk/LayoutTests/fast/canvas/canvas-strokePath-shadow-expected.txt (108834 => 108835)
--- trunk/LayoutTests/fast/canvas/canvas-strokePath-shadow-expected.txt 2012-02-24 19:41:12 UTC (rev 108834)
+++ trunk/LayoutTests/fast/canvas/canvas-strokePath-shadow-expected.txt 2012-02-24 20:07:12 UTC (rev 108835)
@@ -3,34 +3,34 @@
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
Modified: trunk/LayoutTests/fast/canvas/script-tests/canvas-strokePath-shadow.js (108834 => 108835)
--- trunk/LayoutTests/fast/canvas/script-tests/canvas-strokePath-shadow.js 2012-02-24 19:41:12 UTC (rev 108834)
+++ trunk/LayoutTests/fast/canvas/script-tests/canvas-strokePath-shadow.js 2012-02-24 20:07:12 UTC (rev 108835)
@@ -10,19 +10,10 @@
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 @@
// Verify solid shadow.
imageData = ctx.getImageData(650, 300, 1, 1);
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 = ""
-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 = ""
-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 = ""
-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 = ""
-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 = ""
-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 = ""
-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 = ""
-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');
Modified: trunk/LayoutTests/fast/js/resources/js-test-pre.js (108834 => 108835)
--- trunk/LayoutTests/fast/js/resources/js-test-pre.js 2012-02-24 19:41:12 UTC (rev 108834)
+++ trunk/LayoutTests/fast/js/resources/js-test-pre.js 2012-02-24 20:07:12 UTC (rev 108835)
@@ -187,6 +187,45 @@
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")
_______________________________________________ webkit-changes mailing list [email protected] http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes
