mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-22 15:30:59 +00:00
FilmPicker
widget tests
This commit is contained in:
parent
54898ba42e
commit
e15d64b10f
1 changed files with 109 additions and 0 deletions
|
@ -0,0 +1,109 @@
|
||||||
|
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/shared/readings_container/components/film_picker/widget_picker_film.dart';
|
||||||
|
import 'package:lightmeter/screens/metering/components/shared/readings_container/components/shared/reading_value_container/widget_container_reading_value.dart';
|
||||||
|
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
|
||||||
|
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
||||||
|
|
||||||
|
import '../../../../../application_mock.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
group('Film push/pull label', () {
|
||||||
|
testWidgets(
|
||||||
|
'Film.other()',
|
||||||
|
(tester) async {
|
||||||
|
await tester.pumpApplication(_films[0]);
|
||||||
|
_expectReadingValueContainerText(S.current.film);
|
||||||
|
_expectReadingValueContainerText(S.current.none);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
testWidgets(
|
||||||
|
'Film with the same ISO',
|
||||||
|
(tester) async {
|
||||||
|
await tester.pumpApplication(_films[2]);
|
||||||
|
_expectReadingValueContainerText(S.current.film);
|
||||||
|
_expectReadingValueContainerText(_films[2].name);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
testWidgets(
|
||||||
|
'Film with greater ISO',
|
||||||
|
(tester) async {
|
||||||
|
await tester.pumpApplication(_films[3]);
|
||||||
|
_expectReadingValueContainerText(S.current.filmPull);
|
||||||
|
_expectReadingValueContainerText(_films[3].name);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
testWidgets(
|
||||||
|
'Film with lower ISO',
|
||||||
|
(tester) async {
|
||||||
|
await tester.pumpApplication(_films[1]);
|
||||||
|
_expectReadingValueContainerText(S.current.filmPush);
|
||||||
|
_expectReadingValueContainerText(_films[1].name);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets(
|
||||||
|
'Film picker shows only films in use',
|
||||||
|
(tester) async {
|
||||||
|
await tester.pumpApplication(_films[1]);
|
||||||
|
await tester.tap(find.byType(FilmPicker));
|
||||||
|
await tester.pumpAndSettle(Dimens.durationL);
|
||||||
|
_expectRadioListTile(S.current.none);
|
||||||
|
_expectRadioListTile(_films[1].name);
|
||||||
|
_expectRadioListTile(_films[2].name);
|
||||||
|
_expectRadioListTile(_films[3].name);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
extension WidgetTesterActions on WidgetTester {
|
||||||
|
Future<void> pumpApplication(Film selectedFilm) async {
|
||||||
|
await pumpWidget(
|
||||||
|
FilmsProvider(
|
||||||
|
child: Films(
|
||||||
|
values: _films,
|
||||||
|
filmsInUse: _films.sublist(0, _films.length - 1),
|
||||||
|
selected: selectedFilm,
|
||||||
|
child: const WidgetTestApplicationMock(
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: FilmPicker(selectedIso: IsoValue(400, StopType.full)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await pumpAndSettle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const _films = [
|
||||||
|
Film.other(),
|
||||||
|
Film('ISO 100 Film', 100),
|
||||||
|
Film('ISO 400 Film', 400),
|
||||||
|
Film('ISO 800 Film', 800),
|
||||||
|
Film('ISO 1600 Film', 1600),
|
||||||
|
];
|
||||||
|
|
||||||
|
void _expectReadingValueContainerText(String text) {
|
||||||
|
expect(
|
||||||
|
find.descendant(of: find.byType(ReadingValueContainer), matching: find.text(text)),
|
||||||
|
findsOneWidget,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _expectRadioListTile(String filmName) {
|
||||||
|
expect(
|
||||||
|
find.descendant(of: find.byType(RadioListTile<Film>), matching: find.text(filmName)),
|
||||||
|
findsOneWidget,
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in a new issue