mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-26 01:10:39 +00:00
set sharedprefs mock without redundant group
This commit is contained in:
parent
4f1908c200
commit
e91d0f88c7
1 changed files with 73 additions and 83 deletions
|
@ -29,109 +29,99 @@ void main() {
|
||||||
final Color darkThemeColor = primaryColorsList[3];
|
final Color darkThemeColor = primaryColorsList[3];
|
||||||
|
|
||||||
void mockSharedPrefs(ThemeType theme, Color color) {
|
void mockSharedPrefs(ThemeType theme, Color color) {
|
||||||
setUp(() {
|
SharedPreferences.setMockInitialValues({
|
||||||
SharedPreferences.setMockInitialValues({
|
/// Metering values
|
||||||
/// Metering values
|
UserPreferencesService.evSourceTypeKey: EvSourceType.camera.index,
|
||||||
UserPreferencesService.evSourceTypeKey: EvSourceType.camera.index,
|
UserPreferencesService.isoKey: 400,
|
||||||
UserPreferencesService.isoKey: 400,
|
UserPreferencesService.ndFilterKey: 0,
|
||||||
UserPreferencesService.ndFilterKey: 0,
|
|
||||||
|
|
||||||
/// Metering settings
|
/// Metering settings
|
||||||
UserPreferencesService.stopTypeKey: StopType.third.index,
|
UserPreferencesService.stopTypeKey: StopType.third.index,
|
||||||
UserPreferencesService.cameraEvCalibrationKey: 0.0,
|
UserPreferencesService.cameraEvCalibrationKey: 0.0,
|
||||||
UserPreferencesService.lightSensorEvCalibrationKey: 0.0,
|
UserPreferencesService.lightSensorEvCalibrationKey: 0.0,
|
||||||
UserPreferencesService.meteringScreenLayoutKey: json.encode(
|
UserPreferencesService.meteringScreenLayoutKey: json.encode(
|
||||||
{
|
{
|
||||||
MeteringScreenLayoutFeature.equipmentProfiles: true,
|
MeteringScreenLayoutFeature.equipmentProfiles: true,
|
||||||
MeteringScreenLayoutFeature.extremeExposurePairs: true,
|
MeteringScreenLayoutFeature.extremeExposurePairs: true,
|
||||||
MeteringScreenLayoutFeature.filmPicker: true,
|
MeteringScreenLayoutFeature.filmPicker: true,
|
||||||
MeteringScreenLayoutFeature.histogram: false,
|
MeteringScreenLayoutFeature.histogram: false,
|
||||||
}.toJson(),
|
}.toJson(),
|
||||||
),
|
),
|
||||||
|
|
||||||
/// General settings
|
/// General settings
|
||||||
UserPreferencesService.caffeineKey: true,
|
UserPreferencesService.caffeineKey: true,
|
||||||
UserPreferencesService.hapticsKey: true,
|
UserPreferencesService.hapticsKey: true,
|
||||||
UserPreferencesService.volumeActionKey: VolumeAction.shutter.toString(),
|
UserPreferencesService.volumeActionKey: VolumeAction.shutter.toString(),
|
||||||
UserPreferencesService.localeKey: 'en',
|
UserPreferencesService.localeKey: 'en',
|
||||||
|
|
||||||
/// Theme settings
|
/// Theme settings
|
||||||
UserPreferencesService.themeTypeKey: theme.index,
|
UserPreferencesService.themeTypeKey: theme.index,
|
||||||
UserPreferencesService.primaryColorKey: color.value,
|
UserPreferencesService.primaryColorKey: color.value,
|
||||||
UserPreferencesService.dynamicColorKey: false,
|
UserPreferencesService.dynamicColorKey: false,
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
group(
|
/// Generates several screenshots with the light theme
|
||||||
'Light theme',
|
testWidgets(
|
||||||
() {
|
'Generate light theme screenshots',
|
||||||
|
(tester) async {
|
||||||
mockSharedPrefs(ThemeType.light, lightThemeColor);
|
mockSharedPrefs(ThemeType.light, lightThemeColor);
|
||||||
testWidgets(
|
await tester.pumpApplication();
|
||||||
'Generate light screenshots',
|
|
||||||
(tester) async {
|
|
||||||
await tester.pumpApplication();
|
|
||||||
|
|
||||||
await tester.takePhoto();
|
await tester.takePhoto();
|
||||||
await tester.takeScreenshot(binding, '${lightThemeColor.value}_metering_reflected');
|
await tester.takeScreenshot(binding, '${lightThemeColor.value}_metering_reflected');
|
||||||
|
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
await tester.tap(find.byTooltip(S.current.tooltipUseLightSensor));
|
await tester.tap(find.byTooltip(S.current.tooltipUseLightSensor));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.tap(find.byType(MeteringMeasureButton));
|
await tester.tap(find.byType(MeteringMeasureButton));
|
||||||
await sendMockIncidentEv(7.3);
|
await sendMockIncidentEv(7.3);
|
||||||
await tester.tap(find.byType(MeteringMeasureButton));
|
await tester.tap(find.byType(MeteringMeasureButton));
|
||||||
await tester.takeScreenshot(binding, '${lightThemeColor.value}_metering_incident');
|
await tester.takeScreenshot(binding, '${lightThemeColor.value}_metering_incident');
|
||||||
}
|
}
|
||||||
|
|
||||||
await tester.tap(find.byType(IsoValuePicker));
|
await tester.tap(find.byType(IsoValuePicker));
|
||||||
await tester.pumpAndSettle(Dimens.durationL);
|
await tester.pumpAndSettle(Dimens.durationL);
|
||||||
await tester.takeScreenshot(binding, '${lightThemeColor.value}_metering_iso_picker');
|
await tester.takeScreenshot(binding, '${lightThemeColor.value}_metering_iso_picker');
|
||||||
|
|
||||||
await tester.tapCancelButton();
|
await tester.tapCancelButton();
|
||||||
await tester.tap(find.byTooltip(S.current.tooltipOpenSettings));
|
await tester.tap(find.byTooltip(S.current.tooltipOpenSettings));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.takeScreenshot(binding, '${lightThemeColor.value}_settings');
|
await tester.takeScreenshot(binding, '${lightThemeColor.value}_settings');
|
||||||
|
|
||||||
await tester.tapListTile(S.current.meteringScreenLayout);
|
await tester.tapListTile(S.current.meteringScreenLayout);
|
||||||
await tester.takeScreenshot(binding, '${lightThemeColor.value}_settings_metering_screen_layout');
|
await tester.takeScreenshot(binding, '${lightThemeColor.value}_settings_metering_screen_layout');
|
||||||
|
|
||||||
await tester.tapCancelButton();
|
await tester.tapCancelButton();
|
||||||
await tester.tapListTile(S.current.equipmentProfiles);
|
await tester.tapListTile(S.current.equipmentProfiles);
|
||||||
await tester.tap(find.byType(EquipmentProfileContainer).first);
|
await tester.tap(find.byType(EquipmentProfileContainer).first);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.takeScreenshot(binding, '${lightThemeColor.value}-equipment_profiles');
|
await tester.takeScreenshot(binding, '${lightThemeColor.value}-equipment_profiles');
|
||||||
|
|
||||||
await tester.tap(find.byIcon(Icons.iso).first);
|
await tester.tap(find.byIcon(Icons.iso).first);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.takeScreenshot(binding, '${lightThemeColor.value}_equipment_profiles_iso_picker');
|
await tester.takeScreenshot(binding, '${lightThemeColor.value}_equipment_profiles_iso_picker');
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
group(
|
/// and the additionally the first one with the dark theme
|
||||||
'Dark theme',
|
testWidgets(
|
||||||
() {
|
'Generate dark theme screenshots',
|
||||||
|
(tester) async {
|
||||||
mockSharedPrefs(ThemeType.dark, darkThemeColor);
|
mockSharedPrefs(ThemeType.dark, darkThemeColor);
|
||||||
testWidgets(
|
await tester.pumpApplication();
|
||||||
'Generate dark screenshots',
|
|
||||||
(tester) async {
|
|
||||||
await tester.pumpApplication();
|
|
||||||
|
|
||||||
await tester.takePhoto();
|
await tester.takePhoto();
|
||||||
await tester.takeScreenshot(binding, '${darkThemeColor.value}_metering_reflected');
|
await tester.takeScreenshot(binding, '${darkThemeColor.value}_metering_reflected');
|
||||||
|
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
await tester.tap(find.byTooltip(S.current.tooltipUseLightSensor));
|
await tester.tap(find.byTooltip(S.current.tooltipUseLightSensor));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.tap(find.byType(MeteringMeasureButton));
|
await tester.tap(find.byType(MeteringMeasureButton));
|
||||||
await sendMockIncidentEv(7.3);
|
await sendMockIncidentEv(7.3);
|
||||||
await tester.tap(find.byType(MeteringMeasureButton));
|
await tester.tap(find.byType(MeteringMeasureButton));
|
||||||
await tester.takeScreenshot(binding, '${darkThemeColor.value}_metering_incident');
|
await tester.takeScreenshot(binding, '${darkThemeColor.value}_metering_incident');
|
||||||
}
|
}
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue