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

Side by Side Diff: third_party/WebKit/LayoutTests/typedcssom/skewTransformComponent.html

Issue 2018313003: Typed CSSOM: Rename Skew and SkewTransformComponent to CSSSkew (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4
5 <script>
6 var EPSILON = 1e-6; // float epsilon
7 var values = [
8 {input: new Skew(0, 0), ax: 0, ay: 0, cssString: "skew(0, 0)"},
9 {input: new Skew(1, 2), ax: 1, ay: 2, cssString: "skew(1, 2)"},
10 {input: new Skew(-2, -4), ax: -2, ay: -4, cssString: "skew(-2, -4)"},
11 {input: new Skew(3.4, 2.7), ax: 3.4, ay: 2.7, cssString: "skew(3.4, 2.7)"}
12 ];
13
14 test(function() {
15 for (var i = 0; i < values.length; ++i) {
16 assert_equals(values[i].input.ax, values[i].ax);
17 assert_equals(values[i].input.ay, values[i].ay);
18 }
19 }, "Test that the (ax, ay) values for Skew are correct.");
20
21 test(function() {
22 for (var i = 0; i < values.length; ++i) {
23 assert_true(values[i].input.is2DComponent());
24 }
25 }, "Test that the is2DComponent values for Skew is correct.");
26
27 test(function() {
28 for (var i = 0; i < values.length; ++i) {
29 assert_equals(values[i].input.cssString, values[i].cssString);
30 }
31 }, "Test that the cssString for Skew is correct.");
32
33 test(function() {
34 assert_throws(null, function() { new Skew(); });
35 assert_throws(null, function() { new Skew(1); });
36 }, "Test that invalid number of arguments for Skew throws an exception.");
37
38 function tanDegrees(degrees) {
39 var radians = degrees * Math.PI / 180;
40 return Math.tan(radians);
41 }
42
43 test(function() {
44 for (var i = 0; i < values.length; ++i) {
45 var input = values[i].input;
46 var inputAsMatrix = input.asMatrix();
47 assert_true(inputAsMatrix.is2DComponent());
48 var tanAx = tanDegrees(input.ax);
49 var tanAy = tanDegrees(input.ay);
50 var expectedMatrix = new Matrix(1, tanAy, tanAx, 1, 0, 0);
51 for (var attribute in expectedMatrix) {
52 if (typeof expectedMatrix[attribute] === "number") {
53 assert_approx_equals(inputAsMatrix[attribute], expectedMatrix[attribute] , EPSILON);
54 } else {
55 assert_equals(inputAsMatrix[attribute], expectedMatrix[attribute]);
56 }
57 }
58 }
59 }, "Test that asMatrix is constructed correctly for Skew.");
60
61 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698