Unverified Commit c6dbb6f2 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Update mockito dep and remove usage in manual tests and localizations (#77945)

parent b8d44fd2
...@@ -17,8 +17,6 @@ dev_dependencies: ...@@ -17,8 +17,6 @@ dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
mockito: 4.1.1
async: 2.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" async: 2.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
boolean_selector: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
charcode: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
...@@ -36,4 +34,4 @@ dev_dependencies: ...@@ -36,4 +34,4 @@ dev_dependencies:
flutter: flutter:
uses-material-design: true uses-material-design: true
# PUBSPEC CHECKSUM: d387 # PUBSPEC CHECKSUM: 7441
...@@ -2,38 +2,62 @@ ...@@ -2,38 +2,62 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:mockito/mockito.dart'; import 'package:flutter_test/flutter_test.dart';
import '../../../packages/flutter/test/image_data.dart'; import '../../../packages/flutter/test/image_data.dart';
// Returns a mock HTTP client that responds with an image to all requests. // Returns a mock HTTP client that responds with an image to all requests.
MockHttpClient createMockImageHttpClient(SecurityContext _) { FakeHttpClient createMockImageHttpClient(SecurityContext _) {
final MockHttpClient client = MockHttpClient(); final FakeHttpClient client = FakeHttpClient();
final MockHttpClientRequest request = MockHttpClientRequest();
final MockHttpClientResponse response = MockHttpClientResponse();
final MockHttpHeaders headers = MockHttpHeaders();
when(client.getUrl(any)).thenAnswer((_) => Future<HttpClientRequest>.value(request));
when(request.headers).thenReturn(headers);
when(request.close()).thenAnswer((_) => Future<HttpClientResponse>.value(response));
when(response.contentLength).thenReturn(kTransparentImage.length);
when(response.statusCode).thenReturn(HttpStatus.ok);
when(response.compressionState).thenReturn(HttpClientResponseCompressionState.notCompressed);
when(response.listen(any)).thenAnswer((Invocation invocation) {
final void Function(List<int>) onData = invocation.positionalArguments[0] as void Function(List<int>);
final void Function() onDone = invocation.namedArguments[#onDone] as void Function();
final void Function(Object, [StackTrace]) onError = invocation.namedArguments[#onError] as void Function(Object, [StackTrace]);
final bool cancelOnError = invocation.namedArguments[#cancelOnError] as bool;
return Stream<List<int>>.fromIterable(<List<int>>[kTransparentImage]).listen(onData, onDone: onDone, onError: onError, cancelOnError: cancelOnError);
});
return client; return client;
} }
class MockHttpClient extends Mock implements HttpClient {} class FakeHttpClient extends Fake implements HttpClient {
@override
bool autoUncompress = false;
class MockHttpClientRequest extends Mock implements HttpClientRequest {} final FakeHttpClientRequest request = FakeHttpClientRequest();
class MockHttpClientResponse extends Mock implements HttpClientResponse {} @override
Future<HttpClientRequest> getUrl(Uri url) async {
return request;
}
}
class FakeHttpClientRequest extends Fake implements HttpClientRequest {
final FakeHttpClientResponse response = FakeHttpClientResponse();
@override
Future<HttpClientResponse> close() async {
return response;
}
}
class FakeHttpClientResponse extends Fake implements HttpClientResponse {
@override
int get statusCode => 200;
@override
int get contentLength => kTransparentImage.length;
@override
final FakeHttpHeaders headers = FakeHttpHeaders();
@override
HttpClientResponseCompressionState get compressionState => HttpClientResponseCompressionState.notCompressed;
@override
StreamSubscription<List<int>> listen(void Function(List<int>) onData, {
void Function() onDone,
Function onError,
bool cancelOnError,
}) {
return Stream<List<int>>.fromIterable(<List<int>>[kTransparentImage])
.listen(onData, onDone: onDone, onError: onError, cancelOnError: cancelOnError);
}
}
class MockHttpHeaders extends Mock implements HttpHeaders {} class FakeHttpHeaders extends Fake implements HttpHeaders {}
...@@ -21,7 +21,6 @@ dependencies: ...@@ -21,7 +21,6 @@ dependencies:
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
mockito: 4.1.1
async: 2.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" async: 2.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
boolean_selector: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
...@@ -35,4 +34,4 @@ dev_dependencies: ...@@ -35,4 +34,4 @@ dev_dependencies:
term_glyph: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
test_api: 0.2.19 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" test_api: 0.2.19 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
# PUBSPEC CHECKSUM: 18bf # PUBSPEC CHECKSUM: 9279
...@@ -29,7 +29,7 @@ const Map<String, String> _kManuallyPinnedDependencies = <String, String>{ ...@@ -29,7 +29,7 @@ const Map<String, String> _kManuallyPinnedDependencies = <String, String>{
// existing tests do not fail when the package has a new version. // existing tests do not fail when the package has a new version.
'flutter_gallery_assets': '^1.0.1', 'flutter_gallery_assets': '^1.0.1',
'flutter_template_images': '1.0.1', // Must always exactly match flutter_tools template. 'flutter_template_images': '1.0.1', // Must always exactly match flutter_tools template.
'mockito': '4.1.1', // Prevent mockito from upgrading to the source gen version. 'mockito': '4.1.1+1', // Prevent mockito from upgrading to the source gen version.
'vm_service_client': '0.2.6+2', // Final version before being marked deprecated. 'vm_service_client': '0.2.6+2', // Final version before being marked deprecated.
// DART TEAM OWNED NNBD DEPS // DART TEAM OWNED NNBD DEPS
'archive': '">=3.0.0-nullsafety.0"', 'archive': '">=3.0.0-nullsafety.0"',
......
...@@ -94,7 +94,7 @@ dependencies: ...@@ -94,7 +94,7 @@ dependencies:
dev_dependencies: dev_dependencies:
collection: 1.15.0 collection: 1.15.0
mockito: 4.1.1 mockito: 4.1.1+1
file_testing: 3.0.0 file_testing: 3.0.0
test: 1.16.5 test: 1.16.5
pubspec_parse: 0.1.8 pubspec_parse: 0.1.8
...@@ -108,4 +108,4 @@ dartdoc: ...@@ -108,4 +108,4 @@ dartdoc:
# Exclude this package from the hosted API docs. # Exclude this package from the hosted API docs.
nodoc: true nodoc: true
# PUBSPEC CHECKSUM: 09dc # PUBSPEC CHECKSUM: 4339
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