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> {
return Center(
child: SizedBox(
width: 300,
child: IntrinsicHeight(
child: Column(
children: <Widget>[
RadioListTile<bool>(
title: const Text('Do Not Allow Exit'),
groupValue: _shouldExit,
value: false,
onChanged: _radioChanged,
),
RadioListTile<bool>(
title: const Text('Allow Exit'),
groupValue: _shouldExit,
value: true,
onChanged: _radioChanged,
),
const SizedBox(height: 30),
ElevatedButton(
onPressed: _quit,
child: const Text('Quit'),
),
const SizedBox(height: 30),
Text('Exit Request: $_lastExitResponse'),
],
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
RadioListTile<bool>(
title: const Text('Do Not Allow Exit'),
groupValue: _shouldExit,
value: false,
onChanged: _radioChanged,
),
RadioListTile<bool>(
title: const Text('Allow Exit'),
groupValue: _shouldExit,
value: true,
onChanged: _radioChanged,
),
const SizedBox(height: 30),
ElevatedButton(
onPressed: _quit,
child: const Text('Quit'),
),
const SizedBox(height: 30),
Text('Exit Request: $_lastExitResponse'),
],
),
),
);
......
......@@ -275,11 +275,12 @@ void main() {
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 {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(
_boilerplate(
useMaterial3: false,
Container(
width: 200.0,
height: 200.0,
......@@ -306,6 +307,38 @@ void main() {
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',
(WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
......@@ -937,5 +970,11 @@ void main() {
});
}
Widget _boilerplate(Widget child) =>
MaterialApp(home: Scaffold(body: Center(child: child)));
Widget _boilerplate(Widget child, { bool? useMaterial3 }) {
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