testUISleepUntilRoutes function

Future<bool> testUISleepUntilRoutes(
  1. List<String> routes, {
  2. int? timeoutMs,
  3. int? intervalMs,
  4. int? minMs,
  5. bool expected = false,
})

Calls testUISleepUntil checking if routes has the current route (UINavigator.currentRoute).

Implementation

Future<bool> testUISleepUntilRoutes(List<String> routes,
    {int? timeoutMs, int? intervalMs, int? minMs, bool expected = false}) {
  if (routes.isEmpty) {
    throw ArgumentError("Empty `routes`");
  }

  var stackTrace = StackTrace.current;

  return testUISleepUntil(
    () => routes.contains(UINavigator.currentRoute ?? ''),
    readyTitle: 'one of routes $routes',
    timeoutMs: timeoutMs ?? 2000,
    intervalMs: intervalMs ?? 100,
    minMs: minMs,
  ).thenChain((ok) {
    if (expected && !ok) {
      Error.throwWithStackTrace(
          TestFailure(
              "Expected routes: `$routes` ; current: `${UINavigator.currentRoute}`"),
          stackTrace);
    }
    return ok;
  });
}