From 9dbe46a64c998fccc0eda56c4599e7a94b30f0b8 Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Thu, 19 Oct 2023 00:10:24 +0200 Subject: [PATCH] moved screenshots generator to screenshots folder --- .gitignore | 2 +- screenshots/README.md | 37 ++++++++++++++++++ .../generate_screenshots.dart | 39 +++++++------------ .../generate_screenshots.sh | 2 +- 4 files changed, 53 insertions(+), 27 deletions(-) create mode 100644 screenshots/README.md rename {integration_test => screenshots}/generate_screenshots.dart (79%) rename {integration_test => screenshots}/generate_screenshots.sh (83%) diff --git a/.gitignore b/.gitignore index afa2a01..4904e66 100644 --- a/.gitignore +++ b/.gitignore @@ -61,4 +61,4 @@ ios/Runner/GoogleService-Info.plist coverage/ test/coverage_helper_test.dart -screenshots/ \ No newline at end of file +screenshots/*.png \ No newline at end of file diff --git a/screenshots/README.md b/screenshots/README.md new file mode 100644 index 0000000..06df390 --- /dev/null +++ b/screenshots/README.md @@ -0,0 +1,37 @@ +# Screenshots + +The easiest way to create several sets of identical screenshots for Android and iOS is to generate them instead of taking them manually. Generating screenshots will save time and effort while also providing a consistent output. + +## Context + +As a user I want to see the most relevant screenshots in the store, so that I can see the actual state of the app. + +## Screenshot cases + +- Metering screen + + 1. Reflected light metering mode* + 2. Incident light metering mode* ** + 3. Opened ISO picker + +- Settings screen + + 1. Just the screen + 2. Opened metering screen layout features dialog + +- Equipment profiles screen + + 1. Just the screen + 2. Opened equipment profile ISO picker + +> *also in dark mode + +> **Android only + +## Run the generator + +```console +sh screenshots/generate_screenshots.sh +``` + +Screenshots will be stored in the _screenshots/_ folder. diff --git a/integration_test/generate_screenshots.dart b/screenshots/generate_screenshots.dart similarity index 79% rename from integration_test/generate_screenshots.dart rename to screenshots/generate_screenshots.dart index a44c42b..8c8e7e9 100644 --- a/integration_test/generate_screenshots.dart +++ b/screenshots/generate_screenshots.dart @@ -10,18 +10,19 @@ import 'package:lightmeter/data/models/theme_type.dart'; import 'package:lightmeter/data/models/volume_action.dart'; import 'package:lightmeter/data/shared_prefs_service.dart'; import 'package:lightmeter/generated/l10n.dart'; -import 'package:lightmeter/res/dimens.dart'; import 'package:lightmeter/res/theme.dart'; -import 'package:lightmeter/screens/metering/components/bottom_controls/components/measure_button/widget_button_measure.dart'; import 'package:lightmeter/screens/metering/components/shared/readings_container/components/iso_picker/widget_picker_iso.dart'; -import 'package:lightmeter/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/widget_container_equipment_profile.dart'; +import 'package:lightmeter/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/screen_equipment_profile.dart'; +import 'package:lightmeter/screens/settings/screen_settings.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; import 'package:shared_preferences/shared_preferences.dart'; -import 'utils/platform_channel_mock.dart'; -import 'utils/widget_tester_actions.dart'; +import '../integration_test/mocks/paid_features_mock.dart'; +import '../integration_test/utils/widget_tester_actions.dart'; //https://stackoverflow.com/a/67186625/13167574 + +/// Just a screenshot generator. No expectations here. void main() { final binding = IntegrationTestWidgetsFlutterBinding(); IntegrationTestWidgetsFlutterBinding.ensureInitialized(); @@ -29,6 +30,7 @@ void main() { final Color darkThemeColor = primaryColorsList[3]; void mockSharedPrefs(ThemeType theme, Color color) { + // ignore: invalid_use_of_visible_for_testing_member SharedPreferences.setMockInitialValues({ /// Metering values UserPreferencesService.evSourceTypeKey: EvSourceType.camera.index, @@ -74,14 +76,11 @@ void main() { if (Platform.isAndroid) { await tester.tap(find.byTooltip(S.current.tooltipUseLightSensor)); await tester.pumpAndSettle(); - await tester.tap(find.byType(MeteringMeasureButton)); - await sendMockIncidentEv(7.3); - await tester.tap(find.byType(MeteringMeasureButton)); + await tester.toggleIncidentMetering(7.3); await tester.takeScreenshot(binding, '${lightThemeColor.value}_metering_incident'); } - await tester.tap(find.byType(IsoValuePicker)); - await tester.pumpAndSettle(Dimens.durationL); + await tester.openAnimatedPicker(); await tester.takeScreenshot(binding, '${lightThemeColor.value}_metering_iso_picker'); await tester.tapCancelButton(); @@ -89,12 +88,13 @@ void main() { await tester.pumpAndSettle(); await tester.takeScreenshot(binding, '${lightThemeColor.value}_settings'); - await tester.tapListTile(S.current.meteringScreenLayout); + await tester.tapDescendantTextOf(S.current.meteringScreenLayout); await tester.takeScreenshot(binding, '${lightThemeColor.value}_settings_metering_screen_layout'); await tester.tapCancelButton(); - await tester.tapListTile(S.current.equipmentProfiles); - await tester.tap(find.byType(EquipmentProfileContainer).first); + 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'); @@ -117,9 +117,7 @@ void main() { if (Platform.isAndroid) { await tester.tap(find.byTooltip(S.current.tooltipUseLightSensor)); await tester.pumpAndSettle(); - await tester.tap(find.byType(MeteringMeasureButton)); - await sendMockIncidentEv(7.3); - await tester.tap(find.byType(MeteringMeasureButton)); + await tester.toggleIncidentMetering(7.3); await tester.takeScreenshot(binding, '${darkThemeColor.value}_metering_incident'); } }, @@ -135,13 +133,4 @@ extension on WidgetTester { await binding.takeScreenshot(name); await pumpAndSettle(); } - - Future tapListTile(String title) async { - final listTile = find.byWidgetPredicate( - (widget) => widget is ListTile && widget.title is Text && (widget.title as Text?)?.data == title, - ); - expect(listTile, findsOneWidget); - await tap(listTile); - await pumpAndSettle(); - } } diff --git a/integration_test/generate_screenshots.sh b/screenshots/generate_screenshots.sh similarity index 83% rename from integration_test/generate_screenshots.sh rename to screenshots/generate_screenshots.sh index 8296e96..c95568e 100644 --- a/integration_test/generate_screenshots.sh +++ b/screenshots/generate_screenshots.sh @@ -2,7 +2,7 @@ flutter drive \ --dart-define="cameraPreviewAspectRatio=240/320" \ --dart-define="cameraStubImage=assets/camera_stub_image.jpg" \ --driver=test_driver/screenshot_driver.dart \ - --target=integration_test/generate_screenshots.dart \ + --target=screenshots/generate_screenshots.dart \ --profile \ --flavor=dev \ --no-dds \