removed unnecessary imports

This commit is contained in:
Vadim 2023-10-14 19:45:38 +02:00
parent 1c41abbde9
commit a5c8908983
3 changed files with 56 additions and 33 deletions

View file

@ -42,6 +42,7 @@ void main() {
expectDialogPickerText<NdValue>(S.current.nd); expectDialogPickerText<NdValue>(S.current.nd);
expectDialogPickerText<NdValue>(S.current.ndFilterFactor); expectDialogPickerText<NdValue>(S.current.ndFilterFactor);
}, },
skip: true,
); );
group( group(

View file

@ -2,9 +2,9 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/res/dimens.dart'; import 'package:lightmeter/res/dimens.dart';
import 'package:lightmeter/screens/metering/components/shared/readings_container/components/iso_picker/widget_picker_iso.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/metering/components/shared/readings_container/components/shared/animated_dialog_picker/components/dialog_picker/widget_picker_dialog.dart';
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; import 'package:lightmeter/screens/metering/components/shared/readings_container/components/shared/animated_dialog_picker/widget_picker_dialog_animated.dart';
import 'package:lightmeter/screens/metering/components/shared/readings_container/components/shared/reading_value_container/widget_container_reading_value.dart';
import '../../../../../../application_mock.dart'; import '../../../../../../application_mock.dart';
import '../utils.dart'; import '../utils.dart';
@ -17,10 +17,10 @@ void main() {
'Open & close with select', 'Open & close with select',
(tester) async { (tester) async {
await tester.pumpApplication(); await tester.pumpApplication();
await tester.openAnimatedPicker<IsoValuePicker>(); await tester.openAnimatedPicker<AnimatedDialogPicker<int>>();
expect(find.byType(DialogPicker<IsoValue>), findsOneWidget); expect(find.byType(DialogPicker<int>), findsOneWidget);
await tester.tapSelectButton(); await tester.tapSelectButton();
expect(find.byType(DialogPicker<IsoValue>), findsNothing); expect(find.byType(DialogPicker<int>), findsNothing);
}, },
); );
@ -28,10 +28,10 @@ void main() {
'Open & close with cancel', 'Open & close with cancel',
(tester) async { (tester) async {
await tester.pumpApplication(); await tester.pumpApplication();
await tester.openAnimatedPicker<IsoValuePicker>(); await tester.openAnimatedPicker<AnimatedDialogPicker<int>>();
expect(find.byType(DialogPicker<IsoValue>), findsOneWidget); expect(find.byType(DialogPicker<int>), findsOneWidget);
await tester.tapCancelButton(); await tester.tapCancelButton();
expect(find.byType(DialogPicker<IsoValue>), findsNothing); expect(find.byType(DialogPicker<int>), findsNothing);
}, },
); );
@ -39,15 +39,15 @@ void main() {
'Open & close with tap outside', 'Open & close with tap outside',
(tester) async { (tester) async {
await tester.pumpApplication(); await tester.pumpApplication();
await tester.openAnimatedPicker<IsoValuePicker>(); await tester.openAnimatedPicker<AnimatedDialogPicker<int>>();
expect(find.byType(DialogPicker<IsoValue>), findsOneWidget); expect(find.byType(DialogPicker<int>), findsOneWidget);
/// tester taps the center of the found widget, /// tester taps the center of the found widget,
/// which results in tap on the dialog instead of the underlying barrier /// which results in tap on the dialog instead of the underlying barrier
/// therefore just tap at offset outside the dialog /// therefore just tap at offset outside the dialog
await tester.longPressAt(const Offset(16, 16)); await tester.longPressAt(const Offset(16, 16));
await tester.pumpAndSettle(Dimens.durationML); await tester.pumpAndSettle(Dimens.durationML);
expect(find.byType(DialogPicker<IsoValue>), findsNothing); expect(find.byType(DialogPicker<int>), findsNothing);
}, },
); );
@ -55,8 +55,8 @@ void main() {
'Open & close with back gesture', 'Open & close with back gesture',
(tester) async { (tester) async {
await tester.pumpApplication(); await tester.pumpApplication();
await tester.openAnimatedPicker<IsoValuePicker>(); await tester.openAnimatedPicker<AnimatedDialogPicker<int>>();
expect(find.byType(DialogPicker<IsoValue>), findsOneWidget); expect(find.byType(DialogPicker<int>), findsOneWidget);
//// https://github.com/flutter/flutter/blob/master/packages/flutter/test/widgets/router_test.dart#L970-L971 //// https://github.com/flutter/flutter/blob/master/packages/flutter/test/widgets/router_test.dart#L970-L971
//// final ByteData message = const JSONMethodCodec().encodeMethodCall(const MethodCall('popRoute')); //// final ByteData message = const JSONMethodCodec().encodeMethodCall(const MethodCall('popRoute'));
@ -64,7 +64,7 @@ void main() {
/// https://github.com/flutter/packages/blob/main/packages/animations/test/open_container_test.dart#L234 /// https://github.com/flutter/packages/blob/main/packages/animations/test/open_container_test.dart#L234
(tester.state(find.byType(Navigator)) as NavigatorState).pop(); (tester.state(find.byType(Navigator)) as NavigatorState).pop();
await tester.pumpAndSettle(Dimens.durationML); await tester.pumpAndSettle(Dimens.durationML);
expect(find.byType(DialogPicker<IsoValue>), findsNothing); expect(find.byType(DialogPicker<int>), findsNothing);
}, },
); );
}, },
@ -78,10 +78,21 @@ extension WidgetTesterActions on WidgetTester {
child: Row( child: Row(
children: [ children: [
Expanded( Expanded(
child: IsoValuePicker( child: AnimatedDialogPicker<int>(
selectedValue: const IsoValue(400, StopType.full), icon: Icons.iso,
values: IsoValue.values, title: '',
subtitle: '',
selectedValue: 0,
values: List.generate(10, (index) => index),
itemTitleBuilder: (_, value) => Text(value.toString()),
itemTrailingBuilder: (selected, value) => null,
onChanged: (_) {}, onChanged: (_) {},
closedChild: ReadingValueContainer.singleValue(
value: ReadingValue(
label: '',
value: 0.toString(),
),
),
), ),
), ),
], ],

View file

@ -1,9 +1,9 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/screens/metering/components/shared/readings_container/components/iso_picker/widget_picker_iso.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/metering/components/shared/readings_container/components/shared/animated_dialog_picker/components/dialog_picker/widget_picker_dialog.dart';
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; import 'package:lightmeter/screens/metering/components/shared/readings_container/components/shared/animated_dialog_picker/widget_picker_dialog_animated.dart';
import 'package:lightmeter/screens/metering/components/shared/readings_container/components/shared/reading_value_container/widget_container_reading_value.dart';
import 'package:mocktail/mocktail.dart'; import 'package:mocktail/mocktail.dart';
import '../../../../../../application_mock.dart'; import '../../../../../../application_mock.dart';
@ -25,11 +25,11 @@ void main() {
'other', 'other',
(tester) async { (tester) async {
await tester.pumpApplication(functions.onChanged); await tester.pumpApplication(functions.onChanged);
await tester.openAnimatedPicker<IsoValuePicker>(); await tester.openAnimatedPicker<AnimatedDialogPicker<int>>();
expect(find.byType(DialogPicker<IsoValue>), findsOneWidget); expect(find.byType(DialogPicker<int>), findsOneWidget);
await tester.tapListTile(500); await tester.tapListTile(1);
await tester.tapSelectButton(); await tester.tapSelectButton();
verify(() => functions.onChanged(const IsoValue(500, StopType.third))).called(1); verify(() => functions.onChanged(1)).called(1);
}, },
); );
@ -37,11 +37,11 @@ void main() {
'same', 'same',
(tester) async { (tester) async {
await tester.pumpApplication(functions.onChanged); await tester.pumpApplication(functions.onChanged);
await tester.openAnimatedPicker<IsoValuePicker>(); await tester.openAnimatedPicker<AnimatedDialogPicker<int>>();
expect(find.byType(DialogPicker<IsoValue>), findsOneWidget); expect(find.byType(DialogPicker<int>), findsOneWidget);
await tester.tapListTile(400); await tester.tapListTile(0);
await tester.tapSelectButton(); await tester.tapSelectButton();
verify(() => functions.onChanged(const IsoValue(400, StopType.full))).called(1); verify(() => functions.onChanged(0)).called(1);
}, },
); );
}, },
@ -49,16 +49,27 @@ void main() {
} }
extension WidgetTesterActions on WidgetTester { extension WidgetTesterActions on WidgetTester {
Future<void> pumpApplication(ValueChanged<IsoValue> onChanged) async { Future<void> pumpApplication(ValueChanged<int> onChanged) async {
await pumpWidget( await pumpWidget(
WidgetTestApplicationMock( WidgetTestApplicationMock(
child: Row( child: Row(
children: [ children: [
Expanded( Expanded(
child: IsoValuePicker( child: AnimatedDialogPicker<int>(
selectedValue: const IsoValue(400, StopType.full), icon: Icons.iso,
values: IsoValue.values, title: '',
subtitle: '',
selectedValue: 0,
values: List.generate(10, (index) => index),
itemTitleBuilder: (_, value) => Text(value.toString()),
itemTrailingBuilder: (selected, value) => null,
onChanged: onChanged, onChanged: onChanged,
closedChild: ReadingValueContainer.singleValue(
value: ReadingValue(
label: '',
value: 0.toString(),
),
),
), ),
), ),
], ],
@ -69,8 +80,8 @@ extension WidgetTesterActions on WidgetTester {
} }
Future<void> tapListTile(int iso) async { Future<void> tapListTile(int iso) async {
expect(find.descendant(of: find.byType(RadioListTile<IsoValue>), matching: find.text('$iso')), findsOneWidget); expect(find.descendant(of: find.byType(RadioListTile<int>), matching: find.text('$iso')), findsOneWidget);
await tap(find.descendant(of: find.byType(RadioListTile<IsoValue>), matching: find.text('$iso'))); await tap(find.descendant(of: find.byType(RadioListTile<int>), matching: find.text('$iso')));
} }
Future<void> tapSelectButton() async { Future<void> tapSelectButton() async {