Index: LayoutTests/fast/dom/geometry-interfaces-dom-matrix-translate.html |
diff --git a/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-translate.html b/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-translate.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e712741443de8290daf40466b33389e6b1fed227 |
--- /dev/null |
+++ b/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-translate.html |
@@ -0,0 +1,135 @@ |
+<!DOCTYPE html> |
+<html> |
+<head> |
+<title>Geometry Interfaces: DOMMatrix translate</title> |
+<script src="../../resources/js-test.js"></script> |
krit
2014/08/08 06:24:15
As mentioned in another CL, it would be great if w
zino
2014/08/16 03:23:32
Done.
|
+</head> |
+<body> |
+<script> |
+ |
+function compareMatrix(matrixObject, matrixValue) |
+{ |
+ return matrixObject.m11 == matrixValue[0] && |
+ matrixObject.m21 == matrixValue[1] && |
+ matrixObject.m31 == matrixValue[2] && |
+ matrixObject.m41 == matrixValue[3] && |
+ matrixObject.m12 == matrixValue[4] && |
+ matrixObject.m22 == matrixValue[5] && |
+ matrixObject.m32 == matrixValue[6] && |
+ matrixObject.m42 == matrixValue[7] && |
+ matrixObject.m13 == matrixValue[8] && |
+ matrixObject.m23 == matrixValue[9] && |
+ matrixObject.m33 == matrixValue[10] && |
+ matrixObject.m43 == matrixValue[11] && |
+ matrixObject.m14 == matrixValue[12] && |
+ matrixObject.m24 == matrixValue[13] && |
+ matrixObject.m34 == matrixValue[14] && |
+ matrixObject.m44 == matrixValue[15]; |
+} |
+ |
+debug("# DOMMatrix.translate(tx, ty)"); |
+var matrix = new DOMMatrix(); |
+shouldBeTrue("matrix.is2D"); |
+shouldBeTrue("matrix.isIdentity"); |
+shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); |
+var result = matrix.translate(2, 3); |
+shouldBeTrue("result.is2D"); |
+shouldBeFalse("result.isIdentity"); |
+shouldBeTrue("compareMatrix(result, [ 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 0, 0, 0, 0, 1 ])"); |
+shouldBeTrue("matrix.is2D"); |
+shouldBeTrue("matrix.isIdentity"); |
+shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); |
+debug(""); |
+ |
+debug("# DOMMatrix.translate(tx, ty) with non-identity"); |
+matrix = new DOMMatrix(result); |
+shouldBeTrue("matrix.is2D"); |
+shouldBeFalse("matrix.isIdentity"); |
+shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 0, 0, 0, 0, 1 ])"); |
+result = matrix.translate(4, 2); |
+shouldBeTrue("result.is2D"); |
+shouldBeFalse("result.isIdentity"); |
+shouldBeTrue("compareMatrix(result, [ 1, 0, 0, 6, 0, 1, 0, 5, 0, 0, 1, 0, 0, 0, 0, 1 ])"); |
+shouldBeTrue("matrix.is2D"); |
+shouldBeFalse("matrix.isIdentity"); |
+shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 0, 0, 0, 0, 1 ])"); |
+debug(""); |
+ |
+debug("# DOMMatrix.translateSelf(tx, ty)"); |
+matrix = new DOMMatrix(); |
+shouldBeTrue("matrix.is2D"); |
+shouldBeTrue("matrix.isIdentity"); |
+shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); |
+result = matrix.translateSelf(4, 2); |
+shouldBeTrue("result.is2D"); |
+shouldBeFalse("result.isIdentity"); |
+shouldBeTrue("compareMatrix(result, [ 1, 0, 0, 4, 0, 1, 0, 2, 0, 0, 1, 0, 0, 0, 0, 1 ])"); |
+shouldBeTrue("matrix.is2D"); |
+shouldBeFalse("matrix.isIdentity"); |
+shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 4, 0, 1, 0, 2, 0, 0, 1, 0, 0, 0, 0, 1 ])"); |
+debug(""); |
+ |
+debug("# DOMMatrix.translate(tx, ty, tz)"); |
+matrix = new DOMMatrix(); |
+shouldBeTrue("matrix.is2D"); |
+shouldBeTrue("matrix.isIdentity"); |
+shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); |
+result = matrix.translate(2, 3, 4); |
+shouldBeFalse("result.is2D"); |
+shouldBeFalse("result.isIdentity"); |
+shouldBeTrue("compareMatrix(result, [ 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 4, 0, 0, 0, 1 ])"); |
+shouldBeTrue("matrix.is2D"); |
+shouldBeTrue("matrix.isIdentity"); |
+shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); |
+debug(""); |
+ |
+debug("# DOMMatrix.translate(tx, ty, tz) with non-identity"); |
+var matrix2d = new DOMMatrix(); |
+matrix2d.translateSelf(2, 3); |
+matrix = new DOMMatrix(matrix2d); |
+shouldBeTrue("matrix.is2D"); |
+shouldBeFalse("matrix.isIdentity"); |
+shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 0, 0, 0, 0, 1 ])"); |
+result = matrix.translate(4, 2, 3); |
+shouldBeFalse("result.is2D"); |
+shouldBeFalse("result.isIdentity"); |
+shouldBeTrue("compareMatrix(result, [ 1, 0, 0, 6, 0, 1, 0, 5, 0, 0, 1, 3, 0, 0, 0, 1 ])"); |
+shouldBeTrue("matrix.is2D"); |
+shouldBeFalse("matrix.isIdentity"); |
+shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 0, 0, 0, 0, 1 ])"); |
+debug(""); |
+ |
+debug("# DOMMatrix.translateSelf(tx, ty, tz)"); |
+matrix = new DOMMatrix(); |
+shouldBeTrue("matrix.is2D"); |
+shouldBeTrue("matrix.isIdentity"); |
+shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); |
+result = matrix.translateSelf(4, 2, 3); |
+shouldBeFalse("result.is2D"); |
+shouldBeFalse("result.isIdentity"); |
+shouldBeTrue("compareMatrix(result, [ 1, 0, 0, 4, 0, 1, 0, 2, 0, 0, 1, 3, 0, 0, 0, 1 ])"); |
+shouldBeFalse("matrix.is2D"); |
+shouldBeFalse("matrix.isIdentity"); |
+shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 4, 0, 1, 0, 2, 0, 0, 1, 3, 0, 0, 0, 1 ])"); |
+debug(""); |
+ |
+debug("# DOMMatrix.translateSelf(tx, ty, tz) Homogeneous Coordinates"); |
+matrix = new DOMMatrix(); |
+shouldBeTrue("matrix.is2D"); |
+shouldBeTrue("matrix.isIdentity"); |
+matrix.m14 = 2; |
+matrix.m24 = 3; |
+matrix.m34 = 4; |
+matrix.m44 = 7; |
+shouldBeFalse("matrix.is2D"); |
+shouldBeFalse("matrix.isIdentity"); |
+shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2, 3, 4, 7 ])"); |
+matrix.translateSelf(7, -8, 2); |
+shouldBeFalse("matrix.is2D"); |
+shouldBeFalse("matrix.isIdentity"); |
+shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 7, 0, 1, 0, -8, 0, 0, 1, 2, 2, 3, 4, 5 ])"); |
+debug(""); |
+ |
+</script> |
+</body> |
+</html> |