m3_lightmeter/lib/screens/metering/components/shared/ev_source_base/bloc_base_ev_source.dart
Vadim 74d0a7101c
ML-62 Bloc's tests (#78)
* 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
2023-06-20 08:43:49 +02:00

27 lines
1 KiB
Dart

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:lightmeter/screens/metering/communication/bloc_communication_metering.dart';
import 'package:lightmeter/screens/metering/communication/state_communication_metering.dart'
as communication_states;
abstract class EvSourceBlocBase<E, S> extends Bloc<E, S> {
final MeteringCommunicationBloc communicationBloc;
late final StreamSubscription<communication_states.SourceState> _communicationSubscription;
EvSourceBlocBase(this.communicationBloc, super.initialState) {
_communicationSubscription = communicationBloc.stream
.where((event) => event is communication_states.SourceState)
.map((event) => event as communication_states.SourceState)
.listen(onCommunicationState);
}
@override
Future<void> close() async {
await _communicationSubscription.cancel();
return super.close();
}
@visibleForTesting
void onCommunicationState(communication_states.SourceState communicationState);
}