Address benchmark and integration test flakiness (#9690)
diff --git a/packages/devtools_test/lib/src/helpers/actions.dart b/packages/devtools_test/lib/src/helpers/actions.dart
index 4465cc6..f772168 100644
--- a/packages/devtools_test/lib/src/helpers/actions.dart
+++ b/packages/devtools_test/lib/src/helpers/actions.dart
@@ -110,10 +110,26 @@
);
_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<bool>(
+ () 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 @@
/// 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<void> scrollToEnd<T>(WidgetController controller) async {
+Future<void> scrollToEnd<T>(
+ WidgetController controller, {
+ bool waitForSettle = true,
+}) async {
final scrollbarFinder = find.descendant(
of: find.byType(T),
matching: find.byType(Scrollbar),
@@ -185,5 +204,7 @@
duration: const Duration(milliseconds: 500),
curve: Curves.easeInOutCubic,
);
- await controller.pump(shortPumpDuration);
+ await (waitForSettle
+ ? controller.pumpAndSettle(shortPumpDuration)
+ : controller.pump(shortPumpDuration));
}