Unverified Commit 3fcc1069 authored by Hans Muller's avatar Hans Muller Committed by GitHub

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

parent be601c26
...@@ -17,6 +17,11 @@ Future<void> endOfAnimation() async { ...@@ -17,6 +17,11 @@ Future<void> endOfAnimation() async {
} while (SchedulerBinding.instance.hasScheduledFrame); } 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 { Future<void> main() async {
MaterialPageRoute.debugEnableFadingRoutes = true; // ignore: deprecated_member_use MaterialPageRoute.debugEnableFadingRoutes = true; // ignore: deprecated_member_use
final Completer<void> ready = new Completer<void>(); final Completer<void> ready = new Completer<void>();
...@@ -59,12 +64,21 @@ Future<void> main() async { ...@@ -59,12 +64,21 @@ Future<void> main() async {
await new Future<Null>.delayed(const Duration(milliseconds: 20)); await new Future<Null>.delayed(const Duration(milliseconds: 20));
} while (!demoItem.precache()); } 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) { for (int iteration = 0; iteration < 15; iteration += 1) {
debugPrint('Tapping... (iteration $iteration)'); debugPrint('Tapping... (iteration $iteration)');
await controller.tap(demoItem); await controller.tap(demoItem);
await endOfAnimation(); await endOfAnimation();
debugPrint('Backing out...'); debugPrint('Backing out...');
await controller.tap(find.byTooltip('Back').last); await controller.tap(find.byTooltip('Back'));
await endOfAnimation(); await endOfAnimation();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment