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

Unified 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: 0 diff for dartium. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/html/dart2js/html_dart2js.dart ('k') | tools/dom/scripts/systemhtml.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/canvasrenderingcontext2d_test.dart
diff --git a/tests/html/canvasrenderingcontext2d_test.dart b/tests/html/canvasrenderingcontext2d_test.dart
index da9338b8ad2c12a451be3ec10fd6f82b1a66baab..32beb1e6ae8781458db435d68a43f60ea8659320 100644
--- a/tests/html/canvasrenderingcontext2d_test.dart
+++ b/tests/html/canvasrenderingcontext2d_test.dart
@@ -674,4 +674,69 @@ main() {
//var pattern2 = context.createPatternFromImage(new ImageElement(), '');
});
});
+
+ group('fillText', () {
+ setUp(setupFunc);
+ tearDown(tearDownFunc);
+
+ test('without maxWidth', () {
+ context.font = '40pt Garamond';
+ context.fillStyle = 'blue';
+
+ // Draw a blue box.
+ context.fillText('█', 50, 50);
+
+ var width = context.measureText('█').width;
+
+ checkPixel(readPixel(50, 50), [0, 0, 255, 255]);
+ checkPixel(readPixel(60, 50), [0, 0, 255, 255]);
+
+ expectPixelUnfilled(40, 50);
+ expectPixelFilled(50, 50);
+ expectPixelFilled(60, 50);
+
+ // The box does not draw after `width` pixels.
+ expectPixelFilled(50 + width, 50);
+ expectPixelUnfilled(50 + width + 1, 50);
+ });
+
+ test('with maxWidth null', () {
+ context.font = '40pt Garamond';
+ context.fillStyle = 'blue';
+
+ // Draw a blue box with null maxWidth.
+ context.fillText('█', 50, 50, null);
+
+ var width = context.measureText('█').width;
+
+ checkPixel(readPixel(50, 50), [0, 0, 255, 255]);
+ checkPixel(readPixel(60, 50), [0, 0, 255, 255]);
+
+ expectPixelUnfilled(40, 50);
+ expectPixelFilled(50, 50);
+ expectPixelFilled(60, 50);
+
+ // The box does not draw after `width` pixels.
+ expectPixelFilled(50 + width, 50);
+ expectPixelUnfilled(50 + width + 1, 50);
+ });
+
+ test('with maxWidth defined', () {
+ context.font = '40pt Garamond';
+ context.fillStyle = 'blue';
+
+ // Draw a blue box that's at most 20 pixels wide.
+ context.fillText('█', 50, 50, 20);
+
+ checkPixel(readPixel(50, 50), [0, 0, 255, 255]);
+ checkPixel(readPixel(60, 50), [0, 0, 255, 255]);
+
+ // The box does not draw after 20 pixels.
+ expectPixelUnfilled(40, 50);
+ expectPixelUnfilled(71, 50);
+ expectPixelUnfilled(90, 50);
+ expectPixelFilled(50, 50);
+ expectPixelFilled(60, 50);
+ });
+ });
}
« no previous file with comments | « sdk/lib/html/dart2js/html_dart2js.dart ('k') | tools/dom/scripts/systemhtml.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698