Skip to content

Commit

Permalink
Add test where white text on white background fails contrast. (#110217)
Browse files Browse the repository at this point in the history
  • Loading branch information
ankur2136 committed Aug 30, 2022
1 parent 171ddeb commit 9865039
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions packages/flutter_test/test/accessibility_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,40 @@ void main() {
handle.dispose();
});

testWidgets('White text on white background fails contrast test',
(WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(
_boilerplate(
Container(
width: 200.0,
height: 300.0,
color: Colors.white,
child: Column(
children: const <Widget>[
Text(
'this is a white text',
style: TextStyle(fontSize: 14.0, color: Colors.white),
),
SizedBox(height: 50),
Text(
'this is a black text test1',
style: TextStyle(fontSize: 14.0, color: Colors.black),
),
SizedBox(height: 50),
Text(
'this is a black text test2',
style: TextStyle(fontSize: 14.0, color: Colors.black),
),
],
),
),
),
);
await expectLater(tester, doesNotMeetGuideline(textContrastGuideline));
handle.dispose();
});

const Color surface = Color(0xFFF0F0F0);

/// Shades of blue with contrast ratio of 2.9, 4.4, 4.5 from [surface].
Expand Down

0 comments on commit 9865039

Please sign in to comment.