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

Unified Diff: LayoutTests/fast/canvas/script-tests/canvas-currentTransform2.js

Issue 24233004: Support currentTransform in 2D Canvas. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 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: LayoutTests/fast/canvas/script-tests/canvas-currentTransform2.js
diff --git a/LayoutTests/fast/canvas/script-tests/canvas-currentTransform2.js b/LayoutTests/fast/canvas/script-tests/canvas-currentTransform2.js
new file mode 100644
index 0000000000000000000000000000000000000000..03df2b90568d6dc89588115802ab7bf445a31b21
--- /dev/null
+++ b/LayoutTests/fast/canvas/script-tests/canvas-currentTransform2.js
@@ -0,0 +1,97 @@
+description("This test checks currentTransform in canvas v5");
+
+var canvas = document.createElement('canvas');
+document.body.appendChild(canvas);
+canvas.setAttribute('width', '100');
+canvas.setAttribute('height', '100');
+var ctx = canvas.getContext('2d');
+var matrix = ctx.currentTransform;
+
+debug("Check initial currentTransform values");
+shouldBe("matrix.a", "1");
+shouldBe("matrix.b", "0");
+shouldBe("matrix.c", "0");
+shouldBe("matrix.d", "1");
+shouldBe("matrix.e", "0");
+shouldBe("matrix.f", "0");
+
+matrix.a = 2;
+matrix.b = 0;
+matrix.c = 0;
+matrix.d = 2;
+matrix.e = 40;
+matrix.f = 40;
+ctx.currentTransform = matrix;
+matrix = ctx.currentTransform;
Justin Novosad 2013/09/19 19:23:48 Should use a different variable here to test that
+
+debug("Check assigning currentTransform");
+shouldBe("matrix.a", "2");
+shouldBe("matrix.b", "0");
+shouldBe("matrix.c", "0");
+shouldBe("matrix.d", "2");
+shouldBe("matrix.e", "40");
+shouldBe("matrix.f", "40");
+
+ctx.save();
+matrix.a = 3;
+matrix.b = 0;
+matrix.c = 0;
+matrix.d = 3;
+matrix.e = 60;
+matrix.f = 60;
+ctx.currentTransform = matrix;
+matrix = ctx.currentTransform;
Justin Novosad 2013/09/19 19:23:48 Same here
+
+debug("Check currentTransform after save of the context");
+shouldBe("matrix.a", "3");
+shouldBe("matrix.b", "0");
+shouldBe("matrix.c", "0");
+shouldBe("matrix.d", "3");
+shouldBe("matrix.e", "60");
+shouldBe("matrix.f", "60");
+
+ctx.restore();
+matrix = ctx.currentTransform;
+
+debug("Check currentTransform after restore of the context");
+shouldBe("matrix.a", "2");
+shouldBe("matrix.b", "0");
+shouldBe("matrix.c", "0");
+shouldBe("matrix.d", "2");
+shouldBe("matrix.e", "40");
+shouldBe("matrix.f", "40");
+
+debug("Check assigning an invalid object throws exception as expected");
+shouldThrow("ctx.currentTransform = ctx", "'TypeError: Type error'")
+
+matrix = ctx.currentTransform;
Justin Novosad 2013/09/19 19:23:48 Same here.
+
+debug("Check currentTransform should preserve a value after exception");
+shouldBe("matrix.a", "2");
+shouldBe("matrix.b", "0");
+shouldBe("matrix.c", "0");
+shouldBe("matrix.d", "2");
+shouldBe("matrix.e", "40");
+shouldBe("matrix.f", "40");
+
+ctx.scale(2, 2);
+matrix = ctx.currentTransform;
+
+debug("Check currentTransform after scale");
+shouldBe("matrix.a", "4");
+shouldBe("matrix.b", "0");
+shouldBe("matrix.c", "0");
+shouldBe("matrix.d", "4");
+shouldBe("matrix.e", "40");
+shouldBe("matrix.f", "40");
+
+ctx.translate(10, 10);
+matrix = ctx.currentTransform;
+
+debug("Check currentTransform after translate");
+shouldBe("matrix.a", "4");
+shouldBe("matrix.b", "0");
+shouldBe("matrix.c", "0");
+shouldBe("matrix.d", "4");
+shouldBe("matrix.e", "80");
+shouldBe("matrix.f", "80");

Powered by Google App Engine
This is Rietveld 408576698