mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-26 01:10:39 +00:00
Compare commits
3 commits
54898ba42e
...
069a07214c
Author | SHA1 | Date | |
---|---|---|---|
|
069a07214c | ||
|
fce20c7154 | ||
|
e15d64b10f |
6 changed files with 121 additions and 8 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -60,4 +60,5 @@ ios/Runner/GoogleService-Info.plist
|
||||||
/lib/firebase_options.dart
|
/lib/firebase_options.dart
|
||||||
|
|
||||||
coverage/
|
coverage/
|
||||||
|
test/coverage_helper_test.dart
|
||||||
screenshots/
|
screenshots/
|
|
@ -118,11 +118,7 @@ class _DialogPickerState<T> extends State<DialogPicker<T>> {
|
||||||
),
|
),
|
||||||
const SizedBox(width: Dimens.grid16),
|
const SizedBox(width: Dimens.grid16),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () => widget.onSelect(_selectedValue),
|
||||||
if (widget.initialValue != _selectedValue) {
|
|
||||||
widget.onSelect(_selectedValue);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Text(S.of(context).select),
|
child: Text(S.of(context).select),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -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,
|
||||||
|
);
|
||||||
|
}
|
|
@ -101,7 +101,7 @@ extension WidgetTesterActions on WidgetTester {
|
||||||
);
|
);
|
||||||
expect(cancelButton, findsOneWidget);
|
expect(cancelButton, findsOneWidget);
|
||||||
await tap(cancelButton);
|
await tap(cancelButton);
|
||||||
await pumpAndSettle();
|
await pumpAndSettle(Dimens.durationML);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> tapCancelButton() async {
|
Future<void> tapCancelButton() async {
|
||||||
|
@ -110,6 +110,6 @@ extension WidgetTesterActions on WidgetTester {
|
||||||
);
|
);
|
||||||
expect(cancelButton, findsOneWidget);
|
expect(cancelButton, findsOneWidget);
|
||||||
await tap(cancelButton);
|
await tap(cancelButton);
|
||||||
await pumpAndSettle();
|
await pumpAndSettle(Dimens.durationML);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ void main() {
|
||||||
expect(find.byType(DialogPicker<IsoValue>), findsOneWidget);
|
expect(find.byType(DialogPicker<IsoValue>), findsOneWidget);
|
||||||
await tester.tapListTile(400);
|
await tester.tapListTile(400);
|
||||||
await tester.tapSelectButton();
|
await tester.tapSelectButton();
|
||||||
verifyNever(() => functions.onChanged(const IsoValue(400, StopType.full)));
|
verify(() => functions.onChanged(const IsoValue(400, StopType.full))).called(1);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,4 +1,11 @@
|
||||||
flutter test --coverage
|
flutter test --coverage
|
||||||
|
|
||||||
|
file=test/coverage_helper_test.dart
|
||||||
|
echo "// Helper file to make coverage work for all dart files\n" > $file
|
||||||
|
echo "// ignore_for_file: unused_import, directives_ordering" >> $file
|
||||||
|
find lib '!' -path '*generated*/*' '!' -name '*.g.dart' '!' -name '*.part.dart' -name '*.dart' | cut -c4- | awk -v package=$1 '{printf "import '\''package:lightmeter%s%s'\'';\n", package, $1}' >> $file
|
||||||
|
echo "void main() {}" >> $file
|
||||||
|
|
||||||
lcov --remove coverage/lcov.info 'lib/generated/*' 'lib/l10n/*' -o coverage/new_lcov.info
|
lcov --remove coverage/lcov.info 'lib/generated/*' 'lib/l10n/*' -o coverage/new_lcov.info
|
||||||
genhtml coverage/new_lcov.info -o coverage/html
|
genhtml coverage/new_lcov.info -o coverage/html
|
||||||
open coverage/html/index.html
|
open coverage/html/index.html
|
Loading…
Reference in a new issue