Add RadioListItem use-case to a11y_assessments (#140984)
Adds a use-case screen for `RadioListTile`, similar to the `CheckBoxListTile`. This screen can help test scenarios such as the one reported in https://github.com/flutter/flutter/issues/126805.
This commit is contained in:
parent
954d30f07f
commit
a9faaf2683
@ -41,12 +41,23 @@ class _MainWidget extends StatelessWidget {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
const Text('This is a typical dialog.'),
|
const Text('This is a typical dialog.'),
|
||||||
const SizedBox(height: 15),
|
const SizedBox(height: 15),
|
||||||
TextButton(
|
Row(
|
||||||
autofocus: true,
|
children: <Widget>[
|
||||||
onPressed: () {
|
TextButton(
|
||||||
Navigator.pop(context);
|
autofocus: true,
|
||||||
},
|
onPressed: () {
|
||||||
child: const Text('Close'),
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
child: const Text('OK'),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
autofocus: true,
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
child: const Text('Cancel'),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
59
dev/a11y_assessments/lib/use_cases/radio_list_tile.dart
Normal file
59
dev/a11y_assessments/lib/use_cases/radio_list_tile.dart
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'use_cases.dart';
|
||||||
|
|
||||||
|
class RadioListTileUseCase extends UseCase {
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get name => 'RadioListTile';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get route => '/radio-list-tile';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => _MainWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MainWidget extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
State<_MainWidget> createState() => _MainWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
enum SingingCharacter { lafayette, jefferson }
|
||||||
|
|
||||||
|
class _MainWidgetState extends State<_MainWidget> {
|
||||||
|
SingingCharacter _value = SingingCharacter.lafayette;
|
||||||
|
|
||||||
|
void _onChanged(SingingCharacter? value) {
|
||||||
|
setState(() {
|
||||||
|
_value = value!;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(title: const Text('Radio button')),
|
||||||
|
body: ListView(
|
||||||
|
children: <Widget>[
|
||||||
|
RadioListTile<SingingCharacter>(
|
||||||
|
title: const Text('Lafayette'),
|
||||||
|
value: SingingCharacter.lafayette,
|
||||||
|
groupValue: _value,
|
||||||
|
onChanged: _onChanged,
|
||||||
|
),
|
||||||
|
RadioListTile<SingingCharacter>(
|
||||||
|
title: const Text('Jefferson'),
|
||||||
|
value: SingingCharacter.jefferson,
|
||||||
|
groupValue: _value,
|
||||||
|
onChanged: _onChanged,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,7 @@ import 'date_picker.dart';
|
|||||||
import 'dialog.dart';
|
import 'dialog.dart';
|
||||||
import 'material_banner.dart';
|
import 'material_banner.dart';
|
||||||
import 'navigation_bar.dart';
|
import 'navigation_bar.dart';
|
||||||
|
import 'radio_list_tile.dart';
|
||||||
import 'slider.dart';
|
import 'slider.dart';
|
||||||
import 'text_button.dart';
|
import 'text_button.dart';
|
||||||
import 'text_field.dart';
|
import 'text_field.dart';
|
||||||
@ -34,4 +35,5 @@ final List<UseCase> useCases = <UseCase>[
|
|||||||
MaterialBannerUseCase(),
|
MaterialBannerUseCase(),
|
||||||
NavigationBarUseCase(),
|
NavigationBarUseCase(),
|
||||||
TextButtonUseCase(),
|
TextButtonUseCase(),
|
||||||
|
RadioListTileUseCase(),
|
||||||
];
|
];
|
||||||
|
16
dev/a11y_assessments/test/check_box_list_tile_test.dart
Normal file
16
dev/a11y_assessments/test/check_box_list_tile_test.dart
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
import 'package:a11y_assessments/use_cases/check_box_list_tile.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
import 'test_utils.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('check box list tile use-case renders check boxes', (WidgetTester tester) async {
|
||||||
|
await pumpsUseCase(tester, CheckBoxListTile());
|
||||||
|
expect(find.text('a check box list title'), findsOneWidget);
|
||||||
|
expect(find.text('a disabled check box list title'), findsOneWidget);
|
||||||
|
});
|
||||||
|
}
|
@ -12,12 +12,20 @@ void main() {
|
|||||||
await pumpsUseCase(tester, DialogUseCase());
|
await pumpsUseCase(tester, DialogUseCase());
|
||||||
expect(find.text('Show Dialog'), findsOneWidget);
|
expect(find.text('Show Dialog'), findsOneWidget);
|
||||||
|
|
||||||
await tester.tap(find.text('Show Dialog'));
|
Future<void> invokeDialog() async {
|
||||||
await tester.pumpAndSettle();
|
await tester.tap(find.text('Show Dialog'));
|
||||||
expect(find.text('This is a typical dialog.'), findsOneWidget);
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text('This is a typical dialog.'), findsOneWidget);
|
||||||
|
}
|
||||||
|
|
||||||
await tester.tap(find.text('Close'));
|
await invokeDialog();
|
||||||
|
await tester.tap(find.text('OK'));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(find.text('Show Dialog'), findsOneWidget);
|
expect(find.text('This is a typical dialog.'), findsNothing);
|
||||||
|
|
||||||
|
await invokeDialog();
|
||||||
|
await tester.tap(find.text('Cancel'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text('This is a typical dialog.'), findsNothing);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
16
dev/a11y_assessments/test/radio_list_tile_test.dart
Normal file
16
dev/a11y_assessments/test/radio_list_tile_test.dart
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
import 'package:a11y_assessments/use_cases/radio_list_tile.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
import 'test_utils.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('radio list tile use-case renders radio buttons', (WidgetTester tester) async {
|
||||||
|
await pumpsUseCase(tester, RadioListTileUseCase());
|
||||||
|
expect(find.text('Lafayette'), findsOneWidget);
|
||||||
|
expect(find.text('Jefferson'), findsOneWidget);
|
||||||
|
});
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user