From 4f86dee0f4729a4bf81e1f999e2a0198d77665b3 Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Wed, 27 Dec 2023 12:06:03 +0100 Subject: [PATCH] place screenshots in platform-specific folders --- .gitignore | 2 +- .../mocks/paid_features_mock.dart | 11 ++++++++- .../utils/widget_tester_actions.dart | 1 + screenshots/generate_screenshots.dart | 24 ++++++++++--------- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 4904e66..92a32ba 100644 --- a/.gitignore +++ b/.gitignore @@ -61,4 +61,4 @@ ios/Runner/GoogleService-Info.plist coverage/ test/coverage_helper_test.dart -screenshots/*.png \ No newline at end of file +screenshots/*/*.png \ No newline at end of file diff --git a/integration_test/mocks/paid_features_mock.dart b/integration_test/mocks/paid_features_mock.dart index 5d38c52..1038694 100644 --- a/integration_test/mocks/paid_features_mock.dart +++ b/integration_test/mocks/paid_features_mock.dart @@ -8,12 +8,16 @@ import 'package:mocktail/mocktail.dart'; class _MockIAPStorageService extends Mock implements IAPStorageService {} class MockIAPProviders extends StatefulWidget { + final List equipmentProfiles; final String selectedEquipmentProfileId; + final List films; final Film selectedFilm; final Widget child; const MockIAPProviders({ + this.equipmentProfiles = const [], this.selectedEquipmentProfileId = '', + this.films = mockFilms, this.selectedFilm = const Film.other(), required this.child, super.key, @@ -66,7 +70,12 @@ final mockEquipmentProfiles = [ ApertureValue.values.indexOf(const ApertureValue(1.7, StopType.half)), ApertureValue.values.indexOf(const ApertureValue(16, StopType.full)) + 1, ), - ndValues: NdValue.values.sublist(0, 3), + ndValues: const [ + NdValue(0), + NdValue(2), + NdValue(4), + NdValue(8), + ], shutterSpeedValues: ShutterSpeedValue.values.sublist( ShutterSpeedValue.values.indexOf(const ShutterSpeedValue(1000, true, StopType.full)), ShutterSpeedValue.values.indexOf(const ShutterSpeedValue(16, false, StopType.full)) + 1, diff --git a/integration_test/utils/widget_tester_actions.dart b/integration_test/utils/widget_tester_actions.dart index 8411634..72bc328 100644 --- a/integration_test/utils/widget_tester_actions.dart +++ b/integration_test/utils/widget_tester_actions.dart @@ -63,6 +63,7 @@ extension WidgetTesterListTileActions on WidgetTester { /// Useful for tapping a specific [ListTile] inside a specific screen or dialog Future tapDescendantTextOf(String text) async { await tap(find.descendant(of: find.byType(T), matching: find.text(text))); + await pumpAndSettle(); } } diff --git a/screenshots/generate_screenshots.dart b/screenshots/generate_screenshots.dart index 814cfd1..b29130e 100644 --- a/screenshots/generate_screenshots.dart +++ b/screenshots/generate_screenshots.dart @@ -70,37 +70,37 @@ void main() { await tester.pumpApplication(); await tester.takePhoto(); - await tester.takeScreenshot(binding, '${lightThemeColor.value}_metering_reflected'); + await tester.takeScreenshot(binding, 'light-metering_reflected'); if (Platform.isAndroid) { await tester.tap(find.byTooltip(S.current.tooltipUseLightSensor)); await tester.pumpAndSettle(); await tester.toggleIncidentMetering(7.3); - await tester.takeScreenshot(binding, '${lightThemeColor.value}_metering_incident'); + await tester.takeScreenshot(binding, 'light-metering_incident'); } await tester.openAnimatedPicker(); - await tester.takeScreenshot(binding, '${lightThemeColor.value}_metering_iso_picker'); + await tester.takeScreenshot(binding, 'light-metering_iso_picker'); await tester.tapCancelButton(); await tester.tap(find.byTooltip(S.current.tooltipOpenSettings)); await tester.pumpAndSettle(); - await tester.takeScreenshot(binding, '${lightThemeColor.value}_settings'); + await tester.takeScreenshot(binding, 'light-settings'); await tester.tapDescendantTextOf(S.current.meteringScreenLayout); - await tester.takeScreenshot(binding, '${lightThemeColor.value}_settings_metering_screen_layout'); + await tester.takeScreenshot(binding, 'light-settings_metering_screen_layout'); await tester.tapCancelButton(); await tester.tapDescendantTextOf(S.current.equipmentProfiles); await tester.pumpAndSettle(); await tester.tapDescendantTextOf(mockEquipmentProfiles.first.name); await tester.pumpAndSettle(); - await tester.takeScreenshot(binding, '${lightThemeColor.value}-equipment_profiles'); + await tester.takeScreenshot(binding, 'light-equipment_profiles'); await tester.tap(find.byIcon(Icons.iso).first); await tester.pumpAndSettle(); - await tester.takeScreenshot(binding, '${lightThemeColor.value}_equipment_profiles_iso_picker'); - }, + await tester.takeScreenshot(binding, 'light-equipment_profiles_iso_picker'); + } ); /// and the additionally the first one with the dark theme @@ -111,25 +111,27 @@ void main() { await tester.pumpApplication(); await tester.takePhoto(); - await tester.takeScreenshot(binding, '${darkThemeColor.value}_metering_reflected'); + await tester.takeScreenshot(binding, 'dark-metering_reflected'); if (Platform.isAndroid) { await tester.tap(find.byTooltip(S.current.tooltipUseLightSensor)); await tester.pumpAndSettle(); await tester.toggleIncidentMetering(7.3); - await tester.takeScreenshot(binding, '${darkThemeColor.value}_metering_incident'); + await tester.takeScreenshot(binding, 'dark-metering_incident'); } }, ); } +final String _platformFolder = Platform.isAndroid ? 'android' : 'ios'; + extension on WidgetTester { Future takeScreenshot(IntegrationTestWidgetsFlutterBinding binding, String name) async { if (Platform.isAndroid) { await binding.convertFlutterSurfaceToImage(); await pumpAndSettle(); } - await binding.takeScreenshot(name); + await binding.takeScreenshot("$_platformFolder/$name"); await pumpAndSettle(); } }