mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-22 15:30:59 +00:00
FilmPicker
integration tests
This commit is contained in:
parent
387d875038
commit
24804a119e
4 changed files with 69 additions and 32 deletions
|
@ -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<FilmPicker>(title: S.current.film, value: S.current.none);
|
||||
expectExposurePairsContainer('$mockPhotoFastestExposurePair', '$mockPhotoSlowestExposurePair');
|
||||
expectMeasureButton(mockPhotoEv100);
|
||||
|
||||
await tester.openAnimatedPicker<FilmPicker>();
|
||||
expect(find.byType(DialogPicker<Film>), findsOneWidget);
|
||||
await tester.tapDescendantTextOf<DialogPicker<Film>>(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<FilmPicker>(title: S.current.film, value: S.current.none);
|
||||
expectExposurePairsContainer('$mockPhotoFastestExposurePair', '$mockPhotoSlowestExposurePair');
|
||||
expectMeasureButton(mockPhotoEv100);
|
||||
|
||||
await tester.openAnimatedPicker<FilmPicker>();
|
||||
await tester.tapDescendantTextOf<DialogPicker<Film>>(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,
|
||||
);
|
||||
}
|
||||
|
||||
extension _WidgetTesterActions on WidgetTester {
|
||||
Future<void> tapRadioListTile<T>(String value) async {
|
||||
expect(find.descendant(of: find.byType(RadioListTile<T>), matching: find.text(value)), findsOneWidget);
|
||||
await tap(find.descendant(of: find.byType(RadioListTile<T>), matching: find.text(value)));
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -9,18 +9,8 @@ import 'package:lightmeter/screens/settings/components/shared/dialog_picker/widg
|
|||
void expectAnimatedPickerWith<T>({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
|
||||
|
|
|
@ -54,6 +54,17 @@ extension WidgetTesterCommonActions on WidgetTester {
|
|||
}
|
||||
}
|
||||
|
||||
extension WidgetTesterListTileActions on WidgetTester {
|
||||
Future<void> tapRadioListTile<T>(String text) async {
|
||||
await tap(find.descendant(of: find.byType(RadioListTile<T>), matching: find.text(text)));
|
||||
}
|
||||
|
||||
/// Useful for tapping a specific [ListTile] inside a specific screen or dialog
|
||||
Future<void> tapDescendantTextOf<T>(String text) async {
|
||||
await tap(find.descendant(of: find.byType(T), matching: find.text(text)));
|
||||
}
|
||||
}
|
||||
|
||||
extension WidgetTesterTextButtonActions on WidgetTester {
|
||||
Future<void> tapSelectButton() => _tapTextButton(S.current.select);
|
||||
|
||||
|
|
Loading…
Reference in a new issue