place screenshots in platform-specific folders

This commit is contained in:
Vadim 2023-12-27 12:06:03 +01:00
parent 5e446800e0
commit 4f86dee0f4
4 changed files with 25 additions and 13 deletions

2
.gitignore vendored
View file

@ -61,4 +61,4 @@ ios/Runner/GoogleService-Info.plist
coverage/
test/coverage_helper_test.dart
screenshots/*.png
screenshots/*/*.png

View file

@ -8,12 +8,16 @@ import 'package:mocktail/mocktail.dart';
class _MockIAPStorageService extends Mock implements IAPStorageService {}
class MockIAPProviders extends StatefulWidget {
final List<EquipmentProfile> equipmentProfiles;
final String selectedEquipmentProfileId;
final List<Film> films;
final Film selectedFilm;
final Widget child;
const MockIAPProviders({
this.equipmentProfiles = const [],
this.selectedEquipmentProfileId = '',
this.films = mockFilms,
this.selectedFilm = const Film.other(),
required this.child,
super.key,
@ -66,7 +70,12 @@ final mockEquipmentProfiles = [
ApertureValue.values.indexOf(const ApertureValue(1.7, StopType.half)),
ApertureValue.values.indexOf(const ApertureValue(16, StopType.full)) + 1,
),
ndValues: NdValue.values.sublist(0, 3),
ndValues: const [
NdValue(0),
NdValue(2),
NdValue(4),
NdValue(8),
],
shutterSpeedValues: ShutterSpeedValue.values.sublist(
ShutterSpeedValue.values.indexOf(const ShutterSpeedValue(1000, true, StopType.full)),
ShutterSpeedValue.values.indexOf(const ShutterSpeedValue(16, false, StopType.full)) + 1,

View file

@ -63,6 +63,7 @@ extension WidgetTesterListTileActions on WidgetTester {
/// 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)));
await pumpAndSettle();
}
}

View file

@ -70,37 +70,37 @@ void main() {
await tester.pumpApplication();
await tester.takePhoto();
await tester.takeScreenshot(binding, '${lightThemeColor.value}_metering_reflected');
await tester.takeScreenshot(binding, 'light-metering_reflected');
if (Platform.isAndroid) {
await tester.tap(find.byTooltip(S.current.tooltipUseLightSensor));
await tester.pumpAndSettle();
await tester.toggleIncidentMetering(7.3);
await tester.takeScreenshot(binding, '${lightThemeColor.value}_metering_incident');
await tester.takeScreenshot(binding, 'light-metering_incident');
}
await tester.openAnimatedPicker<IsoValuePicker>();
await tester.takeScreenshot(binding, '${lightThemeColor.value}_metering_iso_picker');
await tester.takeScreenshot(binding, 'light-metering_iso_picker');
await tester.tapCancelButton();
await tester.tap(find.byTooltip(S.current.tooltipOpenSettings));
await tester.pumpAndSettle();
await tester.takeScreenshot(binding, '${lightThemeColor.value}_settings');
await tester.takeScreenshot(binding, 'light-settings');
await tester.tapDescendantTextOf<SettingsScreen>(S.current.meteringScreenLayout);
await tester.takeScreenshot(binding, '${lightThemeColor.value}_settings_metering_screen_layout');
await tester.takeScreenshot(binding, 'light-settings_metering_screen_layout');
await tester.tapCancelButton();
await tester.tapDescendantTextOf<SettingsScreen>(S.current.equipmentProfiles);
await tester.pumpAndSettle();
await tester.tapDescendantTextOf<EquipmentProfilesScreen>(mockEquipmentProfiles.first.name);
await tester.pumpAndSettle();
await tester.takeScreenshot(binding, '${lightThemeColor.value}-equipment_profiles');
await tester.takeScreenshot(binding, 'light-equipment_profiles');
await tester.tap(find.byIcon(Icons.iso).first);
await tester.pumpAndSettle();
await tester.takeScreenshot(binding, '${lightThemeColor.value}_equipment_profiles_iso_picker');
},
await tester.takeScreenshot(binding, 'light-equipment_profiles_iso_picker');
}
);
/// and the additionally the first one with the dark theme
@ -111,25 +111,27 @@ void main() {
await tester.pumpApplication();
await tester.takePhoto();
await tester.takeScreenshot(binding, '${darkThemeColor.value}_metering_reflected');
await tester.takeScreenshot(binding, 'dark-metering_reflected');
if (Platform.isAndroid) {
await tester.tap(find.byTooltip(S.current.tooltipUseLightSensor));
await tester.pumpAndSettle();
await tester.toggleIncidentMetering(7.3);
await tester.takeScreenshot(binding, '${darkThemeColor.value}_metering_incident');
await tester.takeScreenshot(binding, 'dark-metering_incident');
}
},
);
}
final String _platformFolder = Platform.isAndroid ? 'android' : 'ios';
extension on WidgetTester {
Future<void> takeScreenshot(IntegrationTestWidgetsFlutterBinding binding, String name) async {
if (Platform.isAndroid) {
await binding.convertFlutterSurfaceToImage();
await pumpAndSettle();
}
await binding.takeScreenshot(name);
await binding.takeScreenshot("$_platformFolder/$name");
await pumpAndSettle();
}
}