mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2025-08-05 04:36:41 +00:00
fixed unit tests
This commit is contained in:
parent
c5ef878ddb
commit
d67b75cbca
8 changed files with 114 additions and 20 deletions
|
@ -1,14 +1,18 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:lightmeter/data/geolocation_service.dart';
|
||||||
import 'package:lightmeter/providers/equipment_profile_provider.dart';
|
import 'package:lightmeter/providers/equipment_profile_provider.dart';
|
||||||
import 'package:lightmeter/providers/films_provider.dart';
|
import 'package:lightmeter/providers/films_provider.dart';
|
||||||
|
import 'package:lightmeter/providers/logbook_photos_provider.dart';
|
||||||
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
|
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
|
||||||
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
||||||
import 'package:mocktail/mocktail.dart';
|
import 'package:mocktail/mocktail.dart';
|
||||||
|
|
||||||
class _MockIapStorageService extends Mock implements IapStorageService {}
|
class _MockIapStorageService extends Mock implements IapStorageService {}
|
||||||
|
|
||||||
|
class _MockGeolocationService extends Mock implements GeolocationService {}
|
||||||
|
|
||||||
class MockIAPProviders extends StatefulWidget {
|
class MockIAPProviders extends StatefulWidget {
|
||||||
final TogglableMap<EquipmentProfile> equipmentProfiles;
|
final TogglableMap<EquipmentProfile> equipmentProfiles;
|
||||||
final String selectedEquipmentProfileId;
|
final String selectedEquipmentProfileId;
|
||||||
|
@ -36,11 +40,15 @@ class MockIAPProviders extends StatefulWidget {
|
||||||
|
|
||||||
class _MockIAPProvidersState extends State<MockIAPProviders> {
|
class _MockIAPProvidersState extends State<MockIAPProviders> {
|
||||||
late final _MockIapStorageService mockIapStorageService;
|
late final _MockIapStorageService mockIapStorageService;
|
||||||
|
late final mockGeolocationService = _MockGeolocationService();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
registerFallbackValue(defaultEquipmentProfile);
|
registerFallbackValue(defaultEquipmentProfile);
|
||||||
|
registerFallbackValue(defaultCustomPhotos.first);
|
||||||
|
registerFallbackValue(ApertureValue.values.first);
|
||||||
|
registerFallbackValue(ShutterSpeedValue.values.first);
|
||||||
mockIapStorageService = _MockIapStorageService();
|
mockIapStorageService = _MockIapStorageService();
|
||||||
when(() => mockIapStorageService.init()).thenAnswer((_) async {});
|
when(() => mockIapStorageService.init()).thenAnswer((_) async {});
|
||||||
|
|
||||||
|
@ -59,6 +67,22 @@ class _MockIAPProvidersState extends State<MockIAPProviders> {
|
||||||
when(() => mockIapStorageService.getPredefinedFilms()).thenAnswer((_) => Future.value(widget.predefinedFilms));
|
when(() => mockIapStorageService.getPredefinedFilms()).thenAnswer((_) => Future.value(widget.predefinedFilms));
|
||||||
when(() => mockIapStorageService.getCustomFilms()).thenAnswer((_) => Future.value(widget.customFilms));
|
when(() => mockIapStorageService.getCustomFilms()).thenAnswer((_) => Future.value(widget.customFilms));
|
||||||
when(() => mockIapStorageService.selectedFilmId).thenReturn(widget.selectedFilmId);
|
when(() => mockIapStorageService.selectedFilmId).thenReturn(widget.selectedFilmId);
|
||||||
|
|
||||||
|
when(() => mockIapStorageService.getPhotos()).thenAnswer((_) async => []);
|
||||||
|
when(() => mockIapStorageService.addPhoto(any())).thenAnswer((_) async {});
|
||||||
|
when(
|
||||||
|
() => mockIapStorageService.updatePhoto(
|
||||||
|
id: any(named: 'id'),
|
||||||
|
note: any(named: 'note'),
|
||||||
|
apertureValue: any(named: 'apertureValue'),
|
||||||
|
removeApertureValue: any(named: 'removeApertureValue'),
|
||||||
|
shutterSpeedValue: any(named: 'shutterSpeedValue'),
|
||||||
|
removeShutterSpeedValue: any(named: 'removeShutterSpeedValue'),
|
||||||
|
),
|
||||||
|
).thenAnswer((_) async {});
|
||||||
|
when(() => mockIapStorageService.deletePhoto(any())).thenAnswer((_) async {});
|
||||||
|
|
||||||
|
when(() => mockGeolocationService.getCurrentPosition()).thenAnswer((_) => Future.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -67,8 +91,12 @@ class _MockIAPProvidersState extends State<MockIAPProviders> {
|
||||||
storageService: mockIapStorageService,
|
storageService: mockIapStorageService,
|
||||||
child: FilmsProvider(
|
child: FilmsProvider(
|
||||||
storageService: mockIapStorageService,
|
storageService: mockIapStorageService,
|
||||||
|
child: LogbookPhotosProvider(
|
||||||
|
storageService: mockIapStorageService,
|
||||||
|
geolocationService: mockGeolocationService,
|
||||||
child: widget.child,
|
child: widget.child,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -193,3 +221,24 @@ class _FilmMultiplying extends FilmExponential {
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(id, name, iso, reciprocityMultiplier, runtimeType);
|
int get hashCode => Object.hash(id, name, iso, reciprocityMultiplier, runtimeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final List<LogbookPhoto> defaultCustomPhotos = [
|
||||||
|
LogbookPhoto(
|
||||||
|
id: '1',
|
||||||
|
name: 'test_photo_1.jpg',
|
||||||
|
timestamp: DateTime(2024, 1, 1, 12),
|
||||||
|
ev: 12.0,
|
||||||
|
iso: 100,
|
||||||
|
nd: 0,
|
||||||
|
note: 'Test photo 1',
|
||||||
|
),
|
||||||
|
LogbookPhoto(
|
||||||
|
id: '2',
|
||||||
|
name: 'test_photo_2.jpg',
|
||||||
|
timestamp: DateTime(2024, 1, 2, 12),
|
||||||
|
ev: 13.0,
|
||||||
|
iso: 200,
|
||||||
|
nd: 1,
|
||||||
|
note: 'Test photo 2',
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
|
@ -84,6 +84,7 @@ class _ApplicationWrapperState extends State<ApplicationWrapper> {
|
||||||
onInitialized: filmsStorageServiceCompleter.complete,
|
onInitialized: filmsStorageServiceCompleter.complete,
|
||||||
child: LogbookPhotosProvider(
|
child: LogbookPhotosProvider(
|
||||||
storageService: iapStorageService,
|
storageService: iapStorageService,
|
||||||
|
geolocationService: const GeolocationService(),
|
||||||
onInitialized: logbookPhotosStorageServiceCompleter.complete,
|
onInitialized: logbookPhotosStorageServiceCompleter.complete,
|
||||||
child: UserPreferencesProvider(
|
child: UserPreferencesProvider(
|
||||||
hasLightSensor: hasLightSensor,
|
hasLightSensor: hasLightSensor,
|
||||||
|
|
|
@ -2,7 +2,8 @@ import 'dart:io';
|
||||||
|
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:lightmeter/providers/services_provider.dart';
|
import 'package:lightmeter/data/geolocation_service.dart';
|
||||||
|
import 'package:lightmeter/platform_config.dart';
|
||||||
import 'package:lightmeter/utils/context_utils.dart';
|
import 'package:lightmeter/utils/context_utils.dart';
|
||||||
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
|
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
|
||||||
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
||||||
|
@ -10,11 +11,13 @@ import 'package:uuid/v8.dart';
|
||||||
|
|
||||||
class LogbookPhotosProvider extends StatefulWidget {
|
class LogbookPhotosProvider extends StatefulWidget {
|
||||||
final IapStorageService storageService;
|
final IapStorageService storageService;
|
||||||
|
final GeolocationService geolocationService;
|
||||||
final VoidCallback? onInitialized;
|
final VoidCallback? onInitialized;
|
||||||
final Widget child;
|
final Widget child;
|
||||||
|
|
||||||
const LogbookPhotosProvider({
|
const LogbookPhotosProvider({
|
||||||
required this.storageService,
|
required this.storageService,
|
||||||
|
required this.geolocationService,
|
||||||
this.onInitialized,
|
this.onInitialized,
|
||||||
required this.child,
|
required this.child,
|
||||||
super.key,
|
super.key,
|
||||||
|
@ -64,15 +67,14 @@ class LogbookPhotosProviderState extends State<LogbookPhotosProvider> {
|
||||||
widget.onInitialized?.call();
|
widget.onInitialized?.call();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> addPhotoIfPossible(
|
Future<LogbookPhoto?> addPhotoIfPossible(
|
||||||
String path, {
|
String path, {
|
||||||
required double ev100,
|
required double ev100,
|
||||||
required int iso,
|
required int iso,
|
||||||
required int nd,
|
required int nd,
|
||||||
}) async {
|
}) async {
|
||||||
if (context.isPro && _isEnabled) {
|
if (context.isPro && _isEnabled) {
|
||||||
final geolocationService = ServicesProvider.of(context).geolocationService;
|
final coordinates = await widget.geolocationService.getCurrentPosition();
|
||||||
final coordinates = await geolocationService.getCurrentPosition();
|
|
||||||
|
|
||||||
final photo = LogbookPhoto(
|
final photo = LogbookPhoto(
|
||||||
id: const UuidV8().generate(),
|
id: const UuidV8().generate(),
|
||||||
|
@ -86,12 +88,14 @@ class LogbookPhotosProviderState extends State<LogbookPhotosProvider> {
|
||||||
await widget.storageService.addPhoto(photo);
|
await widget.storageService.addPhoto(photo);
|
||||||
_photos[photo.id] = photo;
|
_photos[photo.id] = photo;
|
||||||
setState(() {});
|
setState(() {});
|
||||||
|
return photo;
|
||||||
} else {
|
} else {
|
||||||
Directory(path).deleteSync(recursive: true);
|
_deletePhoto(path);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateProfile(LogbookPhoto photo) async {
|
Future<void> updateLogbookPhoto(LogbookPhoto photo) async {
|
||||||
final oldProfile = _photos[photo.id]!;
|
final oldProfile = _photos[photo.id]!;
|
||||||
await widget.storageService.updatePhoto(
|
await widget.storageService.updatePhoto(
|
||||||
id: photo.id,
|
id: photo.id,
|
||||||
|
@ -105,12 +109,22 @@ class LogbookPhotosProviderState extends State<LogbookPhotosProvider> {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> deleteProfile(LogbookPhoto photo) async {
|
Future<void> deleteLogbookPhoto(LogbookPhoto photo) async {
|
||||||
await widget.storageService.deletePhoto(photo.id);
|
await widget.storageService.deletePhoto(photo.id);
|
||||||
_photos.remove(photo.id);
|
_photos.remove(photo.id);
|
||||||
Directory(photo.name).deleteSync(recursive: true);
|
_deletePhoto(photo.name);
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _deletePhoto(String path) async {
|
||||||
|
if (PlatformConfig.cameraStubImage.isEmpty) {
|
||||||
|
try {
|
||||||
|
Directory(path).deleteSync(recursive: true);
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint(e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum _LogbookPhotosModelAspect { photosList, isEnabled }
|
enum _LogbookPhotosModelAspect { photosList, isEnabled }
|
||||||
|
|
|
@ -79,13 +79,13 @@ class LogbookPhotoEditBloc extends Bloc<LogbookPhotoEditEvent, LogbookPhotoEditS
|
||||||
|
|
||||||
Future<void> _onSave(LogbookPhotoSaveEvent _, Emitter emit) async {
|
Future<void> _onSave(LogbookPhotoSaveEvent _, Emitter emit) async {
|
||||||
emit(state.copyWith(isLoading: true));
|
emit(state.copyWith(isLoading: true));
|
||||||
await photosProvider.updateProfile(_newPhoto);
|
await photosProvider.updateLogbookPhoto(_newPhoto);
|
||||||
emit(state.copyWith(isLoading: false));
|
emit(state.copyWith(isLoading: false));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onDelete(LogbookPhotoDeleteEvent _, Emitter emit) async {
|
Future<void> _onDelete(LogbookPhotoDeleteEvent _, Emitter emit) async {
|
||||||
emit(state.copyWith(isLoading: true));
|
emit(state.copyWith(isLoading: true));
|
||||||
await photosProvider.deleteProfile(_newPhoto);
|
await photosProvider.deleteLogbookPhoto(_newPhoto);
|
||||||
emit(state.copyWith(isLoading: false));
|
emit(state.copyWith(isLoading: false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import 'package:light_sensor/light_sensor.dart';
|
||||||
import 'package:lightmeter/data/analytics/analytics.dart';
|
import 'package:lightmeter/data/analytics/analytics.dart';
|
||||||
import 'package:lightmeter/data/analytics/api/analytics_firebase.dart';
|
import 'package:lightmeter/data/analytics/api/analytics_firebase.dart';
|
||||||
import 'package:lightmeter/data/caffeine_service.dart';
|
import 'package:lightmeter/data/caffeine_service.dart';
|
||||||
|
import 'package:lightmeter/data/geolocation_service.dart';
|
||||||
import 'package:lightmeter/data/haptics_service.dart';
|
import 'package:lightmeter/data/haptics_service.dart';
|
||||||
import 'package:lightmeter/data/light_sensor_service.dart';
|
import 'package:lightmeter/data/light_sensor_service.dart';
|
||||||
import 'package:lightmeter/data/models/supported_locale.dart';
|
import 'package:lightmeter/data/models/supported_locale.dart';
|
||||||
|
@ -153,6 +154,7 @@ class _MockApplicationWrapper extends StatelessWidget {
|
||||||
analytics: const LightmeterAnalytics(api: LightmeterAnalyticsFirebase()),
|
analytics: const LightmeterAnalytics(api: LightmeterAnalyticsFirebase()),
|
||||||
caffeineService: const CaffeineService(),
|
caffeineService: const CaffeineService(),
|
||||||
environment: const Environment.dev().copyWith(hasLightSensor: true),
|
environment: const Environment.dev().copyWith(hasLightSensor: true),
|
||||||
|
geolocationService: const GeolocationService(),
|
||||||
hapticsService: const HapticsService(),
|
hapticsService: const HapticsService(),
|
||||||
lightSensorService: const LightSensorService(LocalPlatform()),
|
lightSensorService: const LightSensorService(LocalPlatform()),
|
||||||
permissionsService: const PermissionsService(),
|
permissionsService: const PermissionsService(),
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:lightmeter/data/geolocation_service.dart';
|
||||||
import 'package:lightmeter/providers/logbook_photos_provider.dart';
|
import 'package:lightmeter/providers/logbook_photos_provider.dart';
|
||||||
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
|
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
|
||||||
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
||||||
|
@ -7,16 +8,22 @@ import 'package:mocktail/mocktail.dart';
|
||||||
|
|
||||||
class _MockLogbookPhotosStorageService extends Mock implements IapStorageService {}
|
class _MockLogbookPhotosStorageService extends Mock implements IapStorageService {}
|
||||||
|
|
||||||
|
class _MockGeolocationService extends Mock implements GeolocationService {}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
TestWidgetsFlutterBinding.ensureInitialized();
|
TestWidgetsFlutterBinding.ensureInitialized();
|
||||||
late _MockLogbookPhotosStorageService storageService;
|
late _MockLogbookPhotosStorageService storageService;
|
||||||
|
late _MockGeolocationService geolocationService;
|
||||||
|
|
||||||
setUpAll(() {
|
setUpAll(() {
|
||||||
storageService = _MockLogbookPhotosStorageService();
|
storageService = _MockLogbookPhotosStorageService();
|
||||||
|
geolocationService = _MockGeolocationService();
|
||||||
|
registerFallbackValue(ApertureValue.values.first);
|
||||||
|
registerFallbackValue(_customPhotos.first);
|
||||||
|
registerFallbackValue(ShutterSpeedValue.values.first);
|
||||||
});
|
});
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
registerFallbackValue(_customPhotos.first);
|
|
||||||
when(() => storageService.addPhoto(any<LogbookPhoto>())).thenAnswer((_) async {});
|
when(() => storageService.addPhoto(any<LogbookPhoto>())).thenAnswer((_) async {});
|
||||||
when(
|
when(
|
||||||
() => storageService.updatePhoto(
|
() => storageService.updatePhoto(
|
||||||
|
@ -30,6 +37,8 @@ void main() {
|
||||||
).thenAnswer((_) async {});
|
).thenAnswer((_) async {});
|
||||||
when(() => storageService.deletePhoto(any<String>())).thenAnswer((_) async {});
|
when(() => storageService.deletePhoto(any<String>())).thenAnswer((_) async {});
|
||||||
when(() => storageService.getPhotos()).thenAnswer((_) => Future.value(_customPhotos));
|
when(() => storageService.getPhotos()).thenAnswer((_) => Future.value(_customPhotos));
|
||||||
|
|
||||||
|
when(() => geolocationService.getCurrentPosition()).thenAnswer((_) => Future.value());
|
||||||
});
|
});
|
||||||
|
|
||||||
tearDown(() {
|
tearDown(() {
|
||||||
|
@ -48,6 +57,7 @@ void main() {
|
||||||
],
|
],
|
||||||
child: LogbookPhotosProvider(
|
child: LogbookPhotosProvider(
|
||||||
storageService: storageService,
|
storageService: storageService,
|
||||||
|
geolocationService: geolocationService,
|
||||||
child: const _Application(),
|
child: const _Application(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -128,11 +138,19 @@ void main() {
|
||||||
expectLogbookPhotosCount(0);
|
expectLogbookPhotosCount(0);
|
||||||
expectLogbookPhotosEnabled(true);
|
expectLogbookPhotosEnabled(true);
|
||||||
|
|
||||||
|
/// Create a photo
|
||||||
|
final photo = await tester.logbookPhotosProvider.addPhotoIfPossible(
|
||||||
|
_customPhotos.first.name,
|
||||||
|
ev100: _customPhotos.first.ev,
|
||||||
|
iso: _customPhotos.first.iso,
|
||||||
|
nd: _customPhotos.first.nd,
|
||||||
|
);
|
||||||
|
|
||||||
/// Update a photo
|
/// Update a photo
|
||||||
final updatedPhoto = _customPhotos.first.copyWith(note: 'Updated note');
|
final updatedPhoto = photo!.copyWith(note: 'Updated note');
|
||||||
await tester.logbookPhotosProvider.updateProfile(updatedPhoto);
|
await tester.logbookPhotosProvider.updateLogbookPhoto(updatedPhoto);
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expectLogbookPhotosCount(0); // No photos loaded initially
|
expectLogbookPhotosCount(1); // No photos loaded initially
|
||||||
verify(
|
verify(
|
||||||
() => storageService.updatePhoto(
|
() => storageService.updatePhoto(
|
||||||
id: updatedPhoto.id,
|
id: updatedPhoto.id,
|
||||||
|
@ -143,10 +161,10 @@ void main() {
|
||||||
).called(1);
|
).called(1);
|
||||||
|
|
||||||
/// Delete a photo
|
/// Delete a photo
|
||||||
await tester.logbookPhotosProvider.deleteProfile(_customPhotos.first);
|
await tester.logbookPhotosProvider.deleteLogbookPhoto(updatedPhoto);
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expectLogbookPhotosCount(0);
|
expectLogbookPhotosCount(0);
|
||||||
verify(() => storageService.deletePhoto(_customPhotos.first.id)).called(1);
|
verify(() => storageService.deletePhoto(updatedPhoto.id)).called(1);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -162,7 +180,7 @@ void main() {
|
||||||
|
|
||||||
// Try to add photo when disabled
|
// Try to add photo when disabled
|
||||||
await tester.logbookPhotosProvider.addPhotoIfPossible(
|
await tester.logbookPhotosProvider.addPhotoIfPossible(
|
||||||
'test_path.jpg',
|
'assets/camera_stub_image.jpg',
|
||||||
ev100: 12.0,
|
ev100: 12.0,
|
||||||
iso: 100,
|
iso: 100,
|
||||||
nd: 0,
|
nd: 0,
|
||||||
|
@ -228,7 +246,7 @@ class _LogbookPhotosEnabled extends StatelessWidget {
|
||||||
final List<LogbookPhoto> _customPhotos = [
|
final List<LogbookPhoto> _customPhotos = [
|
||||||
LogbookPhoto(
|
LogbookPhoto(
|
||||||
id: '1',
|
id: '1',
|
||||||
name: 'test_photo_1.jpg',
|
name: 'assets/camera_stub_image.jpg',
|
||||||
timestamp: DateTime(2024, 1, 1, 12),
|
timestamp: DateTime(2024, 1, 1, 12),
|
||||||
ev: 12.0,
|
ev: 12.0,
|
||||||
iso: 100,
|
iso: 100,
|
||||||
|
@ -237,7 +255,7 @@ final List<LogbookPhoto> _customPhotos = [
|
||||||
),
|
),
|
||||||
LogbookPhoto(
|
LogbookPhoto(
|
||||||
id: '2',
|
id: '2',
|
||||||
name: 'test_photo_2.jpg',
|
name: 'assets/camera_stub_image.jpg',
|
||||||
timestamp: DateTime(2024, 1, 2, 12),
|
timestamp: DateTime(2024, 1, 2, 12),
|
||||||
ev: 13.0,
|
ev: 13.0,
|
||||||
iso: 200,
|
iso: 200,
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import 'package:bloc_test/bloc_test.dart';
|
import 'package:bloc_test/bloc_test.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:lightmeter/data/models/volume_action.dart';
|
import 'package:lightmeter/data/models/volume_action.dart';
|
||||||
import 'package:lightmeter/interactors/metering_interactor.dart';
|
import 'package:lightmeter/interactors/metering_interactor.dart';
|
||||||
|
import 'package:lightmeter/providers/logbook_photos_provider.dart';
|
||||||
import 'package:lightmeter/screens/metering/bloc_metering.dart';
|
import 'package:lightmeter/screens/metering/bloc_metering.dart';
|
||||||
import 'package:lightmeter/screens/metering/communication/bloc_communication_metering.dart';
|
import 'package:lightmeter/screens/metering/communication/bloc_communication_metering.dart';
|
||||||
import 'package:lightmeter/screens/metering/communication/event_communication_metering.dart' as communication_events;
|
import 'package:lightmeter/screens/metering/communication/event_communication_metering.dart' as communication_events;
|
||||||
|
@ -20,11 +22,17 @@ class _MockMeteringCommunicationBloc
|
||||||
extends MockBloc<communication_events.MeteringCommunicationEvent, communication_states.MeteringCommunicationState>
|
extends MockBloc<communication_events.MeteringCommunicationEvent, communication_states.MeteringCommunicationState>
|
||||||
implements MeteringCommunicationBloc {}
|
implements MeteringCommunicationBloc {}
|
||||||
|
|
||||||
|
class _MockLogbookPhotosProviderState extends Mock implements LogbookPhotosProviderState {
|
||||||
|
@override
|
||||||
|
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) => '_MockLogbookPhotosProviderState';
|
||||||
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
late _MockMeteringInteractor meteringInteractor;
|
late _MockMeteringInteractor meteringInteractor;
|
||||||
late _MockVolumeKeysNotifier volumeKeysNotifier;
|
late _MockVolumeKeysNotifier volumeKeysNotifier;
|
||||||
late _MockMeteringCommunicationBloc communicationBloc;
|
late _MockMeteringCommunicationBloc communicationBloc;
|
||||||
late MeteringBloc bloc;
|
late MeteringBloc bloc;
|
||||||
|
late _MockLogbookPhotosProviderState logbookPhotosProvider;
|
||||||
const iso100 = IsoValue(100, StopType.full);
|
const iso100 = IsoValue(100, StopType.full);
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
|
@ -37,11 +45,13 @@ void main() {
|
||||||
|
|
||||||
volumeKeysNotifier = _MockVolumeKeysNotifier();
|
volumeKeysNotifier = _MockVolumeKeysNotifier();
|
||||||
communicationBloc = _MockMeteringCommunicationBloc();
|
communicationBloc = _MockMeteringCommunicationBloc();
|
||||||
|
logbookPhotosProvider = _MockLogbookPhotosProviderState();
|
||||||
|
|
||||||
bloc = MeteringBloc(
|
bloc = MeteringBloc(
|
||||||
meteringInteractor,
|
meteringInteractor,
|
||||||
volumeKeysNotifier,
|
volumeKeysNotifier,
|
||||||
communicationBloc,
|
communicationBloc,
|
||||||
|
logbookPhotosProvider,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 497 KiB After Width: | Height: | Size: 474 KiB |
Loading…
Reference in a new issue