Unverified Commit 06f015a8 authored by Brian Quinlan's avatar Brian Quinlan Committed by GitHub

Modify flutter_tests dart:io mocks to support Dart 3.0 (#123706)

Modify flutter_tests dart:io mocks to support Dart 3.0
parent c26d1de4
......@@ -206,10 +206,19 @@ class _MockHttpClient implements HttpClient {
}
/// A mocked [HttpClientRequest] which always returns a [_MockHttpClientResponse].
class _MockHttpRequest extends HttpClientRequest {
class _MockHttpRequest implements HttpClientRequest {
@override
bool bufferOutput = true;
@override
int contentLength = -1;
@override
late Encoding encoding;
@override
bool followRedirects = true;
@override
final HttpHeaders headers = _MockHttpHeaders();
......@@ -246,9 +255,15 @@ class _MockHttpRequest extends HttpClientRequest {
return Future<void>.value();
}
@override
int maxRedirects = 5;
@override
String get method => '';
@override
bool persistentConnection = true;
@override
Uri get uri => Uri();
......@@ -514,22 +529,49 @@ class _MockHttpResponse implements HttpClientResponse {
}
/// A mocked [HttpHeaders] that ignores all writes.
class _MockHttpHeaders extends HttpHeaders {
class _MockHttpHeaders implements HttpHeaders {
@override
List<String>? operator [](String name) => <String>[];
@override
void add(String name, Object value, {bool preserveHeaderCase = false}) { }
@override
late bool chunkedTransferEncoding;
@override
void clear() { }
@override
int contentLength = -1;
@override
ContentType? contentType;
@override
DateTime? date;
@override
DateTime? expires;
@override
void forEach(void Function(String name, List<String> values) f) { }
@override
String? host;
@override
DateTime? ifModifiedSince;
@override
void noFolding(String name) { }
@override
late bool persistentConnection;
@override
int? port;
@override
void remove(String name, Object value) { }
......
......@@ -457,7 +457,7 @@ class _FakeHttpClientResponse extends Stream<List<int>> implements HttpClientRes
int get statusCode => _response.statusCode;
}
class _FakeHttpHeaders extends HttpHeaders {
class _FakeHttpHeaders implements HttpHeaders {
_FakeHttpHeaders(this._backingData);
final Map<String, List<String>> _backingData;
......@@ -471,14 +471,32 @@ class _FakeHttpHeaders extends HttpHeaders {
_backingData[name]!.add(value.toString());
}
@override
late bool chunkedTransferEncoding;
@override
void clear() {
_backingData.clear();
}
@override
int contentLength = -1;
@override
ContentType? contentType;
@override
DateTime? date;
@override
DateTime? expires;
@override
void forEach(void Function(String name, List<String> values) action) { }
@override
String? host;
@override
void noFolding(String name) { }
......@@ -501,4 +519,13 @@ class _FakeHttpHeaders extends HttpHeaders {
String? value(String name) {
return _backingData[name]?.join('; ');
}
@override
DateTime? ifModifiedSince;
@override
late bool persistentConnection;
@override
int? port;
}
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