Skip to content

Commit 213f766

Browse files
Use ValueKey finder instead of text finder in keyboard_textfield_test (#97996)
1 parent 3f7d997 commit 213f766

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

dev/integration_tests/ui/lib/keyboard_textfield.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,17 @@ class _MyHomePageState extends State<MyHomePage> {
5555

5656
@override
5757
Widget build(BuildContext context) {
58-
final String softKeyboardVisibility = MediaQuery.of(context).viewInsets.bottom > 100
59-
? 'keyboard visible'
60-
: 'keyboard not visible';
58+
final bool isSoftKeyboardVisible = MediaQuery.of(context).viewInsets.bottom > 100;
6159
return Scaffold(
6260
body: Column(
6361
children: <Widget>[
6462
Text('$offset',
6563
key: const ValueKey<String>(keys.kOffsetText),
6664
),
67-
Text(softKeyboardVisibility),
65+
if (isSoftKeyboardVisible) const Text(
66+
'keyboard visible',
67+
key: ValueKey<String>(keys.kKeyboardVisibleView),
68+
),
6869
Expanded(
6970
child: ListView(
7071
key: const ValueKey<String>(keys.kListView),

dev/integration_tests/ui/lib/keys.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ const String kHeightText = 'height_text';
77
const String kUnfocusButton = 'unfocus_button';
88
const String kOffsetText = 'offset_text';
99
const String kListView = 'list_view';
10+
const String kKeyboardVisibleView = 'keyboard_visible';

dev/integration_tests/ui/test_driver/keyboard_textfield_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void main() {
2424
final SerializableFinder listViewFinder = find.byValueKey(keys.kListView);
2525
final SerializableFinder textFieldFinder = find.byValueKey(keys.kDefaultTextField);
2626
final SerializableFinder offsetFinder = find.byValueKey(keys.kOffsetText);
27-
final SerializableFinder keyboardVisibilityIndicatorFinder = find.text('keyboard visible');
27+
final SerializableFinder keyboardVisibilityIndicatorFinder = find.byValueKey(keys.kKeyboardVisibleView);
2828

2929
// Align TextField with bottom edge to ensure it would be covered when keyboard comes up.
3030
await driver.waitForAbsent(textFieldFinder);

0 commit comments

Comments
 (0)