main
  1
  2import 'package:blood_pressure_app/app.dart';
  3import 'package:blood_pressure_app/features/export_import/add_export_column_dialoge.dart';
  4import 'package:blood_pressure_app/features/export_import/export_column_management_screen.dart';
  5import 'package:blood_pressure_app/features/settings/add_medication_dialoge.dart';
  6import 'package:blood_pressure_app/features/settings/delete_data_screen.dart';
  7import 'package:blood_pressure_app/features/settings/enter_timeformat_dialoge.dart';
  8import 'package:blood_pressure_app/features/settings/export_import_screen.dart';
  9import 'package:blood_pressure_app/features/settings/graph_markings_screen.dart';
 10import 'package:blood_pressure_app/features/settings/medicine_manager_screen.dart';
 11import 'package:blood_pressure_app/features/settings/warn_about_screen.dart';
 12import 'package:blood_pressure_app/screens/home_screen.dart';
 13import 'package:blood_pressure_app/screens/settings_screen.dart';
 14import 'package:blood_pressure_app/screens/statistics_screen.dart';
 15import 'package:flutter/material.dart';
 16import 'package:blood_pressure_app/l10n/app_localizations.dart';
 17import 'package:flutter_test/flutter_test.dart';
 18import 'package:integration_test/integration_test.dart';
 19
 20import 'util.dart';
 21
 22void main() {
 23  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
 24  testWidgets('Can visit all screens and dialoges', (WidgetTester tester) async {
 25    final localizations = await AppLocalizations.delegate.load(const Locale('en'));
 26    const double settingsScrollAmount = 200.0;
 27
 28    await tester.pumpWidget(App());
 29    await tester.pumpAndSettle();
 30    await tester.pumpUntil(() => find.byType(AppHome).hasFound);
 31    // home
 32
 33    expect(find.byType(AppHome), findsOneWidget);
 34    expect(find.byType(SettingsPage), findsNothing);
 35    expect(find.byIcon(Icons.settings), findsOneWidget);
 36    await tester.tap(find.byIcon(Icons.settings));
 37    await tester.pumpAndSettle();
 38    expect(find.byType(SettingsPage), findsOneWidget);
 39    // settings
 40
 41    expect(find.byType(EnterTimeFormatDialoge), findsNothing);
 42    expect(find.text(localizations.timeFormat), findsOneWidget);
 43    await tester.tap(find.text(localizations.timeFormat));
 44    await tester.pumpAndSettle();
 45    expect(find.byType(EnterTimeFormatDialoge), findsOneWidget);
 46    // time format
 47    expect(find.text(localizations.btnSave), findsOneWidget);
 48    await tester.tap(find.text(localizations.btnSave));
 49    await tester.pumpAndSettle();
 50    expect(find.byType(EnterTimeFormatDialoge), findsNothing);
 51    // settings
 52
 53    expect(find.byType(MedicineManagerScreen), findsNothing);
 54    await tester.scrollUntilVisible(find.text(localizations.medications), settingsScrollAmount);
 55    await tester.tap(find.text(localizations.medications));
 56    await tester.pumpAndSettle();
 57    expect(find.byType(MedicineManagerScreen), findsOneWidget);
 58    // medication manager
 59    expect(find.byType(AddMedicationDialoge), findsNothing);
 60    await tester.tap(find.text(localizations.addMedication));
 61    await tester.pumpAndSettle();
 62    expect(find.byType(AddMedicationDialoge), findsOneWidget);
 63    // add medication
 64    await tester.tap(find.byIcon(Icons.close));
 65    await tester.pumpAndSettle();
 66    expect(find.byType(AddMedicationDialoge), findsNothing);
 67    // medication manager
 68    await tester.tap(find.byIcon(Icons.arrow_back));
 69    await tester.pumpAndSettle();
 70    expect(find.byType(MedicineManagerScreen), findsNothing);
 71    // settings
 72
 73    expect(find.byType(AboutWarnValuesScreen), findsNothing);
 74    await tester.scrollUntilVisible(find.text(localizations.aboutWarnValuesScreenDesc), settingsScrollAmount);
 75    await tester.tap(find.text(localizations.aboutWarnValuesScreenDesc));
 76    await tester.pumpAndSettle();
 77    expect(find.byType(AboutWarnValuesScreen), findsOneWidget);
 78    // warn values info
 79    await tester.tap(find.byIcon(Icons.arrow_back));
 80    await tester.pumpAndSettle();
 81    expect(find.byType(AboutWarnValuesScreen), findsNothing);
 82    // settings
 83
 84    expect(find.byType(GraphMarkingsScreen), findsNothing);
 85    await tester.scrollUntilVisible(find.text(localizations.customGraphMarkings), settingsScrollAmount);
 86    await tester.tap(find.text(localizations.customGraphMarkings));
 87    await tester.pumpAndSettle();
 88    expect(find.byType(GraphMarkingsScreen), findsOneWidget);
 89    // markings
 90    await tester.tap(find.byIcon(Icons.arrow_back));
 91    await tester.pumpAndSettle();
 92    expect(find.byType(GraphMarkingsScreen), findsNothing);
 93    // settings
 94
 95    expect(find.byType(ExportImportScreen), findsNothing);
 96    await tester.scrollUntilVisible(find.text(localizations.exportImport), settingsScrollAmount);
 97    await tester.tap(find.text(localizations.exportImport));
 98    await tester.pumpAndSettle();
 99    expect(find.byType(ExportImportScreen), findsOneWidget);
100    // export / import
101    expect(find.byType(ExportColumnsManagementScreen), findsNothing);
102    await tester.scrollUntilVisible(find.text(localizations.manageExportColumns), settingsScrollAmount);
103    await tester.tap(find.text(localizations.manageExportColumns));
104    await tester.pumpAndSettle();
105    expect(find.byType(ExportColumnsManagementScreen), findsOneWidget);
106    // export column manager
107    expect(find.byType(AddExportColumnDialoge), findsNothing);
108    await tester.tap(find.text(localizations.addExportformat));
109    await tester.pumpAndSettle();
110    expect(find.byType(AddExportColumnDialoge), findsOneWidget);
111    // add export column
112    await tester.tap(find.byIcon(Icons.close));
113    await tester.pumpAndSettle();
114    expect(find.byType(AddExportColumnDialoge), findsNothing);
115    // export column manager
116    await tester.tap(find.byIcon(Icons.arrow_back));
117    await tester.pumpAndSettle();
118    expect(find.byType(ExportColumnsManagementScreen), findsNothing);
119    // export / import
120    await tester.tap(find.byIcon(Icons.arrow_back));
121    await tester.pumpAndSettle();
122    expect(find.byType(ExportImportScreen), findsNothing);
123    // settings
124
125    expect(find.byType(DeleteDataScreen), findsNothing);
126    await tester.scrollUntilVisible(find.text(localizations.delete), settingsScrollAmount);
127    await tester.tap(find.text(localizations.delete));
128    await tester.pumpAndSettle();
129    expect(find.byType(DeleteDataScreen), findsOneWidget);
130    // delete data
131    await tester.tap(find.byIcon(Icons.arrow_back));
132    await tester.pumpAndSettle();
133    expect(find.byType(DeleteDataScreen), findsNothing);
134    // settings
135
136    expect(find.byType(LicensePage), findsNothing);
137    await tester.scrollUntilVisible(find.text(localizations.licenses, skipOffstage: false), settingsScrollAmount);
138    await tester.tap(find.text(localizations.licenses));
139    await tester.pumpAndSettle();
140    expect(find.byType(LicensePage), findsOneWidget);
141    // delete data
142    await tester.tap(find.byIcon(Icons.arrow_back));
143    await tester.pumpAndSettle();
144    expect(find.byType(LicensePage), findsNothing);
145    // settings
146
147    await tester.tap(find.byIcon(Icons.arrow_back));
148    await tester.pumpAndSettle();
149    expect(find.byType(SettingsPage), findsNothing);
150    expect(find.byType(AppHome), findsOneWidget);
151    // home
152
153
154    expect(find.byType(StatisticsScreen), findsNothing);
155    await tester.tap(find.byIcon(Icons.insights));
156    await tester.pumpAndSettle();
157    expect(find.byType(StatisticsScreen), findsOneWidget);
158    await tester.tap(find.byIcon(Icons.arrow_back));
159    await tester.pumpAndSettle();
160    expect(find.byType(StatisticsScreen), findsNothing);
161    expect(find.byType(AppHome), findsOneWidget);
162  });
163}