mirror of
https://github.com/flutter/flutter
synced 2024-10-12 19:23:02 +00:00
Add handling for empty expectation (#66142)
This commit is contained in:
parent
689ca09cd0
commit
51fa704642
|
@ -648,7 +648,7 @@ class FlutterLocalFileComparator extends FlutterGoldenFileComparator with LocalC
|
|||
late String? testExpectation;
|
||||
testExpectation = await skiaClient.getExpectationForTest(testName);
|
||||
|
||||
if (testExpectation == null) {
|
||||
if (testExpectation == null || testExpectation.isEmpty) {
|
||||
// There is no baseline for this test
|
||||
print('No expectations provided by Skia Gold for test: $golden. '
|
||||
'This may be a new test. If this is an unexpected result, check '
|
||||
|
|
|
@ -903,6 +903,8 @@ void main() {
|
|||
|
||||
when(mockSkiaClient.getExpectationForTest('flutter.golden_test.1'))
|
||||
.thenAnswer((_) => Future<String>.value('55109a4bed52acc780530f7a9aeff6c0'));
|
||||
when(mockSkiaClient.getExpectationForTest('flutter.new_golden_test.2'))
|
||||
.thenAnswer((_) => Future<String>.value(''));
|
||||
when(mockSkiaClient.getImageBytes('55109a4bed52acc780530f7a9aeff6c0'))
|
||||
.thenAnswer((_) => Future<List<int>>.value(_kTestPngBytes));
|
||||
when(mockSkiaClient.cleanTestName('library.flutter.golden_test.1.png'))
|
||||
|
@ -919,7 +921,7 @@ void main() {
|
|||
);
|
||||
});
|
||||
|
||||
testWithOutput('passes non-existent baseline for new test', () async {
|
||||
testWithOutput('passes non-existent baseline for new test, null expectation', () async {
|
||||
expect(
|
||||
await comparator.compare(
|
||||
Uint8List.fromList(_kFailPngBytes),
|
||||
|
@ -932,6 +934,19 @@ void main() {
|
|||
'Validate image output found at flutter/test/library/'
|
||||
);
|
||||
|
||||
testWithOutput('passes non-existent baseline for new test, empty expectation', () async {
|
||||
expect(
|
||||
await comparator.compare(
|
||||
Uint8List.fromList(_kFailPngBytes),
|
||||
Uri.parse('flutter.new_golden_test.2'),
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
}, '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.\n'
|
||||
'Validate image output found at flutter/test/library/'
|
||||
);
|
||||
|
||||
test('compare properly awaits validation & output before failing.', () async {
|
||||
final Completer<bool> completer = Completer<bool>();
|
||||
final Future<bool> result = comparator.compare(
|
||||
|
|
Loading…
Reference in a new issue