[Android] Fix spell_check integration test flakiness (#112109)
This commit is contained in:
parent
07c5ebca78
commit
b94b584298
2
.ci.yaml
2
.ci.yaml
@ -2107,7 +2107,7 @@ targets:
|
|||||||
task_name: routing_test
|
task_name: routing_test
|
||||||
|
|
||||||
- name: Linux_android spell_check_test
|
- name: Linux_android spell_check_test
|
||||||
bringup: true
|
bringup: true # TESTING PURPOSES ONLY
|
||||||
recipe: devicelab/devicelab_drone
|
recipe: devicelab/devicelab_drone
|
||||||
presubmit: false
|
presubmit: false
|
||||||
timeout: 60
|
timeout: 60
|
||||||
|
@ -12,22 +12,35 @@ import 'package:spell_check/main.dart';
|
|||||||
late DefaultSpellCheckService defaultSpellCheckService;
|
late DefaultSpellCheckService defaultSpellCheckService;
|
||||||
late Locale locale;
|
late Locale locale;
|
||||||
|
|
||||||
/// Copy from flutter/test/widgets/editable_text_utils.dart.
|
/// Waits to find [EditableText] that displays text with misspelled
|
||||||
RenderEditable findRenderEditable(WidgetTester tester, Type type) {
|
/// words marked the same as the [TextSpan] provided and returns
|
||||||
final RenderObject root = tester.renderObject(find.byType(type));
|
/// true if it is found before timing out at 20 seconds.
|
||||||
|
Future<bool> findTextSpanTree(
|
||||||
|
WidgetTester tester,
|
||||||
|
TextSpan inlineSpan,
|
||||||
|
) async {
|
||||||
|
final RenderObject root = tester.renderObject(find.byType(EditableText));
|
||||||
expect(root, isNotNull);
|
expect(root, isNotNull);
|
||||||
|
|
||||||
late RenderEditable renderEditable;
|
RenderEditable? renderEditable;
|
||||||
void recursiveFinder(RenderObject child) {
|
void recursiveFinder(RenderObject child) {
|
||||||
if (child is RenderEditable) {
|
if (child is RenderEditable && child.text == inlineSpan) {
|
||||||
renderEditable = child;
|
renderEditable = child;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
child.visitChildren(recursiveFinder);
|
child.visitChildren(recursiveFinder);
|
||||||
}
|
}
|
||||||
root.visitChildren(recursiveFinder);
|
|
||||||
expect(renderEditable, isNotNull);
|
final DateTime endTime = tester.binding.clock.now().add(const Duration(seconds: 20));
|
||||||
return renderEditable;
|
do {
|
||||||
|
if (tester.binding.clock.now().isAfter(endTime)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
root.visitChildren(recursiveFinder);
|
||||||
|
} while (renderEditable == null);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
@ -147,21 +160,21 @@ Future<void> main() async {
|
|||||||
|
|
||||||
await tester.pumpWidget(const MyApp());
|
await tester.pumpWidget(const MyApp());
|
||||||
|
|
||||||
await tester.enterText(find.byType(EditableText), 'Hey cfabiueqqocnakoef! Hey!');
|
await tester.enterText(find.byType(EditableText), 'Hey cfabiueq qocnakoef! Hey!');
|
||||||
await tester.pumpAndSettle();
|
|
||||||
|
|
||||||
final RenderEditable renderEditable = findRenderEditable(tester, EditableText);
|
|
||||||
final TextSpan textSpanTree = renderEditable.text! as TextSpan;
|
|
||||||
|
|
||||||
const TextSpan expectedTextSpanTree = TextSpan(
|
const TextSpan expectedTextSpanTree = TextSpan(
|
||||||
style: style,
|
style: style,
|
||||||
children: <TextSpan>[
|
children: <TextSpan>[
|
||||||
TextSpan(style: style, text: 'Hey '),
|
TextSpan(style: style, text: 'Hey '),
|
||||||
TextSpan(style: misspelledTextStyle, text: 'cfabiueqqocnakoef'),
|
TextSpan(style: misspelledTextStyle, text: 'cfabiueq'),
|
||||||
TextSpan(style: style, text: '! Hey!'),
|
TextSpan(style: style, text: ' '),
|
||||||
]);
|
TextSpan(style: misspelledTextStyle, text: 'qocnakoef'),
|
||||||
|
TextSpan(style: style, text: '! Hey!'),
|
||||||
|
]);
|
||||||
|
|
||||||
expect(textSpanTree, equals(expectedTextSpanTree));
|
final bool expectedTextSpanTreeFound = await findTextSpanTree(tester, expectedTextSpanTree);
|
||||||
|
|
||||||
|
expect(expectedTextSpanTreeFound, isTrue);
|
||||||
});
|
});
|
||||||
|
|
||||||
test(
|
test(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user