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
80679f0b
Unverified
Commit
80679f0b
authored
Aug 03, 2022
by
Pascal Welsch
Committed by
GitHub
Aug 03, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_test] perf: find.ancestor (#108868)
parent
7270c48b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
2 deletions
+37
-2
finders.dart
packages/flutter_test/lib/src/finders.dart
+4
-2
widget_tester_test.dart
packages/flutter_test/test/widget_tester_test.dart
+33
-0
No files found.
packages/flutter_test/lib/src/finders.dart
View file @
80679f0b
...
...
@@ -923,7 +923,8 @@ class _DescendantFinder extends Finder {
@override
Iterable
<
Element
>
apply
(
Iterable
<
Element
>
candidates
)
{
return
candidates
.
where
((
Element
element
)
=>
descendant
.
evaluate
().
contains
(
element
));
final
Iterable
<
Element
>
descendants
=
descendant
.
evaluate
();
return
candidates
.
where
((
Element
element
)
=>
descendants
.
contains
(
element
));
}
@override
...
...
@@ -956,7 +957,8 @@ class _AncestorFinder extends Finder {
@override
Iterable
<
Element
>
apply
(
Iterable
<
Element
>
candidates
)
{
return
candidates
.
where
((
Element
element
)
=>
ancestor
.
evaluate
().
contains
(
element
));
final
Iterable
<
Element
>
ancestors
=
ancestor
.
evaluate
();
return
candidates
.
where
((
Element
element
)
=>
ancestors
.
contains
(
element
));
}
@override
...
...
packages/flutter_test/test/widget_tester_test.dart
View file @
80679f0b
...
...
@@ -361,6 +361,30 @@ void main() {
matchRoot:
true
,
),
findsOneWidget
);
});
testWidgets
(
'is fast in deep tree'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
_deepWidgetTree
(
depth:
1000
,
child:
Row
(
children:
<
Widget
>[
_deepWidgetTree
(
depth:
1000
,
child:
Column
(
children:
fooBarTexts
),
),
],
),
),
),
);
expect
(
find
.
ancestor
(
of:
find
.
text
(
'bar'
),
matching:
find
.
byType
(
Row
),
),
findsOneWidget
);
});
});
group
(
'pageBack'
,
()
{
...
...
@@ -854,3 +878,12 @@ class _AlwaysRepaint extends CustomPainter {
onPaint
();
}
}
/// Wraps [child] in [depth] layers of [SizedBox]
Widget
_deepWidgetTree
(
{
required
int
depth
,
required
Widget
child
})
{
Widget
tree
=
child
;
for
(
int
i
=
0
;
i
<
depth
;
i
+=
1
)
{
tree
=
SizedBox
(
child:
tree
);
}
return
tree
;
}
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