blob: 984ad636251e06b4299054139b5941e9d6283c8b [file] [log] [blame]
<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="./resources/geometry-interfaces-test-helpers.js"></script>
<script>
test(function() {
var matrix = new DOMMatrix();
assert_identity_2d_matrix(matrix);
var result = matrix.translate();
assert_identity_2d_matrix(result);
assert_identity_2d_matrix(matrix);
}, "DOMMatrix.translate()");
test(function() {
var matrix = new DOMMatrix();
assert_identity_2d_matrix(matrix);
var result = matrix.translate(6);
assert_2d_matrix_equals(result, [1, 0, 0, 1, 6, 0]);
assert_identity_2d_matrix(matrix);
}, "DOMMatrix.translate(tx)");
test(function() {
var matrix = new DOMMatrix();
assert_identity_2d_matrix(matrix);
var result = matrix.translate(2, 3);
assert_2d_matrix_equals(result, [1, 0, 0, 1, 2, 3]);
assert_identity_2d_matrix(matrix);
}, "DOMMatrix.translate(tx, ty)");
test(function() {
var matrix = new DOMMatrix();
matrix.translateSelf(2, 3);
assert_2d_matrix_equals(matrix, [1, 0, 0, 1, 2, 3]);
var result = matrix.translate(4, 2);
assert_2d_matrix_equals(result, [1, 0, 0, 1, 6, 5]);
assert_2d_matrix_equals(matrix, [1, 0, 0, 1, 2, 3]);
}, "DOMMatrix.translate(tx, ty) with non-identity");
test(function() {
var matrix = new DOMMatrix();
assert_identity_2d_matrix(matrix);
var result = matrix.translateSelf();
assert_identity_2d_matrix(result);
assert_identity_2d_matrix(matrix);
}, "DOMMatrix.translateSelf()");
test(function() {
var matrix = new DOMMatrix();
assert_identity_2d_matrix(matrix);
var result = matrix.translateSelf(5);
assert_2d_matrix_equals(result, [1, 0, 0, 1, 5, 0]);
assert_2d_matrix_equals(matrix, [1, 0, 0, 1, 5, 0]);
}, "DOMMatrix.translateSelf(tx)");
test(function() {
var matrix = new DOMMatrix();
assert_identity_2d_matrix(matrix);
var result = matrix.translateSelf(4, 2);
assert_2d_matrix_equals(result, [1, 0, 0, 1, 4, 2]);
assert_2d_matrix_equals(matrix, [1, 0, 0, 1, 4, 2]);
}, "DOMMatrix.translateSelf(tx, ty)");
test(function() {
var matrix = new DOMMatrix();
assert_identity_2d_matrix(matrix);
var result = matrix.translate(2, 3, 4);
assert_3d_matrix_equals(result, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2, 3, 4, 1]);
assert_identity_2d_matrix(matrix);
}, "DOMMatrix.translate(tx, ty, tz)");
test(function() {
var matrix = new DOMMatrix();
matrix.translateSelf(2, 3);
assert_2d_matrix_equals(matrix, [1, 0, 0, 1, 2, 3]);
var result = matrix.translate(4, 2, 3);
assert_3d_matrix_equals(result, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 6, 5, 3, 1]);
assert_2d_matrix_equals(matrix, [1, 0, 0, 1, 2, 3]);
}, "DOMMatrix.translate(tx, ty, tz) with non-identity");
test(function() {
var matrix = new DOMMatrix();
assert_identity_2d_matrix(matrix);
var result = matrix.translateSelf(4, 2, 3);
assert_3d_matrix_equals(result, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 4, 2, 3, 1]);
assert_3d_matrix_equals(matrix, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 4, 2, 3, 1]);
}, "DOMMatrix.translateSelf(tx, ty, tz)");
test(function() {
var matrix = new DOMMatrix();
assert_identity_2d_matrix(matrix);
matrix.m14 = 2;
matrix.m24 = 3;
matrix.m34 = 4;
matrix.m44 = 7;
assert_3d_matrix_equals(matrix, [1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 4, 0, 0, 0, 7]);
matrix.translateSelf(7, -8, 2);
assert_3d_matrix_equals(matrix, [1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 4, 7, -8, 2, 5]);
}, "DOMMatrix.translateSelf(tx, ty, tz) Homogeneous Coordinates");
</script>