diff --git a/packages/devtools_test/lib/src/helpers/actions.dart b/packages/devtools_test/lib/src/helpers/actions.dart index 4465cc6b7f0..f772168a9d4 100644 --- a/packages/devtools_test/lib/src/helpers/actions.dart +++ b/packages/devtools_test/lib/src/helpers/actions.dart @@ -110,10 +110,26 @@ Future switchToScreen( ); _maybeExpect(tabFinder, findsOneWidget, shouldExpect: runWithExpectations); - await controller.tap(tabFinder, warnIfMissed: warnIfTapMissed); - // We use pump here instead of pumpAndSettle because pumpAndSettle will - // never complete if there is an animation (e.g. a progress indicator). - await controller.pump(safePumpDuration); + await retryAsync( + () async { + try { + await controller.tap(tabFinder, warnIfMissed: warnIfTapMissed); + // We use pump here instead of pumpAndSettle because pumpAndSettle will + // never complete if there is an animation (e.g. a progress indicator). + await controller.pump(safePumpDuration); + return true; + } catch (e) { + logStatus('Attempt to switch to $screenId failed with error: $e'); + return false; + } + }, + condition: (success) => success, + onRetry: () async { + logStatus('Retrying switch to $screenId...'); + // Try pumping again to give UI time to settle. + await controller.pump(safePumpDuration); + }, + ); } /// Finds the tab with [icon] either in the top-level DevTools tab bar or in the @@ -174,7 +190,10 @@ Future loadSampleData( /// 2) access the [Scrollbar] widget's [ScrollController]. /// 3) scroll the scrollable attached to the [ScrollController] to the end of /// the [ScrollController]'s scroll extent. -Future scrollToEnd(WidgetController controller) async { +Future scrollToEnd( + WidgetController controller, { + bool waitForSettle = true, +}) async { final scrollbarFinder = find.descendant( of: find.byType(T), matching: find.byType(Scrollbar), @@ -185,5 +204,7 @@ Future scrollToEnd(WidgetController controller) async { duration: const Duration(milliseconds: 500), curve: Curves.easeInOutCubic, ); - await controller.pump(shortPumpDuration); + await (waitForSettle + ? controller.pumpAndSettle(shortPumpDuration) + : controller.pump(shortPumpDuration)); }