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