Skip to content

Commit 101747f

Browse files
authored
[web] Unskip and strengthen missing glyph tofu test on Wimp (flutter#193426)
Unskips `Renders tab as space instead of tofu` in `engine/src/flutter/lib/web_ui/test/ui/text_test.dart` on Wimp (`chrome-dart2wasm-wimp-ui`) and strengthens the test assertions: - When `DlWimpImageFromPicture::GetImpellerTexture` was introduced in flutter#175442 (`e0f544bf620`), it constructed a temporary `impeller::AiksContext` with a `nullptr` `TypographerContext`, causing `picture.toImage()` to drop text runs and return blank images (which caused `matchImage(tabImage, tofuImage)` to fail when the `!isWimp` skip was added in flutter#183913 / `2490c22d5be`). - flutter#191747 (`87c02198123`) refactored `DlWimpImageFromPicture::GetImpellerTexture` to render via `ImpellerRenderContext` (which owns the shared `impeller::ContentContext` and `TypographerContextSkia::Make()`), restoring `.notdef` glyph rendering in `picture.toImage()`. - Removes the `!isWimp` guard so `Renders tab as space instead of tofu` runs on both Skwasm and Wimp. - Adds an assertion that unassigned non-control codepoints (`\u{0378}`) also render a `.notdef` tofu box distinct from `''`, and disposes `Paragraph`, `Picture`, and `Image` resources created inside `drawText`. Fixes flutter#183944 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant in-code documentation (doc comments with `///`). - [x] If this PR introduces a new feature or capability, I created and linked a website documentation issue or PR in [flutter/website] (or verified none is needed). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [flutter/website]: https://github.com/flutter/website [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent aafc901 commit 101747f

1 file changed

Lines changed: 37 additions & 25 deletions

File tree

‎engine/src/flutter/lib/web_ui/test/ui/text_test.dart‎

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -56,36 +56,48 @@ void testMain() {
5656
expect(boxes.single.direction, equals(ui.TextDirection.ltr));
5757
});
5858

59-
test(
60-
'Renders tab as space instead of tofu',
61-
() async {
62-
// Skia renders a tofu if the font does not have a glyph for a
63-
// character. However, Flutter opts-in to a Skia feature to render
64-
// tabs as a single space.
65-
// See: https://github.com/flutter/flutter/issues/79153
66-
Future<ui.Image> drawText(String text) {
67-
const bounds = ui.Rect.fromLTRB(0, 0, 100, 100);
68-
final recorder = ui.PictureRecorder();
69-
final canvas = ui.Canvas(recorder, bounds);
70-
final ui.Paragraph paragraph = makeSimpleText(text);
71-
59+
test('Renders tab as space instead of tofu', () async {
60+
// Skia renders a tofu if the font does not have a glyph for a
61+
// character. However, Flutter opts-in to a Skia feature to render
62+
// tabs as a single space.
63+
// See: https://github.com/flutter/flutter/issues/79153
64+
Future<ui.Image> drawText(String text) async {
65+
const bounds = ui.Rect.fromLTRB(0, 0, 100, 100);
66+
final recorder = ui.PictureRecorder();
67+
final canvas = ui.Canvas(recorder, bounds);
68+
final ui.Paragraph paragraph = makeSimpleText(text);
69+
try {
7270
canvas.drawParagraph(paragraph, ui.Offset.zero);
7371
final ui.Picture picture = recorder.endRecording();
74-
return picture.toImage(100, 100);
72+
try {
73+
final ui.Image image = await picture.toImage(100, 100);
74+
addTearDown(image.dispose);
75+
return image;
76+
} finally {
77+
picture.dispose();
78+
}
79+
} finally {
80+
paragraph.dispose();
7581
}
82+
}
7683

77-
// The backspace character, \b, does not have a corresponding glyph and
78-
// is rendered as a tofu.
79-
final ui.Image tabImage = await drawText('>\t<');
80-
final ui.Image spaceImage = await drawText('> <');
81-
final ui.Image tofuImage = await drawText('>\b<');
84+
// The backspace character, \b, and unassigned codepoint \u0378 do not
85+
// have corresponding glyphs and are rendered as tofu boxes.
86+
final ui.Image tabImage = await drawText('>\t<');
87+
final ui.Image spaceImage = await drawText('> <');
88+
final ui.Image tofuImage = await drawText('>\b<');
89+
final ui.Image noMidImage = await drawText('><');
90+
final ui.Image onlyTofuImage = await drawText('\b');
91+
final ui.Image unassignedTofuImage = await drawText('\u{0378}');
92+
final ui.Image emptyImage = await drawText('');
8293

83-
expect(await matchImage(tabImage, spaceImage), isTrue);
84-
expect(await matchImage(tabImage, tofuImage), isFalse);
85-
},
86-
skip: isWimp || isSafari || isFirefox,
87-
); // TODO(hterkelsen): https://github.com/flutter/flutter/issues/71520
88-
// TODO(jacksongardner): https://github.com/flutter/flutter/issues/183944
94+
expect(await matchImage(tabImage, spaceImage), isTrue);
95+
expect(await matchImage(tabImage, tofuImage), isFalse);
96+
expect(await matchImage(tofuImage, noMidImage), isFalse);
97+
expect(await matchImage(onlyTofuImage, emptyImage), isFalse);
98+
expect(await matchImage(unassignedTofuImage, emptyImage), isFalse);
99+
});
100+
// TODO(hterkelsen): https://github.com/flutter/flutter/issues/71520
89101
}, skip: isSafari || isFirefox);
90102
}
91103

0 commit comments

Comments
 (0)