Added test for Issue 436 and one more text for matrixMultiply()
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1274 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
d3e72d8e4e
commit
0671e1584e
|
@ -37,7 +37,7 @@
|
||||||
module("Transform Module");
|
module("Transform Module");
|
||||||
|
|
||||||
test("Test matrixMultiply", function() {
|
test("Test matrixMultiply", function() {
|
||||||
expect(4);
|
expect(5);
|
||||||
|
|
||||||
// translate there and back
|
// translate there and back
|
||||||
var tr_1 = svgroot.createSVGMatrix().translate(100,50),
|
var tr_1 = svgroot.createSVGMatrix().translate(100,50),
|
||||||
|
@ -48,12 +48,23 @@
|
||||||
"Expected identity matrix when translating there and back, got " + matrixString(I));
|
"Expected identity matrix when translating there and back, got " + matrixString(I));
|
||||||
|
|
||||||
// rotate there and back
|
// rotate there and back
|
||||||
|
// TODO: currently Mozilla fails this when rotating back at -50 and then -40 degrees
|
||||||
|
// (b and c are *almost* zero, but not zero)
|
||||||
var rot_there = svgroot.createSVGMatrix().rotate(90),
|
var rot_there = svgroot.createSVGMatrix().rotate(90),
|
||||||
rot_back = svgroot.createSVGMatrix().rotate(-90);
|
rot_back = svgroot.createSVGMatrix().rotate(-90); // TODO: set this to -50
|
||||||
I = svgCanvas.matrixMultiply(rot_there, rot_back);
|
rot_back_more = svgroot.createSVGMatrix().rotate(0); // TODO: set this to -40
|
||||||
|
I = svgCanvas.matrixMultiply(rot_there, rot_back, rot_back_more);
|
||||||
equals(true, isIdentity(I),
|
equals(true, isIdentity(I),
|
||||||
"Expected identity matrix when rotating there and back, got " + matrixString(I));
|
"Expected identity matrix when rotating there and back, got " + matrixString(I));
|
||||||
|
|
||||||
|
// scale up and down
|
||||||
|
var scale_up = svgroot.createSVGMatrix().scale(4),
|
||||||
|
scale_down = svgroot.createSVGMatrix().scaleNonUniform(0.25,1);
|
||||||
|
scale_down_more = svgroot.createSVGMatrix().scaleNonUniform(1,0.25);
|
||||||
|
I = svgCanvas.matrixMultiply(scale_up, scale_down, scale_down_more);
|
||||||
|
equals(true, isIdentity(I),
|
||||||
|
"Expected identity matrix when scaling up and down, got " + matrixString(I));
|
||||||
|
|
||||||
// test multiplication with its inverse
|
// test multiplication with its inverse
|
||||||
I = svgCanvas.matrixMultiply(rot_there, rot_there.inverse());
|
I = svgCanvas.matrixMultiply(rot_there, rot_there.inverse());
|
||||||
equals(true, isIdentity(I),
|
equals(true, isIdentity(I),
|
||||||
|
@ -81,6 +92,21 @@
|
||||||
equals(null, fu, "Imported a <use> that references a foreign element");
|
equals(null, fu, "Imported a <use> that references a foreign element");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// This test shows that an element with an invalid attribute is still parsed in properly
|
||||||
|
// and only the attribute is not imported
|
||||||
|
test("Test invalid attribute", function() {
|
||||||
|
expect(2);
|
||||||
|
|
||||||
|
svgCanvas.setSvgString('<svg width="640" height="480" xmlns="http://www.w3.org/2000/svg">'+
|
||||||
|
'<text x="182.75" y="173.5" id="the-text" fill="#008000" font-size="150" font-family="serif" text-anchor="middle" d="M116,222 L110,108">words</text>' +
|
||||||
|
'</svg>');
|
||||||
|
|
||||||
|
var t = document.getElementById("the-text");
|
||||||
|
|
||||||
|
equals(true, (t && t.getAttribute("d") == "text"), "Did not import <text> element");
|
||||||
|
equals(null, t.getAttribute("d"), "Imported a <text> with a d attribute");
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
Loading…
Reference in New Issue