Unverified Commit ce248e87 authored by Hans Muller's avatar Hans Muller Committed by GitHub

Update misc tests for Material3 (#128712)

parent 09b7e561
...@@ -78,30 +78,29 @@ class _ApplicationExitControlState extends State<ApplicationExitControl> { ...@@ -78,30 +78,29 @@ class _ApplicationExitControlState extends State<ApplicationExitControl> {
return Center( return Center(
child: SizedBox( child: SizedBox(
width: 300, width: 300,
child: IntrinsicHeight( child: Column(
child: Column( mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
RadioListTile<bool>( RadioListTile<bool>(
title: const Text('Do Not Allow Exit'), title: const Text('Do Not Allow Exit'),
groupValue: _shouldExit, groupValue: _shouldExit,
value: false, value: false,
onChanged: _radioChanged, onChanged: _radioChanged,
), ),
RadioListTile<bool>( RadioListTile<bool>(
title: const Text('Allow Exit'), title: const Text('Allow Exit'),
groupValue: _shouldExit, groupValue: _shouldExit,
value: true, value: true,
onChanged: _radioChanged, onChanged: _radioChanged,
), ),
const SizedBox(height: 30), const SizedBox(height: 30),
ElevatedButton( ElevatedButton(
onPressed: _quit, onPressed: _quit,
child: const Text('Quit'), child: const Text('Quit'),
), ),
const SizedBox(height: 30), const SizedBox(height: 30),
Text('Exit Request: $_lastExitResponse'), Text('Exit Request: $_lastExitResponse'),
], ],
),
), ),
), ),
); );
......
...@@ -275,11 +275,12 @@ void main() { ...@@ -275,11 +275,12 @@ void main() {
handle.dispose(); handle.dispose();
}); });
testWidgets('yellow text on yellow background fails with correct message', testWidgets('Material2: yellow text on yellow background fails with correct message',
(WidgetTester tester) async { (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics(); final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget( await tester.pumpWidget(
_boilerplate( _boilerplate(
useMaterial3: false,
Container( Container(
width: 200.0, width: 200.0,
height: 200.0, height: 200.0,
...@@ -306,6 +307,38 @@ void main() { ...@@ -306,6 +307,38 @@ void main() {
handle.dispose(); handle.dispose();
}); });
testWidgets('Material3: yellow text on yellow background fails with correct message',
(WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(
_boilerplate(
useMaterial3: true,
Container(
width: 200.0,
height: 200.0,
color: Colors.yellow,
child: const Text(
'this is a test',
style: TextStyle(fontSize: 14.0, color: Colors.yellowAccent),
),
),
),
);
final Evaluation result = await textContrastGuideline.evaluate(tester);
expect(result.passed, false);
expect(
result.reason,
'SemanticsNode#4(Rect.fromLTRB(300.0, 200.0, 500.0, 400.0), '
'label: "this is a test", textDirection: ltr):\n'
'Expected contrast ratio of at least 4.5 but found 1.19 for a font '
'size of 14.0.\n'
'The computed colors was:\n'
'light - Color(0xfffffbfe), dark - Color(0xffffeb3b)\n'
'See also: https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html',
);
handle.dispose();
});
testWidgets('label without corresponding text is skipped', testWidgets('label without corresponding text is skipped',
(WidgetTester tester) async { (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics(); final SemanticsHandle handle = tester.ensureSemantics();
...@@ -937,5 +970,11 @@ void main() { ...@@ -937,5 +970,11 @@ void main() {
}); });
} }
Widget _boilerplate(Widget child) => Widget _boilerplate(Widget child, { bool? useMaterial3 }) {
MaterialApp(home: Scaffold(body: Center(child: child))); return MaterialApp(
theme: ThemeData(useMaterial3: useMaterial3),
home: Scaffold(
body: Center(child: child),
),
);
}
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