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

Unified Diff: third_party/WebKit/LayoutTests/typedcssom/cssScale.html

Issue 2010383002: Typed CSSOM: Rename Scale and ScaleTransformComponent to CSSScale (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 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/typedcssom/scaleTransformComponent.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/typedcssom/cssScale.html
diff --git a/third_party/WebKit/LayoutTests/typedcssom/cssScale.html b/third_party/WebKit/LayoutTests/typedcssom/cssScale.html
new file mode 100644
index 0000000000000000000000000000000000000000..602504b6820ffbff26e243e96ec51cb9f5b51567
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/typedcssom/cssScale.html
@@ -0,0 +1,94 @@
+<!DOCTYPE html>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+
+<script>
+var EPSILON = 1e-6; // float epsilon
+var values = [
+ {input: new CSSScale(0, 0), x: 0, y: 0, z: 1, is2DComponent: true,
+ cssString: "scale(0, 0)"},
+ {input: new CSSScale(1, 2), x: 1, y: 2, z: 1, is2DComponent: true,
+ cssString: "scale(1, 2)"},
+ {input: new CSSScale(-2, -4), x: -2, y: -4, z: 1, is2DComponent: true,
+ cssString: "scale(-2, -4)"},
+ {input: new CSSScale(3.4, 2.7), x: 3.4, y: 2.7, z: 1, is2DComponent: true,
+ cssString: "scale(3.4, 2.7)"},
+ {input: new CSSScale(0, 0, 0), x: 0, y: 0, z: 0, is2DComponent: false,
+ cssString: "scale3d(0, 0, 0)"},
+ {input: new CSSScale(1, 2, 3), x: 1, y: 2, z: 3, is2DComponent: false,
+ cssString: "scale3d(1, 2, 3)"},
+ {input: new CSSScale(3.5, -2.7, -2), x: 3.5, y: -2.7, z: -2, is2DComponent: false,
+ cssString: "scale3d(3.5, -2.7, -2)"}
+];
+
+test(function() {
+ for (var i = 0; i < values.length; ++i) {
+ assert_equals(values[i].input.x, values[i].x);
+ assert_equals(values[i].input.y, values[i].y);
+ assert_equals(values[i].input.z, values[i].z);
+ }
+}, "Test that the (x, y, z) values for CSSScale are correct.");
+
+test(function() {
+ for (var i = 0; i < values.length; ++i) {
+ assert_equals(values[i].input.is2DComponent(), values[i].is2DComponent);
+ }
+}, "Test that the is2DComponent values for CSSScale is correct.");
+
+test(function() {
+ for (var i = 0; i < values.length; ++i) {
+ assert_equals(values[i].input.cssString, values[i].cssString);
+ }
+}, "Test that the cssString for CSSScale is correct.");
+
+test(function() {
+ assert_throws(null, () => { new CSSScale(); });
+ assert_throws(null, () => { new CSSScale(1); });
+}, "Test that invalid number of arguments for CSSScale throws an exception.");
+
+test(function() {
+ assert_throws(null, () => { new CSSScale(NaN, 0); });
+ assert_throws(null, () => { new CSSScale(0, NaN); });
+ assert_throws(null, () => { new CSSScale(NaN, NaN); });
+ assert_throws(null, () => { new CSSScale(Infinity, 0); });
+ assert_throws(null, () => { new CSSScale(-Infinity, 0); });
+ assert_throws(null, () => { new CSSScale("hello", 0); });
+ assert_throws(null, () => { new CSSScale(0, "world"); });
+ assert_throws(null, () => { new CSSScale(undefined, 0); });
+ assert_throws(null, () => { new CSSScale({}, {}); });
+
+ assert_throws(null, () => { new CSSScale("hello", 0, 0); });
+ assert_throws(null, () => { new CSSScale(0, NaN, 0); });
+ assert_throws(null, () => { new CSSScale(0, Infinity, 0); });
+ assert_throws(null, () => { new CSSScale(0, 0, NaN); });
+ assert_throws(null, () => { new CSSScale(0, 0, Infinity); });
+ assert_throws(null, () => { new CSSScale(0, 0, -Infinity); });
+ assert_throws(null, () => { new CSSScale(0, 0, undefined); });
+ assert_throws(null, () => { new CSSScale(undefined, undefined, 0); });
+ assert_throws(null, () => { new CSSScale(NaN, undefined, 0); });
+ assert_throws(null, () => { new CSSScale(NaN, 0, NaN); });
+ assert_throws(null, () => { new CSSScale(0, "hello", "world"); });
+ assert_throws(null, () => { new CSSScale(0, {}, {}); });
+ assert_throws(null, () => { new CSSScale({}, {}, {}); });
+ assert_throws(null, () => { new CSSScale(NaN, NaN, NaN); });
+}, "Test that invalid input throws an exception.");
+
+test(function() {
+ for (var i = 0; i < values.length; ++i) {
+ var input = values[i].input;
+ var inputAsMatrix = input.asMatrix();
+ assert_equals(inputAsMatrix.is2DComponent(), input.is2DComponent());
+
+ var expectedMatrix = input.is2DComponent() ? new Matrix(input.x, 0, 0, input.y, 0, 0) :
+ new Matrix(input.x, 0, 0, 0, 0, input.y, 0, 0, 0, 0, input.z, 0, 0, 0, 0, 1);
+ for (var attribute in expectedMatrix) {
+ if (typeof expectedMatrix[attribute] === "number") {
+ assert_approx_equals(inputAsMatrix[attribute], expectedMatrix[attribute], EPSILON);
+ } else {
+ assert_equals(inputAsMatrix[attribute], expectedMatrix[attribute]);
+ }
+ }
+ }
+}, "Test that asMatrix is constructed correctly for CSSScale.");
+
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/typedcssom/scaleTransformComponent.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698