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> {
|
class MainWidgetState extends State<MainWidget> {
|
||||||
double currentSliderValue = 20;
|
int _count = 0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -39,25 +39,32 @@ class MainWidgetState extends State<MainWidget> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Row(
|
MergeSemantics(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
child: Row(
|
||||||
children: <Widget>[
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
const Text('This is a TextButton:'),
|
children: <Widget>[
|
||||||
TextButton(
|
const Text('This is a TextButton:'),
|
||||||
onPressed: () { },
|
TextButton(
|
||||||
child: const Text('Action'),
|
onPressed: () {
|
||||||
),
|
setState(() { _count++; });
|
||||||
],
|
},
|
||||||
|
child: const Text('Action'),
|
||||||
|
),
|
||||||
|
Text('Clicked $_count time(s).'),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const Row(
|
const MergeSemantics(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
child: Row(
|
||||||
children: <Widget>[
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
Text('This is a disabled TextButton:'),
|
children: <Widget>[
|
||||||
TextButton(
|
Text('This is a disabled TextButton:'),
|
||||||
onPressed: null,
|
TextButton(
|
||||||
child: Text('Action'),
|
onPressed: null,
|
||||||
),
|
child: Text('Action Disabled'),
|
||||||
],
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -10,6 +10,20 @@ import 'test_utils.dart';
|
|||||||
void main() {
|
void main() {
|
||||||
testWidgets('text button can run', (WidgetTester tester) async {
|
testWidgets('text button can run', (WidgetTester tester) async {
|
||||||
await pumpsUseCase(tester, TextButtonUseCase());
|
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