forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add web engine screenshot (scuba) tests (flutter#12353)
* Import all golden files and tests from internal repo. * Adapt test files to new screenshot API, and tweak some settings. (Check PR to see individual changes to each file) Fixes flutter/flutter#40975
- Loading branch information
Showing
131 changed files
with
2,137 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+522 Bytes
lib/web_ui/test/golden_files/engine/bitmap_canvas_fills_color_when_transformed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+525 Bytes
lib/web_ui/test/golden_files/engine/bitmap_canvas_fills_paint_when_transformed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.5 KB
lib/web_ui/test/golden_files/engine/canvas_drrect_overlapping_radius.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.96 KB
lib/web_ui/test/golden_files/engine/canvas_rrect_overlapping_radius.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.37 KB
...ui/test/golden_files/engine/compositing_clip_rect_with_offset_and_transform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.11 KB
lib/web_ui/test/golden_files/engine/compositing_cull_rect_fills_layer_clip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.79 KB
.../golden_files/engine/compositing_cull_rect_intersects_clip_and_paint_bounds.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.85 KB
..._ui/test/golden_files/engine/compositing_cull_rect_offset_inside_layer_clip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.49 KB
lib/web_ui/test/golden_files/engine/compositing_cull_rect_rotated.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.38 KB
lib/web_ui/test/golden_files/engine/compositing_shifted_clip_rect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.53 KB
lib/web_ui/test/golden_files/engine/compositing_shifted_clip_rrect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.26 KB
lib/web_ui/test/golden_files/engine/compositing_shifted_physical_shape_clip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+909 Bytes
lib/web_ui/test/golden_files/engine/misaligned_pixels_in_canvas_test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.5 KB
...n_files/engine/multiline_text_clipping_path_BitmapCanvas+canvas_measurement.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.5 KB
lib/web_ui/test/golden_files/engine/multiline_text_clipping_path_BitmapCanvas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+15.2 KB
lib/web_ui/test/golden_files/engine/multiline_text_clipping_path_HoudiniCanvas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.1 KB
...n_files/engine/multiline_text_clipping_rect_BitmapCanvas+canvas_measurement.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.1 KB
lib/web_ui/test/golden_files/engine/multiline_text_clipping_rect_BitmapCanvas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10 KB
lib/web_ui/test/golden_files/engine/multiline_text_clipping_rect_HoudiniCanvas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.26 KB
lib/web_ui/test/golden_files/engine/multiline_text_clipping_rect_translate.png
Oops, something went wrong.
Binary file added
BIN
+8.92 KB
...gine/multiline_text_clipping_rect_translate_BitmapCanvas+canvas_measurement.png
Oops, something went wrong.
Binary file added
BIN
+8.92 KB
...est/golden_files/engine/multiline_text_clipping_rect_translate_BitmapCanvas.png
Oops, something went wrong.
Binary file added
BIN
+8.78 KB
...st/golden_files/engine/multiline_text_clipping_rect_translate_HoudiniCanvas.png
Oops, something went wrong.
Binary file added
BIN
+10.3 KB
lib/web_ui/test/golden_files/engine/multiline_text_clipping_roundrect.png
Oops, something went wrong.
Binary file added
BIN
+10.7 KB
...es/engine/multiline_text_clipping_roundrect_BitmapCanvas+canvas_measurement.png
Oops, something went wrong.
Binary file added
BIN
+11.2 KB
..._ui/test/golden_files/engine/multiline_text_clipping_roundrect_BitmapCanvas.png
Oops, something went wrong.
Binary file added
BIN
+10.6 KB
...ui/test/golden_files/engine/multiline_text_clipping_roundrect_HoudiniCanvas.png
Oops, something went wrong.
Binary file added
BIN
+12.6 KB
lib/web_ui/test/golden_files/engine/multiline_text_clipping_stack1.png
Oops, something went wrong.
Binary file added
BIN
+10.4 KB
...files/engine/multiline_text_clipping_stack1_BitmapCanvas+canvas_measurement.png
Oops, something went wrong.
Binary file added
BIN
+11.5 KB
...web_ui/test/golden_files/engine/multiline_text_clipping_stack1_BitmapCanvas.png
Oops, something went wrong.
Binary file added
BIN
+5.12 KB
...eb_ui/test/golden_files/engine/multiline_text_clipping_stack1_HoudiniCanvas.png
Oops, something went wrong.
Binary file added
BIN
+2.09 KB
...lden_files/engine/paint_bounds_for_clip_rect_intersects_paint_left_to_right.png
Oops, something went wrong.
Binary file added
BIN
+2.09 KB
...lden_files/engine/paint_bounds_for_clip_rect_intersects_paint_top_to_bottom.png
Oops, something went wrong.
Binary file added
BIN
+2.77 KB
lib/web_ui/test/golden_files/engine/paint_bounds_for_clip_rect_rotated.png
Oops, something went wrong.
Binary file added
BIN
+2.14 KB
lib/web_ui/test/golden_files/engine/paint_bounds_for_clip_rect_simple.png
Oops, something went wrong.
Binary file added
BIN
+2.08 KB
lib/web_ui/test/golden_files/engine/paint_bounds_for_clip_rects_intersect.png
Oops, something went wrong.
Binary file added
BIN
+3.36 KB
lib/web_ui/test/golden_files/engine/paint_bounds_for_complex_transform.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file added
BIN
+2.04 KB
lib/web_ui/test/golden_files/engine/paint_bounds_for_draw_drrect_empty.png
Oops, something went wrong.
Oops, something went wrong.
Binary file added
BIN
+2.92 KB
...web_ui/test/golden_files/engine/paint_bounds_for_draw_line_exceeding_limits.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file added
BIN
+2.16 KB
lib/web_ui/test/golden_files/engine/paint_bounds_for_draw_paragraph.png
Oops, something went wrong.
Binary file added
BIN
+2.16 KB
lib/web_ui/test/golden_files/engine/paint_bounds_for_draw_paragraph_multi_line.png
Oops, something went wrong.
Oops, something went wrong.
Binary file added
BIN
+2.06 KB
...web_ui/test/golden_files/engine/paint_bounds_for_draw_rect_exceeding_limits.png
Oops, something went wrong.
Binary file added
BIN
+2.3 KB
lib/web_ui/test/golden_files/engine/paint_bounds_for_draw_round_rect.png
Oops, something went wrong.
Binary file added
BIN
+977 KB
lib/web_ui/test/golden_files/engine/paint_bounds_for_empty_canvas.diff..png
Oops, something went wrong.
Binary file added
BIN
+2.05 KB
lib/web_ui/test/golden_files/engine/paint_bounds_for_empty_canvas.out..png
Oops, something went wrong.
Binary file added
BIN
+2.04 KB
lib/web_ui/test/golden_files/engine/paint_bounds_for_empty_canvas.png
Oops, something went wrong.
Binary file added
BIN
+2.18 KB
lib/web_ui/test/golden_files/engine/paint_bounds_for_line_rotated.png
Oops, something went wrong.
Binary file added
BIN
+3.33 KB
...b_ui/test/golden_files/engine/paint_bounds_for_path_with_line_and_roundrect.png
Oops, something went wrong.
Binary file added
BIN
+3.18 KB
lib/web_ui/test/golden_files/engine/paint_bounds_for_path_with_shadow.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file added
BIN
+2.08 KB
lib/web_ui/test/golden_files/engine/paint_bounds_for_scale_negative.png
Oops, something went wrong.
Binary file added
BIN
+2.25 KB
lib/web_ui/test/golden_files/engine/paint_bounds_for_skew_horizontally.png
Oops, something went wrong.
Binary file added
BIN
+2.31 KB
lib/web_ui/test/golden_files/engine/paint_bounds_for_skew_vertically.png
Oops, something went wrong.
Binary file added
BIN
+18.9 KB
...ngine/paint_bounds_for_text_decorationStyle_BitmapCanvas+canvas_measurement.png
Oops, something went wrong.
Binary file added
BIN
+18.9 KB
...test/golden_files/engine/paint_bounds_for_text_decorationStyle_BitmapCanvas.png
Oops, something went wrong.
Binary file added
BIN
+18.9 KB
...ui/test/golden_files/engine/paint_bounds_for_text_decorationStyle_DomCanvas.png
Oops, something went wrong.
Binary file added
BIN
+18.9 KB
...est/golden_files/engine/paint_bounds_for_text_decorationStyle_HoudiniCanvas.png
Oops, something went wrong.
Binary file added
BIN
+15.4 KB
...est/golden_files/engine/paint_bounds_for_text_decorationStyle_bitmap_canvas.png
Oops, something went wrong.
Binary file added
BIN
+15.4 KB
...i/test/golden_files/engine/paint_bounds_for_text_decorationStyle_dom_canvas.png
Oops, something went wrong.
Binary file added
BIN
+29.2 KB
...les/engine/paint_bounds_for_text_decoration_BitmapCanvas+canvas_measurement.png
Oops, something went wrong.
Binary file added
BIN
+29.2 KB
...b_ui/test/golden_files/engine/paint_bounds_for_text_decoration_BitmapCanvas.png
Oops, something went wrong.
Binary file added
BIN
+29.2 KB
lib/web_ui/test/golden_files/engine/paint_bounds_for_text_decoration_DomCanvas.png
Oops, something went wrong.
Binary file added
BIN
+29.2 KB
..._ui/test/golden_files/engine/paint_bounds_for_text_decoration_HoudiniCanvas.png
Oops, something went wrong.
Binary file added
BIN
+22.2 KB
..._ui/test/golden_files/engine/paint_bounds_for_text_decoration_bitmap_canvas.png
Oops, something went wrong.
Binary file added
BIN
+22.2 KB
...web_ui/test/golden_files/engine/paint_bounds_for_text_decoration_dom_canvas.png
Oops, something went wrong.
Binary file added
BIN
+19.8 KB
.../paint_bounds_for_text_style_letter_spacing_BitmapCanvas+canvas_measurement.png
Oops, something went wrong.
Binary file added
BIN
+19.8 KB
...golden_files/engine/paint_bounds_for_text_style_letter_spacing_BitmapCanvas.png
Oops, something went wrong.
Binary file added
BIN
+20.3 KB
...st/golden_files/engine/paint_bounds_for_text_style_letter_spacing_DomCanvas.png
Oops, something went wrong.
Binary file added
BIN
+20.3 KB
...olden_files/engine/paint_bounds_for_text_style_letter_spacing_HoudiniCanvas.png
Oops, something went wrong.
Binary file added
BIN
+18.2 KB
...olden_files/engine/paint_bounds_for_text_style_letter_spacing_bitmap_canvas.png
Oops, something went wrong.
Binary file added
BIN
+18.2 KB
...t/golden_files/engine/paint_bounds_for_text_style_letter_spacing_dom_canvas.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file added
BIN
+15.5 KB
...ui/test/golden_files/engine/text_background_BitmapCanvas+canvas_measurement.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file added
BIN
+15.5 KB
lib/web_ui/test/golden_files/engine/text_background_HoudiniCanvas.png
Oops, something went wrong.
Binary file added
BIN
+9.19 KB
...t/golden_files/engine/text_long_unbreakable_BitmapCanvas+canvas_measurement.png
Oops, something went wrong.
Binary file added
BIN
+9.11 KB
lib/web_ui/test/golden_files/engine/text_long_unbreakable_BitmapCanvas.png
Oops, something went wrong.
Binary file added
BIN
+9.1 KB
lib/web_ui/test/golden_files/engine/text_long_unbreakable_DomCanvas.png
Oops, something went wrong.
Binary file added
BIN
+9.1 KB
lib/web_ui/test/golden_files/engine/text_long_unbreakable_HoudiniCanvas.png
Oops, something went wrong.
Binary file added
BIN
+23 KB
..._ui/test/golden_files/engine/text_max_lines_BitmapCanvas+canvas_measurement.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file added
BIN
+18.3 KB
...n_files/engine/text_max_lines_with_ellipsis_BitmapCanvas+canvas_measurement.png
Oops, something went wrong.
Binary file added
BIN
+18.6 KB
lib/web_ui/test/golden_files/engine/text_max_lines_with_ellipsis_BitmapCanvas.png
Oops, something went wrong.
Binary file added
BIN
+18.6 KB
lib/web_ui/test/golden_files/engine/text_max_lines_with_ellipsis_DomCanvas.png
Oops, something went wrong.
Binary file added
BIN
+18.6 KB
lib/web_ui/test/golden_files/engine/text_max_lines_with_ellipsis_HoudiniCanvas.png
Oops, something went wrong.
86 changes: 86 additions & 0 deletions
86
lib/web_ui/test/golden_tests/engine/canvas_rrect_scuba_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'dart:html' as html; | ||
|
||
import 'package:ui/src/engine.dart'; | ||
import 'package:ui/ui.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
import 'package:web_engine_tester/golden_tester.dart'; | ||
|
||
void main() async { | ||
final Rect region = Rect.fromLTWH(8, 8, 500, 100); // Compensate for old scuba tester padding | ||
|
||
BitmapCanvas canvas; | ||
|
||
final PaintData niceRRectPaint = PaintData() | ||
..color = const Color.fromRGBO(250, 186, 218, 1.0) // #fabada | ||
..style = PaintingStyle.fill; | ||
|
||
// Some values to see how the algo behaves as radius get absurdly large | ||
const List<double> rRectRadii = <double>[0, 10, 20, 80, 8000]; | ||
|
||
const Radius someFixedRadius = Radius.circular(10); | ||
|
||
setUp(() { | ||
canvas = BitmapCanvas(const Rect.fromLTWH(0, 0, 500, 100)); | ||
canvas.translate(10, 10); // Center | ||
}); | ||
|
||
tearDown(() { | ||
canvas.rootElement.remove(); | ||
}); | ||
|
||
test('round square with big (equal) radius ends up as a circle', () async { | ||
for (int i = 0; i < 5; i++) { | ||
canvas.drawRRect( | ||
RRect.fromRectAndRadius(Rect.fromLTWH(100 * i.toDouble(), 0, 80, 80), | ||
Radius.circular(rRectRadii[i])), | ||
niceRRectPaint); | ||
} | ||
|
||
html.document.body.append(canvas.rootElement); | ||
await matchGoldenFile('engine/canvas_rrect_round_square.png', region: region); | ||
}, timeout: const Timeout(Duration(seconds: 10))); | ||
|
||
test('round rect with big radius scale down smaller radius', () async { | ||
for (int i = 0; i < 5; i++) { | ||
final Radius growingRadius = Radius.circular(rRectRadii[i]); | ||
final RRect rrect = RRect.fromRectAndCorners( | ||
Rect.fromLTWH(100 * i.toDouble(), 0, 80, 80), | ||
bottomRight: someFixedRadius, | ||
topRight: growingRadius, | ||
bottomLeft: growingRadius); | ||
|
||
canvas.drawRRect(rrect, niceRRectPaint); | ||
} | ||
|
||
html.document.body.append(canvas.rootElement); | ||
await matchGoldenFile('engine/canvas_rrect_overlapping_radius.png', region: region); | ||
}, timeout: const Timeout(Duration(seconds: 10))); | ||
|
||
test('diff round rect with big radius scale down smaller radius', () async { | ||
for (int i = 0; i < 5; i++) { | ||
final Radius growingRadius = Radius.circular(rRectRadii[i]); | ||
final RRect outerRRect = RRect.fromRectAndCorners( | ||
Rect.fromLTWH(100 * i.toDouble(), 0, 80, 80), | ||
bottomRight: someFixedRadius, | ||
topRight: growingRadius, | ||
bottomLeft: growingRadius); | ||
|
||
// Inner is half of outer, but offset a little so it looks nicer | ||
final RRect innerRRect = RRect.fromRectAndCorners( | ||
Rect.fromLTWH(100 * i.toDouble() + 5, 5, 40, 40), | ||
bottomRight: someFixedRadius / 2, | ||
topRight: growingRadius / 2, | ||
bottomLeft: growingRadius / 2); | ||
|
||
canvas.drawDRRect(outerRRect, innerRRect, niceRRectPaint); | ||
} | ||
|
||
html.document.body.append(canvas.rootElement); | ||
await matchGoldenFile('engine/canvas_drrect_overlapping_radius.png', region: region); | ||
}, timeout: const Timeout(Duration(seconds: 10))); | ||
} |
112 changes: 112 additions & 0 deletions
112
lib/web_ui/test/golden_tests/engine/canvas_scuba_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'dart:html' as html; | ||
|
||
import 'package:ui/src/engine.dart'; | ||
import 'package:ui/ui.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
import 'package:web_engine_tester/golden_tester.dart'; | ||
|
||
void main() async { | ||
final Rect region = Rect.fromLTWH(8, 8, 500, 100); // Compensate for old scuba tester padding | ||
|
||
BitmapCanvas canvas; | ||
|
||
setUp(() { | ||
html.document.body.style.transform = 'translate(10px, 10px)'; | ||
}); | ||
|
||
tearDown(() { | ||
html.document.body.style.transform = 'none'; | ||
canvas.rootElement.remove(); | ||
}); | ||
|
||
/// Draws several lines, some aligned precisely with the pixel grid, and some | ||
/// that are offset by 0.5 vertically or horizontally. | ||
/// | ||
/// The produced picture stresses the antialiasing generated by the browser | ||
/// when positioning and rasterizing `<canvas>` tags. Aliasing artifacts can | ||
/// be seen depending on pixel alignment and whether antialiasing happens | ||
/// before or after rasterization. | ||
void drawMisalignedLines(BitmapCanvas canvas) { | ||
final PaintData linePaint = (Paint() | ||
..style = PaintingStyle.stroke | ||
..strokeWidth = 1) | ||
.webOnlyPaintData; | ||
|
||
final PaintData fillPaint = | ||
(Paint()..style = PaintingStyle.fill).webOnlyPaintData; | ||
|
||
canvas.drawRect( | ||
const Rect.fromLTWH(0, 0, 40, 40), | ||
linePaint, | ||
); | ||
|
||
canvas.drawLine( | ||
const Offset(10, 0), | ||
const Offset(10, 40), | ||
linePaint, | ||
); | ||
|
||
canvas.drawLine( | ||
const Offset(20.5, 0), | ||
const Offset(20, 40), | ||
linePaint, | ||
); | ||
|
||
canvas.drawCircle(const Offset(30, 10), 3, fillPaint); | ||
canvas.drawCircle(const Offset(30.5, 30), 3, fillPaint); | ||
} | ||
|
||
test('renders pixels that are not aligned inside the canvas', () async { | ||
canvas = BitmapCanvas(const Rect.fromLTWH(0, 0, 60, 60)); | ||
|
||
drawMisalignedLines(canvas); | ||
|
||
html.document.body.append(canvas.rootElement); | ||
|
||
await matchGoldenFile('engine/misaligned_pixels_in_canvas_test.png', region: region); | ||
}, timeout: const Timeout(Duration(seconds: 10))); | ||
|
||
test('compensates for misalignment of the canvas', () async { | ||
// Notice the 0.5 offset in the bounds rectangle. It's what causes the | ||
// misalignment of canvas relative to the pixel grid. BitmapCanvas will | ||
// shift its position back to 0.0 and at the same time it will it will | ||
// compensate by shifting the contents of the canvas in the opposite | ||
// direction. | ||
canvas = BitmapCanvas(const Rect.fromLTWH(0.5, 0.5, 60, 60)); | ||
|
||
drawMisalignedLines(canvas); | ||
|
||
html.document.body.append(canvas.rootElement); | ||
|
||
await matchGoldenFile('engine/misaligned_canvas_test.png', region: region); | ||
}, timeout: const Timeout(Duration(seconds: 10))); | ||
|
||
test('fill the whole canvas with color even when transformed', () async { | ||
canvas = BitmapCanvas(const Rect.fromLTWH(0, 0, 50, 50)); | ||
|
||
canvas.translate(25, 25); | ||
canvas.drawColor(const Color.fromRGBO(0, 255, 0, 1.0), BlendMode.src); | ||
|
||
html.document.body.append(canvas.rootElement); | ||
|
||
await matchGoldenFile('engine/bitmap_canvas_fills_color_when_transformed.png', region: region); | ||
}, timeout: const Timeout(Duration(seconds: 10))); | ||
|
||
test('fill the whole canvas with paint even when transformed', () async { | ||
canvas = BitmapCanvas(const Rect.fromLTWH(0, 0, 50, 50)); | ||
|
||
canvas.translate(25, 25); | ||
canvas.drawPaint(PaintData() | ||
..color = const Color.fromRGBO(0, 255, 0, 1.0) | ||
..style = PaintingStyle.fill); | ||
|
||
html.document.body.append(canvas.rootElement); | ||
|
||
await matchGoldenFile('engine/bitmap_canvas_fills_paint_when_transformed.png', region: region); | ||
}, timeout: const Timeout(Duration(seconds: 10))); | ||
} |
Oops, something went wrong.