mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 21:35:39 +00:00
Bug 922942 - Add some fuzz to some SVG path measurement tests since D2D doesn't return exact results. r=roc
--HG-- extra : rebase_source : 2cef979ae0a6f88f42c660c43f8fb2588c2e6b45
This commit is contained in:
parent
e0cf27c36e
commit
41ad83dd75
@ -20,31 +20,31 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=449327
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function fuzzyEq(a, b) {
|
||||
var epsilon = 0.0002;
|
||||
return Math.abs(a - b) < epsilon;
|
||||
}
|
||||
|
||||
function run()
|
||||
{
|
||||
var doc = $("svg").contentDocument;
|
||||
|
||||
function isFuzzy(a, b, error, name)
|
||||
{
|
||||
ok(!(Math.abs(a - b) > error), name, "got " + a + ", expected " + b + " (within " + error + ")");
|
||||
}
|
||||
|
||||
function getBBox(id) {
|
||||
return doc.getElementById(id).getBBox();
|
||||
}
|
||||
function checkBBox(id, x, y, width, height) {
|
||||
function checkBBox(id, x, y, width, height, error) {
|
||||
var bbox = getBBox(id);
|
||||
is(bbox.x, x, id + ".getBBox().x");
|
||||
is(bbox.y, y, id + ".getBBox().y");
|
||||
is(bbox.width, width, id + ".getBBox().width");
|
||||
is(bbox.height, height, id + ".getBBox().height");
|
||||
isFuzzy(bbox.x, x, error, id + ".getBBox().x");
|
||||
isFuzzy(bbox.y, y, error, id + ".getBBox().y");
|
||||
isFuzzy(bbox.width, width, error, id + ".getBBox().width");
|
||||
isFuzzy(bbox.height, height, error, id + ".getBBox().height");
|
||||
}
|
||||
function compareBBox(id1, id2) {
|
||||
var bbox1 = getBBox(id1);
|
||||
var bbox2 = getBBox(id2);
|
||||
is(bbox1.x, bbox2.x, id1 + ".getBBox().x");
|
||||
is(bbox1.y, bbox2.y, id1 + ".getBBox().y");
|
||||
ok(fuzzyEq(bbox1.width, bbox2.width), id1 + ".getBBox().width");
|
||||
isFuzzy(bbox1.width, bbox2.width, 0.0002, id1 + ".getBBox().width");
|
||||
is(bbox1.height, bbox2.height, id1 + ".getBBox().height");
|
||||
}
|
||||
function compareBBoxHeight(id1, id2) {
|
||||
@ -53,14 +53,14 @@ function run()
|
||||
is(bbox1.height, bbox2.height, id1 + ".getBBox().height");
|
||||
}
|
||||
|
||||
checkBBox("fO", 10, 10, 100, 100);
|
||||
checkBBox("i", 10, 10, 100, 100);
|
||||
checkBBox("fO", 10, 10, 100, 100, 0.0);
|
||||
checkBBox("i", 10, 10, 100, 100, 0.0);
|
||||
compareBBoxHeight("a", "b");
|
||||
compareBBoxHeight("a", "y");
|
||||
compareBBox("b", "tspan");
|
||||
checkBBox("v", 95, 45, 10, 155);
|
||||
checkBBox("h", 195, 45, 105, 55);
|
||||
checkBBox("e", 95, 95, 10, 10);
|
||||
checkBBox("v", 95, 45, 10, 155, 0.001);
|
||||
checkBBox("h", 195, 45, 105, 55, 0.001);
|
||||
checkBBox("e", 95, 95, 10, 10, 0.001);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ function doTest() {
|
||||
checkElement("d3", []);
|
||||
checkElement("d4", [[50,250,50,50]]);
|
||||
checkElement("d5", [[70,330,40,40]]);
|
||||
checkElement("s1", [[100,350,20,20]]);
|
||||
checkElement("s1", [[100,350,20,20]], 0.1);
|
||||
var sqrt2 = Math.sqrt(2);
|
||||
checkElement("d6", [[100 - 50*sqrt2,500 - 50*sqrt2,100*sqrt2,100*sqrt2]], 0.1);
|
||||
checkElement("d7", [[50,550,100,100]]);
|
||||
|
Loading…
Reference in New Issue
Block a user