Correctly chain finders to ancestor/descendant finders (#20601)

This commit is contained in:
xster
2018-08-15 17:24:03 -07:00
committed by GitHub
parent 28bc818054
commit 0f4ea504bc
3 changed files with 66 additions and 22 deletions

View File

@@ -56,6 +56,34 @@ void main() {
expect(tester.widget(hitTestable).key, const ValueKey<int>(0));
});
});
testWidgets('ChainedFinders chain properly', (WidgetTester tester) async {
final GlobalKey key1 = new GlobalKey();
await tester.pumpWidget(
_boilerplate(new Column(
children: <Widget>[
new Container(
key: key1,
child: const Text('1'),
),
new Container(
child: const Text('2'),
)
],
)),
);
// Get the text back. By correctly chaining the descendant finder's
// candidates, it should find 1 instead of 2. If the _LastFinder wasn't
// correctly chained after the descendant's candidates, the last element
// with a Text widget would have been 2.
final Text text = find.descendant(
of: find.byKey(key1),
matching: find.byType(Text),
).last.evaluate().single.widget;
expect(text.data, '1');
});
}
Widget _boilerplate(Widget child) {