Replace text directionality control characters with escape sequences in the semantics_tester (#93034)

This commit is contained in:
Jason Simmons 2021-11-03 19:13:03 -07:00 committed by GitHub
parent 773789344e
commit 0d0b2dbae5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 7 deletions

View File

@ -635,12 +635,9 @@ class SemanticsTester {
if (nodeData.actions != 0)
buf.writeln(' actions: ${_actionsToSemanticsActionExpression(nodeData.actions)},');
if (node.label != null && node.label.isNotEmpty) {
final String escapedLabel = node.label.replaceAll('\n', r'\n');
if (escapedLabel != node.label) {
buf.writeln(" label: r'$escapedLabel',");
} else {
buf.writeln(" label: '$escapedLabel',");
}
// Escape newlines and text directionality control characters.
final String escapedLabel = node.label.replaceAll('\n', r'\n').replaceAll('\u202a', r'\u202a').replaceAll('\u202c', r'\u202c');
buf.writeln(" label: '$escapedLabel',");
}
if (node.value != null && node.value.isNotEmpty)
buf.writeln(" value: '${node.value}',");

View File

@ -132,7 +132,7 @@ void _tests() {
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
flags: <SemanticsFlag>[SemanticsFlag.hasCheckedState, SemanticsFlag.isChecked, SemanticsFlag.isSelected],
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.decrease],
label: 'Interactive text',
label: '\u202aInteractive text\u202c',
value: 'test-value',
increasedValue: 'test-increasedValue',
decreasedValue: 'test-decreasedValue',