testUISleepUntilRoute function
Calls testUISleepUntil checking if route
is the current route (UINavigator.currentRoute).
- If
parameters
is notnull
will requires a match with UINavigator.currentRouteParameters. - If
partialParameters
istrue
will allow partial match ofparameters
.
Implementation
Future<bool> testUISleepUntilRoute(String route,
{Map<String, dynamic>? parameters,
bool partialParameters = false,
int? timeoutMs,
int? intervalMs,
int? minMs,
bool expected = false}) {
var stackTrace = StackTrace.current;
return testUISleepUntil(
() {
if (UINavigator.currentRoute == route) {
if (parameters != null) {
return _equalsParameters(
parameters, UINavigator.currentRouteParameters,
partialParameters: partialParameters);
} else {
return true;
}
} else {
return false;
}
},
readyTitle:
'route: `$route`${parameters != null ? ' ; parameters: $parameters' : ''}',
timeoutMs: timeoutMs ?? 2000,
intervalMs: intervalMs ?? 100,
minMs: minMs,
).thenChain((ok) {
if (expected && !ok) {
Error.throwWithStackTrace(
TestFailure(
"Expected route: `$route` ; current: `${UINavigator.currentRoute}`"),
stackTrace);
}
return ok;
});
}