Compare commits

..

No commits in common. "2a7463184bc2e8c2d2eaa8ff1201c8848e826753" and "f9b18330cd89f053390bcbeab3e663897461ec0d" have entirely different histories.

7 changed files with 39 additions and 207 deletions

2
.gitignore vendored
View file

@ -58,5 +58,3 @@ android/app/google-services.json
ios/firebase_app_id_file.json
ios/Runner/GoogleService-Info.plist
lib/firebase_options.dart
coverage/

View file

@ -90,7 +90,7 @@ class MeteringBloc extends Bloc<MeteringEvent, MeteringState> {
iso = event.equipmentProfileData.isoValues.first;
_meteringInteractor.film = Film.values.first;
film = Film.values.first;
willUpdateMeasurements = true;
willUpdateMeasurements &= true;
}
/// The same for ND filter
@ -98,7 +98,7 @@ class MeteringBloc extends Bloc<MeteringEvent, MeteringState> {
if (!event.equipmentProfileData.ndValues.any((v) => state.nd.value == v.value)) {
_meteringInteractor.ndFilter = event.equipmentProfileData.ndValues.first;
nd = event.equipmentProfileData.ndValues.first;
willUpdateMeasurements = true;
willUpdateMeasurements &= true;
}
if (willUpdateMeasurements) {

View file

@ -50,7 +50,7 @@ void main() {
});
group(
'`MeasureEvent`',
'`MeasureEvent` tests',
() {
blocTest<MeteringBloc, MeteringState>(
'`MeasureEvent` -> success',
@ -144,7 +144,7 @@ void main() {
);
group(
'`IsoChangedEvent`',
'`IsoChangedEvent` tests',
() {
blocTest<MeteringBloc, MeteringState>(
'Pick different ISO (ev100 != null)',
@ -263,7 +263,7 @@ void main() {
);
group(
'`NdChangedEvent`',
'`NdChangedEvent` tests',
() {
blocTest<MeteringBloc, MeteringState>(
'Pick different ND (ev100 != null)',
@ -378,7 +378,7 @@ void main() {
);
group(
'`FilmChangedEvent`',
'`FilmChangedEvent` tests',
() {
blocTest<MeteringBloc, MeteringState>(
'Pick different film with different ISO',
@ -485,126 +485,11 @@ void main() {
},
);
group(
'`EquipmentProfileChangedEvent`',
() {
final reducedProfile = EquipmentProfileData(
id: '0',
name: 'Reduced',
apertureValues: ApertureValue.values,
ndValues: NdValue.values.getRange(0, 3).toList(),
shutterSpeedValues: ShutterSpeedValue.values,
isoValues: IsoValue.values.getRange(4, 23).toList(),
);
blocTest<MeteringBloc, MeteringState>(
'New profile has current ISO & ND',
build: () => bloc,
seed: () => MeteringDataState(
ev100: 1.0,
film: Film.values[1],
iso: const IsoValue(100, StopType.full),
nd: NdValue.values.first,
isMetering: false,
),
act: (bloc) async {
bloc.add(EquipmentProfileChangedEvent(reducedProfile));
},
verify: (_) {
verifyNever(() => meteringInteractor.film = const Film.other());
verifyNever(() => meteringInteractor.iso = reducedProfile.isoValues.first);
verifyNever(() => meteringInteractor.ndFilter = reducedProfile.ndValues.first);
verifyNever(() => meteringInteractor.responseVibration());
},
expect: () => [],
);
blocTest<MeteringBloc, MeteringState>(
'New profile has new ISO & current ND',
build: () => bloc,
seed: () => MeteringDataState(
ev100: 1.0,
film: Film.values[1],
iso: IsoValue.values[2],
nd: NdValue.values.first,
isMetering: false,
),
act: (bloc) async {
bloc.add(EquipmentProfileChangedEvent(reducedProfile));
},
verify: (_) {
verify(() => meteringInteractor.film = const Film.other()).called(1);
verify(() => meteringInteractor.iso = reducedProfile.isoValues.first).called(1);
verifyNever(() => meteringInteractor.ndFilter = reducedProfile.ndValues.first);
verify(() => meteringInteractor.responseVibration()).called(1);
},
expect: () => [
isA<MeteringDataState>()
.having((state) => state.ev100, 'ev100', 1.0)
.having((state) => state.film, 'film', const Film.other())
.having((state) => state.iso, 'iso', reducedProfile.isoValues.first)
.having((state) => state.nd, 'nd', NdValue.values.first)
.having((state) => state.isMetering, 'isMetering', false),
],
);
blocTest<MeteringBloc, MeteringState>(
'New profile has current ISO & new ND',
build: () => bloc,
seed: () => MeteringDataState(
ev100: 1.0,
film: Film.values[1],
iso: const IsoValue(100, StopType.full),
nd: NdValue.values[4],
isMetering: false,
),
act: (bloc) async {
bloc.add(EquipmentProfileChangedEvent(reducedProfile));
},
verify: (_) {
verifyNever(() => meteringInteractor.film = const Film.other());
verifyNever(() => meteringInteractor.iso = reducedProfile.isoValues.first);
verify(() => meteringInteractor.ndFilter = reducedProfile.ndValues.first).called(1);
verify(() => meteringInteractor.responseVibration()).called(1);
},
expect: () => [
isA<MeteringDataState>()
.having((state) => state.ev100, 'ev100', 1.0)
.having((state) => state.film, 'film', Film.values[1])
.having((state) => state.iso, 'iso', const IsoValue(100, StopType.full))
.having((state) => state.nd, 'nd', reducedProfile.ndValues.first)
.having((state) => state.isMetering, 'isMetering', false),
],
);
blocTest<MeteringBloc, MeteringState>(
'New profile has new ISO & new ND',
build: () => bloc,
seed: () => MeteringDataState(
ev100: 1.0,
film: Film.values[1],
iso: IsoValue.values[2],
nd: NdValue.values[4],
isMetering: false,
),
act: (bloc) async {
bloc.add(EquipmentProfileChangedEvent(reducedProfile));
},
verify: (_) {
verify(() => meteringInteractor.film = const Film.other()).called(1);
verify(() => meteringInteractor.iso = reducedProfile.isoValues.first).called(1);
verify(() => meteringInteractor.ndFilter = reducedProfile.ndValues.first).called(1);
verify(() => meteringInteractor.responseVibration()).called(1);
},
expect: () => [
isA<MeteringDataState>()
.having((state) => state.ev100, 'ev100', 1.0)
.having((state) => state.film, 'film', const Film.other())
.having((state) => state.iso, 'iso', reducedProfile.isoValues.first)
.having((state) => state.nd, 'nd', reducedProfile.ndValues.first)
.having((state) => state.isMetering, 'isMetering', false),
],
);
},
);
// TODO(vodemn): when this feautre is enabled
// group(
// '`EquipmentProfileChangedEvent` tests',
// () {
//
// },
// );
}

View file

@ -16,7 +16,7 @@ void main() {
});
group(
'`MeasureEvent`',
'`MeasureEvent` tests',
() {
blocTest<MeteringCommunicationBloc, MeteringCommunicationState>(
'Multiple consequtive measure events',
@ -60,7 +60,7 @@ void main() {
);
group(
'`MeteringInProgressEvent`',
'`MeteringInProgressEvent` tests',
() {
blocTest<MeteringCommunicationBloc, MeteringCommunicationState>(
'Multiple consequtive in progress events',
@ -83,7 +83,7 @@ void main() {
);
group(
'`MeteringEndedEvent`',
'`MeteringEndedEvent` tests',
() {
blocTest<MeteringCommunicationBloc, MeteringCommunicationState>(
'Multiple consequtive ended events',

View file

@ -41,25 +41,10 @@ void main() {
"sensorOrientation": 0,
},
];
const frontCameras = [
{
"name": "front",
"lensFacing": "front",
"sensorOrientation": 0,
},
{
"name": "front2",
"lensFacing": "front",
"sensorOrientation": 0,
},
];
Future<Object?>? cameraMethodCallSuccessHandler(
MethodCall methodCall, {
List<Map<String, Object>> cameras = availableCameras,
}) async {
Future<Object?>? cameraMethodCallSuccessHandler(MethodCall methodCall) async {
switch (methodCall.method) {
case "availableCameras":
return cameras;
return availableCameras;
case "create":
return {"cameraId": 1};
case "initialize":
@ -134,7 +119,7 @@ void main() {
});
group(
'`RequestPermissionEvent`',
'`RequestPermissionEvent` tests',
() {
blocTest<CameraContainerBloc, CameraContainerState>(
'Request denied',
@ -183,33 +168,15 @@ void main() {
verify(() => meteringInteractor.requestPermission()).called(1);
verify(() => meteringInteractor.checkCameraPermission()).called(1);
},
expect: () => initializedStateSequence,
expect: () => [
...initializedStateSequence,
],
);
},
);
group(
'`OpenAppSettingsEvent`',
() {
blocTest<CameraContainerBloc, CameraContainerState>(
'App settings opened',
setUp: () {
when(() => meteringInteractor.openAppSettings()).thenAnswer((_) {});
},
build: () => bloc,
act: (bloc) async {
bloc.add(const OpenAppSettingsEvent());
},
verify: (_) {
verify(() => meteringInteractor.openAppSettings()).called(1);
},
expect: () => [],
);
},
);
group(
'`InitializeEvent`/`DeinitializeEvent`',
'`InitializeEvent`/`DeinitializeEvent` tests',
() {
blocTest<CameraContainerBloc, CameraContainerState>(
'No cameras detected error',
@ -218,7 +185,14 @@ void main() {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(
cameraMethodChannel,
(methodCall) async => cameraMethodCallSuccessHandler(methodCall, cameras: const []),
(methodCall) async {
switch (methodCall.method) {
case "availableCameras":
return const [];
default:
return null;
}
},
);
},
tearDown: () {
@ -237,28 +211,6 @@ void main() {
],
);
blocTest<CameraContainerBloc, CameraContainerState>(
'No back facing cameras available',
setUp: () {
when(() => meteringInteractor.checkCameraPermission()).thenAnswer((_) async => true);
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(
cameraMethodChannel,
(methodCall) async => cameraMethodCallSuccessHandler(methodCall, cameras: frontCameras),
);
},
tearDown: () {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(cameraMethodChannel, null);
},
build: () => bloc,
act: (bloc) => bloc.add(const InitializeEvent()),
verify: (_) {
verify(() => meteringInteractor.checkCameraPermission()).called(1);
},
expect: () => initializedStateSequence,
);
blocTest<CameraContainerBloc, CameraContainerState>(
'Catch other initialization errors',
setUp: () {
@ -317,7 +269,7 @@ void main() {
);
group(
'`_takePicture()`',
'`_takePicture()` tests',
() {
blocTest<CameraContainerBloc, CameraContainerState>(
'Returned ev100 == null',
@ -329,15 +281,14 @@ void main() {
bloc.add(const InitializeEvent());
await Future.delayed(Duration.zero);
bloc.onCommunicationState(const communication_states.MeasureState());
bloc.onCommunicationState(const communication_states.MeasureState());
bloc.onCommunicationState(const communication_states.MeasureState());
bloc.onCommunicationState(const communication_states.MeasureState());
},
verify: (_) {
verify(() => meteringInteractor.checkCameraPermission()).called(1);
verifyNever(() => meteringInteractor.cameraEvCalibration);
},
expect: () => initializedStateSequence,
expect: () => [
...initializedStateSequence,
],
);
// TODO(vodemn): figure out how to mock `_file.readAsBytes()`
@ -370,10 +321,11 @@ void main() {
// ],
// );
},
skip: true,
);
group(
'`ZoomChangedEvent`',
'`ZoomChangedEvent` tests',
() {
blocTest<CameraContainerBloc, CameraContainerState>(
'Set zoom multiple times',
@ -420,7 +372,7 @@ void main() {
);
group(
'`ExposureOffsetChangedEvent`/`ExposureOffsetResetEvent`',
'`ExposureOffsetChangedEvent`/`ExposureOffsetResetEvent` tests',
() {
blocTest<CameraContainerBloc, CameraContainerState>(
'Set exposure offset multiple times and reset',

View file

@ -39,7 +39,7 @@ void main() {
});
group(
'`LuxMeteringEvent`',
'`LuxMeteringEvent` tests',
() {
const List<int> luxIterable = [1, 2, 2, 2, 3];
final List<double> resultList = luxIterable.map((lux) => log2(lux / 2.5)).toList();

View file

@ -1,3 +0,0 @@
flutter test --coverage
genhtml coverage/lcov.info -o coverage/html
open coverage/html/index.html