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

Side by Side Diff: tests/html/canvasrenderingcontext2d_test.dart

Issue 12648011: Reverting "Fix drawImage on Firefox and update html.status." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tests/html/html.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library canvas_rendering_context_2d_test; import '../../pkg/unittest/lib/unittes t.dart'; 5 library canvas_rendering_context_2d_test;
6 import '../../pkg/unittest/lib/unittest.dart';
6 import '../../pkg/unittest/lib/html_config.dart'; 7 import '../../pkg/unittest/lib/html_config.dart';
7 import 'dart:html'; 8 import 'dart:html';
8 import 'dart:math'; 9 import 'dart:math';
9 10
10 // Some rounding errors in the browsers. 11 // Some rounding errors in the browsers.
11 checkPixel(List<int> pixel, List<int> expected) { 12 checkPixel(List<int> pixel, List<int> expected) {
12 expect(pixel[0], closeTo(expected[0], 2)); 13 expect(pixel[0], closeTo(expected[0], 2));
13 expect(pixel[1], closeTo(expected[1], 2)); 14 expect(pixel[1], closeTo(expected[1], 2));
14 expect(pixel[2], closeTo(expected[2], 2)); 15 expect(pixel[2], closeTo(expected[2], 2));
15 expect(pixel[3], closeTo(expected[3], 2)); 16 expect(pixel[3], closeTo(expected[3], 2));
16 } 17 }
17 18
18 var canvas;
19 var context;
20 var otherCanvas;
21 var otherContext;
22 var video;
23
24 void createCanvas() {
25 canvas = new CanvasElement();
26 canvas.width = 100;
27 canvas.height = 100;
28
29 context = canvas.context2d;
30 }
31
32 void createOtherCanvas() {
33 otherCanvas = new CanvasElement();
34 otherCanvas.width = 10;
35 otherCanvas.height = 10;
36 otherContext = otherCanvas.context2d;
37 otherContext.fillStyle = "red";
38 otherContext.fillRect(0, 0, otherCanvas.width, otherCanvas.height);
39 }
40
41 void setupFunc() {
42 createCanvas();
43 createOtherCanvas();
44 video = new VideoElement();
45 }
46
47 void tearDownFunc() {
48 canvas = null;
49 context = null;
50 otherCanvas = null;
51 otherContext = null;
52 video = null;
53 }
54
55 List<int> readPixel(int x, int y) {
56 var imageData = context.getImageData(x, y, 1, 1);
57 return imageData.data;
58 }
59
60 /// Returns true if the pixel has some data in it, false otherwise.
61 bool isPixelFilled(int x, int y) => readPixel(x,y).any((p) => p != 0);
62
63 String pixelDataToString(List<int> data, int x, int y) {
64 return '[${data.join(", ")}]';
65 }
66
67 String _filled(bool v) => v ? "filled" : "unfilled";
68
69 void expectPixelFilled(int x, int y, [bool filled = true]) {
70 expect(isPixelFilled(x, y), filled, reason:
71 'Pixel at ($x, $y) was expected to'
72 ' be: <${_filled(filled)}> but was: <${_filled(!filled)}> with data: '
73 '${pixelDataToString(readPixel(x, y), x, y)}');
74 }
75
76 void expectPixelUnfilled(int x, int y) {
77 expectPixelFilled(x, y, false);
78 }
79
80 main() { 19 main() {
81 useHtmlConfiguration(); 20 useHtmlConfiguration();
82 21
83 group('pixel_manipulation', () { 22 group('canvasRenderingContext2d', () {
84 setUp(setupFunc); 23 var canvas;
85 tearDown(tearDownFunc); 24 var context;
25 var otherCanvas;
26 var otherContext;
27
28 void createOtherCanvas() {
29 otherCanvas = new CanvasElement();
30 otherCanvas.width = 10;
31 otherCanvas.height = 10;
32 otherContext = otherCanvas.context2d;
33 otherContext.fillStyle = "red";
34 otherContext.fillRect(0, 0, otherCanvas.width, otherCanvas.height);
35 }
36
37 setUp(() {
38 canvas = new CanvasElement();
39 canvas.width = 100;
40 canvas.height = 100;
41
42 context = canvas.context2d;
43
44 createOtherCanvas();
45 });
46
47 tearDown(() {
48 canvas = null;
49 context = null;
50 otherCanvas = null;
51 otherContext = null;
52 });
53
54 List<int> readPixel(int x, int y) {
55 var imageData = context.getImageData(x, y, 1, 1);
56 return imageData.data;
57 }
58
59 /// Returns true if the pixel has some data in it, false otherwise.
60 bool isPixelFilled(int x, int y) => readPixel(x,y).any((p) => p != 0);
61
62 String pixelDataToString(int x, int y) {
63 var data = readPixel(x, y);
64
65 return '[${data.join(", ")}]';
66 }
67
68 String _filled(bool v) => v ? "filled" : "unfilled";
69
70 void expectPixelFilled(int x, int y, [bool filled = true]) {
71 expect(isPixelFilled(x, y), filled, reason:
72 'Pixel at ($x, $y) was expected to'
73 ' be: <${_filled(filled)}> but was: <${_filled(!filled)}> with data: '
74 '${pixelDataToString(x,y)}');
75 }
76
77 void expectPixelUnfilled(int x, int y) {
78 expectPixelFilled(x, y, false);
79 }
80
86 81
87 test('setFillColorRgb', () { 82 test('setFillColorRgb', () {
88 context.setFillColorRgb(255, 0, 255, 1); 83 context.setFillColorRgb(255, 0, 255, 1);
89 context.fillRect(0, 0, canvas.width, canvas.height); 84 context.fillRect(0, 0, canvas.width, canvas.height);
90 expect(readPixel(2, 2), [255, 0, 255, 255]); 85 expect(readPixel(2, 2), [255, 0, 255, 255]);
91 }); 86 });
92 87
93 test('setFillColorHsl hue', () { 88 test('setFillColorHsl hue', () {
94 context.setFillColorHsl(0, 100, 50); 89 context.setFillColorHsl(0, 100, 50);
95 context.fillRect(0, 0, canvas.width, canvas.height); 90 context.fillRect(0, 0, canvas.width, canvas.height);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 expectedData.data[3] = 255; 162 expectedData.data[3] = 255;
168 context.fillStyle = 'green'; 163 context.fillStyle = 'green';
169 context.fillRect(0, 0, canvas.width, canvas.height); 164 context.fillRect(0, 0, canvas.width, canvas.height);
170 165
171 context.putImageData(expectedData, 0, 0); 166 context.putImageData(expectedData, 0, 0);
172 167
173 var resultingData = context.getImageData(0, 0, 10, 10); 168 var resultingData = context.getImageData(0, 0, 10, 10);
174 // Make sure that we read back what we wrote. 169 // Make sure that we read back what we wrote.
175 expect(resultingData.data, expectedData.data); 170 expect(resultingData.data, expectedData.data);
176 }); 171 });
177 });
178
179 group('arc', () {
180 setUp(setupFunc);
181 tearDown(tearDownFunc);
182 172
183 test('default arc should be clockwise', () { 173 test('default arc should be clockwise', () {
184 context.beginPath(); 174 context.beginPath();
185 final r = 10; 175 final r = 10;
186 176
187 // Center of arc. 177 // Center of arc.
188 final cx = 20; 178 final cx = 20;
189 final cy = 20; 179 final cy = 20;
190 // Arc centered at (20, 20) with radius 10 will go clockwise 180 // Arc centered at (20, 20) with radius 10 will go clockwise
191 // from (20 + r, 20) to (20, 20 + r), which is 1/4 of a circle. 181 // from (20 + r, 20) to (20, 20 + r), which is 1/4 of a circle.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 245
256 // (cx - r/SQRT2, cy - r/SQRT2) should be filled. 246 // (cx - r/SQRT2, cy - r/SQRT2) should be filled.
257 expectPixelFilled((cx - r/SQRT2).toInt(), (cy + r/SQRT2).toInt(), true); 247 expectPixelFilled((cx - r/SQRT2).toInt(), (cy + r/SQRT2).toInt(), true);
258 248
259 // (cx + r/SQRT2, cy + r/SQRT2) should be filled. 249 // (cx + r/SQRT2, cy + r/SQRT2) should be filled.
260 expectPixelFilled((cx - r/SQRT2).toInt(), (cy - r/SQRT2).toInt(), true); 250 expectPixelFilled((cx - r/SQRT2).toInt(), (cy - r/SQRT2).toInt(), true);
261 251
262 // (cx - r/SQRT2, cy - r/SQRT2) should be filled. 252 // (cx - r/SQRT2, cy - r/SQRT2) should be filled.
263 expectPixelFilled((cx + r/SQRT2).toInt(), (cy - r/SQRT2).toInt(), true); 253 expectPixelFilled((cx + r/SQRT2).toInt(), (cy - r/SQRT2).toInt(), true);
264 }); 254 });
265 });
266 255
267 group('drawImage_image_element', () {
268 setUp(setupFunc);
269 tearDown(tearDownFunc);
270 // Draw an image to the canvas from an image element. 256 // Draw an image to the canvas from an image element.
271 test('with 3 params', () { 257 test('drawImage from img element with 3 params', () {
272 var dataUrl = otherCanvas.toDataUrl('image/gif'); 258 var dataUrl = otherCanvas.toDataUrl('image/gif');
273 var img = new ImageElement(); 259 var img = new ImageElement();
274 260
275 img.onLoad.listen(expectAsync1((_) { 261 img.onLoad.listen(expectAsync1((_) {
276 context.drawImage(img, 50, 50); 262 context.drawImage(img, 50, 50);
277 263
278 expectPixelFilled(50, 50); 264 expectPixelFilled(50, 50);
279 expectPixelFilled(55, 55); 265 expectPixelFilled(55, 55);
280 expectPixelFilled(59, 59); 266 expectPixelFilled(59, 59);
281 expectPixelUnfilled(60, 60); 267 expectPixelUnfilled(60, 60);
282 expectPixelUnfilled(0, 0); 268 expectPixelUnfilled(0, 0);
283 expectPixelUnfilled(70, 70); 269 expectPixelUnfilled(70, 70);
284 })); 270 }));
285 img.onError.listen((_) { 271 img.onError.listen((_) {
286 guardAsync(() { 272 guardAsync(() {
287 fail('URL failed to load.'); 273 fail('URL failed to load.');
288 }); 274 });
289 }); 275 });
290 img.src = dataUrl; 276 img.src = dataUrl;
291 }); 277 });
292 278
293 // Draw an image to the canvas from an image element and scale it. 279 // Draw an image to the canvas from an image element and scale it.
294 test('with 5 params', () { 280 test('drawImage from img element with 5 params', () {
295 var dataUrl = otherCanvas.toDataUrl('image/gif'); 281 var dataUrl = otherCanvas.toDataUrl('image/gif');
296 var img = new ImageElement(); 282 var img = new ImageElement();
297 283
298 img.onLoad.listen(expectAsync1((_) { 284 img.onLoad.listen(expectAsync1((_) {
299 context.drawImageToRect(img, new Rect(50, 50, 20, 20)); 285 context.drawImageToRect(img, new Rect(50, 50, 20, 20));
300 286
301 expectPixelFilled(50, 50); 287 expectPixelFilled(50, 50);
302 expectPixelFilled(55, 55); 288 expectPixelFilled(55, 55);
303 expectPixelFilled(59, 59); 289 expectPixelFilled(59, 59);
304 expectPixelFilled(60, 60); 290 expectPixelFilled(60, 60);
305 expectPixelFilled(69, 69); 291 expectPixelFilled(69, 69);
306 expectPixelUnfilled(70, 70); 292 expectPixelUnfilled(70, 70);
307 expectPixelUnfilled(0, 0); 293 expectPixelUnfilled(0, 0);
308 expectPixelUnfilled(80, 80); 294 expectPixelUnfilled(80, 80);
309 })); 295 }));
310 img.onError.listen((_) { 296 img.onError.listen((_) {
311 guardAsync(() { 297 guardAsync(() {
312 fail('URL failed to load.'); 298 fail('URL failed to load.');
313 }); 299 });
314 }); 300 });
315 img.src = dataUrl; 301 img.src = dataUrl;
316 }); 302 });
317 303
318 // Draw an image to the canvas from an image element and scale it. 304 // Draw an image to the canvas from an image element and scale it.
319 test('with 9 params', () { 305 test('drawImage from img element with 9 params', () {
320 otherContext.fillStyle = "blue"; 306 otherContext.fillStyle = "blue";
321 otherContext.fillRect(5, 5, 5, 5); 307 otherContext.fillRect(5, 5, 5, 5);
322 var dataUrl = otherCanvas.toDataUrl('image/gif'); 308 var dataUrl = otherCanvas.toDataUrl('image/gif');
323 var img = new ImageElement(); 309 var img = new ImageElement();
324 310
325 img.onLoad.listen(expectAsync1((_) { 311 img.onLoad.listen(expectAsync1((_) {
326 // This will take a 6x6 square from the first canvas from position 2,2 312 // This will take a 6x6 square from the first canvas from position 2,2
327 // and then scale it to a 20x20 square and place it to the second 313 // and then scale it to a 20x20 square and place it to the second canvas
328 // canvas at 50,50. 314 // at 50,50.
329 context.drawImageToRect(img, new Rect(50, 50, 20, 20), 315 context.drawImageToRect(img, new Rect(50, 50, 20, 20),
330 sourceRect: new Rect(2, 2, 6, 6)); 316 sourceRect: new Rect(2, 2, 6, 6));
331 317
332 checkPixel(readPixel(50, 50), [255, 0, 0, 255]); 318 checkPixel(readPixel(50, 50), [255, 0, 0, 255]);
333 checkPixel(readPixel(55, 55), [255, 0, 0, 255]); 319 checkPixel(readPixel(55, 55), [255, 0, 0, 255]);
334 checkPixel(readPixel(60, 50), [255, 0, 0, 255]); 320 checkPixel(readPixel(60, 50), [255, 0, 0, 255]);
335 checkPixel(readPixel(65, 65), [0, 0, 255, 255]); 321 checkPixel(readPixel(65, 65), [0, 0, 255, 255]);
336 checkPixel(readPixel(69, 69), [0, 0, 255, 255]); 322 checkPixel(readPixel(69, 69), [0, 0, 255, 255]);
337 323
338 expectPixelFilled(50, 50); 324 expectPixelFilled(50, 50);
339 expectPixelFilled(55, 55); 325 expectPixelFilled(55, 55);
340 expectPixelFilled(59, 59); 326 expectPixelFilled(59, 59);
341 expectPixelFilled(60, 60); 327 expectPixelFilled(60, 60);
342 expectPixelFilled(69, 69); 328 expectPixelFilled(69, 69);
343 expectPixelUnfilled(70, 70); 329 expectPixelUnfilled(70, 70);
344 expectPixelUnfilled(0, 0); 330 expectPixelUnfilled(0, 0);
345 expectPixelUnfilled(80, 80); 331 expectPixelUnfilled(80, 80);
346 })); 332 }));
347 img.onError.listen((_) { 333 img.onError.listen((_) {
348 guardAsync(() { 334 guardAsync(() {
349 fail('URL failed to load.'); 335 fail('URL failed to load.');
350 }); 336 });
351 }); 337 });
352 img.src = dataUrl; 338 img.src = dataUrl;
353 }); 339 });
354 });
355 340
356 // These videos and base64 strings are the same video, representing 2 341 // These base64 strings are the same video, representing 2 frames of 8x8 red
357 // frames of 8x8 red pixels. 342 // pixels.
358 // The videos were created with: 343 // The videos were created with:
359 // convert -size 8x8 xc:red blank1.jpg 344 // convert -size 8x8 xc:red blank1.jpg
360 // convert -size 8x8 xc:red blank2.jpg 345 // convert -size 8x8 xc:red blank2.jpg
361 // avconv -f image2 -i "blank%d.jpg" -c:v libx264 small.mp4 346 // avconv -f image2 -i "blank%d.jpg" -c:v libx264 small.mp4
362 // avconv -i small.mp4 small.webm 347 // python -m base64 -e small.mp4
363 // python -m base64 -e small.mp4 348 // avconv -i small.mp4 small.webm
364 // python -m base64 -e small.webm 349 // python -m base64 -e small.webm
365 var mp4VideoUrl = '/root_dart/tests/html/small.mp4'; 350 var mp4VideoUrl =
366 var webmVideoUrl = '/root_dart/tests/html/small.webm'; 351 'data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZn'
367 var mp4VideoDataUrl = 352 'JlZQAAAsdtZGF0AAACmwYF//+X3EXpvebZSLeWLNgg2SPu73gyNjQgLSBjb3JlIDEyMCByMj'
368 'data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAA' 353 'E1MSBhM2Y0NDA3IC0gSC4yNjQvTVBFRy00IEFWQyBjb2RlYyAtIENvcHlsZWZ0IDIwMDMtMj'
369 'AIZnJlZQAAAsdtZGF0AAACmwYF//+X3EXpvebZSLeWLNgg2SPu73gyNjQgLSBjb3JlID' 354 'AxMSAtIGh0dHA6Ly93d3cudmlkZW9sYW4ub3JnL3gyNjQuaHRtbCAtIG9wdGlvbnM6IGNhYm'
370 'EyMCByMjE1MSBhM2Y0NDA3IC0gSC4yNjQvTVBFRy00IEFWQyBjb2RlYyAtIENvcHlsZW' 355 'FjPTEgcmVmPTMgZGVibG9jaz0xOjA6MCBhbmFseXNlPTB4MToweDExMSBtZT1oZXggc3VibW'
371 'Z0IDIwMDMtMjAxMSAtIGh0dHA6Ly93d3cudmlkZW9sYW4ub3JnL3gyNjQuaHRtbCAtIG' 356 'U9NyBwc3k9MSBwc3lfcmQ9MS4wMDowLjAwIG1peGVkX3JlZj0wIG1lX3JhbmdlPTE2IGNocm'
372 '9wdGlvbnM6IGNhYmFjPTEgcmVmPTMgZGVibG9jaz0xOjA6MCBhbmFseXNlPTB4MToweD' 357 '9tYV9tZT0xIHRyZWxsaXM9MSA4eDhkY3Q9MCBjcW09MCBkZWFkem9uZT0yMSwxMSBmYXN0X3'
373 'ExMSBtZT1oZXggc3VibWU9NyBwc3k9MSBwc3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('drawImage_video_element', () {
414 setUp(setupFunc);
415 tearDown(tearDownFunc);
416 393
417 test('with 3 params', () { 394 // test('drawImage from video element with 3 params', () {
418 video.onCanPlay.listen(expectAsync1((_) { 395 // var video = new VideoElement();
419 context.drawImage(video, 50, 50); 396 //
397 // video.onLoadedData.listen(expectAsync1((_) {
398 // context.drawImage(video, 50, 50);
399 //
400 // expectPixelFilled(50, 50);
401 // expectPixelFilled(54, 54);
402 // expectPixelFilled(57, 57);
403 // expectPixelUnfilled(58, 58);
404 // expectPixelUnfilled(0, 0);
405 // expectPixelUnfilled(70, 70);
406 // }));
407 // video.onError.listen((_) {
408 // guardAsync(() {
409 // fail('URL failed to load.');
410 // });
411 // });
412 //
413 // if(video.canPlayType('video/webm; codecs="vp8.0, vorbis"', '') != '') {
414 // video.src = webmVideoUrl;
415 // } else if(video.canPlayType('video/mp4; codecs="avc1.4D401E, mp4a.40.2"' ,
416 // null) != '') {
417 // video.src = mp4VideoUrl;
418 // } else {
419 // logMessage('Video is not supported on this system.');
420 // }
421 // });
422 //
423 // test('drawImage from video element with 5 params', () {
424 // var video = new VideoElement();
425 //
426 // video.onLoadedData.listen(expectAsync1((_) {
427 // context.drawImageToRect(video, new Rect(50, 50, 20, 20));
428 //
429 // expectPixelFilled(50, 50);
430 // expectPixelFilled(55, 55);
431 // expectPixelFilled(59, 59);
432 // expectPixelFilled(60, 60);
433 // expectPixelFilled(69, 69);
434 // expectPixelUnfilled(70, 70);
435 // expectPixelUnfilled(0, 0);
436 // expectPixelUnfilled(80, 80);
437 // }));
438 // video.onError.listen((_) {
439 // guardAsync(() {
440 // fail('URL failed to load.');
441 // });
442 // });
443 //
444 // if(video.canPlayType('video/webm; codecs="vp8.0, vorbis"', '') != '') {
445 // video.src = webmVideoUrl;
446 // } else if(video.canPlayType('video/mp4; codecs="avc1.4D401E, mp4a.40.2"' ,
447 // null) != '') {
448 // video.src = mp4VideoUrl;
449 // } else {
450 // // TODO(amouravski): Better fallback?
451 // logMessage('Video is not supported on this system.');
452 // }
453 // });
454 //
455 // test('drawImage from video element with 9 params', () {
456 // var video = new VideoElement();
457 //
458 // video.onLoadedData.listen(expectAsync1((_) {
459 // context.drawImageToRect(video, new Rect(50, 50, 20, 20),
460 // sourceRect: new Rect(2, 2, 6, 6));
461 //
462 // expectPixelFilled(50, 50);
463 // expectPixelFilled(55, 55);
464 // expectPixelFilled(59, 59);
465 // expectPixelFilled(60, 60);
466 // expectPixelFilled(69, 69);
467 // expectPixelUnfilled(70, 70);
468 // expectPixelUnfilled(0, 0);
469 // expectPixelUnfilled(80, 80);
470 // }));
471 // video.onError.listen((_) {
472 // guardAsync(() {
473 // fail('URL failed to load.');
474 // });
475 // });
476 //
477 // if(video.canPlayType('video/webm; codecs="vp8.0, vorbis"', '') != '') {
478 // video.src = webmVideoUrl;
479 // } else if(video.canPlayType('video/mp4; codecs="avc1.4D401E, mp4a.40.2"' ,
480 // null) != '') {
481 // video.src = mp4VideoUrl;
482 // } else {
483 // // TODO(amouravski): Better fallback?
484 // logMessage('Video is not supported on this system.');
485 // }
486 // });
420 487
421 expectPixelFilled(50, 50); 488 test('drawImage from canvas element with 3 params', () {
422 expectPixelFilled(54, 54);
423 expectPixelFilled(57, 57);
424 expectPixelUnfilled(58, 58);
425 expectPixelUnfilled(0, 0);
426 expectPixelUnfilled(70, 70);
427 }));
428
429 video.onError.listen((_) {
430 guardAsync(() {
431 fail('URL failed to load.');
432 });
433 });
434
435 if(video.canPlayType('video/webm; codecs="vp8.0, vorbis"', '') != '') {
436 video.src = webmVideoUrl;
437 } else if(video.canPlayType('video/mp4; codecs="avc1.4D401E, mp4a.40.2"',
438 null) != '') {
439 video.src = mp4VideoUrl;
440 } else {
441 window.console.log('Video is not supported on this system.');
442 }
443 });
444
445 test('with 5 params', () {
446 video.onCanPlay.listen(expectAsync1((_) {
447 context.drawImageToRect(video, new Rect(50, 50, 20, 20));
448
449 expectPixelFilled(50, 50);
450 expectPixelFilled(55, 55);
451 expectPixelFilled(59, 59);
452 expectPixelFilled(60, 60);
453 expectPixelFilled(69, 69);
454 expectPixelUnfilled(70, 70);
455 expectPixelUnfilled(0, 0);
456 expectPixelUnfilled(80, 80);
457 }));
458 video.onError.listen((_) {
459 guardAsync(() {
460 fail('URL failed to load.');
461 });
462 });
463
464 if(video.canPlayType('video/webm; codecs="vp8.0, vorbis"', '') != '') {
465 video.src = webmVideoUrl;
466 } else if(video.canPlayType('video/mp4; codecs="avc1.4D401E, mp4a.40.2"',
467 null) != '') {
468 video.src = mp4VideoUrl;
469 } else {
470 // TODO(amouravski): Better fallback?
471 window.console.log('Video is not supported on this system.');
472 }
473 });
474
475 test('with 9 params', () {
476 video.onCanPlay.listen(expectAsync1((_) {
477 context.drawImageToRect(video, new Rect(50, 50, 20, 20),
478 sourceRect: new Rect(2, 2, 6, 6));
479
480 expectPixelFilled(50, 50);
481 expectPixelFilled(55, 55);
482 expectPixelFilled(59, 59);
483 expectPixelFilled(60, 60);
484 expectPixelFilled(69, 69);
485 expectPixelUnfilled(70, 70);
486 expectPixelUnfilled(0, 0);
487 expectPixelUnfilled(80, 80);
488 }));
489 video.onError.listen((_) {
490 guardAsync(() {
491 fail('URL failed to load.');
492 });
493 });
494
495 if(video.canPlayType('video/webm; codecs="vp8.0, vorbis"', '') != '') {
496 video.src = webmVideoUrl;
497 } else if(video.canPlayType('video/mp4; codecs="avc1.4D401E, mp4a.40.2"',
498 null) != '') {
499 video.src = mp4VideoUrl;
500 } else {
501 // TODO(amouravski): Better fallback?
502 window.console.log('Video is not supported on this system.');
503 }
504 });
505 });
506
507 group('drawImage_video_element_dataUrl', () {
508 setUp(setupFunc);
509 tearDown(tearDownFunc);
510
511 test('with 9 params', () {
512 video = new VideoElement();
513 canvas = new CanvasElement();
514 video.onCanPlay.listen(expectAsync1((_) {
515 context.drawImageToRect(video, new Rect(50, 50, 20, 20),
516 sourceRect: new Rect(2, 2, 6, 6));
517
518 expectPixelFilled(50, 50);
519 expectPixelFilled(55, 55);
520 expectPixelFilled(59, 59);
521 expectPixelFilled(60, 60);
522 expectPixelFilled(69, 69);
523 expectPixelUnfilled(70, 70);
524 expectPixelUnfilled(0, 0);
525 expectPixelUnfilled(80, 80);
526 }));
527 video.onError.listen((_) {
528 guardAsync(() {
529 fail('URL failed to load.');
530 });
531 });
532
533 if(video.canPlayType('video/webm; codecs="vp8.0, vorbis"', '') != '') {
534 video.src = webmVideoDataUrl;
535 } else if(video.canPlayType('video/mp4; codecs="avc1.4D401E, mp4a.40.2"',
536 null) != '') {
537 video.src = mp4VideoDataUrl;
538 } else {
539 // TODO(amouravski): Better fallback?
540 window.console.log('Video is not supported on this system.');
541 }
542 });
543 });
544
545 group('drawImage_canvas_element', () {
546 setUp(setupFunc);
547 tearDown(tearDownFunc);
548
549 test('with 3 params', () {
550 // Draw an image to the canvas from a canvas element. 489 // Draw an image to the canvas from a canvas element.
551 context.drawImage(otherCanvas, 50, 50); 490 context.drawImage(otherCanvas, 50, 50);
552 491
553 expectPixelFilled(50, 50); 492 expectPixelFilled(50, 50);
554 expectPixelFilled(55, 55); 493 expectPixelFilled(55, 55);
555 expectPixelFilled(59, 59); 494 expectPixelFilled(59, 59);
556 expectPixelUnfilled(60, 60); 495 expectPixelUnfilled(60, 60);
557 expectPixelUnfilled(0, 0); 496 expectPixelUnfilled(0, 0);
558 expectPixelUnfilled(70, 70); 497 expectPixelUnfilled(70, 70);
559 }); 498 });
560 test('with 5 params', () { 499 test('drawImage from canvas element with 5 params', () {
561 // Draw an image to the canvas from a canvas element. 500 // Draw an image to the canvas from a canvas element.
562 context.drawImageToRect(otherCanvas, new Rect(50, 50, 20, 20)); 501 context.drawImageToRect(otherCanvas, new Rect(50, 50, 20, 20));
563 502
564 expectPixelFilled(50, 50); 503 expectPixelFilled(50, 50);
565 expectPixelFilled(55, 55); 504 expectPixelFilled(55, 55);
566 expectPixelFilled(59, 59); 505 expectPixelFilled(59, 59);
567 expectPixelFilled(60, 60); 506 expectPixelFilled(60, 60);
568 expectPixelFilled(69, 69); 507 expectPixelFilled(69, 69);
569 expectPixelUnfilled(70, 70); 508 expectPixelUnfilled(70, 70);
570 expectPixelUnfilled(0, 0); 509 expectPixelUnfilled(0, 0);
571 expectPixelUnfilled(80, 80); 510 expectPixelUnfilled(80, 80);
572 }); 511 });
573 test('with 9 params', () { 512 test('drawImage from canvas element with 9 params', () {
574 // Draw an image to the canvas from a canvas element. 513 // Draw an image to the canvas from a canvas element.
575 otherContext.fillStyle = "blue"; 514 otherContext.fillStyle = "blue";
576 otherContext.fillRect(5, 5, 5, 5); 515 otherContext.fillRect(5, 5, 5, 5);
577 context.drawImageToRect(otherCanvas, new Rect(50, 50, 20, 20), 516 context.drawImageToRect(otherCanvas, new Rect(50, 50, 20, 20),
578 sourceRect: new Rect(2, 2, 6, 6)); 517 sourceRect: new Rect(2, 2, 6, 6));
579 518
580 checkPixel(readPixel(50, 50), [255, 0, 0, 255]); 519 checkPixel(readPixel(50, 50), [255, 0, 0, 255]);
581 checkPixel(readPixel(55, 55), [255, 0, 0, 255]); 520 checkPixel(readPixel(55, 55), [255, 0, 0, 255]);
582 checkPixel(readPixel(60, 50), [255, 0, 0, 255]); 521 checkPixel(readPixel(60, 50), [255, 0, 0, 255]);
583 checkPixel(readPixel(65, 65), [0, 0, 255, 255]); 522 checkPixel(readPixel(65, 65), [0, 0, 255, 255]);
584 checkPixel(readPixel(69, 69), [0, 0, 255, 255]); 523 checkPixel(readPixel(69, 69), [0, 0, 255, 255]);
585 expectPixelFilled(50, 50); 524 expectPixelFilled(50, 50);
586 expectPixelFilled(55, 55); 525 expectPixelFilled(55, 55);
587 expectPixelFilled(59, 59); 526 expectPixelFilled(59, 59);
588 expectPixelFilled(60, 60); 527 expectPixelFilled(60, 60);
589 expectPixelFilled(69, 69); 528 expectPixelFilled(69, 69);
590 expectPixelUnfilled(70, 70); 529 expectPixelUnfilled(70, 70);
591 expectPixelUnfilled(0, 0); 530 expectPixelUnfilled(0, 0);
592 expectPixelUnfilled(80, 80); 531 expectPixelUnfilled(80, 80);
593 }); 532 });
594 }); 533 });
595 } 534 }
OLDNEW
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tests/html/html.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698