Commit 8badde6
Changed files (11)
test
ui
components
settings
test/ui/components/settings/color_picker_list_tile_test.dart
@@ -1,13 +1,14 @@
import 'package:blood_pressure_app/components/color_picker.dart';
import 'package:blood_pressure_app/components/settings/color_picker_list_tile.dart';
import 'package:flutter/material.dart';
-import 'package:flutter_gen/gen_l10n/app_localizations.dart';
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(
+ await widgetTester.pumpWidget(materialApp(ColorSelectionListTile(
title: const Text('Test'),
onMainColorChanged: (Color value) {
assert(false, 'should not be called');
@@ -16,7 +17,7 @@ void main() {
expect(widgetTester.takeException(), isNull);
});
testWidgets('should preview color', (widgetTester) async {
- await widgetTester.pumpWidget(_materialApp(ColorSelectionListTile(
+ await widgetTester.pumpWidget(materialApp(ColorSelectionListTile(
title: const Text('Test'),
onMainColorChanged: (Color value) {
assert(false, 'should not be called');
@@ -28,7 +29,7 @@ void main() {
(p0) => p0.backgroundColor, 'display color', Colors.teal));
});
testWidgets('should show colorPicker on tap', (widgetTester) async {
- await widgetTester.pumpWidget(_materialApp(ColorSelectionListTile(
+ await widgetTester.pumpWidget(materialApp(ColorSelectionListTile(
title: const Text('Test'),
onMainColorChanged: (Color value) {
assert(false, 'should not be called');
@@ -42,7 +43,7 @@ void main() {
});
testWidgets('should notify on color changed', (widgetTester) async {
int callCount = 0;
- await widgetTester.pumpWidget(_materialApp(ColorSelectionListTile(
+ await widgetTester.pumpWidget(materialApp(ColorSelectionListTile(
title: const Text('Test'),
onMainColorChanged: (Color value) {
callCount += 1;
@@ -62,7 +63,7 @@ void main() {
expect(callCount, 1);
});
testWidgets('should hide color when transparent is selected', (widgetTester) async {
- await widgetTester.pumpWidget(_materialApp(ColorSelectionListTile(
+ await widgetTester.pumpWidget(materialApp(ColorSelectionListTile(
title: const Text('Test'),
onMainColorChanged: (Color value) {
assert(false, 'should not be called');
@@ -74,14 +75,6 @@ void main() {
});
}
-Widget _materialApp(Widget child) {
- return MaterialApp(
- localizationsDelegates: const [AppLocalizations.delegate,],
- locale: const Locale('en'),
- home: Scaffold(body:child),
- );
-}
-
/// Finds the widget with a specific color inside a [ColorPicker], when put into a [CommonFinders.byElementPredicate].
bool Function(Element e) findColored(Color color) {
return (e) =>
test/ui/components/settings/dropdown_list_tile_test.dart
@@ -2,10 +2,12 @@ import 'package:blood_pressure_app/components/settings/dropdown_list_tile.dart';
import 'package:flutter/material.dart';
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>(
+ await widgetTester.pumpWidget(materialApp(DropDownListTile<int>(
title: const Text('test title'),
onChanged: (int? newValue) {
assert(false, 'should not be called');
@@ -17,7 +19,7 @@ void main() {
value: 3,
)));
expect(widgetTester.takeException(), isNull);
- await widgetTester.pumpWidget(_materialApp(DropDownListTile<int>(
+ 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),
@@ -33,7 +35,7 @@ void main() {
expect(widgetTester.takeException(), isNull);
});
testWidgets('should display selected option', (widgetTester) async {
- await widgetTester.pumpWidget(_materialApp(DropDownListTile<int>(
+ await widgetTester.pumpWidget(materialApp(DropDownListTile<int>(
title: const Text('test title'),
onChanged: (int? newValue) {
assert(false, 'should not be called');
@@ -49,7 +51,7 @@ void main() {
});
testWidgets('should call onChanged on option selected', (widgetTester) async {
int callCount = 0;
- await widgetTester.pumpWidget(_materialApp(DropDownListTile<int>(
+ await widgetTester.pumpWidget(materialApp(DropDownListTile<int>(
title: const Text('test title'),
onChanged: (int? newValue) {
callCount += 1;
@@ -72,10 +74,4 @@ void main() {
expect(callCount, 1);
});
});
-}
-
-Widget _materialApp(Widget child) {
- return MaterialApp(
- home: Scaffold(body: child),
- );
}
\ No newline at end of file
test/ui/components/settings/input_list_tile_test.dart
@@ -1,13 +1,14 @@
import 'package:blood_pressure_app/components/dialoges/input_dialoge.dart';
import 'package:blood_pressure_app/components/settings/input_list_tile.dart';
import 'package:flutter/material.dart';
-import 'package:flutter_gen/gen_l10n/app_localizations.dart';
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(
+ await widgetTester.pumpWidget(materialApp(InputListTile(
label: 'test title',
value: 'initial',
onSubmit: (String newValue) {
@@ -19,7 +20,7 @@ void main() {
expect(find.text('initial'), findsOneWidget);
});
testWidgets('should allow canceling edit', (widgetTester) async {
- await widgetTester.pumpWidget(_materialApp(InputListTile(
+ await widgetTester.pumpWidget(materialApp(InputListTile(
label: 'test title',
value: 'initial',
onSubmit: (String newValue) {
@@ -38,7 +39,7 @@ void main() {
expect(find.byType(InputDialoge), findsNothing);
});
testWidgets('should prefill value on edit', (widgetTester) async {
- await widgetTester.pumpWidget(_materialApp(InputListTile(
+ await widgetTester.pumpWidget(materialApp(InputListTile(
label: 'test title',
value: 'initial',
onSubmit: (String newValue) {
@@ -54,7 +55,7 @@ void main() {
});
testWidgets('should allow editing values', (widgetTester) async {
int callCount = 0;
- await widgetTester.pumpWidget(_materialApp(InputListTile(
+ await widgetTester.pumpWidget(materialApp(InputListTile(
label: 'test title',
value: 'initial',
onSubmit: (String newValue) {
@@ -76,12 +77,4 @@ void main() {
expect(callCount, 1);
});
});
-}
-
-Widget _materialApp(Widget child) {
- return MaterialApp(
- localizationsDelegates: const [AppLocalizations.delegate,],
- locale: const Locale('en'),
- home: Scaffold(body:child),
- );
}
\ No newline at end of file
test/ui/components/settings/number_input_list_tile_test.dart
@@ -1,13 +1,14 @@
import 'package:blood_pressure_app/components/dialoges/input_dialoge.dart';
import 'package:blood_pressure_app/components/settings/number_input_list_tile.dart';
import 'package:flutter/material.dart';
-import 'package:flutter_gen/gen_l10n/app_localizations.dart';
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(
+ await widgetTester.pumpWidget(materialApp(NumberInputListTile(
label: 'test title',
value: 15,
onParsableSubmit: (double newValue) {
@@ -19,7 +20,7 @@ void main() {
expect(find.text('15'), findsOneWidget);
});
testWidgets('should allow canceling edit', (widgetTester) async {
- await widgetTester.pumpWidget(_materialApp(NumberInputListTile(
+ await widgetTester.pumpWidget(materialApp(NumberInputListTile(
label: 'test title',
value: 15,
onParsableSubmit: (double newValue) {
@@ -38,7 +39,7 @@ void main() {
expect(find.byType(InputDialoge), findsNothing);
});
testWidgets('should prefill value on edit', (widgetTester) async {
- await widgetTester.pumpWidget(_materialApp(NumberInputListTile(
+ await widgetTester.pumpWidget(materialApp(NumberInputListTile(
label: 'test title',
value: 15,
onParsableSubmit: (double newValue) {
@@ -54,7 +55,7 @@ void main() {
});
testWidgets('should allow editing values', (widgetTester) async {
int callCount = 0;
- await widgetTester.pumpWidget(_materialApp(NumberInputListTile(
+ await widgetTester.pumpWidget(materialApp(NumberInputListTile(
label: 'test title',
value: 15,
onParsableSubmit: (double newValue) {
@@ -109,12 +110,4 @@ void main() {
expect(callCount, 4);
});
});
-}
-
-Widget _materialApp(Widget child) {
- return MaterialApp(
- localizationsDelegates: const [AppLocalizations.delegate,],
- locale: const Locale('en'),
- home: Scaffold(body:child),
- );
}
\ No newline at end of file
test/ui/components/settings/slider_list_tile_test.dart
@@ -2,10 +2,12 @@ import 'package:blood_pressure_app/components/settings/slider_list_tile.dart';
import 'package:flutter/material.dart';
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(
+ await widgetTester.pumpWidget(materialApp(SliderListTile(
title: const Text('test title'),
onChanged: (double newValue) {
assert(false, 'should not be called');
@@ -15,7 +17,7 @@ void main() {
max: 20,
)));
expect(widgetTester.takeException(), isNull);
- await widgetTester.pumpWidget(_materialApp(SliderListTile(
+ await widgetTester.pumpWidget(materialApp(SliderListTile(
title: const Text('Very long title that could overflow'),
onChanged: (double newValue) {
assert(false, 'should not be called');
@@ -32,7 +34,7 @@ void main() {
});
testWidgets('should report value changes', (widgetTester) async {
int callCount = 0;
- await widgetTester.pumpWidget(_materialApp(SliderListTile(
+ await widgetTester.pumpWidget(materialApp(SliderListTile(
title: const Text('title'),
onChanged: (double newValue) {
callCount += 1;
@@ -53,10 +55,4 @@ void main() {
expect(callCount, 1);
});
});
-}
-
-Widget _materialApp(Widget child) {
- return MaterialApp(
- home: Scaffold(body: child),
- );
}
\ No newline at end of file
test/ui/components/settings/titled_column_test.dart
@@ -1,12 +1,13 @@
import 'package:blood_pressure_app/components/settings/settings_widgets.dart';
import 'package:flutter/material.dart';
-import 'package:flutter_gen/gen_l10n/app_localizations.dart';
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(
+ await widgetTester.pumpWidget(materialApp(TitledColumn(
title: const Text('test title'),
children: [
const ListTile(title: Text('ListTile text 1'),),
@@ -24,7 +25,7 @@ void main() {
expect(find.text('ListTile text 2'), findsOneWidget);
});
testWidgets('should show title first', (widgetTester) async {
- await widgetTester.pumpWidget(_materialApp(TitledColumn(
+ await widgetTester.pumpWidget(materialApp(TitledColumn(
title: const Text('test title'),
children: [
const ListTile(title: Text('ListTile text 1'),),
@@ -43,12 +44,4 @@ void main() {
);
});
});
-}
-
-Widget _materialApp(Widget child) {
- return MaterialApp(
- localizationsDelegates: const [AppLocalizations.delegate,],
- locale: const Locale('en'),
- home: Scaffold(body:child),
- );
}
\ No newline at end of file
test/ui/components/add_export_column_dialoge_test.dart
@@ -7,10 +7,12 @@ import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
+import 'util.dart';
+
void main() {
group('AddExportColumnDialoge', () {
testWidgets('should show everything on load', (widgetTester) async {
- await widgetTester.pumpWidget(_materialApp(AddExportColumnDialoge(settings: Settings(),)));
+ await widgetTester.pumpWidget(materialApp(AddExportColumnDialoge(settings: Settings(),)));
expect(widgetTester.takeException(), isNull);
expect(find.text('SAVE'), findsOneWidget);
@@ -24,7 +26,7 @@ void main() {
expect(find.byIcon(Icons.arrow_downward), findsNWidgets(2));
});
testWidgets('should prefill values', (widgetTester) async {
- await widgetTester.pumpWidget(_materialApp(
+ await widgetTester.pumpWidget(materialApp(
AddExportColumnDialoge(initialColumn: UserColumn('id', 'csvTitle', r'formatPattern$SYS'), settings: Settings(),)
));
expect(widgetTester.takeException(), isNull);
@@ -40,7 +42,7 @@ void main() {
expect(find.byIcon(Icons.arrow_downward), findsNWidgets(2));
});
testWidgets('should show preview', (widgetTester) async {
- await widgetTester.pumpWidget(_materialApp(
+ await widgetTester.pumpWidget(materialApp(
AddExportColumnDialoge(initialColumn: UserColumn('id', 'csvTitle', r'formatPattern$SYS'), settings: Settings(),)
));
await widgetTester.pumpAndSettle();
@@ -51,7 +53,7 @@ void main() {
expect(find.textContaining('RowDataFieldType.sys'), findsOneWidget);
});
testWidgets('should open format Info screen', (widgetTester) async {
- await widgetTester.pumpWidget(_materialApp(AddExportColumnDialoge(settings: Settings(),)));
+ await widgetTester.pumpWidget(materialApp(AddExportColumnDialoge(settings: Settings(),)));
expect(find.byType(InformationScreen), findsNothing);
@@ -64,7 +66,7 @@ void main() {
});
group('showAddExportColumnDialoge', () {
testWidgets('should open AddExportColumnDialoge', (widgetTester) async {
- await widgetTester.pumpWidget(_materialApp(Builder(builder: (context) => TextButton(onPressed: () =>
+ await widgetTester.pumpWidget(materialApp(Builder(builder: (context) => TextButton(onPressed: () =>
showAddExportColumnDialoge(context, Settings()), child: const Text('X')))));
expect(find.byType(AddExportColumnDialoge), findsNothing);
@@ -76,7 +78,7 @@ void main() {
});
testWidgets('should return null on cancel', (widgetTester) async {
dynamic returnedValue = false;
- await widgetTester.pumpWidget(_materialApp(Builder(builder: (context) => TextButton(onPressed: () async =>
+ await widgetTester.pumpWidget(materialApp(Builder(builder: (context) => TextButton(onPressed: () async =>
returnedValue = await showAddExportColumnDialoge(context, Settings()), child: const Text('X')))));
await widgetTester.tap(find.text('X'));
await widgetTester.pumpAndSettle();
@@ -91,7 +93,7 @@ void main() {
});
testWidgets('should save entered values', (widgetTester) async {
dynamic returnedValue = false;
- await widgetTester.pumpWidget(_materialApp(Builder(builder: (context) => TextButton(onPressed: () async =>
+ await widgetTester.pumpWidget(materialApp(Builder(builder: (context) => TextButton(onPressed: () async =>
returnedValue = await showAddExportColumnDialoge(context, Settings()), child: const Text('X')))));
final localizations = await AppLocalizations.delegate.load(const Locale('en'));
@@ -122,7 +124,7 @@ void main() {
});
testWidgets('should keep internalIdentifier on edit', (widgetTester) async {
dynamic returnedValue = false;
- await widgetTester.pumpWidget(_materialApp(Builder(builder: (context) => TextButton(onPressed: () async =>
+ await widgetTester.pumpWidget(materialApp(Builder(builder: (context) => TextButton(onPressed: () async =>
returnedValue = await showAddExportColumnDialoge(context, Settings(),
UserColumn('initialInternalIdentifier', 'csvTitle', 'formatPattern')
), child: const Text('X')))));
@@ -148,12 +150,4 @@ void main() {
});
});
-}
-
-Widget _materialApp(Widget child) {
- return MaterialApp(
- localizationsDelegates: const [AppLocalizations.delegate,],
- locale: const Locale('en'),
- home: Scaffold(body:child),
- );
}
\ No newline at end of file
test/ui/components/add_measurement_dialoge_test.dart
@@ -8,11 +8,12 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
import 'settings/color_picker_list_tile_test.dart';
+import 'util.dart';
void main() {
group('AddMeasurementDialoge', () {
testWidgets('should show everything on initial page', (widgetTester) async {
- await widgetTester.pumpWidget(_materialApp(
+ await widgetTester.pumpWidget(materialApp(
AddMeasurementDialoge(
settings: Settings(),
)
@@ -26,7 +27,7 @@ void main() {
expect(find.byType(ColorSelectionListTile), findsOneWidget);
});
testWidgets('should prefill initialRecord values', (widgetTester) async {
- await widgetTester.pumpWidget(_materialApp(
+ await widgetTester.pumpWidget(materialApp(
AddMeasurementDialoge(
settings: Settings(),
initialRecord: BloodPressureRecord(
@@ -50,7 +51,7 @@ void main() {
group('showAddMeasurementDialoge', () {
testWidgets('should return null on cancel', (widgetTester) async {
dynamic result = 'not null';
- await widgetTester.pumpWidget(_materialApp(
+ await widgetTester.pumpWidget(materialApp(
Builder(
builder: (BuildContext context) => TextButton(onPressed: () async {
result = await showAddMeasurementDialoge(context, Settings(),
@@ -76,7 +77,7 @@ void main() {
DateTime.now(), 123, 56, 43, 'Test note',
needlePin: const MeasurementNeedlePin(Colors.teal)
);
- await widgetTester.pumpWidget(_materialApp(
+ await widgetTester.pumpWidget(materialApp(
Builder(
builder: (BuildContext context) => TextButton(onPressed: () async {
result = await showAddMeasurementDialoge(context, Settings(), record);
@@ -97,7 +98,7 @@ void main() {
});
testWidgets('should be able to input values', (WidgetTester widgetTester) async {
dynamic result = 'not null';
- await widgetTester.pumpWidget(_materialApp(
+ await widgetTester.pumpWidget(materialApp(
Builder(
builder: (BuildContext context) => TextButton(onPressed: () async {
result = await showAddMeasurementDialoge(context, Settings());
@@ -129,10 +130,10 @@ void main() {
expect(castResult.needlePin?.color, Colors.red);
});
testWidgets('should not allow invalid values', (widgetTester) async {
- await widgetTester.pumpWidget(_materialApp(Container()));
+ await widgetTester.pumpWidget(materialApp(Container()));
late final BuildContext buildContext;
- await widgetTester.pumpWidget(_materialApp(
+ await widgetTester.pumpWidget(materialApp(
Builder(
builder: (BuildContext context) {
buildContext = context;
@@ -204,7 +205,7 @@ void main() {
expect(find.text(localizations.errDiaGtSys), findsNothing);
});
testWidgets('should allow invalid values when setting is set', (widgetTester) async {
- await widgetTester.pumpWidget(_materialApp(
+ await widgetTester.pumpWidget(materialApp(
Builder(
builder: (BuildContext context) => TextButton(onPressed: () async {
await showAddMeasurementDialoge(context, Settings(validateInputs: false, allowMissingValues: true));
@@ -220,7 +221,7 @@ void main() {
expect(find.byType(AddMeasurementDialoge), findsNothing);
});
testWidgets('should respect settings.allowManualTimeInput', (widgetTester) async {
- await widgetTester.pumpWidget(_materialApp(
+ await widgetTester.pumpWidget(materialApp(
Builder(
builder: (BuildContext context) => TextButton(onPressed: () async {
await showAddMeasurementDialoge(context, Settings(allowManualTimeInput: false));
@@ -232,7 +233,7 @@ void main() {
expect(find.byIcon(Icons.edit), findsNothing);
});
testWidgets('should start with sys input focused', (widgetTester) async {
- await widgetTester.pumpWidget(_materialApp(
+ await widgetTester.pumpWidget(materialApp(
Builder(
builder: (BuildContext context) => TextButton(onPressed: () async {
await showAddMeasurementDialoge(context, Settings(allowManualTimeInput: false),
@@ -253,7 +254,7 @@ void main() {
.having((p0) => p0.initialValue, 'expecting systolic field to be selected', '12'));
});
testWidgets('should focus next on input finished', (widgetTester) async {
- await widgetTester.pumpWidget(_materialApp(
+ await widgetTester.pumpWidget(materialApp(
Builder(
builder: (BuildContext context) => TextButton(onPressed: () async {
await showAddMeasurementDialoge(context, Settings(allowManualTimeInput: false),
@@ -301,7 +302,7 @@ void main() {
});
testWidgets('should focus last input field on backspace pressed in empty input field', (widgetTester) async {
- await widgetTester.pumpWidget(_materialApp(
+ await widgetTester.pumpWidget(materialApp(
Builder(
builder: (BuildContext context) => TextButton(onPressed: () async {
await showAddMeasurementDialoge(context, Settings(allowManualTimeInput: false),
@@ -368,12 +369,4 @@ void main() {
expect(find.descendant(of: fourthFocusedTextFormField, matching: find.text('Systolic')), findsWidgets);
});
});
-}
-
-Widget _materialApp(Widget child) {
- return MaterialApp(
- localizationsDelegates: const [AppLocalizations.delegate,],
- locale: const Locale('en'),
- home: Scaffold(body:child),
- );
}
\ No newline at end of file
test/ui/components/color_picker_test.dart
@@ -2,19 +2,22 @@ import 'package:blood_pressure_app/components/color_picker.dart';
import 'package:flutter/material.dart';
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) {})));
+ 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) {
+ await widgetTester.pumpWidget(materialApp(ColorPicker(onColorSelected: (color) {
expect(color, Colors.blue);
onColorSelectedCallCount += 1;
})));
@@ -33,10 +36,4 @@ void main() {
expect(onColorSelectedCallCount, 1);
});
});
-}
-
-Widget _materialApp(Widget child) {
- return MaterialApp(
- home: Scaffold(body: child),
- );
}
\ No newline at end of file
test/ui/components/measurement_list_entry_test.dart
@@ -1,31 +1,29 @@
import 'package:blood_pressure_app/components/measurement_list/measurement_list_entry.dart';
import 'package:blood_pressure_app/model/blood_pressure.dart';
-import 'package:blood_pressure_app/model/ram_only_implementations.dart';
-import 'package:blood_pressure_app/model/storage/intervall_store.dart';
import 'package:blood_pressure_app/model/storage/settings_store.dart';
import 'package:flutter/material.dart';
-import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
-import 'package:provider/provider.dart';
+
+import 'util.dart';
void main() {
group('MeasurementListRow', () {
testWidgets('should initialize without errors', (widgetTester) async {
- await widgetTester.pumpWidget(_materialApp(MeasurementListRow(
+ await widgetTester.pumpWidget(materialApp(MeasurementListRow(
settings: Settings(),
record: BloodPressureRecord(DateTime(2023), 123, 80, 60, 'test'))));
expect(widgetTester.takeException(), isNull);
- await widgetTester.pumpWidget(_materialApp(MeasurementListRow(
+ 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(
+ 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(
+ await widgetTester.pumpWidget(materialApp(MeasurementListRow(
settings: Settings(),
record: BloodPressureRecord(DateTime(2023), 123, 78, 56, 'Test texts'))));
expect(find.byIcon(Icons.expand_more), findsOneWidget);
@@ -36,7 +34,7 @@ void main() {
expect(find.byIcon(Icons.delete), findsOneWidget);
});
testWidgets('should display correct information', (widgetTester) async {
- await widgetTester.pumpWidget(_materialApp(MeasurementListRow(
+ await widgetTester.pumpWidget(materialApp(MeasurementListRow(
settings: Settings(),
record: BloodPressureRecord(DateTime(2023), 123, 78, 56, 'Test text'))));
expect(find.text('123'), findsOneWidget);
@@ -53,7 +51,7 @@ void main() {
expect(find.textContaining('2023'), findsOneWidget);
});
testWidgets('should not display null values', (widgetTester) async {
- await widgetTester.pumpWidget(_materialApp(MeasurementListRow(
+ await widgetTester.pumpWidget(materialApp(MeasurementListRow(
settings: Settings(),
record: BloodPressureRecord(DateTime(2023), null, null, null, ''))));
expect(find.text('null'), findsNothing);
@@ -63,24 +61,4 @@ void main() {
expect(find.text('null'), findsNothing);
});
});
-}
-
-Widget _materialApp(Widget child) {
- return MaterialApp(
- home: Localizations(
- delegates: AppLocalizations.localizationsDelegates,
- locale: const Locale('en'),
- child: MultiProvider(
- providers: [
- ChangeNotifierProvider(create: (_) => IntervallStoreManager(IntervallStorage(), IntervallStorage(), IntervallStorage())),
- ChangeNotifierProvider<BloodPressureModel>(create: (_) => RamBloodPressureModel()),
- ],
- child: Localizations(
- delegates: AppLocalizations.localizationsDelegates,
- locale: const Locale('en'),
- child: Scaffold(body: child),
- ),
- )
- ),
- );
}
\ No newline at end of file
test/ui/components/util.dart
@@ -0,0 +1,10 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_gen/gen_l10n/app_localizations.dart';
+
+Widget materialApp(Widget child) {
+ return MaterialApp(
+ localizationsDelegates: const [AppLocalizations.delegate,],
+ locale: const Locale('en'),
+ home: Scaffold(body:child),
+ );
+}
\ No newline at end of file