Commit eafeffd
Changed files (9)
test/ui/components/settings/color_picker_list_tile_test.dart
@@ -6,72 +6,70 @@ import 'package:flutter_test/flutter_test.dart';
import '../util.dart';
void main() {
- group('ColorSelectionListTile', () {
- testWidgets('should initialize without errors', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(ColorSelectionListTile(
- title: const Text('Test'),
- onMainColorChanged: (Color value) {
- assert(false, 'should not be called');
- },
- initialColor: Colors.teal,),),);
- expect(widgetTester.takeException(), isNull);
- });
- testWidgets('should preview color', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(ColorSelectionListTile(
- title: const Text('Test'),
- onMainColorChanged: (Color value) {
- assert(false, 'should not be called');
- },
- initialColor: Colors.teal,),),);
+ testWidgets('should initialize without errors', (widgetTester) async {
+ await widgetTester.pumpWidget(materialApp(ColorSelectionListTile(
+ title: const Text('Test'),
+ onMainColorChanged: (Color value) {
+ assert(false, 'should not be called');
+ },
+ initialColor: Colors.teal,),),);
+ expect(widgetTester.takeException(), isNull);
+ });
+ testWidgets('should preview color', (widgetTester) async {
+ await widgetTester.pumpWidget(materialApp(ColorSelectionListTile(
+ title: const Text('Test'),
+ onMainColorChanged: (Color value) {
+ assert(false, 'should not be called');
+ },
+ initialColor: Colors.teal,),),);
- expect(find.byType(CircleAvatar), findsOneWidget);
- expect(widgetTester.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(
- title: const Text('Test'),
- onMainColorChanged: (Color value) {
- assert(false, 'should not be called');
- },
- initialColor: Colors.teal,),),);
+ expect(find.byType(CircleAvatar), findsOneWidget);
+ expect(widgetTester.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(
+ title: const Text('Test'),
+ onMainColorChanged: (Color value) {
+ assert(false, 'should not be called');
+ },
+ initialColor: Colors.teal,),),);
- expect(find.byType(ColorPicker), findsNothing);
- await widgetTester.tap(find.byType(ListTile));
- await widgetTester.pumpAndSettle();
- expect(find.byType(ColorPicker), findsOneWidget);
- });
- testWidgets('should notify on color changed', (widgetTester) async {
- int callCount = 0;
- await widgetTester.pumpWidget(materialApp(ColorSelectionListTile(
- title: const Text('Test'),
- onMainColorChanged: (Color value) {
- callCount += 1;
- expect(value, Colors.red);
- },
- initialColor: Colors.teal,),),);
+ expect(find.byType(ColorPicker), findsNothing);
+ await widgetTester.tap(find.byType(ListTile));
+ await widgetTester.pumpAndSettle();
+ expect(find.byType(ColorPicker), findsOneWidget);
+ });
+ testWidgets('should notify on color changed', (widgetTester) async {
+ int callCount = 0;
+ await widgetTester.pumpWidget(materialApp(ColorSelectionListTile(
+ title: const Text('Test'),
+ onMainColorChanged: (Color value) {
+ callCount += 1;
+ expect(value, Colors.red);
+ },
+ initialColor: Colors.teal,),),);
- expect(find.byType(ColorPicker), findsNothing);
- await widgetTester.tap(find.byType(ListTile));
- await widgetTester.pumpAndSettle();
- expect(find.byType(ColorPicker), findsOneWidget);
+ expect(find.byType(ColorPicker), findsNothing);
+ await widgetTester.tap(find.byType(ListTile));
+ await widgetTester.pumpAndSettle();
+ expect(find.byType(ColorPicker), findsOneWidget);
- await widgetTester.tap(find.byElementPredicate(findColored(Colors.red)));
- await widgetTester.pumpAndSettle();
- expect(find.byType(ColorPicker), findsNothing);
+ await widgetTester.tap(find.byElementPredicate(findColored(Colors.red)));
+ await widgetTester.pumpAndSettle();
+ expect(find.byType(ColorPicker), findsNothing);
- expect(callCount, 1);
- });
- testWidgets('should hide color when transparent is selected', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(ColorSelectionListTile(
- title: const Text('Test'),
- onMainColorChanged: (Color value) {
- assert(false, 'should not be called');
- },
- initialColor: Colors.transparent,),),);
+ expect(callCount, 1);
+ });
+ testWidgets('should hide color when transparent is selected', (widgetTester) async {
+ await widgetTester.pumpWidget(materialApp(ColorSelectionListTile(
+ title: const Text('Test'),
+ onMainColorChanged: (Color value) {
+ assert(false, 'should not be called');
+ },
+ initialColor: Colors.transparent,),),);
- expect(find.byType(CircleAvatar), findsNothing);
- });
+ expect(find.byType(CircleAvatar), findsNothing);
});
}
test/ui/components/settings/dropdown_list_tile_test.dart
@@ -5,73 +5,71 @@ import 'package:flutter_test/flutter_test.dart';
import '../util.dart';
void main() {
- group('DropDownListTile', () {
- testWidgets('should not throw errors', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(DropDownListTile<int>(
- title: const Text('test title'),
- onChanged: (int? newValue) {
- assert(false, 'should not be called');
- },
- items: [
- for (int i = 0; i < 10; i++)
- DropdownMenuItem(value: i, child: Text('option $i')),
- ],
- value: 3,
- ),),);
- expect(widgetTester.takeException(), isNull);
- await widgetTester.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),
- onChanged: (int? newValue) {
- assert(false, 'should not be called');
- },
- items: [
- for (int i = 0; i < 1000; i++)
- DropdownMenuItem(value: i, child: Text('option $i')),
- ],
- value: 527,
- ),),);
- expect(widgetTester.takeException(), isNull);
- });
- testWidgets('should display selected option', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(DropDownListTile<int>(
- title: const Text('test title'),
- onChanged: (int? newValue) {
- assert(false, 'should not be called');
- },
- items: [
- for (int i = 0; i < 10; i++)
- DropdownMenuItem(value: i, child: Text('option $i')),
- ],
- value: 3,
- ),),);
- expect(find.text('option 3'), findsOneWidget);
- expect(find.text('option 4'), findsNothing);
- });
- testWidgets('should call onChanged on option selected', (widgetTester) async {
- int callCount = 0;
- await widgetTester.pumpWidget(materialApp(DropDownListTile<int>(
- title: const Text('test title'),
- onChanged: (int? newValue) {
- callCount += 1;
- expect(newValue, 5);
- },
- items: [
- for (int i = 0; i < 10; i++)
- DropdownMenuItem(value: i, child: Text('option $i')),
- ],
- value: 3,
- ),),);
+ testWidgets('should not throw errors', (widgetTester) async {
+ await widgetTester.pumpWidget(materialApp(DropDownListTile<int>(
+ title: const Text('test title'),
+ onChanged: (int? newValue) {
+ assert(false, 'should not be called');
+ },
+ items: [
+ for (int i = 0; i < 10; i++)
+ DropdownMenuItem(value: i, child: Text('option $i')),
+ ],
+ value: 3,
+ ),),);
+ expect(widgetTester.takeException(), isNull);
+ await widgetTester.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),
+ onChanged: (int? newValue) {
+ assert(false, 'should not be called');
+ },
+ items: [
+ for (int i = 0; i < 1000; i++)
+ DropdownMenuItem(value: i, child: Text('option $i')),
+ ],
+ value: 527,
+ ),),);
+ expect(widgetTester.takeException(), isNull);
+ });
+ testWidgets('should display selected option', (widgetTester) async {
+ await widgetTester.pumpWidget(materialApp(DropDownListTile<int>(
+ title: const Text('test title'),
+ onChanged: (int? newValue) {
+ assert(false, 'should not be called');
+ },
+ items: [
+ for (int i = 0; i < 10; i++)
+ DropdownMenuItem(value: i, child: Text('option $i')),
+ ],
+ value: 3,
+ ),),);
+ expect(find.text('option 3'), findsOneWidget);
+ expect(find.text('option 4'), findsNothing);
+ });
+ testWidgets('should call onChanged on option selected', (widgetTester) async {
+ int callCount = 0;
+ await widgetTester.pumpWidget(materialApp(DropDownListTile<int>(
+ title: const Text('test title'),
+ onChanged: (int? newValue) {
+ callCount += 1;
+ expect(newValue, 5);
+ },
+ items: [
+ for (int i = 0; i < 10; i++)
+ DropdownMenuItem(value: i, child: Text('option $i')),
+ ],
+ value: 3,
+ ),),);
- await widgetTester.tap(find.text('option 3'));
- await widgetTester.pumpAndSettle();
+ await widgetTester.tap(find.text('option 3'));
+ await widgetTester.pumpAndSettle();
- expect(find.text('option 5'), findsOneWidget);
- await widgetTester.tap(find.text('option 5'));
- await widgetTester.pumpAndSettle();
+ expect(find.text('option 5'), findsOneWidget);
+ await widgetTester.tap(find.text('option 5'));
+ await widgetTester.pumpAndSettle();
- expect(callCount, 1);
- });
+ expect(callCount, 1);
});
}
test/ui/components/settings/input_list_tile_test.dart
@@ -6,75 +6,73 @@ import 'package:flutter_test/flutter_test.dart';
import '../util.dart';
void main() {
- group('InputListTile', () {
- testWidgets('should show fields', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(InputListTile(
- label: 'test title',
- value: 'initial',
- onSubmit: (String newValue) {
- assert(false, 'should not be called');
- },
- ),),);
- expect(widgetTester.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(
- label: 'test title',
- value: 'initial',
- onSubmit: (String newValue) {
- assert(false, 'should not be called');
- },
- ),),);
+ testWidgets('should show fields', (widgetTester) async {
+ await widgetTester.pumpWidget(materialApp(InputListTile(
+ label: 'test title',
+ value: 'initial',
+ onSubmit: (String newValue) {
+ assert(false, 'should not be called');
+ },
+ ),),);
+ expect(widgetTester.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(
+ label: 'test title',
+ value: 'initial',
+ onSubmit: (String newValue) {
+ assert(false, 'should not be called');
+ },
+ ),),);
- expect(find.byType(InputDialoge), findsNothing);
- await widgetTester.tap(find.byType(InputListTile));
- await widgetTester.pumpAndSettle();
+ expect(find.byType(InputDialoge), findsNothing);
+ await widgetTester.tap(find.byType(InputListTile));
+ await widgetTester.pumpAndSettle();
- expect(find.byType(InputDialoge), findsOneWidget);
- await widgetTester.tapAt(const Offset(0, 0));
- await widgetTester.pumpAndSettle();
+ expect(find.byType(InputDialoge), findsOneWidget);
+ await widgetTester.tapAt(const Offset(0, 0));
+ await widgetTester.pumpAndSettle();
- expect(find.byType(InputDialoge), findsNothing);
- });
- testWidgets('should prefill value on edit', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(InputListTile(
- label: 'test title',
- value: 'initial',
- onSubmit: (String newValue) {
- assert(false, 'should not be called');
- },
- ),),);
+ expect(find.byType(InputDialoge), findsNothing);
+ });
+ testWidgets('should prefill value on edit', (widgetTester) async {
+ await widgetTester.pumpWidget(materialApp(InputListTile(
+ label: 'test title',
+ value: 'initial',
+ onSubmit: (String newValue) {
+ assert(false, 'should not be called');
+ },
+ ),),);
- expect(find.text('initial'), findsOneWidget);
- await widgetTester.tap(find.byType(InputListTile));
- await widgetTester.pumpAndSettle();
+ expect(find.text('initial'), findsOneWidget);
+ await widgetTester.tap(find.byType(InputListTile));
+ await widgetTester.pumpAndSettle();
- expect(find.text('initial'), findsNWidgets(2));
- });
- testWidgets('should allow editing values', (widgetTester) async {
- int callCount = 0;
- await widgetTester.pumpWidget(materialApp(InputListTile(
- label: 'test title',
- value: 'initial',
- onSubmit: (String newValue) {
- callCount += 1;
- expect(newValue, 'changed');
- },
- ),),);
+ expect(find.text('initial'), findsNWidgets(2));
+ });
+ testWidgets('should allow editing values', (widgetTester) async {
+ int callCount = 0;
+ await widgetTester.pumpWidget(materialApp(InputListTile(
+ label: 'test title',
+ value: 'initial',
+ onSubmit: (String newValue) {
+ callCount += 1;
+ expect(newValue, 'changed');
+ },
+ ),),);
- expect(find.text('initial'), findsOneWidget);
- await widgetTester.tap(find.byType(InputListTile));
- await widgetTester.pumpAndSettle();
+ expect(find.text('initial'), findsOneWidget);
+ await widgetTester.tap(find.byType(InputListTile));
+ await widgetTester.pumpAndSettle();
- expect(find.byType(TextField), findsOneWidget);
- await widgetTester.enterText(find.byType(TextField), 'changed');
- await widgetTester.tap(find.text('OK'));
- await widgetTester.pumpAndSettle();
+ expect(find.byType(TextField), findsOneWidget);
+ await widgetTester.enterText(find.byType(TextField), 'changed');
+ await widgetTester.tap(find.text('OK'));
+ await widgetTester.pumpAndSettle();
- expect(find.byType(InputDialoge), findsNothing);
- expect(callCount, 1);
- });
+ expect(find.byType(InputDialoge), findsNothing);
+ expect(callCount, 1);
});
}
test/ui/components/settings/number_input_list_tile_test.dart
@@ -6,108 +6,106 @@ import 'package:flutter_test/flutter_test.dart';
import '../util.dart';
void main() {
- group('NumberInputListTile', () {
- testWidgets('should show fields', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(NumberInputListTile(
- label: 'test title',
- value: 15,
- onParsableSubmit: (double newValue) {
- assert(false, 'should not be called');
- },
- ),),);
- expect(widgetTester.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(
- label: 'test title',
- value: 15,
- onParsableSubmit: (double newValue) {
- assert(false, 'should not be called');
- },
- ),),);
+ testWidgets('should show fields', (widgetTester) async {
+ await widgetTester.pumpWidget(materialApp(NumberInputListTile(
+ label: 'test title',
+ value: 15,
+ onParsableSubmit: (double newValue) {
+ assert(false, 'should not be called');
+ },
+ ),),);
+ expect(widgetTester.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(
+ label: 'test title',
+ value: 15,
+ onParsableSubmit: (double newValue) {
+ assert(false, 'should not be called');
+ },
+ ),),);
- expect(find.byType(InputDialoge), findsNothing);
- await widgetTester.tap(find.byType(NumberInputListTile));
- await widgetTester.pumpAndSettle();
+ expect(find.byType(InputDialoge), findsNothing);
+ await widgetTester.tap(find.byType(NumberInputListTile));
+ await widgetTester.pumpAndSettle();
- expect(find.byType(InputDialoge), findsOneWidget);
- await widgetTester.tapAt(const Offset(0, 0));
- await widgetTester.pumpAndSettle();
+ expect(find.byType(InputDialoge), findsOneWidget);
+ await widgetTester.tapAt(const Offset(0, 0));
+ await widgetTester.pumpAndSettle();
- expect(find.byType(InputDialoge), findsNothing);
- });
- testWidgets('should prefill value on edit', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(NumberInputListTile(
- label: 'test title',
- value: 15,
- onParsableSubmit: (double newValue) {
- assert(false, 'should not be called');
- },
- ),),);
+ expect(find.byType(InputDialoge), findsNothing);
+ });
+ testWidgets('should prefill value on edit', (widgetTester) async {
+ await widgetTester.pumpWidget(materialApp(NumberInputListTile(
+ label: 'test title',
+ value: 15,
+ onParsableSubmit: (double newValue) {
+ assert(false, 'should not be called');
+ },
+ ),),);
- expect(find.text('15'), findsOneWidget);
- await widgetTester.tap(find.byType(NumberInputListTile));
- await widgetTester.pumpAndSettle();
+ expect(find.text('15'), findsOneWidget);
+ await widgetTester.tap(find.byType(NumberInputListTile));
+ await widgetTester.pumpAndSettle();
- expect(find.text('15'), findsNWidgets(2));
- });
- testWidgets('should allow editing values', (widgetTester) async {
- int callCount = 0;
- await widgetTester.pumpWidget(materialApp(NumberInputListTile(
- label: 'test title',
- value: 15,
- onParsableSubmit: (double newValue) {
- callCount += 1;
- switch (callCount) {
- case 1:
- expect(newValue, 17.0);
- break;
- case 2:
- expect(newValue, 15.0);
- break;
- case 3:
- expect(newValue, 0.123);
- break;
- case 4:
- expect(newValue, 5.4);
- break;
- }
- },
- ),),);
+ expect(find.text('15'), findsNWidgets(2));
+ });
+ testWidgets('should allow editing values', (widgetTester) async {
+ int callCount = 0;
+ await widgetTester.pumpWidget(materialApp(NumberInputListTile(
+ label: 'test title',
+ value: 15,
+ onParsableSubmit: (double newValue) {
+ callCount += 1;
+ switch (callCount) {
+ case 1:
+ expect(newValue, 17.0);
+ break;
+ case 2:
+ expect(newValue, 15.0);
+ break;
+ case 3:
+ expect(newValue, 0.123);
+ break;
+ case 4:
+ expect(newValue, 5.4);
+ break;
+ }
+ },
+ ),),);
- expect(find.text('15'), findsOneWidget);
- await widgetTester.tap(find.byType(NumberInputListTile));
- await widgetTester.pumpAndSettle();
- expect(find.byType(TextField), findsOneWidget);
- await widgetTester.enterText(find.byType(TextField), '17');
- await widgetTester.tap(find.text('OK'));
- await widgetTester.pumpAndSettle();
+ expect(find.text('15'), findsOneWidget);
+ await widgetTester.tap(find.byType(NumberInputListTile));
+ await widgetTester.pumpAndSettle();
+ expect(find.byType(TextField), findsOneWidget);
+ await widgetTester.enterText(find.byType(TextField), '17');
+ await widgetTester.tap(find.text('OK'));
+ await widgetTester.pumpAndSettle();
- await widgetTester.tap(find.byType(NumberInputListTile));
- await widgetTester.pumpAndSettle();
- expect(find.byType(TextField), findsOneWidget);
- await widgetTester.enterText(find.byType(TextField), '15.0');
- await widgetTester.tap(find.text('OK'));
- await widgetTester.pumpAndSettle();
+ await widgetTester.tap(find.byType(NumberInputListTile));
+ await widgetTester.pumpAndSettle();
+ expect(find.byType(TextField), findsOneWidget);
+ await widgetTester.enterText(find.byType(TextField), '15.0');
+ await widgetTester.tap(find.text('OK'));
+ await widgetTester.pumpAndSettle();
- await widgetTester.tap(find.byType(NumberInputListTile));
- await widgetTester.pumpAndSettle();
- expect(find.byType(TextField), findsOneWidget);
- await widgetTester.enterText(find.byType(TextField), '0.123');
- await widgetTester.tap(find.text('OK'));
- await widgetTester.pumpAndSettle();
+ await widgetTester.tap(find.byType(NumberInputListTile));
+ await widgetTester.pumpAndSettle();
+ expect(find.byType(TextField), findsOneWidget);
+ await widgetTester.enterText(find.byType(TextField), '0.123');
+ await widgetTester.tap(find.text('OK'));
+ await widgetTester.pumpAndSettle();
- await widgetTester.tap(find.byType(NumberInputListTile));
- await widgetTester.pumpAndSettle();
- expect(find.byType(TextField), findsOneWidget);
- await widgetTester.enterText(find.byType(TextField), '5.4');
- await widgetTester.tap(find.text('OK'));
- await widgetTester.pumpAndSettle();
+ await widgetTester.tap(find.byType(NumberInputListTile));
+ await widgetTester.pumpAndSettle();
+ expect(find.byType(TextField), findsOneWidget);
+ await widgetTester.enterText(find.byType(TextField), '5.4');
+ await widgetTester.tap(find.text('OK'));
+ await widgetTester.pumpAndSettle();
- expect(find.byType(InputDialoge), findsNothing);
- expect(callCount, 4);
- });
+ expect(find.byType(InputDialoge), findsNothing);
+ expect(callCount, 4);
});
}
test/ui/components/settings/slider_list_tile_test.dart
@@ -5,54 +5,52 @@ import 'package:flutter_test/flutter_test.dart';
import '../util.dart';
void main() {
- group('SliderListTile', () {
- testWidgets('should not throw errors', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(SliderListTile(
- title: const Text('test title'),
- onChanged: (double newValue) {
- assert(false, 'should not be called');
- },
- value: 15,
- min: 1,
- max: 20,
- ),),);
- expect(widgetTester.takeException(), isNull);
- await widgetTester.pumpWidget(materialApp(SliderListTile(
- title: const Text('Very long title that could overflow'),
- onChanged: (double newValue) {
- assert(false, 'should not be called');
- },
- value: 15,
- min: 1,
- max: 20,
- stepSize: 0.001,
- leading: const Icon(Icons.add),
- trailing: const Icon(Icons.add),
- subtitle: const Text('While sliders support subtitle widgets, they should not interfere with the slider!'),
- ),),);
- expect(widgetTester.takeException(), isNull);
- });
- testWidgets('should report value changes', (widgetTester) async {
- int callCount = 0;
- await widgetTester.pumpWidget(materialApp(SliderListTile(
- title: const Text('title'),
- onChanged: (double newValue) {
- callCount += 1;
- expect(newValue, 8);
- },
- value: 3,
- min: 1,
- max: 10,
- subtitle: const Text('While sliders support subtitle widgets, they should not interfere with the slider!'),
- ),),);
+ testWidgets('should not throw errors', (widgetTester) async {
+ await widgetTester.pumpWidget(materialApp(SliderListTile(
+ title: const Text('test title'),
+ onChanged: (double newValue) {
+ assert(false, 'should not be called');
+ },
+ value: 15,
+ min: 1,
+ max: 20,
+ ),),);
+ expect(widgetTester.takeException(), isNull);
+ await widgetTester.pumpWidget(materialApp(SliderListTile(
+ title: const Text('Very long title that could overflow'),
+ onChanged: (double newValue) {
+ assert(false, 'should not be called');
+ },
+ value: 15,
+ min: 1,
+ max: 20,
+ stepSize: 0.001,
+ leading: const Icon(Icons.add),
+ trailing: const Icon(Icons.add),
+ subtitle: const Text('While sliders support subtitle widgets, they should not interfere with the slider!'),
+ ),),);
+ expect(widgetTester.takeException(), isNull);
+ });
+ testWidgets('should report value changes', (widgetTester) async {
+ int callCount = 0;
+ await widgetTester.pumpWidget(materialApp(SliderListTile(
+ title: const Text('title'),
+ onChanged: (double newValue) {
+ callCount += 1;
+ expect(newValue, 8);
+ },
+ value: 3,
+ min: 1,
+ max: 10,
+ 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 = widgetTester.getTopLeft(find.byType(Slider));
+ final bottomRight = widgetTester.getBottomRight(find.byType(Slider));
- final slider8Position = topLeft + ((bottomRight - topLeft) * 8 / 10);
- await widgetTester.tapAt(slider8Position);
- await widgetTester.pumpAndSettle();
- expect(callCount, 1);
- });
+ final slider8Position = topLeft + ((bottomRight - topLeft) * 8 / 10);
+ await widgetTester.tapAt(slider8Position);
+ await widgetTester.pumpAndSettle();
+ expect(callCount, 1);
});
}
test/ui/components/settings/titled_column_test.dart
@@ -5,43 +5,41 @@ import 'package:flutter_test/flutter_test.dart';
import '../util.dart';
void main() {
- group('TitledColumn', () {
- testWidgets('should show title and widgets', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(TitledColumn(
- title: const Text('test title'),
- children: [
- const ListTile(title: Text('ListTile text 1'),),
- SwitchListTile(
- title: const Text('SwitchListTile text'),
- value: true, onChanged: (v) {},),
- const ListTile(title: Text('ListTile text 2'),),
- ],
- ),),);
- expect(widgetTester.takeException(), isNull);
+ testWidgets('should show title and widgets', (widgetTester) async {
+ await widgetTester.pumpWidget(materialApp(TitledColumn(
+ title: const Text('test title'),
+ children: [
+ const ListTile(title: Text('ListTile text 1'),),
+ SwitchListTile(
+ title: const Text('SwitchListTile text'),
+ value: true, onChanged: (v) {},),
+ const ListTile(title: Text('ListTile text 2'),),
+ ],
+ ),),);
+ expect(widgetTester.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(
- title: const Text('test title'),
- children: [
- const ListTile(title: Text('ListTile text 1'),),
- SwitchListTile(
- title: const Text('SwitchListTile text'),
- value: true, onChanged: (v) {},),
- const ListTile(title: Text('ListTile text 2'),),
- ],
- ),),);
+ 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(
+ title: const Text('test title'),
+ children: [
+ const ListTile(title: Text('ListTile text 1'),),
+ SwitchListTile(
+ title: const Text('SwitchListTile text'),
+ value: true, onChanged: (v) {},),
+ const ListTile(title: Text('ListTile text 2'),),
+ ],
+ ),),);
- expect(find.byType(Column), findsOneWidget);
- expect(find.descendant(
- of: find.byType(Column).first,
- matching: find.text('test title'),),
- findsOneWidget,
- );
- });
+ expect(find.byType(Column), findsOneWidget);
+ expect(find.descendant(
+ of: find.byType(Column).first,
+ matching: find.text('test title'),),
+ findsOneWidget,
+ );
});
}
test/ui/components/color_picker_test.dart
@@ -5,35 +5,33 @@ import 'package:flutter_test/flutter_test.dart';
import 'util.dart';
void main() {
- group('ColorPicker', () {
- 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(
- materialApp(ColorPicker(availableColors: const [], initialColor: Colors.red, onColorSelected: (color) {})),);
- expect(widgetTester.takeException(), isNull);
- });
- testWidgets('should report correct picked color', (widgetTester) async {
- int onColorSelectedCallCount = 0;
- await widgetTester.pumpWidget(materialApp(ColorPicker(onColorSelected: (color) {
- expect(color, Colors.blue);
- onColorSelectedCallCount += 1;
- },),),);
+ 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(
+ materialApp(ColorPicker(availableColors: const [], initialColor: Colors.red, onColorSelected: (color) {})),);
+ expect(widgetTester.takeException(), isNull);
+ });
+ testWidgets('should report correct picked color', (widgetTester) async {
+ int onColorSelectedCallCount = 0;
+ await widgetTester.pumpWidget(materialApp(ColorPicker(onColorSelected: (color) {
+ expect(color, Colors.blue);
+ onColorSelectedCallCount += 1;
+ },),),);
- final containers = find.byType(Container).evaluate();
- final blueColor = containers.where((element) { // find widgets with color blue
- final widget = (element.widget as Container);
- final decoration = widget.decoration;
- if (decoration != null && decoration is BoxDecoration) {
- return decoration.color == Colors.blue;
- }
- return false;
- });
- expect(blueColor.length, 1);
- await widgetTester.tap(find.byWidget(blueColor.first.widget));
- expect(onColorSelectedCallCount, 1);
+ final containers = find.byType(Container).evaluate();
+ final blueColor = containers.where((element) { // find widgets with color blue
+ final widget = (element.widget as Container);
+ final decoration = widget.decoration;
+ if (decoration != null && decoration is BoxDecoration) {
+ return decoration.color == Colors.blue;
+ }
+ return false;
});
+ expect(blueColor.length, 1);
+ await widgetTester.tap(find.byWidget(blueColor.first.widget));
+ expect(onColorSelectedCallCount, 1);
});
}
test/ui/components/measurement_list_entry_test.dart
@@ -10,82 +10,80 @@ import '../../model/export_import/record_formatter_test.dart';
import 'util.dart';
void main() {
- group('MeasurementListRow', () {
- testWidgets('should initialize without errors', (widgetTester) async {
- await widgetTester.pumpWidget(materialApp(MeasurementListRow(
- settings: Settings(),
- record: BloodPressureRecord(DateTime(2023), 123, 80, 60, 'test'),),),);
- expect(widgetTester.takeException(), isNull);
- await widgetTester.pumpWidget(materialApp(MeasurementListRow(
+ testWidgets('should initialize without errors', (widgetTester) async {
+ await widgetTester.pumpWidget(materialApp(MeasurementListRow(
+ settings: Settings(),
+ record: BloodPressureRecord(DateTime(2023), 123, 80, 60, 'test'),),),);
+ expect(widgetTester.takeException(), isNull);
+ await widgetTester.pumpWidget(materialApp(MeasurementListRow(
+ settings: Settings(),
+ record: BloodPressureRecord(DateTime.fromMillisecondsSinceEpoch(31279811), null, null, null, 'null test'),),),);
+ expect(widgetTester.takeException(), isNull);
+ await widgetTester.pumpWidget(materialApp(MeasurementListRow(
+ settings: Settings(),
+ record: BloodPressureRecord(DateTime(2023), 124, 85, 63, 'color', needlePin: const MeasurementNeedlePin(Colors.cyan)),),),);
+ expect(widgetTester.takeException(), isNull);
+ });
+ testWidgets('should expand correctly', (widgetTester) async {
+ await widgetTester.pumpWidget(materialApp(MeasurementListRow(
settings: Settings(),
- record: BloodPressureRecord(DateTime.fromMillisecondsSinceEpoch(31279811), null, null, null, 'null test'),),),);
- expect(widgetTester.takeException(), isNull);
- await widgetTester.pumpWidget(materialApp(MeasurementListRow(
+ 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();
+ 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(
settings: Settings(),
- record: BloodPressureRecord(DateTime(2023), 124, 85, 63, 'color', needlePin: const MeasurementNeedlePin(Colors.cyan)),),),);
- expect(widgetTester.takeException(), isNull);
- });
- testWidgets('should expand correctly', (widgetTester) async {
- await widgetTester.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();
- 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(
- settings: Settings(),
- record: BloodPressureRecord(DateTime(2023), 123, 78, 56, 'Test text'),),),);
- expect(find.text('123'), findsOneWidget);
- expect(find.text('78'), findsOneWidget);
- expect(find.text('56'), findsOneWidget);
- expect(find.textContaining('2023'), findsNothing);
- expect(find.text('Test text'), findsNothing);
+ record: BloodPressureRecord(DateTime(2023), 123, 78, 56, 'Test text'),),),);
+ expect(find.text('123'), findsOneWidget);
+ expect(find.text('78'), findsOneWidget);
+ expect(find.text('56'), findsOneWidget);
+ expect(find.textContaining('2023'), findsNothing);
+ expect(find.text('Test text'), findsNothing);
- expect(find.byIcon(Icons.expand_more), findsOneWidget);
- await widgetTester.tap(find.byIcon(Icons.expand_more));
- await widgetTester.pumpAndSettle();
+ expect(find.byIcon(Icons.expand_more), findsOneWidget);
+ await widgetTester.tap(find.byIcon(Icons.expand_more));
+ await widgetTester.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(
- 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();
- expect(find.text('null'), findsNothing);
- });
- testWidgets('should open edit dialoge', (widgetTester) async {
- await widgetTester.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();
+ expect(find.text('Test text'), findsOneWidget);
+ expect(find.textContaining('2023'), findsOneWidget);
+ });
+ testWidgets('should not display null values', (widgetTester) async {
+ await widgetTester.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();
+ expect(find.text('null'), findsNothing);
+ });
+ testWidgets('should open edit dialoge', (widgetTester) async {
+ await widgetTester.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();
- expect(find.byIcon(Icons.edit), findsOneWidget);
- await widgetTester.tap(find.byIcon(Icons.edit));
- await widgetTester.pumpAndSettle();
+ expect(find.byIcon(Icons.edit), findsOneWidget);
+ await widgetTester.tap(find.byIcon(Icons.edit));
+ await widgetTester.pumpAndSettle();
- /// Finder of text widgets that are descendants of the AddEntryDialoge.
- Finder descTxt(String txt) => find.descendant(
- of: find.byType(AddEntryDialoge),
- matching: find.text(txt),
- );
+ /// Finder of text widgets that are descendants of the AddEntryDialoge.
+ Finder descTxt(String txt) => find.descendant(
+ of: find.byType(AddEntryDialoge),
+ matching: find.text(txt),
+ );
- expect(find.byType(AddEntryDialoge), findsOneWidget);
- expect(descTxt('testTxt'), findsOneWidget);
- expect(descTxt('1'), findsOneWidget);
- expect(descTxt('2'), findsOneWidget);
- expect(descTxt('3'), findsOneWidget);
+ expect(find.byType(AddEntryDialoge), findsOneWidget);
+ expect(descTxt('testTxt'), findsOneWidget);
+ expect(descTxt('1'), findsOneWidget);
+ expect(descTxt('2'), findsOneWidget);
+ expect(descTxt('3'), findsOneWidget);
- });
});
}
test/ui/statistics_test.dart
@@ -15,64 +15,62 @@ import '../model/export_import/record_formatter_test.dart';
import '../ram_only_implementations.dart';
void main() {
- group('StatisticsPage', () {
- testWidgets('should load page', (widgetTester) async {
- await _initStatsPage(widgetTester, []);
- expect(widgetTester.takeException(), isNull);
+ testWidgets('should load page', (widgetTester) async {
+ await _initStatsPage(widgetTester, []);
+ expect(widgetTester.takeException(), isNull);
- final localizations = await AppLocalizations.delegate.load(const Locale('en'));
- expect(find.text(localizations.statistics), findsAtLeast(1));
- expect(find.text(localizations.valueDistribution), findsOneWidget);
- expect(find.text(localizations.timeResolvedMetrics, skipOffstage: false),
- findsOneWidget,);
- });
- testWidgets('should report measurement count', (widgetTester) async {
- await _initStatsPage(widgetTester, [
- 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,),
- ], intervallStoreManager: IntervallStoreManager(IntervallStorage(),
- IntervallStorage(), IntervallStorage(stepSize: TimeStep.lifetime,),),);
- final localizations = await AppLocalizations.delegate.load(const Locale('en'));
-
- expect(find.text(localizations.measurementCount), findsOneWidget);
+ final localizations = await AppLocalizations.delegate.load(const Locale('en'));
+ expect(find.text(localizations.statistics), findsAtLeast(1));
+ expect(find.text(localizations.valueDistribution), findsOneWidget);
+ expect(find.text(localizations.timeResolvedMetrics, skipOffstage: false),
+ findsOneWidget,);
+ });
+ testWidgets('should report measurement count', (widgetTester) async {
+ await _initStatsPage(widgetTester, [
+ 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,),
+ ], intervallStoreManager: IntervallStoreManager(IntervallStorage(),
+ IntervallStorage(), IntervallStorage(stepSize: TimeStep.lifetime,),),);
+ final localizations = await AppLocalizations.delegate.load(const Locale('en'));
- final measurementCountWidget = find.ancestor(
- of: find.text(localizations.measurementCount),
- matching: find.byType(ListTile),
- );
- expect(measurementCountWidget, findsOneWidget);
- expect(find.descendant(
- of: measurementCountWidget,
- matching: find.text('49'),
- ), findsNothing,);
- expect(find.descendant(
- of: measurementCountWidget,
- matching: find.text('51'),
- ), findsNothing,);
- expect(find.descendant(
+ expect(find.text(localizations.measurementCount), findsOneWidget);
+
+ final measurementCountWidget = find.ancestor(
+ of: find.text(localizations.measurementCount),
+ matching: find.byType(ListTile),
+ );
+ expect(measurementCountWidget, findsOneWidget);
+ expect(find.descendant(
of: measurementCountWidget,
- matching: find.text('50'),
- ), findsOneWidget,);
- });
- testWidgets("should not display 'null' or -1", (widgetTester) async {
- await _initStatsPage(widgetTester, [
- mockRecord(time: DateTime.fromMillisecondsSinceEpoch(1), sys: 40, dia: 60),
- mockRecord(time: DateTime.fromMillisecondsSinceEpoch(2),),
- ], intervallStoreManager: IntervallStoreManager(IntervallStorage(),
- IntervallStorage(), IntervallStorage(stepSize: TimeStep.lifetime),),);
- expect(find.textContaining('-1'), findsNothing);
- expect(find.textContaining('null'), findsNothing);
- });
+ matching: find.text('49'),
+ ), findsNothing,);
+ expect(find.descendant(
+ of: measurementCountWidget,
+ matching: find.text('51'),
+ ), findsNothing,);
+ expect(find.descendant(
+ of: measurementCountWidget,
+ matching: find.text('50'),
+ ), findsOneWidget,);
+ });
+ testWidgets("should not display 'null' or -1", (widgetTester) async {
+ await _initStatsPage(widgetTester, [
+ mockRecord(time: DateTime.fromMillisecondsSinceEpoch(1), sys: 40, dia: 60),
+ mockRecord(time: DateTime.fromMillisecondsSinceEpoch(2),),
+ ], intervallStoreManager: IntervallStoreManager(IntervallStorage(),
+ IntervallStorage(), IntervallStorage(stepSize: TimeStep.lifetime),),);
+ expect(find.textContaining('-1'), findsNothing);
+ expect(find.textContaining('null'), findsNothing);
+ });
- testWidgets("should not display 'null' when empty", (widgetTester) async {
- await _initStatsPage(widgetTester, [],
- intervallStoreManager: IntervallStoreManager(
- IntervallStorage(), IntervallStorage(),
- IntervallStorage(stepSize: TimeStep.lifetime,),),);
- expect(find.textContaining('-1'), findsNothing);
- expect(find.textContaining('null'), findsNothing);
- });
+ testWidgets("should not display 'null' when empty", (widgetTester) async {
+ await _initStatsPage(widgetTester, [],
+ intervallStoreManager: IntervallStoreManager(
+ IntervallStorage(), IntervallStorage(),
+ IntervallStorage(stepSize: TimeStep.lifetime,),),);
+ expect(find.textContaining('-1'), findsNothing);
+ expect(find.textContaining('null'), findsNothing);
});
}