fixed unit tests

This commit is contained in:
Vadim 2024-10-29 10:20:55 +01:00
parent 09d04c665f
commit 7db43fb83b
5 changed files with 169 additions and 161 deletions

View file

@ -58,7 +58,6 @@ class ApplicationWrapper extends StatelessWidget {
storageService: iapService, storageService: iapService,
child: FilmsProvider( child: FilmsProvider(
filmsStorageService: filmsStorageService, filmsStorageService: filmsStorageService,
storageService: iapService,
child: UserPreferencesProvider( child: UserPreferencesProvider(
hasLightSensor: hasLightSensor, hasLightSensor: hasLightSensor,
userPreferencesService: userPreferencesService, userPreferencesService: userPreferencesService,

View file

@ -5,12 +5,10 @@ import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
class FilmsProvider extends StatefulWidget { class FilmsProvider extends StatefulWidget {
final FilmsStorageService filmsStorageService; final FilmsStorageService filmsStorageService;
final IAPStorageService storageService;
final Widget child; final Widget child;
const FilmsProvider({ const FilmsProvider({
required this.filmsStorageService, required this.filmsStorageService,
required this.storageService,
required this.child, required this.child,
super.key, super.key,
}); });
@ -39,8 +37,8 @@ class FilmsProviderState extends State<FilmsProvider> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Films( return Films(
predefinedFilms: predefinedFilms, predefinedFilms: context.isPro ? predefinedFilms : {},
customFilms: customFilms, customFilms: context.isPro ? customFilms : {},
selected: context.isPro ? _selectedFilm : const FilmStub(), selected: context.isPro ? _selectedFilm : const FilmStub(),
child: widget.child, child: widget.child,
); );
@ -64,7 +62,7 @@ class FilmsProviderState extends State<FilmsProvider> {
void selectFilm(Film film) { void selectFilm(Film film) {
if (_selectedFilm != film) { if (_selectedFilm != film) {
_selectedId = film.id; _selectedId = film.id;
widget.storageService.selectedFilmId = _selectedId; widget.filmsStorageService.selectedFilmId = _selectedId;
setState(() {}); setState(() {});
} }
} }
@ -91,7 +89,7 @@ class FilmsProviderState extends State<FilmsProvider> {
} }
Future<void> _init() async { Future<void> _init() async {
_selectedId = widget.storageService.selectedFilmId; _selectedId = widget.filmsStorageService.selectedFilmId;
predefinedFilms.addAll(await widget.filmsStorageService.getPredefinedFilms()); predefinedFilms.addAll(await widget.filmsStorageService.getPredefinedFilms());
customFilms.addAll(await widget.filmsStorageService.getCustomFilms()); customFilms.addAll(await widget.filmsStorageService.getCustomFilms());
_discardSelectedIfNotIncluded(); _discardSelectedIfNotIncluded();
@ -105,7 +103,7 @@ class FilmsProviderState extends State<FilmsProvider> {
final isSelectedUsed = predefinedFilms[_selectedId]?.isUsed ?? customFilms[_selectedId]?.isUsed ?? false; final isSelectedUsed = predefinedFilms[_selectedId]?.isUsed ?? customFilms[_selectedId]?.isUsed ?? false;
if (!isSelectedUsed) { if (!isSelectedUsed) {
_selectedId = const FilmStub().id; _selectedId = const FilmStub().id;
widget.storageService.selectedFilmId = _selectedId; widget.filmsStorageService.selectedFilmId = _selectedId;
} }
} }
} }

View file

@ -5,18 +5,29 @@ import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
import 'package:mocktail/mocktail.dart'; import 'package:mocktail/mocktail.dart';
class _MockIAPStorageService extends Mock implements IAPStorageService {} class _MockFilmsStorageService extends Mock implements FilmsStorageService {}
void main() { void main() {
TestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized();
late _MockIAPStorageService mockIAPStorageService; late _MockFilmsStorageService mockFilmsStorageService;
setUpAll(() { setUpAll(() {
mockIAPStorageService = _MockIAPStorageService(); mockFilmsStorageService = _MockFilmsStorageService();
});
setUp(() {
registerFallbackValue(mockCustomFilms.first);
when(() => mockFilmsStorageService.toggleFilm(any<Film>(), any<bool>())).thenAnswer((_) async {});
when(() => mockFilmsStorageService.addFilm(any<FilmExponential>())).thenAnswer((_) async {});
when(() => mockFilmsStorageService.updateFilm(any<FilmExponential>())).thenAnswer((_) async {});
when(() => mockFilmsStorageService.deleteFilm(any<FilmExponential>())).thenAnswer((_) async {});
when(() => mockFilmsStorageService.getPredefinedFilms())
.thenAnswer((_) => Future.value(mockPredefinedFilms.toFilmsMap()));
when(() => mockFilmsStorageService.getCustomFilms()).thenAnswer((_) => Future.value(mockCustomFilms.toFilmsMap()));
}); });
tearDown(() { tearDown(() {
reset(mockIAPStorageService); reset(mockFilmsStorageService);
}); });
Future<void> pumpTestWidget(WidgetTester tester, IAPProductStatus productStatus) async { Future<void> pumpTestWidget(WidgetTester tester, IAPProductStatus productStatus) async {
@ -30,16 +41,20 @@ void main() {
), ),
], ],
child: FilmsProvider( child: FilmsProvider(
storageService: mockIAPStorageService, filmsStorageService: mockFilmsStorageService,
availableFilms: mockFilms,
child: const _Application(), child: const _Application(),
), ),
), ),
); );
await tester.pumpAndSettle();
} }
void expectFilmsCount(int count) { void expectPredefinedFilmsCount(int count) {
expect(find.text('Films count: $count'), findsOneWidget); expect(find.text('Predefined films count: $count'), findsOneWidget);
}
void expectCustomFilmsCount(int count) {
expect(find.text('Custom films count: $count'), findsOneWidget);
} }
void expectFilmsInUseCount(int count) { void expectFilmsInUseCount(int count) {
@ -54,17 +69,21 @@ void main() {
'FilmsProvider dependency on IAPProductStatus', 'FilmsProvider dependency on IAPProductStatus',
() { () {
setUp(() { setUp(() {
when(() => mockIAPStorageService.selectedFilm).thenReturn(mockFilms.first); when(() => mockFilmsStorageService.selectedFilmId).thenReturn(mockPredefinedFilms.first.id);
when(() => mockIAPStorageService.filmsInUse).thenReturn(mockFilms); when(() => mockFilmsStorageService.getPredefinedFilms())
.thenAnswer((_) => Future.value(mockPredefinedFilms.toFilmsMap()));
when(() => mockFilmsStorageService.getCustomFilms())
.thenAnswer((_) => Future.value(mockCustomFilms.toFilmsMap()));
}); });
testWidgets( testWidgets(
'IAPProductStatus.purchased - show all saved films', 'IAPProductStatus.purchased - show all saved films',
(tester) async { (tester) async {
await pumpTestWidget(tester, IAPProductStatus.purchased); await pumpTestWidget(tester, IAPProductStatus.purchased);
expectFilmsCount(mockFilms.length + 1); expectPredefinedFilmsCount(mockPredefinedFilms.length);
expectFilmsInUseCount(mockFilms.length + 1); expectCustomFilmsCount(mockCustomFilms.length);
expectSelectedFilmName(mockFilms.first.name); expectFilmsInUseCount(mockPredefinedFilms.length + mockCustomFilms.length + 1);
expectSelectedFilmName(mockPredefinedFilms.first.name);
}, },
); );
@ -72,7 +91,8 @@ void main() {
'IAPProductStatus.purchasable - show only default', 'IAPProductStatus.purchasable - show only default',
(tester) async { (tester) async {
await pumpTestWidget(tester, IAPProductStatus.purchasable); await pumpTestWidget(tester, IAPProductStatus.purchasable);
expectFilmsCount(mockFilms.length + 1); expectPredefinedFilmsCount(0);
expectCustomFilmsCount(0);
expectFilmsInUseCount(1); expectFilmsInUseCount(1);
expectSelectedFilmName(''); expectSelectedFilmName('');
}, },
@ -82,7 +102,8 @@ void main() {
'IAPProductStatus.pending - show only default', 'IAPProductStatus.pending - show only default',
(tester) async { (tester) async {
await pumpTestWidget(tester, IAPProductStatus.pending); await pumpTestWidget(tester, IAPProductStatus.pending);
expectFilmsCount(mockFilms.length + 1); expectPredefinedFilmsCount(0);
expectCustomFilmsCount(0);
expectFilmsInUseCount(1); expectFilmsInUseCount(1);
expectSelectedFilmName(''); expectSelectedFilmName('');
}, },
@ -91,126 +112,126 @@ void main() {
); );
group( group(
'FilmsProvider CRUD', 'toggleFilm',
() { () {
testWidgets( testWidgets(
'Select films in use', 'toggle predefined film',
(tester) async { (tester) async {
when(() => mockIAPStorageService.selectedFilm).thenReturn(const FilmStub()); when(() => mockFilmsStorageService.selectedFilmId).thenReturn(mockPredefinedFilms.first.id);
when(() => mockIAPStorageService.filmsInUse).thenReturn([]);
/// Init
await pumpTestWidget(tester, IAPProductStatus.purchased); await pumpTestWidget(tester, IAPProductStatus.purchased);
expectFilmsCount(mockFilms.length + 1); expectPredefinedFilmsCount(mockPredefinedFilms.length);
expectFilmsInUseCount(1); expectCustomFilmsCount(mockCustomFilms.length);
expectFilmsInUseCount(mockPredefinedFilms.length + mockCustomFilms.length + 1);
expectSelectedFilmName(mockPredefinedFilms.first.name);
await tester.filmsProvider.toggleFilm(mockPredefinedFilms.first, false);
await tester.pump();
expectPredefinedFilmsCount(mockPredefinedFilms.length);
expectCustomFilmsCount(mockCustomFilms.length);
expectFilmsInUseCount(mockPredefinedFilms.length - 1 + mockCustomFilms.length + 1);
expectSelectedFilmName(''); expectSelectedFilmName('');
/// Select all filmsInUse verify(() => mockFilmsStorageService.toggleFilm(mockPredefinedFilms.first, false)).called(1);
await tester.tap(find.byKey(_Application.saveFilmsButtonKey(0))); verify(() => mockFilmsStorageService.selectedFilmId = '').called(1);
await tester.pumpAndSettle();
expectFilmsCount(mockFilms.length + 1);
expectFilmsInUseCount(mockFilms.length + 1);
expectSelectedFilmName('');
verify(() => mockIAPStorageService.filmsInUse = mockFilms.skip(0).toList()).called(1);
verifyNever(() => mockIAPStorageService.selectedFilm = const FilmStub());
}, },
); );
testWidgets( testWidgets(
'Select film', 'toggle custom film',
(tester) async { (tester) async {
when(() => mockIAPStorageService.selectedFilm).thenReturn(const FilmStub()); when(() => mockFilmsStorageService.selectedFilmId).thenReturn(mockCustomFilms.first.id);
when(() => mockIAPStorageService.filmsInUse).thenReturn(mockFilms);
/// Init
await pumpTestWidget(tester, IAPProductStatus.purchased); await pumpTestWidget(tester, IAPProductStatus.purchased);
expectFilmsCount(mockFilms.length + 1); expectPredefinedFilmsCount(mockPredefinedFilms.length);
expectFilmsInUseCount(mockFilms.length + 1); expectCustomFilmsCount(mockCustomFilms.length);
expectFilmsInUseCount(mockPredefinedFilms.length + mockCustomFilms.length + 1);
expectSelectedFilmName(mockCustomFilms.first.name);
await tester.filmsProvider.toggleFilm(mockCustomFilms.first, false);
await tester.pump();
expectPredefinedFilmsCount(mockPredefinedFilms.length);
expectCustomFilmsCount(mockCustomFilms.length);
expectFilmsInUseCount(mockPredefinedFilms.length - 1 + mockCustomFilms.length + 1);
expectSelectedFilmName(''); expectSelectedFilmName('');
/// Select all filmsInUse verify(() => mockFilmsStorageService.toggleFilm(mockCustomFilms.first, false)).called(1);
await tester.tap(find.byKey(_Application.setFilmButtonKey(0))); verify(() => mockFilmsStorageService.selectedFilmId = '').called(1);
await tester.pumpAndSettle();
expectFilmsCount(mockFilms.length + 1);
expectFilmsInUseCount(mockFilms.length + 1);
expectSelectedFilmName(mockFilms.first.name);
verifyNever(() => mockIAPStorageService.filmsInUse = any<List<Film>>());
verify(() => mockIAPStorageService.selectedFilm = mockFilms.first).called(1);
},
);
group(
'Coming from free app',
() {
testWidgets(
'Has selected film',
(tester) async {
when(() => mockIAPStorageService.selectedFilm).thenReturn(mockFilms[2]);
when(() => mockIAPStorageService.filmsInUse).thenReturn([]);
/// Init
await pumpTestWidget(tester, IAPProductStatus.purchased);
expectFilmsInUseCount(1);
expectSelectedFilmName('');
verifyNever(() => mockIAPStorageService.filmsInUse = any<List<Film>>());
verify(() => mockIAPStorageService.selectedFilm = const FilmStub()).called(1);
},
);
testWidgets(
'None film selected',
(tester) async {
when(() => mockIAPStorageService.selectedFilm).thenReturn(const FilmStub());
when(() => mockIAPStorageService.filmsInUse).thenReturn([]);
/// Init
await pumpTestWidget(tester, IAPProductStatus.purchased);
expectFilmsInUseCount(1);
expectSelectedFilmName('');
verifyNever(() => mockIAPStorageService.filmsInUse = any<List<Film>>());
verifyNever(() => mockIAPStorageService.selectedFilm = const FilmStub());
}, },
); );
}, },
); );
testWidgets( testWidgets(
'Discard selected (by filmsInUse list update)', 'selectFilm',
(tester) async { (tester) async {
when(() => mockIAPStorageService.selectedFilm).thenReturn(mockFilms.first); when(() => mockFilmsStorageService.selectedFilmId).thenReturn('');
when(() => mockIAPStorageService.filmsInUse).thenReturn(mockFilms);
/// Init
await pumpTestWidget(tester, IAPProductStatus.purchased); await pumpTestWidget(tester, IAPProductStatus.purchased);
expectFilmsCount(mockFilms.length + 1);
expectFilmsInUseCount(mockFilms.length + 1);
expectSelectedFilmName(mockFilms.first.name);
/// Select all filmsInUse except the first one
await tester.tap(find.byKey(_Application.saveFilmsButtonKey(1)));
await tester.pumpAndSettle();
expectFilmsCount(mockFilms.length + 1);
expectFilmsInUseCount((mockFilms.length - 1) + 1);
expectSelectedFilmName(''); expectSelectedFilmName('');
verify(() => mockIAPStorageService.filmsInUse = mockFilms.skip(1).toList()).called(1); tester.filmsProvider.selectFilm(mockPredefinedFilms.first);
verify(() => mockIAPStorageService.selectedFilm = const FilmStub()).called(1); await tester.pump();
expectSelectedFilmName(mockPredefinedFilms.first.name);
tester.filmsProvider.selectFilm(mockCustomFilms.first);
await tester.pump();
expectSelectedFilmName(mockCustomFilms.first.name);
verify(() => mockFilmsStorageService.selectedFilmId = mockPredefinedFilms.first.id).called(1);
verify(() => mockFilmsStorageService.selectedFilmId = mockCustomFilms.first.id).called(1);
}, },
); );
testWidgets(
'Custom film CRUD',
(tester) async {
when(() => mockFilmsStorageService.selectedFilmId).thenReturn('');
when(() => mockFilmsStorageService.getCustomFilms()).thenAnswer((_) => Future.value({}));
await pumpTestWidget(tester, IAPProductStatus.purchased);
expectPredefinedFilmsCount(mockPredefinedFilms.length);
expectCustomFilmsCount(0);
expectFilmsInUseCount(mockPredefinedFilms.length + 0 + 1);
expectSelectedFilmName('');
await tester.filmsProvider.addCustomFilm(mockCustomFilms.first);
await tester.filmsProvider.toggleFilm(mockCustomFilms.first, true);
tester.filmsProvider.selectFilm(mockCustomFilms.first);
await tester.pump();
expectPredefinedFilmsCount(mockPredefinedFilms.length);
expectCustomFilmsCount(1);
expectFilmsInUseCount(mockPredefinedFilms.length + 1 + 1);
expectSelectedFilmName(mockCustomFilms.first.name);
verify(() => mockFilmsStorageService.addFilm(mockCustomFilms.first)).called(1);
verify(() => mockFilmsStorageService.toggleFilm(mockCustomFilms.first, true)).called(1);
verify(() => mockFilmsStorageService.selectedFilmId = mockCustomFilms.first.id).called(1);
const editedFilmName = 'Edited custom film 2x';
final editedFilm = mockCustomFilms.first.copyWith(name: editedFilmName);
await tester.filmsProvider.updateCustomFilm(editedFilm);
await tester.pump();
expectSelectedFilmName(editedFilm.name);
verify(() => mockFilmsStorageService.updateFilm(editedFilm)).called(1);
await tester.filmsProvider.deleteCustomFilm(editedFilm);
await tester.pump();
expectPredefinedFilmsCount(mockPredefinedFilms.length);
expectCustomFilmsCount(0);
expectFilmsInUseCount(mockPredefinedFilms.length + 0 + 1);
expectSelectedFilmName('');
verify(() => mockFilmsStorageService.deleteFilm(editedFilm)).called(1);
verify(() => mockFilmsStorageService.selectedFilmId = '').called(1);
}, },
); );
} }
extension on WidgetTester {
FilmsProviderState get filmsProvider {
final BuildContext context = element(find.byType(_Application));
return FilmsProvider.of(context);
}
}
class _Application extends StatelessWidget { class _Application extends StatelessWidget {
const _Application(); const _Application();
static ValueKey saveFilmsButtonKey(int index) => ValueKey('saveFilmsButtonKey$index');
static ValueKey setFilmButtonKey(int index) => ValueKey('setFilmButtonKey$index');
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
@ -218,42 +239,30 @@ class _Application extends StatelessWidget {
body: Center( body: Center(
child: Column( child: Column(
children: [ children: [
Text("Films count: ${Films.of(context).length}"), Text("Predefined films count: ${Films.predefinedFilmsOf(context).length}"),
Text("Custom films count: ${Films.customFilmsOf(context).length}"),
Text("Films in use count: ${Films.inUseOf(context).length}"), Text("Films in use count: ${Films.inUseOf(context).length}"),
Text("Selected film: ${Films.selectedOf(context).name}"), Text("Selected film: ${Films.selectedOf(context).name}"),
_filmRow(context, 0),
_filmRow(context, 1),
], ],
), ),
), ),
), ),
); );
} }
Widget _filmRow(BuildContext context, int index) {
return Row(
children: [
ElevatedButton(
key: saveFilmsButtonKey(index),
onPressed: () {
FilmsProvider.of(context).saveFilms(mockFilms.skip(index).toList());
},
child: const Text("Save filmsInUse"),
),
ElevatedButton(
key: setFilmButtonKey(index),
onPressed: () {
FilmsProvider.of(context).setFilm(mockFilms[index]);
},
child: const Text("Set film"),
),
],
);
}
} }
const mockFilms = [ const mockPredefinedFilms = [
FilmExponential(id: '1', name: 'Mock film 2x', iso: 400, exponent: 1.34), FilmExponential(id: '1', name: 'Mock film 2x', iso: 400, exponent: 1.34),
FilmExponential(id: '2', name: 'Mock film 3x', iso: 800, exponent: 1.34), FilmExponential(id: '2', name: 'Mock film 3x', iso: 800, exponent: 1.34),
FilmExponential(id: '3', name: 'Mock film 4x', iso: 1200, exponent: 1.34), FilmExponential(id: '3', name: 'Mock film 4x', iso: 1200, exponent: 1.34),
]; ];
const mockCustomFilms = [
FilmExponential(id: '1abc', name: 'Mock custom film 2x', iso: 400, exponent: 1.34),
FilmExponential(id: '2abc', name: 'Mock custom film 3x', iso: 800, exponent: 1.34),
];
extension on List<Film> {
Map<String, ({T film, bool isUsed})> toFilmsMap<T extends Film>() =>
Map.fromEntries(map((e) => MapEntry(e.id, (film: e as T, isUsed: true))));
}

View file

@ -50,8 +50,8 @@ extension WidgetTesterActions on WidgetTester {
}) async { }) async {
await pumpWidget( await pumpWidget(
Films( Films(
values: const [FilmStub()], predefinedFilms: const {},
filmsInUse: const [FilmStub()], customFilms: const {},
selected: const FilmStub(), selected: const FilmStub(),
child: WidgetTestApplicationMock( child: WidgetTestApplicationMock(
child: Row( child: Row(

View file

@ -10,14 +10,16 @@ import 'package:mocktail/mocktail.dart';
import '../../../../../application_mock.dart'; import '../../../../../application_mock.dart';
import 'utils.dart'; import 'utils.dart';
class _MockIAPStorageService extends Mock implements IAPStorageService {} class _MockFilmsStorageService extends Mock implements FilmsStorageService {}
void main() { void main() {
late final _MockIAPStorageService mockIAPStorageService; late final _MockFilmsStorageService mockFilmsStorageService;
setUpAll(() { setUpAll(() {
mockIAPStorageService = _MockIAPStorageService(); mockFilmsStorageService = _MockFilmsStorageService();
when(() => mockIAPStorageService.filmsInUse).thenReturn(_films); when(() => mockFilmsStorageService.getPredefinedFilms()).thenAnswer(
(_) => Future.value(Map.fromEntries(_films.map((e) => MapEntry(e.id, (film: e, isUsed: true))))),
);
}); });
Future<void> pumpApplication(WidgetTester tester) async { Future<void> pumpApplication(WidgetTester tester) async {
@ -31,7 +33,7 @@ void main() {
), ),
], ],
child: FilmsProvider( child: FilmsProvider(
storageService: mockIAPStorageService, filmsStorageService: mockFilmsStorageService,
child: const WidgetTestApplicationMock( child: const WidgetTestApplicationMock(
child: Row( child: Row(
children: [ children: [
@ -51,7 +53,7 @@ void main() {
testWidgets( testWidgets(
'Film.other()', 'Film.other()',
(tester) async { (tester) async {
when(() => mockIAPStorageService.selectedFilm).thenReturn(const FilmStub()); when(() => mockFilmsStorageService.selectedFilmId).thenReturn(const FilmStub().id);
await pumpApplication(tester); await pumpApplication(tester);
expectReadingValueContainerText(S.current.film); expectReadingValueContainerText(S.current.film);
expectReadingValueContainerText(S.current.none); expectReadingValueContainerText(S.current.none);
@ -61,7 +63,7 @@ void main() {
testWidgets( testWidgets(
'Film with the same ISO', 'Film with the same ISO',
(tester) async { (tester) async {
when(() => mockIAPStorageService.selectedFilm).thenReturn(_films[1]); when(() => mockFilmsStorageService.selectedFilmId).thenReturn(_films[1].id);
await pumpApplication(tester); await pumpApplication(tester);
expectReadingValueContainerText(S.current.film); expectReadingValueContainerText(S.current.film);
expectReadingValueContainerText(_films[1].name); expectReadingValueContainerText(_films[1].name);
@ -71,7 +73,7 @@ void main() {
testWidgets( testWidgets(
'Film with greater ISO', 'Film with greater ISO',
(tester) async { (tester) async {
when(() => mockIAPStorageService.selectedFilm).thenReturn(_films[2]); when(() => mockFilmsStorageService.selectedFilmId).thenReturn(_films[2].id);
await pumpApplication(tester); await pumpApplication(tester);
expectReadingValueContainerText(S.current.filmPull); expectReadingValueContainerText(S.current.filmPull);
expectReadingValueContainerText(_films[2].name); expectReadingValueContainerText(_films[2].name);
@ -81,7 +83,7 @@ void main() {
testWidgets( testWidgets(
'Film with lower ISO', 'Film with lower ISO',
(tester) async { (tester) async {
when(() => mockIAPStorageService.selectedFilm).thenReturn(_films[0]); when(() => mockFilmsStorageService.selectedFilmId).thenReturn(_films[0].id);
await pumpApplication(tester); await pumpApplication(tester);
expectReadingValueContainerText(S.current.filmPush); expectReadingValueContainerText(S.current.filmPush);
expectReadingValueContainerText(_films[0].name); expectReadingValueContainerText(_films[0].name);
@ -92,7 +94,7 @@ void main() {
testWidgets( testWidgets(
'Film picker shows only films in use', 'Film picker shows only films in use',
(tester) async { (tester) async {
when(() => mockIAPStorageService.selectedFilm).thenReturn(_films[0]); when(() => mockFilmsStorageService.selectedFilmId).thenReturn(_films[0].id);
await pumpApplication(tester); await pumpApplication(tester);
await tester.openAnimatedPicker<FilmPicker>(); await tester.openAnimatedPicker<FilmPicker>();
expectRadioListTile<Film>(S.current.none, isSelected: true); expectRadioListTile<Film>(S.current.none, isSelected: true);
@ -104,8 +106,8 @@ void main() {
} }
const _films = [ const _films = [
FilmExponential(id: '', name: 'ISO 100 Film', iso: 100, exponent: 1.34), FilmExponential(id: '1', name: 'ISO 100 Film', iso: 100, exponent: 1.34),
FilmExponential(id: '', name: 'ISO 400 Film', iso: 400, exponent: 1.34), FilmExponential(id: '2', name: 'ISO 400 Film', iso: 400, exponent: 1.34),
FilmExponential(id: '', name: 'ISO 800 Film', iso: 800, exponent: 1.34), FilmExponential(id: '3', name: 'ISO 800 Film', iso: 800, exponent: 1.34),
FilmExponential(id: '', name: 'ISO 1600 Film', iso: 1600, exponent: 1.34), FilmExponential(id: '4', name: 'ISO 1600 Film', iso: 1600, exponent: 1.34),
]; ];