make showKeyboard respect finder's skipOffstage value (#79034)

This commit is contained in:
Michael Bui 2021-03-30 12:19:03 +11:00 committed by GitHub
parent 462ad79036
commit 39499bd2bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 18 deletions

View File

@ -1031,7 +1031,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
final EditableTextState editable = state<EditableTextState>(
find.descendant(
of: finder,
matching: find.byType(EditableText),
matching: find.byType(EditableText, skipOffstage: finder.skipOffstage),
matchRoot: true,
),
);

View File

@ -611,25 +611,42 @@ void main() {
});
});
testWidgets('showKeyboard can be called twice', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Material(
child: Center(
child: TextFormField(),
group('showKeyboard', () {
testWidgets('can be called twice', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Material(
child: Center(
child: TextFormField(),
),
),
),
),
);
await tester.showKeyboard(find.byType(TextField));
await tester.testTextInput.receiveAction(TextInputAction.done);
await tester.pump();
await tester.showKeyboard(find.byType(TextField));
await tester.testTextInput.receiveAction(TextInputAction.done);
await tester.pump();
await tester.showKeyboard(find.byType(TextField));
await tester.showKeyboard(find.byType(TextField));
await tester.pump();
);
await tester.showKeyboard(find.byType(TextField));
await tester.testTextInput.receiveAction(TextInputAction.done);
await tester.pump();
await tester.showKeyboard(find.byType(TextField));
await tester.testTextInput.receiveAction(TextInputAction.done);
await tester.pump();
await tester.showKeyboard(find.byType(TextField));
await tester.showKeyboard(find.byType(TextField));
await tester.pump();
});
testWidgets(
'can focus on offstage text input field if finder says not to skip offstage nodes',
(WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Material(
child: Offstage(
child: TextFormField(),
),
),
),
);
await tester.showKeyboard(find.byType(TextField, skipOffstage: false));
});
});
testWidgets('verifyTickersWereDisposed control test', (WidgetTester tester) async {