Unverified Commit e00d87ff authored by LongCatIsLooong's avatar LongCatIsLooong Committed by GitHub

[keyboard_textfield_test] wait until the keyboard becomes visible (#92032)

parent 63c43a5e
...@@ -47,14 +47,24 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -47,14 +47,24 @@ class _MyHomePageState extends State<MyHomePage> {
}); });
} }
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final String softKeyboardVisibility = MediaQuery.of(context).viewInsets.bottom > 100
? 'keyboard visible'
: 'keyboard not visible';
return Scaffold( return Scaffold(
body: Column( body: Column(
children: <Widget>[ children: <Widget>[
Text('$offset', Text('$offset',
key: const ValueKey<String>(keys.kOffsetText), key: const ValueKey<String>(keys.kOffsetText),
), ),
Text(softKeyboardVisibility),
Expanded( Expanded(
child: ListView( child: ListView(
key: const ValueKey<String>(keys.kListView), key: const ValueKey<String>(keys.kListView),
......
...@@ -24,6 +24,7 @@ void main() { ...@@ -24,6 +24,7 @@ void main() {
final SerializableFinder listViewFinder = find.byValueKey(keys.kListView); final SerializableFinder listViewFinder = find.byValueKey(keys.kListView);
final SerializableFinder textFieldFinder = find.byValueKey(keys.kDefaultTextField); final SerializableFinder textFieldFinder = find.byValueKey(keys.kDefaultTextField);
final SerializableFinder offsetFinder = find.byValueKey(keys.kOffsetText); final SerializableFinder offsetFinder = find.byValueKey(keys.kOffsetText);
final SerializableFinder keyboardVisibilityIndicatorFinder = find.text('keyboard visible');
// Align TextField with bottom edge to ensure it would be covered when keyboard comes up. // Align TextField with bottom edge to ensure it would be covered when keyboard comes up.
await driver.waitForAbsent(textFieldFinder); await driver.waitForAbsent(textFieldFinder);
...@@ -38,7 +39,7 @@ void main() { ...@@ -38,7 +39,7 @@ void main() {
// Bring up keyboard // Bring up keyboard
await driver.tap(textFieldFinder); await driver.tap(textFieldFinder);
await Future<void>.delayed(const Duration(seconds: 1)); await driver.waitFor(keyboardVisibilityIndicatorFinder);
// Ensure that TextField is visible again // Ensure that TextField is visible again
await driver.waitFor(textFieldFinder); await driver.waitFor(textFieldFinder);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment