mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-24 00:10:47 +00:00
fixed golden tests
This commit is contained in:
parent
b4fffb8cc2
commit
7b9f03f46e
6 changed files with 61 additions and 18 deletions
|
@ -45,6 +45,7 @@ class _MockIAPProvidersState extends State<MockIAPProviders> {
|
|||
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<Film> {
|
||||
|
@ -146,15 +147,15 @@ extension FilmMapper on List<Film> {
|
|||
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 &&
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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,
|
||||
});
|
||||
|
||||
|
|
|
@ -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<GoldenTestApplicationMock> {
|
|||
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<GoldenTestApplicationMock> {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 301 KiB After Width: | Height: | Size: 301 KiB |
Binary file not shown.
Before Width: | Height: | Size: 499 KiB After Width: | Height: | Size: 494 KiB |
Loading…
Reference in a new issue