mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-21 23:10:40 +00:00
fixed storage mock for integration tests
This commit is contained in:
parent
5c51c284c9
commit
4ea34410a4
2 changed files with 32 additions and 34 deletions
|
@ -58,24 +58,24 @@ void testE2E(String description) {
|
|||
await tester.tapDescendantTextOf<SettingsScreen>(S.current.equipmentProfiles);
|
||||
await tester.tap(find.byIcon(Icons.add_outlined).first);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.selectProfileName(mockEquipmentProfiles[0].name);
|
||||
await tester.expandEquipmentProfileContainer(mockEquipmentProfiles[0].name);
|
||||
await tester.setIsoValues(0, mockEquipmentProfiles[0].isoValues);
|
||||
await tester.setNdValues(0, mockEquipmentProfiles[0].ndValues);
|
||||
await tester.setApertureValues(0, mockEquipmentProfiles[0].apertureValues);
|
||||
await tester.setShutterSpeedValues(0, mockEquipmentProfiles[0].shutterSpeedValues);
|
||||
await tester.setZoomValue(0, mockEquipmentProfiles[0].lensZoom);
|
||||
await tester.enterProfileName(mockEquipmentProfiles[0].name);
|
||||
await tester.setIsoValues(mockEquipmentProfiles[0].isoValues);
|
||||
await tester.setNdValues(mockEquipmentProfiles[0].ndValues);
|
||||
await tester.setApertureValues(mockEquipmentProfiles[0].apertureValues);
|
||||
await tester.setShutterSpeedValues(mockEquipmentProfiles[0].shutterSpeedValues);
|
||||
await tester.setZoomValue(mockEquipmentProfiles[0].lensZoom);
|
||||
expect(find.text('x1.91'), findsOneWidget);
|
||||
expect(find.text('f/1.7 - f/16'), findsOneWidget);
|
||||
expect(find.text('1/1000 - B'), findsOneWidget);
|
||||
await tester.tap(find.byIcon(Icons.save_outlined));
|
||||
await tester.pump();
|
||||
|
||||
/// Create Praktica + Jupiter profile from Zenitar profile
|
||||
await tester.tap(find.byIcon(Icons.copy_outlined).first);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.selectProfileName(mockEquipmentProfiles[1].name);
|
||||
await tester.expandEquipmentProfileContainer(mockEquipmentProfiles[1].name);
|
||||
await tester.setApertureValues(1, mockEquipmentProfiles[1].apertureValues);
|
||||
await tester.setZoomValue(1, mockEquipmentProfiles[1].lensZoom);
|
||||
await tester.enterProfileName(mockEquipmentProfiles[1].name);
|
||||
await tester.setApertureValues(mockEquipmentProfiles[1].apertureValues);
|
||||
await tester.setZoomValue(mockEquipmentProfiles[1].lensZoom);
|
||||
expect(find.text('x5.02'), findsOneWidget);
|
||||
expect(find.text('f/3.5 - f/22'), findsOneWidget);
|
||||
expect(find.text('1/1000 - B'), findsNWidgets(2));
|
||||
|
@ -147,40 +147,31 @@ void testE2E(String description) {
|
|||
}
|
||||
|
||||
extension EquipmentProfileActions on WidgetTester {
|
||||
Future<void> expandEquipmentProfileContainer(String name) async {
|
||||
await tap(find.text(name));
|
||||
await pump(Dimens.durationM);
|
||||
}
|
||||
|
||||
Future<void> selectProfileName(String name) async {
|
||||
Future<void> enterProfileName(String name) async {
|
||||
await enterText(find.byType(TextField), name);
|
||||
await pump();
|
||||
await tapSaveButton();
|
||||
}
|
||||
|
||||
Future<void> setIsoValues(int profileIndex, List<IsoValue> values) =>
|
||||
_openAndSetDialogFilterValues<IsoValue>(profileIndex, S.current.isoValues, values);
|
||||
Future<void> setNdValues(int profileIndex, List<NdValue> values) =>
|
||||
_openAndSetDialogFilterValues<NdValue>(profileIndex, S.current.ndFilters, values);
|
||||
Future<void> setIsoValues(List<IsoValue> values) =>
|
||||
_openAndSetDialogFilterValues<IsoValue>(S.current.isoValues, values);
|
||||
Future<void> setNdValues(List<NdValue> values) => _openAndSetDialogFilterValues<NdValue>(S.current.ndFilters, values);
|
||||
Future<void> _openAndSetDialogFilterValues<T extends PhotographyValue>(
|
||||
int profileIndex,
|
||||
String listTileTitle,
|
||||
List<T> valuesToSelect, {
|
||||
bool deselectAll = true,
|
||||
}) async {
|
||||
await tap(find.text(listTileTitle).at(profileIndex));
|
||||
await tap(find.text(listTileTitle));
|
||||
await pumpAndSettle();
|
||||
await setDialogFilterValues(valuesToSelect, deselectAll: deselectAll);
|
||||
}
|
||||
|
||||
Future<void> setApertureValues(int profileIndex, List<ApertureValue> values) =>
|
||||
_setDialogRangePickerValues<ApertureValue>(profileIndex, S.current.apertureValues, values);
|
||||
Future<void> setApertureValues(List<ApertureValue> values) =>
|
||||
_setDialogRangePickerValues<ApertureValue>(S.current.apertureValues, values);
|
||||
|
||||
Future<void> setShutterSpeedValues(int profileIndex, List<ShutterSpeedValue> values) =>
|
||||
_setDialogRangePickerValues<ShutterSpeedValue>(profileIndex, S.current.shutterSpeedValues, values);
|
||||
Future<void> setShutterSpeedValues(List<ShutterSpeedValue> values) =>
|
||||
_setDialogRangePickerValues<ShutterSpeedValue>(S.current.shutterSpeedValues, values);
|
||||
|
||||
Future<void> setZoomValue(int profileIndex, double value) =>
|
||||
_setDialogSliderPickerValue(profileIndex, S.current.lensZoom, value);
|
||||
Future<void> setZoomValue(double value) => _setDialogSliderPickerValue(S.current.lensZoom, value);
|
||||
}
|
||||
|
||||
extension on WidgetTester {
|
||||
|
@ -212,11 +203,10 @@ extension on WidgetTester {
|
|||
}
|
||||
|
||||
Future<void> _setDialogRangePickerValues<T extends PhotographyValue>(
|
||||
int profileIndex,
|
||||
String listTileTitle,
|
||||
List<T> valuesToSelect,
|
||||
) async {
|
||||
await tap(find.text(listTileTitle).at(profileIndex));
|
||||
await tap(find.text(listTileTitle));
|
||||
await pumpAndSettle();
|
||||
|
||||
final dialog = widget<DialogRangePicker<T>>(find.byType(DialogRangePicker<T>));
|
||||
|
@ -247,11 +237,10 @@ extension on WidgetTester {
|
|||
}
|
||||
|
||||
Future<void> _setDialogSliderPickerValue(
|
||||
int profileIndex,
|
||||
String listTileTitle,
|
||||
double value,
|
||||
) async {
|
||||
await tap(find.text(listTileTitle).at(profileIndex));
|
||||
await tap(find.text(listTileTitle));
|
||||
await pumpAndSettle();
|
||||
|
||||
final sliderFinder = find.byType(Slider);
|
||||
|
|
|
@ -41,12 +41,21 @@ class _MockIAPProvidersState extends State<MockIAPProviders> {
|
|||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
registerFallbackValue(defaultEquipmentProfile);
|
||||
mockEquipmentProfilesStorageService = _MockEquipmentProfilesStorageService();
|
||||
when(() => mockEquipmentProfilesStorageService.init()).thenAnswer((_) async {});
|
||||
when(() => mockEquipmentProfilesStorageService.getProfiles())
|
||||
.thenAnswer((_) => Future.value(widget.equipmentProfiles));
|
||||
when(() => mockEquipmentProfilesStorageService.selectedEquipmentProfileId)
|
||||
.thenReturn(widget.selectedEquipmentProfileId);
|
||||
when(() => mockEquipmentProfilesStorageService.addProfile(any<EquipmentProfile>())).thenAnswer((_) async {});
|
||||
when(
|
||||
() => mockEquipmentProfilesStorageService.updateProfile(
|
||||
id: any<String>(named: 'id'),
|
||||
name: any<String>(named: 'name'),
|
||||
),
|
||||
).thenAnswer((_) async {});
|
||||
when(() => mockEquipmentProfilesStorageService.deleteProfile(any<String>())).thenAnswer((_) async {});
|
||||
|
||||
mockFilmsStorageService = _MockFilmsStorageService();
|
||||
when(() => mockFilmsStorageService.init()).thenAnswer((_) async {});
|
||||
|
|
Loading…
Reference in a new issue