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

Side by Side Diff: test/codegen/expect/lib/html/canvasrenderingcontext2d_test.js

Issue 2128353002: Check in codegen test expectations. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « test/codegen/expect/lib/html/canvas_test.js ('k') | test/codegen/expect/lib/html/cdata_test.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 dart_library.library('lib/html/canvasrenderingcontext2d_test', null, /* Imports */[
2 'dart_sdk',
3 'unittest'
4 ], function load__canvasrenderingcontext2d_test(exports, dart_sdk, unittest) {
5 'use strict';
6 const core = dart_sdk.core;
7 const html = dart_sdk.html;
8 const _interceptors = dart_sdk._interceptors;
9 const math = dart_sdk.math;
10 const dart = dart_sdk.dart;
11 const dartx = dart_sdk.dartx;
12 const src__matcher__expect = unittest.src__matcher__expect;
13 const src__matcher__numeric_matchers = unittest.src__matcher__numeric_matchers ;
14 const html_individual_config = unittest.html_individual_config;
15 const unittest$ = unittest.unittest;
16 const src__matcher__core_matchers = unittest.src__matcher__core_matchers;
17 const src__matcher__throws_matcher = unittest.src__matcher__throws_matcher;
18 const canvasrenderingcontext2d_test = Object.create(null);
19 let ListOfint = () => (ListOfint = dart.constFn(core.List$(core.int)))();
20 let JSArrayOfint = () => (JSArrayOfint = dart.constFn(_interceptors.JSArray$(c ore.int)))();
21 let EventTovoid = () => (EventTovoid = dart.constFn(dart.functionType(dart.voi d, [html.Event])))();
22 let RectangleOfnum = () => (RectangleOfnum = dart.constFn(math.Rectangle$(core .num)))();
23 let ListOfintAndListOfintTodynamic = () => (ListOfintAndListOfintTodynamic = d art.constFn(dart.definiteFunctionType(dart.dynamic, [ListOfint(), ListOfint()])) )();
24 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(da rt.void, [])))();
25 let intAndintToListOfint = () => (intAndintToListOfint = dart.constFn(dart.def initeFunctionType(ListOfint(), [core.int, core.int])))();
26 let intTobool = () => (intTobool = dart.constFn(dart.definiteFunctionType(core .bool, [core.int])))();
27 let intAndintTobool = () => (intAndintTobool = dart.constFn(dart.definiteFunct ionType(core.bool, [core.int, core.int])))();
28 let ListOfintAndintAndintToString = () => (ListOfintAndintAndintToString = dar t.constFn(dart.definiteFunctionType(core.String, [ListOfint(), core.int, core.in t])))();
29 let boolToString = () => (boolToString = dart.constFn(dart.definiteFunctionTyp e(core.String, [core.bool])))();
30 let intAndint__Tovoid = () => (intAndint__Tovoid = dart.constFn(dart.definiteF unctionType(dart.void, [core.int, core.int], [core.bool])))();
31 let intAndintTovoid = () => (intAndintTovoid = dart.constFn(dart.definiteFunct ionType(dart.void, [core.int, core.int])))();
32 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT ype(dart.dynamic, [])))();
33 let dynamicTodynamic = () => (dynamicTodynamic = dart.constFn(dart.definiteFun ctionType(dart.dynamic, [dart.dynamic])))();
34 let EventTovoid$ = () => (EventTovoid$ = dart.constFn(dart.definiteFunctionTyp e(dart.void, [html.Event])))();
35 canvasrenderingcontext2d_test.checkPixel = function(pixel, expected) {
36 src__matcher__expect.expect(pixel[dartx.get](0), src__matcher__numeric_match ers.closeTo(expected[dartx.get](0), 2));
37 src__matcher__expect.expect(pixel[dartx.get](1), src__matcher__numeric_match ers.closeTo(expected[dartx.get](1), 2));
38 src__matcher__expect.expect(pixel[dartx.get](2), src__matcher__numeric_match ers.closeTo(expected[dartx.get](2), 2));
39 src__matcher__expect.expect(pixel[dartx.get](3), src__matcher__numeric_match ers.closeTo(expected[dartx.get](3), 2));
40 };
41 dart.fn(canvasrenderingcontext2d_test.checkPixel, ListOfintAndListOfintTodynam ic());
42 canvasrenderingcontext2d_test.canvas = null;
43 canvasrenderingcontext2d_test.context = null;
44 canvasrenderingcontext2d_test.otherCanvas = null;
45 canvasrenderingcontext2d_test.otherContext = null;
46 canvasrenderingcontext2d_test.video = null;
47 canvasrenderingcontext2d_test.createCanvas = function() {
48 canvasrenderingcontext2d_test.canvas = html.CanvasElement.new();
49 dart.dput(canvasrenderingcontext2d_test.canvas, 'width', 100);
50 dart.dput(canvasrenderingcontext2d_test.canvas, 'height', 100);
51 canvasrenderingcontext2d_test.context = dart.dload(canvasrenderingcontext2d_ test.canvas, 'context2D');
52 };
53 dart.fn(canvasrenderingcontext2d_test.createCanvas, VoidTovoid());
54 canvasrenderingcontext2d_test.createOtherCanvas = function() {
55 canvasrenderingcontext2d_test.otherCanvas = html.CanvasElement.new();
56 dart.dput(canvasrenderingcontext2d_test.otherCanvas, 'width', 10);
57 dart.dput(canvasrenderingcontext2d_test.otherCanvas, 'height', 10);
58 canvasrenderingcontext2d_test.otherContext = dart.dload(canvasrenderingconte xt2d_test.otherCanvas, 'context2D');
59 dart.dput(canvasrenderingcontext2d_test.otherContext, 'fillStyle', "red");
60 dart.dsend(canvasrenderingcontext2d_test.otherContext, 'fillRect', 0, 0, dar t.dload(canvasrenderingcontext2d_test.otherCanvas, 'width'), dart.dload(canvasre nderingcontext2d_test.otherCanvas, 'height'));
61 };
62 dart.fn(canvasrenderingcontext2d_test.createOtherCanvas, VoidTovoid());
63 canvasrenderingcontext2d_test.setupFunc = function() {
64 canvasrenderingcontext2d_test.createCanvas();
65 canvasrenderingcontext2d_test.createOtherCanvas();
66 canvasrenderingcontext2d_test.video = html.VideoElement.new();
67 };
68 dart.fn(canvasrenderingcontext2d_test.setupFunc, VoidTovoid());
69 canvasrenderingcontext2d_test.tearDownFunc = function() {
70 canvasrenderingcontext2d_test.canvas = null;
71 canvasrenderingcontext2d_test.context = null;
72 canvasrenderingcontext2d_test.otherCanvas = null;
73 canvasrenderingcontext2d_test.otherContext = null;
74 canvasrenderingcontext2d_test.video = null;
75 };
76 dart.fn(canvasrenderingcontext2d_test.tearDownFunc, VoidTovoid());
77 canvasrenderingcontext2d_test.readPixel = function(x, y) {
78 let imageData = dart.dsend(canvasrenderingcontext2d_test.context, 'getImageD ata', x, y, 1, 1);
79 return ListOfint()._check(dart.dload(imageData, 'data'));
80 };
81 dart.fn(canvasrenderingcontext2d_test.readPixel, intAndintToListOfint());
82 canvasrenderingcontext2d_test.isPixelFilled = function(x, y) {
83 return canvasrenderingcontext2d_test.readPixel(x, y)[dartx.any](dart.fn(p => p != 0, intTobool()));
84 };
85 dart.fn(canvasrenderingcontext2d_test.isPixelFilled, intAndintTobool());
86 canvasrenderingcontext2d_test.pixelDataToString = function(data, x, y) {
87 return dart.str`[${data[dartx.join](", ")}]`;
88 };
89 dart.fn(canvasrenderingcontext2d_test.pixelDataToString, ListOfintAndintAndint ToString());
90 canvasrenderingcontext2d_test._filled = function(v) {
91 return dart.test(v) ? "filled" : "unfilled";
92 };
93 dart.fn(canvasrenderingcontext2d_test._filled, boolToString());
94 canvasrenderingcontext2d_test.expectPixelFilled = function(x, y, filled) {
95 if (filled === void 0) filled = true;
96 src__matcher__expect.expect(canvasrenderingcontext2d_test.isPixelFilled(x, y ), filled, {reason: dart.str`Pixel at (${x}, ${y}) was expected to` + dart.str` be: <${canvasrenderingcontext2d_test._filled(filled)}> but was: <${canvasrenderi ngcontext2d_test._filled(!dart.test(filled))}> with data: ` + dart.str`${canvasr enderingcontext2d_test.pixelDataToString(canvasrenderingcontext2d_test.readPixel (x, y), x, y)}`});
97 };
98 dart.fn(canvasrenderingcontext2d_test.expectPixelFilled, intAndint__Tovoid());
99 canvasrenderingcontext2d_test.expectPixelUnfilled = function(x, y) {
100 canvasrenderingcontext2d_test.expectPixelFilled(x, y, false);
101 };
102 dart.fn(canvasrenderingcontext2d_test.expectPixelUnfilled, intAndintTovoid());
103 canvasrenderingcontext2d_test.main = function() {
104 html_individual_config.useHtmlIndividualConfiguration();
105 unittest$.group('pixel_manipulation', dart.fn(() => {
106 unittest$.setUp(canvasrenderingcontext2d_test.setupFunc);
107 unittest$.tearDown(canvasrenderingcontext2d_test.tearDownFunc);
108 unittest$.test('setFillColorRgb', dart.fn(() => {
109 dart.dsend(canvasrenderingcontext2d_test.context, 'setFillColorRgb', 255 , 0, 255, 1);
110 dart.dsend(canvasrenderingcontext2d_test.context, 'fillRect', 0, 0, dart .dload(canvasrenderingcontext2d_test.canvas, 'width'), dart.dload(canvasrenderin gcontext2d_test.canvas, 'height'));
111 src__matcher__expect.expect(canvasrenderingcontext2d_test.readPixel(2, 2 ), JSArrayOfint().of([255, 0, 255, 255]));
112 }, VoidTodynamic()));
113 unittest$.test('setFillColorHsl hue', dart.fn(() => {
114 dart.dsend(canvasrenderingcontext2d_test.context, 'setFillColorHsl', 0, 100, 50);
115 dart.dsend(canvasrenderingcontext2d_test.context, 'fillRect', 0, 0, dart .dload(canvasrenderingcontext2d_test.canvas, 'width'), dart.dload(canvasrenderin gcontext2d_test.canvas, 'height'));
116 canvasrenderingcontext2d_test.checkPixel(canvasrenderingcontext2d_test.r eadPixel(2, 2), JSArrayOfint().of([255, 0, 0, 255]));
117 }, VoidTodynamic()));
118 unittest$.test('setFillColorHsl hue 2', dart.fn(() => {
119 dart.dsend(canvasrenderingcontext2d_test.context, 'setFillColorHsl', 240 , 100, 50);
120 dart.dsend(canvasrenderingcontext2d_test.context, 'fillRect', 0, 0, dart .dload(canvasrenderingcontext2d_test.canvas, 'width'), dart.dload(canvasrenderin gcontext2d_test.canvas, 'height'));
121 canvasrenderingcontext2d_test.checkPixel(canvasrenderingcontext2d_test.r eadPixel(2, 2), JSArrayOfint().of([0, 0, 255, 255]));
122 }, VoidTodynamic()));
123 unittest$.test('setFillColorHsl sat', dart.fn(() => {
124 dart.dsend(canvasrenderingcontext2d_test.context, 'setFillColorHsl', 0, 0, 50);
125 dart.dsend(canvasrenderingcontext2d_test.context, 'fillRect', 0, 0, dart .dload(canvasrenderingcontext2d_test.canvas, 'width'), dart.dload(canvasrenderin gcontext2d_test.canvas, 'height'));
126 canvasrenderingcontext2d_test.checkPixel(canvasrenderingcontext2d_test.r eadPixel(2, 2), JSArrayOfint().of([127, 127, 127, 255]));
127 }, VoidTodynamic()));
128 unittest$.test('setStrokeColorRgb', dart.fn(() => {
129 dart.dsend(canvasrenderingcontext2d_test.context, 'setStrokeColorRgb', 2 55, 0, 255, 1);
130 dart.dput(canvasrenderingcontext2d_test.context, 'lineWidth', 10);
131 dart.dsend(canvasrenderingcontext2d_test.context, 'strokeRect', 0, 0, da rt.dload(canvasrenderingcontext2d_test.canvas, 'width'), dart.dload(canvasrender ingcontext2d_test.canvas, 'height'));
132 src__matcher__expect.expect(canvasrenderingcontext2d_test.readPixel(2, 2 ), JSArrayOfint().of([255, 0, 255, 255]));
133 }, VoidTodynamic()));
134 unittest$.test('setStrokeColorHsl hue', dart.fn(() => {
135 dart.dsend(canvasrenderingcontext2d_test.context, 'setStrokeColorHsl', 0 , 100, 50);
136 dart.dput(canvasrenderingcontext2d_test.context, 'lineWidth', 10);
137 dart.dsend(canvasrenderingcontext2d_test.context, 'strokeRect', 0, 0, da rt.dload(canvasrenderingcontext2d_test.canvas, 'width'), dart.dload(canvasrender ingcontext2d_test.canvas, 'height'));
138 src__matcher__expect.expect(canvasrenderingcontext2d_test.readPixel(2, 2 ), JSArrayOfint().of([255, 0, 0, 255]));
139 }, VoidTodynamic()));
140 unittest$.test('setStrokeColorHsl hue 2', dart.fn(() => {
141 dart.dsend(canvasrenderingcontext2d_test.context, 'setStrokeColorHsl', 2 40, 100, 50);
142 dart.dput(canvasrenderingcontext2d_test.context, 'lineWidth', 10);
143 dart.dsend(canvasrenderingcontext2d_test.context, 'strokeRect', 0, 0, da rt.dload(canvasrenderingcontext2d_test.canvas, 'width'), dart.dload(canvasrender ingcontext2d_test.canvas, 'height'));
144 src__matcher__expect.expect(canvasrenderingcontext2d_test.readPixel(2, 2 ), JSArrayOfint().of([0, 0, 255, 255]));
145 }, VoidTodynamic()));
146 unittest$.test('setStrokeColorHsl sat', dart.fn(() => {
147 dart.dsend(canvasrenderingcontext2d_test.context, 'setStrokeColorHsl', 0 , 0, 50);
148 dart.dput(canvasrenderingcontext2d_test.context, 'lineWidth', 10);
149 dart.dsend(canvasrenderingcontext2d_test.context, 'strokeRect', 0, 0, da rt.dload(canvasrenderingcontext2d_test.canvas, 'width'), dart.dload(canvasrender ingcontext2d_test.canvas, 'height'));
150 canvasrenderingcontext2d_test.checkPixel(canvasrenderingcontext2d_test.r eadPixel(2, 2), JSArrayOfint().of([127, 127, 127, 255]));
151 }, VoidTodynamic()));
152 unittest$.test('fillStyle', dart.fn(() => {
153 dart.dput(canvasrenderingcontext2d_test.context, 'fillStyle', "red");
154 dart.dsend(canvasrenderingcontext2d_test.context, 'fillRect', 0, 0, dart .dload(canvasrenderingcontext2d_test.canvas, 'width'), dart.dload(canvasrenderin gcontext2d_test.canvas, 'height'));
155 canvasrenderingcontext2d_test.checkPixel(canvasrenderingcontext2d_test.r eadPixel(2, 2), JSArrayOfint().of([255, 0, 0, 255]));
156 }, VoidTodynamic()));
157 unittest$.test('strokeStyle', dart.fn(() => {
158 dart.dput(canvasrenderingcontext2d_test.context, 'strokeStyle', "blue");
159 dart.dput(canvasrenderingcontext2d_test.context, 'lineWidth', 10);
160 dart.dsend(canvasrenderingcontext2d_test.context, 'strokeRect', 0, 0, da rt.dload(canvasrenderingcontext2d_test.canvas, 'width'), dart.dload(canvasrender ingcontext2d_test.canvas, 'height'));
161 src__matcher__expect.expect(canvasrenderingcontext2d_test.readPixel(2, 2 ), JSArrayOfint().of([0, 0, 255, 255]));
162 }, VoidTodynamic()));
163 unittest$.test('fillStyle linearGradient', dart.fn(() => {
164 let gradient = dart.dsend(canvasrenderingcontext2d_test.context, 'create LinearGradient', 0, 0, 20, 20);
165 dart.dsend(gradient, 'addColorStop', 0, 'red');
166 dart.dsend(gradient, 'addColorStop', 1, 'blue');
167 dart.dput(canvasrenderingcontext2d_test.context, 'fillStyle', gradient);
168 dart.dsend(canvasrenderingcontext2d_test.context, 'fillRect', 0, 0, dart .dload(canvasrenderingcontext2d_test.canvas, 'width'), dart.dload(canvasrenderin gcontext2d_test.canvas, 'height'));
169 src__matcher__expect.expect(html.CanvasGradient.is(dart.dload(canvasrend eringcontext2d_test.context, 'fillStyle')), src__matcher__core_matchers.isTrue);
170 }, VoidTodynamic()));
171 unittest$.test('putImageData', dart.fn(() => {
172 dart.dput(canvasrenderingcontext2d_test.context, 'fillStyle', 'green');
173 dart.dsend(canvasrenderingcontext2d_test.context, 'fillRect', 0, 0, dart .dload(canvasrenderingcontext2d_test.canvas, 'width'), dart.dload(canvasrenderin gcontext2d_test.canvas, 'height'));
174 let expectedData = html.ImageData._check(dart.dsend(canvasrenderingconte xt2d_test.context, 'getImageData', 0, 0, 10, 10));
175 expectedData[dartx.data][dartx.set](0, 25);
176 expectedData[dartx.data][dartx.set](1, 65);
177 expectedData[dartx.data][dartx.set](2, 255);
178 expectedData[dartx.data][dartx.set](3, 255);
179 dart.dsend(canvasrenderingcontext2d_test.context, 'putImageData', expect edData, 0, 0);
180 let resultingData = dart.dsend(canvasrenderingcontext2d_test.context, 'g etImageData', 0, 0, 10, 10);
181 src__matcher__expect.expect(dart.dload(resultingData, 'data'), expectedD ata[dartx.data]);
182 }, VoidTodynamic()));
183 unittest$.test('putImageData dirty rectangle', dart.fn(() => {
184 dart.dput(canvasrenderingcontext2d_test.context, 'fillStyle', 'green');
185 dart.dsend(canvasrenderingcontext2d_test.context, 'fillRect', 0, 0, dart .dload(canvasrenderingcontext2d_test.canvas, 'width'), dart.dload(canvasrenderin gcontext2d_test.canvas, 'height'));
186 let drawnData = html.ImageData._check(dart.dsend(canvasrenderingcontext2 d_test.context, 'getImageData', 0, 0, 10, 10));
187 drawnData[dartx.data][dartx.set](0, 25);
188 drawnData[dartx.data][dartx.set](1, 65);
189 drawnData[dartx.data][dartx.set](2, 255);
190 drawnData[dartx.data][dartx.set](3, 255);
191 drawnData[dartx.data][dartx.set](2 * 4 + 0, 25);
192 drawnData[dartx.data][dartx.set](2 * 4 + 1, 65);
193 drawnData[dartx.data][dartx.set](2 * 4 + 2, 255);
194 drawnData[dartx.data][dartx.set](2 * 4 + 3, 255);
195 drawnData[dartx.data][dartx.set](7 * 4 + 0, 25);
196 drawnData[dartx.data][dartx.set](7 * 4 + 1, 65);
197 drawnData[dartx.data][dartx.set](7 * 4 + 2, 255);
198 drawnData[dartx.data][dartx.set](7 * 4 + 3, 255);
199 dart.dsend(canvasrenderingcontext2d_test.context, 'putImageData', drawnD ata, 0, 0, 1, 0, 5, 5);
200 let expectedData = html.ImageData._check(dart.dsend(canvasrenderingconte xt2d_test.context, 'createImageData', 10, 10));
201 for (let i = 0; i < dart.notNull(expectedData[dartx.data][dartx.length]) ; i++) {
202 switch (i[dartx['%']](4)) {
203 case 0:
204 {
205 expectedData[dartx.data][dartx.set](i, 0);
206 break;
207 }
208 case 1:
209 {
210 expectedData[dartx.data][dartx.set](i, 128);
211 break;
212 }
213 case 2:
214 {
215 expectedData[dartx.data][dartx.set](i, 0);
216 break;
217 }
218 case 3:
219 {
220 expectedData[dartx.data][dartx.set](i, 255);
221 break;
222 }
223 }
224 }
225 expectedData[dartx.data][dartx.set](2 * 4 + 0, 25);
226 expectedData[dartx.data][dartx.set](2 * 4 + 1, 65);
227 expectedData[dartx.data][dartx.set](2 * 4 + 2, 255);
228 expectedData[dartx.data][dartx.set](2 * 4 + 3, 255);
229 let resultingData = dart.dsend(canvasrenderingcontext2d_test.context, 'g etImageData', 0, 0, 10, 10);
230 src__matcher__expect.expect(dart.dload(resultingData, 'data'), expectedD ata[dartx.data]);
231 }, VoidTodynamic()));
232 unittest$.test('putImageData throws with wrong number of arguments', dart. fn(() => {
233 let expectedData = html.ImageData._check(dart.dsend(canvasrenderingconte xt2d_test.context, 'getImageData', 0, 0, 10, 10));
234 src__matcher__expect.expect(dart.fn(() => dart.dsend(canvasrenderingcont ext2d_test.context, 'putImageData', expectedData, 0, 0, 1), VoidTodynamic()), sr c__matcher__throws_matcher.throws);
235 src__matcher__expect.expect(dart.fn(() => dart.dsend(canvasrenderingcont ext2d_test.context, 'putImageData', expectedData, 0, 0, 1, 1), VoidTodynamic()), src__matcher__throws_matcher.throws);
236 src__matcher__expect.expect(dart.fn(() => dart.dsend(canvasrenderingcont ext2d_test.context, 'putImageData', expectedData, 0, 0, 1, 1, 5), VoidTodynamic( )), src__matcher__throws_matcher.throws);
237 }, VoidTodynamic()));
238 }, VoidTovoid()));
239 unittest$.group('arc', dart.fn(() => {
240 unittest$.setUp(canvasrenderingcontext2d_test.setupFunc);
241 unittest$.tearDown(canvasrenderingcontext2d_test.tearDownFunc);
242 unittest$.test('default arc should be clockwise', dart.fn(() => {
243 dart.dsend(canvasrenderingcontext2d_test.context, 'beginPath');
244 let r = 10;
245 let cx = 20;
246 let cy = 20;
247 dart.dsend(canvasrenderingcontext2d_test.context, 'arc', cx, cy, r, 0, m ath.PI / 2);
248 dart.dput(canvasrenderingcontext2d_test.context, 'strokeStyle', 'green') ;
249 dart.dput(canvasrenderingcontext2d_test.context, 'lineWidth', 2);
250 dart.dsend(canvasrenderingcontext2d_test.context, 'stroke');
251 canvasrenderingcontext2d_test.expectPixelUnfilled(cx, cy);
252 canvasrenderingcontext2d_test.expectPixelFilled(cx + r, cy, true);
253 canvasrenderingcontext2d_test.expectPixelFilled(cx, cy + r, true);
254 canvasrenderingcontext2d_test.expectPixelFilled(cx - r, cy, false);
255 canvasrenderingcontext2d_test.expectPixelFilled(cx, cy - r, false);
256 canvasrenderingcontext2d_test.expectPixelFilled((cx + r / dart.notNull(m ath.SQRT2))[dartx.toInt](), (cy + r / dart.notNull(math.SQRT2))[dartx.toInt](), true);
257 canvasrenderingcontext2d_test.expectPixelFilled((cx - r / dart.notNull(m ath.SQRT2))[dartx.toInt](), (cy + r / dart.notNull(math.SQRT2))[dartx.toInt](), false);
258 canvasrenderingcontext2d_test.expectPixelFilled((cx - r / dart.notNull(m ath.SQRT2))[dartx.toInt](), (cy - r / dart.notNull(math.SQRT2))[dartx.toInt](), false);
259 canvasrenderingcontext2d_test.expectPixelFilled((cx + r / dart.notNull(m ath.SQRT2))[dartx.toInt](), (cy - r / dart.notNull(math.SQRT2))[dartx.toInt](), false);
260 }, VoidTodynamic()));
261 unittest$.test('arc anticlockwise', dart.fn(() => {
262 dart.dsend(canvasrenderingcontext2d_test.context, 'beginPath');
263 let r = 10;
264 let cx = 20;
265 let cy = 20;
266 dart.dsend(canvasrenderingcontext2d_test.context, 'arc', cx, cy, r, 0.1, math.PI / 2 - 0.1, true);
267 dart.dput(canvasrenderingcontext2d_test.context, 'strokeStyle', 'green') ;
268 dart.dput(canvasrenderingcontext2d_test.context, 'lineWidth', 2);
269 dart.dsend(canvasrenderingcontext2d_test.context, 'stroke');
270 canvasrenderingcontext2d_test.expectPixelUnfilled(cx, cy);
271 canvasrenderingcontext2d_test.expectPixelFilled(cx + r, cy, true);
272 canvasrenderingcontext2d_test.expectPixelFilled(cx, cy + r, true);
273 canvasrenderingcontext2d_test.expectPixelFilled(cx - r, cy, true);
274 canvasrenderingcontext2d_test.expectPixelFilled(cx, cy - r, true);
275 canvasrenderingcontext2d_test.expectPixelFilled((cx + r / dart.notNull(m ath.SQRT2))[dartx.toInt](), (cy + r / dart.notNull(math.SQRT2))[dartx.toInt](), false);
276 canvasrenderingcontext2d_test.expectPixelFilled((cx - r / dart.notNull(m ath.SQRT2))[dartx.toInt](), (cy + r / dart.notNull(math.SQRT2))[dartx.toInt](), true);
277 canvasrenderingcontext2d_test.expectPixelFilled((cx - r / dart.notNull(m ath.SQRT2))[dartx.toInt](), (cy - r / dart.notNull(math.SQRT2))[dartx.toInt](), true);
278 canvasrenderingcontext2d_test.expectPixelFilled((cx + r / dart.notNull(m ath.SQRT2))[dartx.toInt](), (cy - r / dart.notNull(math.SQRT2))[dartx.toInt](), true);
279 }, VoidTodynamic()));
280 }, VoidTovoid()));
281 unittest$.group('drawImage_image_element', dart.fn(() => {
282 unittest$.setUp(canvasrenderingcontext2d_test.setupFunc);
283 unittest$.tearDown(canvasrenderingcontext2d_test.tearDownFunc);
284 unittest$.test('with 3 params', dart.fn(() => {
285 let dataUrl = dart.dsend(canvasrenderingcontext2d_test.otherCanvas, 'toD ataUrl', 'image/gif');
286 let img = html.ImageElement.new();
287 img[dartx.onLoad].listen(EventTovoid()._check(unittest$.expectAsync(dart .fn(_ => {
288 dart.dsend(canvasrenderingcontext2d_test.context, 'drawImage', img, 50 , 50);
289 canvasrenderingcontext2d_test.expectPixelFilled(50, 50);
290 canvasrenderingcontext2d_test.expectPixelFilled(55, 55);
291 canvasrenderingcontext2d_test.expectPixelFilled(59, 59);
292 canvasrenderingcontext2d_test.expectPixelUnfilled(60, 60);
293 canvasrenderingcontext2d_test.expectPixelUnfilled(0, 0);
294 canvasrenderingcontext2d_test.expectPixelUnfilled(70, 70);
295 }, dynamicTodynamic()))));
296 img[dartx.onError].listen(dart.fn(_ => {
297 src__matcher__expect.fail('URL failed to load.');
298 }, EventTovoid$()));
299 img[dartx.src] = core.String._check(dataUrl);
300 }, VoidTodynamic()));
301 unittest$.test('with 5 params', dart.fn(() => {
302 let dataUrl = dart.dsend(canvasrenderingcontext2d_test.otherCanvas, 'toD ataUrl', 'image/gif');
303 let img = html.ImageElement.new();
304 img[dartx.onLoad].listen(EventTovoid()._check(unittest$.expectAsync(dart .fn(_ => {
305 dart.dsend(canvasrenderingcontext2d_test.context, 'drawImageToRect', i mg, new (RectangleOfnum())(50, 50, 20, 20));
306 canvasrenderingcontext2d_test.expectPixelFilled(50, 50);
307 canvasrenderingcontext2d_test.expectPixelFilled(55, 55);
308 canvasrenderingcontext2d_test.expectPixelFilled(59, 59);
309 canvasrenderingcontext2d_test.expectPixelFilled(60, 60);
310 canvasrenderingcontext2d_test.expectPixelFilled(69, 69);
311 canvasrenderingcontext2d_test.expectPixelUnfilled(70, 70);
312 canvasrenderingcontext2d_test.expectPixelUnfilled(0, 0);
313 canvasrenderingcontext2d_test.expectPixelUnfilled(80, 80);
314 }, dynamicTodynamic()))));
315 img[dartx.onError].listen(dart.fn(_ => {
316 src__matcher__expect.fail('URL failed to load.');
317 }, EventTovoid$()));
318 img[dartx.src] = core.String._check(dataUrl);
319 }, VoidTodynamic()));
320 unittest$.test('with 9 params', dart.fn(() => {
321 dart.dput(canvasrenderingcontext2d_test.otherContext, 'fillStyle', "blue ");
322 dart.dsend(canvasrenderingcontext2d_test.otherContext, 'fillRect', 5, 5, 5, 5);
323 let dataUrl = dart.dsend(canvasrenderingcontext2d_test.otherCanvas, 'toD ataUrl', 'image/gif');
324 let img = html.ImageElement.new();
325 img[dartx.onLoad].listen(EventTovoid()._check(unittest$.expectAsync(dart .fn(_ => {
326 dart.dsend(canvasrenderingcontext2d_test.context, 'drawImageToRect', i mg, new (RectangleOfnum())(50, 50, 20, 20), {sourceRect: new (RectangleOfnum())( 2, 2, 6, 6)});
327 canvasrenderingcontext2d_test.checkPixel(canvasrenderingcontext2d_test .readPixel(50, 50), JSArrayOfint().of([255, 0, 0, 255]));
328 canvasrenderingcontext2d_test.checkPixel(canvasrenderingcontext2d_test .readPixel(55, 55), JSArrayOfint().of([255, 0, 0, 255]));
329 canvasrenderingcontext2d_test.checkPixel(canvasrenderingcontext2d_test .readPixel(60, 50), JSArrayOfint().of([255, 0, 0, 255]));
330 canvasrenderingcontext2d_test.checkPixel(canvasrenderingcontext2d_test .readPixel(65, 65), JSArrayOfint().of([0, 0, 255, 255]));
331 canvasrenderingcontext2d_test.checkPixel(canvasrenderingcontext2d_test .readPixel(69, 69), JSArrayOfint().of([0, 0, 255, 255]));
332 canvasrenderingcontext2d_test.expectPixelFilled(50, 50);
333 canvasrenderingcontext2d_test.expectPixelFilled(55, 55);
334 canvasrenderingcontext2d_test.expectPixelFilled(59, 59);
335 canvasrenderingcontext2d_test.expectPixelFilled(60, 60);
336 canvasrenderingcontext2d_test.expectPixelFilled(69, 69);
337 canvasrenderingcontext2d_test.expectPixelUnfilled(70, 70);
338 canvasrenderingcontext2d_test.expectPixelUnfilled(0, 0);
339 canvasrenderingcontext2d_test.expectPixelUnfilled(80, 80);
340 }, dynamicTodynamic()))));
341 img[dartx.onError].listen(dart.fn(_ => {
342 src__matcher__expect.fail('URL failed to load.');
343 }, EventTovoid$()));
344 img[dartx.src] = core.String._check(dataUrl);
345 }, VoidTodynamic()));
346 }, VoidTovoid()));
347 let mp4VideoUrl = '/root_dart/tests/html/small.mp4';
348 let webmVideoUrl = '/root_dart/tests/html/small.webm';
349 let mp4VideoDataUrl = 'data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28 yYXZjMW1wNDEAAA' + 'AIZnJlZQAAAsdtZGF0AAACmwYF//+X3EXpvebZSLeWLNgg2SPu73gyNjQgLS Bjb3JlID' + 'EyMCByMjE1MSBhM2Y0NDA3IC0gSC4yNjQvTVBFRy00IEFWQyBjb2RlYyAtIENvcHlsZ W' + 'Z0IDIwMDMtMjAxMSAtIGh0dHA6Ly93d3cudmlkZW9sYW4ub3JnL3gyNjQuaHRtbCAtIG' + '9 wdGlvbnM6IGNhYmFjPTEgcmVmPTMgZGVibG9jaz0xOjA6MCBhbmFseXNlPTB4MToweD' + 'ExMSBtZT 1oZXggc3VibWU9NyBwc3k9MSBwc3lfcmQ9MS4wMDowLjAwIG1peGVkX3JlZj' + '0wIG1lX3JhbmdlP TE2IGNocm9tYV9tZT0xIHRyZWxsaXM9MSA4eDhkY3Q9MCBjcW09MC' + 'BkZWFkem9uZT0yMSwxMSBm YXN0X3Bza2lwPTEgY2hyb21hX3FwX29mZnNldD0tMiB0aH' + 'JlYWRzPTE4IHNsaWNlZF90aHJlYWR zPTAgbnI9MCBkZWNpbWF0ZT0xIGludGVybGFjZW' + 'Q9MCBibHVyYXlfY29tcGF0PTAgY29uc3RyYW luZWRfaW50cmE9MCBiZnJhbWVzPTMgYl' + '9weXJhbWlkPTAgYl9hZGFwdD0xIGJfYmlhcz0wIGRpc mVjdD0xIHdlaWdodGI9MCBvcG' + 'VuX2dvcD0xIHdlaWdodHA9MiBrZXlpbnQ9MjUwIGtleWludF9t aW49MjUgc2NlbmVjdX' + 'Q9NDAgaW50cmFfcmVmcmVzaD0wIHJjX2xvb2thaGVhZD00MCByYz1jcmY gbWJ0cmVlPT' + 'EgY3JmPTUxLjAgcWNvbXA9MC42MCBxcG1pbj0wIHFwbWF4PTY5IHFwc3RlcD00IG lwX3' + 'JhdGlvPTEuMjUgYXE9MToxLjAwAIAAAAARZYiEB//3aoK5/tP9+8yeuIEAAAAHQZoi2P' + '/wgAAAAzxtb292AAAAbG12aGQAAAAAAAAAAAAAAAAAAAPoAAAAUAABAAABAAAAAAAAAA' + 'AAAAA AAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAA AAAAAAAAACAAAAGGlvZHMAAAAAEICAgAcAT/////7/AAACUHRyYWsAAA' + 'BcdGtoZAAAAA8AAAAAA AAAAAAAAAEAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAQAAAA' + 'AAAAAAAAAAAAAAAAEAAAAAAAAA AAAAAAAAAEAAAAAACAAAAAgAAAAAACRlZHRzAAAAHG' + 'Vsc3QAAAAAAAAAAQAAAFAAAAABAAEAAAA AAchtZGlhAAAAIG1kaGQAAAAAAAAAAAAAAA' + 'AAAAAZAAAAAlXEAAAAAAAtaGRscgAAAAAAAAAAdm lkZQAAAAAAAAAAAAAAAFZpZGVvSG' + 'FuZGxlcgAAAAFzbWluZgAAABR2bWhkAAAAAQAAAAAAAAAAA AAAJGRpbmYAAAAcZHJlZg' + 'AAAAAAAAABAAAADHVybCAAAAABAAABM3N0YmwAAACXc3RzZAAAAAAA AAABAAAAh2F2Yz' + 'EAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAACAAIAEgAAABIAAAAAAAAAAEAAAA AAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY//8AAAAxYXZjQwFNQAr/4QAYZ01ACuiPyy ' + '4C2QAAAwABAAADADIPEiUSAQAGaOvAZSyAAAAAGHN0dHMAAAAAAAAAAQAAAAIAAAABAA' + 'AA FHN0c3MAAAAAAAAAAQAAAAEAAAAYY3R0cwAAAAAAAAABAAAAAgAAAAEAAAAcc3RzYw' + 'AAAAAAAAA BAAAAAQAAAAEAAAABAAAAHHN0c3oAAAAAAAAAAAAAAAIAAAK0AAAACwAAAB' + 'hzdGNvAAAAAAAAAA IAAAAwAAAC5AAAAGB1ZHRhAAAAWG1ldGEAAAAAAAAAIWhkbHIAAA' + 'AAAAAAAG1kaXJhcHBsAAAAA AAAAAAAAAAAK2lsc3QAAAAjqXRvbwAAABtkYXRhAAAAAQ' + 'AAAABMYXZmNTMuMjEuMQ==';
350 let webmVideoDataUrl = 'data:video/webm;base64,GkXfowEAAAAAAAAfQoaBAUL3gQFC8 oEEQvOBCEKChHdlY' + 'm1Ch4ECQoWBAhhTgGcBAAAAAAAB/hFNm3RALE27i1OrhBVJqWZTrIHfTbuM U6uEFlSua' + '1OsggEsTbuMU6uEHFO7a1OsggHk7AEAAAAAAACkAAAAAAAAAAAAAAAAAAAAAAAAAAA AA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + ' AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmAQAAAAAAA' + 'EEq17GDD0JATYC LTGF2ZjUzLjIxLjFXQYtMYXZmNTMuMjEuMXOkkJatuHwTJ7cvFLSzB' + 'Smxbp5EiYhAVAAAAAAAAB ZUrmsBAAAAAAAAR64BAAAAAAAAPteBAXPFgQGcgQAitZyDd' + 'W5khoVWX1ZQOIOBASPjg4QCYloA4 AEAAAAAAAASsIEIuoEIVLCBCFS6gQhUsoEDH0O2d' + 'QEAAAAAAABZ54EAo72BAACA8AIAnQEqCAAI AABHCIWFiIWEiAICAnWqA/gD+gINTRgA/' + 'v0hRf/kb+PnRv/I4//8WE8DijI//FRAo5WBACgAsQE AARAQABgAGFgv9AAIAAAcU7trA' + 'QAAAAAAAA67jLOBALeH94EB8YIBfw==';
351 unittest$.group('drawImage_video_element', dart.fn(() => {
352 unittest$.setUp(canvasrenderingcontext2d_test.setupFunc);
353 unittest$.tearDown(canvasrenderingcontext2d_test.tearDownFunc);
354 unittest$.test('with 3 params', dart.fn(() => {
355 dart.dsend(dart.dload(canvasrenderingcontext2d_test.video, 'onCanPlay'), 'listen', unittest$.expectAsync(dart.fn(_ => {
356 dart.dsend(canvasrenderingcontext2d_test.context, 'drawImage', canvasr enderingcontext2d_test.video, 50, 50);
357 canvasrenderingcontext2d_test.expectPixelFilled(50, 50);
358 canvasrenderingcontext2d_test.expectPixelFilled(54, 54);
359 canvasrenderingcontext2d_test.expectPixelFilled(57, 57);
360 canvasrenderingcontext2d_test.expectPixelUnfilled(58, 58);
361 canvasrenderingcontext2d_test.expectPixelUnfilled(0, 0);
362 canvasrenderingcontext2d_test.expectPixelUnfilled(70, 70);
363 }, dynamicTodynamic())));
364 dart.dsend(dart.dload(canvasrenderingcontext2d_test.video, 'onError'), ' listen', dart.fn(_ => {
365 src__matcher__expect.fail('URL failed to load.');
366 }, dynamicTodynamic()));
367 if (!dart.equals(dart.dsend(canvasrenderingcontext2d_test.video, 'canPla yType', 'video/webm; codecs="vp8.0, vorbis"', ''), '')) {
368 dart.dput(canvasrenderingcontext2d_test.video, 'src', webmVideoUrl);
369 } else if (!dart.equals(dart.dsend(canvasrenderingcontext2d_test.video, 'canPlayType', 'video/mp4; codecs="avc1.4D401E, mp4a.40.2"', null), '')) {
370 dart.dput(canvasrenderingcontext2d_test.video, 'src', mp4VideoUrl);
371 } else {
372 html.window[dartx.console].log('Video is not supported on this system. ');
373 }
374 }, VoidTodynamic()));
375 unittest$.test('with 5 params', dart.fn(() => {
376 dart.dsend(dart.dload(canvasrenderingcontext2d_test.video, 'onCanPlay'), 'listen', unittest$.expectAsync(dart.fn(_ => {
377 dart.dsend(canvasrenderingcontext2d_test.context, 'drawImageToRect', c anvasrenderingcontext2d_test.video, new (RectangleOfnum())(50, 50, 20, 20));
378 canvasrenderingcontext2d_test.expectPixelFilled(50, 50);
379 canvasrenderingcontext2d_test.expectPixelFilled(55, 55);
380 canvasrenderingcontext2d_test.expectPixelFilled(59, 59);
381 canvasrenderingcontext2d_test.expectPixelFilled(60, 60);
382 canvasrenderingcontext2d_test.expectPixelFilled(69, 69);
383 canvasrenderingcontext2d_test.expectPixelUnfilled(70, 70);
384 canvasrenderingcontext2d_test.expectPixelUnfilled(0, 0);
385 canvasrenderingcontext2d_test.expectPixelUnfilled(80, 80);
386 }, dynamicTodynamic())));
387 dart.dsend(dart.dload(canvasrenderingcontext2d_test.video, 'onError'), ' listen', dart.fn(_ => {
388 src__matcher__expect.fail('URL failed to load.');
389 }, dynamicTodynamic()));
390 if (!dart.equals(dart.dsend(canvasrenderingcontext2d_test.video, 'canPla yType', 'video/webm; codecs="vp8.0, vorbis"', ''), '')) {
391 dart.dput(canvasrenderingcontext2d_test.video, 'src', webmVideoUrl);
392 } else if (!dart.equals(dart.dsend(canvasrenderingcontext2d_test.video, 'canPlayType', 'video/mp4; codecs="avc1.4D401E, mp4a.40.2"', null), '')) {
393 dart.dput(canvasrenderingcontext2d_test.video, 'src', mp4VideoUrl);
394 } else {
395 html.window[dartx.console].log('Video is not supported on this system. ');
396 }
397 }, VoidTodynamic()));
398 unittest$.test('with 9 params', dart.fn(() => {
399 dart.dsend(dart.dload(canvasrenderingcontext2d_test.video, 'onCanPlay'), 'listen', unittest$.expectAsync(dart.fn(_ => {
400 dart.dsend(canvasrenderingcontext2d_test.context, 'drawImageToRect', c anvasrenderingcontext2d_test.video, new (RectangleOfnum())(50, 50, 20, 20), {sou rceRect: new (RectangleOfnum())(2, 2, 6, 6)});
401 canvasrenderingcontext2d_test.expectPixelFilled(50, 50);
402 canvasrenderingcontext2d_test.expectPixelFilled(55, 55);
403 canvasrenderingcontext2d_test.expectPixelFilled(59, 59);
404 canvasrenderingcontext2d_test.expectPixelFilled(60, 60);
405 canvasrenderingcontext2d_test.expectPixelFilled(69, 69);
406 canvasrenderingcontext2d_test.expectPixelUnfilled(70, 70);
407 canvasrenderingcontext2d_test.expectPixelUnfilled(0, 0);
408 canvasrenderingcontext2d_test.expectPixelUnfilled(80, 80);
409 }, dynamicTodynamic())));
410 dart.dsend(dart.dload(canvasrenderingcontext2d_test.video, 'onError'), ' listen', dart.fn(_ => {
411 src__matcher__expect.fail('URL failed to load.');
412 }, dynamicTodynamic()));
413 if (!dart.equals(dart.dsend(canvasrenderingcontext2d_test.video, 'canPla yType', 'video/webm; codecs="vp8.0, vorbis"', ''), '')) {
414 dart.dput(canvasrenderingcontext2d_test.video, 'src', webmVideoUrl);
415 } else if (!dart.equals(dart.dsend(canvasrenderingcontext2d_test.video, 'canPlayType', 'video/mp4; codecs="avc1.4D401E, mp4a.40.2"', null), '')) {
416 dart.dput(canvasrenderingcontext2d_test.video, 'src', mp4VideoUrl);
417 } else {
418 html.window[dartx.console].log('Video is not supported on this system. ');
419 }
420 }, VoidTodynamic()));
421 }, VoidTovoid()));
422 unittest$.group('drawImage_video_element_dataUrl', dart.fn(() => {
423 unittest$.setUp(canvasrenderingcontext2d_test.setupFunc);
424 unittest$.tearDown(canvasrenderingcontext2d_test.tearDownFunc);
425 unittest$.test('with 9 params', dart.fn(() => {
426 canvasrenderingcontext2d_test.video = html.VideoElement.new();
427 canvasrenderingcontext2d_test.canvas = html.CanvasElement.new();
428 dart.dsend(dart.dload(canvasrenderingcontext2d_test.video, 'onCanPlay'), 'listen', unittest$.expectAsync(dart.fn(_ => {
429 dart.dsend(canvasrenderingcontext2d_test.context, 'drawImageToRect', c anvasrenderingcontext2d_test.video, new (RectangleOfnum())(50, 50, 20, 20), {sou rceRect: new (RectangleOfnum())(2, 2, 6, 6)});
430 canvasrenderingcontext2d_test.expectPixelFilled(50, 50);
431 canvasrenderingcontext2d_test.expectPixelFilled(55, 55);
432 canvasrenderingcontext2d_test.expectPixelFilled(59, 59);
433 canvasrenderingcontext2d_test.expectPixelFilled(60, 60);
434 canvasrenderingcontext2d_test.expectPixelFilled(69, 69);
435 canvasrenderingcontext2d_test.expectPixelUnfilled(70, 70);
436 canvasrenderingcontext2d_test.expectPixelUnfilled(0, 0);
437 canvasrenderingcontext2d_test.expectPixelUnfilled(80, 80);
438 }, dynamicTodynamic())));
439 dart.dsend(dart.dload(canvasrenderingcontext2d_test.video, 'onError'), ' listen', dart.fn(_ => {
440 src__matcher__expect.fail('URL failed to load.');
441 }, dynamicTodynamic()));
442 if (!dart.equals(dart.dsend(canvasrenderingcontext2d_test.video, 'canPla yType', 'video/webm; codecs="vp8.0, vorbis"', ''), '')) {
443 dart.dput(canvasrenderingcontext2d_test.video, 'src', webmVideoDataUrl );
444 } else if (!dart.equals(dart.dsend(canvasrenderingcontext2d_test.video, 'canPlayType', 'video/mp4; codecs="avc1.4D401E, mp4a.40.2"', null), '')) {
445 dart.dput(canvasrenderingcontext2d_test.video, 'src', mp4VideoDataUrl) ;
446 } else {
447 html.window[dartx.console].log('Video is not supported on this system. ');
448 }
449 }, VoidTodynamic()));
450 }, VoidTovoid()));
451 unittest$.group('drawImage_canvas_element', dart.fn(() => {
452 unittest$.setUp(canvasrenderingcontext2d_test.setupFunc);
453 unittest$.tearDown(canvasrenderingcontext2d_test.tearDownFunc);
454 unittest$.test('with 3 params', dart.fn(() => {
455 dart.dsend(canvasrenderingcontext2d_test.context, 'drawImage', canvasren deringcontext2d_test.otherCanvas, 50, 50);
456 canvasrenderingcontext2d_test.expectPixelFilled(50, 50);
457 canvasrenderingcontext2d_test.expectPixelFilled(55, 55);
458 canvasrenderingcontext2d_test.expectPixelFilled(59, 59);
459 canvasrenderingcontext2d_test.expectPixelUnfilled(60, 60);
460 canvasrenderingcontext2d_test.expectPixelUnfilled(0, 0);
461 canvasrenderingcontext2d_test.expectPixelUnfilled(70, 70);
462 }, VoidTodynamic()));
463 unittest$.test('with 5 params', dart.fn(() => {
464 dart.dsend(canvasrenderingcontext2d_test.context, 'drawImageToRect', can vasrenderingcontext2d_test.otherCanvas, new (RectangleOfnum())(50, 50, 20, 20));
465 canvasrenderingcontext2d_test.expectPixelFilled(50, 50);
466 canvasrenderingcontext2d_test.expectPixelFilled(55, 55);
467 canvasrenderingcontext2d_test.expectPixelFilled(59, 59);
468 canvasrenderingcontext2d_test.expectPixelFilled(60, 60);
469 canvasrenderingcontext2d_test.expectPixelFilled(69, 69);
470 canvasrenderingcontext2d_test.expectPixelUnfilled(70, 70);
471 canvasrenderingcontext2d_test.expectPixelUnfilled(0, 0);
472 canvasrenderingcontext2d_test.expectPixelUnfilled(80, 80);
473 }, VoidTodynamic()));
474 unittest$.test('with 9 params', dart.fn(() => {
475 dart.dput(canvasrenderingcontext2d_test.otherContext, 'fillStyle', "blue ");
476 dart.dsend(canvasrenderingcontext2d_test.otherContext, 'fillRect', 5, 5, 5, 5);
477 dart.dsend(canvasrenderingcontext2d_test.context, 'drawImageToRect', can vasrenderingcontext2d_test.otherCanvas, new (RectangleOfnum())(50, 50, 20, 20), {sourceRect: new (RectangleOfnum())(2, 2, 6, 6)});
478 canvasrenderingcontext2d_test.checkPixel(canvasrenderingcontext2d_test.r eadPixel(50, 50), JSArrayOfint().of([255, 0, 0, 255]));
479 canvasrenderingcontext2d_test.checkPixel(canvasrenderingcontext2d_test.r eadPixel(55, 55), JSArrayOfint().of([255, 0, 0, 255]));
480 canvasrenderingcontext2d_test.checkPixel(canvasrenderingcontext2d_test.r eadPixel(60, 50), JSArrayOfint().of([255, 0, 0, 255]));
481 canvasrenderingcontext2d_test.checkPixel(canvasrenderingcontext2d_test.r eadPixel(65, 65), JSArrayOfint().of([0, 0, 255, 255]));
482 canvasrenderingcontext2d_test.checkPixel(canvasrenderingcontext2d_test.r eadPixel(69, 69), JSArrayOfint().of([0, 0, 255, 255]));
483 canvasrenderingcontext2d_test.expectPixelFilled(50, 50);
484 canvasrenderingcontext2d_test.expectPixelFilled(55, 55);
485 canvasrenderingcontext2d_test.expectPixelFilled(59, 59);
486 canvasrenderingcontext2d_test.expectPixelFilled(60, 60);
487 canvasrenderingcontext2d_test.expectPixelFilled(69, 69);
488 canvasrenderingcontext2d_test.expectPixelUnfilled(70, 70);
489 canvasrenderingcontext2d_test.expectPixelUnfilled(0, 0);
490 canvasrenderingcontext2d_test.expectPixelUnfilled(80, 80);
491 }, VoidTodynamic()));
492 unittest$.test('createImageData', dart.fn(() => {
493 let imageData = dart.dsend(canvasrenderingcontext2d_test.context, 'creat eImageData', 15, 15);
494 src__matcher__expect.expect(dart.dload(imageData, 'width'), 15);
495 src__matcher__expect.expect(dart.dload(imageData, 'height'), 15);
496 let other = dart.dsend(canvasrenderingcontext2d_test.context, 'createIma geDataFromImageData', imageData);
497 src__matcher__expect.expect(dart.dload(other, 'width'), 15);
498 src__matcher__expect.expect(dart.dload(other, 'height'), 15);
499 }, VoidTodynamic()));
500 unittest$.test('createPattern', dart.fn(() => {
501 let pattern = dart.dsend(canvasrenderingcontext2d_test.context, 'createP attern', html.CanvasElement.new(), '');
502 }, VoidTodynamic()));
503 }, VoidTovoid()));
504 unittest$.group('fillText', dart.fn(() => {
505 unittest$.setUp(canvasrenderingcontext2d_test.setupFunc);
506 unittest$.tearDown(canvasrenderingcontext2d_test.tearDownFunc);
507 let x = 20;
508 let y = 20;
509 unittest$.test('without maxWidth', dart.fn(() => {
510 dart.dput(canvasrenderingcontext2d_test.context, 'font', '40pt Garamond' );
511 dart.dput(canvasrenderingcontext2d_test.context, 'fillStyle', 'blue');
512 dart.dsend(canvasrenderingcontext2d_test.context, 'fillText', '█', x, y) ;
513 let width = dart.dsend(dart.dload(dart.dsend(canvasrenderingcontext2d_te st.context, 'measureText', '█'), 'width'), 'ceil');
514 canvasrenderingcontext2d_test.checkPixel(canvasrenderingcontext2d_test.r eadPixel(x, y), JSArrayOfint().of([0, 0, 255, 255]));
515 canvasrenderingcontext2d_test.checkPixel(canvasrenderingcontext2d_test.r eadPixel(x + 10, y), JSArrayOfint().of([0, 0, 255, 255]));
516 canvasrenderingcontext2d_test.expectPixelUnfilled(x - 10, y);
517 canvasrenderingcontext2d_test.expectPixelFilled(x, y);
518 canvasrenderingcontext2d_test.expectPixelFilled(x + 10, y);
519 canvasrenderingcontext2d_test.expectPixelFilled(dart.asInt(x + dart.notN ull(core.num._check(width)) - 2), y);
520 canvasrenderingcontext2d_test.expectPixelUnfilled(dart.asInt(x + dart.no tNull(core.num._check(width)) + 1), y);
521 }, VoidTodynamic()));
522 unittest$.test('with maxWidth null', dart.fn(() => {
523 dart.dput(canvasrenderingcontext2d_test.context, 'font', '40pt Garamond' );
524 dart.dput(canvasrenderingcontext2d_test.context, 'fillStyle', 'blue');
525 dart.dsend(canvasrenderingcontext2d_test.context, 'fillText', '█', x, y, null);
526 let width = dart.dsend(dart.dload(dart.dsend(canvasrenderingcontext2d_te st.context, 'measureText', '█'), 'width'), 'ceil');
527 canvasrenderingcontext2d_test.checkPixel(canvasrenderingcontext2d_test.r eadPixel(x, y), JSArrayOfint().of([0, 0, 255, 255]));
528 canvasrenderingcontext2d_test.checkPixel(canvasrenderingcontext2d_test.r eadPixel(x + 10, y), JSArrayOfint().of([0, 0, 255, 255]));
529 canvasrenderingcontext2d_test.expectPixelUnfilled(x - 10, y);
530 canvasrenderingcontext2d_test.expectPixelFilled(x, y);
531 canvasrenderingcontext2d_test.expectPixelFilled(x + 10, y);
532 canvasrenderingcontext2d_test.expectPixelFilled(dart.asInt(x + dart.notN ull(core.num._check(width)) - 2), y);
533 canvasrenderingcontext2d_test.expectPixelUnfilled(dart.asInt(x + dart.no tNull(core.num._check(width)) + 1), y);
534 }, VoidTodynamic()));
535 unittest$.test('with maxWidth defined', dart.fn(() => {
536 dart.dput(canvasrenderingcontext2d_test.context, 'font', '40pt Garamond' );
537 dart.dput(canvasrenderingcontext2d_test.context, 'fillStyle', 'blue');
538 let maxWidth = 20;
539 dart.dsend(canvasrenderingcontext2d_test.context, 'fillText', '█', x, y, maxWidth);
540 canvasrenderingcontext2d_test.checkPixel(canvasrenderingcontext2d_test.r eadPixel(x, y), JSArrayOfint().of([0, 0, 255, 255]));
541 canvasrenderingcontext2d_test.checkPixel(canvasrenderingcontext2d_test.r eadPixel(x + 10, y), JSArrayOfint().of([0, 0, 255, 255]));
542 canvasrenderingcontext2d_test.expectPixelUnfilled(x - 10, y);
543 canvasrenderingcontext2d_test.expectPixelUnfilled(x + maxWidth + 1, y);
544 canvasrenderingcontext2d_test.expectPixelUnfilled(x + maxWidth + 20, y);
545 canvasrenderingcontext2d_test.expectPixelFilled(x, y);
546 canvasrenderingcontext2d_test.expectPixelFilled(x + 10, y);
547 }, VoidTodynamic()));
548 }, VoidTovoid()));
549 };
550 dart.fn(canvasrenderingcontext2d_test.main, VoidTodynamic());
551 // Exports:
552 exports.canvasrenderingcontext2d_test = canvasrenderingcontext2d_test;
553 });
OLDNEW
« no previous file with comments | « test/codegen/expect/lib/html/canvas_test.js ('k') | test/codegen/expect/lib/html/cdata_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698