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
ea6b7587
Unverified
Commit
ea6b7587
authored
Jun 13, 2019
by
Dan Field
Committed by
GitHub
Jun 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix semantics_tester (#34368)
parent
72828d66
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
95 additions
and
27 deletions
+95
-27
date_picker.dart
packages/flutter/lib/src/material/date_picker.dart
+1
-0
paragraph.dart
packages/flutter/lib/src/rendering/paragraph.dart
+7
-6
semantics.dart
packages/flutter/lib/src/semantics/semantics.dart
+1
-1
pubspec.yaml
packages/flutter/pubspec.yaml
+1
-1
date_picker_test.dart
packages/flutter/test/material/date_picker_test.dart
+16
-0
search_test.dart
packages/flutter/test/material/search_test.dart
+2
-1
semantics_test.dart
packages/flutter/test/semantics/semantics_test.dart
+2
-2
semantics_tester.dart
packages/flutter/test/widgets/semantics_tester.dart
+3
-2
semantics_tester_test.dart
packages/flutter/test/widgets/semantics_tester_test.dart
+44
-0
semantics_traversal_test.dart
packages/flutter/test/widgets/semantics_traversal_test.dart
+12
-12
sliver_semantics_test.dart
packages/flutter/test/widgets/sliver_semantics_test.dart
+4
-0
text_test.dart
packages/flutter/test/widgets/text_test.dart
+2
-2
No files found.
packages/flutter/lib/src/material/date_picker.dart
View file @
ea6b7587
...
...
@@ -438,6 +438,7 @@ class DayPicker extends StatelessWidget {
// formatted full date.
label:
'
${localizations.formatDecimal(day)}
,
${localizations.formatFullDate(dayToBuild)}
'
,
selected:
isSelectedDay
,
sortKey:
OrdinalSortKey
(
day
.
toDouble
()),
child:
ExcludeSemantics
(
child:
Text
(
localizations
.
formatDecimal
(
day
),
style:
itemStyle
),
),
...
...
packages/flutter/lib/src/rendering/paragraph.dart
View file @
ea6b7587
...
...
@@ -762,7 +762,7 @@ class RenderParagraph extends RenderBox
TextDirection
currentDirection
=
textDirection
;
Rect
currentRect
;
SemanticsConfiguration
buildSemanticsConfig
(
int
start
,
int
end
,
{
bool
includeText
=
true
}
)
{
SemanticsConfiguration
buildSemanticsConfig
(
int
start
,
int
end
)
{
final
TextDirection
initialDirection
=
currentDirection
;
final
TextSelection
selection
=
TextSelection
(
baseOffset:
start
,
extentOffset:
end
);
final
List
<
ui
.
TextBox
>
rects
=
getBoxesForSelection
(
selection
);
...
...
@@ -784,10 +784,8 @@ class RenderParagraph extends RenderBox
order
+=
1
;
final
SemanticsConfiguration
configuration
=
SemanticsConfiguration
()
..
sortKey
=
OrdinalSortKey
(
order
)
..
textDirection
=
initialDirection
;
if
(
includeText
)
{
configuration
.
label
=
rawLabel
.
substring
(
start
,
end
);
}
..
textDirection
=
initialDirection
..
label
=
rawLabel
.
substring
(
start
,
end
);
return
configuration
;
}
...
...
@@ -805,7 +803,7 @@ class RenderParagraph extends RenderBox
newChildren
.
add
(
node
);
}
final
dynamic
inlineElement
=
_inlineSemanticsElements
[
j
];
final
SemanticsConfiguration
configuration
=
buildSemanticsConfig
(
start
,
end
,
includeText:
false
);
final
SemanticsConfiguration
configuration
=
buildSemanticsConfig
(
start
,
end
);
if
(
inlineElement
!=
null
)
{
// Add semantics for this recognizer.
final
SemanticsNode
node
=
SemanticsNode
();
...
...
@@ -824,6 +822,9 @@ class RenderParagraph extends RenderBox
}
else
if
(
childIndex
<
children
.
length
)
{
// Add semantics for this placeholder. Semantics are precomputed in the children
// argument.
// Placeholders should not get a label, which would come through as an
// object replacement character.
configuration
.
label
=
''
;
final
SemanticsNode
childNode
=
children
.
elementAt
(
childIndex
);
final
TextParentData
parentData
=
child
.
parentData
;
childNode
.
rect
=
Rect
.
fromLTWH
(
...
...
packages/flutter/lib/src/semantics/semantics.dart
View file @
ea6b7587
...
...
@@ -2098,7 +2098,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
properties
.
add
(
DoubleProperty
(
'scrollPosition'
,
scrollPosition
,
defaultValue:
null
));
properties
.
add
(
DoubleProperty
(
'scrollExtentMax'
,
scrollExtentMax
,
defaultValue:
null
));
properties
.
add
(
DoubleProperty
(
'elevation'
,
elevation
,
defaultValue:
0.0
));
properties
.
add
(
DoubleProperty
(
'thicknes'
,
thickness
,
defaultValue:
0.0
));
properties
.
add
(
DoubleProperty
(
'thicknes
s
'
,
thickness
,
defaultValue:
0.0
));
}
/// Returns a string representation of this node and its descendants.
...
...
packages/flutter/pubspec.yaml
View file @
ea6b7587
...
...
@@ -5,7 +5,7 @@ homepage: http://flutter.dev
environment
:
# The pub client defaults to an <2.0.0 sdk constraint which we need to explicitly overwrite.
sdk
:
"
>=2.2.
0
<3.0.0"
sdk
:
"
>=2.2.
2
<3.0.0"
dependencies
:
# To update these, use "flutter update-packages --force-upgrade".
...
...
packages/flutter/test/material/date_picker_test.dart
View file @
ea6b7587
...
...
@@ -449,6 +449,7 @@ void _tests() {
TestSemantics
(
children:
<
TestSemantics
>[
TestSemantics
(
id:
55
,
actions:
<
SemanticsAction
>[
SemanticsAction
.
scrollLeft
,
SemanticsAction
.
scrollRight
],
children:
<
TestSemantics
>[
TestSemantics
(
...
...
@@ -456,7 +457,22 @@ void _tests() {
TestSemantics
(
children:
<
TestSemantics
>[
TestSemantics
(
id:
11
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
hasImplicitScrolling
],
children:
<
TestSemantics
>[
// TODO(dnfield): These shouldn't be here. https://github.com/flutter/flutter/issues/34431
TestSemantics
(),
TestSemantics
(),
TestSemantics
(),
TestSemantics
(),
TestSemantics
(),
TestSemantics
(),
TestSemantics
(),
TestSemantics
(),
TestSemantics
(),
TestSemantics
(),
TestSemantics
(),
TestSemantics
(),
TestSemantics
(
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
],
label:
'1, Friday, January 1, 2016'
,
...
...
packages/flutter/test/material/search_test.dart
View file @
ea6b7587
...
...
@@ -530,7 +530,7 @@ void main() {
SemanticsFlag
.
isTextField
,
SemanticsFlag
.
isFocused
,
SemanticsFlag
.
isHeader
,
SemanticsFlag
.
namesRoute
,
if
(
debugDefaultTargetPlatformOverride
!=
TargetPlatform
.
iOS
)
SemanticsFlag
.
namesRoute
,
],
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
,
...
...
@@ -539,6 +539,7 @@ void main() {
],
label:
'Search'
,
textDirection:
TextDirection
.
ltr
,
textSelection:
const
TextSelection
(
baseOffset:
0
,
extentOffset:
0
),
),
],
),
...
...
packages/flutter/test/semantics/semantics_test.dart
View file @
ea6b7587
...
...
@@ -353,7 +353,7 @@ void main() {
' scrollPosition: null
\n
'
' scrollExtentMax: null
\n
'
' elevation: 0.0
\n
'
' thicknes: 0.0
\n
'
,
' thicknes
s
: 0.0
\n
'
,
);
final
SemanticsConfiguration
config
=
SemanticsConfiguration
()
...
...
@@ -448,7 +448,7 @@ void main() {
' scrollPosition: null
\n
'
' scrollExtentMax: null
\n
'
' elevation: 0.0
\n
'
' thicknes: 0.0
\n
'
,
' thicknes
s
: 0.0
\n
'
,
);
});
...
...
packages/flutter/test/widgets/semantics_tester.dart
View file @
ea6b7587
...
...
@@ -335,7 +335,9 @@ class TestSemantics {
result
=
false
;
return
false
;
}
return
true
;
}
if
(
it
.
moveNext
())
{
return
false
;
}
return
result
;
}
...
...
@@ -603,7 +605,6 @@ class SemanticsTester {
buf
.
writeln
(
' hint:
\'
${node.hint}
\'
,'
);
if
(
node
.
textDirection
!=
null
)
buf
.
writeln
(
' textDirection:
${node.textDirection}
,'
);
if
(
node
.
hasChildren
)
{
buf
.
writeln
(
' children: <TestSemantics>['
);
for
(
final
SemanticsNode
child
in
node
.
debugListChildrenInOrder
(
childOrder
))
{
...
...
packages/flutter/test/widgets/semantics_tester_test.dart
0 → 100644
View file @
ea6b7587
// Copyright 2019 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/gestures.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'semantics_tester.dart'
;
void
main
(
)
{
testWidgets
(
'Semantics tester visits last child'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
const
TextStyle
textStyle
=
TextStyle
(
fontFamily:
'Ahem'
);
await
tester
.
pumpWidget
(
Text
.
rich
(
TextSpan
(
children:
<
TextSpan
>[
const
TextSpan
(
text:
'hello'
),
TextSpan
(
text:
'world'
,
recognizer:
TapGestureRecognizer
()..
onTap
=
()
{
}),
],
style:
textStyle
,
),
textDirection:
TextDirection
.
ltr
,
maxLines:
1
,
),
);
final
TestSemantics
expectedSemantics
=
TestSemantics
.
root
(
children:
<
TestSemantics
>[
TestSemantics
.
rootChild
(
children:
<
TestSemantics
>[
TestSemantics
(
label:
'hello'
,
textDirection:
TextDirection
.
ltr
,
),
TestSemantics
(),
],
),
],
);
expect
(
semantics
,
isNot
(
hasSemantics
(
expectedSemantics
,
ignoreTransform:
true
,
ignoreId:
true
,
ignoreRect:
true
)));
semantics
.
dispose
();
});
}
packages/flutter/test/widgets/semantics_traversal_test.dart
View file @
ea6b7587
...
...
@@ -152,11 +152,11 @@ void main() {
// ┌─────────────────┘
// V
// ┌───┐ ┌─────────┐ ┌───┐
// │ E │
│ │>│ H
│
// └───┘ │
G
│ └───┘
//
V │ │ V
// │ E │
>│ │>│ G
│
// └───┘ │
F
│ └───┘
//
┌───|─────────|───┘
// ┌───┐ │ │ ┌───┐
// │
F │>│ │
│ I │
// │
H │─|─────────|>
│ I │
// └───┘ └─────────┘ └───┘
// ┌─────────────────┘
// V
...
...
@@ -171,11 +171,11 @@ void main() {
// └─────────────────┐
// V
// ┌───┐ ┌─────────┐ ┌───┐
// │ E │<│ │
│ H
│
// └───┘ │
G
│ └───┘
//
V │ │ V
// │ E │<│ │
<│ G
│
// └───┘ │
F
│ └───┘
//
└──|─────────|────┐
// ┌───┐ │ │ ┌───┐
// │
F │ │ │<
│ I │
// │
H │<|─────────|─
│ I │
// └───┘ └─────────┘ └───┘
// └─────────────────┐
// V
...
...
@@ -189,9 +189,9 @@ void main() {
'C'
:
const
Offset
(
40.0
,
0.0
)
&
tenByTen
,
'D'
:
const
Offset
(
60.0
,
0.0
)
&
tenByTen
,
'E'
:
const
Offset
(
0.0
,
20.0
)
&
tenByTen
,
'F'
:
const
Offset
(
0.0
,
40.0
)
&
tenByTen
,
'G'
:
const
Offset
(
20.0
,
20.0
)
&
(
tenByTen
*
2.0
)
,
'H'
:
const
Offset
(
60.0
,
2
0.0
)
&
tenByTen
,
'F'
:
const
Offset
(
20.0
,
20.0
)
&
(
tenByTen
*
2.0
)
,
'G'
:
const
Offset
(
60.0
,
20.0
)
&
tenByTen
,
'H'
:
const
Offset
(
0.0
,
4
0.0
)
&
tenByTen
,
'I'
:
const
Offset
(
60.0
,
40.0
)
&
tenByTen
,
'J'
:
const
Offset
(
0.0
,
60.0
)
&
tenByTen
,
'K'
:
const
Offset
(
20.0
,
60.0
)
&
tenByTen
,
...
...
@@ -208,7 +208,7 @@ void main() {
await
tester
.
test
(
textDirection:
TextDirection
.
rtl
,
children:
children
,
expectedTraversal:
'D C B A
H I G E F
M L K J'
,
expectedTraversal:
'D C B A
G F E I H
M L K J'
,
);
});
...
...
packages/flutter/test/widgets/sliver_semantics_test.dart
View file @
ea6b7587
...
...
@@ -168,6 +168,7 @@ void _tests() {
SemanticsAction
.
scrollUp
,
SemanticsAction
.
scrollDown
,
],
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
hasImplicitScrolling
],
children:
<
TestSemantics
>[
TestSemantics
(
id:
3
,
...
...
@@ -521,6 +522,7 @@ void _tests() {
SemanticsAction
.
scrollUp
,
SemanticsAction
.
scrollDown
,
],
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
hasImplicitScrolling
],
children:
<
TestSemantics
>[
TestSemantics
(
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isHidden
],
...
...
@@ -630,6 +632,7 @@ void _tests() {
SemanticsAction
.
scrollUp
,
SemanticsAction
.
scrollDown
,
],
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
hasImplicitScrolling
],
children:
<
TestSemantics
>[
TestSemantics
(
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isHidden
],
...
...
@@ -994,6 +997,7 @@ void _tests() {
SemanticsAction
.
scrollUp
,
SemanticsAction
.
scrollDown
,
],
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
hasImplicitScrolling
],
children:
<
TestSemantics
>[
TestSemantics
(
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isHidden
],
...
...
packages/flutter/test/widgets/text_test.dart
View file @
ea6b7587
...
...
@@ -218,7 +218,7 @@ void main() {
],
),
TestSemantics
(
label:
' regrettable event'
,
label:
'
this is a
regrettable event'
,
textDirection:
TextDirection
.
ltr
,
),
],
...
...
@@ -414,7 +414,7 @@ void main() {
TestSemantics
(
label:
'INTERRUPTION'
,
textDirection:
TextDirection
.
rtl
,
rect:
const
Rect
.
fromLTRB
(
448.0
,
0.0
,
488
.0
,
80.0
),
rect:
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
40
.0
,
80.0
),
),
TestSemantics
(
label:
'sky'
,
...
...
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