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
cdf1cec9
Unverified
Commit
cdf1cec9
authored
Oct 06, 2018
by
Jonah Williams
Committed by
GitHub
Oct 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add ability to match child semantics data (#22001)
parent
21a32fdd
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
307 additions
and
62 deletions
+307
-62
chip_demo_test.dart
...es/flutter_gallery/test/demo/material/chip_demo_test.dart
+2
-2
slider_test.dart
packages/flutter/test/cupertino/slider_test.dart
+2
-2
back_button_test.dart
packages/flutter/test/material/back_button_test.dart
+1
-1
checkbox_test.dart
packages/flutter/test/material/checkbox_test.dart
+5
-5
dropdown_test.dart
packages/flutter/test/material/dropdown_test.dart
+2
-2
expand_icon_test.dart
packages/flutter/test/material/expand_icon_test.dart
+2
-2
expansion_panel_test.dart
packages/flutter/test/material/expansion_panel_test.dart
+2
-2
reorderable_list_test.dart
packages/flutter/test/material/reorderable_list_test.dart
+2
-2
snack_bar_test.dart
packages/flutter/test/material/snack_bar_test.dart
+1
-1
user_accounts_drawer_header_test.dart
...utter/test/material/user_accounts_drawer_header_test.dart
+3
-3
image_icon_test.dart
packages/flutter/test/widgets/image_icon_test.dart
+1
-1
semantics_test.dart
packages/flutter/test/widgets/semantics_test.dart
+3
-3
matchers.dart
packages/flutter_test/lib/src/matchers.dart
+204
-22
widget_tester.dart
packages/flutter_test/lib/src/widget_tester.dart
+27
-3
matchers_test.dart
packages/flutter_test/test/matchers_test.dart
+44
-7
widget_tester_test.dart
packages/flutter_test/test/widget_tester_test.dart
+6
-4
No files found.
examples/flutter_gallery/test/demo/material/chip_demo_test.dart
View file @
cdf1cec9
...
@@ -14,7 +14,7 @@ void main() {
...
@@ -14,7 +14,7 @@ void main() {
home:
ChipDemo
(),
home:
ChipDemo
(),
));
));
expect
(
tester
.
getSemantics
Data
(
find
.
byIcon
(
Icons
.
vignette
)),
matchesSemanticsData
(
expect
(
tester
.
getSemantics
(
find
.
byIcon
(
Icons
.
vignette
)),
matchesSemantics
(
isButton:
true
,
isButton:
true
,
hasEnabledState:
true
,
hasEnabledState:
true
,
isEnabled:
true
,
isEnabled:
true
,
...
@@ -22,7 +22,7 @@ void main() {
...
@@ -22,7 +22,7 @@ void main() {
label:
'Update border shape'
,
label:
'Update border shape'
,
));
));
expect
(
tester
.
getSemantics
Data
(
find
.
byIcon
(
Icons
.
refresh
)),
matchesSemanticsData
(
expect
(
tester
.
getSemantics
(
find
.
byIcon
(
Icons
.
refresh
)),
matchesSemantics
(
isButton:
true
,
isButton:
true
,
hasEnabledState:
true
,
hasEnabledState:
true
,
isEnabled:
true
,
isEnabled:
true
,
...
...
packages/flutter/test/cupertino/slider_test.dart
View file @
cdf1cec9
...
@@ -330,7 +330,7 @@ void main() {
...
@@ -330,7 +330,7 @@ void main() {
),
),
));
));
expect
(
tester
.
getSemantics
Data
(
find
.
byType
(
CupertinoSlider
)),
matchesSemanticsData
(
expect
(
tester
.
getSemantics
(
find
.
byType
(
CupertinoSlider
)),
matchesSemantics
(
hasIncreaseAction:
true
,
hasIncreaseAction:
true
,
hasDecreaseAction:
true
,
hasDecreaseAction:
true
,
value:
'50%'
,
value:
'50%'
,
...
@@ -348,7 +348,7 @@ void main() {
...
@@ -348,7 +348,7 @@ void main() {
),
),
));
));
expect
(
tester
.
getSemantics
Data
(
find
.
byType
(
CupertinoSlider
)),
matchesSemanticsData
(
expect
(
tester
.
getSemantics
(
find
.
byType
(
CupertinoSlider
)),
matchesSemantics
(
hasIncreaseAction:
true
,
hasIncreaseAction:
true
,
hasDecreaseAction:
true
,
hasDecreaseAction:
true
,
value:
'60%'
,
value:
'60%'
,
...
...
packages/flutter/test/material/back_button_test.dart
View file @
cdf1cec9
...
@@ -82,7 +82,7 @@ void main() {
...
@@ -82,7 +82,7 @@ void main() {
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
tester
.
getSemantics
Data
(
find
.
byType
(
BackButton
)),
matchesSemanticsData
(
expect
(
tester
.
getSemantics
(
find
.
byType
(
BackButton
)),
matchesSemantics
(
label:
'Back'
,
label:
'Back'
,
isButton:
true
,
isButton:
true
,
hasEnabledState:
true
,
hasEnabledState:
true
,
...
...
packages/flutter/test/material/checkbox_test.dart
View file @
cdf1cec9
...
@@ -66,7 +66,7 @@ void main() {
...
@@ -66,7 +66,7 @@ void main() {
),
),
));
));
expect
(
tester
.
getSemantics
Data
(
find
.
byType
(
Checkbox
)),
matchesSemanticsData
(
expect
(
tester
.
getSemantics
(
find
.
byType
(
Checkbox
)),
matchesSemantics
(
hasCheckedState:
true
,
hasCheckedState:
true
,
hasEnabledState:
true
,
hasEnabledState:
true
,
isEnabled:
true
,
isEnabled:
true
,
...
@@ -80,7 +80,7 @@ void main() {
...
@@ -80,7 +80,7 @@ void main() {
),
),
));
));
expect
(
tester
.
getSemantics
Data
(
find
.
byType
(
Checkbox
)),
matchesSemanticsData
(
expect
(
tester
.
getSemantics
(
find
.
byType
(
Checkbox
)),
matchesSemantics
(
hasCheckedState:
true
,
hasCheckedState:
true
,
hasEnabledState:
true
,
hasEnabledState:
true
,
isChecked:
true
,
isChecked:
true
,
...
@@ -95,7 +95,7 @@ void main() {
...
@@ -95,7 +95,7 @@ void main() {
),
),
));
));
expect
(
tester
.
getSemantics
Data
(
find
.
byType
(
Checkbox
)),
matchesSemanticsData
(
expect
(
tester
.
getSemantics
(
find
.
byType
(
Checkbox
)),
matchesSemantics
(
hasCheckedState:
true
,
hasCheckedState:
true
,
hasEnabledState:
true
,
hasEnabledState:
true
,
));
));
...
@@ -107,7 +107,7 @@ void main() {
...
@@ -107,7 +107,7 @@ void main() {
),
),
));
));
expect
(
tester
.
getSemantics
Data
(
find
.
byType
(
Checkbox
)),
matchesSemanticsData
(
expect
(
tester
.
getSemantics
(
find
.
byType
(
Checkbox
)),
matchesSemantics
(
hasCheckedState:
true
,
hasCheckedState:
true
,
hasEnabledState:
true
,
hasEnabledState:
true
,
isChecked:
true
,
isChecked:
true
,
...
@@ -129,7 +129,7 @@ void main() {
...
@@ -129,7 +129,7 @@ void main() {
),
),
));
));
expect
(
tester
.
getSemantics
Data
(
find
.
byType
(
Checkbox
)),
matchesSemanticsData
(
expect
(
tester
.
getSemantics
(
find
.
byType
(
Checkbox
)),
matchesSemantics
(
label:
'foo'
,
label:
'foo'
,
textDirection:
TextDirection
.
ltr
,
textDirection:
TextDirection
.
ltr
,
hasCheckedState:
true
,
hasCheckedState:
true
,
...
...
packages/flutter/test/material/dropdown_test.dart
View file @
cdf1cec9
...
@@ -692,7 +692,7 @@ void main() {
...
@@ -692,7 +692,7 @@ void main() {
));
));
// By default the hint contributes the label.
// By default the hint contributes the label.
expect
(
tester
.
getSemantics
Data
(
find
.
byKey
(
key
)),
matchesSemanticsData
(
expect
(
tester
.
getSemantics
(
find
.
byKey
(
key
)),
matchesSemantics
(
isButton:
true
,
isButton:
true
,
label:
'test'
,
label:
'test'
,
hasTapAction:
true
,
hasTapAction:
true
,
...
@@ -707,7 +707,7 @@ void main() {
...
@@ -707,7 +707,7 @@ void main() {
));
));
// Displays label of select item and is no longer tappable.
// Displays label of select item and is no longer tappable.
expect
(
tester
.
getSemantics
Data
(
find
.
byKey
(
key
)),
matchesSemanticsData
(
expect
(
tester
.
getSemantics
(
find
.
byKey
(
key
)),
matchesSemantics
(
isButton:
true
,
isButton:
true
,
label:
'three'
,
label:
'three'
,
hasTapAction:
true
,
hasTapAction:
true
,
...
...
packages/flutter/test/material/expand_icon_test.dart
View file @
cdf1cec9
...
@@ -95,7 +95,7 @@ void main() {
...
@@ -95,7 +95,7 @@ void main() {
)
)
));
));
expect
(
tester
.
getSemantics
Data
(
find
.
byType
(
ExpandIcon
)),
matchesSemanticsData
(
expect
(
tester
.
getSemantics
(
find
.
byType
(
ExpandIcon
)),
matchesSemantics
(
hasTapAction:
true
,
hasTapAction:
true
,
hasEnabledState:
true
,
hasEnabledState:
true
,
isEnabled:
true
,
isEnabled:
true
,
...
@@ -110,7 +110,7 @@ void main() {
...
@@ -110,7 +110,7 @@ void main() {
)
)
));
));
expect
(
tester
.
getSemantics
Data
(
find
.
byType
(
ExpandIcon
)),
matchesSemanticsData
(
expect
(
tester
.
getSemantics
(
find
.
byType
(
ExpandIcon
)),
matchesSemantics
(
hasTapAction:
true
,
hasTapAction:
true
,
hasEnabledState:
true
,
hasEnabledState:
true
,
isEnabled:
true
,
isEnabled:
true
,
...
...
packages/flutter/test/material/expansion_panel_test.dart
View file @
cdf1cec9
...
@@ -382,7 +382,7 @@ void main() {
...
@@ -382,7 +382,7 @@ void main() {
),
),
);
);
expect
(
tester
.
getSemantics
Data
(
find
.
byKey
(
expandedKey
)),
matchesSemanticsData
(
expect
(
tester
.
getSemantics
(
find
.
byKey
(
expandedKey
)),
matchesSemantics
(
label:
'Expanded'
,
label:
'Expanded'
,
isButton:
true
,
isButton:
true
,
hasEnabledState:
true
,
hasEnabledState:
true
,
...
@@ -391,7 +391,7 @@ void main() {
...
@@ -391,7 +391,7 @@ void main() {
onTapHint:
localizations
.
expandedIconTapHint
,
onTapHint:
localizations
.
expandedIconTapHint
,
));
));
expect
(
tester
.
getSemantics
Data
(
find
.
byKey
(
collapsedKey
)),
matchesSemanticsData
(
expect
(
tester
.
getSemantics
(
find
.
byKey
(
collapsedKey
)),
matchesSemantics
(
label:
'Collapsed'
,
label:
'Collapsed'
,
isButton:
true
,
isButton:
true
,
hasEnabledState:
true
,
hasEnabledState:
true
,
...
...
packages/flutter/test/material/reorderable_list_test.dart
View file @
cdf1cec9
...
@@ -462,10 +462,10 @@ void main() {
...
@@ -462,10 +462,10 @@ void main() {
));
));
// Get the switch tile's semantics:
// Get the switch tile's semantics:
final
Semantics
Data
semanticsData
=
tester
.
getSemanticsData
(
find
.
byKey
(
const
Key
(
'Switch tile'
)));
final
Semantics
Node
semanticsNode
=
tester
.
getSemantics
(
find
.
byKey
(
const
Key
(
'Switch tile'
)));
// Check for properties of both SwitchTile semantics and the ReorderableListView custom semantics actions.
// Check for properties of both SwitchTile semantics and the ReorderableListView custom semantics actions.
expect
(
semantics
Data
,
matchesSemanticsData
(
expect
(
semantics
Node
,
matchesSemantics
(
hasToggledState:
true
,
hasToggledState:
true
,
isToggled:
true
,
isToggled:
true
,
isEnabled:
true
,
isEnabled:
true
,
...
...
packages/flutter/test/material/snack_bar_test.dart
View file @
cdf1cec9
...
@@ -555,7 +555,7 @@ void main() {
...
@@ -555,7 +555,7 @@ void main() {
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
tester
.
getSemantics
Data
(
find
.
text
(
'snack'
)),
matchesSemanticsData
(
expect
(
tester
.
getSemantics
(
find
.
text
(
'snack'
)),
matchesSemantics
(
isLiveRegion:
true
,
isLiveRegion:
true
,
hasDismissAction:
true
,
hasDismissAction:
true
,
hasScrollDownAction:
true
,
hasScrollDownAction:
true
,
...
...
packages/flutter/test/material/user_accounts_drawer_header_test.dart
View file @
cdf1cec9
...
@@ -378,17 +378,17 @@ void main() {
...
@@ -378,17 +378,17 @@ void main() {
final
SemanticsHandle
handle
=
tester
.
ensureSemantics
();
final
SemanticsHandle
handle
=
tester
.
ensureSemantics
();
await
pumpTestWidget
(
tester
);
await
pumpTestWidget
(
tester
);
expect
(
tester
.
getSemantics
Data
(
find
.
text
(
'B'
)),
matchesSemanticsData
(
expect
(
tester
.
getSemantics
(
find
.
text
(
'B'
)),
matchesSemantics
(
label:
'B'
,
label:
'B'
,
size:
const
Size
(
48.0
,
48.0
),
size:
const
Size
(
48.0
,
48.0
),
));
));
expect
(
tester
.
getSemantics
Data
(
find
.
text
(
'C'
)),
matchesSemanticsData
(
expect
(
tester
.
getSemantics
(
find
.
text
(
'C'
)),
matchesSemantics
(
label:
'C'
,
label:
'C'
,
size:
const
Size
(
48.0
,
48.0
),
size:
const
Size
(
48.0
,
48.0
),
));
));
expect
(
tester
.
getSemantics
Data
(
find
.
text
(
'D'
)),
matchesSemanticsData
(
expect
(
tester
.
getSemantics
(
find
.
text
(
'D'
)),
matchesSemantics
(
label:
'D'
,
label:
'D'
,
size:
const
Size
(
48.0
,
48.0
),
size:
const
Size
(
48.0
,
48.0
),
));
));
...
...
packages/flutter/test/widgets/image_icon_test.dart
View file @
cdf1cec9
...
@@ -111,7 +111,7 @@ void main() {
...
@@ -111,7 +111,7 @@ void main() {
),
),
);
);
expect
(
tester
.
getSemantics
Data
(
find
.
byType
(
ImageIcon
)),
matchesSemanticsData
(
expect
(
tester
.
getSemantics
(
find
.
byType
(
ImageIcon
)),
matchesSemantics
(
label:
'test'
,
label:
'test'
,
textDirection:
TextDirection
.
ltr
,
textDirection:
TextDirection
.
ltr
,
));
));
...
...
packages/flutter/test/widgets/semantics_test.dart
View file @
cdf1cec9
...
@@ -643,7 +643,7 @@ void main() {
...
@@ -643,7 +643,7 @@ void main() {
onTapHint:
'test'
,
onTapHint:
'test'
,
));
));
expect
(
tester
.
getSemantics
Data
(
find
.
byType
(
Semantics
)),
matchesSemanticsData
(
expect
(
tester
.
getSemantics
(
find
.
byType
(
Semantics
)),
matchesSemantics
(
hasTapAction:
true
,
hasTapAction:
true
,
onTapHint:
'test'
onTapHint:
'test'
));
));
...
@@ -654,7 +654,7 @@ void main() {
...
@@ -654,7 +654,7 @@ void main() {
onLongPressHint:
'foo'
,
onLongPressHint:
'foo'
,
));
));
expect
(
tester
.
getSemantics
Data
(
find
.
byType
(
Semantics
)),
matchesSemanticsData
(
expect
(
tester
.
getSemantics
(
find
.
byType
(
Semantics
)),
matchesSemantics
(
hasLongPressAction:
true
,
hasLongPressAction:
true
,
onLongPressHint:
'foo'
onLongPressHint:
'foo'
));
));
...
@@ -671,7 +671,7 @@ void main() {
...
@@ -671,7 +671,7 @@ void main() {
},
},
));
));
expect
(
tester
.
getSemantics
Data
(
find
.
byType
(
Semantics
)),
matchesSemanticsData
(
expect
(
tester
.
getSemantics
(
find
.
byType
(
Semantics
)),
matchesSemantics
(
customActions:
<
CustomSemanticsAction
>[
customActions:
<
CustomSemanticsAction
>[
const
CustomSemanticsAction
(
label:
'bar'
),
const
CustomSemanticsAction
(
label:
'bar'
),
const
CustomSemanticsAction
(
label:
'foo'
),
const
CustomSemanticsAction
(
label:
'foo'
),
...
...
packages/flutter_test/lib/src/matchers.dart
View file @
cdf1cec9
This diff is collapsed.
Click to expand it.
packages/flutter_test/lib/src/widget_tester.dart
View file @
cdf1cec9
...
@@ -617,15 +617,39 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
...
@@ -617,15 +617,39 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
});
});
}
}
/// Attempts to find the [Semantics
Data
] of first result from `finder`.
/// Attempts to find the [Semantics
Node
] of first result from `finder`.
///
///
/// If the object identified by the finder doesn't own it's semantic node,
/// If the object identified by the finder doesn't own it's semantic node,
/// this will return the semantics data of the first ancestor with semantics
/// this will return the semantics data of the first ancestor with semantics
.
///
data.
The ancestor's semantic data will include the child's as well as
/// The ancestor's semantic data will include the child's as well as
/// other nodes that have been merged together.
/// other nodes that have been merged together.
///
///
/// Will throw a [StateError] if the finder returns more than one element or
/// Will throw a [StateError] if the finder returns more than one element or
/// if no semantics are found or are not enabled.
/// if no semantics are found or are not enabled.
SemanticsNode
getSemantics
(
Finder
finder
)
{
if
(
binding
.
pipelineOwner
.
semanticsOwner
==
null
)
throw
StateError
(
'Semantics are not enabled.'
);
final
Iterable
<
Element
>
candidates
=
finder
.
evaluate
();
if
(
candidates
.
isEmpty
)
{
throw
StateError
(
'Finder returned no matching elements.'
);
}
if
(
candidates
.
length
>
1
)
{
throw
StateError
(
'Finder returned more than one element.'
);
}
final
Element
element
=
candidates
.
single
;
RenderObject
renderObject
=
element
.
findRenderObject
();
SemanticsNode
result
=
renderObject
.
debugSemantics
;
while
(
renderObject
!=
null
&&
result
==
null
)
{
renderObject
=
renderObject
?.
parent
;
result
=
renderObject
?.
debugSemantics
;
}
if
(
result
==
null
)
throw
StateError
(
'No Semantics data found.'
);
return
result
;
}
/// DEPRECATED: use [getSemantics] instead.
@Deprecated
(
'use getSemantics instead'
)
SemanticsData
getSemanticsData
(
Finder
finder
)
{
SemanticsData
getSemanticsData
(
Finder
finder
)
{
if
(
binding
.
pipelineOwner
.
semanticsOwner
==
null
)
if
(
binding
.
pipelineOwner
.
semanticsOwner
==
null
)
throw
StateError
(
'Semantics are not enabled.'
);
throw
StateError
(
'Semantics are not enabled.'
);
...
...
packages/flutter_test/test/matchers_test.dart
View file @
cdf1cec9
...
@@ -409,8 +409,8 @@ void main() {
...
@@ -409,8 +409,8 @@ void main() {
},
},
));
));
expect
(
tester
.
getSemantics
Data
(
find
.
byKey
(
key
)),
expect
(
tester
.
getSemantics
(
find
.
byKey
(
key
)),
matchesSemantics
Data
(
matchesSemantics
(
label:
'foo'
,
label:
'foo'
,
hint:
'bar'
,
hint:
'bar'
,
value:
'baz'
,
value:
'baz'
,
...
@@ -432,8 +432,8 @@ void main() {
...
@@ -432,8 +432,8 @@ void main() {
);
);
// Doesn't match custom actions
// Doesn't match custom actions
expect
(
tester
.
getSemantics
Data
(
find
.
byKey
(
key
)),
expect
(
tester
.
getSemantics
(
find
.
byKey
(
key
)),
isNot
(
matchesSemantics
Data
(
isNot
(
matchesSemantics
(
label:
'foo'
,
label:
'foo'
,
hint:
'bar'
,
hint:
'bar'
,
value:
'baz'
,
value:
'baz'
,
...
@@ -453,8 +453,8 @@ void main() {
...
@@ -453,8 +453,8 @@ void main() {
);
);
// Doesn't match wrong hints
// Doesn't match wrong hints
expect
(
tester
.
getSemantics
Data
(
find
.
byKey
(
key
)),
expect
(
tester
.
getSemantics
(
find
.
byKey
(
key
)),
isNot
(
matchesSemantics
Data
(
isNot
(
matchesSemantics
(
label:
'foo'
,
label:
'foo'
,
hint:
'bar'
,
hint:
'bar'
,
value:
'baz'
,
value:
'baz'
,
...
@@ -500,8 +500,10 @@ void main() {
...
@@ -500,8 +500,10 @@ void main() {
scrollExtentMin:
null
,
scrollExtentMin:
null
,
customSemanticsActionIds:
<
int
>[
CustomSemanticsAction
.
getIdentifier
(
action
)],
customSemanticsActionIds:
<
int
>[
CustomSemanticsAction
.
getIdentifier
(
action
)],
);
);
final
_FakeSemanticsNode
node
=
_FakeSemanticsNode
();
node
.
data
=
data
;
expect
(
data
,
matchesSemanticsData
(
expect
(
node
,
matchesSemantics
(
rect:
Rect
.
fromLTRB
(
0.0
,
0.0
,
10.0
,
10.0
),
rect:
Rect
.
fromLTRB
(
0.0
,
0.0
,
10.0
,
10.0
),
size:
const
Size
(
10.0
,
10.0
),
size:
const
Size
(
10.0
,
10.0
),
/* Flags */
/* Flags */
...
@@ -548,6 +550,35 @@ void main() {
...
@@ -548,6 +550,35 @@ void main() {
customActions:
<
CustomSemanticsAction
>[
action
],
customActions:
<
CustomSemanticsAction
>[
action
],
));
));
});
});
testWidgets
(
'Can match child semantics'
,
(
WidgetTester
tester
)
async
{
final
SemanticsHandle
handle
=
tester
.
ensureSemantics
();
const
Key
key
=
Key
(
'a'
);
await
tester
.
pumpWidget
(
Semantics
(
key:
key
,
label:
'Foo'
,
container:
true
,
explicitChildNodes:
true
,
textDirection:
TextDirection
.
ltr
,
child:
Semantics
(
label:
'Bar'
,
textDirection:
TextDirection
.
ltr
,
),
));
final
SemanticsNode
node
=
tester
.
getSemantics
(
find
.
byKey
(
key
));
expect
(
node
,
matchesSemantics
(
label:
'Foo'
,
textDirection:
TextDirection
.
ltr
,
children:
<
Matcher
>[
matchesSemantics
(
label:
'Bar'
,
textDirection:
TextDirection
.
ltr
,
),
],
));
handle
.
dispose
();
});
});
});
}
}
...
@@ -592,3 +623,9 @@ class _FakeComparator implements GoldenFileComparator {
...
@@ -592,3 +623,9 @@ class _FakeComparator implements GoldenFileComparator {
return
Future
<
void
>.
value
();
return
Future
<
void
>.
value
();
}
}
}
}
class
_FakeSemanticsNode
extends
SemanticsNode
{
SemanticsData
data
;
@override
SemanticsData
getSemanticsData
()
=>
data
;
}
\ No newline at end of file
packages/flutter_test/test/widget_tester_test.dart
View file @
cdf1cec9
...
@@ -540,7 +540,7 @@ void main() {
...
@@ -540,7 +540,7 @@ void main() {
),
),
);
);
expect
(()
=>
tester
.
getSemantics
Data
(
find
.
text
(
'hello'
)),
expect
(()
=>
tester
.
getSemantics
(
find
.
text
(
'hello'
)),
throwsA
(
isInstanceOf
<
StateError
>()));
throwsA
(
isInstanceOf
<
StateError
>()));
});
});
...
@@ -560,7 +560,7 @@ void main() {
...
@@ -560,7 +560,7 @@ void main() {
),
),
);
);
expect
(()
=>
tester
.
getSemantics
Data
(
find
.
text
(
'hello'
)),
expect
(()
=>
tester
.
getSemantics
(
find
.
text
(
'hello'
)),
throwsA
(
isInstanceOf
<
StateError
>()));
throwsA
(
isInstanceOf
<
StateError
>()));
semanticsHandle
.
dispose
();
semanticsHandle
.
dispose
();
});
});
...
@@ -581,7 +581,8 @@ void main() {
...
@@ -581,7 +581,8 @@ void main() {
),
),
);
);
final
SemanticsData
semantics
=
tester
.
getSemanticsData
(
find
.
text
(
'hello'
));
final
SemanticsNode
node
=
tester
.
getSemantics
(
find
.
text
(
'hello'
));
final
SemanticsData
semantics
=
node
.
getSemanticsData
();
expect
(
semantics
.
label
,
'hello'
);
expect
(
semantics
.
label
,
'hello'
);
expect
(
semantics
.
hasAction
(
SemanticsAction
.
tap
),
true
);
expect
(
semantics
.
hasAction
(
SemanticsAction
.
tap
),
true
);
expect
(
semantics
.
hasFlag
(
SemanticsFlag
.
isButton
),
true
);
expect
(
semantics
.
hasFlag
(
SemanticsFlag
.
isButton
),
true
);
...
@@ -609,7 +610,8 @@ void main() {
...
@@ -609,7 +610,8 @@ void main() {
),
),
);
);
final
SemanticsData
semantics
=
tester
.
getSemanticsData
(
find
.
byKey
(
key
));
final
SemanticsNode
node
=
tester
.
getSemantics
(
find
.
byKey
(
key
));
final
SemanticsData
semantics
=
node
.
getSemanticsData
();
expect
(
semantics
.
label
,
'A
\n
B
\n
C'
);
expect
(
semantics
.
label
,
'A
\n
B
\n
C'
);
semanticsHandle
.
dispose
();
semanticsHandle
.
dispose
();
});
});
...
...
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