Add handling for empty expectation (#66142)

This commit is contained in:
Kate Lovett 2020-09-19 11:27:04 -07:00 committed by GitHub
parent 689ca09cd0
commit 51fa704642
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View file

@ -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 '

View file

@ -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(