Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix.html

Issue 2283363003: GeometryInterface: Add DOMMatrixInit and fromMatrix(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix.html
diff --git a/third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix.html b/third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix.html
index f394c57d40b7fa85fa610fefe4f3edc1b449166a..b151191d3c1e13c81c902a5d365b9582a876cefc 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix.html
+++ b/third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix.html
@@ -108,6 +108,83 @@ test(function() {
assert_true(matrix.isIdentity);
}, "DOMMatrix.is2D can never be set to 'true' when it was set to 'false' before calling setMatrixValue().");
+test(function() {
+ var matrix = DOMMatrix.fromMatrix();
+ assert_array_equals(matrix.toFloat64Array(), [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
dominicc (has gone to gerrit) 2016/08/30 02:13:43 This assert_array_equals/assert_true/assert_true i
zino 2016/09/10 10:18:15 Done.
+ assert_true(matrix.is2D);
+ assert_true(matrix.isIdentity);
+}, "DOMMatrix.fromMatrix() with no parameter.");
+
+test(function() {
+ var matrix = DOMMatrix.fromMatrix(null);
+ assert_array_equals(matrix.toFloat64Array(), [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
+ assert_true(matrix.is2D);
+ assert_true(matrix.isIdentity);
+}, "DOMMatrix.fromMatrix() with null.");
+
+test(function() {
+ var matrix = DOMMatrix.fromMatrix(undefined);
+ assert_array_equals(matrix.toFloat64Array(), [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
+ assert_true(matrix.is2D);
+ assert_true(matrix.isIdentity);
+}, "DOMMatrix.fromMatrix() with undefined.");
+
+test(function() {
+ var matrix = DOMMatrix.fromMatrix({});
+ assert_array_equals(matrix.toFloat64Array(), [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
+ assert_true(matrix.is2D);
+ assert_true(matrix.isIdentity);
+}, "DOMMatrix.fromMatrix() with empty object.");
+
+test(function() {
+ var matrix = DOMMatrix.fromMatrix({a: 1, b: 2, c: 3, d: 4, e: 5, f: 6});
+ assert_array_equals(matrix.toFloat64Array(), [1, 2, 0, 0, 3, 4, 0, 0, 0, 0, 1, 0, 5, 6, 0, 1]);
+ assert_true(matrix.is2D);
+ assert_false(matrix.isIdentity);
+}, "DOMMatrix.fromMatrix({a: 1, b: 2, c: 3, d: 4, e: 5, f: 6}) should create a 2D DOMMatrix.");
+
+test(function() {
+ var matrix = DOMMatrix.fromMatrix({m11: 1, m22: 2, m33: 3, m44: 4, m23: 5, m43: 6});
+ assert_array_equals(matrix.toFloat64Array(), [1, 0, 0, 0, 0, 2, 5, 0, 0, 0, 3, 0, 0, 0, 6, 4]);
+ assert_false(matrix.is2D);
+ assert_false(matrix.isIdentity);
+}, "DOMMatrix.fromMatrix({m11: 1, m22: 2, m33: 3, m44: 4, m23: 5, m43: 6}) should create a 2D DOMMatrix.");
+
+test(function() {
+ var matrix = DOMMatrix.fromMatrix({a: 1, m12: 2, m21: 3, d: 4, m41: 5, f: 6});
+ assert_equals(matrix.m11, 1);
+ assert_equals(matrix.b, 2);
+ assert_equals(matrix.c, 3);
+ assert_equals(matrix.m22, 4);
+ assert_equals(matrix.e, 5);
+ assert_equals(matrix.m42, 6);
+}, "[a, b, c, d, e, f] members should equals [m11, m12, m21, m22, m41, m42].");
+
+test(function() {
+ var matrix = DOMMatrix.fromMatrix({a: 7, c: 9});
+ assert_equals(matrix.a, 7);
+ assert_equals(matrix.b, 0);
+ assert_equals(matrix.c, 9);
+ assert_equals(matrix.d, 1);
+ assert_equals(matrix.e, 0);
+ assert_equals(matrix.f, 0);
+ assert_equals(matrix.m11, 7);
+ assert_equals(matrix.m12, 0);
+ assert_equals(matrix.m21, 9);
+ assert_equals(matrix.m22, 1);
+ assert_equals(matrix.m41, 0);
+ assert_equals(matrix.m42, 0);
+}, "If 2d related members don't be set, should set to fallback.");
+
+test(function() {
+ assert_throws(new TypeError(), function() {
+ var matrix = DOMMatrix.fromMatrix({a: 1, b: 2, m33: 3, m44: 4, is2D: true});
+ }, "The is2D member is set to true but the input matrix is 3d matrix.");
+ assert_throws(new TypeError(), function() {
+ var matrix = DOMMatrix.fromMatrix({a: 1, b: 2, m11: 3});
+ }, "The a member should equal the m11 member.");
+}, "DOMMatrix.fromMatrix(): Exception tests.");
+
dominicc (has gone to gerrit) 2016/08/30 02:13:43 I think it would be worth adding NaN tests, given
zino 2016/09/10 10:18:15 Done.
</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698