-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2461 from leancodepl/patch-enter-text-bug
Patch enter text bug
- Loading branch information
Showing
9 changed files
with
971 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'package:e2e_app/text_fields_screen.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
import 'common.dart'; | ||
|
||
void main() { | ||
patrol('Can enter text into same field twice', ($) async { | ||
await $.pumpWidgetAndSettle(const TextFieldsScreen()); | ||
await $.pumpAndSettle(); | ||
|
||
// Enter text into the first text field. | ||
await $(const Key('textField1')).enterText('User'); | ||
await $(const Key('buttonFocus')).tap(); | ||
expect($('User'), findsOneWidget); | ||
|
||
// Enter text into the first text field again. After focusing on the button. | ||
await $(const Key('textField1')).enterText('User2'); | ||
await $(const Key('buttonUnfocus')).tap(); | ||
expect($('User'), findsNothing); | ||
expect($('User2'), findsOneWidget); | ||
|
||
// Enter text into the first text field again. After unfocusing the button. | ||
// Then enter text into the second text field and into the first field again. | ||
await $(const Key('textField1')).enterText('User3'); | ||
await $(const Key('textField2')).enterText('User4'); | ||
await $(const Key('textField1')).enterText('User5'); | ||
expect($('User2'), findsNothing); | ||
expect($('User3'), findsNothing); | ||
expect($('User4'), findsOneWidget); | ||
expect($('User5'), findsOneWidget); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class TextFieldsScreen extends StatefulWidget { | ||
const TextFieldsScreen({super.key}); | ||
|
||
@override | ||
State<TextFieldsScreen> createState() => _TextFieldsScreenState(); | ||
} | ||
|
||
class _TextFieldsScreenState extends State<TextFieldsScreen> { | ||
FocusNode focusNode = FocusNode(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
home: Scaffold( | ||
appBar: AppBar( | ||
title: const Text('Text Fields'), | ||
), | ||
body: Center( | ||
child: SingleChildScrollView( | ||
child: Column( | ||
children: [ | ||
const TextField( | ||
key: Key('textField1'), | ||
), | ||
ElevatedButton.icon( | ||
key: const Key('buttonFocus'), | ||
onPressed: () => | ||
FocusScope.of(context).requestFocus(focusNode), | ||
label: const Icon(Icons.search), | ||
focusNode: focusNode, | ||
), | ||
const TextField( | ||
key: Key('textField2'), | ||
), | ||
ElevatedButton.icon( | ||
key: const Key('buttonUnfocus'), | ||
onPressed: () => FocusScope.of(context).unfocus(), | ||
label: const Icon(Icons.search), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.