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

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

Issue 29273005: CanvasRenderingContext2D.fillText now works correctly with null maxWidth. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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
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 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 var other = context.createImageDataFromImageData(imageData); 667 var other = context.createImageDataFromImageData(imageData);
668 expect(other.width, 15); 668 expect(other.width, 15);
669 expect(other.height, 15); 669 expect(other.height, 15);
670 }); 670 });
671 671
672 test('createPattern', () { 672 test('createPattern', () {
673 var pattern = context.createPattern(new CanvasElement(), ''); 673 var pattern = context.createPattern(new CanvasElement(), '');
674 //var pattern2 = context.createPatternFromImage(new ImageElement(), ''); 674 //var pattern2 = context.createPatternFromImage(new ImageElement(), '');
675 }); 675 });
676 }); 676 });
677
678 group('fillText', () {
679 setUp(setupFunc);
680 tearDown(tearDownFunc);
681
682 test('with maxWidth defined', () {
683 context.font = '40pt Garamond';
684 context.fillStyle = 'blue';
685
686 // Draw a blue box that's at most 20 pixels wide.
687 context.fillText('█', 50, 50, 20);
688
689 checkPixel(readPixel(50, 50), [0, 0, 255, 255]);
690 checkPixel(readPixel(60, 50), [0, 0, 255, 255]);
691
692 // The box does not draw after 20 pixels.
693 expectPixelUnfilled(40, 50);
694 expectPixelUnfilled(71, 50);
695 expectPixelUnfilled(90, 50);
696 expectPixelFilled(50, 50);
697 expectPixelFilled(60, 50);
698 });
699
700 test('with maxWidth null', () {
701 context.font = '40pt Garamond';
702 context.fillStyle = 'blue';
703
704 // Draw a blue box with null maxWidth.
705 context.fillText('█', 50, 50, null);
706
707 checkPixel(readPixel(50, 50), [0, 0, 255, 255]);
708 checkPixel(readPixel(60, 50), [0, 0, 255, 255]);
709
710 expectPixelUnfilled(40, 50);
711 expectPixelUnfilled(90, 50);
712 expectPixelFilled(50, 50);
713 expectPixelFilled(60, 50);
714 expectPixelFilled(70, 50);
715 });
716 });
677 } 717 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698