diff --git a/integration_test/metering_screen_test.dart b/integration_test/metering_screen_test.dart index cea653e..933d669 100644 --- a/integration_test/metering_screen_test.dart +++ b/integration_test/metering_screen_test.dart @@ -32,7 +32,9 @@ const mockPhotoEv100 = 8.3; const mockPhotoFastestAperture = ApertureValue(1, StopType.full); const mockPhotoSlowestAperture = ApertureValue(45, StopType.full); const mockPhotoFastestShutterSpeed = ShutterSpeedValue(320, true, StopType.third); -const mockPhotoSlowestShutterSpeed = ShutterSpeedValue(13, false, StopType.third); +const mockPhotoSlowestShutterSpeed = ShutterSpeedValue(6, false, StopType.third); +const mockPhotoFastestExposurePair = ExposurePair(mockPhotoFastestAperture, mockPhotoFastestShutterSpeed); +const mockPhotoSlowestExposurePair = ExposurePair(mockPhotoSlowestAperture, mockPhotoSlowestShutterSpeed); //https://stackoverflow.com/a/67186625/13167574 void main() { @@ -187,26 +189,66 @@ void main() { testWidgets( 'with the same ISO', (tester) async { - await tester.pumpApplication(productStatus: IAPProductStatus.purchased); - expectExposurePairsContainer('f/1.0 - 1/320', 'f/45 - 13"'); + await tester.pumpApplication(); + await tester.takePhoto(); + + // Verify that reciprocity failure is applies for the film is not selected + expectAnimatedPickerWith(title: S.current.film, value: S.current.none); + expectExposurePairsContainer('$mockPhotoFastestExposurePair', '$mockPhotoSlowestExposurePair'); expectMeasureButton(mockPhotoEv100); await tester.openAnimatedPicker(); - expect(find.byType(DialogPicker), findsOneWidget); + await tester.tapDescendantTextOf>(mockFilms.first.name); await tester.tapSelectButton(); - expectExposurePairsContainer('f/1.0 - 1/320', 'f/45 - 13"'); + + /// Verify that exposure pairs are the same, except that the reciprocity failure is applied + expectExposurePairsContainer( + '$mockPhotoFastestExposurePair', + '$mockPhotoSlowestAperture - ${mockFilms.first.reciprocityFailure(mockPhotoSlowestShutterSpeed)}', + ); expectMeasureButton(mockPhotoEv100); - /// Make sure, that nothing is changed - await tester.tap(find.byType(MeteringMeasureButton)); - await tester.tap(find.byType(MeteringMeasureButton)); - await tester.pumpAndSettle(); - expectExposurePairsContainer('f/1.0 - 1/320', 'f/45 - 13"'); + /// Make sure, that the EV is not changed + await tester.takePhoto(); + expectExposurePairsContainer( + '$mockPhotoFastestExposurePair', + '$mockPhotoSlowestAperture - ${mockFilms.first.reciprocityFailure(mockPhotoSlowestShutterSpeed)}', + ); expectMeasureButton(mockPhotoEv100); }, ); - /// Select film with iso > current + testWidgets( + 'with greater ISO', + (tester) async { + await tester.pumpApplication(); + await tester.takePhoto(); + + // Verify that reciprocity failure is applies for the film is not selected + expectAnimatedPickerWith(title: S.current.film, value: S.current.none); + expectExposurePairsContainer('$mockPhotoFastestExposurePair', '$mockPhotoSlowestExposurePair'); + expectMeasureButton(mockPhotoEv100); + + await tester.openAnimatedPicker(); + await tester.tapDescendantTextOf>(mockFilms[1].name); + await tester.tapSelectButton(); + + /// Verify that exposure pairs are the same, except that the reciprocity failure is applied + expectExposurePairsContainer( + '$mockPhotoFastestExposurePair', + '$mockPhotoSlowestAperture - ${mockFilms[1].reciprocityFailure(mockPhotoSlowestShutterSpeed)}', + ); + expectMeasureButton(mockPhotoEv100); + + /// Make sure, that the EV is not changed + await tester.takePhoto(); + expectExposurePairsContainer( + '$mockPhotoFastestExposurePair', + '$mockPhotoSlowestAperture - ${mockFilms[1].reciprocityFailure(mockPhotoSlowestShutterSpeed)}', + ); + expectMeasureButton(mockPhotoEv100); + }, + ); }); testWidgets( @@ -230,6 +272,7 @@ void main() { expectExposurePairsContainer('f/1.0 - 1/320', 'f/45 - 6"'); expectMeasureButton(8.3); }, + skip: true, ); testWidgets( @@ -253,15 +296,8 @@ void main() { expectExposurePairsContainer('f/1.0 - 1/80', 'f/36 - 16"'); expectMeasureButton(6.3); }, + skip: true, ); }, - skip: true, ); } - -extension _WidgetTesterActions on WidgetTester { - 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/mocks/paid_features_mock.dart b/integration_test/mocks/paid_features_mock.dart index fe99260..5d38c52 100644 --- a/integration_test/mocks/paid_features_mock.dart +++ b/integration_test/mocks/paid_features_mock.dart @@ -93,7 +93,7 @@ final mockEquipmentProfiles = [ ), ]; -const mockFilms = [_MockFilm(400, 2), _MockFilm(3, 800), _MockFilm(400, 1.5)]; +const mockFilms = [_MockFilm(100, 2), _MockFilm(400, 2), _MockFilm(3, 800), _MockFilm(400, 1.5)]; class _MockFilm extends Film { final double reciprocityMultiplier; diff --git a/integration_test/utils/expectations.dart b/integration_test/utils/expectations.dart index 29be39e..06f9429 100644 --- a/integration_test/utils/expectations.dart +++ b/integration_test/utils/expectations.dart @@ -9,18 +9,8 @@ import 'package:lightmeter/screens/settings/components/shared/dialog_picker/widg void expectAnimatedPickerWith({String? title, String? value}) { final pickerFinder = find.byType(T); expect(pickerFinder, findsOneWidget); - if (title != null) { - expect( - find.descendant(of: pickerFinder, matching: find.text(title)), - findsOneWidget, - ); - } - if (value != null) { - expect( - find.descendant(of: pickerFinder, matching: find.text(value)), - findsOneWidget, - ); - } + if (title != null) expect(find.descendant(of: pickerFinder, matching: find.text(title)), findsOneWidget); + if (value != null) expect(find.descendant(of: pickerFinder, matching: find.text(value)), findsOneWidget); } /// Finds exactly one dialog picker of the provided value type diff --git a/integration_test/utils/widget_tester_actions.dart b/integration_test/utils/widget_tester_actions.dart index 8abc4ce..1769b72 100644 --- a/integration_test/utils/widget_tester_actions.dart +++ b/integration_test/utils/widget_tester_actions.dart @@ -54,6 +54,17 @@ extension WidgetTesterCommonActions on WidgetTester { } } +extension WidgetTesterListTileActions on WidgetTester { + Future tapRadioListTile(String text) async { + await tap(find.descendant(of: find.byType(RadioListTile), matching: find.text(text))); + } + + /// 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))); + } +} + extension WidgetTesterTextButtonActions on WidgetTester { Future tapSelectButton() => _tapTextButton(S.current.select);