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

Unified Diff: third_party/WebKit/LayoutTests/svg/dom/SVGTransformList-basics.html

Issue 2362653002: Convert LayoutTests/svg/dom/SVGTransform*.html js-tests.js to testharness.js based tests (Closed)
Patch Set: Align with review comments Created 4 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: third_party/WebKit/LayoutTests/svg/dom/SVGTransformList-basics.html
diff --git a/third_party/WebKit/LayoutTests/svg/dom/SVGTransformList-basics.html b/third_party/WebKit/LayoutTests/svg/dom/SVGTransformList-basics.html
new file mode 100644
index 0000000000000000000000000000000000000000..8375c7082d14c941306170e5688b3f3fa212c3a3
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/svg/dom/SVGTransformList-basics.html
@@ -0,0 +1,183 @@
+<!DOCTYPE HTML>
+<title>SVGTransformList, basics</title>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="resources/SVGTransformList-helper.js"></script>
+<svg width="200" height="200">
+ <circle cx="40" cy="40" r="40" fill="green" transform="scale(2, 2) translate(10 10)"/>
+</svg>
+<script>
+test(function() {
+ // This is a test of the simple SVGTransformList API parts.
+
+ var svg = document.querySelector("svg");
+ var circle1 = document.querySelector("circle");
+ var transformList = circle1.transform.baseVal;
+
+ // TODO(shanmuga.m) : // Split into several subtests.
+
+ // Spec: The object referenced by animVal will always be distinct from the one referenced by baseVal, even when the attribute is not animated.
+ assert_not_equals(circle1.transform.baseVal, circle1.transform.animVal);
+
+ assert_equals(circle1.transform.baseVal.numberOfItems, 2);
+ assert_equals(circle1.transform.animVal.numberOfItems, 2);
+ assert_equals(transformList.getItem(0).toString(), "type=SVG_TRANSFORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
+ assert_equals(transformList.getItem(1).toString(), "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
+
+ // Test uncommon arguments for initialize().
+ assert_throws(new TypeError(), function() { transformList.initialize(30); });
+ assert_throws(new TypeError(), function() { transformList.initialize('aString'); });
+ assert_throws(new TypeError(), function() { transformList.initialize(circle1); });
+ assert_throws(new TypeError(), function() { transformList.initialize(null); });
+
+ // Test uncommon arguments for getItem().
+ assert_throws("IndexSizeError", function() { transformList.getItem(30); });
+ assert_equals(transformList.getItem('aString').toString(), "type=SVG_TRANSFORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
+ assert_equals(transformList.getItem(circle1).toString(), "type=SVG_TRANSFORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
+ assert_equals(transformList.getItem(null).toString(), "type=SVG_TRANSFORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
+
+ // Test uncommon arguments for insertItemBefore().
+ assert_throws(new TypeError(), function() { transformList.insertItemBefore(30); });
+ assert_throws(new TypeError(), function() { transformList.insertItemBefore('aString'); });
+ assert_throws(new TypeError(), function() { transformList.insertItemBefore(circle1); });
+ assert_throws(new TypeError(), function() { transformList.insertItemBefore(null); });
+
+ assert_equals(transformList.insertItemBefore(transformList.getItem(1), 'aString').toString(), "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
+ assert_equals(transformList.numberOfItems, 3);
+ assert_equals(transformList.getItem(0).toString(), "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
+ assert_equals(transformList.getItem(1).toString(), "type=SVG_TRANSFORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
+ assert_equals(transformList.getItem(2).toString(), "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
+ assert_equals(circle1.getAttribute('transform'), "translate(10 10) scale(2 2) translate(10 10)");
+
+ assert_equals(transformList.insertItemBefore(transformList.getItem(1), circle1).toString(), "type=SVG_TRANSFORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
+ assert_equals(transformList.numberOfItems, 4);
+ assert_equals(transformList.getItem(0).toString(), "type=SVG_TRANSFORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
+ assert_equals(transformList.getItem(1).toString(), "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
+ assert_equals(transformList.getItem(2).toString(), "type=SVG_TRANSFORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
+ assert_equals(transformList.getItem(3).toString(), "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
+ assert_equals(circle1.getAttribute('transform'), "scale(2 2) translate(10 10) scale(2 2) translate(10 10)");
+
+ assert_equals(transformList.insertItemBefore(transformList.getItem(1), null).toString(), "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
+ assert_equals(transformList.numberOfItems, 5);
+ assert_equals(transformList.getItem(0).toString(), "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
+ assert_equals(transformList.getItem(1).toString(), "type=SVG_TRANSFORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
+ assert_equals(transformList.getItem(2).toString(), "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
+ assert_equals(transformList.getItem(3).toString(), "type=SVG_TRANSFORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
+ assert_equals(transformList.getItem(4).toString(), "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
+ assert_equals(circle1.getAttribute('transform'), "translate(10 10) scale(2 2) translate(10 10) scale(2 2) translate(10 10)");
+
+ assert_equals(transformList.insertItemBefore(transformList.getItem(1), 0).toString(), "type=SVG_TRANSFORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
+ assert_equals(transformList.numberOfItems, 6);
+ assert_equals(transformList.getItem(0).toString(), "type=SVG_TRANSFORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
+ assert_equals(transformList.getItem(1).toString(), "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
+ assert_equals(transformList.getItem(2).toString(), "type=SVG_TRANSFORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
+ assert_equals(transformList.getItem(3).toString(), "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
+ assert_equals(transformList.getItem(4).toString(), "type=SVG_TRANSFORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
+ assert_equals(transformList.getItem(5).toString(), "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
+ assert_equals(circle1.getAttribute('transform'), "scale(2 2) translate(10 10) scale(2 2) translate(10 10) scale(2 2) translate(10 10)");
+
+ assert_throws(new TypeError(), function() { transformList.insertItemBefore(30, 0); });
+ assert_throws(new TypeError(), function() { transformList.insertItemBefore('aString', 0); });
+ assert_throws(new TypeError(), function() { transformList.insertItemBefore(circle1, 0); });
+ assert_throws(new TypeError(), function() { transformList.insertItemBefore(null, 0); });
+
+ // Set transform='rotate(90) scale(2 2) translate(10 10) skewX(45)' for circle1.
+ circle1.setAttribute('transform', 'rotate(90) scale(2 2) translate(10 10) skewX(45)');
+ assert_equals(transformList.numberOfItems, 4);
+ assert_equals(transformList.getItem(0).toString(), "type=SVG_TRANSFORM_ROTATE matrix=[0.0 1.0 -1.0 0.0 0.0 0.0]");
+ assert_equals(transformList.getItem(1).toString(), "type=SVG_TRANSFORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
+ assert_equals(transformList.getItem(2).toString(), "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
+ assert_equals(transformList.getItem(3).toString(), "type=SVG_TRANSFORM_SKEWX matrix=[1.0 0.0 1.0 1.0 0.0 0.0]");
+ assert_equals(circle1.getAttribute('transform'), "rotate(90) scale(2 2) translate(10 10) skewX(45)");
+
+ // Test uncommon arguments for replaceItem().
+ assert_throws(new TypeError(), function() { transformList.replaceItem(30); });
+ assert_throws(new TypeError(), function() { transformList.replaceItem('aString'); });
+ assert_throws(new TypeError(), function() { transformList.replaceItem(circle1); });
+ assert_throws(new TypeError(), function() { transformList.replaceItem(null); });
+ assert_throws(new TypeError(), function() { transformList.replaceItem(30, 0); });
+ assert_throws(new TypeError(), function() { transformList.replaceItem('aString', 0); });
+ assert_throws(new TypeError(), function() { transformList.replaceItem(circle1, 0); });
+ assert_throws(new TypeError(), function() { transformList.replaceItem(null, 0); });
+
+ // Test uncommon values for indexed setter.
+ assert_throws(new TypeError(), function() { transformList[0] = 30; });
+ assert_throws(new TypeError(), function() { transformList[0] = 'aString'; });
+ assert_throws(new TypeError(), function() { transformList[0] = circle1; });
+ assert_throws(new TypeError(), function() { transformList[0] = null; });
+
+ assert_equals(transformList.replaceItem(transformList.getItem(3), 0).toString(), "type=SVG_TRANSFORM_SKEWX matrix=[1.0 0.0 1.0 1.0 0.0 0.0]");
+ assert_equals(transformList.numberOfItems, 4);
+ assert_equals(transformList.getItem(0).toString(), "type=SVG_TRANSFORM_SKEWX matrix=[1.0 0.0 1.0 1.0 0.0 0.0]");
+ assert_equals(transformList.getItem(1).toString(), "type=SVG_TRANSFORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
+ assert_equals(transformList.getItem(2).toString(), "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
+ assert_equals(transformList.getItem(3).toString(), "type=SVG_TRANSFORM_SKEWX matrix=[1.0 0.0 1.0 1.0 0.0 0.0]");
+ assert_equals(circle1.getAttribute('transform'), "skewX(45) scale(2 2) translate(10 10) skewX(45)");
+
+ // Set transform='rotate(90) scale(2 2) translate(10 10) skewX(45)' for circle1.
+ circle1.setAttribute('transform', 'rotate(90) scale(2 2) translate(10 10) skewX(45)');
+ assert_equals(transformList.replaceItem(transformList.getItem(0), 'aString').toString(), "type=SVG_TRANSFORM_ROTATE matrix=[0.0 1.0 -1.0 0.0 0.0 0.0]");
+ assert_equals(transformList.numberOfItems, 4);
+ assert_equals(transformList.getItem(0).toString(), "type=SVG_TRANSFORM_ROTATE matrix=[0.0 1.0 -1.0 0.0 0.0 0.0]");
+ assert_equals(transformList.getItem(1).toString(), "type=SVG_TRANSFORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
+ assert_equals(transformList.getItem(2).toString(), "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
+ assert_equals(transformList.getItem(3).toString(), "type=SVG_TRANSFORM_SKEWX matrix=[1.0 0.0 1.0 1.0 0.0 0.0]");
+ assert_equals(circle1.getAttribute('transform'), "rotate(90) scale(2 2) translate(10 10) skewX(45)");
+
+ assert_equals(transformList.replaceItem(transformList.getItem(0), circle1).toString(), "type=SVG_TRANSFORM_ROTATE matrix=[0.0 1.0 -1.0 0.0 0.0 0.0]");
+ assert_equals(transformList.numberOfItems, 4);
+ assert_equals(transformList.getItem(0).toString(), "type=SVG_TRANSFORM_ROTATE matrix=[0.0 1.0 -1.0 0.0 0.0 0.0]");
+ assert_equals(transformList.getItem(1).toString(), "type=SVG_TRANSFORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
+ assert_equals(transformList.getItem(2).toString(), "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
+ assert_equals(transformList.getItem(3).toString(), "type=SVG_TRANSFORM_SKEWX matrix=[1.0 0.0 1.0 1.0 0.0 0.0]");
+ assert_equals(circle1.getAttribute('transform'), "rotate(90) scale(2 2) translate(10 10) skewX(45)");
+
+ assert_equals(transformList.replaceItem(transformList.getItem(0), null).toString(), "type=SVG_TRANSFORM_ROTATE matrix=[0.0 1.0 -1.0 0.0 0.0 0.0]");
+ assert_equals(transformList.numberOfItems, 4);
+ assert_equals(circle1.getAttribute('transform'), "rotate(90) scale(2 2) translate(10 10) skewX(45)");
+
+ // Set transform='rotate(90) scale(2 2) translate(10 10) skewX(45)' for circle1.
+ circle1.setAttribute('transform', 'rotate(90) scale(2 2) translate(10 10) skewX(45)');
+
+ // Test uncommon arguments for removeItem().
+ assert_throws("IndexSizeError", function() { transformList.removeItem(30); });
+
+ assert_equals(transformList.removeItem(0).toString(), "type=SVG_TRANSFORM_ROTATE matrix=[0.0 1.0 -1.0 0.0 0.0 0.0]");
+ assert_equals(transformList.numberOfItems, 3);
+ assert_equals(transformList.getItem(0).toString(), "type=SVG_TRANSFORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
+ assert_equals(transformList.getItem(1).toString(), "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
+ assert_equals(transformList.getItem(2).toString(), "type=SVG_TRANSFORM_SKEWX matrix=[1.0 0.0 1.0 1.0 0.0 0.0]");
+ assert_equals(circle1.getAttribute('transform'), "scale(2 2) translate(10 10) skewX(45)");
+
+ assert_equals(transformList.removeItem('aString').toString(), "type=SVG_TRANSFORM_SCALE matrix=[2.0 0.0 0.0 2.0 0.0 0.0]");
+ assert_equals(transformList.numberOfItems, 2);
+ assert_equals(transformList.getItem(0).toString(), "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
+ assert_equals(transformList.getItem(1).toString(), "type=SVG_TRANSFORM_SKEWX matrix=[1.0 0.0 1.0 1.0 0.0 0.0]");
+ assert_equals(circle1.getAttribute('transform'), "translate(10 10) skewX(45)");
+
+ assert_equals(transformList.removeItem(circle1).toString(), "type=SVG_TRANSFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 10.0 10.0]");
+ assert_equals(transformList.numberOfItems, 1);
+ assert_equals(transformList.getItem(0).toString(), "type=SVG_TRANSFORM_SKEWX matrix=[1.0 0.0 1.0 1.0 0.0 0.0]");
+ assert_equals(circle1.getAttribute('transform'), "skewX(45)");
+
+ // Test uncommon arguments for appendItem().
+ assert_throws(new TypeError(), function() { transformList.appendItem(30); });
+ assert_throws(new TypeError(), function() { transformList.appendItem('aString'); });
+ assert_throws(new TypeError(), function() { transformList.appendItem(circle1); });
+ assert_throws(new TypeError(), function() { transformList.appendItem(null); });
+
+ // Testing animVal clear throws.
+ assert_throws("NoModificationAllowedError", function() { circle1.transform.animVal.clear(); });
+ transformList.clear();
+
+ // Creating new SVGTransform, with 45 deg rotation about x=50, y=100 and append it to the transform list.
+ var transform = svg.createSVGTransform();
+ assert_equals(transform.toString(), "type=SVG_TRANSFORM_MATRIX matrix=[1.0 0.0 0.0 1.0 0.0 0.0]");
+ transform.setRotate(45, 50, 100);
+
+ assert_equals(transformList.appendItem(transform).toString(), "type=SVG_TRANSFORM_ROTATE matrix=[0.7 0.7 -0.7 0.7 85.4 -6.1]");
+ assert_equals(transformList.numberOfItems, 1);
+ assert_equals(transformList.getItem(0).toString(), "type=SVG_TRANSFORM_ROTATE matrix=[0.7 0.7 -0.7 0.7 85.4 -6.1]");
+ assert_equals(circle1.getAttribute('transform'), "rotate(45 50 100)");
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698