Commit 4f207a7
Changed files (18)
test
ui
components
settings
test/ui/components/settings/color_picker_list_tile_test.dart
@@ -6,17 +6,17 @@ import 'package:flutter_test/flutter_test.dart';
import '../util.dart';
void main() {
- testWidgets('should initialize without errors', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(ColorSelectionListTile(
+ testWidgets('should initialize without errors', (tester) async {
+ await tester.pumpWidget(materialApp(ColorSelectionListTile(
title: const Text('Test'),
onMainColorChanged: (Color value) {
assert(false, 'should not be called');
},
initialColor: Colors.teal,),),);
- expect(widgetTester.takeException(), isNull);
+ expect(tester.takeException(), isNull);
});
- testWidgets('should preview color', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(ColorSelectionListTile(
+ testWidgets('should preview color', (tester) async {
+ await tester.pumpWidget(materialApp(ColorSelectionListTile(
title: const Text('Test'),
onMainColorChanged: (Color value) {
assert(false, 'should not be called');
@@ -24,11 +24,11 @@ void main() {
initialColor: Colors.teal,),),);
expect(find.byType(CircleAvatar), findsOneWidget);
- expect(widgetTester.widget(find.byType(CircleAvatar)), isA<CircleAvatar>().having(
+ expect(tester.widget(find.byType(CircleAvatar)), isA<CircleAvatar>().having(
(p0) => p0.backgroundColor, 'display color', Colors.teal,),);
});
- testWidgets('should show colorPicker on tap', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(ColorSelectionListTile(
+ testWidgets('should show colorPicker on tap', (tester) async {
+ await tester.pumpWidget(materialApp(ColorSelectionListTile(
title: const Text('Test'),
onMainColorChanged: (Color value) {
assert(false, 'should not be called');
@@ -36,13 +36,13 @@ void main() {
initialColor: Colors.teal,),),);
expect(find.byType(ColorPicker), findsNothing);
- await widgetTester.tap(find.byType(ListTile));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byType(ListTile));
+ await tester.pumpAndSettle();
expect(find.byType(ColorPicker), findsOneWidget);
});
- testWidgets('should notify on color changed', (widgetTester) async {
+ testWidgets('should notify on color changed', (tester) async {
int callCount = 0;
- await widgetTester.pumpWidget(materialApp(ColorSelectionListTile(
+ await tester.pumpWidget(materialApp(ColorSelectionListTile(
title: const Text('Test'),
onMainColorChanged: (Color value) {
callCount += 1;
@@ -51,18 +51,18 @@ void main() {
initialColor: Colors.teal,),),);
expect(find.byType(ColorPicker), findsNothing);
- await widgetTester.tap(find.byType(ListTile));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byType(ListTile));
+ await tester.pumpAndSettle();
expect(find.byType(ColorPicker), findsOneWidget);
- await widgetTester.tap(find.byElementPredicate(findColored(Colors.red)));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byElementPredicate(findColored(Colors.red)));
+ await tester.pumpAndSettle();
expect(find.byType(ColorPicker), findsNothing);
expect(callCount, 1);
});
- testWidgets('should hide color when transparent is selected', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(ColorSelectionListTile(
+ testWidgets('should hide color when transparent is selected', (tester) async {
+ await tester.pumpWidget(materialApp(ColorSelectionListTile(
title: const Text('Test'),
onMainColorChanged: (Color value) {
assert(false, 'should not be called');
test/ui/components/settings/dropdown_list_tile_test.dart
@@ -5,8 +5,8 @@ import 'package:flutter_test/flutter_test.dart';
import '../util.dart';
void main() {
- testWidgets('should not throw errors', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(DropDownListTile<int>(
+ testWidgets('should not throw errors', (tester) async {
+ await tester.pumpWidget(materialApp(DropDownListTile<int>(
title: const Text('test title'),
onChanged: (int? newValue) {
assert(false, 'should not be called');
@@ -17,8 +17,8 @@ void main() {
],
value: 3,
),),);
- expect(widgetTester.takeException(), isNull);
- await widgetTester.pumpWidget(materialApp(DropDownListTile<int>(
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(materialApp(DropDownListTile<int>(
title: const Text('This is a very long test title.'),
subtitle: const Text('This is a very long test subtitle that should go over multiple lines.'),
leading: const Icon(Icons.add),
@@ -31,10 +31,10 @@ void main() {
],
value: 527,
),),);
- expect(widgetTester.takeException(), isNull);
+ expect(tester.takeException(), isNull);
});
- testWidgets('should display selected option', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(DropDownListTile<int>(
+ testWidgets('should display selected option', (tester) async {
+ await tester.pumpWidget(materialApp(DropDownListTile<int>(
title: const Text('test title'),
onChanged: (int? newValue) {
assert(false, 'should not be called');
@@ -48,9 +48,9 @@ void main() {
expect(find.text('option 3'), findsOneWidget);
expect(find.text('option 4'), findsNothing);
});
- testWidgets('should call onChanged on option selected', (widgetTester) async {
+ testWidgets('should call onChanged on option selected', (tester) async {
int callCount = 0;
- await widgetTester.pumpWidget(materialApp(DropDownListTile<int>(
+ await tester.pumpWidget(materialApp(DropDownListTile<int>(
title: const Text('test title'),
onChanged: (int? newValue) {
callCount += 1;
@@ -63,12 +63,12 @@ void main() {
value: 3,
),),);
- await widgetTester.tap(find.text('option 3'));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text('option 3'));
+ await tester.pumpAndSettle();
expect(find.text('option 5'), findsOneWidget);
- await widgetTester.tap(find.text('option 5'));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text('option 5'));
+ await tester.pumpAndSettle();
expect(callCount, 1);
});
test/ui/components/settings/input_list_tile_test.dart
@@ -6,20 +6,20 @@ import 'package:flutter_test/flutter_test.dart';
import '../util.dart';
void main() {
- testWidgets('should show fields', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(InputListTile(
+ testWidgets('should show fields', (tester) async {
+ await tester.pumpWidget(materialApp(InputListTile(
label: 'test title',
value: 'initial',
onSubmit: (String newValue) {
assert(false, 'should not be called');
},
),),);
- expect(widgetTester.takeException(), isNull);
+ expect(tester.takeException(), isNull);
expect(find.text('test title'), findsOneWidget);
expect(find.text('initial'), findsOneWidget);
});
- testWidgets('should allow canceling edit', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(InputListTile(
+ testWidgets('should allow canceling edit', (tester) async {
+ await tester.pumpWidget(materialApp(InputListTile(
label: 'test title',
value: 'initial',
onSubmit: (String newValue) {
@@ -28,17 +28,17 @@ void main() {
),),);
expect(find.byType(InputDialoge), findsNothing);
- await widgetTester.tap(find.byType(InputListTile));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byType(InputListTile));
+ await tester.pumpAndSettle();
expect(find.byType(InputDialoge), findsOneWidget);
- await widgetTester.tapAt(const Offset(0, 0));
- await widgetTester.pumpAndSettle();
+ await tester.tapAt(const Offset(0, 0));
+ await tester.pumpAndSettle();
expect(find.byType(InputDialoge), findsNothing);
});
- testWidgets('should prefill value on edit', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(InputListTile(
+ testWidgets('should prefill value on edit', (tester) async {
+ await tester.pumpWidget(materialApp(InputListTile(
label: 'test title',
value: 'initial',
onSubmit: (String newValue) {
@@ -47,14 +47,14 @@ void main() {
),),);
expect(find.text('initial'), findsOneWidget);
- await widgetTester.tap(find.byType(InputListTile));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byType(InputListTile));
+ await tester.pumpAndSettle();
expect(find.text('initial'), findsNWidgets(2));
});
- testWidgets('should allow editing values', (widgetTester) async {
+ testWidgets('should allow editing values', (tester) async {
int callCount = 0;
- await widgetTester.pumpWidget(materialApp(InputListTile(
+ await tester.pumpWidget(materialApp(InputListTile(
label: 'test title',
value: 'initial',
onSubmit: (String newValue) {
@@ -64,13 +64,13 @@ void main() {
),),);
expect(find.text('initial'), findsOneWidget);
- await widgetTester.tap(find.byType(InputListTile));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byType(InputListTile));
+ await tester.pumpAndSettle();
expect(find.byType(TextField), findsOneWidget);
- await widgetTester.enterText(find.byType(TextField), 'changed');
- await widgetTester.tap(find.text('OK'));
- await widgetTester.pumpAndSettle();
+ await tester.enterText(find.byType(TextField), 'changed');
+ await tester.tap(find.text('OK'));
+ await tester.pumpAndSettle();
expect(find.byType(InputDialoge), findsNothing);
expect(callCount, 1);
test/ui/components/settings/number_input_list_tile_test.dart
@@ -6,20 +6,20 @@ import 'package:flutter_test/flutter_test.dart';
import '../util.dart';
void main() {
- testWidgets('should show fields', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(NumberInputListTile(
+ testWidgets('should show fields', (tester) async {
+ await tester.pumpWidget(materialApp(NumberInputListTile(
label: 'test title',
value: 15,
onParsableSubmit: (double newValue) {
assert(false, 'should not be called');
},
),),);
- expect(widgetTester.takeException(), isNull);
+ expect(tester.takeException(), isNull);
expect(find.text('test title'), findsOneWidget);
expect(find.text('15'), findsOneWidget);
});
- testWidgets('should allow canceling edit', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(NumberInputListTile(
+ testWidgets('should allow canceling edit', (tester) async {
+ await tester.pumpWidget(materialApp(NumberInputListTile(
label: 'test title',
value: 15,
onParsableSubmit: (double newValue) {
@@ -28,17 +28,17 @@ void main() {
),),);
expect(find.byType(InputDialoge), findsNothing);
- await widgetTester.tap(find.byType(NumberInputListTile));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byType(NumberInputListTile));
+ await tester.pumpAndSettle();
expect(find.byType(InputDialoge), findsOneWidget);
- await widgetTester.tapAt(const Offset(0, 0));
- await widgetTester.pumpAndSettle();
+ await tester.tapAt(const Offset(0, 0));
+ await tester.pumpAndSettle();
expect(find.byType(InputDialoge), findsNothing);
});
- testWidgets('should prefill value on edit', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(NumberInputListTile(
+ testWidgets('should prefill value on edit', (tester) async {
+ await tester.pumpWidget(materialApp(NumberInputListTile(
label: 'test title',
value: 15,
onParsableSubmit: (double newValue) {
@@ -47,14 +47,14 @@ void main() {
),),);
expect(find.text('15'), findsOneWidget);
- await widgetTester.tap(find.byType(NumberInputListTile));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byType(NumberInputListTile));
+ await tester.pumpAndSettle();
expect(find.text('15'), findsNWidgets(2));
});
- testWidgets('should allow editing values', (widgetTester) async {
+ testWidgets('should allow editing values', (tester) async {
int callCount = 0;
- await widgetTester.pumpWidget(materialApp(NumberInputListTile(
+ await tester.pumpWidget(materialApp(NumberInputListTile(
label: 'test title',
value: 15,
onParsableSubmit: (double newValue) {
@@ -77,33 +77,33 @@ void main() {
),),);
expect(find.text('15'), findsOneWidget);
- await widgetTester.tap(find.byType(NumberInputListTile));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byType(NumberInputListTile));
+ await tester.pumpAndSettle();
expect(find.byType(TextField), findsOneWidget);
- await widgetTester.enterText(find.byType(TextField), '17');
- await widgetTester.tap(find.text('OK'));
- await widgetTester.pumpAndSettle();
+ await tester.enterText(find.byType(TextField), '17');
+ await tester.tap(find.text('OK'));
+ await tester.pumpAndSettle();
- await widgetTester.tap(find.byType(NumberInputListTile));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byType(NumberInputListTile));
+ await tester.pumpAndSettle();
expect(find.byType(TextField), findsOneWidget);
- await widgetTester.enterText(find.byType(TextField), '15.0');
- await widgetTester.tap(find.text('OK'));
- await widgetTester.pumpAndSettle();
+ await tester.enterText(find.byType(TextField), '15.0');
+ await tester.tap(find.text('OK'));
+ await tester.pumpAndSettle();
- await widgetTester.tap(find.byType(NumberInputListTile));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byType(NumberInputListTile));
+ await tester.pumpAndSettle();
expect(find.byType(TextField), findsOneWidget);
- await widgetTester.enterText(find.byType(TextField), '0.123');
- await widgetTester.tap(find.text('OK'));
- await widgetTester.pumpAndSettle();
+ await tester.enterText(find.byType(TextField), '0.123');
+ await tester.tap(find.text('OK'));
+ await tester.pumpAndSettle();
- await widgetTester.tap(find.byType(NumberInputListTile));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byType(NumberInputListTile));
+ await tester.pumpAndSettle();
expect(find.byType(TextField), findsOneWidget);
- await widgetTester.enterText(find.byType(TextField), '5.4');
- await widgetTester.tap(find.text('OK'));
- await widgetTester.pumpAndSettle();
+ await tester.enterText(find.byType(TextField), '5.4');
+ await tester.tap(find.text('OK'));
+ await tester.pumpAndSettle();
expect(find.byType(InputDialoge), findsNothing);
expect(callCount, 4);
test/ui/components/settings/slider_list_tile_test.dart
@@ -5,8 +5,8 @@ import 'package:flutter_test/flutter_test.dart';
import '../util.dart';
void main() {
- testWidgets('should not throw errors', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(SliderListTile(
+ testWidgets('should not throw errors', (tester) async {
+ await tester.pumpWidget(materialApp(SliderListTile(
title: const Text('test title'),
onChanged: (double newValue) {
assert(false, 'should not be called');
@@ -15,8 +15,8 @@ void main() {
min: 1,
max: 20,
),),);
- expect(widgetTester.takeException(), isNull);
- await widgetTester.pumpWidget(materialApp(SliderListTile(
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(materialApp(SliderListTile(
title: const Text('Very long title that could overflow'),
onChanged: (double newValue) {
assert(false, 'should not be called');
@@ -29,11 +29,11 @@ void main() {
trailing: const Icon(Icons.add),
subtitle: const Text('While sliders support subtitle widgets, they should not interfere with the slider!'),
),),);
- expect(widgetTester.takeException(), isNull);
+ expect(tester.takeException(), isNull);
});
- testWidgets('should report value changes', (widgetTester) async {
+ testWidgets('should report value changes', (tester) async {
int callCount = 0;
- await widgetTester.pumpWidget(materialApp(SliderListTile(
+ await tester.pumpWidget(materialApp(SliderListTile(
title: const Text('title'),
onChanged: (double newValue) {
callCount += 1;
@@ -45,12 +45,12 @@ void main() {
subtitle: const Text('While sliders support subtitle widgets, they should not interfere with the slider!'),
),),);
- final topLeft = widgetTester.getTopLeft(find.byType(Slider));
- final bottomRight = widgetTester.getBottomRight(find.byType(Slider));
+ final topLeft = tester.getTopLeft(find.byType(Slider));
+ final bottomRight = tester.getBottomRight(find.byType(Slider));
final slider8Position = topLeft + ((bottomRight - topLeft) * 8 / 10);
- await widgetTester.tapAt(slider8Position);
- await widgetTester.pumpAndSettle();
+ await tester.tapAt(slider8Position);
+ await tester.pumpAndSettle();
expect(callCount, 1);
});
}
test/ui/components/settings/titled_column_test.dart
@@ -5,8 +5,8 @@ import 'package:flutter_test/flutter_test.dart';
import '../util.dart';
void main() {
- testWidgets('should show title and widgets', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(TitledColumn(
+ testWidgets('should show title and widgets', (tester) async {
+ await tester.pumpWidget(materialApp(TitledColumn(
title: const Text('test title'),
children: [
const ListTile(title: Text('ListTile text 1'),),
@@ -16,15 +16,15 @@ void main() {
const ListTile(title: Text('ListTile text 2'),),
],
),),);
- expect(widgetTester.takeException(), isNull);
+ expect(tester.takeException(), isNull);
expect(find.text('test title'), findsOneWidget);
expect(find.text('ListTile text 1'), findsOneWidget);
expect(find.text('SwitchListTile text'), findsOneWidget);
expect(find.text('ListTile text 2'), findsOneWidget);
});
- testWidgets('should show title first', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(TitledColumn(
+ testWidgets('should show title first', (tester) async {
+ await tester.pumpWidget(materialApp(TitledColumn(
title: const Text('test title'),
children: [
const ListTile(title: Text('ListTile text 1'),),
test/ui/components/statistics/blood_pressure_distribution_test.dart
@@ -9,8 +9,8 @@ import '../../../model/export_import/record_formatter_test.dart';
import '../util.dart';
void main() {
- testWidgets('should show allow navigation to view all widgets', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(BloodPressureDistribution(
+ testWidgets('should show allow navigation to view all widgets', (tester) async {
+ await tester.pumpWidget(materialApp(BloodPressureDistribution(
records: const [],
settings: Settings(),
),),);
@@ -25,20 +25,20 @@ void main() {
expect(find.byKey(const Key('dia-dist')), findsNothing);
expect(find.byKey(const Key('pul-dist')), findsNothing);
- await widgetTester.tap(find.text(localizations.diaLong));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text(localizations.diaLong));
+ await tester.pumpAndSettle();
expect(find.byKey(const Key('sys-dist')), findsNothing);
expect(find.byKey(const Key('dia-dist')), findsOneWidget);
expect(find.byKey(const Key('pul-dist')), findsNothing);
- await widgetTester.tap(find.text(localizations.pulLong));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text(localizations.pulLong));
+ await tester.pumpAndSettle();
expect(find.byKey(const Key('sys-dist')), findsNothing);
expect(find.byKey(const Key('dia-dist')), findsNothing);
expect(find.byKey(const Key('pul-dist')), findsOneWidget);
});
- testWidgets('should report records to ValueDistribution', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(BloodPressureDistribution(
+ testWidgets('should report records to ValueDistribution', (tester) async {
+ await tester.pumpWidget(materialApp(BloodPressureDistribution(
records: [
mockRecord(sys: 123),
mockRecord(dia: 123),
@@ -56,23 +56,23 @@ void main() {
final localizations = await AppLocalizations.delegate.load(const Locale('en'));
- await widgetTester.tap(find.text(localizations.sysLong));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text(localizations.sysLong));
+ await tester.pumpAndSettle();
expect(find.byType(ValueDistribution), paints
..line(color: Colors.red.shade500)
..line(color: Colors.white70),
);
- await widgetTester.tap(find.text(localizations.diaLong));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text(localizations.diaLong));
+ await tester.pumpAndSettle();
expect(find.byType(ValueDistribution), paints
..line(color: Colors.green.shade500)
..line(color: Colors.green.shade500)
..line(color: Colors.white70),
);
- await widgetTester.tap(find.text(localizations.pulLong));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text(localizations.pulLong));
+ await tester.pumpAndSettle();
expect(find.byType(ValueDistribution), paints
..line(color: Colors.blue.shade500)
..line(color: Colors.blue.shade500)
test/ui/components/statistics/value_distribution_test.dart
@@ -8,8 +8,8 @@ import 'package:flutter_test/flutter_test.dart';
import '../util.dart';
void main() {
- testWidgets('should show centered info when values are empty', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(const ValueDistribution(
+ testWidgets('should show centered info when values are empty', (tester) async {
+ await tester.pumpWidget(materialApp(const ValueDistribution(
color: Colors.red,
values: [],
),),);
@@ -18,13 +18,13 @@ void main() {
expect(find.byType(Text), findsOneWidget);
expect(find.text(localizations.errNoData), findsOneWidget);
- final errorCenter = widgetTester.getCenter(find.byType(Text));
- final canvasCenter = widgetTester.getCenter(find.byType(MaterialApp));
+ final errorCenter = tester.getCenter(find.byType(Text));
+ final canvasCenter = tester.getCenter(find.byType(MaterialApp));
expect(errorCenter, equals(canvasCenter));
},);
- testWidgets('should draw labels at correct positions', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(const SizedBox(
+ testWidgets('should draw labels at correct positions', (tester) async {
+ await tester.pumpWidget(materialApp(const SizedBox(
height: 50,
width: 180,
child: ValueDistribution(
@@ -44,8 +44,8 @@ void main() {
);
},);
- testWidgets('should correct amount of value bars', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(const SizedBox(
+ testWidgets('should correct amount of value bars', (tester) async {
+ await tester.pumpWidget(materialApp(const SizedBox(
height: 50,
width: 180,
child: ValueDistribution(
@@ -64,8 +64,8 @@ void main() {
..line(color: Colors.white70) // start drawing decoration
,);
},);
- testWidgets('should have semantics labels with correct values', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(const SizedBox(
+ testWidgets('should have semantics labels with correct values', (tester) async {
+ await tester.pumpWidget(materialApp(const SizedBox(
height: 50,
width: 180,
child: ValueDistribution(
@@ -75,7 +75,7 @@ void main() {
),),);
final localizations = await AppLocalizations.delegate.load(const Locale('en'));
- final labels = _getAllLabels(widgetTester.getSemantics(find.byType(ValueDistribution)));
+ final labels = _getAllLabels(tester.getSemantics(find.byType(ValueDistribution)));
expect(labels, contains(localizations.minOf('3')));
expect(labels, contains(localizations.maxOf('10')));
test/ui/components/add_export_column_dialoge_test.dart
@@ -11,9 +11,9 @@ import 'util.dart';
void main() {
group('AddExportColumnDialoge', () {
- testWidgets('should show everything on load', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(AddExportColumnDialoge(settings: Settings(),)));
- expect(widgetTester.takeException(), isNull);
+ testWidgets('should show everything on load', (tester) async {
+ await tester.pumpWidget(materialApp(AddExportColumnDialoge(settings: Settings(),)));
+ expect(tester.takeException(), isNull);
expect(find.text('SAVE'), findsOneWidget);
expect(find.byIcon(Icons.close), findsOneWidget);
@@ -25,11 +25,11 @@ void main() {
expect(find.byIcon(Icons.info_outline).hitTestable(), findsOneWidget);
expect(find.byIcon(Icons.arrow_downward), findsNWidgets(2));
});
- testWidgets('should prefill values', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(
+ testWidgets('should prefill values', (tester) async {
+ await tester.pumpWidget(materialApp(
AddExportColumnDialoge(initialColumn: UserColumn('id', 'csvTitle', r'formatPattern$SYS'), settings: Settings(),),
),);
- expect(widgetTester.takeException(), isNull);
+ expect(tester.takeException(), isNull);
expect(find.text('SAVE'), findsOneWidget);
expect(find.byIcon(Icons.close), findsOneWidget);
@@ -41,50 +41,50 @@ void main() {
expect(find.byIcon(Icons.info_outline).hitTestable(), findsOneWidget);
expect(find.byIcon(Icons.arrow_downward), findsNWidgets(2));
});
- testWidgets('should show preview', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(
+ testWidgets('should show preview', (tester) async {
+ await tester.pumpWidget(materialApp(
AddExportColumnDialoge(initialColumn: UserColumn('id', 'csvTitle', r'formatPattern$SYS'), settings: Settings(),),
),);
- await widgetTester.pumpAndSettle();
+ await tester.pumpAndSettle();
expect(find.text('Please enter a value'), findsNothing);
expect(find.text('null'), findsNothing);
expect(find.textContaining('formatPattern'), findsNWidgets(2));
expect(find.textContaining('RowDataFieldType.sys'), findsOneWidget);
});
- testWidgets('should open format Info screen', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(AddExportColumnDialoge(settings: Settings(),)));
+ testWidgets('should open format Info screen', (tester) async {
+ await tester.pumpWidget(materialApp(AddExportColumnDialoge(settings: Settings(),)));
expect(find.byType(InformationScreen), findsNothing);
expect(find.byIcon(Icons.info_outline).hitTestable(), findsOneWidget);
- await widgetTester.tap(find.byIcon(Icons.info_outline).hitTestable(),);
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byIcon(Icons.info_outline).hitTestable(),);
+ await tester.pumpAndSettle();
expect(find.byType(InformationScreen), findsOneWidget);
});
});
group('showAddExportColumnDialoge', () {
- testWidgets('should open AddExportColumnDialoge', (widgetTester) async {
- await loadDialoge(widgetTester, (context) => showAddExportColumnDialoge(context, Settings()));
+ testWidgets('should open AddExportColumnDialoge', (tester) async {
+ await loadDialoge(tester, (context) => showAddExportColumnDialoge(context, Settings()));
expect(find.byType(AddExportColumnDialoge), findsOneWidget);
});
- testWidgets('should return null on cancel', (widgetTester) async {
+ testWidgets('should return null on cancel', (tester) async {
dynamic returnedValue = false;
- await loadDialoge(widgetTester, (context) async => returnedValue = await showAddExportColumnDialoge(context, Settings()));
+ await loadDialoge(tester, (context) async => returnedValue = await showAddExportColumnDialoge(context, Settings()));
expect(returnedValue, false);
expect(find.byIcon(Icons.close), findsOneWidget);
- await widgetTester.tap(find.byIcon(Icons.close));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byIcon(Icons.close));
+ await tester.pumpAndSettle();
expect(find.byType(AddExportColumnDialoge), findsNothing);
expect(returnedValue, null);
});
- testWidgets('should save entered values', (widgetTester) async {
+ testWidgets('should save entered values', (tester) async {
dynamic returnedValue = false;
- await loadDialoge(widgetTester, (context) async => returnedValue = await showAddExportColumnDialoge(context, Settings()));
+ await loadDialoge(tester, (context) async => returnedValue = await showAddExportColumnDialoge(context, Settings()));
final localizations = await AppLocalizations.delegate.load(const Locale('en'));
@@ -92,30 +92,30 @@ void main() {
expect(find.ancestor(of: find.text(localizations.csvTitle).first, matching: find.byType(TextFormField)),
findsAtLeastNWidgets(1),);
- await widgetTester.enterText(
+ await tester.enterText(
find.ancestor(of: find.text(localizations.csvTitle).first, matching: find.byType(TextFormField)),
'testCsvTitle',);
expect(find.ancestor(of: find.text(localizations.csvTitle).first, matching: find.byType(TextFormField)),
findsAtLeastNWidgets(1),);
- await widgetTester.enterText(
+ await tester.enterText(
find.ancestor(of: find.text(localizations.fieldFormat).first, matching: find.byType(TextFormField)),
r'test$SYSformat',);
expect(find.text(localizations.btnSave), findsOneWidget);
- await widgetTester.tap(find.text(localizations.btnSave));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text(localizations.btnSave));
+ await tester.pumpAndSettle();
expect(find.byType(AddExportColumnDialoge), findsNothing);
expect(returnedValue, isA<UserColumn>()
.having((p0) => p0.csvTitle, 'csvTitle', 'testCsvTitle')
.having((p0) => p0.formatter.formatPattern, 'formatter', r'test$SYSformat'),);
});
- testWidgets('should keep internalIdentifier on edit', (widgetTester) async {
+ testWidgets('should keep internalIdentifier on edit', (tester) async {
final localizations = await AppLocalizations.delegate.load(const Locale('en'));
dynamic returnedValue = false;
- await loadDialoge(widgetTester, (context) async => returnedValue =
+ await loadDialoge(tester, (context) async => returnedValue =
await showAddExportColumnDialoge(context, Settings(),
UserColumn('initialInternalIdentifier', 'csvTitle', 'formatPattern'),
),);
@@ -124,13 +124,13 @@ void main() {
expect(find.ancestor(of: find.text(localizations.csvTitle).first, matching: find.byType(TextFormField)),
findsAtLeastNWidgets(1),);
- await widgetTester.enterText(
+ await tester.enterText(
find.ancestor(of: find.text(localizations.csvTitle).first, matching: find.byType(TextFormField)),
'changedCsvTitle',);
expect(find.text(localizations.btnSave), findsOneWidget);
- await widgetTester.tap(find.text(localizations.btnSave));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text(localizations.btnSave));
+ await tester.pumpAndSettle();
expect(find.byType(AddExportColumnDialoge), findsNothing);
expect(returnedValue, isA<UserColumn>()
test/ui/components/add_measurement_dialoge_test.dart
@@ -17,13 +17,13 @@ import 'util.dart';
void main() {
group('AddEntryDialoge', () {
- testWidgets('should show everything on initial page', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(
+ testWidgets('should show everything on initial page', (tester) async {
+ await tester.pumpWidget(materialApp(
AddEntryDialoge(
settings: Settings(),
),
),);
- expect(widgetTester.takeException(), isNull);
+ expect(tester.takeException(), isNull);
expect(find.byType(DropdownButton<Medicine?>), findsNothing, reason: 'No medication in settings.');
expect(find.text('SAVE'), findsOneWidget);
@@ -33,8 +33,8 @@ void main() {
expect(find.text('Pulse'), findsWidgets);
expect(find.byType(ColorSelectionListTile), findsOneWidget);
});
- testWidgets('should prefill initialRecord values', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(
+ testWidgets('should prefill initialRecord values', (tester) async {
+ await tester.pumpWidget(materialApp(
AddEntryDialoge(
settings: Settings(),
initialRecord: BloodPressureRecord(
@@ -43,7 +43,7 @@ void main() {
),
),
),);
- await widgetTester.pumpAndSettle();
+ await tester.pumpAndSettle();
expect(find.byType(DropdownButton<Medicine?>), findsNothing, reason: 'No medication in settings.');
expect(find.text('SAVE'), findsOneWidget);
expect(find.byIcon(Icons.close), findsOneWidget);
@@ -55,48 +55,48 @@ void main() {
expect(find.byType(ColorSelectionListTile).evaluate().first.widget, isA<ColorSelectionListTile>().
having((p0) => p0.initialColor, 'ColorSelectionListTile should have correct initial color', Colors.teal),);
});
- testWidgets('should show medication picker when medications available', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(
+ testWidgets('should show medication picker when medications available', (tester) async {
+ await tester.pumpWidget(materialApp(
AddEntryDialoge(
settings: Settings(
medications: [mockMedicine(designation: 'testmed')],
),
),
),);
- await widgetTester.pumpAndSettle();
+ await tester.pumpAndSettle();
final localizations = await AppLocalizations.delegate.load(const Locale('en'));
expect(find.byType(DropdownButton<Medicine?>), findsOneWidget);
expect(find.text(localizations.noMedication), findsOneWidget);
expect(find.text('testmed'), findsNothing);
- await widgetTester.tap(find.byType(DropdownButton<Medicine?>));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byType(DropdownButton<Medicine?>));
+ await tester.pumpAndSettle();
expect(find.text('testmed'), findsOneWidget);
});
- testWidgets('should reveal dosis on medication selection', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(
+ testWidgets('should reveal dosis on medication selection', (tester) async {
+ await tester.pumpWidget(materialApp(
AddEntryDialoge(
settings: Settings(
medications: [mockMedicine(designation: 'testmed')],
),
),
),);
- await widgetTester.pumpAndSettle();
+ await tester.pumpAndSettle();
final localizations = await AppLocalizations.delegate.load(const Locale('en'));
expect(find.byType(DropdownButton<Medicine?>), findsOneWidget);
expect(find.text(localizations.noMedication), findsOneWidget);
expect(find.text('testmed'), findsNothing);
- await widgetTester.tap(find.byType(DropdownButton<Medicine?>));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byType(DropdownButton<Medicine?>));
+ await tester.pumpAndSettle();
expect(find.text(localizations.dosis), findsNothing);
expect(find.text('testmed'), findsOneWidget);
- await widgetTester.tap(find.text('testmed'));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text('testmed'));
+ await tester.pumpAndSettle();
expect(
find.ancestor(
@@ -106,81 +106,81 @@ void main() {
findsOneWidget,
);
});
- testWidgets('should enter default dosis if available', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(
+ testWidgets('should enter default dosis if available', (tester) async {
+ await tester.pumpWidget(materialApp(
AddEntryDialoge(
settings: Settings(
medications: [mockMedicine(designation: 'testmed', defaultDosis: 3.1415)],
),
),
),);
- await widgetTester.pumpAndSettle();
+ await tester.pumpAndSettle();
- await widgetTester.tap(find.byType(DropdownButton<Medicine?>));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byType(DropdownButton<Medicine?>));
+ await tester.pumpAndSettle();
- await widgetTester.tap(find.text('testmed'));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text('testmed'));
+ await tester.pumpAndSettle();
expect(find.text('3.1415'), findsOneWidget);
});
- testWidgets('should not quit when the measurement field is incorrectly filled, but a measurement is added', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(
+ testWidgets('should not quit when the measurement field is incorrectly filled, but a measurement is added', (tester) async {
+ await tester.pumpWidget(materialApp(
AddEntryDialoge(
settings: Settings(
medications: [mockMedicine(designation: 'testmed', defaultDosis: 3.1415)],
),
),
),);
- await widgetTester.pumpAndSettle();
+ await tester.pumpAndSettle();
- await widgetTester.tap(find.byType(DropdownButton<Medicine?>));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byType(DropdownButton<Medicine?>));
+ await tester.pumpAndSettle();
- await widgetTester.tap(find.text('testmed'));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text('testmed'));
+ await tester.pumpAndSettle();
- await widgetTester.enterText(find.ancestor(of: find.text('Systolic').first, matching: find.byType(TextFormField)), '123');
- await widgetTester.enterText(find.ancestor(of: find.text('Diastolic').first, matching: find.byType(TextFormField)), '900');
- await widgetTester.enterText(find.ancestor(of: find.text('Pulse').first, matching: find.byType(TextFormField)), '89');
- await widgetTester.pumpAndSettle();
+ await tester.enterText(find.ancestor(of: find.text('Systolic').first, matching: find.byType(TextFormField)), '123');
+ await tester.enterText(find.ancestor(of: find.text('Diastolic').first, matching: find.byType(TextFormField)), '900');
+ await tester.enterText(find.ancestor(of: find.text('Pulse').first, matching: find.byType(TextFormField)), '89');
+ await tester.pumpAndSettle();
final localizations = await AppLocalizations.delegate.load(const Locale('en'));
expect(find.byType(AddEntryDialoge), findsOneWidget);
expect(find.text(localizations.errUnrealistic), findsNothing);
- await widgetTester.tap(find.text(localizations.btnSave));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text(localizations.btnSave));
+ await tester.pumpAndSettle();
expect(find.byType(AddEntryDialoge), findsOneWidget);
expect(find.text(localizations.errUnrealistic), findsOneWidget);
});
});
group('showAddEntryDialoge', () {
- testWidgets('should return null on cancel', (widgetTester) async {
+ testWidgets('should return null on cancel', (tester) async {
dynamic result = 'result before save';
- await loadDialoge(widgetTester, (context) async
+ await loadDialoge(tester, (context) async
=> result = await showAddEntryDialoge(context, Settings(),
mockRecord(sys: 123, dia: 56, pul: 43, note: 'Test note', pin: Colors.teal),),);
expect(find.byType(DropdownButton<Medicine?>), findsNothing, reason: 'No medication in settings.');
expect(find.byType(AddEntryDialoge), findsOneWidget);
- await widgetTester.tap(find.byIcon(Icons.close));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byIcon(Icons.close));
+ await tester.pumpAndSettle();
expect(find.byType(AddEntryDialoge), findsNothing);
expect(result, null);
});
- testWidgets('should return values on edit cancel', (widgetTester) async {
+ testWidgets('should return values on edit cancel', (tester) async {
dynamic result = 'result before save';
final record = mockRecord(sys: 123, dia: 56, pul: 43, note: 'Test note', pin: Colors.teal);
- await loadDialoge(widgetTester, (context) async
+ await loadDialoge(tester, (context) async
=> result = await showAddEntryDialoge(context, Settings(), record),);
expect(find.byType(DropdownButton<Medicine?>), findsNothing, reason: 'No medication in settings.');
expect(find.byType(AddEntryDialoge), findsOneWidget);
- await widgetTester.tap(find.text('SAVE'));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text('SAVE'));
+ await tester.pumpAndSettle();
expect(find.byType(AddEntryDialoge), findsNothing);
expect(result?.$2, isNull);
@@ -189,25 +189,25 @@ void main() {
'should return initial values as they were not modified',
(record.creationTime, record.systolic, record.diastolic, record.pulse, record.notes, record.needlePin!.color),),);
});
- testWidgets('should be able to input records', (WidgetTester widgetTester) async {
+ testWidgets('should be able to input records', (WidgetTester tester) async {
dynamic result = 'result before save';
- await loadDialoge(widgetTester, (context) async
+ await loadDialoge(tester, (context) async
=> result = await showAddEntryDialoge(context, Settings()),);
expect(find.byType(DropdownButton<Medicine?>), findsNothing, reason: 'No medication in settings.');
- await widgetTester.enterText(find.ancestor(of: find.text('Systolic').first, matching: find.byType(TextFormField)), '123');
- await widgetTester.enterText(find.ancestor(of: find.text('Diastolic').first, matching: find.byType(TextFormField)), '67');
- await widgetTester.enterText(find.ancestor(of: find.text('Pulse').first, matching: find.byType(TextFormField)), '89');
- await widgetTester.enterText(find.ancestor(of: find.text('Note (optional)').first, matching: find.byType(TextFormField)), 'Test note');
+ await tester.enterText(find.ancestor(of: find.text('Systolic').first, matching: find.byType(TextFormField)), '123');
+ await tester.enterText(find.ancestor(of: find.text('Diastolic').first, matching: find.byType(TextFormField)), '67');
+ await tester.enterText(find.ancestor(of: find.text('Pulse').first, matching: find.byType(TextFormField)), '89');
+ await tester.enterText(find.ancestor(of: find.text('Note (optional)').first, matching: find.byType(TextFormField)), 'Test note');
- await widgetTester.tap(find.byType(ColorSelectionListTile));
- await widgetTester.pumpAndSettle();
- await widgetTester.tap(find.byElementPredicate(findColored(Colors.red)));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byType(ColorSelectionListTile));
+ await tester.pumpAndSettle();
+ await tester.tap(find.byElementPredicate(findColored(Colors.red)));
+ await tester.pumpAndSettle();
expect(find.text('SAVE'), findsOneWidget);
- await widgetTester.tap(find.text('SAVE'));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text('SAVE'));
+ await tester.pumpAndSettle();
expect(result?.$2, isNull);
expect(result?.$1, isA<BloodPressureRecord>()
@@ -218,23 +218,23 @@ void main() {
.having((p0) => p0.needlePin?.color, 'needlePin', Colors.red),
);
});
- testWidgets('should allow value only', (WidgetTester widgetTester) async {
+ testWidgets('should allow value only', (WidgetTester tester) async {
dynamic result = 'result before save';
- await loadDialoge(widgetTester, (context) async
+ await loadDialoge(tester, (context) async
=> result = await showAddEntryDialoge(context, Settings()),);
expect(find.byType(DropdownButton<Medicine?>), findsNothing, reason: 'No medication in settings.');
final localizations = await AppLocalizations.delegate.load(const Locale('en'));
- await widgetTester.enterText(find.ancestor(of: find.text(localizations.sysLong).first,
+ await tester.enterText(find.ancestor(of: find.text(localizations.sysLong).first,
matching: find.byType(TextFormField),), '123',);
- await widgetTester.enterText(find.ancestor(of: find.text(localizations.diaLong).first,
+ await tester.enterText(find.ancestor(of: find.text(localizations.diaLong).first,
matching: find.byType(TextFormField),), '67',);
- await widgetTester.enterText(find.ancestor(of: find.text(localizations.pulLong).first,
+ await tester.enterText(find.ancestor(of: find.text(localizations.pulLong).first,
matching: find.byType(TextFormField),), '89',);
expect(find.text(localizations.btnSave), findsOneWidget);
- await widgetTester.tap(find.text(localizations.btnSave));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text(localizations.btnSave));
+ await tester.pumpAndSettle();
expect(result?.$2, isNull);
expect(result?.$1, isA<BloodPressureRecord>()
@@ -245,9 +245,9 @@ void main() {
.having((p0) => p0.needlePin?.color, 'needlePin', null),
);
});
- testWidgets('should allow note only', (WidgetTester widgetTester) async {
+ testWidgets('should allow note only', (WidgetTester tester) async {
dynamic result = 'result before save';
- await loadDialoge(widgetTester, (context) async
+ await loadDialoge(tester, (context) async
=> result = await showAddEntryDialoge(context, Settings(
allowMissingValues: true,
validateInputs: false,
@@ -255,12 +255,12 @@ void main() {
expect(find.byType(DropdownButton<Medicine?>), findsNothing, reason: 'No medication in settings.');
final localizations = await AppLocalizations.delegate.load(const Locale('en'));
- await widgetTester.enterText(find.ancestor(of: find.text(localizations.addNote).first,
+ await tester.enterText(find.ancestor(of: find.text(localizations.addNote).first,
matching: find.byType(TextFormField),), 'test note',);
expect(find.text(localizations.btnSave), findsOneWidget);
- await widgetTester.tap(find.text(localizations.btnSave));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text(localizations.btnSave));
+ await tester.pumpAndSettle();
expect(result?.$2, isNull);
expect(result?.$1, isA<BloodPressureRecord>()
@@ -271,11 +271,11 @@ void main() {
.having((p0) => p0.needlePin?.color, 'needlePin', null),
);
});
- testWidgets('should be able to input medicines', (WidgetTester widgetTester) async {
+ testWidgets('should be able to input medicines', (WidgetTester tester) async {
final med2 = mockMedicine(designation: 'medication2', defaultDosis: 31.415);
dynamic result = 'result before save';
- await loadDialoge(widgetTester, (context) async
+ await loadDialoge(tester, (context) async
=> result = await showAddEntryDialoge(context, Settings(
medications: [
mockMedicine(designation: 'medication1'),
@@ -284,16 +284,16 @@ void main() {
),),);
final localizations = await AppLocalizations.delegate.load(const Locale('en'));
- await widgetTester.tap(find.byType(DropdownButton<Medicine?>));
+ await tester.tap(find.byType(DropdownButton<Medicine?>));
final openDialogeTimeStamp = DateTime.now();
- await widgetTester.pumpAndSettle();
+ await tester.pumpAndSettle();
expect(find.text('medication1'), findsOneWidget);
expect(find.text('medication2'), findsOneWidget);
- await widgetTester.tap(find.text('medication2'));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text('medication2'));
+ await tester.pumpAndSettle();
- await widgetTester.enterText(
+ await tester.enterText(
find.ancestor(
of: find.text(localizations.dosis).first,
matching: find.byType(TextFormField),
@@ -302,8 +302,8 @@ void main() {
);
expect(find.text(localizations.btnSave), findsOneWidget);
- await widgetTester.tap(find.text(localizations.btnSave));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text(localizations.btnSave));
+ await tester.pumpAndSettle();
expect(result?.$1, isNull);
expect(result?.$2, isA<MedicineIntake>()
@@ -312,8 +312,8 @@ void main() {
.having((p0) => p0.dosis, 'dosis', 123.456),
);
});
- testWidgets('should not allow invalid values', (widgetTester) async {
- await loadDialoge(widgetTester, (context) => showAddEntryDialoge(context, Settings()));
+ testWidgets('should not allow invalid values', (tester) async {
+ await loadDialoge(tester, (context) => showAddEntryDialoge(context, Settings()));
final localizations = await AppLocalizations.delegate.load(const Locale('en'));
expect(find.byType(DropdownButton<Medicine?>), findsNothing, reason: 'No medication in settings.');
@@ -324,40 +324,40 @@ void main() {
expect(find.text(localizations.errUnrealistic), findsNothing);
expect(find.text(localizations.errDiaGtSys), findsNothing);
- await widgetTester.enterText(find.ancestor(of: find.text('Systolic').first, matching: find.byType(TextFormField)), '123');
- await widgetTester.enterText(find.ancestor(of: find.text('Diastolic').first, matching: find.byType(TextFormField)), '67');
+ await tester.enterText(find.ancestor(of: find.text('Systolic').first, matching: find.byType(TextFormField)), '123');
+ await tester.enterText(find.ancestor(of: find.text('Diastolic').first, matching: find.byType(TextFormField)), '67');
- await widgetTester.tap(find.text('SAVE'));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text('SAVE'));
+ await tester.pumpAndSettle();
expect(find.byType(AddEntryDialoge), findsOneWidget);
expect(find.text(localizations.errNaN), findsOneWidget);
expect(find.text(localizations.errLt30), findsNothing);
expect(find.text(localizations.errUnrealistic), findsNothing);
expect(find.text(localizations.errDiaGtSys), findsNothing);
- await widgetTester.enterText(find.ancestor(of: find.text('Pulse').first, matching: find.byType(TextFormField)), '20');
- await widgetTester.tap(find.text('SAVE'));
- await widgetTester.pumpAndSettle();
+ await tester.enterText(find.ancestor(of: find.text('Pulse').first, matching: find.byType(TextFormField)), '20');
+ await tester.tap(find.text('SAVE'));
+ await tester.pumpAndSettle();
expect(find.byType(AddEntryDialoge), findsOneWidget);
expect(find.text(localizations.errNaN), findsNothing);
expect(find.text(localizations.errLt30), findsOneWidget);
expect(find.text(localizations.errUnrealistic), findsNothing);
expect(find.text(localizations.errDiaGtSys), findsNothing);
- await widgetTester.enterText(find.ancestor(of: find.text('Pulse').first, matching: find.byType(TextFormField)), '60');
- await widgetTester.enterText(find.ancestor(of: find.text('Diastolic').first, matching: find.byType(TextFormField)), '500');
- await widgetTester.tap(find.text('SAVE'));
- await widgetTester.pumpAndSettle();
+ await tester.enterText(find.ancestor(of: find.text('Pulse').first, matching: find.byType(TextFormField)), '60');
+ await tester.enterText(find.ancestor(of: find.text('Diastolic').first, matching: find.byType(TextFormField)), '500');
+ await tester.tap(find.text('SAVE'));
+ await tester.pumpAndSettle();
expect(find.byType(AddEntryDialoge), findsOneWidget);
expect(find.text(localizations.errNaN), findsNothing);
expect(find.text(localizations.errLt30), findsNothing);
expect(find.text(localizations.errUnrealistic), findsOneWidget);
expect(find.text(localizations.errDiaGtSys), findsNothing);
- await widgetTester.enterText(find.ancestor(of: find.text('Diastolic').first, matching: find.byType(TextFormField)), '100');
- await widgetTester.enterText(find.ancestor(of: find.text('Systolic').first, matching: find.byType(TextFormField)), '90');
- await widgetTester.tap(find.text('SAVE'));
- await widgetTester.pumpAndSettle();
+ await tester.enterText(find.ancestor(of: find.text('Diastolic').first, matching: find.byType(TextFormField)), '100');
+ await tester.enterText(find.ancestor(of: find.text('Systolic').first, matching: find.byType(TextFormField)), '90');
+ await tester.tap(find.text('SAVE'));
+ await tester.pumpAndSettle();
expect(find.byType(AddEntryDialoge), findsOneWidget);
expect(find.text(localizations.errNaN), findsNothing);
expect(find.text(localizations.errLt30), findsNothing);
@@ -365,36 +365,36 @@ void main() {
expect(find.text(localizations.errDiaGtSys), findsOneWidget);
- await widgetTester.enterText(find.ancestor(of: find.text('Diastolic').first, matching: find.byType(TextFormField)), '78');
- await widgetTester.enterText(find.ancestor(of: find.text('Systolic').first, matching: find.byType(TextFormField)), '123');
- await widgetTester.tap(find.text('SAVE'));
- await widgetTester.pumpAndSettle();
+ await tester.enterText(find.ancestor(of: find.text('Diastolic').first, matching: find.byType(TextFormField)), '78');
+ await tester.enterText(find.ancestor(of: find.text('Systolic').first, matching: find.byType(TextFormField)), '123');
+ await tester.tap(find.text('SAVE'));
+ await tester.pumpAndSettle();
expect(find.byType(AddEntryDialoge), findsNothing);
expect(find.text(localizations.errNaN), findsNothing);
expect(find.text(localizations.errLt30), findsNothing);
expect(find.text(localizations.errUnrealistic), findsNothing);
expect(find.text(localizations.errDiaGtSys), findsNothing);
});
- testWidgets('should allow invalid values when setting is set', (widgetTester) async {
- await loadDialoge(widgetTester, (context) =>
+ testWidgets('should allow invalid values when setting is set', (tester) async {
+ await loadDialoge(tester, (context) =>
showAddEntryDialoge(context, Settings(validateInputs: false, allowMissingValues: true)),);
expect(find.byType(DropdownButton<Medicine?>), findsNothing, reason: 'No medication in settings.');
- await widgetTester.enterText(find.ancestor(of: find.text('Systolic').first, matching: find.byType(TextFormField)), '2');
- await widgetTester.enterText(find.ancestor(of: find.text('Diastolic').first, matching: find.byType(TextFormField)), '500');
- await widgetTester.tap(find.text('SAVE'));
- await widgetTester.pumpAndSettle();
+ await tester.enterText(find.ancestor(of: find.text('Systolic').first, matching: find.byType(TextFormField)), '2');
+ await tester.enterText(find.ancestor(of: find.text('Diastolic').first, matching: find.byType(TextFormField)), '500');
+ await tester.tap(find.text('SAVE'));
+ await tester.pumpAndSettle();
expect(find.byType(AddEntryDialoge), findsNothing);
});
- testWidgets('should respect settings.allowManualTimeInput', (widgetTester) async {
- await loadDialoge(widgetTester, (context) =>
+ testWidgets('should respect settings.allowManualTimeInput', (tester) async {
+ await loadDialoge(tester, (context) =>
showAddEntryDialoge(context, Settings(allowManualTimeInput: false)),);
expect(find.byType(DropdownButton<Medicine?>), findsNothing, reason: 'No medication in settings.');
expect(find.byIcon(Icons.edit), findsNothing);
});
- testWidgets('should start with sys input focused', (widgetTester) async {
- await loadDialoge(widgetTester, (context) =>
+ testWidgets('should start with sys input focused', (tester) async {
+ await loadDialoge(tester, (context) =>
showAddEntryDialoge(context, Settings(), mockRecord(sys: 12)),);
expect(find.byType(DropdownButton<Medicine?>), findsNothing, reason: 'No medication in settings.');
@@ -408,12 +408,12 @@ void main() {
expect(focusedTextFormField.evaluate().first.widget, isA<TextFormField>()
.having((p0) => p0.initialValue, 'systolic content', '12'),);
});
- testWidgets('should focus next on input finished', (widgetTester) async {
- await loadDialoge(widgetTester, (context) =>
+ testWidgets('should focus next on input finished', (tester) async {
+ await loadDialoge(tester, (context) =>
showAddEntryDialoge(context, Settings(), mockRecord(sys: 12, dia: 3, pul: 4, note: 'note')),);
expect(find.byType(DropdownButton<Medicine?>), findsNothing, reason: 'No medication in settings.');
- await widgetTester.enterText(find.ancestor(of: find.text('Systolic').first, matching: find.byType(TextFormField)), '123');
+ await tester.enterText(find.ancestor(of: find.text('Systolic').first, matching: find.byType(TextFormField)), '123');
final firstFocused = FocusManager.instance.primaryFocus;
expect(firstFocused?.context?.widget, isNotNull);
@@ -425,7 +425,7 @@ void main() {
expect(focusedTextFormField.evaluate().first.widget, isA<TextFormField>()
.having((p0) => p0.initialValue, 'diastolic content', '3'),);
- await widgetTester.enterText(find.ancestor(of: find.text('Diastolic').first, matching: find.byType(TextFormField)), '78');
+ await tester.enterText(find.ancestor(of: find.text('Diastolic').first, matching: find.byType(TextFormField)), '78');
final secondFocused = FocusManager.instance.primaryFocus;
expect(secondFocused?.context?.widget, isNotNull);
@@ -437,7 +437,7 @@ void main() {
expect(secondFocusedTextFormField.evaluate().first.widget, isA<TextFormField>()
.having((p0) => p0.initialValue, 'pulse content', '4'),);
- await widgetTester.enterText(find.ancestor(of: find.text('Pulse').first, matching: find.byType(TextFormField)), '60');
+ await tester.enterText(find.ancestor(of: find.text('Pulse').first, matching: find.byType(TextFormField)), '60');
final thirdFocused = FocusManager.instance.primaryFocus;
expect(thirdFocused?.context?.widget, isNotNull);
@@ -450,13 +450,13 @@ void main() {
.having((p0) => p0.initialValue, 'note input content', 'note'),);
});
- testWidgets('should focus last input field on backspace pressed in empty input field', (widgetTester) async {
- await loadDialoge(widgetTester, (context) =>
+ testWidgets('should focus last input field on backspace pressed in empty input field', (tester) async {
+ await loadDialoge(tester, (context) =>
showAddEntryDialoge(context, Settings(), mockRecord(sys: 12, dia: 3, pul: 4, note: 'note')),);
expect(find.byType(DropdownButton<Medicine?>), findsNothing, reason: 'No medication in settings.');
- await widgetTester.enterText(find.ancestor(of: find.text('note').first, matching: find.byType(TextFormField)), '');
- await widgetTester.sendKeyEvent(LogicalKeyboardKey.backspace);
+ await tester.enterText(find.ancestor(of: find.text('note').first, matching: find.byType(TextFormField)), '');
+ await tester.sendKeyEvent(LogicalKeyboardKey.backspace);
final firstFocused = FocusManager.instance.primaryFocus;
expect(firstFocused?.context?.widget, isNotNull);
@@ -469,8 +469,8 @@ void main() {
expect(find.descendant(of: focusedTextFormField, matching: find.text('Pulse')), findsWidgets);
- await widgetTester.enterText(find.ancestor(of: find.text('Pulse').first, matching: find.byType(TextFormField)), '');
- await widgetTester.sendKeyEvent(LogicalKeyboardKey.backspace);
+ await tester.enterText(find.ancestor(of: find.text('Pulse').first, matching: find.byType(TextFormField)), '');
+ await tester.sendKeyEvent(LogicalKeyboardKey.backspace);
final secondFocused = FocusManager.instance.primaryFocus;
expect(secondFocused?.context?.widget, isNotNull);
@@ -483,8 +483,8 @@ void main() {
expect(find.descendant(of: secondFocusedTextFormField, matching: find.text('Diastolic')), findsWidgets);
- await widgetTester.enterText(find.ancestor(of: find.text('Diastolic').first, matching: find.byType(TextFormField)), '');
- await widgetTester.sendKeyEvent(LogicalKeyboardKey.backspace);
+ await tester.enterText(find.ancestor(of: find.text('Diastolic').first, matching: find.byType(TextFormField)), '');
+ await tester.sendKeyEvent(LogicalKeyboardKey.backspace);
final thirdFocused = FocusManager.instance.primaryFocus;
expect(thirdFocused?.context?.widget, isNotNull);
@@ -498,8 +498,8 @@ void main() {
// should not go back further than systolic
- await widgetTester.enterText(find.ancestor(of: find.text('Systolic').first, matching: find.byType(TextFormField)), '');
- await widgetTester.sendKeyEvent(LogicalKeyboardKey.backspace);
+ await tester.enterText(find.ancestor(of: find.text('Systolic').first, matching: find.byType(TextFormField)), '');
+ await tester.sendKeyEvent(LogicalKeyboardKey.backspace);
final fourthFocused = FocusManager.instance.primaryFocus;
expect(fourthFocused?.context?.widget, isNotNull);
@@ -510,35 +510,35 @@ void main() {
expect(fourthFocusedTextFormField, findsOneWidget);
expect(find.descendant(of: fourthFocusedTextFormField, matching: find.text('Systolic')), findsWidgets);
});
- testWidgets('should allow entering custom dosis', (widgetTester) async {
+ testWidgets('should allow entering custom dosis', (tester) async {
dynamic result;
- await loadDialoge(widgetTester, (context) async =>
+ await loadDialoge(tester, (context) async =>
result = await showAddEntryDialoge(context, Settings(
medications: [mockMedicine(designation: 'testmed')],
),),
);
- await widgetTester.tap(find.byType(DropdownButton<Medicine?>));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byType(DropdownButton<Medicine?>));
+ await tester.pumpAndSettle();
- await widgetTester.tap(find.text('testmed'));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text('testmed'));
+ await tester.pumpAndSettle();
final localizations = await AppLocalizations.delegate.load(const Locale('en'));
- await widgetTester.tap(find.text(localizations.btnSave));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text(localizations.btnSave));
+ await tester.pumpAndSettle();
expect(find.text(localizations.errNaN), findsOneWidget);
- await widgetTester.enterText(
+ await tester.enterText(
find.ancestor(
of: find.text(localizations.dosis).first,
matching: find.byType(TextFormField),
),
'654.321',
);
- await widgetTester.tap(find.text(localizations.btnSave));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text(localizations.btnSave));
+ await tester.pumpAndSettle();
expect(result, isNotNull);
expect(result?.$1, isNull);
@@ -546,40 +546,40 @@ void main() {
.having((p0) => p0.dosis, 'dosis', 654.321),
);
});
- testWidgets('should allow modifying entered dosis', (widgetTester) async {
+ testWidgets('should allow modifying entered dosis', (tester) async {
dynamic result;
- await loadDialoge(widgetTester, (context) async =>
+ await loadDialoge(tester, (context) async =>
result = await showAddEntryDialoge(context, Settings(
medications: [mockMedicine(designation: 'testmed')],
),),
);
final localizations = await AppLocalizations.delegate.load(const Locale('en'));
- await widgetTester.tap(find.byType(DropdownButton<Medicine?>));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byType(DropdownButton<Medicine?>));
+ await tester.pumpAndSettle();
- await widgetTester.tap(find.text('testmed'));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text('testmed'));
+ await tester.pumpAndSettle();
- await widgetTester.enterText(
+ await tester.enterText(
find.ancestor(
of: find.text(localizations.dosis).first,
matching: find.byType(TextFormField),
),
'654.321',
);
- await widgetTester.pumpAndSettle();
- await widgetTester.enterText(
+ await tester.pumpAndSettle();
+ await tester.enterText(
find.ancestor(
of: find.text(localizations.dosis).first,
matching: find.byType(TextFormField),
),
'654.322',
);
- await widgetTester.pumpAndSettle();
+ await tester.pumpAndSettle();
- await widgetTester.tap(find.text(localizations.btnSave));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text(localizations.btnSave));
+ await tester.pumpAndSettle();
expect(result, isNotNull);
expect(result?.$1, isNull);
@@ -587,16 +587,16 @@ void main() {
.having((p0) => p0.dosis, 'dosis', 654.322),
);
});
- testWidgets('should not go back to last field when the current field is still filled', (widgetTester) async {
- await loadDialoge(widgetTester, (context) =>
+ testWidgets('should not go back to last field when the current field is still filled', (tester) async {
+ await loadDialoge(tester, (context) =>
showAddEntryDialoge(context, Settings(), mockRecord(sys: 12, dia: 3, pul: 4, note: 'note')),);
expect(find.byType(DropdownButton<Medicine?>), findsNothing, reason: 'No medication in settings.');
- await widgetTester.enterText(find.ancestor(
+ await tester.enterText(find.ancestor(
of: find.text('note').first,
matching: find.byType(TextFormField),),
'not empty',);
- await widgetTester.sendKeyEvent(LogicalKeyboardKey.backspace);
+ await tester.sendKeyEvent(LogicalKeyboardKey.backspace);
final firstFocused = FocusManager.instance.primaryFocus;
expect(firstFocused?.context?.widget, isNotNull);
test/ui/components/color_picker_test.dart
@@ -5,18 +5,18 @@ import 'package:flutter_test/flutter_test.dart';
import 'util.dart';
void main() {
- testWidgets('should initialize without errors', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(ColorPicker(onColorSelected: (color) {})));
- await widgetTester.pumpWidget(materialApp(ColorPicker(availableColors: const [], onColorSelected: (color) {})));
- await widgetTester.pumpWidget(materialApp(ColorPicker(showTransparentColor: false, onColorSelected: (color) {})));
- await widgetTester.pumpWidget(materialApp(ColorPicker(circleSize: 15, onColorSelected: (color) {})));
- await widgetTester.pumpWidget(
+ testWidgets('should initialize without errors', (tester) async {
+ await tester.pumpWidget(materialApp(ColorPicker(onColorSelected: (color) {})));
+ await tester.pumpWidget(materialApp(ColorPicker(availableColors: const [], onColorSelected: (color) {})));
+ await tester.pumpWidget(materialApp(ColorPicker(showTransparentColor: false, onColorSelected: (color) {})));
+ await tester.pumpWidget(materialApp(ColorPicker(circleSize: 15, onColorSelected: (color) {})));
+ await tester.pumpWidget(
materialApp(ColorPicker(availableColors: const [], initialColor: Colors.red, onColorSelected: (color) {})),);
- expect(widgetTester.takeException(), isNull);
+ expect(tester.takeException(), isNull);
});
- testWidgets('should report correct picked color', (widgetTester) async {
+ testWidgets('should report correct picked color', (tester) async {
int onColorSelectedCallCount = 0;
- await widgetTester.pumpWidget(materialApp(ColorPicker(onColorSelected: (color) {
+ await tester.pumpWidget(materialApp(ColorPicker(onColorSelected: (color) {
expect(color, Colors.blue);
onColorSelectedCallCount += 1;
},),),);
@@ -31,7 +31,7 @@ void main() {
return false;
});
expect(blueColor.length, 1);
- await widgetTester.tap(find.byWidget(blueColor.first.widget));
+ await tester.tap(find.byWidget(blueColor.first.widget));
expect(onColorSelectedCallCount, 1);
});
}
test/ui/components/enter_timeformat_dialoge_test.dart
@@ -6,19 +6,19 @@ import 'util.dart';
void main() {
group('EnterTimeFormatDialoge', () {
- testWidgets('should initialize without errors', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(const EnterTimeFormatDialoge(initialValue: 'yyyy-MM-dd HH:mm',)));
- expect(widgetTester.takeException(), isNull);
+ testWidgets('should initialize without errors', (tester) async {
+ await tester.pumpWidget(materialApp(const EnterTimeFormatDialoge(initialValue: 'yyyy-MM-dd HH:mm',)));
+ expect(tester.takeException(), isNull);
expect(find.byType(EnterTimeFormatDialoge), findsOneWidget);
});
- testWidgets('should prefill time format', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp( const EnterTimeFormatDialoge(initialValue: 'yyyy-MM-dd HH:mm',)));
+ testWidgets('should prefill time format', (tester) async {
+ await tester.pumpWidget(materialApp( const EnterTimeFormatDialoge(initialValue: 'yyyy-MM-dd HH:mm',)));
final textField = find.byType(TextField);
expect(textField, findsOneWidget);
expect(find.descendant(of: textField, matching: find.text('yyyy-MM-dd HH:mm')), findsOneWidget);
});
- testWidgets('should show preview', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(EnterTimeFormatDialoge(
+ testWidgets('should show preview', (tester) async {
+ await tester.pumpWidget(materialApp(EnterTimeFormatDialoge(
initialValue: 'yyyy-MM-dd HH:mm',
previewTime: DateTime(2023, 7, 23, 8, 20),
),
@@ -27,66 +27,66 @@ void main() {
// other time formats
expect(find.byType(TextField), findsOneWidget);
- await widgetTester.enterText(find.byType(TextField), 'QQQQ + LLLL');
- await widgetTester.pumpAndSettle();
+ await tester.enterText(find.byType(TextField), 'QQQQ + LLLL');
+ await tester.pumpAndSettle();
expect(find.text('3rd quarter + July'), findsOneWidget);
});
- testWidgets('should close page on close button pressed', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(const EnterTimeFormatDialoge(initialValue: 'yyyy-MM-dd HH:mm',)));
+ testWidgets('should close page on close button pressed', (tester) async {
+ await tester.pumpWidget(materialApp(const EnterTimeFormatDialoge(initialValue: 'yyyy-MM-dd HH:mm',)));
expect(find.byType(EnterTimeFormatDialoge), findsOneWidget);
expect(find.byIcon(Icons.close), findsOneWidget);
- await widgetTester.tap(find.byIcon(Icons.close));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byIcon(Icons.close));
+ await tester.pumpAndSettle();
expect(find.byType(EnterTimeFormatDialoge), findsNothing);
});
- testWidgets('should not allow saving empty time formats', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(const EnterTimeFormatDialoge(initialValue: 'yyyy-MM-dd HH:mm',)));
+ testWidgets('should not allow saving empty time formats', (tester) async {
+ await tester.pumpWidget(materialApp(const EnterTimeFormatDialoge(initialValue: 'yyyy-MM-dd HH:mm',)));
- await widgetTester.enterText(find.byType(TextField), '');
- await widgetTester.pumpAndSettle();
+ await tester.enterText(find.byType(TextField), '');
+ await tester.pumpAndSettle();
expect(find.text('Please enter a value'), findsOneWidget);
expect(find.byType(EnterTimeFormatDialoge), findsOneWidget);
- await widgetTester.tap(find.text('SAVE'));
+ await tester.tap(find.text('SAVE'));
expect(find.byType(EnterTimeFormatDialoge), findsOneWidget);
});
});
group('showTimeFormatPickerDialoge', () {
- testWidgets('should return null on close', (widgetTester) async {
+ testWidgets('should return null on close', (tester) async {
String? result = 'notnull';
- await loadDialoge(widgetTester,
+ await loadDialoge(tester,
(context) async => result = await showTimeFormatPickerDialoge(context, 'yyyy-MM-dd HH:mm', false),);
expect(find.byIcon(Icons.close), findsOneWidget);
- await widgetTester.tap(find.byIcon(Icons.close));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byIcon(Icons.close));
+ await tester.pumpAndSettle();
expect(result, null);
});
- testWidgets('should return value on save', (widgetTester) async {
+ testWidgets('should return value on save', (tester) async {
String? result;
- await loadDialoge(widgetTester,
+ await loadDialoge(tester,
(context) async => result = await showTimeFormatPickerDialoge(context, 'yyyy-MM-dd HH:mm', false),);
expect(find.text('SAVE'), findsOneWidget);
- await widgetTester.tap(find.text('SAVE'));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text('SAVE'));
+ await tester.pumpAndSettle();
expect(result, 'yyyy-MM-dd HH:mm');
});
- testWidgets('should return modified value on save', (widgetTester) async {
+ testWidgets('should return modified value on save', (tester) async {
String? result;
- await loadDialoge(widgetTester,
+ await loadDialoge(tester,
(context) async => result = await showTimeFormatPickerDialoge(context, 'yyyy-MM-dd HH:mm', false),);
- await widgetTester.enterText(find.byType(TextField), 'test text!');
- await widgetTester.pumpAndSettle();
+ await tester.enterText(find.byType(TextField), 'test text!');
+ await tester.pumpAndSettle();
expect(find.text('SAVE'), findsOneWidget);
- await widgetTester.tap(find.text('SAVE'));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text('SAVE'));
+ await tester.pumpAndSettle();
expect(result, 'test text!');
});
test/ui/components/input_dialoge_test.dart
@@ -7,44 +7,44 @@ import 'util.dart';
void main() {
group('InputDialoge', () {
- testWidgets('should initialize without errors', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(const InputDialoge()));
- expect(widgetTester.takeException(), isNull);
- await widgetTester.pumpWidget(const MaterialApp(
+ testWidgets('should initialize without errors', (tester) async {
+ await tester.pumpWidget(materialApp(const InputDialoge()));
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const MaterialApp(
localizationsDelegates: [AppLocalizations.delegate,], locale: Locale('en'),
home: InputDialoge(
hintText: 'test hint',
initialValue: 'initial text',
),
),);
- expect(widgetTester.takeException(), isNull);
+ expect(tester.takeException(), isNull);
expect(find.byType(InputDialoge), findsOneWidget);
});
- testWidgets('should show prefilled text', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(const InputDialoge(
+ testWidgets('should show prefilled text', (tester) async {
+ await tester.pumpWidget(materialApp(const InputDialoge(
hintText: 'test hint',
initialValue: 'initial text',
),),);
expect(find.text('initial text'), findsOneWidget);
expect(find.text('test hint'), findsNWidgets(2));
});
- testWidgets('should show validator errors', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(InputDialoge(
+ testWidgets('should show validator errors', (tester) async {
+ await tester.pumpWidget(materialApp(InputDialoge(
initialValue: 'initial text',
validator: (_) => 'test error',
),),);
final localizations = await AppLocalizations.delegate.load(const Locale('en'));
expect(find.text(localizations.btnConfirm), findsOneWidget);
- await widgetTester.tap(find.text(localizations.btnConfirm));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text(localizations.btnConfirm));
+ await tester.pumpAndSettle();
expect(find.byType(InputDialoge), findsOneWidget);
expect(find.text('test error'), findsOneWidget);
});
- testWidgets('should send current text to validator', (widgetTester) async {
+ testWidgets('should send current text to validator', (tester) async {
int validatorCalls = 0;
- await widgetTester.pumpWidget(materialApp(InputDialoge(
+ await tester.pumpWidget(materialApp(InputDialoge(
initialValue: 'initial text',
validator: (value) {
expect(value, 'initial text');
@@ -57,8 +57,8 @@ void main() {
expect(validatorCalls, 0);
expect(find.text(localizations.btnConfirm), findsOneWidget);
- await widgetTester.tap(find.text(localizations.btnConfirm));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text(localizations.btnConfirm));
+ await tester.pumpAndSettle();
expect(validatorCalls, 1);
@@ -66,8 +66,8 @@ void main() {
});
});
group('showInputDialoge', () {
- testWidgets('should start with input focused', (widgetTester) async {
- await loadDialoge(widgetTester, (context) => showInputDialoge(context, initialValue: 'testval'));
+ testWidgets('should start with input focused', (tester) async {
+ await loadDialoge(tester, (context) => showInputDialoge(context, initialValue: 'testval'));
expect(find.byType(InputDialoge), findsOneWidget);
final primaryFocus = FocusManager.instance.primaryFocus;
@@ -78,40 +78,40 @@ void main() {
);
expect(find.descendant(of: focusedTextField, matching: find.text('testval')), findsOneWidget);
});
- testWidgets('should allow entering a value', (widgetTester) async {
+ testWidgets('should allow entering a value', (tester) async {
String? result = 'init';
- await loadDialoge(widgetTester, (context) async => result = await showInputDialoge(context));
+ await loadDialoge(tester, (context) async => result = await showInputDialoge(context));
final localizations = await AppLocalizations.delegate.load(const Locale('en'));
expect(find.byType(InputDialoge), findsOneWidget);
expect(find.byType(TextField), findsOneWidget);
- await widgetTester.enterText(find.byType(TextField), 'inputted text');
+ await tester.enterText(find.byType(TextField), 'inputted text');
expect(find.text(localizations.btnConfirm), findsOneWidget);
- await widgetTester.tap(find.text(localizations.btnConfirm));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text(localizations.btnConfirm));
+ await tester.pumpAndSettle();
expect(result, 'inputted text');
});
- testWidgets('should not return value on cancel', (widgetTester) async {
+ testWidgets('should not return value on cancel', (tester) async {
String? result = 'init';
- await loadDialoge(widgetTester, (context) async => result = await showInputDialoge(context, initialValue: 'test'));
+ await loadDialoge(tester, (context) async => result = await showInputDialoge(context, initialValue: 'test'));
final localizations = await AppLocalizations.delegate.load(const Locale('en'));
expect(find.byType(InputDialoge), findsOneWidget);
expect(find.byType(TextField), findsOneWidget);
- await widgetTester.enterText(find.byType(TextField), 'inputted text');
+ await tester.enterText(find.byType(TextField), 'inputted text');
expect(find.text(localizations.btnCancel), findsOneWidget);
- await widgetTester.tap(find.text(localizations.btnCancel));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text(localizations.btnCancel));
+ await tester.pumpAndSettle();
expect(result, null);
});
});
group('showNumberInputDialoge', () {
- testWidgets('should start with input focused', (widgetTester) async {
- await loadDialoge(widgetTester, (context) => showNumberInputDialoge(context, initialValue: 123));
+ testWidgets('should start with input focused', (tester) async {
+ await loadDialoge(tester, (context) => showNumberInputDialoge(context, initialValue: 123));
expect(find.byType(InputDialoge), findsOneWidget);
expect(find.text('123'), findsOneWidget);
@@ -124,39 +124,39 @@ void main() {
);
expect(find.descendant(of: focusedTextField, matching: find.text('123')), findsOneWidget);
});
- testWidgets('should allow entering a number', (widgetTester) async {
+ testWidgets('should allow entering a number', (tester) async {
double? result = -1;
- await loadDialoge(widgetTester, (context) async => result = await showNumberInputDialoge(context));
+ await loadDialoge(tester, (context) async => result = await showNumberInputDialoge(context));
final localizations = await AppLocalizations.delegate.load(const Locale('en'));
expect(find.byType(InputDialoge), findsOneWidget);
expect(find.byType(TextField), findsOneWidget);
- await widgetTester.enterText(find.byType(TextField), '123.76');
+ await tester.enterText(find.byType(TextField), '123.76');
expect(find.text(localizations.btnConfirm), findsOneWidget);
- await widgetTester.tap(find.text(localizations.btnConfirm));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text(localizations.btnConfirm));
+ await tester.pumpAndSettle();
expect(result, 123.76);
});
- testWidgets('should not allow entering text', (widgetTester) async {
+ testWidgets('should not allow entering text', (tester) async {
double? result = -1;
- await loadDialoge(widgetTester, (context) async => result = await showNumberInputDialoge(context));
+ await loadDialoge(tester, (context) async => result = await showNumberInputDialoge(context));
final localizations = await AppLocalizations.delegate.load(const Locale('en'));
expect(find.byType(InputDialoge), findsOneWidget);
- await widgetTester.enterText(find.byType(TextField), 'test');
+ await tester.enterText(find.byType(TextField), 'test');
expect(find.text(localizations.btnConfirm), findsOneWidget);
- await widgetTester.tap(find.text(localizations.btnConfirm));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text(localizations.btnConfirm));
+ await tester.pumpAndSettle();
expect(find.byType(InputDialoge), findsOneWidget); // unclosable through confirm
expect(find.text(localizations.errNaN), findsOneWidget);
expect(find.text(localizations.btnCancel), findsOneWidget);
- await widgetTester.tap(find.text(localizations.btnCancel));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.text(localizations.btnCancel));
+ await tester.pumpAndSettle();
expect(result, null);
});
test/ui/components/measurement_list_entry_test.dart
@@ -10,33 +10,33 @@ import '../../model/export_import/record_formatter_test.dart';
import 'util.dart';
void main() {
- testWidgets('should initialize without errors', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(MeasurementListRow(
+ testWidgets('should initialize without errors', (tester) async {
+ await tester.pumpWidget(materialApp(MeasurementListRow(
settings: Settings(),
record: BloodPressureRecord(DateTime(2023), 123, 80, 60, 'test'),),),);
- expect(widgetTester.takeException(), isNull);
- await widgetTester.pumpWidget(materialApp(MeasurementListRow(
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(materialApp(MeasurementListRow(
settings: Settings(),
record: BloodPressureRecord(DateTime.fromMillisecondsSinceEpoch(31279811), null, null, null, 'null test'),),),);
- expect(widgetTester.takeException(), isNull);
- await widgetTester.pumpWidget(materialApp(MeasurementListRow(
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(materialApp(MeasurementListRow(
settings: Settings(),
record: BloodPressureRecord(DateTime(2023), 124, 85, 63, 'color', needlePin: const MeasurementNeedlePin(Colors.cyan)),),),);
- expect(widgetTester.takeException(), isNull);
+ expect(tester.takeException(), isNull);
});
- testWidgets('should expand correctly', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(MeasurementListRow(
+ testWidgets('should expand correctly', (tester) async {
+ await tester.pumpWidget(materialApp(MeasurementListRow(
settings: Settings(),
record: BloodPressureRecord(DateTime(2023), 123, 78, 56, 'Test texts'),),),);
expect(find.byIcon(Icons.expand_more), findsOneWidget);
- await widgetTester.tap(find.byIcon(Icons.expand_more));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byIcon(Icons.expand_more));
+ await tester.pumpAndSettle();
expect(find.text('Timestamp'), findsOneWidget);
expect(find.byIcon(Icons.edit), findsOneWidget);
expect(find.byIcon(Icons.delete), findsOneWidget);
});
- testWidgets('should display correct information', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(MeasurementListRow(
+ testWidgets('should display correct information', (tester) async {
+ await tester.pumpWidget(materialApp(MeasurementListRow(
settings: Settings(),
record: BloodPressureRecord(DateTime(2023), 123, 78, 56, 'Test text'),),),);
expect(find.text('123'), findsOneWidget);
@@ -46,32 +46,32 @@ void main() {
expect(find.text('Test text'), findsNothing);
expect(find.byIcon(Icons.expand_more), findsOneWidget);
- await widgetTester.tap(find.byIcon(Icons.expand_more));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byIcon(Icons.expand_more));
+ await tester.pumpAndSettle();
expect(find.text('Test text'), findsOneWidget);
expect(find.textContaining('2023'), findsOneWidget);
});
- testWidgets('should not display null values', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(MeasurementListRow(
+ testWidgets('should not display null values', (tester) async {
+ await tester.pumpWidget(materialApp(MeasurementListRow(
settings: Settings(), record: mockRecord(time: DateTime(2023)),),),);
expect(find.text('null'), findsNothing);
expect(find.byIcon(Icons.expand_more), findsOneWidget);
- await widgetTester.tap(find.byIcon(Icons.expand_more));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byIcon(Icons.expand_more));
+ await tester.pumpAndSettle();
expect(find.text('null'), findsNothing);
});
- testWidgets('should open edit dialoge', (widgetTester) async {
- await widgetTester.pumpWidget(appBase(MeasurementListRow(
+ testWidgets('should open edit dialoge', (tester) async {
+ await tester.pumpWidget(appBase(MeasurementListRow(
settings: Settings(), record: mockRecord(time: DateTime(2023),
sys:1, dia: 2, pul: 3, note: 'testTxt',),),),);
expect(find.byIcon(Icons.expand_more), findsOneWidget);
- await widgetTester.tap(find.byIcon(Icons.expand_more));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byIcon(Icons.expand_more));
+ await tester.pumpAndSettle();
expect(find.byIcon(Icons.edit), findsOneWidget);
- await widgetTester.tap(find.byIcon(Icons.edit));
- await widgetTester.pumpAndSettle();
+ await tester.tap(find.byIcon(Icons.edit));
+ await tester.pumpAndSettle();
/// Finder of text widgets that are descendants of the AddEntryDialoge.
Finder descTxt(String txt) => find.descendant(
test/ui/components/util.dart
@@ -52,7 +52,7 @@ Widget appBase(Widget child, {
/// Example usage:
/// ```dart
/// dynamic returnedValue = false;
-/// await loadDialoge(widgetTester, (context) async => returnedValue =
+/// await loadDialoge(tester, (context) async => returnedValue =
/// await showAddExportColumnDialoge(context, Settings(),
/// UserColumn('initialInternalIdentifier', 'csvTitle', 'formatPattern')
/// ));
test/ui/statistics_test.dart
@@ -15,9 +15,9 @@ import '../model/export_import/record_formatter_test.dart';
import '../ram_only_implementations.dart';
void main() {
- testWidgets('should load page', (widgetTester) async {
- await _initStatsPage(widgetTester, []);
- expect(widgetTester.takeException(), isNull);
+ testWidgets('should load page', (tester) async {
+ await _initStatsPage(tester, []);
+ expect(tester.takeException(), isNull);
final localizations = await AppLocalizations.delegate.load(const Locale('en'));
expect(find.text(localizations.statistics), findsAtLeast(1));
@@ -25,8 +25,8 @@ void main() {
expect(find.text(localizations.timeResolvedMetrics, skipOffstage: false),
findsOneWidget,);
});
- testWidgets('should report measurement count', (widgetTester) async {
- await _initStatsPage(widgetTester, [
+ testWidgets('should report measurement count', (tester) async {
+ await _initStatsPage(tester, [
for (int i = 1; i<51; i++) // can't safe entries at or before epoch
mockRecord(time: DateTime.fromMillisecondsSinceEpoch(1582991592 + i),
sys: i, dia: 60+i, pul: 110+i,),
@@ -54,8 +54,8 @@ void main() {
matching: find.text('50'),
), findsOneWidget,);
});
- testWidgets("should not display 'null' or -1", (widgetTester) async {
- await _initStatsPage(widgetTester, [
+ testWidgets("should not display 'null' or -1", (tester) async {
+ await _initStatsPage(tester, [
mockRecord(time: DateTime.fromMillisecondsSinceEpoch(1), sys: 40, dia: 60),
mockRecord(time: DateTime.fromMillisecondsSinceEpoch(2),),
], intervallStoreManager: IntervallStoreManager(IntervallStorage(),
@@ -64,8 +64,8 @@ void main() {
expect(find.textContaining('null'), findsNothing);
});
- testWidgets("should not display 'null' when empty", (widgetTester) async {
- await _initStatsPage(widgetTester, [],
+ testWidgets("should not display 'null' when empty", (tester) async {
+ await _initStatsPage(tester, [],
intervallStoreManager: IntervallStoreManager(
IntervallStorage(), IntervallStorage(),
IntervallStorage(stepSize: TimeStep.lifetime,),),);
@@ -74,7 +74,7 @@ void main() {
});
}
-Future<void> _initStatsPage(WidgetTester widgetTester, List<BloodPressureRecord> records, {
+Future<void> _initStatsPage(WidgetTester tester, List<BloodPressureRecord> records, {
Settings? settings,
ExportSettings? exportSettings,
CsvExportSettings? csvExportSettings,
@@ -92,7 +92,7 @@ Future<void> _initStatsPage(WidgetTester widgetTester, List<BloodPressureRecord>
model.add(r);
}
- await widgetTester.pumpWidget(MultiProvider(
+ await tester.pumpWidget(MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => settings),
ChangeNotifierProvider(create: (_) => exportSettings),
@@ -107,5 +107,5 @@ Future<void> _initStatsPage(WidgetTester widgetTester, List<BloodPressureRecord>
child: const StatisticsScreen(),
),
),);
- await widgetTester.pumpAndSettle();
+ await tester.pumpAndSettle();
}