added functionality to where SR will communicate button clicked (#152185)
added functionality to onPressed method to communicate button press action to screen readers. Before: https://screencast.googleplex.com/cast/NjI2NzEyMzY3OTYyNTIxNnw1NjgyNGE3MC0wNQ After: https://screencast.googleplex.com/cast/NjUyODAxNzc0MzQ3ODc4NHwxNjBhZDZjNi1hOA fixes b/347102786
This commit is contained in:
parent
75b6a2ff6a
commit
3293010a43
@ -26,7 +26,7 @@ class MainWidget extends StatefulWidget {
|
||||
}
|
||||
|
||||
class MainWidgetState extends State<MainWidget> {
|
||||
double currentSliderValue = 20;
|
||||
int _count = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -39,25 +39,32 @@ class MainWidgetState extends State<MainWidget> {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
const Text('This is a TextButton:'),
|
||||
TextButton(
|
||||
onPressed: () { },
|
||||
child: const Text('Action'),
|
||||
),
|
||||
],
|
||||
MergeSemantics(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
const Text('This is a TextButton:'),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
setState(() { _count++; });
|
||||
},
|
||||
child: const Text('Action'),
|
||||
),
|
||||
Text('Clicked $_count time(s).'),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text('This is a disabled TextButton:'),
|
||||
TextButton(
|
||||
onPressed: null,
|
||||
child: Text('Action'),
|
||||
),
|
||||
],
|
||||
const MergeSemantics(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text('This is a disabled TextButton:'),
|
||||
TextButton(
|
||||
onPressed: null,
|
||||
child: Text('Action Disabled'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -10,6 +10,20 @@ import 'test_utils.dart';
|
||||
void main() {
|
||||
testWidgets('text button can run', (WidgetTester tester) async {
|
||||
await pumpsUseCase(tester, TextButtonUseCase());
|
||||
expect(find.text('Action'), findsExactly(2));
|
||||
expect(find.text('Action'), findsOneWidget);
|
||||
expect(find.text('Action Disabled'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('text button increments correctly when clicked', (WidgetTester tester) async {
|
||||
await pumpsUseCase(tester, TextButtonUseCase());
|
||||
|
||||
expect(find.text('Action'), findsOneWidget);
|
||||
await tester.tap(find.text('Action'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Clicked 1 time(s).'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.text('Action'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Clicked 2 time(s).'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user