Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
41b50c22
Unverified
Commit
41b50c22
authored
Aug 28, 2022
by
Casey Hillers
Committed by
GitHub
Aug 28, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Update accessibility contrast test coverage (#109784)" (#110436)
This reverts commit
f477c8b1
.
parent
041c3af5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
123 deletions
+51
-123
accessibility.dart
packages/flutter_test/lib/src/accessibility.dart
+51
-68
accessibility_test.dart
packages/flutter_test/test/accessibility_test.dart
+0
-55
No files found.
packages/flutter_test/lib/src/accessibility.dart
View file @
41b50c22
...
@@ -331,54 +331,27 @@ class MinimumTextContrastGuideline extends AccessibilityGuideline {
...
@@ -331,54 +331,27 @@ class MinimumTextContrastGuideline extends AccessibilityGuideline {
if
(
shouldSkipNode
(
data
))
{
if
(
shouldSkipNode
(
data
))
{
return
result
;
return
result
;
}
}
final
String
text
=
data
.
label
.
isEmpty
?
data
.
value
:
data
.
label
;
final
Iterable
<
Element
>
elements
=
find
.
text
(
text
).
hitTestable
().
evaluate
();
for
(
final
Element
element
in
elements
)
{
result
+=
await
_evaluateElement
(
node
,
element
,
tester
,
image
,
byteData
);
}
return
result
;
}
Future
<
Evaluation
>
_evaluateElement
(
SemanticsNode
node
,
Element
element
,
WidgetTester
tester
,
ui
.
Image
image
,
ByteData
byteData
,
)
async
{
// Look up inherited text properties to determine text size and weight.
// Look up inherited text properties to determine text size and weight.
late
bool
isBold
;
late
bool
isBold
;
double
?
fontSize
;
double
?
fontSize
;
final
String
text
=
data
.
label
.
isEmpty
?
data
.
value
:
data
.
label
;
final
List
<
Element
>
elements
=
find
.
text
(
text
).
hitTestable
().
evaluate
().
toList
();
late
final
Rect
paintBounds
;
late
final
Rect
paintBounds
;
late
final
Rect
paintBoundsWithOffset
;
if
(
elements
.
length
==
1
)
{
final
Element
element
=
elements
.
single
;
final
RenderObject
?
renderBox
=
element
.
renderObject
;
final
RenderObject
?
renderBox
=
element
.
renderObject
;
if
(
renderBox
is
!
RenderBox
)
{
if
(
renderBox
is
!
RenderBox
)
{
throw
StateError
(
'Unexpected renderObject type:
$renderBox
'
);
throw
StateError
(
'Unexpected renderObject type:
$renderBox
'
);
}
}
const
Offset
offset
=
Offset
(
4.0
,
4.0
);
const
Offset
offset
=
Offset
(
4.0
,
4.0
);
paintBoundsWithOffset
=
Rect
.
fromPoints
(
paintBounds
=
Rect
.
fromPoints
(
renderBox
.
localToGlobal
(
renderBox
.
paintBounds
.
topLeft
-
offset
),
renderBox
.
localToGlobal
(
renderBox
.
paintBounds
.
topLeft
-
offset
),
renderBox
.
localToGlobal
(
renderBox
.
paintBounds
.
bottomRight
+
offset
),
renderBox
.
localToGlobal
(
renderBox
.
paintBounds
.
bottomRight
+
offset
),
);
);
paintBounds
=
Rect
.
fromPoints
(
renderBox
.
localToGlobal
(
renderBox
.
paintBounds
.
topLeft
),
renderBox
.
localToGlobal
(
renderBox
.
paintBounds
.
bottomRight
),
);
final
Offset
?
nodeOffset
=
node
.
transform
!=
null
?
MatrixUtils
.
getAsTranslation
(
node
.
transform
!)
:
null
;
final
Rect
nodeBounds
=
node
.
rect
.
shift
(
nodeOffset
??
Offset
.
zero
);
final
Rect
intersection
=
nodeBounds
.
intersect
(
paintBounds
);
if
(
intersection
.
width
<=
0
||
intersection
.
height
<=
0
)
{
// Skip this element since it doesn't correspond to the given semantic
// node.
return
const
Evaluation
.
pass
();
}
final
Widget
widget
=
element
.
widget
;
final
Widget
widget
=
element
.
widget
;
final
DefaultTextStyle
defaultTextStyle
=
DefaultTextStyle
.
of
(
element
);
final
DefaultTextStyle
defaultTextStyle
=
DefaultTextStyle
.
of
(
element
);
if
(
widget
is
Text
)
{
if
(
widget
is
Text
)
{
...
@@ -394,16 +367,25 @@ class MinimumTextContrastGuideline extends AccessibilityGuideline {
...
@@ -394,16 +367,25 @@ class MinimumTextContrastGuideline extends AccessibilityGuideline {
}
else
{
}
else
{
throw
StateError
(
'Unexpected widget type:
${widget.runtimeType}
'
);
throw
StateError
(
'Unexpected widget type:
${widget.runtimeType}
'
);
}
}
}
else
if
(
elements
.
length
>
1
)
{
return
Evaluation
.
fail
(
'Multiple nodes with the same label:
${data.label}
\n
'
,
);
}
else
{
// If we can't find the text node then assume the label does not
// correspond to actual text.
return
result
;
}
if
(
isNodeOffScreen
(
paintBounds
WithOffset
,
tester
.
binding
.
window
))
{
if
(
isNodeOffScreen
(
paintBounds
,
tester
.
binding
.
window
))
{
return
const
Evaluation
.
pass
()
;
return
result
;
}
}
final
Map
<
Color
,
int
>
colorHistogram
=
_colorsWithinRect
(
byteData
,
paintBounds
WithOffset
,
image
.
width
,
image
.
height
);
final
Map
<
Color
,
int
>
colorHistogram
=
_colorsWithinRect
(
byteData
,
paintBounds
,
image
.
width
,
image
.
height
);
// Node was too far off screen.
// Node was too far off screen.
if
(
colorHistogram
.
isEmpty
)
{
if
(
colorHistogram
.
isEmpty
)
{
return
const
Evaluation
.
pass
()
;
return
result
;
}
}
final
_ContrastReport
report
=
_ContrastReport
(
colorHistogram
);
final
_ContrastReport
report
=
_ContrastReport
(
colorHistogram
);
...
@@ -412,9 +394,10 @@ class MinimumTextContrastGuideline extends AccessibilityGuideline {
...
@@ -412,9 +394,10 @@ class MinimumTextContrastGuideline extends AccessibilityGuideline {
final
double
targetContrastRatio
=
this
.
targetContrastRatio
(
fontSize
,
bold:
isBold
);
final
double
targetContrastRatio
=
this
.
targetContrastRatio
(
fontSize
,
bold:
isBold
);
if
(
contrastRatio
-
targetContrastRatio
>=
_tolerance
)
{
if
(
contrastRatio
-
targetContrastRatio
>=
_tolerance
)
{
return
const
Evaluation
.
pass
();
return
result
+
const
Evaluation
.
pass
();
}
}
return
Evaluation
.
fail
(
return
result
+
Evaluation
.
fail
(
'
$node
:
\n
'
'
$node
:
\n
'
'Expected contrast ratio of at least
$targetContrastRatio
'
'Expected contrast ratio of at least
$targetContrastRatio
'
'but found
${contrastRatio.toStringAsFixed(2)}
'
'but found
${contrastRatio.toStringAsFixed(2)}
'
...
...
packages/flutter_test/test/accessibility_test.dart
View file @
41b50c22
...
@@ -23,61 +23,6 @@ void main() {
...
@@ -23,61 +23,6 @@ void main() {
handle
.
dispose
();
handle
.
dispose
();
});
});
testWidgets
(
'Multiple text with same label'
,
(
WidgetTester
tester
)
async
{
final
SemanticsHandle
handle
=
tester
.
ensureSemantics
();
await
tester
.
pumpWidget
(
_boilerplate
(
Column
(
children:
const
<
Widget
>[
Text
(
'this is a test'
,
style:
TextStyle
(
fontSize:
14.0
,
color:
Colors
.
black
),
),
Text
(
'this is a test'
,
style:
TextStyle
(
fontSize:
14.0
,
color:
Colors
.
black
),
),
],
),
),
);
await
expectLater
(
tester
,
meetsGuideline
(
textContrastGuideline
));
handle
.
dispose
();
});
testWidgets
(
'Multiple text with same label but Nodes excluded from '
'semantic tree have failing contrast should pass a11y guideline '
,
(
WidgetTester
tester
)
async
{
final
SemanticsHandle
handle
=
tester
.
ensureSemantics
();
await
tester
.
pumpWidget
(
_boilerplate
(
Column
(
children:
const
<
Widget
>[
Text
(
'this is a test'
,
style:
TextStyle
(
fontSize:
14.0
,
color:
Colors
.
black
),
),
SizedBox
(
height:
50
),
Text
(
'this is a test'
,
style:
TextStyle
(
fontSize:
14.0
,
color:
Colors
.
black
),
),
SizedBox
(
height:
50
),
ExcludeSemantics
(
child:
Text
(
'this is a test'
,
style:
TextStyle
(
fontSize:
14.0
,
color:
Colors
.
white
),
),
),
],
),
),
);
await
expectLater
(
tester
,
meetsGuideline
(
textContrastGuideline
));
handle
.
dispose
();
});
testWidgets
(
'white text on black background - Text Widget - direct style'
,
testWidgets
(
'white text on black background - Text Widget - direct style'
,
(
WidgetTester
tester
)
async
{
(
WidgetTester
tester
)
async
{
final
SemanticsHandle
handle
=
tester
.
ensureSemantics
();
final
SemanticsHandle
handle
=
tester
.
ensureSemantics
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment