From b68e6384d9c700c342623b229b9f2220884b5773 Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Sat, 14 Oct 2023 21:24:11 +0200 Subject: [PATCH] Films in use test --- integration_test/metering_screen_test.dart | 6 -- integration_test/settings_screen_test.dart | 66 +++++++++++++++---- .../utils/widget_tester_actions.dart | 6 ++ 3 files changed, 59 insertions(+), 19 deletions(-) diff --git a/integration_test/metering_screen_test.dart b/integration_test/metering_screen_test.dart index 230076b..543d993 100644 --- a/integration_test/metering_screen_test.dart +++ b/integration_test/metering_screen_test.dart @@ -17,7 +17,6 @@ import 'package:lightmeter/environment.dart'; import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/providers/services_provider.dart'; import 'package:lightmeter/providers/user_preferences_provider.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/exposure_pairs_list/widget_list_exposure_pairs.dart'; @@ -333,11 +332,6 @@ void main() { } extension _WidgetTesterActions on WidgetTester { - Future openAnimatedPicker() async { - await tap(find.byType(T)); - await pumpAndSettle(Dimens.durationL); - } - Future tapRadioListTile(String value) async { expect(find.descendant(of: find.byType(RadioListTile), matching: find.text(value)), findsOneWidget); await tap(find.descendant(of: find.byType(RadioListTile), matching: find.text(value))); diff --git a/integration_test/settings_screen_test.dart b/integration_test/settings_screen_test.dart index 36caee4..e1b8ca8 100644 --- a/integration_test/settings_screen_test.dart +++ b/integration_test/settings_screen_test.dart @@ -21,7 +21,9 @@ import 'package:lightmeter/res/theme.dart'; import 'package:lightmeter/screens/metering/components/shared/readings_container/components/equipment_profile_picker/widget_picker_equipment_profiles.dart'; import 'package:lightmeter/screens/metering/components/shared/readings_container/components/extreme_exposure_pairs_container/widget_container_extreme_exposure_pairs.dart'; import 'package:lightmeter/screens/metering/components/shared/readings_container/components/film_picker/widget_picker_film.dart'; +import 'package:lightmeter/screens/metering/components/shared/readings_container/components/shared/animated_dialog_picker/components/dialog_picker/widget_picker_dialog.dart'; import 'package:lightmeter/screens/settings/components/metering/components/metering_screen_layout/components/meterins_screen_layout_features_dialog/widget_dialog_metering_screen_layout_features.dart'; +import 'package:lightmeter/screens/settings/components/shared/dialog_filter/widget_dialog_filter.dart'; import 'package:lightmeter/screens/settings/screen_settings.dart'; import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; @@ -73,7 +75,7 @@ void main() { MeteringScreenLayoutFeature.equipmentProfiles: true, MeteringScreenLayoutFeature.extremeExposurePairs: true, MeteringScreenLayoutFeature.filmPicker: true, - MeteringScreenLayoutFeature.histogram: false, + MeteringScreenLayoutFeature.histogram: true, }); when(() => mockUserPreferencesService.themeType).thenReturn(ThemeType.light); when(() => mockUserPreferencesService.primaryColor).thenReturn(primaryColorsList[5]); @@ -135,7 +137,7 @@ void main() { } group( - 'Metering layout features', + '[Metering layout features]', () { Future toggleFeatureAndClose(WidgetTester tester, String feature) async { await tester.openSettings(); @@ -155,17 +157,6 @@ void main() { await tester.pumpAndSettle(); } - setUpAll(() { - when(() => mockUserPreferencesService.evSourceType).thenReturn(EvSourceType.sensor); - when(() => mockLightSensorService.luxStream()).thenAnswer((_) => Stream.fromIterable([100])); - when(() => mockUserPreferencesService.meteringScreenLayout).thenReturn({ - MeteringScreenLayoutFeature.equipmentProfiles: true, - MeteringScreenLayoutFeature.extremeExposurePairs: true, - MeteringScreenLayoutFeature.filmPicker: true, - MeteringScreenLayoutFeature.histogram: true, - }); - }); - testWidgets( 'Toggle equipmentProfiles & discard selected', (tester) async { @@ -243,6 +234,55 @@ void main() { ); }, ); + + testWidgets( + '[Films in use] Deselect current', + (tester) async { + await pumpApplication( + tester, + IAPProductStatus.purchased, + selectedFilm: mockFilms[0], + ); + + // Check that film is selected and reciprocity is applied + await tester.toggleIncidentMetering(); + expectAnimatedPickerWith(value: mockFilms[0].name); + expectExposurePairsContainer('f/1.0 - 1/160', 'f/45 - 26"'); + expectMeasureButton(7.3); + + // Deselect the first films + await tester.openSettings(); + expect(find.byType(SettingsScreen), findsOneWidget); + await tester.tap(find.text(S.current.filmsInUse)); + await tester.pumpAndSettle(); + expect(find.byType(DialogFilter), findsOneWidget); + await tester.tap( + find.descendant( + of: find.byType(CheckboxListTile), + matching: find.text(mockFilms[0].name), + ), + ); + await tester.tapSaveButton(); + expect(find.byType(DialogFilter), findsNothing); + await tester.tap(find.byIcon(Icons.close)); + await tester.pumpAndSettle(); + + // The previously selected films is no longer in use and therefore is discarded to None + expectAnimatedPickerWith(value: S.current.none); + expectMeasureButton(7.3); + + // The previously selected films is no longer in use and therefore is not present in the picker + await tester.openAnimatedPicker(); + expect(find.byType(DialogPicker), findsOneWidget); + expect( + find.descendant( + of: find.byWidgetPredicate((widget) => widget is RadioListTile && widget.selected), + matching: find.text(mockFilms[0].name), + ), + findsNothing, + ); + }, + ); } extension _WidgetTesterActions on WidgetTester { diff --git a/integration_test/utils/widget_tester_actions.dart b/integration_test/utils/widget_tester_actions.dart index 84278cf..2c6f8c0 100644 --- a/integration_test/utils/widget_tester_actions.dart +++ b/integration_test/utils/widget_tester_actions.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:lightmeter/generated/l10n.dart'; +import 'package:lightmeter/res/dimens.dart'; import 'package:lightmeter/screens/metering/components/bottom_controls/components/measure_button/widget_button_measure.dart'; extension WidgetTesterTextButtonActions on WidgetTester { @@ -26,4 +27,9 @@ extension WidgetTesterCommonActions on WidgetTester { await tap(find.byType(MeteringMeasureButton)); await pumpAndSettle(); } + + Future openAnimatedPicker() async { + await tap(find.byType(T)); + await pumpAndSettle(Dimens.durationL); + } }