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

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

Issue 2867883003: [CSS Typed OM] Delete obsolete number and length classes from Typed OM (Closed)
Patch Set: rebase Created 3 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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script> 2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script> 3 <script src="../resources/testharnessreport.js"></script>
4 4
5 <script> 5 <script>
6 var EPSILON = 1e-6; // float epsilon 6 var EPSILON = 1e-6; // float epsilon
7 7
8 function angle(deg) { return new CSSAngleValue(deg, 'deg'); } 8 function angle(deg) { return new CSSUnitValue(deg, 'deg'); }
9 9
10 function tanDegrees(degrees) { 10 function tanDegrees(degrees) {
11 var radians = degrees * Math.PI / 180; 11 var radians = degrees * Math.PI / 180;
12 return Math.tan(radians); 12 return Math.tan(radians);
13 } 13 }
14 14
15 var values = [ 15 var values = [
16 {input: new CSSSkew(angle(0), angle(0)), ax: 0, ay: 0, cssText: "skew(0deg, 0d eg)"}, 16 {input: new CSSSkew(angle(0), angle(0)), ax: 0, ay: 0, cssText: "skew(0deg, 0d eg)"},
17 {input: new CSSSkew(angle(1), angle(2)), ax: 1, ay: 2, cssText: "skew(1deg, 2d eg)"}, 17 {input: new CSSSkew(angle(1), angle(2)), ax: 1, ay: 2, cssText: "skew(1deg, 2d eg)"},
18 {input: new CSSSkew(angle(-2), angle(-4)), ax: -2, ay: -4, cssText: "skew(-2de g, -4deg)"}, 18 {input: new CSSSkew(angle(-2), angle(-4)), ax: -2, ay: -4, cssText: "skew(-2de g, -4deg)"},
19 {input: new CSSSkew(angle(3.4), angle(2.7)), ax: 3.4, ay: 2.7, cssText: "skew( 3.4deg, 2.7deg)"}, 19 {input: new CSSSkew(angle(3.4), angle(2.7)), ax: 3.4, ay: 2.7, cssText: "skew( 3.4deg, 2.7deg)"},
20 {input: new CSSSkew(new CSSAngleValue(1, 'rad'), angle(0)), ax: 57.2957795, ay : 0, cssText: "skew(1rad, 0deg)"}, 20 {input: new CSSSkew(new CSSUnitValue(1, 'rad'), angle(0)), ax: 57.2957795, ay: 0, cssText: "skew(1rad, 0deg)"},
21 {input: new CSSSkew(angle(0), new CSSAngleValue(1, 'rad')), ax: 0, ay: 57.2957 795, cssText: "skew(0deg, 1rad)"} 21 {input: new CSSSkew(angle(0), new CSSUnitValue(1, 'rad')), ax: 0, ay: 57.29577 95, cssText: "skew(0deg, 1rad)"}
22 ]; 22 ];
23 23
24 test(function() { 24 test(function() {
25 for (var i = 0; i < values.length; ++i) { 25 for (var i = 0; i < values.length; ++i) {
26 assert_approx_equals(values[i].input.ax.degrees, values[i].ax, EPSILON); 26 assert_approx_equals(values[i].input.ax.degrees, values[i].ax, EPSILON);
27 assert_approx_equals(values[i].input.ay.degrees, values[i].ay, EPSILON); 27 assert_approx_equals(values[i].input.ay.degrees, values[i].ay, EPSILON);
28 } 28 }
29 }, "(ax, ay) values for CSSSkew are correct."); 29 }, "(ax, ay) values for CSSSkew are correct.");
30 30
31 test(function() { 31 test(function() {
32 for (var i = 0; i < values.length; ++i) { 32 for (var i = 0; i < values.length; ++i) {
33 assert_true(values[i].input.is2D()); 33 assert_true(values[i].input.is2D());
34 } 34 }
35 }, "is2D values for CSSSkew are correct."); 35 }, "is2D values for CSSSkew are correct.");
36 36
37 test(function() { 37 test(function() {
38 for (var i = 0; i < values.length; ++i) { 38 for (var i = 0; i < values.length; ++i) {
39 assert_equals(values[i].input.toString(), values[i].cssText); 39 assert_equals(values[i].input.toString(), values[i].cssText);
40 } 40 }
41 }, "toString() for CSSSkew is correct."); 41 }, "toString() for CSSSkew is correct.");
42 42
43 test(function() { 43 test(function() {
44 assert_throws(null, function() { new CSSSkew(); }); 44 assert_throws(new TypeError(), function() { new CSSSkew(); });
45 assert_throws(null, function() { new CSSSkew(null); }); 45 assert_throws(new TypeError(), function() { new CSSSkew(null); });
46 assert_throws(null, function() { new CSSSkew(1); }); 46 assert_throws(new TypeError(), function() { new CSSSkew(1); });
47 assert_throws(null, function() { new CSSSkew('1'); }); 47 assert_throws(new TypeError(), function() { new CSSSkew('1'); });
48 assert_throws(null, function() { new CSSSkew(angle(1)); }); 48 assert_throws(new TypeError(), function() { new CSSSkew(angle(1)); });
49 }, "Invalid arguments for CSSSkew throws an exception."); 49 }, "Invalid arguments for CSSSkew throws an exception.");
50 50
51 test(function() { 51 test(function() {
52 for (var i = 0; i < values.length; ++i) { 52 for (var i = 0; i < values.length; ++i) {
53 var input = values[i].input; 53 var input = values[i].input;
54 var inputAsMatrix = input.asMatrix(); 54 var inputAsMatrix = input.asMatrix();
55 assert_true(inputAsMatrix.is2D()); 55 assert_true(inputAsMatrix.is2D());
56 var tanAx = tanDegrees(input.ax.degrees); 56 var tanAx = tanDegrees(input.ax.degrees);
57 var tanAy = tanDegrees(input.ay.degrees); 57 var tanAy = tanDegrees(input.ay.degrees);
58 var expectedMatrix = new CSSMatrixComponent(new DOMMatrixReadOnly([1, tanAy, tanAx, 1, 0, 0])); 58 var expectedMatrix = new CSSMatrixComponent(new DOMMatrixReadOnly([1, tanAy, tanAx, 1, 0, 0]));
(...skipping 11 matching lines...) Expand all
70 for (var i = 0; i < actual.length; i++) { 70 for (var i = 0; i < actual.length; i++) {
71 assert_approx_equals(actual[i], expected[i], EPSILON); 71 assert_approx_equals(actual[i], expected[i], EPSILON);
72 } 72 }
73 } 73 }
74 74
75 function assert_matrix_approx_equals(actual, expected) { 75 function assert_matrix_approx_equals(actual, expected) {
76 assert_array_approx_equals(actual.toFloat64Array(), expected.toFloat64Array()) ; 76 assert_array_approx_equals(actual.toFloat64Array(), expected.toFloat64Array()) ;
77 } 77 }
78 78
79 </script> 79 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698