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

Unified Diff: tests/html/canvasrenderingcontext2d_test.dart

Issue 33833003: Updated tests for fillText to better account for off-by-one errors. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | 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 32beb1e6ae8781458db435d68a43f60ea8659320..9cafb0d8c9f5296b077b44dadae515133c010ea5 100644
--- a/tests/html/canvasrenderingcontext2d_test.dart
+++ b/tests/html/canvasrenderingcontext2d_test.dart
@@ -679,25 +679,28 @@ main() {
setUp(setupFunc);
tearDown(tearDownFunc);
+ final x = 20;
+ final y = 20;
+
test('without maxWidth', () {
context.font = '40pt Garamond';
context.fillStyle = 'blue';
// Draw a blue box.
- context.fillText('█', 50, 50);
+ context.fillText('█', x, y);
var width = context.measureText('█').width;
- checkPixel(readPixel(50, 50), [0, 0, 255, 255]);
- checkPixel(readPixel(60, 50), [0, 0, 255, 255]);
+ checkPixel(readPixel(x, y), [0, 0, 255, 255]);
+ checkPixel(readPixel(x + 10, y), [0, 0, 255, 255]);
- expectPixelUnfilled(40, 50);
- expectPixelFilled(50, 50);
- expectPixelFilled(60, 50);
+ expectPixelUnfilled(x - 10, y);
+ expectPixelFilled(x, y);
+ expectPixelFilled(x + 10, y);
// The box does not draw after `width` pixels.
- expectPixelFilled(50 + width, 50);
- expectPixelUnfilled(50 + width + 1, 50);
+ expectPixelFilled(x + width - 1, y);
+ expectPixelUnfilled(x + width + 1, y);
});
test('with maxWidth null', () {
@@ -705,38 +708,40 @@ main() {
context.fillStyle = 'blue';
// Draw a blue box with null maxWidth.
- context.fillText('█', 50, 50, null);
+ context.fillText('█', x, y, null);
var width = context.measureText('█').width;
- checkPixel(readPixel(50, 50), [0, 0, 255, 255]);
- checkPixel(readPixel(60, 50), [0, 0, 255, 255]);
+ checkPixel(readPixel(x, y), [0, 0, 255, 255]);
+ checkPixel(readPixel(x + 10, y), [0, 0, 255, 255]);
- expectPixelUnfilled(40, 50);
- expectPixelFilled(50, 50);
- expectPixelFilled(60, 50);
+ expectPixelUnfilled(x - 10, y);
+ expectPixelFilled(x, y);
+ expectPixelFilled(x + 10, y);
// The box does not draw after `width` pixels.
- expectPixelFilled(50 + width, 50);
- expectPixelUnfilled(50 + width + 1, 50);
+ expectPixelFilled(x + width - 1, y);
+ expectPixelUnfilled(x + width + 1, y);
});
test('with maxWidth defined', () {
context.font = '40pt Garamond';
context.fillStyle = 'blue';
+ final maxWidth = 20;
+
// Draw a blue box that's at most 20 pixels wide.
- context.fillText('█', 50, 50, 20);
+ context.fillText('█', x, y, maxWidth);
- checkPixel(readPixel(50, 50), [0, 0, 255, 255]);
- checkPixel(readPixel(60, 50), [0, 0, 255, 255]);
+ checkPixel(readPixel(x, y), [0, 0, 255, 255]);
+ checkPixel(readPixel(x + 10, y), [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);
+ expectPixelUnfilled(x - 10, y);
+ expectPixelUnfilled(x + maxWidth + 1, y);
+ expectPixelUnfilled(x + maxWidth + 20, y);
+ expectPixelFilled(x, y);
+ expectPixelFilled(x + 10, y);
});
});
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698