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

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

Issue 2380713004: [GeometryInterface] Add setMatrixValue(transfromList) function. (Closed)
Patch Set: [GeometryInterface] Add setMatrixValue(transfromList) function. Created 4 years, 2 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-setMatrixValue.html
diff --git a/third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-setMatrixValue.html b/third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-setMatrixValue.html
new file mode 100644
index 0000000000000000000000000000000000000000..78b042ef50bf8bdda1c2a0413f2949d968b26a09
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-setMatrixValue.html
@@ -0,0 +1,293 @@
+<!DOCTYPE HTML>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="./resources/geometry-interfaces-test-helpers.js"></script>
+<script>
+
+var matrix2d = new DOMMatrix([5, 4, 11, 34, 55, 11]);
+var matrix3d = new DOMMatrix([5, 11, 55, 77, 44, 33, 55, 75, 88, 99, 12, 43, 65, 36, 85, 25]);
+
+test(() => {
+ var actualMatrix1 = new DOMMatrix(matrix2d);
+ var actualMatrix2 = new DOMMatrix(matrix3d);
+ var expectedMatrix = new DOMMatrix();
+ actualMatrix1.setMatrixValue("");
+ assert_true(actualMatrix1.is2D);
+ assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
+ actualMatrix2.setMatrixValue("");
+ assert_true(actualMatrix2.is2D);
+ assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
+}, "DOMMatrix setMatrix(EmptyString)");
+
+test(() => {
+ var actualMatrix1 = new DOMMatrix(matrix2d);
+ var actualMatrix2 = new DOMMatrix(matrix3d);
+ var expectedMatrix = new DOMMatrix();
+ actualMatrix1.setMatrixValue("none");
+ assert_true(actualMatrix1.is2D);
+ assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
+ actualMatrix2.setMatrixValue("none");
+ assert_true(actualMatrix2.is2D);
+ assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
+}, "DOMMatrix setMatrix('none')");
+
+test(() => {
+ var actualMatrix1 = new DOMMatrix(matrix2d);
+ var actualMatrix2 = new DOMMatrix(matrix3d);
+ var expectedMatrix = new DOMMatrix();
+ actualMatrix1.setMatrixValue("matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0)");
+ assert_true(actualMatrix1.is2D);
+ actualMatrix2.setMatrixValue("matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0)");
+ assert_true(actualMatrix2.is2D);
+ expectedMatrix.multiplySelf(new DOMMatrix([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]))
+ assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
+ assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
+}, "DOMMatrix setMatrix('matrix')");
+
+test(() => {
+ var actualMatrix1 = new DOMMatrix(matrix2d);
+ var actualMatrix2 = new DOMMatrix(matrix3d);
+ var expectedMatrix = new DOMMatrix();
+ actualMatrix1.setMatrixValue("translate(44px, 55px)");
+ assert_true(actualMatrix1.is2D);
+ actualMatrix2.setMatrixValue("translate(44px, 55px)");
+ assert_true(actualMatrix2.is2D);
+ expectedMatrix.translateSelf(44, 55)
+ assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
+ assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
+}, "DOMMatrix setMatrix('translate')");
+
+test(() => {
+ var actualMatrix1 = new DOMMatrix(matrix2d);
+ var actualMatrix2 = new DOMMatrix(matrix3d);
+ var expectedMatrix = new DOMMatrix();
+ actualMatrix1.setMatrixValue("translateX(35px)");
+ assert_true(actualMatrix1.is2D);
+ actualMatrix2.setMatrixValue("translateX(35px)");
+ assert_true(actualMatrix2.is2D);
+ expectedMatrix.translateSelf(35, 0)
+ assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
+ assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
+}, "DOMMatrix setMatrix('translateX')");
+
+test(() => {
+ var actualMatrix1 = new DOMMatrix(matrix2d);
+ var actualMatrix2 = new DOMMatrix(matrix3d);
+ var expectedMatrix = new DOMMatrix();
+ actualMatrix1.setMatrixValue("translateY(77px)");
+ assert_true(actualMatrix1.is2D);
+ actualMatrix2.setMatrixValue("translateY(77px)");
+ assert_true(actualMatrix2.is2D);
+ expectedMatrix.translateSelf(0, 77)
+ assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
+ assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
+}, "DOMMatrix setMatrix('translateY')");
+
+test(() => {
+ var actualMatrix1 = new DOMMatrix(matrix2d);
+ var actualMatrix2 = new DOMMatrix(matrix3d);
+ var expectedMatrix = new DOMMatrix();
+ actualMatrix1.setMatrixValue("scale(2, 2)");
+ assert_true(actualMatrix1.is2D);
+ actualMatrix2.setMatrixValue("scale(2, 2)");
+ assert_true(actualMatrix2.is2D);
+ expectedMatrix.scaleSelf(2, 2);
+ assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
+ assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
+}, "DOMMatrix setMatrix('scale')");
+
+test(() => {
+ var actualMatrix1 = new DOMMatrix(matrix2d);
+ var actualMatrix2 = new DOMMatrix(matrix3d);
+ var expectedMatrix = new DOMMatrix();
+ actualMatrix1.setMatrixValue("scaleX(2)");
+ assert_true(actualMatrix1.is2D);
+ actualMatrix2.setMatrixValue("scaleX(2)");
+ assert_true(actualMatrix2.is2D);
+ expectedMatrix.scaleSelf(2, 1);
+ assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
+ assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
+}, "DOMMatrix setMatrix('scaleX')");
+
+test(() => {
+ var actualMatrix1 = new DOMMatrix(matrix2d);
+ var actualMatrix2 = new DOMMatrix(matrix3d);
+ var expectedMatrix = new DOMMatrix();
+ actualMatrix1.setMatrixValue("scaleY(2)");
+ assert_true(actualMatrix1.is2D);
+ actualMatrix2.setMatrixValue("scaleY(2)");
+ assert_true(actualMatrix2.is2D);
+ expectedMatrix.scaleSelf(1, 2);
+ assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
+ assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
+}, "DOMMatrix setMatrix('scaleY')");
+
+test(() => {
+ var actualMatrix1 = new DOMMatrix(matrix2d);
+ var actualMatrix2 = new DOMMatrix(matrix3d);
+ var expectedMatrix = new DOMMatrix();
+ actualMatrix1.setMatrixValue("rotate(90deg)");
+ assert_true(actualMatrix1.is2D);
+ actualMatrix2.setMatrixValue("rotate(90deg)");
+ assert_true(actualMatrix2.is2D);
+ expectedMatrix.rotateAxisAngleSelf(0, 0, 1, 90);
+ assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
+ assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
+}, "DOMMatrix setMatrix('rotate')");
+
+test(() => {
+ var actualMatrix1 = new DOMMatrix(matrix2d);
+ var actualMatrix2 = new DOMMatrix(matrix3d);
+ var expectedMatrix = new DOMMatrix();
+ actualMatrix1.setMatrixValue("skewX(30deg)");
+ assert_true(actualMatrix1.is2D);
+ actualMatrix2.setMatrixValue("skewX(30deg)");
+ assert_true(actualMatrix2.is2D);
+ expectedMatrix.skewXSelf(30);
+ assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
+ assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
+}, "DOMMatrix setMatrix('skewX')");
+
+test(() => {
+ var actualMatrix1 = new DOMMatrix(matrix2d);
+ var actualMatrix2 = new DOMMatrix(matrix3d);
+ var expectedMatrix = new DOMMatrix();
+ actualMatrix1.setMatrixValue("skewY(40deg)");
+ assert_true(actualMatrix1.is2D);
+ actualMatrix2.setMatrixValue("skewY(40deg)");
+ assert_true(actualMatrix2.is2D);
+ expectedMatrix.skewYSelf(40);
+ assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
+ assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
+}, "DOMMatrix setMatrix('skewY')");
+
+test(() => {
+ var actualMatrix1 = new DOMMatrix(matrix2d);
+ var actualMatrix2 = new DOMMatrix(matrix3d);
+ var expectedMatrix = new DOMMatrix();
+ actualMatrix1.setMatrixValue("matrix3d(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0)");
+ assert_false(actualMatrix1.is2D);
+ actualMatrix2.setMatrixValue("matrix3d(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0)");
+ assert_false(actualMatrix2.is2D);
+ expectedMatrix.multiplySelf(new DOMMatrix([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0]))
+ assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
+ assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
+}, "DOMMatrix setMatrix(matrix3d)");
+
+test(() => {
+ var actualMatrix1 = new DOMMatrix(matrix2d);
+ var actualMatrix2 = new DOMMatrix(matrix3d);
+ var expectedMatrix = new DOMMatrix();
+ actualMatrix1.setMatrixValue("translate3d(10px, 20px, 30px)");
+ assert_false(actualMatrix1.is2D);
+ actualMatrix2.setMatrixValue("translate3d(10px, 20px, 30px)");
+ assert_false(actualMatrix2.is2D);
+ expectedMatrix.translateSelf(10, 20, 30)
+ assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
+ assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
+}, "DOMMatrix setMatrix(translate3d)");
+
+test(() => {
+ var actualMatrix1 = new DOMMatrix(matrix2d);
+ var actualMatrix2 = new DOMMatrix(matrix3d);
+ var expectedMatrix = new DOMMatrix();
+ actualMatrix1.setMatrixValue("translateZ(88px)");
+ assert_false(actualMatrix1.is2D);
+ actualMatrix2.setMatrixValue("translateZ(88px)");
+ assert_false(actualMatrix2.is2D);
+ expectedMatrix.translateSelf(0, 0, 88)
+ assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
+ assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
+}, "DOMMatrix setMatrix('translateY')");
+
+test(() => {
+ var actualMatrix1 = new DOMMatrix(matrix2d);
+ var actualMatrix2 = new DOMMatrix(matrix3d);
+ var expectedMatrix = new DOMMatrix();
+ actualMatrix1.setMatrixValue("matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0) translate(44px, 55px) skewX(30deg)");
+ assert_true(actualMatrix1.is2D);
+ actualMatrix2.setMatrixValue("matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0) translate(44px, 55px) skewX(30deg)");
+ assert_true(actualMatrix2.is2D);
+ expectedMatrix.multiplySelf(new DOMMatrix([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]))
+ expectedMatrix.translateSelf(44, 55)
+ expectedMatrix.skewXSelf(30);
+ assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
+ assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
+}, "DOMMatrix setMatrix(multiple value)");
+
+// TODO(hs1217.lee) : calc() function take only absolute unit. should be pass this test.
+// but calc() function is not supported not yet.
+// refer to hasRelativeLengths() in TransformBuilder.cpp
+// test(() => {
+// var actualMatrix1 = new DOMMatrix(matrix2d);
+// var actualMatrix2 = new DOMMatrix(matrix3d);
+// var expectedMatrix = new DOMMatrix();
+// actualMatrix1.setMatrixValue("translateX(calc(10px + 1px))");
+// assert_true(actualMatrix1.is2D);
+// actualMatrix2.setMatrixValue("translateX(calc(10px + 1px))");
+// assert_true(actualMatrix2.is2D);
+// expectedMatrix.translateSelf(11, 0)
+// assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
+// assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
+// }, "DOMMatrix setMatrix(multiple value)");
+
+test(() => {
+
+ var actualMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]);
+ var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]);
+
+ assert_throws(new SyntaxError(), () => {
+ actualMatrix.setMatrixValue("initial");
+ }, "CSS-wide keywords are disallowed.");
+
+ assert_throws(new SyntaxError(), () => {
+ actualMatrix.setMatrixValue("notExistFunction()");
+ }, "can't parse not exist function.");
+
+ assert_throws(new SyntaxError(), () => {
+ actualMatrix.setMatrixValue("translateY(50%)");
+ }, "Can't parse without absolute unit.");
+
+ assert_throws(new SyntaxError(), () => {
+ actualMatrix.setMatrixValue("translateX(1.2em)");
+ }, "Can't parse without absolute unit.");
+
+ assert_throws(new SyntaxError(), () => {
+ actualMatrix.setMatrixValue("translateX(10ex)");
+ }, "Can't parse without absolute unit.");
+
+ assert_throws(new SyntaxError(), () => {
+ actualMatrix.setMatrixValue("translateX(10ch)");
+ }, "Can't parse without absolute unit.");
+
+ assert_throws(new SyntaxError(), () => {
+ actualMatrix.setMatrixValue("translateX(10rem)");
+ }, "Can't parse without absolute unit.");
+
+ assert_throws(new SyntaxError(), () => {
+ actualMatrix.setMatrixValue("translateX(10vw)");
+ }, "Can't parse without absolute unit.");
+
+ assert_throws(new SyntaxError(), () => {
+ actualMatrix.setMatrixValue("translateX(10vh)");
+ }, "Can't parse without absolute unit.");
+
+ assert_throws(new SyntaxError(), () => {
+ actualMatrix.setMatrixValue("translateX(10vmin)");
+ }, "Can't parse without absolute unit.");
+
+ assert_throws(new SyntaxError(), () => {
+ actualMatrix.setMatrixValue("translateX(10vmax)");
+ }, "Can't parse without absolute unit.");
+
+ assert_throws(new SyntaxError(), () => {
+ actualMatrix.setMatrixValue("translateX(calc(10px + 1em))");
+ }, "Can't parse without absolute unit.");
+
+ //actualMatrix should be not changed.
+ assert_true(actualMatrix.is2D);
+ assert_matrix_almost_equals(actualMatrix, expectedMatrix);
+
+}, "DOMMatrix.setMatrix(): Exception test.");
+
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698