mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-12-25 15:40:40 +00:00
7787558713
* test granting and revoking pro features * extracted common widget tester actions * test disabling & enabling of the metering screen layout features * added integration tests to CI * added integration tests to PR check * allow matrix jobs to fail * use base64 -d * downgraded iphone version to the supported one * use proper android device name * typo in macos version * upgraded iphone version to the supported one * updated android compileSdkVersion * added google services json restoration * combined all tests in one file * removed ipa signing for ios test * debug prints :) * lints * refined tester extension and expectations * e2e test (wip) * added more expectations to e2e test * changed pickers order a bit in e2e test * added equipment profiles creation to e2e test * added film selection to e2e test * set android emulator API level to 32 * use flutter drive for integration tests * removed app pre-build * try running tests only for one platform * added no-dds to flutter drive * try running only on ios * bumped macos version * increased tests timeout * set IPHONEOS_DEPLOYMENT_TARGET = 12.0 * removed prints * Update Podfile * restore firebase_app_id_file.json * Delete run_integration_tests.sh * run e2e with all tests * reverted pr-check
191 lines
7.6 KiB
Dart
191 lines
7.6 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:lightmeter/data/models/ev_source_type.dart';
|
|
import 'package:lightmeter/data/models/metering_screen_layout_config.dart';
|
|
import 'package:lightmeter/data/shared_prefs_service.dart';
|
|
import 'package:lightmeter/generated/l10n.dart';
|
|
import 'package:lightmeter/screens/metering/components/shared/readings_container/components/equipment_profile_picker/widget_picker_equipment_profiles.dart';
|
|
import 'package:lightmeter/screens/metering/components/shared/readings_container/components/extreme_exposure_pairs_container/widget_container_extreme_exposure_pairs.dart';
|
|
import 'package:lightmeter/screens/metering/components/shared/readings_container/components/film_picker/widget_picker_film.dart';
|
|
import 'package:lightmeter/screens/settings/screen_settings.dart';
|
|
import 'package:meta/meta.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import '../integration_test/utils/widget_tester_actions.dart';
|
|
import 'mocks/paid_features_mock.dart';
|
|
import 'utils/expectations.dart';
|
|
|
|
@isTestGroup
|
|
void testToggleLayoutFeatures(String description) {
|
|
group(
|
|
description,
|
|
() {
|
|
setUp(() {
|
|
SharedPreferences.setMockInitialValues({
|
|
/// Metering values
|
|
UserPreferencesService.evSourceTypeKey: EvSourceType.camera.index,
|
|
UserPreferencesService.meteringScreenLayoutKey: json.encode(
|
|
{
|
|
MeteringScreenLayoutFeature.equipmentProfiles: true,
|
|
MeteringScreenLayoutFeature.extremeExposurePairs: true,
|
|
MeteringScreenLayoutFeature.filmPicker: true,
|
|
}.toJson(),
|
|
),
|
|
});
|
|
});
|
|
|
|
testWidgets(
|
|
'Equipment profile picker',
|
|
(tester) async {
|
|
await tester.pumpApplication(selectedEquipmentProfileId: mockEquipmentProfiles.first.id);
|
|
await tester.takePhoto();
|
|
expectPickerTitle<EquipmentProfilePicker>(mockEquipmentProfiles.first.name);
|
|
expectExtremeExposurePairs('f/1.8 - 1/100', 'f/16 - 1/1.3');
|
|
expectExposurePairsListItem(tester, 'f/1.8', '1/100');
|
|
await tester.scrollToTheLastExposurePair(equipmentProfile: mockEquipmentProfiles.first);
|
|
expectExposurePairsListItem(tester, 'f/16', '1/1.3');
|
|
|
|
// Disable layout feature
|
|
await tester.toggleLayoutFeature(S.current.meteringScreenLayoutHintEquipmentProfiles);
|
|
expect(
|
|
find.byType(EquipmentProfilePicker),
|
|
findsNothing,
|
|
reason:
|
|
'Equipment profile picker must be hidden from the metering screen when the corresponding layout feature is disabled.',
|
|
);
|
|
expectExtremeExposurePairs(
|
|
'f/1.0 - 1/320',
|
|
'f/45 - 6"',
|
|
reason: 'Aperture and shutter speed ranges must be reset to default values when equipment profile is reset',
|
|
);
|
|
expectExposurePairsListItem(
|
|
tester,
|
|
'f/1.0',
|
|
'1/320',
|
|
reason:
|
|
'Aperture and shutter speed ranges must be reset to default values when equipment profile is reset.',
|
|
);
|
|
await tester.scrollToTheLastExposurePair();
|
|
expectExposurePairsListItem(
|
|
tester,
|
|
'f/45',
|
|
'6"',
|
|
reason:
|
|
'Aperture and shutter speed ranges must be reset to default values when equipment profile is reset.',
|
|
);
|
|
|
|
// Enable layout feature
|
|
await tester.toggleLayoutFeature(S.current.meteringScreenLayoutHintEquipmentProfiles);
|
|
expectPickerTitle<EquipmentProfilePicker>(
|
|
S.current.none,
|
|
reason: 'Equipment profile must remain unselected when the corresponding layout feature is re-enabled.',
|
|
);
|
|
},
|
|
);
|
|
|
|
testWidgets(
|
|
'Extreme exposure pairs container',
|
|
(tester) async {
|
|
await tester.pumpApplication();
|
|
await tester.takePhoto();
|
|
expectExtremeExposurePairs('f/1.0 - 1/320', 'f/45 - 6"');
|
|
expectExposurePairsListItem(tester, 'f/1.0', '1/320');
|
|
await tester.scrollToTheLastExposurePair();
|
|
expectExposurePairsListItem(tester, 'f/45', '6"');
|
|
|
|
// Disable layout feature
|
|
await tester.toggleLayoutFeature(S.current.meteringScreenFeatureExtremeExposurePairs);
|
|
expect(
|
|
find.byType(ExtremeExposurePairsContainer),
|
|
findsNothing,
|
|
reason:
|
|
'Extreme exposure pairs container must be hidden from the metering screen when the corresponding layout feature is disabled.',
|
|
);
|
|
expectExposurePairsListItem(
|
|
tester,
|
|
'f/1.0',
|
|
'1/320',
|
|
reason:
|
|
'Exposure pairs list must not be affected by the visibility of the extreme exposure pairs container.',
|
|
);
|
|
await tester.scrollToTheLastExposurePair();
|
|
expectExposurePairsListItem(
|
|
tester,
|
|
'f/45',
|
|
'6"',
|
|
reason:
|
|
'Exposure pairs list must not be affected by the visibility of the extreme exposure pairs container.',
|
|
);
|
|
|
|
// Enable layout feature
|
|
await tester.toggleLayoutFeature(S.current.meteringScreenFeatureExtremeExposurePairs);
|
|
expectExtremeExposurePairs(
|
|
'f/1.0 - 1/320',
|
|
'f/45 - 6"',
|
|
reason:
|
|
'Exposure pairs list must not be affected by the visibility of the extreme exposure pairs container.',
|
|
);
|
|
},
|
|
);
|
|
|
|
testWidgets(
|
|
'Film picker',
|
|
(tester) async {
|
|
await tester.pumpApplication(selectedFilm: mockFilms.first);
|
|
await tester.takePhoto();
|
|
expectPickerTitle<FilmPicker>(mockFilms.first.name);
|
|
expectExtremeExposurePairs('f/1.0 - 1/320', 'f/45 - 12"');
|
|
expectExposurePairsListItem(tester, 'f/1.0', '1/320');
|
|
await tester.scrollToTheLastExposurePair();
|
|
expectExposurePairsListItem(tester, 'f/45', '12"');
|
|
|
|
// Disable layout feature
|
|
await tester.toggleLayoutFeature(S.current.meteringScreenFeatureFilmPicker);
|
|
expect(
|
|
find.byType(FilmPicker),
|
|
findsNothing,
|
|
reason:
|
|
'Film picker must be hidden from the metering screen when the corresponding layout feature is disabled.',
|
|
);
|
|
expectExtremeExposurePairs(
|
|
'f/1.0 - 1/320',
|
|
'f/45 - 6"',
|
|
reason: 'Shutter speed must not be affected by reciprocity when film is discarded.',
|
|
);
|
|
expectExposurePairsListItem(
|
|
tester,
|
|
'f/1.0',
|
|
'1/320',
|
|
reason: 'Shutter speed must not be affected by reciprocity when film is discarded.',
|
|
);
|
|
await tester.scrollToTheLastExposurePair();
|
|
expectExposurePairsListItem(
|
|
tester,
|
|
'f/45',
|
|
'6"',
|
|
reason: 'Shutter speed must not be affected by reciprocity when film is discarded.',
|
|
);
|
|
|
|
// Enable layout feature
|
|
await tester.toggleLayoutFeature(S.current.meteringScreenFeatureFilmPicker);
|
|
expectPickerTitle<FilmPicker>(
|
|
S.current.none,
|
|
reason: 'Film must remain unselected when the corresponding layout feature is re-enabled.',
|
|
);
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
extension on WidgetTester {
|
|
Future<void> toggleLayoutFeature(String feature) async {
|
|
await openSettings();
|
|
await tapDescendantTextOf<SettingsScreen>(S.current.meteringScreenLayout);
|
|
await tapDescendantTextOf<SwitchListTile>(feature);
|
|
await tapSaveButton();
|
|
await navigatorPop();
|
|
}
|
|
}
|