fixed unit tests

This commit is contained in:
Vadim 2025-05-11 19:01:03 +02:00
parent 175beaa21d
commit d65b2d197d
4 changed files with 15 additions and 11 deletions

View file

@ -11,11 +11,13 @@ void main() {
{
'spotMetering': true,
'histogram': true,
'showFocalLength': true,
},
),
{
CameraFeature.spotMetering: true,
CameraFeature.histogram: true,
CameraFeature.showFocalLength: true,
},
);
});
@ -26,6 +28,7 @@ void main() {
{
CameraFeature.spotMetering: false,
CameraFeature.histogram: false,
CameraFeature.showFocalLength: false,
},
);
});

View file

@ -272,6 +272,7 @@ void main() {
{
CameraFeature.spotMetering: false,
CameraFeature.histogram: false,
CameraFeature.showFocalLength: false,
},
);
});
@ -284,6 +285,7 @@ void main() {
{
CameraFeature.spotMetering: false,
CameraFeature.histogram: true,
CameraFeature.showFocalLength: false,
},
);
});
@ -292,17 +294,18 @@ void main() {
when(
() => sharedPreferences.setString(
UserPreferencesService.cameraFeaturesKey,
"""{"spotMetering":false,"histogram":true}""",
"""{"spotMetering":false,"histogram":true,"showFocalLength":true}""",
),
).thenAnswer((_) => Future.value(true));
service.cameraFeatures = {
CameraFeature.spotMetering: false,
CameraFeature.histogram: true,
CameraFeature.showFocalLength: true,
};
verify(
() => sharedPreferences.setString(
UserPreferencesService.cameraFeaturesKey,
"""{"spotMetering":false,"histogram":true}""",
"""{"spotMetering":false,"histogram":true,"showFocalLength":true}""",
),
).called(1);
});

View file

@ -37,6 +37,7 @@ void main() {
when(() => mockUserPreferencesService.cameraFeatures).thenReturn({
CameraFeature.spotMetering: true,
CameraFeature.histogram: true,
CameraFeature.showFocalLength: true,
});
when(() => mockUserPreferencesService.locale).thenReturn(SupportedLocale.en);
when(() => mockUserPreferencesService.themeType).thenReturn(ThemeType.light);
@ -227,13 +228,6 @@ void main() {
expect(find.text("${MeteringScreenLayoutFeature.equipmentProfiles}: true"), findsNWidgets(2));
expect(find.text("${MeteringScreenLayoutFeature.extremeExposurePairs}: false"), findsNWidgets(2));
expect(find.text("${MeteringScreenLayoutFeature.filmPicker}: false"), findsNWidgets(2));
verify(
() => mockUserPreferencesService.meteringScreenLayout = {
MeteringScreenLayoutFeature.extremeExposurePairs: false,
MeteringScreenLayoutFeature.filmPicker: false,
MeteringScreenLayoutFeature.equipmentProfiles: true,
},
).called(1);
},
);
@ -260,6 +254,7 @@ void main() {
onPressed: () => UserPreferencesProvider.of(context).setCameraFeature({
CameraFeature.spotMetering: true,
CameraFeature.histogram: false,
CameraFeature.showFocalLength: false,
}),
child: const Text(''),
),
@ -270,15 +265,18 @@ void main() {
// Match `findsNWidgets(2)` to verify that `cameraFeatureOf` specific results are the same as the whole config
expect(find.text("${CameraFeature.spotMetering}: true"), findsNWidgets(2));
expect(find.text("${CameraFeature.histogram}: true"), findsNWidgets(2));
expect(find.text("${CameraFeature.showFocalLength}: true"), findsNWidgets(2));
await tester.tap(find.byType(ElevatedButton));
await tester.pumpAndSettle();
expect(find.text("${CameraFeature.spotMetering}: true"), findsNWidgets(2));
expect(find.text("${CameraFeature.histogram}: false"), findsNWidgets(2));
expect(find.text("${CameraFeature.showFocalLength}: false"), findsNWidgets(2));
verify(
() => mockUserPreferencesService.cameraFeatures = {
CameraFeature.spotMetering: true,
CameraFeature.histogram: false,
CameraFeature.showFocalLength: false,
},
).called(1);
},

View file

@ -11,7 +11,7 @@ void main() {
() async {
final bytes = File('assets/camera_stub_image.jpg').readAsBytesSync();
final tags = await readExifFromBytes(bytes);
expectLater(evFromTags(tags), completion(8.25230310752341));
expect(evFromTags(tags), 8.25230310752341);
},
);
@ -20,7 +20,7 @@ void main() {
() async {
final bytes = File('assets/launcher_icon_dev_512.png').readAsBytesSync();
final tags = await readExifFromBytes(bytes);
expectLater(evFromTags(tags), throwsArgumentError);
expect(() => evFromTags(tags), throwsArgumentError);
},
);
});