diff --git a/integration_test/mocks/paid_features_mock.dart b/integration_test/mocks/paid_features_mock.dart index 42d2b33..3748c96 100644 --- a/integration_test/mocks/paid_features_mock.dart +++ b/integration_test/mocks/paid_features_mock.dart @@ -45,6 +45,7 @@ class _MockIAPProvidersState extends State { when(() => mockIAPStorageService.selectedEquipmentProfileId).thenReturn(widget.selectedEquipmentProfileId); mockFilmsStorageService = _MockFilmsStorageService(); + when(() => mockFilmsStorageService.init()).thenAnswer((_) async {}); when(() => mockFilmsStorageService.getPredefinedFilms()).thenAnswer((_) => Future.value(widget.predefinedFilms)); when(() => mockFilmsStorageService.getCustomFilms()).thenAnswer((_) => Future.value(widget.customFilms)); when(() => mockFilmsStorageService.selectedFilmId).thenReturn(widget.selectedFilmId); @@ -135,10 +136,10 @@ final mockEquipmentProfiles = [ ]; const mockFilms = [ - FilmMultiplying(id: '1', name: 'Mock film 1', iso: 100, reciprocityMultiplier: 2), - FilmMultiplying(id: '2', name: 'Mock film 2', iso: 400, reciprocityMultiplier: 2), - FilmMultiplying(id: '3', name: 'Mock film 3', iso: 800, reciprocityMultiplier: 3), - FilmMultiplying(id: '4', name: 'Mock film 4', iso: 1200, reciprocityMultiplier: 1.5), + _FilmMultiplying(id: '1', name: 'Mock film 1', iso: 100, reciprocityMultiplier: 2), + _FilmMultiplying(id: '2', name: 'Mock film 2', iso: 400, reciprocityMultiplier: 2), + _FilmMultiplying(id: '3', name: 'Mock film 3', iso: 800, reciprocityMultiplier: 3), + _FilmMultiplying(id: '4', name: 'Mock film 4', iso: 1200, reciprocityMultiplier: 1.5), ]; extension FilmMapper on List { @@ -146,15 +147,15 @@ extension FilmMapper on List { Map.fromEntries(map((e) => MapEntry(e.id, (film: e as T, isUsed: isUsed)))); } -class FilmMultiplying extends FilmExponential { +class _FilmMultiplying extends FilmExponential { final double reciprocityMultiplier; - const FilmMultiplying({ + const _FilmMultiplying({ String? id, - required super.name, + required String name, required super.iso, required this.reciprocityMultiplier, - }) : super(id: id ?? name, exponent: 1); + }) : super(id: id ?? name, name: 'Mock film $iso x$reciprocityMultiplier', exponent: 1); @override ShutterSpeedValue reciprocityFailure(ShutterSpeedValue shutterSpeed) { @@ -173,7 +174,7 @@ class FilmMultiplying extends FilmExponential { bool operator ==(Object other) { if (identical(this, other)) return true; if (other.runtimeType != runtimeType) return false; - return other is FilmMultiplying && + return other is _FilmMultiplying && other.id == id && other.name == name && other.iso == iso && diff --git a/lib/application_wrapper.dart b/lib/application_wrapper.dart index cfee009..1694e1e 100644 --- a/lib/application_wrapper.dart +++ b/lib/application_wrapper.dart @@ -51,7 +51,6 @@ class ApplicationWrapper extends StatelessWidget { permissionsService: const PermissionsService(), userPreferencesService: userPreferencesService, volumeEventsService: const VolumeEventsService(LocalPlatform()), - filmsStorageService: filmsStorageService, child: RemoteConfigProvider( remoteConfigService: remoteConfigService, child: EquipmentProfileProvider( diff --git a/lib/providers/services_provider.dart b/lib/providers/services_provider.dart index c388b6d..1db019e 100644 --- a/lib/providers/services_provider.dart +++ b/lib/providers/services_provider.dart @@ -7,7 +7,6 @@ import 'package:lightmeter/data/permissions_service.dart'; import 'package:lightmeter/data/shared_prefs_service.dart'; import 'package:lightmeter/data/volume_events_service.dart'; import 'package:lightmeter/environment.dart'; -import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart'; // coverage:ignore-start class ServicesProvider extends InheritedWidget { @@ -20,9 +19,6 @@ class ServicesProvider extends InheritedWidget { final UserPreferencesService userPreferencesService; final VolumeEventsService volumeEventsService; - // IAP - final FilmsStorageService filmsStorageService; - const ServicesProvider({ required this.analytics, required this.caffeineService, @@ -32,7 +28,6 @@ class ServicesProvider extends InheritedWidget { required this.permissionsService, required this.userPreferencesService, required this.volumeEventsService, - required this.filmsStorageService, required super.child, }); diff --git a/test/application_mock.dart b/test/application_mock.dart index f9644c4..ff9a9ef 100644 --- a/test/application_mock.dart +++ b/test/application_mock.dart @@ -2,13 +2,25 @@ import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:light_sensor/light_sensor.dart'; -import 'package:lightmeter/application_wrapper.dart'; +import 'package:lightmeter/data/analytics/analytics.dart'; +import 'package:lightmeter/data/analytics/api/analytics_firebase.dart'; +import 'package:lightmeter/data/caffeine_service.dart'; +import 'package:lightmeter/data/haptics_service.dart'; +import 'package:lightmeter/data/light_sensor_service.dart'; import 'package:lightmeter/data/models/supported_locale.dart'; +import 'package:lightmeter/data/permissions_service.dart'; +import 'package:lightmeter/data/remote_config_service.dart'; +import 'package:lightmeter/data/shared_prefs_service.dart'; +import 'package:lightmeter/data/volume_events_service.dart'; import 'package:lightmeter/environment.dart'; import 'package:lightmeter/generated/l10n.dart'; +import 'package:lightmeter/providers/remote_config_provider.dart'; +import 'package:lightmeter/providers/services_provider.dart'; import 'package:lightmeter/providers/user_preferences_provider.dart'; import 'package:lightmeter/res/theme.dart'; import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart'; +import 'package:platform/platform.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import '../integration_test/mocks/paid_features_mock.dart'; import '../integration_test/utils/platform_channel_mock.dart'; @@ -94,8 +106,7 @@ class _GoldenTestApplicationMockState extends State { price: '0.0\$', ), ], - child: ApplicationWrapper( - const Environment.dev(), + child: _MockApplicationWrapper( child: MockIAPProviders( equipmentProfiles: mockEquipmentProfiles, selectedEquipmentProfileId: mockEquipmentProfiles.first.id, @@ -126,3 +137,40 @@ class _GoldenTestApplicationMockState extends State { ); } } + +class _MockApplicationWrapper extends StatelessWidget { + final Widget child; + + const _MockApplicationWrapper({required this.child}); + + @override + Widget build(BuildContext context) { + return FutureBuilder( + future: SharedPreferences.getInstance(), + builder: (_, snapshot) { + if (snapshot.data != null) { + final userPreferencesService = UserPreferencesService(snapshot.data!); + return ServicesProvider( + analytics: const LightmeterAnalytics(api: LightmeterAnalyticsFirebase()), + caffeineService: const CaffeineService(), + environment: const Environment.dev().copyWith(hasLightSensor: true), + hapticsService: const HapticsService(), + lightSensorService: const LightSensorService(LocalPlatform()), + permissionsService: const PermissionsService(), + userPreferencesService: userPreferencesService, + volumeEventsService: const VolumeEventsService(LocalPlatform()), + child: RemoteConfigProvider( + remoteConfigService: const MockRemoteConfigService(), + child: UserPreferencesProvider( + hasLightSensor: true, + userPreferencesService: userPreferencesService, + child: child, + ), + ), + ); + } + return const SizedBox(); + }, + ); + } +} diff --git a/test/screens/lightmeter_pro/goldens/lightmeter_pro_screen.png b/test/screens/lightmeter_pro/goldens/lightmeter_pro_screen.png index 7db028a..d635f48 100644 Binary files a/test/screens/lightmeter_pro/goldens/lightmeter_pro_screen.png and b/test/screens/lightmeter_pro/goldens/lightmeter_pro_screen.png differ diff --git a/test/screens/settings/goldens/settings_screen.png b/test/screens/settings/goldens/settings_screen.png index e54b4bd..ffe5fe6 100644 Binary files a/test/screens/settings/goldens/settings_screen.png and b/test/screens/settings/goldens/settings_screen.png differ