From 830a63e4ce3d91e7e506dcf3dd46293e3e0c67d0 Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Sat, 6 Apr 2024 23:51:24 +0200 Subject: [PATCH] added zoom checks to e2e test --- .vscode/launch.json | 13 +++++++ integration_test/e2e_test.dart | 34 +++++++++++++++++++ .../mocks/paid_features_mock.dart | 2 ++ 3 files changed, 49 insertions(+) diff --git a/.vscode/launch.json b/.vscode/launch.json index ff372ab..37497fb 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -61,5 +61,18 @@ ], "program": "${workspaceFolder}/lib/main_dev.dart", }, + { + "name": "integration-test", + "request": "launch", + "type": "dart", + "flutterMode": "debug", + "args": [ + "--flavor", + "dev", + "--dart-define", + "cameraStubImage=assets/camera_stub_image.jpg" + ], + "program": "${workspaceFolder}/integration_test/run_all_tests.dart", + }, ], } \ No newline at end of file diff --git a/integration_test/e2e_test.dart b/integration_test/e2e_test.dart index 39306a4..fe8c531 100644 --- a/integration_test/e2e_test.dart +++ b/integration_test/e2e_test.dart @@ -15,7 +15,9 @@ import 'package:lightmeter/screens/metering/components/shared/readings_container import 'package:lightmeter/screens/metering/components/shared/readings_container/components/shared/animated_dialog_picker/components/dialog_picker/widget_picker_dialog.dart'; import 'package:lightmeter/screens/settings/components/shared/dialog_filter/widget_dialog_filter.dart'; import 'package:lightmeter/screens/settings/components/shared/dialog_range_picker/widget_dialog_picker_range.dart'; +import 'package:lightmeter/screens/settings/components/shared/dialog_slider_picker/widget_dialog_slider_picker.dart'; import 'package:lightmeter/screens/settings/screen_settings.dart'; +import 'package:lightmeter/utils/double_to_zoom.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; import 'package:meta/meta.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -56,6 +58,8 @@ void testE2E(String description) { await tester.setNdValues(0, mockEquipmentProfiles[0].ndValues); await tester.setApertureValues(0, mockEquipmentProfiles[0].apertureValues); await tester.setShutterSpeedValues(0, mockEquipmentProfiles[0].shutterSpeedValues); + await tester.setZoomValue(0, mockEquipmentProfiles[0].lensZoom); + expect(find.text('x1.91'), findsOneWidget); expect(find.text('f/1.7 - f/16'), findsOneWidget); expect(find.text('1/1000 - 16"'), findsOneWidget); @@ -65,6 +69,8 @@ void testE2E(String description) { await tester.setProfileName(mockEquipmentProfiles[1].name); await tester.expandEquipmentProfileContainer(mockEquipmentProfiles[1].name); await tester.setApertureValues(1, mockEquipmentProfiles[1].apertureValues); + await tester.setZoomValue(1, mockEquipmentProfiles[1].lensZoom); + expect(find.text('x5.02'), findsOneWidget); expect(find.text('f/3.5 - f/22'), findsOneWidget); expect(find.text('1/1000 - 16"'), findsNWidgets(2)); await tester.navigatorPop(); @@ -171,6 +177,9 @@ extension EquipmentProfileActions on WidgetTester { Future setShutterSpeedValues(int profileIndex, List values) => _setDialogRangePickerValues(profileIndex, S.current.shutterSpeedValues, values); + + Future setZoomValue(int profileIndex, double value) => + _setDialogSliderPickerValue(profileIndex, S.current.lensZoom, value); } extension on WidgetTester { @@ -235,6 +244,30 @@ extension on WidgetTester { await tapSaveButton(); } + + Future _setDialogSliderPickerValue( + int profileIndex, + String listTileTitle, + double value, + ) async { + await tap(find.text(listTileTitle).at(profileIndex)); + await pumpAndSettle(); + + final sliderFinder = find.byType(Slider); + final trackWidth = getSize(sliderFinder).width - (2 * Dimens.paddingL); + final trackStep = trackWidth / (widget(sliderFinder).max - widget(sliderFinder).min); + + final oldValue = widget(sliderFinder).value; + final oldStart = (oldValue - 1) * trackStep; + final newStart = (value - 1) * trackStep; + await dragFrom( + getTopLeft(sliderFinder) + Offset(Dimens.paddingL + oldStart, getSize(sliderFinder).height / 2), + Offset(newStart - oldStart, 0), + ); + await pump(); + + await tapSaveButton(); + } } Future _expectMeteringState( @@ -257,6 +290,7 @@ Future _expectMeteringState( await tester.scrollToTheLastExposurePair(equipmentProfile: equipmentProfile); expectExposurePairsListItem(tester, slowest.split(' - ')[0], slowest.split(' - ')[1]); expectMeasureButton(ev); + expect(find.text(equipmentProfile.lensZoom.toZoom()), findsOneWidget); } Future _expectMeteringStateAndMeasure( diff --git a/integration_test/mocks/paid_features_mock.dart b/integration_test/mocks/paid_features_mock.dart index 03402dd..8d4a287 100644 --- a/integration_test/mocks/paid_features_mock.dart +++ b/integration_test/mocks/paid_features_mock.dart @@ -91,6 +91,7 @@ final mockEquipmentProfiles = [ IsoValue(1600, StopType.full), IsoValue(3200, StopType.full), ], + lensZoom: 1.91, ), EquipmentProfile( id: '2', @@ -120,6 +121,7 @@ final mockEquipmentProfiles = [ IsoValue(1600, StopType.full), IsoValue(3200, StopType.full), ], + lensZoom: 5.02, ), ];