Commit 7025ab1

derdilla <82763757+NobodyForNothing@users.noreply.github.com>
2023-11-12 14:22:08
test for errors caught by flutter
Signed-off-by: derdilla <82763757+NobodyForNothing@users.noreply.github.com>
1 parent 1c9e750
test/ui/components/settings/color_picker_list_tile_test.dart
@@ -13,6 +13,7 @@ void main() {
           assert(false, 'should not be called');
         },
         initialColor: Colors.teal,)));
+      expect(widgetTester.takeException(), isNull);
     });
     testWidgets('should preview color', (widgetTester) async {
       await widgetTester.pumpWidget(_materialApp(ColorSelectionListTile(
test/ui/components/settings/dropdown_list_tile_test.dart
@@ -16,6 +16,7 @@ void main() {
         ],
         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.'),
@@ -29,6 +30,7 @@ void main() {
         ],
         value: 527,
       )));
+      expect(widgetTester.takeException(), isNull);
     });
     testWidgets('should display selected option', (widgetTester) async {
       await widgetTester.pumpWidget(_materialApp(DropDownListTile<int>(
test/ui/components/settings/input_list_tile_test.dart
@@ -14,6 +14,7 @@ void main() {
           assert(false, 'should not be called');
         },
       )));
+      expect(widgetTester.takeException(), isNull);
       expect(find.text('test title'), findsOneWidget);
       expect(find.text('initial'), findsOneWidget);
     });
test/ui/components/settings/number_input_list_tile_test.dart
@@ -14,6 +14,7 @@ void main() {
           assert(false, 'should not be called');
         },
       )));
+      expect(widgetTester.takeException(), isNull);
       expect(find.text('test title'), findsOneWidget);
       expect(find.text('15'), findsOneWidget);
     });
test/ui/components/settings/slider_list_tile_test.dart
@@ -14,6 +14,7 @@ void main() {
         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) {
@@ -27,6 +28,7 @@ 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);
     });
     testWidgets('should report value changes', (widgetTester) async {
       int callCount = 0;
test/ui/components/settings/titled_column_test.dart
@@ -16,6 +16,7 @@ void main() {
           const ListTile(title: Text('ListTile text 2'),),
         ],
       )));
+      expect(widgetTester.takeException(), isNull);
 
       expect(find.text('test title'), findsOneWidget);
       expect(find.text('ListTile text 1'), findsOneWidget);
test/ui/components/add_measurement_dialoge_test.dart
@@ -16,6 +16,7 @@ void main() {
           settings: Settings(),
         )
       ));
+      expect(widgetTester.takeException(), isNull);
       expect(find.text('SAVE'), findsOneWidget);
       expect(find.byIcon(Icons.close), findsOneWidget);
       expect(find.text('Systolic'), findsAny);
@@ -229,6 +230,12 @@ void main() {
 
       expect(find.byIcon(Icons.edit), findsNothing);
     });
+    testWidgets('should start with sys input focused', (widgetTester) async {
+
+    });
+    testWidgets('should focus next on input finished', (widgetTester) async {
+
+    });
   });
 }
 
test/ui/components/color_picker_test.dart
@@ -4,16 +4,17 @@ import 'package:flutter_test/flutter_test.dart';
 
 void main() {
   group('ColorPicker', () {
-    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) {})));
+    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', (tester) async {
+    testWidgets('should report correct picked color', (widgetTester) async {
       int onColorSelectedCallCount = 0;
-      await tester.pumpWidget(_materialApp(ColorPicker(onColorSelected: (color) {
+      await widgetTester.pumpWidget(_materialApp(ColorPicker(onColorSelected: (color) {
         expect(color, Colors.blue);
         onColorSelectedCallCount += 1;
       })));
@@ -28,7 +29,7 @@ void main() {
         return false;
       });
       expect(blueColor.length, 1);
-      await tester.tap(find.byWidget(blueColor.first.widget));
+      await widgetTester.tap(find.byWidget(blueColor.first.widget));
       expect(onColorSelectedCallCount, 1);
     });
   });
test/ui/components/enter_timeformat_dialoge_test.dart
@@ -11,6 +11,7 @@ void main() {
         locale: Locale('en'),
         home: EnterTimeFormatDialoge(initialValue: 'yyyy-MM-dd HH:mm',)
       ));
+      expect(widgetTester.takeException(), isNull);
       expect(find.byType(EnterTimeFormatDialoge), findsOneWidget);
     });
     testWidgets('should prefill time format', (widgetTester) async {
test/ui/components/measurement_list_entry_test.dart
@@ -13,11 +13,13 @@ void main() {
     testWidgets('should initialize without errors', (widgetTester) async {
       await widgetTester.pumpWidget(_materialApp(MeasurementListRow(
           record: BloodPressureRecord(DateTime(2023), 123, 80, 60, 'test'))));
+      expect(widgetTester.takeException(), isNull);
       await widgetTester.pumpWidget(_materialApp(MeasurementListRow(
           record: BloodPressureRecord(DateTime.fromMillisecondsSinceEpoch(31279811), null, null, null, 'null test'))));
+      expect(widgetTester.takeException(), isNull);
       await widgetTester.pumpWidget(_materialApp(MeasurementListRow(
           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(
test/ui/navigation_test.dart
@@ -1,3 +1,4 @@
+import 'package:blood_pressure_app/components/dialoges/add_measurement.dart';
 import 'package:blood_pressure_app/components/dialoges/enter_timeformat.dart';
 import 'package:blood_pressure_app/main.dart';
 import 'package:blood_pressure_app/model/blood_pressure.dart';
@@ -22,7 +23,7 @@ void main() {
       await widgetTester.tap(find.byIcon(Icons.add));
       await widgetTester.pumpAndSettle();
 
-      expect(find.byType(AddMeasurementPage), findsOneWidget);
+      expect(find.byType(AddMeasurementDialoge), findsOneWidget);
     });
     testWidgets('should navigate to settings page', (widgetTester) async {
       await pumpAppRoot(widgetTester);
test/ui/statistics_test.dart
@@ -15,6 +15,7 @@ void main() {
   group("StatisticsPage", () {
     testWidgets('should load page', (widgetTester) async {
       await _initStatsPage(widgetTester, []);
+      expect(widgetTester.takeException(), isNull);
       expect(find.text('Statistics'), findsOneWidget);
     });
     testWidgets("should report measurement count", (widgetTester) async {