waitUntilAll method

Future<TestInfoList<St>> waitUntilAll(
  1. List<Type> actionTypes, {
  2. bool ignoreIni = true,
  3. int? timeoutInSeconds,
})

Runs until all actions of the given types are dispatched and finish, in any order. Returns a list with all info until the last action finishes. Ignores other actions types.

Implementation

Future<TestInfoList<St>> waitUntilAll(
  List<Type> actionTypes, {
  bool ignoreIni = true,
  int? timeoutInSeconds,
}) async {
  assert(actionTypes.isNotEmpty);

  timeoutInSeconds ??= defaultTimeout;

  TestInfoList<St> infoList = TestInfoList<St>();
  Set<Type> actionsIni = Set.from(actionTypes);
  Set<Type> actionsEnd = {};
  TestInfo<St>? testInfo;

  while (actionsIni.isNotEmpty || actionsEnd.isNotEmpty) {
    testInfo = await _next(timeoutInSeconds: timeoutInSeconds);
    if (!ignoreIni || testInfo.isEND) infoList._add(testInfo);
    Type actionType = testInfo.action.runtimeType;
    if (testInfo.isINI) {
      if (actionsIni.remove(actionType)) {
        actionsEnd.add(actionType);
      }
    } else
      actionsEnd.remove(actionType);
  }

  lastInfo = infoList.last;
  return infoList;
}