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
86f30978
Unverified
Commit
86f30978
authored
Sep 27, 2022
by
chunhtai
Committed by
GitHub
Sep 27, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes Text contrast test rect check (#112492)
parent
aa0485ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
17 deletions
+53
-17
accessibility.dart
packages/flutter_test/lib/src/accessibility.dart
+22
-17
accessibility_test.dart
packages/flutter_test/test/accessibility_test.dart
+31
-0
No files found.
packages/flutter_test/lib/src/accessibility.dart
View file @
86f30978
...
...
@@ -3,9 +3,9 @@
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:typed_data'
;
import
'dart:ui'
as
ui
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/widgets.dart'
;
...
...
@@ -350,7 +350,7 @@ class MinimumTextContrastGuideline extends AccessibilityGuideline {
late
bool
isBold
;
double
?
fontSize
;
late
final
Rect
paint
Bounds
;
late
final
Rect
screen
Bounds
;
late
final
Rect
paintBoundsWithOffset
;
final
RenderObject
?
renderBox
=
element
.
renderObject
;
...
...
@@ -358,21 +358,26 @@ class MinimumTextContrastGuideline extends AccessibilityGuideline {
throw
StateError
(
'Unexpected renderObject type:
$renderBox
'
);
}
const
Offset
offset
=
Offset
(
4.0
,
4.0
);
paintBoundsWithOffset
=
Rect
.
fromPoints
(
renderBox
.
localToGlobal
(
renderBox
.
paintBounds
.
topLeft
-
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
);
final
Matrix4
globalTransform
=
renderBox
.
getTransformTo
(
null
);
paintBoundsWithOffset
=
MatrixUtils
.
transformRect
(
globalTransform
,
renderBox
.
paintBounds
.
inflate
(
4.0
));
// The semantics node transform will include root view transform, which is
// not included in renderBox.getTransformTo(null). Manually multiply the
// root transform to the global transform.
final
Matrix4
rootTransform
=
Matrix4
.
identity
();
tester
.
binding
.
renderView
.
applyPaintTransform
(
tester
.
binding
.
renderView
.
child
!,
rootTransform
);
rootTransform
.
multiply
(
globalTransform
);
screenBounds
=
MatrixUtils
.
transformRect
(
rootTransform
,
renderBox
.
paintBounds
);
Rect
nodeBounds
=
node
.
rect
;
SemanticsNode
?
current
=
node
;
while
(
current
!=
null
)
{
final
Matrix4
?
transform
=
current
.
transform
;
if
(
transform
!=
null
)
{
nodeBounds
=
MatrixUtils
.
transformRect
(
transform
,
nodeBounds
);
}
current
=
current
.
parent
;
}
final
Rect
intersection
=
nodeBounds
.
intersect
(
screenBounds
);
if
(
intersection
.
width
<=
0
||
intersection
.
height
<=
0
)
{
// Skip this element since it doesn't correspond to the given semantic
// node.
...
...
packages/flutter_test/test/accessibility_test.dart
View file @
86f30978
...
...
@@ -225,6 +225,37 @@ void main() {
handle
.
dispose
();
});
testWidgets
(
'Correctly identify failures in complex transforms'
,
(
WidgetTester
tester
)
async
{
final
SemanticsHandle
handle
=
tester
.
ensureSemantics
();
await
tester
.
pumpWidget
(
_boilerplate
(
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
100
),
child:
Semantics
(
container:
true
,
child:
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
100
),
child:
Semantics
(
container:
true
,
child:
Container
(
width:
100.0
,
height:
200.0
,
color:
Colors
.
amberAccent
,
child:
const
Text
(
'this'
,
style:
TextStyle
(
color:
Colors
.
amber
),
),
),
),
),
),
),
),
);
await
expectLater
(
tester
,
doesNotMeetGuideline
(
textContrastGuideline
));
handle
.
dispose
();
});
testWidgets
(
'Material text field - default style'
,
(
WidgetTester
tester
)
async
{
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