diff --git a/packages/flutter_test/lib/src/binding.dart b/packages/flutter_test/lib/src/binding.dart index 2b53a0037a..8fe5b7865b 100644 --- a/packages/flutter_test/lib/src/binding.dart +++ b/packages/flutter_test/lib/src/binding.dart @@ -1779,7 +1779,11 @@ class _MockHttpRequest extends HttpClientRequest { } /// A mocked [HttpClientResponse] which is empty and has a [statusCode] of 400. -class _MockHttpResponse extends Stream> implements HttpClientResponse { +// TODO(tvolkert): Change to `extends Stream` once +// https://dart-review.googlesource.com/c/sdk/+/104525 is rolled into the framework. +class _MockHttpResponse implements HttpClientResponse { + final Stream _delegate = Stream.fromIterable(const Iterable.empty()); + @override final HttpHeaders headers = _MockHttpHeaders(); @@ -1809,8 +1813,8 @@ class _MockHttpResponse extends Stream> implements HttpClientResponse bool get isRedirect => false; @override - StreamSubscription> listen(void Function(List event) onData, { Function onError, void Function() onDone, bool cancelOnError }) { - return const Stream>.empty().listen(onData, onError: onError, onDone: onDone, cancelOnError: cancelOnError); + StreamSubscription listen(void Function(Uint8List event) onData, { Function onError, void Function() onDone, bool cancelOnError }) { + return const Stream.empty().listen(onData, onError: onError, onDone: onDone, cancelOnError: cancelOnError); } @override @@ -1829,6 +1833,189 @@ class _MockHttpResponse extends Stream> implements HttpClientResponse @override int get statusCode => 400; + + @override + Future any(bool Function(Uint8List element) test) { + return _delegate.any(test); + } + + @override + Stream asBroadcastStream({ + void Function(StreamSubscription subscription) onListen, + void Function(StreamSubscription subscription) onCancel, + }) { + return _delegate.asBroadcastStream(onListen: onListen, onCancel: onCancel); + } + + @override + Stream asyncExpand(Stream Function(Uint8List event) convert) { + return _delegate.asyncExpand(convert); + } + + @override + Stream asyncMap(FutureOr Function(Uint8List event) convert) { + return _delegate.asyncMap(convert); + } + + @override + Stream cast() { + return _delegate.cast(); + } + + @override + Future contains(Object needle) { + return _delegate.contains(needle); + } + + @override + Stream distinct([bool Function(Uint8List previous, Uint8List next) equals]) { + return _delegate.distinct(equals); + } + + @override + Future drain([E futureValue]) { + return _delegate.drain(futureValue); + } + + @override + Future elementAt(int index) { + return _delegate.elementAt(index); + } + + @override + Future every(bool Function(Uint8List element) test) { + return _delegate.every(test); + } + + @override + Stream expand(Iterable Function(Uint8List element) convert) { + return _delegate.expand(convert); + } + + @override + Future get first => _delegate.first; + + @override + Future firstWhere( + bool Function(Uint8List element) test, { + List Function() orElse, + }) { + return _delegate.firstWhere(test, orElse: orElse); + } + + @override + Future fold(S initialValue, S Function(S previous, Uint8List element) combine) { + return _delegate.fold(initialValue, combine); + } + + @override + Future forEach(void Function(Uint8List element) action) { + return _delegate.forEach(action); + } + + @override + Stream handleError( + Function onError, { + bool Function(dynamic error) test, + }) { + return _delegate.handleError(onError, test: test); + } + + @override + bool get isBroadcast => _delegate.isBroadcast; + + @override + Future get isEmpty => _delegate.isEmpty; + + @override + Future join([String separator = '']) { + return _delegate.join(separator); + } + + @override + Future get last => _delegate.last; + + @override + Future lastWhere( + bool Function(Uint8List element) test, { + List Function() orElse, + }) { + return _delegate.lastWhere(test, orElse: orElse); + } + + @override + Future get length => _delegate.length; + + @override + Stream map(S Function(Uint8List event) convert) { + return _delegate.map(convert); + } + + @override + Future pipe(StreamConsumer> streamConsumer) { + return _delegate.pipe(streamConsumer); + } + + @override + Future reduce(List Function(Uint8List previous, Uint8List element) combine) { + return _delegate.reduce(combine); + } + + @override + Future get single => _delegate.single; + + @override + Future singleWhere(bool Function(Uint8List element) test, {List Function() orElse}) { + return _delegate.singleWhere(test, orElse: orElse); + } + + @override + Stream skip(int count) { + return _delegate.skip(count); + } + + @override + Stream skipWhile(bool Function(Uint8List element) test) { + return _delegate.skipWhile(test); + } + + @override + Stream take(int count) { + return _delegate.take(count); + } + + @override + Stream takeWhile(bool Function(Uint8List element) test) { + return _delegate.takeWhile(test); + } + + @override + Stream timeout( + Duration timeLimit, { + void Function(EventSink sink) onTimeout, + }) { + return _delegate.timeout(timeLimit, onTimeout: onTimeout); + } + + @override + Future> toList() { + return _delegate.toList(); + } + + @override + Future> toSet() { + return _delegate.toSet(); + } + + @override + Stream transform(StreamTransformer, S> streamTransformer) { + return _delegate.transform(streamTransformer); + } + + @override + Stream where(bool Function(Uint8List event) test) { + return _delegate.where(test); + } } /// A mocked [HttpHeaders] that ignores all writes.