mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Re-land Assert golden files use the right extension (#99082)
This commit is contained in:
parent
e25670a2a0
commit
a288bd5e3f
@ -1,7 +1,7 @@
|
||||
[0-9]+:[0-9]+ [+]0: Local passes non-existent baseline for new test, null expectation *
|
||||
*No expectations provided by Skia Gold for test: library.flutter.new_golden_test.1. This may be a new test. If this is an unexpected result, check https://flutter-gold.skia.org.
|
||||
*No expectations provided by Skia Gold for test: library.flutter.new_golden_test.1.png. This may be a new test. If this is an unexpected result, check https://flutter-gold.skia.org.
|
||||
*Validate image output found at flutter/test/library/
|
||||
[0-9]+:[0-9]+ [+]1: Local passes non-existent baseline for new test, empty expectation *
|
||||
*No expectations provided by Skia Gold for test: library.flutter.new_golden_test.2. This may be a new test. If this is an unexpected result, check https://flutter-gold.skia.org.
|
||||
*No expectations provided by Skia Gold for test: library.flutter.new_golden_test.2.png. This may be a new test. If this is an unexpected result, check https://flutter-gold.skia.org.
|
||||
*Validate image output found at flutter/test/library/
|
||||
[0-9]+:[0-9]+ [+]2: All tests passed! *
|
||||
|
@ -38,7 +38,7 @@ void main() {
|
||||
expect(
|
||||
await comparator.compare(
|
||||
Uint8List.fromList(_kFailPngBytes),
|
||||
Uri.parse('flutter.new_golden_test.1'),
|
||||
Uri.parse('flutter.new_golden_test.1.png'),
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
@ -48,7 +48,7 @@ void main() {
|
||||
expect(
|
||||
await comparator.compare(
|
||||
Uint8List.fromList(_kFailPngBytes),
|
||||
Uri.parse('flutter.new_golden_test.2'),
|
||||
Uri.parse('flutter.new_golden_test.2.png'),
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
|
@ -167,6 +167,12 @@ abstract class FlutterGoldenFileComparator extends GoldenFileComparator {
|
||||
/// Prepends the golden URL with the library name that encloses the current
|
||||
/// test.
|
||||
Uri _addPrefix(Uri golden) {
|
||||
// Ensure the Uri ends in .png as the SkiaClient expects
|
||||
assert(
|
||||
golden.toString().split('.').last == 'png',
|
||||
'Golden files in the Flutter framework must end with the file extension '
|
||||
'.png.'
|
||||
);
|
||||
final String prefix = basedir.pathSegments[basedir.pathSegments.length - 2];
|
||||
return Uri.parse('$prefix.$golden');
|
||||
}
|
||||
|
@ -481,6 +481,26 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
test('asserts .png format', () async {
|
||||
await expectLater(
|
||||
() async {
|
||||
return comparator.compare(
|
||||
Uint8List.fromList(_kTestPngBytes),
|
||||
Uri.parse('flutter.golden_test.1'),
|
||||
);
|
||||
},
|
||||
throwsA(
|
||||
isA<AssertionError>().having((AssertionError error) => error.toString(),
|
||||
'description',
|
||||
contains(
|
||||
'Golden files in the Flutter framework must end with the file '
|
||||
'extension .png.'
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test('calls init during compare', () {
|
||||
expect(fakeSkiaClient.initCalls, 0);
|
||||
comparator.compare(
|
||||
@ -579,6 +599,26 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
test('asserts .png format', () async {
|
||||
await expectLater(
|
||||
() async {
|
||||
return comparator.compare(
|
||||
Uint8List.fromList(_kTestPngBytes),
|
||||
Uri.parse('flutter.golden_test.1'),
|
||||
);
|
||||
},
|
||||
throwsA(
|
||||
isA<AssertionError>().having((AssertionError error) => error.toString(),
|
||||
'description',
|
||||
contains(
|
||||
'Golden files in the Flutter framework must end with the file '
|
||||
'extension .png.'
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test('calls init during compare', () {
|
||||
expect(fakeSkiaClient.tryInitCalls, 0);
|
||||
comparator.compare(
|
||||
@ -745,6 +785,26 @@ void main() {
|
||||
fakeSkiaClient.cleanTestNameValues['library.flutter.golden_test.1.png'] = 'flutter.golden_test.1';
|
||||
});
|
||||
|
||||
test('asserts .png format', () async {
|
||||
await expectLater(
|
||||
() async {
|
||||
return comparator.compare(
|
||||
Uint8List.fromList(_kTestPngBytes),
|
||||
Uri.parse('flutter.golden_test.1'),
|
||||
);
|
||||
},
|
||||
throwsA(
|
||||
isA<AssertionError>().having((AssertionError error) => error.toString(),
|
||||
'description',
|
||||
contains(
|
||||
'Golden files in the Flutter framework must end with the file '
|
||||
'extension .png.'
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test('passes when bytes match', () async {
|
||||
expect(
|
||||
await comparator.compare(
|
||||
|
Loading…
Reference in New Issue
Block a user