Unverified Commit dedd180f authored by Todd Volkert's avatar Todd Volkert Committed by GitHub

Fix expectLater to not wrap the delegate in a guard (#17085)

Follow-up to https://github.com/flutter/flutter/pull/17063

https://github.com/flutter/flutter/issues/16859
parent 5c2259d5
...@@ -174,9 +174,10 @@ Future<void> expectLater(dynamic actual, dynamic matcher, { ...@@ -174,9 +174,10 @@ Future<void> expectLater(dynamic actual, dynamic matcher, {
String reason, String reason,
dynamic skip, // true or a String dynamic skip, // true or a String
}) { }) {
return TestAsyncUtils.guard(() async { // We can't wrap the delegate in a guard, or we'll hit async barriers in
await test_package.expectLater(actual, matcher, reason: reason, skip: skip); // [TestWidgetsFlutterBinding] while we're waiting for the matcher to complete
}); TestAsyncUtils.guardSync();
return test_package.expectLater(actual, matcher, reason: reason, skip: skip);
} }
/// Class that programmatically interacts with widgets and the test environment. /// Class that programmatically interacts with widgets and the test environment.
......
...@@ -20,7 +20,7 @@ void main() { ...@@ -20,7 +20,7 @@ void main() {
group('expectLater', () { group('expectLater', () {
testWidgets('completes when matcher completes', (WidgetTester tester) async { testWidgets('completes when matcher completes', (WidgetTester tester) async {
final Completer<void> completer = new Completer<void>(); final Completer<void> completer = new Completer<void>();
final Future<Null> future = expectLater(null, new FakeMatcher(completer)); final Future<void> future = expectLater(null, new FakeMatcher(completer));
String value; String value;
future.then((void _) { future.then((void _) {
value = '123'; value = '123';
...@@ -32,19 +32,6 @@ void main() { ...@@ -32,19 +32,6 @@ void main() {
await tester.pump(); await tester.pump();
test_package.expect(value, '123'); test_package.expect(value, '123');
}); });
testWidgets('Prevents re-entrant calls', (WidgetTester tester) async {
final Completer<void> completer = new Completer<void>();
final Future<Null> future = expectLater(null, new FakeMatcher(completer));
try {
expectLater(null, new FakeMatcher(completer));
fail('FlutterError expected but not thrown');
} on FlutterError catch (error) {
completer.complete();
await future;
expect(error.message, contains('Guarded function conflict'));
}
});
}); });
group('findsOneWidget', () { group('findsOneWidget', () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment