mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2025-02-21 03:50:40 +00:00
EquipmentProfileChangedEvent
tests
This commit is contained in:
parent
dca34f6721
commit
2a7463184b
2 changed files with 124 additions and 9 deletions
|
@ -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) {
|
||||
|
|
|
@ -485,11 +485,126 @@ void main() {
|
|||
},
|
||||
);
|
||||
|
||||
// TODO(vodemn): when this feautre is enabled
|
||||
// group(
|
||||
// '`EquipmentProfileChangedEvent`',
|
||||
// () {
|
||||
//
|
||||
// },
|
||||
// );
|
||||
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),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue