mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2025-09-18 12:36:42 +00:00
expanded logbook tests
This commit is contained in:
parent
56ab8aa85a
commit
7b46d4342c
2 changed files with 160 additions and 29 deletions
|
@ -63,23 +63,13 @@ void testLogbook(String description) {
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.openPickerAndSelect<ApertureValue>(S.current.apertureValue, 'f/5.6');
|
await tester.openPickerAndSelect<ApertureValue>(S.current.apertureValue, 'f/5.6');
|
||||||
await tester.openPickerAndSelect<ShutterSpeedValue>(S.current.shutterSpeedValue, '1/125');
|
await tester.openPickerAndSelect<ShutterSpeedValue>(S.current.shutterSpeedValue, '1/125');
|
||||||
expect(
|
_expectPickerListTileValue(
|
||||||
find.descendant(
|
S.current.equipmentProfile,
|
||||||
of: find.byWidgetPredicate(
|
mockEquipmentProfiles.first.name,
|
||||||
(widget) => widget is PickerListTile && widget.title == S.current.equipmentProfile,
|
|
||||||
),
|
|
||||||
matching: find.text(mockEquipmentProfiles.first.name),
|
|
||||||
),
|
|
||||||
findsOneWidget,
|
|
||||||
);
|
);
|
||||||
expect(
|
_expectPickerListTileValue(
|
||||||
find.descendant(
|
S.current.film,
|
||||||
of: find.byWidgetPredicate(
|
mockFilms.first.name,
|
||||||
(widget) => widget is PickerListTile && widget.title == S.current.film,
|
|
||||||
),
|
|
||||||
matching: find.text(mockFilms.first.name),
|
|
||||||
),
|
|
||||||
findsOneWidget,
|
|
||||||
);
|
);
|
||||||
await tester.openPickerAndSelect<Film>(S.current.film, S.current.notSet);
|
await tester.openPickerAndSelect<Film>(S.current.film, S.current.notSet);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
@ -117,14 +107,9 @@ void testLogbook(String description) {
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
/// Verify the edits were saved
|
/// Verify the edits were saved
|
||||||
expect(
|
_expectPickerListTileValue(
|
||||||
find.descendant(
|
S.current.equipmentProfile,
|
||||||
of: find.byWidgetPredicate(
|
S.current.notSet,
|
||||||
(widget) => widget is PickerListTile && widget.title == S.current.equipmentProfile,
|
|
||||||
),
|
|
||||||
matching: find.text(S.current.notSet),
|
|
||||||
),
|
|
||||||
findsOneWidget,
|
|
||||||
);
|
);
|
||||||
expect(find.text('Test note'), findsOneWidget);
|
expect(find.text('Test note'), findsOneWidget);
|
||||||
expect(find.text('f/5.6'), findsOneWidget);
|
expect(find.text('f/5.6'), findsOneWidget);
|
||||||
|
@ -141,6 +126,138 @@ void testLogbook(String description) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@isTest
|
||||||
|
void testLogbookEquipmentProfileChanges(String description) {
|
||||||
|
setUp(() async {
|
||||||
|
SharedPreferences.setMockInitialValues({
|
||||||
|
UserPreferencesService.evSourceTypeKey: EvSourceType.camera.index,
|
||||||
|
UserPreferencesService.seenChangelogVersionKey: await const PlatformUtils().version,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets(
|
||||||
|
description,
|
||||||
|
(tester) async {
|
||||||
|
await tester.pumpApplication(
|
||||||
|
selectedEquipmentProfileId: mockEquipmentProfiles.first.id,
|
||||||
|
selectedFilmId: mockFilms.first.id,
|
||||||
|
customFilms: {},
|
||||||
|
);
|
||||||
|
await tester.takePhoto();
|
||||||
|
await tester.openSettings();
|
||||||
|
await tester.tapDescendantTextOf<SettingsScreen>(S.current.logbook);
|
||||||
|
await tester.tap(find.byType(LogbookPhotoGridTile).first);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
await tester.ensureVisible(find.text(mockEquipmentProfiles.first.name));
|
||||||
|
_expectPickerListTileValue(
|
||||||
|
S.current.equipmentProfile,
|
||||||
|
mockEquipmentProfiles.first.name,
|
||||||
|
);
|
||||||
|
|
||||||
|
await tester.openPickerAndSelect<IEquipmentProfile>(S.current.equipmentProfile, mockEquipmentProfiles[1].name);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
_expectPickerListTileValue(
|
||||||
|
S.current.equipmentProfile,
|
||||||
|
mockEquipmentProfiles[1].name,
|
||||||
|
);
|
||||||
|
|
||||||
|
await tester.openPickerAndSelect<IEquipmentProfile>(
|
||||||
|
S.current.equipmentProfile,
|
||||||
|
mockPinholeEquipmentProfiles.first.name,
|
||||||
|
);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
_expectPickerListTileValue(
|
||||||
|
S.current.equipmentProfile,
|
||||||
|
mockPinholeEquipmentProfiles.first.name,
|
||||||
|
);
|
||||||
|
_expectPickerListTileValue(
|
||||||
|
S.current.apertureValue,
|
||||||
|
'f/${mockPinholeEquipmentProfiles.first.aperture}',
|
||||||
|
reason: 'Aperture value must be automatically set when selecting a pinhole profile',
|
||||||
|
);
|
||||||
|
|
||||||
|
final aperturePickerFinder = find.descendant(
|
||||||
|
of: find.byWidgetPredicate(
|
||||||
|
(widget) => widget is PickerListTile && widget.title == S.current.apertureValue,
|
||||||
|
),
|
||||||
|
matching: find.byType(PickerListTile),
|
||||||
|
);
|
||||||
|
expect(aperturePickerFinder, findsOneWidget);
|
||||||
|
await tester.tap(aperturePickerFinder);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(
|
||||||
|
find.byType(DialogPicker<Optional<ApertureValue>>),
|
||||||
|
findsNothing,
|
||||||
|
reason: 'Aperture picker dialog must not open when pinhole profile is selected',
|
||||||
|
);
|
||||||
|
|
||||||
|
await tester.openPickerAndSelect<IEquipmentProfile>(
|
||||||
|
S.current.equipmentProfile,
|
||||||
|
mockPinholeEquipmentProfiles[1].name,
|
||||||
|
);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
_expectPickerListTileValue(
|
||||||
|
S.current.equipmentProfile,
|
||||||
|
mockPinholeEquipmentProfiles[1].name,
|
||||||
|
);
|
||||||
|
|
||||||
|
_expectPickerListTileValue(
|
||||||
|
S.current.apertureValue,
|
||||||
|
'f/${mockPinholeEquipmentProfiles[1].aperture}',
|
||||||
|
reason: 'Aperture value must be updated when switching to a different pinhole profile',
|
||||||
|
);
|
||||||
|
|
||||||
|
await tester.tap(aperturePickerFinder);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(
|
||||||
|
find.byType(DialogPicker<Optional<ApertureValue>>),
|
||||||
|
findsNothing,
|
||||||
|
reason: 'Aperture picker dialog must not open when switching between pinhole profiles',
|
||||||
|
);
|
||||||
|
|
||||||
|
await tester.openPickerAndSelect<IEquipmentProfile>(S.current.equipmentProfile, mockEquipmentProfiles.first.name);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
_expectPickerListTileValue(
|
||||||
|
S.current.equipmentProfile,
|
||||||
|
mockEquipmentProfiles.first.name,
|
||||||
|
);
|
||||||
|
_expectPickerListTileValue(
|
||||||
|
S.current.apertureValue,
|
||||||
|
S.current.notSet,
|
||||||
|
reason: 'Aperture value must be cleared when switching from pinhole to regular profile',
|
||||||
|
);
|
||||||
|
|
||||||
|
await tester.tap(aperturePickerFinder);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(
|
||||||
|
find.byType(DialogPicker<Optional<ApertureValue>>),
|
||||||
|
findsOneWidget,
|
||||||
|
reason: 'Aperture picker dialog must open when regular profile is selected',
|
||||||
|
);
|
||||||
|
await tester.tap(find.text('Cancel'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
await tester.openPickerAndSelect<IEquipmentProfile>(S.current.equipmentProfile, S.current.notSet);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
_expectPickerListTileValue(
|
||||||
|
S.current.equipmentProfile,
|
||||||
|
S.current.notSet,
|
||||||
|
);
|
||||||
|
|
||||||
|
await tester.tap(find.byIcon(Icons.save_outlined));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
await tester.tap(find.byType(LogbookPhotoGridTile).first);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
_expectPickerListTileValue(
|
||||||
|
S.current.equipmentProfile,
|
||||||
|
S.current.notSet,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
extension on WidgetTester {
|
extension on WidgetTester {
|
||||||
Future<void> openPickerAndSelect<V>(String title, String valueToSelect) async {
|
Future<void> openPickerAndSelect<V>(String title, String valueToSelect) async {
|
||||||
await tap(find.text(title));
|
await tap(find.text(title));
|
||||||
|
@ -156,3 +273,16 @@ extension on WidgetTester {
|
||||||
await tapSelectButton();
|
await tapSelectButton();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _expectPickerListTileValue(String title, String value, {String? reason}) {
|
||||||
|
expect(
|
||||||
|
find.descendant(
|
||||||
|
of: find.byWidgetPredicate(
|
||||||
|
(widget) => widget is PickerListTile && widget.title == title,
|
||||||
|
),
|
||||||
|
matching: find.text(value),
|
||||||
|
),
|
||||||
|
findsOneWidget,
|
||||||
|
reason: reason,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
@ -19,9 +19,10 @@ void main() {
|
||||||
mockCameraFocalLength();
|
mockCameraFocalLength();
|
||||||
});
|
});
|
||||||
|
|
||||||
testPurchases('Purchase & refund premium features');
|
testPurchases('Purchase & refund premium features test');
|
||||||
testGuardProTap('Guard Pro tap');
|
testGuardProTap('Guard Pro tap test');
|
||||||
testToggleLayoutFeatures('Toggle metering screen layout features');
|
testToggleLayoutFeatures('Toggle metering screen layout features test');
|
||||||
testLogbook('Logbook');
|
testLogbook('Logbook test');
|
||||||
testE2E('e2e');
|
testLogbookEquipmentProfileChanges('Logbook equipment profile changes test');
|
||||||
|
testE2E('e2e test');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue