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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-readonly.html

Issue 2309013002: [GeometryInterface] Add fromFloat32Array & fromFloat64Array function (Closed)
Patch Set: [GeometryInterface] Add fromFloat32Array & fromFloat64Array function 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE HTML> 1 <!DOCTYPE HTML>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Geometry Interfaces: DOMMatrixReadOnly</title> 4 <title>Geometry Interfaces: DOMMatrixReadOnly</title>
5 <script src="../../resources/testharness.js"></script> 5 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script> 6 <script src="../../resources/testharnessreport.js"></script>
7 </head> 7 </head>
8 <body> 8 <body>
9 <script> 9 <script>
10 test(function() { 10 test(function() {
(...skipping 22 matching lines...) Expand all
33 assert_equals(matrix3d.m32, 10.1); 33 assert_equals(matrix3d.m32, 10.1);
34 assert_equals(matrix3d.m33, 11); 34 assert_equals(matrix3d.m33, 11);
35 assert_equals(matrix3d.m34, 12); 35 assert_equals(matrix3d.m34, 12);
36 assert_equals(matrix3d.m41, 13); 36 assert_equals(matrix3d.m41, 13);
37 assert_equals(matrix3d.m42, 14); 37 assert_equals(matrix3d.m42, 14);
38 assert_equals(matrix3d.m43, 15); 38 assert_equals(matrix3d.m43, 15);
39 assert_equals(matrix3d.m44, 16.6); 39 assert_equals(matrix3d.m44, 16.6);
40 }, "DOMMatrixReadOnly constructor - 3D matrix"); 40 }, "DOMMatrixReadOnly constructor - 3D matrix");
41 41
42 test(function() { 42 test(function() {
43 var float32Array = new Float32Array([1, 2, 3, 4, 5, 6]);
44 var matrix2d = DOMMatrixReadOnly.fromFloat32Array(float32Array);
45 assert_true(matrix2d.is2D);
46 assert_equals(matrix2d.a, 1);
47 assert_equals(matrix2d.b, 2);
48 assert_equals(matrix2d.c, 3);
49 assert_equals(matrix2d.d, 4);
50 assert_equals(matrix2d.e, 5);
51 assert_equals(matrix2d.f, 6);
52 }, "DOMMatrixReadOnly fromFloat32Array - 2D matrix");
53
54 test(function() {
55 // 3.1 is not representable as a 32-bit float
56 var float64Array = new Float64Array([1, 2, 3, 3.1, 4, 5]);
57 var matrix2d = DOMMatrixReadOnly.fromFloat64Array(float64Array);
58 assert_true(matrix2d.is2D);
59 assert_equals(matrix2d.a, 1);
60 assert_equals(matrix2d.b, 2);
61 assert_equals(matrix2d.c, 3);
62 assert_equals(matrix2d.d, 3.1);
63 assert_equals(matrix2d.e, 4);
64 assert_equals(matrix2d.f, 5);
65 }, "DOMMatrixReadOnly fromFloat64Array - 2D matrix");
66
67 test(function() {
68 var float32Array = new Float32Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
69 var matrix3d = DOMMatrixReadOnly.fromFloat32Array(float32Array);
70 assert_false(matrix3d.is2D);
71 assert_equals(matrix3d.m11, 1);
72 assert_equals(matrix3d.m12, 2);
73 assert_equals(matrix3d.m13, 3);
74 assert_equals(matrix3d.m14, 4);
75 assert_equals(matrix3d.m21, 5);
76 assert_equals(matrix3d.m22, 6);
77 assert_equals(matrix3d.m23, 7);
78 assert_equals(matrix3d.m24, 8);
79 assert_equals(matrix3d.m31, 9);
80 assert_equals(matrix3d.m32, 10);
81 assert_equals(matrix3d.m33, 11);
82 assert_equals(matrix3d.m34, 12);
83 assert_equals(matrix3d.m41, 13);
84 assert_equals(matrix3d.m42, 14);
85 assert_equals(matrix3d.m43, 15);
86 assert_equals(matrix3d.m44, 16);
87 }, "DOMMatrixReadOnly fromFloat32Array - 3D matrix");
88
89 test(function() {
90 // 10.1 and 16.6 are not representable as a 32-bit float
91 var float64Array = new Float64Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12 , 13, 14, 15, 16.6]);
92 var matrix3d = DOMMatrixReadOnly.fromFloat64Array(float64Array);
93 assert_false(matrix3d.is2D);
94 assert_equals(matrix3d.m11, 1);
95 assert_equals(matrix3d.m12, 2);
96 assert_equals(matrix3d.m13, 3);
97 assert_equals(matrix3d.m14, 4);
98 assert_equals(matrix3d.m21, 5);
99 assert_equals(matrix3d.m22, 6);
100 assert_equals(matrix3d.m23, 7);
101 assert_equals(matrix3d.m24, 8);
102 assert_equals(matrix3d.m31, 9);
103 assert_equals(matrix3d.m32, 10.1);
104 assert_equals(matrix3d.m33, 11);
105 assert_equals(matrix3d.m34, 12);
106 assert_equals(matrix3d.m41, 13);
107 assert_equals(matrix3d.m42, 14);
108 assert_equals(matrix3d.m43, 15);
109 assert_equals(matrix3d.m44, 16.6);
110 }, "DOMMatrixReadOnly fromFloat64Array - 3D matrix");
111
112 test(function() {
43 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 3.1, 2, 1]); 113 var matrix2d = new DOMMatrixReadOnly([1, 2, 3, 3.1, 2, 1]);
44 assert_true(matrix2d.is2D); 114 assert_true(matrix2d.is2D);
45 assert_equals(matrix2d.toString(), "matrix(1, 2, 3, 3.1, 2, 1)"); 115 assert_equals(matrix2d.toString(), "matrix(1, 2, 3, 3.1, 2, 1)");
46 }, "DOMMatrixReadOnly toString() - 2D matrix"); 116 }, "DOMMatrixReadOnly toString() - 2D matrix");
47 117
48 test(function() { 118 test(function() {
49 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 1 2, 13, 14, 15, 16.6]); 119 var matrix3d = new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 1 2, 13, 14, 15, 16.6]);
50 assert_false(matrix3d.is2D); 120 assert_false(matrix3d.is2D);
51 assert_equals(matrix3d.toString(), "matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1 , 11, 12, 13, 14, 15, 16.6)"); 121 assert_equals(matrix3d.toString(), "matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1 , 11, 12, 13, 14, 15, 16.6)");
52 }, "DOMMatrixReadOnly toString() - 3D matrix"); 122 }, "DOMMatrixReadOnly toString() - 3D matrix");
53 123
54 test(function() { 124 test(function() {
55 assert_throws(new TypeError(), function() { new DOMMatrixReadOnly(1, 2, 3, 4 , 5, 6); }, 125 assert_throws(new TypeError(), function() { new DOMMatrixReadOnly(1, 2, 3, 4 , 5, 6); },
56 "DOMMatrixReadOnly constructor only accepts 1 argument"); 126 "DOMMatrixReadOnly constructor only accepts 1 argument");
57 assert_throws(new TypeError(), function() { new DOMMatrixReadOnly("myString" ); }, 127 assert_throws(new TypeError(), function() { new DOMMatrixReadOnly("myString" ); },
58 "DOMMatrixReadOnly constructor only accepts 1 number sequence"); 128 "DOMMatrixReadOnly constructor only accepts 1 number sequence");
59 assert_throws(new TypeError(), function() { new DOMMatrixReadOnly([1, 2, 3]) ; }, 129 assert_throws(new TypeError(), function() { new DOMMatrixReadOnly([1, 2, 3]) ; },
60 "DOMMatrixReadOnly constructor only accepts 1 number sequence with 6 or 16 elements."); 130 "DOMMatrixReadOnly constructor only accepts 1 number sequence with 6 or 16 elements.");
61 }, "DOMMatrixReadOnly constructor - invalid arguments"); 131 }, "DOMMatrixReadOnly constructor - invalid arguments");
132
133 test(function() {
134 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat32Arr ay(new Float32Array([1, 2, 3, 4, 5])); },
135 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16 elements.");
136 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat64Arr ay(new Float64Array([1, 2, 3, 4, 5])); },
137 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements.");
138 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat32Arr ay(new Float32Array([1, 2, 3, 4, 5, 6 ,7])); },
139 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16 elements.");
140 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat64Arr ay(new Float64Array([1, 2, 3, 4, 5, 6 ,7])); },
141 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements.");
142 }, "DOMMatrixReadOnly fromFloat*Array - invalid array size of nearby 6");
143
144 test(function() {
145 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat32Arr ay(new Float32Array([1, 2, 3, 4, 5, 6 ,7, 8, 9, 10, 11, 12, 13, 14, 15])); },
146 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16 elements.");
147 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat64Arr ay(new Float64Array([1, 2, 3, 4, 5, 6 ,7, 8, 9, 10, 11, 12, 13, 14, 15])); },
148 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements.");
149 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat32Arr ay(new Float32Array([1, 2, 3, 4, 5, 6 ,7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) ); },
150 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16 elements.");
151 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat64Arr ay(new Float64Array([1, 2, 3, 4, 5, 6 ,7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) ); },
152 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements.");
153 }, "DOMMatrixReadOnly fromFloat*Array - invalid array size of nearby 16");
154
155 test(function() {
156 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat32Arr ay(new Float32Array([])); },
157 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16 elements.");
158 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat64Arr ay(new Float64Array([])); },
159 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements.");
160 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat32Arr ay(new Float32Array([1])); },
161 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16 elements.");
162 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat64Arr ay(new Float64Array([1])); },
163 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements.");
164 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat32Arr ay(new Float32Array(65536)); },
165 "fromFloat32Array function only accepts 1 Float32Array with 6 or 16 elements.");
166 assert_throws(new TypeError(), function() { DOMMatrixReadOnly.fromFloat64Arr ay(new Float64Array(65536)); },
167 "fromFloat64Array function only accepts 1 Float64Array with 6 or 16 elements.");
168 }, "DOMMatrixReadOnly fromFloat*Array - invalid array size");
169
62 </script> 170 </script>
63 </body> 171 </body>
64 </html> 172 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698