From 83476a50362332849b28c774bb84a91419372db4 Mon Sep 17 00:00:00 2001 From: Vadim Date: Sun, 9 Jul 2023 13:33:58 +0200 Subject: [PATCH] fixed `CameraContainerBloc` tests --- .../bloc_container_camera.dart | 3 ++- .../camera/bloc_container_camera_test.dart | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/screens/metering/components/camera_container/bloc_container_camera.dart b/lib/screens/metering/components/camera_container/bloc_container_camera.dart index 8868f7e..7f00256 100644 --- a/lib/screens/metering/components/camera_container/bloc_container_camera.dart +++ b/lib/screens/metering/components/camera_container/bloc_container_camera.dart @@ -159,7 +159,8 @@ class CameraContainerBloc extends EvSourceBlocBase _onDeinitialize(DeinitializeEvent _, Emitter emit) async { - emit(const CameraLoadingState()); + emit(const CameraInitState()); + communicationBloc.add(communication_event.MeteringEndedEvent(_ev100)); await _cameraController?.dispose().then((_) => _cameraController = null); } diff --git a/test/screens/metering/components/camera/bloc_container_camera_test.dart b/test/screens/metering/components/camera/bloc_container_camera_test.dart index 298d5b8..fa08edf 100644 --- a/test/screens/metering/components/camera/bloc_container_camera_test.dart +++ b/test/screens/metering/components/camera/bloc_container_camera_test.dart @@ -310,6 +310,30 @@ void main() { }, expect: () => [ ...initializedStateSequence, + const CameraInitState(), + ...initializedStateSequence, + ], + ); + + blocTest( + 'onCommunicationState', + setUp: () { + when(() => meteringInteractor.checkCameraPermission()).thenAnswer((_) async => true); + }, + build: () => bloc, + act: (bloc) async { + bloc.add(const InitializeEvent()); + await Future.delayed(Duration.zero); + bloc.onCommunicationState(const communication_states.SettingsOpenedState()); + await Future.delayed(Duration.zero); + bloc.onCommunicationState(const communication_states.SettingsClosedState()); + }, + verify: (_) { + verify(() => meteringInteractor.checkCameraPermission()).called(2); + }, + expect: () => [ + ...initializedStateSequence, + const CameraInitState(), ...initializedStateSequence, ], );