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

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

Issue 226903002: tests/html: removed usage of deprecated unittest features (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 | « tests/html/canvas_test.dart ('k') | tests/html/dromaeo_smoke_test.dart » ('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; import '../../pkg/unittest/lib/unittes t.dart';
6 import '../../pkg/unittest/lib/html_individual_config.dart'; 6 import '../../pkg/unittest/lib/html_individual_config.dart';
7 import 'dart:html'; 7 import 'dart:html';
8 import 'dart:math'; 8 import 'dart:math';
9 9
10 // Some rounding errors in the browsers. 10 // Some rounding errors in the browsers.
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 context.drawImage(img, 50, 50); 343 context.drawImage(img, 50, 50);
344 344
345 expectPixelFilled(50, 50); 345 expectPixelFilled(50, 50);
346 expectPixelFilled(55, 55); 346 expectPixelFilled(55, 55);
347 expectPixelFilled(59, 59); 347 expectPixelFilled(59, 59);
348 expectPixelUnfilled(60, 60); 348 expectPixelUnfilled(60, 60);
349 expectPixelUnfilled(0, 0); 349 expectPixelUnfilled(0, 0);
350 expectPixelUnfilled(70, 70); 350 expectPixelUnfilled(70, 70);
351 })); 351 }));
352 img.onError.listen((_) { 352 img.onError.listen((_) {
353 guardAsync(() { 353 fail('URL failed to load.');
354 fail('URL failed to load.');
355 });
356 }); 354 });
357 img.src = dataUrl; 355 img.src = dataUrl;
358 }); 356 });
359 357
360 // Draw an image to the canvas from an image element and scale it. 358 // Draw an image to the canvas from an image element and scale it.
361 test('with 5 params', () { 359 test('with 5 params', () {
362 var dataUrl = otherCanvas.toDataUrl('image/gif'); 360 var dataUrl = otherCanvas.toDataUrl('image/gif');
363 var img = new ImageElement(); 361 var img = new ImageElement();
364 362
365 img.onLoad.listen(expectAsync((_) { 363 img.onLoad.listen(expectAsync((_) {
366 context.drawImageToRect(img, new Rectangle(50, 50, 20, 20)); 364 context.drawImageToRect(img, new Rectangle(50, 50, 20, 20));
367 365
368 expectPixelFilled(50, 50); 366 expectPixelFilled(50, 50);
369 expectPixelFilled(55, 55); 367 expectPixelFilled(55, 55);
370 expectPixelFilled(59, 59); 368 expectPixelFilled(59, 59);
371 expectPixelFilled(60, 60); 369 expectPixelFilled(60, 60);
372 expectPixelFilled(69, 69); 370 expectPixelFilled(69, 69);
373 expectPixelUnfilled(70, 70); 371 expectPixelUnfilled(70, 70);
374 expectPixelUnfilled(0, 0); 372 expectPixelUnfilled(0, 0);
375 expectPixelUnfilled(80, 80); 373 expectPixelUnfilled(80, 80);
376 })); 374 }));
377 img.onError.listen((_) { 375 img.onError.listen((_) {
378 guardAsync(() { 376 fail('URL failed to load.');
379 fail('URL failed to load.');
380 });
381 }); 377 });
382 img.src = dataUrl; 378 img.src = dataUrl;
383 }); 379 });
384 380
385 // Draw an image to the canvas from an image element and scale it. 381 // Draw an image to the canvas from an image element and scale it.
386 test('with 9 params', () { 382 test('with 9 params', () {
387 otherContext.fillStyle = "blue"; 383 otherContext.fillStyle = "blue";
388 otherContext.fillRect(5, 5, 5, 5); 384 otherContext.fillRect(5, 5, 5, 5);
389 var dataUrl = otherCanvas.toDataUrl('image/gif'); 385 var dataUrl = otherCanvas.toDataUrl('image/gif');
390 var img = new ImageElement(); 386 var img = new ImageElement();
(...skipping 14 matching lines...) Expand all
405 expectPixelFilled(50, 50); 401 expectPixelFilled(50, 50);
406 expectPixelFilled(55, 55); 402 expectPixelFilled(55, 55);
407 expectPixelFilled(59, 59); 403 expectPixelFilled(59, 59);
408 expectPixelFilled(60, 60); 404 expectPixelFilled(60, 60);
409 expectPixelFilled(69, 69); 405 expectPixelFilled(69, 69);
410 expectPixelUnfilled(70, 70); 406 expectPixelUnfilled(70, 70);
411 expectPixelUnfilled(0, 0); 407 expectPixelUnfilled(0, 0);
412 expectPixelUnfilled(80, 80); 408 expectPixelUnfilled(80, 80);
413 })); 409 }));
414 img.onError.listen((_) { 410 img.onError.listen((_) {
415 guardAsync(() { 411 fail('URL failed to load.');
416 fail('URL failed to load.');
417 });
418 }); 412 });
419 img.src = dataUrl; 413 img.src = dataUrl;
420 }); 414 });
421 }); 415 });
422 416
423 // These videos and base64 strings are the same video, representing 2 417 // These videos and base64 strings are the same video, representing 2
424 // frames of 8x8 red pixels. 418 // frames of 8x8 red pixels.
425 // The videos were created with: 419 // The videos were created with:
426 // convert -size 8x8 xc:red blank1.jpg 420 // convert -size 8x8 xc:red blank1.jpg
427 // convert -size 8x8 xc:red blank2.jpg 421 // convert -size 8x8 xc:red blank2.jpg
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 481
488 expectPixelFilled(50, 50); 482 expectPixelFilled(50, 50);
489 expectPixelFilled(54, 54); 483 expectPixelFilled(54, 54);
490 expectPixelFilled(57, 57); 484 expectPixelFilled(57, 57);
491 expectPixelUnfilled(58, 58); 485 expectPixelUnfilled(58, 58);
492 expectPixelUnfilled(0, 0); 486 expectPixelUnfilled(0, 0);
493 expectPixelUnfilled(70, 70); 487 expectPixelUnfilled(70, 70);
494 })); 488 }));
495 489
496 video.onError.listen((_) { 490 video.onError.listen((_) {
497 guardAsync(() { 491 fail('URL failed to load.');
498 fail('URL failed to load.');
499 });
500 }); 492 });
501 493
502 if(video.canPlayType('video/webm; codecs="vp8.0, vorbis"', '') != '') { 494 if(video.canPlayType('video/webm; codecs="vp8.0, vorbis"', '') != '') {
503 video.src = webmVideoUrl; 495 video.src = webmVideoUrl;
504 } else if(video.canPlayType('video/mp4; codecs="avc1.4D401E, mp4a.40.2"', 496 } else if(video.canPlayType('video/mp4; codecs="avc1.4D401E, mp4a.40.2"',
505 null) != '') { 497 null) != '') {
506 video.src = mp4VideoUrl; 498 video.src = mp4VideoUrl;
507 } else { 499 } else {
508 window.console.log('Video is not supported on this system.'); 500 window.console.log('Video is not supported on this system.');
509 } 501 }
510 }); 502 });
511 503
512 test('with 5 params', () { 504 test('with 5 params', () {
513 video.onCanPlay.listen(expectAsync((_) { 505 video.onCanPlay.listen(expectAsync((_) {
514 context.drawImageToRect(video, new Rectangle(50, 50, 20, 20)); 506 context.drawImageToRect(video, new Rectangle(50, 50, 20, 20));
515 507
516 expectPixelFilled(50, 50); 508 expectPixelFilled(50, 50);
517 expectPixelFilled(55, 55); 509 expectPixelFilled(55, 55);
518 expectPixelFilled(59, 59); 510 expectPixelFilled(59, 59);
519 expectPixelFilled(60, 60); 511 expectPixelFilled(60, 60);
520 expectPixelFilled(69, 69); 512 expectPixelFilled(69, 69);
521 expectPixelUnfilled(70, 70); 513 expectPixelUnfilled(70, 70);
522 expectPixelUnfilled(0, 0); 514 expectPixelUnfilled(0, 0);
523 expectPixelUnfilled(80, 80); 515 expectPixelUnfilled(80, 80);
524 })); 516 }));
525 video.onError.listen((_) { 517 video.onError.listen((_) {
526 guardAsync(() { 518 fail('URL failed to load.');
527 fail('URL failed to load.');
528 });
529 }); 519 });
530 520
531 if(video.canPlayType('video/webm; codecs="vp8.0, vorbis"', '') != '') { 521 if(video.canPlayType('video/webm; codecs="vp8.0, vorbis"', '') != '') {
532 video.src = webmVideoUrl; 522 video.src = webmVideoUrl;
533 } else if(video.canPlayType('video/mp4; codecs="avc1.4D401E, mp4a.40.2"', 523 } else if(video.canPlayType('video/mp4; codecs="avc1.4D401E, mp4a.40.2"',
534 null) != '') { 524 null) != '') {
535 video.src = mp4VideoUrl; 525 video.src = mp4VideoUrl;
536 } else { 526 } else {
537 // TODO(amouravski): Better fallback? 527 // TODO(amouravski): Better fallback?
538 window.console.log('Video is not supported on this system.'); 528 window.console.log('Video is not supported on this system.');
539 } 529 }
540 }); 530 });
541 531
542 test('with 9 params', () { 532 test('with 9 params', () {
543 video.onCanPlay.listen(expectAsync((_) { 533 video.onCanPlay.listen(expectAsync((_) {
544 context.drawImageToRect(video, new Rectangle(50, 50, 20, 20), 534 context.drawImageToRect(video, new Rectangle(50, 50, 20, 20),
545 sourceRect: new Rectangle(2, 2, 6, 6)); 535 sourceRect: new Rectangle(2, 2, 6, 6));
546 536
547 expectPixelFilled(50, 50); 537 expectPixelFilled(50, 50);
548 expectPixelFilled(55, 55); 538 expectPixelFilled(55, 55);
549 expectPixelFilled(59, 59); 539 expectPixelFilled(59, 59);
550 expectPixelFilled(60, 60); 540 expectPixelFilled(60, 60);
551 expectPixelFilled(69, 69); 541 expectPixelFilled(69, 69);
552 expectPixelUnfilled(70, 70); 542 expectPixelUnfilled(70, 70);
553 expectPixelUnfilled(0, 0); 543 expectPixelUnfilled(0, 0);
554 expectPixelUnfilled(80, 80); 544 expectPixelUnfilled(80, 80);
555 })); 545 }));
556 video.onError.listen((_) { 546 video.onError.listen((_) {
557 guardAsync(() { 547 fail('URL failed to load.');
558 fail('URL failed to load.');
559 });
560 }); 548 });
561 549
562 if(video.canPlayType('video/webm; codecs="vp8.0, vorbis"', '') != '') { 550 if(video.canPlayType('video/webm; codecs="vp8.0, vorbis"', '') != '') {
563 video.src = webmVideoUrl; 551 video.src = webmVideoUrl;
564 } else if(video.canPlayType('video/mp4; codecs="avc1.4D401E, mp4a.40.2"', 552 } else if(video.canPlayType('video/mp4; codecs="avc1.4D401E, mp4a.40.2"',
565 null) != '') { 553 null) != '') {
566 video.src = mp4VideoUrl; 554 video.src = mp4VideoUrl;
567 } else { 555 } else {
568 // TODO(amouravski): Better fallback? 556 // TODO(amouravski): Better fallback?
569 window.console.log('Video is not supported on this system.'); 557 window.console.log('Video is not supported on this system.');
(...skipping 15 matching lines...) Expand all
585 expectPixelFilled(50, 50); 573 expectPixelFilled(50, 50);
586 expectPixelFilled(55, 55); 574 expectPixelFilled(55, 55);
587 expectPixelFilled(59, 59); 575 expectPixelFilled(59, 59);
588 expectPixelFilled(60, 60); 576 expectPixelFilled(60, 60);
589 expectPixelFilled(69, 69); 577 expectPixelFilled(69, 69);
590 expectPixelUnfilled(70, 70); 578 expectPixelUnfilled(70, 70);
591 expectPixelUnfilled(0, 0); 579 expectPixelUnfilled(0, 0);
592 expectPixelUnfilled(80, 80); 580 expectPixelUnfilled(80, 80);
593 })); 581 }));
594 video.onError.listen((_) { 582 video.onError.listen((_) {
595 guardAsync(() { 583 fail('URL failed to load.');
596 fail('URL failed to load.');
597 });
598 }); 584 });
599 585
600 if(video.canPlayType('video/webm; codecs="vp8.0, vorbis"', '') != '') { 586 if(video.canPlayType('video/webm; codecs="vp8.0, vorbis"', '') != '') {
601 video.src = webmVideoDataUrl; 587 video.src = webmVideoDataUrl;
602 } else if(video.canPlayType('video/mp4; codecs="avc1.4D401E, mp4a.40.2"', 588 } else if(video.canPlayType('video/mp4; codecs="avc1.4D401E, mp4a.40.2"',
603 null) != '') { 589 null) != '') {
604 video.src = mp4VideoDataUrl; 590 video.src = mp4VideoDataUrl;
605 } else { 591 } else {
606 // TODO(amouravski): Better fallback? 592 // TODO(amouravski): Better fallback?
607 window.console.log('Video is not supported on this system.'); 593 window.console.log('Video is not supported on this system.');
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 724
739 // The box does not draw after 20 pixels. 725 // The box does not draw after 20 pixels.
740 expectPixelUnfilled(x - 10, y); 726 expectPixelUnfilled(x - 10, y);
741 expectPixelUnfilled(x + maxWidth + 1, y); 727 expectPixelUnfilled(x + maxWidth + 1, y);
742 expectPixelUnfilled(x + maxWidth + 20, y); 728 expectPixelUnfilled(x + maxWidth + 20, y);
743 expectPixelFilled(x, y); 729 expectPixelFilled(x, y);
744 expectPixelFilled(x + 10, y); 730 expectPixelFilled(x + 10, y);
745 }); 731 });
746 }); 732 });
747 } 733 }
OLDNEW
« no previous file with comments | « tests/html/canvas_test.dart ('k') | tests/html/dromaeo_smoke_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698