mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
implicit-casts:false in flutter_goldens and flutter_goldens_client (#45249)
* implicit-casts:false in flutter_goldens and flutter_goldens_client * fix type
This commit is contained in:
parent
a57dddd217
commit
1f3ff5ca42
@ -2,3 +2,12 @@
|
||||
# the ones from above, which include the `public_member_api_docs` rule).
|
||||
|
||||
include: ../../analysis_options.yaml
|
||||
|
||||
analyzer:
|
||||
strong-mode:
|
||||
implicit-casts: false
|
||||
implicit-dynamic: false
|
||||
|
||||
linter:
|
||||
rules:
|
||||
avoid_as: false # Disabled so we can gradually migrate to no implicit dynamic.
|
||||
|
||||
@ -210,7 +210,7 @@ class FlutterSkiaGoldFileComparator extends FlutterGoldenFileComparator {
|
||||
LocalFileComparator defaultComparator,
|
||||
}) async {
|
||||
|
||||
defaultComparator ??= goldenFileComparator;
|
||||
defaultComparator ??= goldenFileComparator as LocalFileComparator;
|
||||
final Directory baseDirectory = FlutterGoldenFileComparator.getBaseDirectory(
|
||||
defaultComparator,
|
||||
platform,
|
||||
@ -293,7 +293,7 @@ class FlutterPreSubmitFileComparator extends FlutterGoldenFileComparator {
|
||||
LocalFileComparator defaultComparator,
|
||||
}) async {
|
||||
|
||||
defaultComparator ??= goldenFileComparator;
|
||||
defaultComparator ??= goldenFileComparator as LocalFileComparator;
|
||||
final Directory baseDirectory = FlutterGoldenFileComparator.getBaseDirectory(
|
||||
defaultComparator,
|
||||
platform,
|
||||
@ -391,7 +391,7 @@ class FlutterSkippingGoldenFileComparator extends FlutterGoldenFileComparator {
|
||||
String reason, {
|
||||
LocalFileComparator defaultComparator,
|
||||
}) {
|
||||
defaultComparator ??= goldenFileComparator;
|
||||
defaultComparator ??= goldenFileComparator as LocalFileComparator;
|
||||
const FileSystem fs = LocalFileSystem();
|
||||
final Uri basedir = defaultComparator.basedir;
|
||||
final SkiaGoldClient skiaClient = SkiaGoldClient(fs.directory(basedir));
|
||||
@ -472,7 +472,7 @@ class FlutterLocalFileComparator extends FlutterGoldenFileComparator with LocalC
|
||||
LocalFileComparator defaultComparator,
|
||||
Directory baseDirectory,
|
||||
}) async {
|
||||
defaultComparator ??= goldenFileComparator;
|
||||
defaultComparator ??= goldenFileComparator as LocalFileComparator;
|
||||
baseDirectory ??= FlutterGoldenFileComparator.getBaseDirectory(
|
||||
defaultComparator,
|
||||
platform,
|
||||
|
||||
@ -97,8 +97,8 @@ void main() {
|
||||
});
|
||||
|
||||
test('validates SkiaDigest', () {
|
||||
final Map<String, dynamic> skiaJson = json.decode(digestResponseTemplate());
|
||||
final SkiaGoldDigest digest = SkiaGoldDigest.fromJson(skiaJson['digest']);
|
||||
final Map<String, dynamic> skiaJson = json.decode(digestResponseTemplate()) as Map<String, dynamic>;
|
||||
final SkiaGoldDigest digest = SkiaGoldDigest.fromJson(skiaJson['digest'] as Map<String, dynamic>);
|
||||
expect(
|
||||
digest.isValid(
|
||||
platform,
|
||||
@ -111,9 +111,9 @@ void main() {
|
||||
|
||||
test('invalidates bad SkiaDigest - platform', () {
|
||||
final Map<String, dynamic> skiaJson = json.decode(
|
||||
digestResponseTemplate(platform: 'linux')
|
||||
);
|
||||
final SkiaGoldDigest digest = SkiaGoldDigest.fromJson(skiaJson['digest']);
|
||||
digestResponseTemplate(platform: 'linux'),
|
||||
) as Map<String, dynamic>;
|
||||
final SkiaGoldDigest digest = SkiaGoldDigest.fromJson(skiaJson['digest'] as Map<String, dynamic>);
|
||||
expect(
|
||||
digest.isValid(
|
||||
platform,
|
||||
@ -126,9 +126,9 @@ void main() {
|
||||
|
||||
test('invalidates bad SkiaDigest - test name', () {
|
||||
final Map<String, dynamic> skiaJson = json.decode(
|
||||
digestResponseTemplate(testName: 'flutter.golden_test.2')
|
||||
);
|
||||
final SkiaGoldDigest digest = SkiaGoldDigest.fromJson(skiaJson['digest']);
|
||||
digestResponseTemplate(testName: 'flutter.golden_test.2'),
|
||||
) as Map<String, dynamic>;
|
||||
final SkiaGoldDigest digest = SkiaGoldDigest.fromJson(skiaJson['digest'] as Map<String, dynamic>);
|
||||
expect(
|
||||
digest.isValid(
|
||||
platform,
|
||||
@ -141,9 +141,9 @@ void main() {
|
||||
|
||||
test('invalidates bad SkiaDigest - expectation', () {
|
||||
final Map<String, dynamic> skiaJson = json.decode(
|
||||
digestResponseTemplate(expectation: '1deg543sf645erg44awqcc78')
|
||||
);
|
||||
final SkiaGoldDigest digest = SkiaGoldDigest.fromJson(skiaJson['digest']);
|
||||
digestResponseTemplate(expectation: '1deg543sf645erg44awqcc78'),
|
||||
) as Map<String, dynamic>;
|
||||
final SkiaGoldDigest digest = SkiaGoldDigest.fromJson(skiaJson['digest'] as Map<String, dynamic>);
|
||||
expect(
|
||||
digest.isValid(
|
||||
platform,
|
||||
@ -156,9 +156,9 @@ void main() {
|
||||
|
||||
test('invalidates bad SkiaDigest - status', () {
|
||||
final Map<String, dynamic> skiaJson = json.decode(
|
||||
digestResponseTemplate(status: 'negative')
|
||||
);
|
||||
final SkiaGoldDigest digest = SkiaGoldDigest.fromJson(skiaJson['digest']);
|
||||
digestResponseTemplate(status: 'negative'),
|
||||
) as Map<String, dynamic>;
|
||||
final SkiaGoldDigest digest = SkiaGoldDigest.fromJson(skiaJson['digest'] as Map<String, dynamic>);
|
||||
expect(
|
||||
digest.isValid(
|
||||
platform,
|
||||
@ -189,8 +189,8 @@ void main() {
|
||||
|
||||
test('detects invalid digests SkiaDigest', () {
|
||||
const String testName = 'flutter.golden_test.2';
|
||||
final Map<String, dynamic> skiaJson = json.decode(digestResponseTemplate());
|
||||
final SkiaGoldDigest digest = SkiaGoldDigest.fromJson(skiaJson['digest']);
|
||||
final Map<String, dynamic> skiaJson = json.decode(digestResponseTemplate()) as Map<String, dynamic>;
|
||||
final SkiaGoldDigest digest = SkiaGoldDigest.fromJson(skiaJson['digest'] as Map<String, dynamic>);
|
||||
expect(digest.isValid(platform, testName, expectation), isFalse);
|
||||
});
|
||||
|
||||
@ -795,16 +795,16 @@ class MockHttpClientRequest extends Mock implements HttpClientRequest {}
|
||||
class MockHttpClientResponse extends Mock implements HttpClientResponse {
|
||||
MockHttpClientResponse(this.response);
|
||||
|
||||
final Uint8List response;
|
||||
final List<int> response;
|
||||
|
||||
@override
|
||||
StreamSubscription<Uint8List> listen(
|
||||
void onData(Uint8List event), {
|
||||
StreamSubscription<List<int>> listen(
|
||||
void onData(List<int> event), {
|
||||
Function onError,
|
||||
void onDone(),
|
||||
bool cancelOnError,
|
||||
}) {
|
||||
return Stream<Uint8List>.fromFuture(Future<Uint8List>.value(response))
|
||||
return Stream<List<int>>.fromFuture(Future<List<int>>.value(response))
|
||||
.listen(onData, onError: onError, onDone: onDone, cancelOnError: cancelOnError);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,3 +2,12 @@
|
||||
# the ones from above, which include the `public_member_api_docs` rule).
|
||||
|
||||
include: ../../analysis_options.yaml
|
||||
|
||||
analyzer:
|
||||
strong-mode:
|
||||
implicit-casts: false
|
||||
implicit-dynamic: false
|
||||
|
||||
linter:
|
||||
rules:
|
||||
avoid_as: false # Disabled so we can gradually migrate to no implicit dynamic.
|
||||
|
||||
@ -205,10 +205,10 @@ class SkiaGoldClient {
|
||||
final io.HttpClientRequest request = await httpClient.getUrl(requestForExpectations);
|
||||
final io.HttpClientResponse response = await request.close();
|
||||
rawResponse = await utf8.decodeStream(response);
|
||||
final Map<String, dynamic> skiaJson = json.decode(rawResponse)['master'];
|
||||
final Map<String, dynamic> skiaJson = json.decode(rawResponse)['master'] as Map<String, dynamic>;
|
||||
|
||||
skiaJson.forEach((String key, dynamic value) {
|
||||
final Map<String, dynamic> hashesMap = value;
|
||||
final Map<String, dynamic> hashesMap = value as Map<String, dynamic>;
|
||||
_expectations[key] = hashesMap.keys.toList();
|
||||
});
|
||||
} on FormatException catch(_) {
|
||||
@ -267,11 +267,11 @@ class SkiaGoldClient {
|
||||
final io.HttpClientRequest request = await httpClient.getUrl(requestForIgnores);
|
||||
final io.HttpClientResponse response = await request.close();
|
||||
rawResponse = await utf8.decodeStream(response);
|
||||
final List<dynamic> ignores = json.decode(rawResponse);
|
||||
for(Map<String, dynamic> ignore in ignores) {
|
||||
final List<String> ignoredQueries = ignore['query'].split('&');
|
||||
final String ignoredPullRequest = ignore['note'].split('/').last;
|
||||
final DateTime expiration = DateTime.parse(ignore['expires']);
|
||||
final List<dynamic> ignores = json.decode(rawResponse) as List<dynamic>;
|
||||
for(dynamic ignore in ignores) {
|
||||
final List<String> ignoredQueries = (ignore['query'] as String).split('&');
|
||||
final String ignoredPullRequest = (ignore['note'] as String).split('/').last;
|
||||
final DateTime expiration = DateTime.parse(ignore['expires'] as String);
|
||||
// The currently failing test is in the process of modification.
|
||||
if (ignoredQueries.contains('name=$testName')) {
|
||||
if (expiration.isAfter(DateTime.now())) {
|
||||
@ -326,8 +326,8 @@ class SkiaGoldClient {
|
||||
final io.HttpClientRequest request = await httpClient.getUrl(requestForDigest);
|
||||
final io.HttpClientResponse response = await request.close();
|
||||
rawResponse = await utf8.decodeStream(response);
|
||||
final Map<String, dynamic> skiaJson = json.decode(rawResponse);
|
||||
final SkiaGoldDigest digest = SkiaGoldDigest.fromJson(skiaJson['digest']);
|
||||
final Map<String, dynamic> skiaJson = json.decode(rawResponse) as Map<String, dynamic>;
|
||||
final SkiaGoldDigest digest = SkiaGoldDigest.fromJson(skiaJson['digest'] as Map<String, dynamic>);
|
||||
isValid = digest.isValid(platform, testName, expectation);
|
||||
|
||||
} on FormatException catch(_) {
|
||||
@ -358,7 +358,7 @@ class SkiaGoldClient {
|
||||
<String>['git', 'rev-parse', 'HEAD'],
|
||||
workingDirectory: _flutterRoot.path,
|
||||
);
|
||||
return revParse.exitCode == 0 ? revParse.stdout.trim() : null;
|
||||
return revParse.exitCode == 0 ? (revParse.stdout as String).trim() : null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -410,11 +410,11 @@ class SkiaGoldDigest {
|
||||
return null;
|
||||
|
||||
return SkiaGoldDigest(
|
||||
imageHash: json['digest'],
|
||||
paramSet: Map<String, dynamic>.from(json['paramset'] ??
|
||||
imageHash: json['digest'] as String,
|
||||
paramSet: Map<String, dynamic>.from(json['paramset'] as Map<String, dynamic> ??
|
||||
<String, String>{'Platform': 'none'}),
|
||||
testName: json['test'],
|
||||
status: json['status'],
|
||||
testName: json['test'] as String,
|
||||
status: json['status'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
@ -433,7 +433,7 @@ class SkiaGoldDigest {
|
||||
/// Validates a given digest against the current testing conditions.
|
||||
bool isValid(Platform platform, String name, String expectation) {
|
||||
return imageHash == expectation
|
||||
&& paramSet['Platform'].contains(platform.operatingSystem)
|
||||
&& (paramSet['Platform'] as List<dynamic>).contains(platform.operatingSystem)
|
||||
&& testName == name
|
||||
&& status == 'positive';
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user