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
2e4d976b
Unverified
Commit
2e4d976b
authored
Apr 12, 2023
by
Bernardo Ferrari
Committed by
GitHub
Apr 12, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
`SemanticsFlag`/`SemanticsAction` cleanup (part 4) (#123329)
`SemanticsFlag`/`SemanticsAction` cleanup (part 4)
parent
b1f8d5df
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
42 deletions
+30
-42
semantics.dart
packages/flutter/lib/src/semantics/semantics.dart
+6
-9
custom_painter_test.dart
packages/flutter/test/widgets/custom_painter_test.dart
+3
-6
semantics_test.dart
packages/flutter/test/widgets/semantics_test.dart
+2
-4
semantics_tester.dart
packages/flutter/test/widgets/semantics_tester.dart
+2
-4
matchers.dart
packages/flutter_test/lib/src/matchers.dart
+5
-1
matchers_test.dart
packages/flutter_test/test/matchers_test.dart
+12
-18
No files found.
packages/flutter/lib/src/semantics/semantics.dart
View file @
2e4d976b
...
...
@@ -672,10 +672,9 @@ class SemanticsData with Diagnosticable {
properties
.
add
(
DoubleProperty
(
'elevation'
,
elevation
,
defaultValue:
0.0
));
properties
.
add
(
DoubleProperty
(
'thickness'
,
thickness
,
defaultValue:
0.0
));
final
List
<
String
>
actionSummary
=
<
String
>[
// ignore: deprecated_member_use
for
(
final
SemanticsAction
action
in
SemanticsAction
.
doNotUseWillBeDeletedWithoutWarningValuesAsList
)
for
(
final
SemanticsAction
action
in
SemanticsAction
.
values
)
if
((
actions
&
action
.
index
)
!=
0
)
describeEnum
(
action
)
,
action
.
name
,
];
final
List
<
String
?>
customSemanticsActionSummary
=
customSemanticsActionIds
!
.
map
<
String
?>((
int
actionId
)
=>
CustomSemanticsAction
.
getAction
(
actionId
)!.
label
)
...
...
@@ -684,10 +683,9 @@ class SemanticsData with Diagnosticable {
properties
.
add
(
IterableProperty
<
String
?>(
'customActions'
,
customSemanticsActionSummary
,
ifEmpty:
null
));
final
List
<
String
>
flagSummary
=
<
String
>[
// ignore: deprecated_member_use
for
(
final
SemanticsFlag
flag
in
SemanticsFlag
.
doNotUseWillBeDeletedWithoutWarningValuesAsList
)
for
(
final
SemanticsFlag
flag
in
SemanticsFlag
.
values
)
if
((
flags
&
flag
.
index
)
!=
0
)
describeEnum
(
flag
)
,
flag
.
name
,
];
properties
.
add
(
IterableProperty
<
String
>(
'flags'
,
flagSummary
,
ifEmpty:
null
));
properties
.
add
(
AttributedStringProperty
(
'label'
,
attributedLabel
));
...
...
@@ -2785,14 +2783,13 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
properties
.
add
(
DiagnosticsProperty
<
Rect
>(
'rect'
,
rect
,
description:
description
,
showName:
false
));
}
properties
.
add
(
IterableProperty
<
String
>(
'tags'
,
tags
?.
map
((
SemanticsTag
tag
)
=>
tag
.
name
),
defaultValue:
null
));
final
List
<
String
>
actions
=
_actions
.
keys
.
map
<
String
>((
SemanticsAction
action
)
=>
'
${
describeEnum(action)
}${_debugIsActionBlocked(action) ? '🚫️' : ''}
'
).
toList
()..
sort
();
final
List
<
String
>
actions
=
_actions
.
keys
.
map
<
String
>((
SemanticsAction
action
)
=>
'
${
action.name
}${_debugIsActionBlocked(action) ? '🚫️' : ''}
'
).
toList
()..
sort
();
final
List
<
String
?>
customSemanticsActions
=
_customSemanticsActions
.
keys
.
map
<
String
?>((
CustomSemanticsAction
action
)
=>
action
.
label
)
.
toList
();
properties
.
add
(
IterableProperty
<
String
>(
'actions'
,
actions
,
ifEmpty:
null
));
properties
.
add
(
IterableProperty
<
String
?>(
'customActions'
,
customSemanticsActions
,
ifEmpty:
null
));
// ignore: deprecated_member_use
final
List
<
String
>
flags
=
SemanticsFlag
.
doNotUseWillBeDeletedWithoutWarningValuesAsList
.
where
((
SemanticsFlag
flag
)
=>
hasFlag
(
flag
)).
map
((
SemanticsFlag
flag
)
=>
flag
.
toString
().
substring
(
'SemanticsFlag.'
.
length
)).
toList
();
final
List
<
String
>
flags
=
SemanticsFlag
.
values
.
where
((
SemanticsFlag
flag
)
=>
hasFlag
(
flag
)).
map
((
SemanticsFlag
flag
)
=>
flag
.
name
).
toList
();
properties
.
add
(
IterableProperty
<
String
>(
'flags'
,
flags
,
ifEmpty:
null
));
properties
.
add
(
FlagProperty
(
'isInvisible'
,
value:
isInvisible
,
ifTrue:
'invisible'
));
properties
.
add
(
FlagProperty
(
'isHidden'
,
value:
hasFlag
(
SemanticsFlag
.
isHidden
),
ifTrue:
'HIDDEN'
));
...
...
packages/flutter/test/widgets/custom_painter_test.dart
View file @
2e4d976b
...
...
@@ -346,8 +346,7 @@ void _defineTests() {
),
),
));
// ignore: deprecated_member_use
final
Set
<
SemanticsAction
>
allActions
=
SemanticsAction
.
doNotUseWillBeDeletedWithoutWarningValuesAsList
.
toSet
()
final
Set
<
SemanticsAction
>
allActions
=
SemanticsAction
.
values
.
toSet
()
..
remove
(
SemanticsAction
.
customAction
)
// customAction is not user-exposed.
..
remove
(
SemanticsAction
.
showOnScreen
);
// showOnScreen is not user-exposed
...
...
@@ -445,8 +444,7 @@ void _defineTests() {
),
),
));
// ignore: deprecated_member_use
List
<
SemanticsFlag
>
flags
=
SemanticsFlag
.
doNotUseWillBeDeletedWithoutWarningValuesAsList
.
toList
();
List
<
SemanticsFlag
>
flags
=
SemanticsFlag
.
values
.
toList
();
// [SemanticsFlag.hasImplicitScrolling] isn't part of [SemanticsProperties]
// therefore it has to be removed.
flags
...
...
@@ -500,8 +498,7 @@ void _defineTests() {
),
),
));
// ignore: deprecated_member_use
flags
=
SemanticsFlag
.
doNotUseWillBeDeletedWithoutWarningValuesAsList
.
toList
();
flags
=
SemanticsFlag
.
values
.
toList
();
// [SemanticsFlag.hasImplicitScrolling] isn't part of [SemanticsProperties]
// therefore it has to be removed.
flags
...
...
packages/flutter/test/widgets/semantics_test.dart
View file @
2e4d976b
...
...
@@ -519,8 +519,7 @@ void main() {
),
);
// ignore: deprecated_member_use
final
Set
<
SemanticsAction
>
allActions
=
SemanticsAction
.
doNotUseWillBeDeletedWithoutWarningValuesAsList
.
toSet
()
final
Set
<
SemanticsAction
>
allActions
=
SemanticsAction
.
values
.
toSet
()
..
remove
(
SemanticsAction
.
moveCursorForwardByWord
)
..
remove
(
SemanticsAction
.
moveCursorBackwardByWord
)
..
remove
(
SemanticsAction
.
customAction
)
// customAction is not user-exposed.
...
...
@@ -612,8 +611,7 @@ void main() {
liveRegion:
true
,
),
);
// ignore: deprecated_member_use
final
List
<
SemanticsFlag
>
flags
=
SemanticsFlag
.
doNotUseWillBeDeletedWithoutWarningValuesAsList
.
toList
();
final
List
<
SemanticsFlag
>
flags
=
SemanticsFlag
.
values
.
toList
();
flags
..
remove
(
SemanticsFlag
.
hasToggledState
)
..
remove
(
SemanticsFlag
.
isToggled
)
...
...
packages/flutter/test/widgets/semantics_tester.dart
View file @
2e4d976b
...
...
@@ -633,8 +633,7 @@ class SemanticsTester {
static
String
_flagsToSemanticsFlagExpression
(
dynamic
flags
)
{
Iterable
<
SemanticsFlag
>
list
;
if
(
flags
is
int
)
{
// ignore: deprecated_member_use
list
=
SemanticsFlag
.
doNotUseWillBeDeletedWithoutWarningValuesAsList
list
=
SemanticsFlag
.
values
.
where
((
SemanticsFlag
flag
)
=>
(
flag
.
index
&
flags
)
!=
0
);
}
else
{
list
=
flags
as
List
<
SemanticsFlag
>;
...
...
@@ -649,8 +648,7 @@ class SemanticsTester {
static String _actionsToSemanticsActionExpression(dynamic actions) {
Iterable<SemanticsAction> list;
if (actions is int) {
// ignore: deprecated_member_use
list = SemanticsAction.doNotUseWillBeDeletedWithoutWarningValuesAsList
list = SemanticsAction.values
.where((SemanticsAction action) => (action.index & actions) != 0);
} else {
list = actions as List<SemanticsAction>;
...
...
packages/flutter_test/lib/src/matchers.dart
View file @
2e4d976b
...
...
@@ -2533,7 +2533,11 @@ class _MatchesSemanticsData extends Matcher {
static
String
_createEnumsSummary
<
T
extends
Object
>(
List
<
T
>
enums
)
{
assert
(
T
==
SemanticsAction
||
T
==
SemanticsFlag
,
'This method is only intended for lists of SemanticsActions or SemanticsFlags.'
);
return
'[
${enums.map(describeEnum).join(', ')}
]'
;
if
(
T
==
SemanticsAction
)
{
return
'[
${(enums as List<SemanticsAction>).map((SemanticsAction d) => d.name).join(', ')}
]'
;
}
else
{
return
'[
${(enums as List<SemanticsFlag>).map((SemanticsFlag d) => d.name).join(', ')}
]'
;
}
}
}
...
...
packages/flutter_test/test/matchers_test.dart
View file @
2e4d976b
...
...
@@ -613,13 +613,11 @@ void main() {
int
actions
=
0
;
int
flags
=
0
;
const
CustomSemanticsAction
action
=
CustomSemanticsAction
(
label:
'test'
);
// ignore: deprecated_member_use
for
(
final
int
index
in
SemanticsAction
.
doNotUseWillBeDeletedWithoutWarningKeys
)
{
actions
|=
index
;
for
(
final
SemanticsAction
action
in
SemanticsAction
.
values
)
{
actions
|=
action
.
index
;
}
// ignore: deprecated_member_use
for
(
final
int
index
in
SemanticsFlag
.
doNotUseWillBeDeletedWithoutWarningKeys
)
{
flags
|=
index
;
for
(
final
SemanticsFlag
flag
in
SemanticsFlag
.
values
)
{
flags
|=
flag
.
index
;
}
final
SemanticsData
data
=
SemanticsData
(
flags:
flags
,
...
...
@@ -897,13 +895,11 @@ void main() {
int
actions
=
0
;
int
flags
=
0
;
const
CustomSemanticsAction
action
=
CustomSemanticsAction
(
label:
'test'
);
// ignore: deprecated_member_use
for
(
final
int
index
in
SemanticsAction
.
doNotUseWillBeDeletedWithoutWarningKeys
)
{
actions
|=
index
;
for
(
final
SemanticsAction
action
in
SemanticsAction
.
values
)
{
actions
|=
action
.
index
;
}
// ignore: deprecated_member_use
for
(
final
int
index
in
SemanticsFlag
.
doNotUseWillBeDeletedWithoutWarningKeys
)
{
flags
|=
index
;
for
(
final
SemanticsFlag
flag
in
SemanticsFlag
.
values
)
{
flags
|=
flag
.
index
;
}
final
SemanticsData
data
=
SemanticsData
(
flags:
flags
,
...
...
@@ -1085,13 +1081,11 @@ void main() {
testWidgets
(
'only matches given flags and actions'
,
(
WidgetTester
tester
)
async
{
int
allActions
=
0
;
int
allFlags
=
0
;
// ignore: deprecated_member_use
for
(
final
int
index
in
SemanticsAction
.
doNotUseWillBeDeletedWithoutWarningKeys
)
{
allActions
|=
index
;
for
(
final
SemanticsAction
action
in
SemanticsAction
.
values
)
{
allActions
|=
action
.
index
;
}
// ignore: deprecated_member_use
for
(
final
int
index
in
SemanticsFlag
.
doNotUseWillBeDeletedWithoutWarningKeys
)
{
allFlags
|=
index
;
for
(
final
SemanticsFlag
flag
in
SemanticsFlag
.
values
)
{
allFlags
|=
flag
.
index
;
}
final
SemanticsData
emptyData
=
SemanticsData
(
flags:
0
,
...
...
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