Made the memory_nav benchmark a little more robust (#20938)

This commit is contained in:
Hans Muller 2018-08-23 12:05:47 -07:00 committed by GitHub
parent be601c26a5
commit 3fcc1069e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,11 @@ Future<void> endOfAnimation() async {
} while (SchedulerBinding.instance.hasScheduledFrame);
}
Rect boundsFor(WidgetController controller, Finder item) {
final RenderBox box = controller.renderObject<RenderBox>(item);
return box.localToGlobal(Offset.zero) & box.size;
}
Future<void> main() async {
MaterialPageRoute.debugEnableFadingRoutes = true; // ignore: deprecated_member_use
final Completer<void> ready = new Completer<void>();
@ -59,12 +64,21 @@ Future<void> main() async {
await new Future<Null>.delayed(const Duration(milliseconds: 20));
} while (!demoItem.precache());
// Ensure that the center of the "Text fields" item is visible
// because that's where we're going to tap
final Rect demoItemBounds = boundsFor(controller, demoItem);
final Rect demoListBounds = boundsFor(controller, demoList);
if (!demoListBounds.contains(demoItemBounds.center)) {
await controller.drag(demoList, new Offset(0.0, demoListBounds.center.dy - demoItemBounds.center.dy));
await endOfAnimation();
}
for (int iteration = 0; iteration < 15; iteration += 1) {
debugPrint('Tapping... (iteration $iteration)');
await controller.tap(demoItem);
await endOfAnimation();
debugPrint('Backing out...');
await controller.tap(find.byTooltip('Back').last);
await controller.tap(find.byTooltip('Back'));
await endOfAnimation();
}