Skip to content

Commit

Permalink
WIP: use completer
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustl22 committed Jul 3, 2024
1 parent eb329b6 commit 6f5ca06
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/audioplayers/example/integration_test/platform_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,10 @@ extension on WidgetTester {
event.eventType == AudioEventType.prepared &&
(event.isPrepared ?? false),
)
.listen((_) => preparedCompleter.complete());
.listen(
(_) => preparedCompleter.complete(),
onError: preparedCompleter.completeError,
);

Future<void> setSource(Source source) async {
if (source is UrlSource) {
Expand All @@ -501,8 +504,12 @@ extension on WidgetTester {

// Wait simultaneously to ensure all errors are propagated through the same
// future.
await Future.wait([futureSetSource, preparedCompleter.future])
.timeout(const Duration(seconds: 30));
await preparedStream.cancel();
try {
await Future.wait([futureSetSource, preparedCompleter.future])
.timeout(const Duration(seconds: 30));
} on Exception catch (_) {
await preparedStream.cancel();
rethrow;
}
}
}

0 comments on commit 6f5ca06

Please sign in to comment.