mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-22 07:20:39 +00:00
Films in use test
This commit is contained in:
parent
49412cfce4
commit
b68e6384d9
3 changed files with 59 additions and 19 deletions
|
@ -17,7 +17,6 @@ import 'package:lightmeter/environment.dart';
|
|||
import 'package:lightmeter/generated/l10n.dart';
|
||||
import 'package:lightmeter/providers/services_provider.dart';
|
||||
import 'package:lightmeter/providers/user_preferences_provider.dart';
|
||||
import 'package:lightmeter/res/dimens.dart';
|
||||
import 'package:lightmeter/res/theme.dart';
|
||||
import 'package:lightmeter/screens/metering/components/bottom_controls/components/measure_button/widget_button_measure.dart';
|
||||
import 'package:lightmeter/screens/metering/components/shared/exposure_pairs_list/widget_list_exposure_pairs.dart';
|
||||
|
@ -333,11 +332,6 @@ void main() {
|
|||
}
|
||||
|
||||
extension _WidgetTesterActions on WidgetTester {
|
||||
Future<void> openAnimatedPicker<T>() async {
|
||||
await tap(find.byType(T));
|
||||
await pumpAndSettle(Dimens.durationL);
|
||||
}
|
||||
|
||||
Future<void> tapRadioListTile<T>(String value) async {
|
||||
expect(find.descendant(of: find.byType(RadioListTile<T>), matching: find.text(value)), findsOneWidget);
|
||||
await tap(find.descendant(of: find.byType(RadioListTile<T>), matching: find.text(value)));
|
||||
|
|
|
@ -21,7 +21,9 @@ import 'package:lightmeter/res/theme.dart';
|
|||
import 'package:lightmeter/screens/metering/components/shared/readings_container/components/equipment_profile_picker/widget_picker_equipment_profiles.dart';
|
||||
import 'package:lightmeter/screens/metering/components/shared/readings_container/components/extreme_exposure_pairs_container/widget_container_extreme_exposure_pairs.dart';
|
||||
import 'package:lightmeter/screens/metering/components/shared/readings_container/components/film_picker/widget_picker_film.dart';
|
||||
import 'package:lightmeter/screens/metering/components/shared/readings_container/components/shared/animated_dialog_picker/components/dialog_picker/widget_picker_dialog.dart';
|
||||
import 'package:lightmeter/screens/settings/components/metering/components/metering_screen_layout/components/meterins_screen_layout_features_dialog/widget_dialog_metering_screen_layout_features.dart';
|
||||
import 'package:lightmeter/screens/settings/components/shared/dialog_filter/widget_dialog_filter.dart';
|
||||
import 'package:lightmeter/screens/settings/screen_settings.dart';
|
||||
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
|
||||
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
||||
|
@ -73,7 +75,7 @@ void main() {
|
|||
MeteringScreenLayoutFeature.equipmentProfiles: true,
|
||||
MeteringScreenLayoutFeature.extremeExposurePairs: true,
|
||||
MeteringScreenLayoutFeature.filmPicker: true,
|
||||
MeteringScreenLayoutFeature.histogram: false,
|
||||
MeteringScreenLayoutFeature.histogram: true,
|
||||
});
|
||||
when(() => mockUserPreferencesService.themeType).thenReturn(ThemeType.light);
|
||||
when(() => mockUserPreferencesService.primaryColor).thenReturn(primaryColorsList[5]);
|
||||
|
@ -135,7 +137,7 @@ void main() {
|
|||
}
|
||||
|
||||
group(
|
||||
'Metering layout features',
|
||||
'[Metering layout features]',
|
||||
() {
|
||||
Future<void> toggleFeatureAndClose(WidgetTester tester, String feature) async {
|
||||
await tester.openSettings();
|
||||
|
@ -155,17 +157,6 @@ void main() {
|
|||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
setUpAll(() {
|
||||
when(() => mockUserPreferencesService.evSourceType).thenReturn(EvSourceType.sensor);
|
||||
when(() => mockLightSensorService.luxStream()).thenAnswer((_) => Stream.fromIterable([100]));
|
||||
when(() => mockUserPreferencesService.meteringScreenLayout).thenReturn({
|
||||
MeteringScreenLayoutFeature.equipmentProfiles: true,
|
||||
MeteringScreenLayoutFeature.extremeExposurePairs: true,
|
||||
MeteringScreenLayoutFeature.filmPicker: true,
|
||||
MeteringScreenLayoutFeature.histogram: true,
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Toggle equipmentProfiles & discard selected',
|
||||
(tester) async {
|
||||
|
@ -243,6 +234,55 @@ void main() {
|
|||
);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'[Films in use] Deselect current',
|
||||
(tester) async {
|
||||
await pumpApplication(
|
||||
tester,
|
||||
IAPProductStatus.purchased,
|
||||
selectedFilm: mockFilms[0],
|
||||
);
|
||||
|
||||
// Check that film is selected and reciprocity is applied
|
||||
await tester.toggleIncidentMetering();
|
||||
expectAnimatedPickerWith<FilmPicker>(value: mockFilms[0].name);
|
||||
expectExposurePairsContainer('f/1.0 - 1/160', 'f/45 - 26"');
|
||||
expectMeasureButton(7.3);
|
||||
|
||||
// Deselect the first films
|
||||
await tester.openSettings();
|
||||
expect(find.byType(SettingsScreen), findsOneWidget);
|
||||
await tester.tap(find.text(S.current.filmsInUse));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(DialogFilter<Film>), findsOneWidget);
|
||||
await tester.tap(
|
||||
find.descendant(
|
||||
of: find.byType(CheckboxListTile),
|
||||
matching: find.text(mockFilms[0].name),
|
||||
),
|
||||
);
|
||||
await tester.tapSaveButton();
|
||||
expect(find.byType(DialogFilter<Film>), findsNothing);
|
||||
await tester.tap(find.byIcon(Icons.close));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// The previously selected films is no longer in use and therefore is discarded to None
|
||||
expectAnimatedPickerWith<FilmPicker>(value: S.current.none);
|
||||
expectMeasureButton(7.3);
|
||||
|
||||
// The previously selected films is no longer in use and therefore is not present in the picker
|
||||
await tester.openAnimatedPicker<FilmPicker>();
|
||||
expect(find.byType(DialogPicker<Film>), findsOneWidget);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byWidgetPredicate((widget) => widget is RadioListTile<Film> && widget.selected),
|
||||
matching: find.text(mockFilms[0].name),
|
||||
),
|
||||
findsNothing,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
extension _WidgetTesterActions on WidgetTester {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:lightmeter/generated/l10n.dart';
|
||||
import 'package:lightmeter/res/dimens.dart';
|
||||
import 'package:lightmeter/screens/metering/components/bottom_controls/components/measure_button/widget_button_measure.dart';
|
||||
|
||||
extension WidgetTesterTextButtonActions on WidgetTester {
|
||||
|
@ -26,4 +27,9 @@ extension WidgetTesterCommonActions on WidgetTester {
|
|||
await tap(find.byType(MeteringMeasureButton));
|
||||
await pumpAndSettle();
|
||||
}
|
||||
|
||||
Future<void> openAnimatedPicker<T>() async {
|
||||
await tap(find.byType(T));
|
||||
await pumpAndSettle(Dimens.durationL);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue