Skip to content

Commit 1fbe576

Browse files
authored
Address benchmark and integration test flakiness (#9690)
1 parent e16b157 commit 1fbe576

1 file changed

Lines changed: 27 additions & 6 deletions

File tree

packages/devtools_test/lib/src/helpers/actions.dart

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,26 @@ Future<void> switchToScreen(
110110
);
111111
_maybeExpect(tabFinder, findsOneWidget, shouldExpect: runWithExpectations);
112112

113-
await controller.tap(tabFinder, warnIfMissed: warnIfTapMissed);
114-
// We use pump here instead of pumpAndSettle because pumpAndSettle will
115-
// never complete if there is an animation (e.g. a progress indicator).
116-
await controller.pump(safePumpDuration);
113+
await retryAsync<bool>(
114+
() async {
115+
try {
116+
await controller.tap(tabFinder, warnIfMissed: warnIfTapMissed);
117+
// We use pump here instead of pumpAndSettle because pumpAndSettle will
118+
// never complete if there is an animation (e.g. a progress indicator).
119+
await controller.pump(safePumpDuration);
120+
return true;
121+
} catch (e) {
122+
logStatus('Attempt to switch to $screenId failed with error: $e');
123+
return false;
124+
}
125+
},
126+
condition: (success) => success,
127+
onRetry: () async {
128+
logStatus('Retrying switch to $screenId...');
129+
// Try pumping again to give UI time to settle.
130+
await controller.pump(safePumpDuration);
131+
},
132+
);
117133
}
118134

119135
/// Finds the tab with [icon] either in the top-level DevTools tab bar or in the
@@ -174,7 +190,10 @@ Future<void> loadSampleData(
174190
/// 2) access the [Scrollbar] widget's [ScrollController].
175191
/// 3) scroll the scrollable attached to the [ScrollController] to the end of
176192
/// the [ScrollController]'s scroll extent.
177-
Future<void> scrollToEnd<T>(WidgetController controller) async {
193+
Future<void> scrollToEnd<T>(
194+
WidgetController controller, {
195+
bool waitForSettle = true,
196+
}) async {
178197
final scrollbarFinder = find.descendant(
179198
of: find.byType(T),
180199
matching: find.byType(Scrollbar),
@@ -185,5 +204,7 @@ Future<void> scrollToEnd<T>(WidgetController controller) async {
185204
duration: const Duration(milliseconds: 500),
186205
curve: Curves.easeInOutCubic,
187206
);
188-
await controller.pump(shortPumpDuration);
207+
await (waitForSettle
208+
? controller.pumpAndSettle(shortPumpDuration)
209+
: controller.pump(shortPumpDuration));
189210
}

0 commit comments

Comments
 (0)