Added: trunk/LayoutTests/imported/blink/fast/dom/geometry-interfaces-dom-matrix-transformPoint.html (0 => 217767)
--- trunk/LayoutTests/imported/blink/fast/dom/geometry-interfaces-dom-matrix-transformPoint.html (rev 0)
+++ trunk/LayoutTests/imported/blink/fast/dom/geometry-interfaces-dom-matrix-transformPoint.html 2017-06-04 15:21:52 UTC (rev 217767)
@@ -0,0 +1,102 @@
+<!DOCTYPE HTML>
+<script src=""
+<script src=""
+<script src=""
+<script>
+
+test(function() {
+ var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]);
+ var point = matrix2d.transformPoint();
+ assert_dom_point_equals(point, new DOMPoint(5, 6, 0, 1));
+}, "DOMMatrixReadOnly transformPoint() - 2d matrix ");
+
+test(function() {
+ var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
+ var point = matrix3d.transformPoint();
+ assert_dom_point_equals(point, new DOMPoint(13, 14, 15, 16));
+}, "DOMMatrixReadOnly transformPoint() - 3d matrix");
+
+test(function() {
+ var matrix2d = new DOMMatrixReadOnly([2, 0, 0, 2, 10, 10]);
+ var point = matrix2d.transformPoint(new DOMPoint(5));
+ assert_dom_point_equals(point, new DOMPoint(20, 10, 0, 1));
+}, "DOMMatrixReadOnly transformPoint(DOMPoint(x)) - 2d matrix");
+
+test(function() {
+ var matrix2d = new DOMMatrixReadOnly([2, 0, 0, 2, 10, 10]);
+ var point = matrix2d.transformPoint(new DOMPoint(5, 0, 0, 0));
+ assert_dom_point_equals(point, new DOMPoint(10, 0, 0, 0));
+}, "DOMMatrixReadOnly transformPoint(DOMPoint(x, 0, 0, 0)) - 2d matrix");
+
+test(function() {
+ var matrix2d = new DOMMatrixReadOnly([2, 0, 0, 2, 10, 10]);
+ var point = matrix2d.transformPoint(new DOMPoint(5, 4));
+ assert_dom_point_equals(point, new DOMPoint(20, 18, 0, 1));
+}, "DOMMatrixReadOnly transformPoint(DOMPoint(x, y)) - 2d matrix");
+
+test(function() {
+ var matrix2d = new DOMMatrixReadOnly([2, 0, 0, 2, 10, 10]);
+ var point = matrix2d.transformPoint(new DOMPoint(5, 4, 0, 0));
+ assert_dom_point_equals(point, new DOMPoint(10, 8, 0, 0));
+}, "DOMMatrixReadOnly transformPoint(DOMPoint(x, y, 0, 0)) - 2d matrix");
+
+test(function() {
+ var matrix2d = new DOMMatrixReadOnly([2, 0, 0, 2, 10, 10]);
+ var point = matrix2d.transformPoint(new DOMPoint(5, 4, 3));
+ assert_dom_point_equals(point, new DOMPoint(20, 18, 3, 1));
+}, "DOMMatrixReadOnly transformPoint(DOMPoint(x, y, z)) - 2d matrix");
+
+test(function() {
+ var matrix2d = new DOMMatrixReadOnly([2, 0, 0, 2, 10, 10]);
+ var point = matrix2d.transformPoint(new DOMPoint(5, 4, 3, 0));
+ assert_dom_point_equals(point, new DOMPoint(10, 8, 3, 0));
+}, "DOMMatrixReadOnly transformPoint(DOMPoint(x, y, z, 0)) - 2d matrix");
+
+test(function() {
+ var matrix2d = new DOMMatrixReadOnly([2, 0, 0, 2, 10, 10]);
+ var point = matrix2d.transformPoint(new DOMPoint(5, 4, 14, 5));
+ assert_dom_point_equals(point, new DOMPoint(60, 58, 14, 5));
+}, "DOMMatrixReadOnly transformPoint(DOMPoint(x, y, z, w)) - 2d matrix");
+
+test(function() {
+ var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
+ var point = matrix3d.transformPoint(new DOMPoint(5));
+ assert_dom_point_equals(point, new DOMPoint(18, 24, 30, 36));
+}, "DOMMatrixReadOnly transformPoint(DOMPoint(x)) - 3d matrix");
+
+test(function() {
+ var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
+ var point = matrix3d.transformPoint(new DOMPoint(5, 0, 0, 0));
+ assert_dom_point_equals(point, new DOMPoint(5, 10, 15, 20));
+}, "DOMMatrixReadOnly transformPoint(DOMPoint(x, 0, 0, 0)) - 3d matrix");
+
+test(function() {
+ var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
+ var point = matrix3d.transformPoint(new DOMPoint(5, 4));
+ assert_dom_point_equals(point, new DOMPoint(38, 48, 58, 68));
+}, "DOMMatrixReadOnly transformPoint(DOMPoint(x, y)) - 3d matrix");
+
+test(function() {
+ var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
+ var point = matrix3d.transformPoint(new DOMPoint(5, 4, 0, 0));
+ assert_dom_point_equals(point, new DOMPoint(25, 34, 43, 52));
+}, "DOMMatrixReadOnly transformPoint(DOMPoint(x, y, 0, 0)) - 3d matrix");
+
+test(function() {
+ var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
+ var point = matrix3d.transformPoint(new DOMPoint(5, 4, 3));
+ assert_dom_point_equals(point, new DOMPoint(65, 78, 91, 104));
+}, "DOMMatrixReadOnly transformPoint(DOMPoint(x, y, z)) - 3d matrix");
+
+test(function() {
+ var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
+ var point = matrix3d.transformPoint(new DOMPoint(5, 4, 3, 0));
+ assert_dom_point_equals(point, new DOMPoint(52, 64, 76, 88));
+}, "DOMMatrixReadOnly transformPoint(DOMPoint(x, y, z, 0)) - 3d matrix");
+
+test(function() {
+ var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
+ var point = matrix3d.transformPoint(new DOMPoint(5, 4, 14, 5));
+ assert_dom_point_equals(point, new DOMPoint(216, 244, 272, 300));
+}, "DOMMatrixReadOnly transformPoint(DOMPoint(x, y, z, w)) - 3d matrix");
+</script>
Added: trunk/LayoutTests/imported/blink/fast/dom/resources/geometry-interfaces-test-helpers.js (0 => 217767)
--- trunk/LayoutTests/imported/blink/fast/dom/resources/geometry-interfaces-test-helpers.js (rev 0)
+++ trunk/LayoutTests/imported/blink/fast/dom/resources/geometry-interfaces-test-helpers.js 2017-06-04 15:21:52 UTC (rev 217767)
@@ -0,0 +1,109 @@
+function assert_identity_2d_matrix(actual) {
+ assert_true(actual instanceof DOMMatrixReadOnly);
+ assert_true(actual.is2D, "is2D");
+ assert_true(actual.isIdentity, "isIdentity");
+ assert_identity_matrix(actual);
+}
+
+function assert_identity_3d_matrix(actual) {
+ assert_true(actual instanceof DOMMatrixReadOnly);
+ assert_false(actual.is2D, "is2D");
+ assert_true(actual.isIdentity, "isIdentity");
+ assert_identity_matrix(actual);
+}
+
+function assert_identity_matrix(actual) {
+ assert_array_equals(actual.toFloat64Array(), [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
+}
+
+function toArray(actual) {
+ var array = actual.toFloat64Array();
+ // Do not care negative zero for testing accommodation.
+ for (var i = 0; i < array.length; i++) {
+ if (array[i] === -0)
+ array[i] = 0;
+ }
+ return array;
+}
+
+function assert_2d_matrix_equals(actual, expected) {
+ assert_true(actual instanceof DOMMatrixReadOnly);
+ assert_true(Array.isArray(expected));
+ assert_equals(6, expected.length, "expected.length");
+ assert_true(actual.is2D, "is2D");
+ assert_false(actual.isIdentity, "isIdentity");
+ assert_array_equals(toArray(actual), [
+ expected[0], expected[1], 0, 0,
+ expected[2], expected[3], 0, 0,
+ 0, 0, 1, 0,
+ expected[4], expected[5], 0, 1
+ ]);
+}
+
+function assert_3d_matrix_equals(actual, expected) {
+ assert_true(actual instanceof DOMMatrixReadOnly);
+ assert_true(Array.isArray(expected) );
+ assert_equals(16, expected.length, "expected.length");
+ assert_false(actual.is2D, "is2D");
+ assert_false(actual.isIdentity, "isIdentity");
+ assert_array_equals(toArray(actual), [
+ expected[0], expected[1], expected[2], expected[3],
+ expected[4], expected[5], expected[6], expected[7],
+ expected[8], expected[9], expected[10], expected[11],
+ expected[12], expected[13], expected[14], expected[15],
+ ]);
+}
+
+function assert_array_almost_equals(actual, expected) {
+ for (var i = 0; i < actual.length; i++) {
+ assert_equals(actual[i].toFixed(10), expected[i].toFixed(10));
+ }
+}
+
+function assert_matrix_almost_equals(actual, expected) {
+ assert_array_almost_equals(actual.toFloat64Array(), expected.toFloat64Array());
+}
+
+function assert_dom_point_equals(actual, expected) {
+ assert_true(actual instanceof DOMPointReadOnly);
+ if(Array.isArray(expected)) {
+ assert_equals(expected.length, 4);
+ assert_equals(actual.x, expected[0], "point equality: x differs");
+ assert_equals(actual.y, expected[1], "point equality: y differs");
+ assert_equals(actual.z, expected[2], "point equality: z differs");
+ assert_equals(actual.w, expected[3], "point equality: w differs");
+ } else if(expected instanceof DOMPointReadOnly) {
+ assert_equals(actual.x, expected.x, "point equality: x differs");
+ assert_equals(actual.y, expected.y, "point equality: y differs");
+ assert_equals(actual.z, expected.z, "point equality: z differs");
+ assert_equals(actual.w, expected.w, "point equality: w differs");
+ } else {
+ assert_unreached();
+ }
+}
+
+function assert_dom_rect_equals(actual, expected) {
+ assert_true(actual instanceof DOMRectReadOnly);
+ if(Array.isArray(expected)) {
+ assert_equals(expected.length, 8);
+ assert_equals(actual.x, expected[0], "rect equality: x differs");
+ assert_equals(actual.y, expected[1], "rect equality: y differs");
+ assert_equals(actual.width, expected[2], "rect equality: width differs");
+ assert_equals(actual.height, expected[3], "rect equality: height differs");
+ assert_equals(actual.top, expected[4], "rect equality: top differs");
+ assert_equals(actual.right, expected[5], "rect equality: right differs");
+ assert_equals(actual.bottom, expected[6], "rect equality: bottom differs");
+ assert_equals(actual.left, expected[7], "rect equality: left differs");
+ } else if(expected instanceof DOMRectReadOnly) {
+ assert_equals(actual.x, expected.x, "rect equality: x differs");
+ assert_equals(actual.y, expected.y, "rect equality: y differs");
+ assert_equals(actual.width, expected.width, "rect equality: width differs");
+ assert_equals(actual.height, expected.height, "rect equality: height differs");
+ assert_equals(actual.top, expected.top, "rect equality: top differs");
+ assert_equals(actual.right, expected.right, "rect equality: right differs");
+ assert_equals(actual.bottom, expected.bottom, "rect equality: bottom differs");
+ assert_equals(actual.left, expected.left, "poirectnt equality: left differs");
+ } else {
+ assert_unreached();
+ }
+}
\ No newline at end of file