Unverified Commit a9faaf26 authored by Yegor's avatar Yegor Committed by GitHub

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.
parent 954d30f0
......@@ -41,12 +41,23 @@ class _MainWidget extends StatelessWidget {
children: <Widget>[
const Text('This is a typical dialog.'),
const SizedBox(height: 15),
TextButton(
autofocus: true,
onPressed: () {
Navigator.pop(context);
},
child: const Text('Close'),
Row(
children: <Widget>[
TextButton(
autofocus: true,
onPressed: () {
Navigator.pop(context);
},
child: const Text('OK'),
),
TextButton(
autofocus: true,
onPressed: () {
Navigator.pop(context);
},
child: const Text('Cancel'),
),
],
),
],
),
......
// 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 'material_banner.dart';
import 'navigation_bar.dart';
import 'radio_list_tile.dart';
import 'slider.dart';
import 'text_button.dart';
import 'text_field.dart';
......@@ -34,4 +35,5 @@ final List<UseCase> useCases = <UseCase>[
MaterialBannerUseCase(),
NavigationBarUseCase(),
TextButtonUseCase(),
RadioListTileUseCase(),
];
// 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());
expect(find.text('Show Dialog'), findsOneWidget);
await tester.tap(find.text('Show Dialog'));
Future<void> invokeDialog() async {
await tester.tap(find.text('Show Dialog'));
await tester.pumpAndSettle();
expect(find.text('This is a typical dialog.'), findsOneWidget);
}
await invokeDialog();
await tester.tap(find.text('OK'));
await tester.pumpAndSettle();
expect(find.text('This is a typical dialog.'), findsOneWidget);
expect(find.text('This is a typical dialog.'), findsNothing);
await tester.tap(find.text('Close'));
await invokeDialog();
await tester.tap(find.text('Cancel'));
await tester.pumpAndSettle();
expect(find.text('Show Dialog'), findsOneWidget);
expect(find.text('This is a typical dialog.'), findsNothing);
});
}
// 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);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment