// Ideally, once the test has failed we would stop getting errors from the test.
// Ideally, once the test has failed we would stop getting errors from the test.
// However, if someone tries hard enough they could get in a state where this happens.
// However, if someone tries hard enough they could get in a state where this happens.
...
@@ -432,6 +429,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
...
@@ -432,6 +429,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
// if the listener is in a different zone (which it would be for the
// if the listener is in a different zone (which it would be for the
// `whenComplete` handler below), or if the Future completes with an
// `whenComplete` handler below), or if the Future completes with an
// error and the future has no listeners at all.
// error and the future has no listeners at all.
//
// This handler further calls the onError handler above, which sets
// This handler further calls the onError handler above, which sets
// _pendingExceptionDetails. Nothing gets printed as a result of that
// _pendingExceptionDetails. Nothing gets printed as a result of that
// call unless we already had an exception pending, because in general
// call unless we already had an exception pending, because in general
...
@@ -440,11 +438,13 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
...
@@ -440,11 +438,13 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
// Now, if we actually get here, this isn't going to be one of those
// Now, if we actually get here, this isn't going to be one of those
// cases. We only get here if the test has actually failed. So, once
// cases. We only get here if the test has actually failed. So, once
// we've carefully reported it, we then immediately end the test by
// we've carefully reported it, we then immediately end the test by
// calling the _testCompletionHandler in the _parentZone.
// calling the testCompletionHandler in the _parentZone.
// We have to manually call _testCompletionHandler because if the Future
//
// We have to manually call testCompletionHandler because if the Future
// library calls us, it is maybe _instead_ of calling a registered
// library calls us, it is maybe _instead_ of calling a registered
// listener from a different zone. In our case, that would be instead of
// listener from a different zone. In our case, that would be instead of
// calling the whenComplete() listener below.
// calling the whenComplete() listener below.
//
// We have to call it in the parent zone because if we called it in
// We have to call it in the parent zone because if we called it in
// _this_ zone, the test framework would find this zone was the current
// _this_ zone, the test framework would find this zone was the current
// zone and helpfully throw the error in this zone, causing us to be
// zone and helpfully throw the error in this zone, causing us to be
...
@@ -478,15 +478,15 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
...
@@ -478,15 +478,15 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
));
));
assert(_parentZone!=null);
assert(_parentZone!=null);
assert(_pendingExceptionDetails!=null,'A test overrode FlutterError.onError but either failed to return it to its original state, or had unexpected additional errors that it could not handle. Typically, this is caused by using expect() before restoring FlutterError.onError.');
assert(_pendingExceptionDetails!=null,'A test overrode FlutterError.onError but either failed to return it to its original state, or had unexpected additional errors that it could not handle. Typically, this is caused by using expect() before restoring FlutterError.onError.');