performAction method
Performs the action
Implementation
Future<void> performAction({Function? setAsDone, int? actionIndex}) async {
print(
'Performing ${action.toValue} action ${actionIndex != null ? '#$actionIndex' : ''}');
try {
switch (action) {
case TestActionType.Press:
await tester!.tap(finder!);
break;
case TestActionType.EnterText:
await tester!.enterText(finder!, enterText!);
break;
case TestActionType.PumpAndSettle:
await tester!.pumpAndSettle();
break;
case TestActionType.FutureAwait:
print(
'** Future delayed by ${awaitDuration!.inSeconds}s -> ${awaitDuration!.inMilliseconds}ms');
await Future.delayed(awaitDuration!);
break;
case TestActionType.CustomAction:
await customAction!();
break;
case TestActionType.Pump:
print('* Pumping for $pumpTime times');
bool pumpDone = false;
for (int i = 0; i < pumpTime; i++) {
await tester!.pump(Duration(milliseconds: 100));
if (i == pumpTime - 1) pumpDone = true;
}
do {
await Future.delayed(Duration(milliseconds: 100));
} while (!pumpDone);
if (setAsDone != null) setAsDone(actionIndex);
print('Action ${action.toValue} #$actionIndex done');
return;
case TestActionType.Drag:
await tester!.drag(finder!, dragOffset!);
break;
}
if (executePumpAndSettle) {
print('Executing pumpAndSettle');
await tester!.pumpAndSettle(Duration(milliseconds: 500));
} else
print('* Avoiding the pumpAndSettle');
} catch (e) {
printError(e, actionIndex ?? 0);
return;
}
if (setAsDone != null) setAsDone(actionIndex);
print('Action ${action.toValue} #$actionIndex done');
return;
}