diff --git a/packages/flutter_goldens/lib/flutter_goldens.dart b/packages/flutter_goldens/lib/flutter_goldens.dart index 6619b33c21..085256405c 100644 --- a/packages/flutter_goldens/lib/flutter_goldens.dart +++ b/packages/flutter_goldens/lib/flutter_goldens.dart @@ -564,7 +564,15 @@ class FlutterLocalFileComparator extends FlutterGoldenFileComparator with LocalC return FlutterSkippingGoldenFileComparator( baseDirectory.uri, goldens, - 'No network connection available for contacting Gold.', + 'OSError occurred, could not reach Gold. ' + 'Switching to FlutterSkippingGoldenFileComparator.', + ); + } on io.SocketException catch (_) { + return FlutterSkippingGoldenFileComparator( + baseDirectory.uri, + goldens, + 'SocketException occurred, could not reach Gold. ' + 'Switching to FlutterSkippingGoldenFileComparator.', ); } diff --git a/packages/flutter_goldens/test/flutter_goldens_test.dart b/packages/flutter_goldens/test/flutter_goldens_test.dart index 76037aec3d..96fb28192d 100644 --- a/packages/flutter_goldens/test/flutter_goldens_test.dart +++ b/packages/flutter_goldens/test/flutter_goldens_test.dart @@ -871,9 +871,19 @@ void main() { final MockDirectory mockDirectory = MockDirectory(); when(mockDirectory.existsSync()).thenReturn(true); when(mockDirectory.uri).thenReturn(Uri.parse('/flutter')); + when(mockSkiaClient.getExpectations()) - .thenAnswer((_) => throw const OSError()); - final FlutterGoldenFileComparator comparator = await FlutterLocalFileComparator.fromDefaultComparator( + .thenAnswer((_) => throw const OSError('Can\'t reach Gold')); + FlutterGoldenFileComparator comparator = await FlutterLocalFileComparator.fromDefaultComparator( + platform, + goldens: mockSkiaClient, + baseDirectory: mockDirectory, + ); + expect(comparator.runtimeType, FlutterSkippingGoldenFileComparator); + + when(mockSkiaClient.getExpectations()) + .thenAnswer((_) => throw const SocketException('Can\'t reach Gold')); + comparator = await FlutterLocalFileComparator.fromDefaultComparator( platform, goldens: mockSkiaClient, baseDirectory: mockDirectory,