mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-27 01:40:40 +00:00
74d0a7101c
* removed redundant `UserPreferencesService` from `MeteringBloc` * wip * post-merge fixes * `MeasureEvent` tests * `MeasureEvent` tests revision * `MeasureEvent` tests added timeout * added stubs for other `MeteringBloc` events * rewritten `MeteringBloc` logic * wip * `IsoChangedEvent` tests * refined `IsoChangedEvent` tests * `NdChangedEvent` tests * `FilmChangedEvent` tests * `MeteringCommunicationBloc` tests * added test run to ci * overriden `==` for `MeasuredState` * `LuxMeteringEvent` tests * refined `LuxMeteringEvent` tests * rename * wip * wip * `InitializeEvent`/`DeinitializeEvent` tests * clamp minZoomLevel * fixed `MeteringCommunicationBloc` tests * wip * `ZoomChangedEvent` tests * `ExposureOffsetChangedEvent`/`ExposureOffsetResetEvent` tests * renamed test groups * added test coverage script * improved `CameraContainerBloc` test coverage * `EquipmentProfileChangedEvent` tests * verify response vibration * fixed running all tests * `MeteringCommunicationBloc` equality tests * `CameraContainerBloc` equality tests * removed generated code from coverage
101 lines
3.3 KiB
Dart
101 lines
3.3 KiB
Dart
import 'package:bloc_test/bloc_test.dart';
|
|
import 'package:lightmeter/screens/metering/communication/bloc_communication_metering.dart';
|
|
import 'package:lightmeter/screens/metering/communication/event_communication_metering.dart';
|
|
import 'package:lightmeter/screens/metering/communication/state_communication_metering.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
void main() {
|
|
late MeteringCommunicationBloc bloc;
|
|
|
|
setUp(() {
|
|
bloc = MeteringCommunicationBloc();
|
|
});
|
|
|
|
tearDown(() {
|
|
bloc.close();
|
|
});
|
|
|
|
group(
|
|
'`MeasureEvent`',
|
|
() {
|
|
blocTest<MeteringCommunicationBloc, MeteringCommunicationState>(
|
|
'Multiple consequtive measure events',
|
|
build: () => bloc,
|
|
act: (bloc) async {
|
|
bloc.add(const MeasureEvent());
|
|
bloc.add(const MeasureEvent());
|
|
bloc.add(const MeasureEvent());
|
|
bloc.add(const MeasureEvent());
|
|
},
|
|
expect: () => [
|
|
isA<MeasureState>(),
|
|
isA<MeasureState>(),
|
|
isA<MeasureState>(),
|
|
isA<MeasureState>(),
|
|
],
|
|
);
|
|
|
|
blocTest<MeteringCommunicationBloc, MeteringCommunicationState>(
|
|
'Continuous metering simulation',
|
|
build: () => bloc,
|
|
act: (bloc) async {
|
|
bloc.add(const MeasureEvent());
|
|
bloc.add(const MeteringInProgressEvent(1));
|
|
bloc.add(const MeteringInProgressEvent(null));
|
|
bloc.add(const MeteringInProgressEvent(null));
|
|
bloc.add(const MeteringInProgressEvent(2));
|
|
bloc.add(const MeasureEvent());
|
|
bloc.add(const MeteringEndedEvent(2));
|
|
bloc.add(const MeteringEndedEvent(2));
|
|
},
|
|
expect: () => [
|
|
isA<MeasureState>(),
|
|
isA<MeteringInProgressState>().having((state) => state.ev100, 'ev100', 1),
|
|
isA<MeteringInProgressState>().having((state) => state.ev100, 'ev100', null),
|
|
isA<MeteringInProgressState>().having((state) => state.ev100, 'ev100', 2),
|
|
isA<MeasureState>(),
|
|
isA<MeteringEndedState>().having((state) => state.ev100, 'ev100', 2),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
|
|
group(
|
|
'`MeteringInProgressEvent`',
|
|
() {
|
|
blocTest<MeteringCommunicationBloc, MeteringCommunicationState>(
|
|
'Multiple consequtive in progress events',
|
|
build: () => bloc,
|
|
act: (bloc) async {
|
|
bloc.add(const MeteringInProgressEvent(1));
|
|
bloc.add(const MeteringInProgressEvent(1));
|
|
bloc.add(const MeteringInProgressEvent(1));
|
|
bloc.add(const MeteringInProgressEvent(null));
|
|
bloc.add(const MeteringInProgressEvent(null));
|
|
bloc.add(const MeteringInProgressEvent(2));
|
|
},
|
|
expect: () => [
|
|
isA<MeteringInProgressState>().having((state) => state.ev100, 'ev100', 1),
|
|
isA<MeteringInProgressState>().having((state) => state.ev100, 'ev100', null),
|
|
isA<MeteringInProgressState>().having((state) => state.ev100, 'ev100', 2),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
|
|
group(
|
|
'`MeteringEndedEvent`',
|
|
() {
|
|
blocTest<MeteringCommunicationBloc, MeteringCommunicationState>(
|
|
'Multiple consequtive ended events',
|
|
build: () => bloc,
|
|
act: (bloc) async {
|
|
bloc.add(const MeteringEndedEvent(1));
|
|
},
|
|
expect: () => [
|
|
isA<MeteringEndedState>().having((state) => state.ev100, 'ev100', 1),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|